本文整理汇总了PHP中add_create_account函数的典型用法代码示例。如果您正苦于以下问题:PHP add_create_account函数的具体用法?PHP add_create_account怎么用?PHP add_create_account使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了add_create_account函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: new_handle_set_entries
function new_handle_set_entries($module_name, $name_value_lists, $select_fields = FALSE)
{
global $beanList, $beanFiles, $app_list_strings;
global $current_user;
$ret_values = array();
$class_name = $beanList[$module_name];
require_once $beanFiles[$class_name];
$ids = array();
$count = 1;
$total = sizeof($name_value_lists);
foreach ($name_value_lists as $name_value_list) {
$seed = new $class_name();
$seed->update_vcal = false;
foreach ($name_value_list as $value) {
if ($value['name'] == 'id') {
$seed->retrieve($value['value']);
break;
}
}
foreach ($name_value_list as $value) {
$val = $value['value'];
if ($seed->field_name_map[$value['name']]['type'] == 'enum') {
$vardef = $seed->field_name_map[$value['name']];
if (isset($app_list_strings[$vardef['options']]) && !isset($app_list_strings[$vardef['options']][$value])) {
if (in_array($val, $app_list_strings[$vardef['options']])) {
$val = array_search($val, $app_list_strings[$vardef['options']]);
}
}
}
$seed->{$value}['name'] = $val;
}
if ($count == $total) {
$seed->update_vcal = false;
}
$count++;
//Add the account to a contact
if ($module_name == 'Contacts') {
Log::debug('Creating Contact Account');
add_create_account($seed);
$duplicate_id = check_for_duplicate_contacts($seed);
if ($duplicate_id == null) {
if ($seed->ACLAccess('Save') && ($seed->deleted != 1 || $seed->ACLAccess('Delete'))) {
$seed->save();
if ($seed->deleted == 1) {
$seed->mark_deleted($seed->id);
}
$ids[] = $seed->id;
}
} else {
//since we found a duplicate we should set the sync flag
if ($seed->ACLAccess('Save')) {
$seed = new $class_name();
$seed->id = $duplicate_id;
$seed->contacts_users_id = $current_user->id;
$seed->save();
$ids[] = $duplicate_id;
//we have a conflict
}
}
} else {
if ($module_name == 'Meetings' || $module_name == 'Calls') {
//we are going to check if we have a meeting in the system
//with the same outlook_id. If we do find one then we will grab that
//id and save it
if ($seed->ACLAccess('Save') && ($seed->deleted != 1 || $seed->ACLAccess('Delete'))) {
if (empty($seed->id) && !isset($seed->id)) {
if (!empty($seed->outlook_id) && isset($seed->outlook_id)) {
//at this point we have an object that does not have
//the id set, but does have the outlook_id set
//so we need to query the db to find if we already
//have an object with this outlook_id, if we do
//then we can set the id, otherwise this is a new object
$order_by = "";
$query = $seed->table_name . ".outlook_id = '" . $GLOBALS['db']->quote($seed->outlook_id) . "'";
$response = $seed->get_list($order_by, $query, 0, -1, -1, 0);
$list = $response['list'];
if (count($list) > 0) {
foreach ($list as $value) {
$seed->id = $value->id;
break;
}
}
//fi
}
//fi
}
//fi
$seed->save();
if ($seed->deleted == 1) {
$seed->mark_deleted($seed->id);
}
$ids[] = $seed->id;
}
//fi
} else {
if ($seed->ACLAccess('Save') && ($seed->deleted != 1 || $seed->ACLAccess('Delete'))) {
$seed->save();
$ids[] = $seed->id;
}
}
//.........这里部分代码省略.........
示例2: handle_set_entries
function handle_set_entries($module_name, $name_value_lists, $select_fields = FALSE)
{
global $beanList, $beanFiles, $app_list_strings, $current_user;
$error = new SoapError();
$ret_values = array();
if (empty($beanList[$module_name])) {
$error->set_error('no_module');
return array('ids' => array(), 'error' => $error->get_soap_array());
}
if (!check_modules_access($current_user, $module_name, 'write')) {
$error->set_error('no_access');
return array('ids' => -1, 'error' => $error->get_soap_array());
}
$class_name = $beanList[$module_name];
require_once $beanFiles[$class_name];
$ids = array();
$count = 1;
$total = sizeof($name_value_lists);
foreach ($name_value_lists as $name_value_list) {
$seed = new $class_name();
$seed->update_vcal = false;
//See if we can retrieve the seed by a given id value
foreach ($name_value_list as $value) {
if ($value['name'] == 'id') {
$seed->retrieve($value['value']);
break;
}
}
$dataValues = array();
foreach ($name_value_list as $value) {
$val = $value['value'];
if ($seed->field_name_map[$value['name']]['type'] == 'enum' || $seed->field_name_map[$value['name']]['type'] == 'radioenum') {
$vardef = $seed->field_name_map[$value['name']];
if (isset($app_list_strings[$vardef['options']]) && !isset($app_list_strings[$vardef['options']][$val])) {
if (in_array($val, $app_list_strings[$vardef['options']])) {
$val = array_search($val, $app_list_strings[$vardef['options']]);
}
}
} else {
if ($seed->field_name_map[$value['name']]['type'] == 'multienum') {
$vardef = $seed->field_name_map[$value['name']];
if (isset($app_list_strings[$vardef['options']]) && !isset($app_list_strings[$vardef['options']][$value])) {
$items = explode(",", $val);
$parsedItems = array();
foreach ($items as $item) {
if (in_array($item, $app_list_strings[$vardef['options']])) {
$keyVal = array_search($item, $app_list_strings[$vardef['options']]);
array_push($parsedItems, $keyVal);
}
}
if (!empty($parsedItems)) {
$val = encodeMultienumValue($parsedItems);
}
}
}
}
//Apply the non-empty values now since this will be used for duplicate checks
//allow string or int of 0 to be updated if set.
if (!empty($val) || ($val === '0' || $val === 0)) {
$seed->{$value}['name'] = $val;
}
//Store all the values in dataValues Array to apply later
$dataValues[$value['name']] = $val;
}
if ($count == $total) {
$seed->update_vcal = false;
}
$count++;
//Add the account to a contact
if ($module_name == 'Contacts') {
$GLOBALS['log']->debug('Creating Contact Account');
add_create_account($seed);
$duplicate_id = check_for_duplicate_contacts($seed);
if ($duplicate_id == null) {
if ($seed->ACLAccess('Save') && ($seed->deleted != 1 || $seed->ACLAccess('Delete'))) {
//Now apply the values, since this is not a duplicate we can just pass false for the $firstSync argument
apply_values($seed, $dataValues, false);
$seed->save();
if ($seed->deleted == 1) {
$seed->mark_deleted($seed->id);
}
$ids[] = $seed->id;
}
} else {
//since we found a duplicate we should set the sync flag
if ($seed->ACLAccess('Save')) {
//Determine if this is a first time sync. We find out based on whether or not a contacts_users relationship exists
$seed->id = $duplicate_id;
$seed->load_relationship("user_sync");
$beans = $seed->user_sync->getBeans();
$first_sync = empty($beans);
//Now apply the values and indicate whether or not this is a first time sync
apply_values($seed, $dataValues, $first_sync);
$seed->contacts_users_id = $current_user->id;
$seed->save();
$ids[] = $duplicate_id;
//we have a conflict
}
}
} else {
//.........这里部分代码省略.........
示例3: set_entries
/**
* Update or create a list of SugarBeans
*
* @param String $session -- Session ID returned by a previous call to login.
* @param String $module_name -- The name of the module to return records from. This name should be the name the module was developed under (changing a tab name is studio does not affect the name that should be passed into this method)..
* @param Array $name_value_lists -- Array of Bean specific Arrays where the keys of the array are the SugarBean attributes, the values of the array are the values the attributes should have.
* @return Array 'ids' -- Array of the IDs of the beans that was written to (-1 on error)
* 'error' -- The SOAP error if any.
*/
function set_entries($session, $module_name, $name_value_lists)
{
global $beanList, $beanFiles;
$error = new SoapError();
if (!validate_authenticated($session)) {
$error->set_error('invalid_login');
return array('ids' => array(), 'error' => $error->get_soap_array());
}
if (empty($beanList[$module_name])) {
$error->set_error('no_module');
return array('ids' => array(), 'error' => $error->get_soap_array());
}
global $current_user;
if (!check_modules_access($current_user, $module_name, 'write')) {
$error->set_error('no_access');
return array('ids' => -1, 'error' => $error->get_soap_array());
}
$class_name = $beanList[$module_name];
require_once $beanFiles[$class_name];
$ids = array();
$count = 1;
$total = sizeof($name_value_lists);
foreach ($name_value_lists as $name_value_list) {
$seed = new $class_name();
$seed->update_vcal = false;
foreach ($name_value_list as $value) {
$seed->{$value}['name'] = $value['value'];
}
if ($count == $total) {
$seed->update_vcal = false;
}
$count++;
//Add the account to a contact
if ($module_name == 'Contacts') {
$GLOBALS['log']->debug('Creating Contact Account');
add_create_account($seed);
$duplicate_id = check_for_duplicate_contacts($seed);
if ($duplicate_id == null) {
if ($seed->ACLAccess('Save')) {
$seed->save();
if ($seed->deleted == 1) {
$seed->mark_deleted($seed->id);
}
$ids[] = $seed->id;
}
} else {
//since we found a duplicate we should set the sync flag
if ($seed->ACLAccess('Save')) {
$seed->id = $duplicate_id;
$seed->save();
$ids[] = $duplicate_id;
//we have a conflict
}
}
} else {
if ($module_name == 'Meetings' || $module_name == 'Calls') {
//we are going to check if we have a meeting in the system
//with the same outlook_id. If we do find one then we will grab that
//id and save it
if ($seed->ACLAccess('Save')) {
if (empty($seed->id) && !isset($seed->id)) {
if (!empty($seed->outlook_id) && isset($seed->outlook_id)) {
//at this point we have an object that does not have
//the id set, but does have the outlook_id set
//so we need to query the db to find if we already
//have an object with this outlook_id, if we do
//then we can set the id, otherwise this is a new object
$order_by = "";
$query = $seed->table_name . ".outlook_id = '" . $seed->outlook_id . "'";
$response = $seed->get_list($order_by, $query, 0, -1, -1, 0);
$list = $response['list'];
if (count($list) > 0) {
foreach ($list as $value) {
$seed->id = $value->id;
break;
}
}
//fi
}
//fi
}
//fi
$seed->save();
$ids[] = $seed->id;
}
//fi
} else {
if ($seed->ACLAccess('Save')) {
$seed->save();
$ids[] = $seed->id;
}
//.........这里部分代码省略.........
示例4: handle_set_entries
function handle_set_entries($module_name, $name_value_lists, $select_fields = FALSE)
{
global $beanList, $beanFiles, $app_list_strings, $current_user;
$error = new SoapError();
$ret_values = array();
if (empty($beanList[$module_name])) {
$error->set_error('no_module');
return array('ids' => array(), 'error' => $error->get_soap_array());
}
if (!check_modules_access($current_user, $module_name, 'write')) {
$error->set_error('no_access');
return array('ids' => -1, 'error' => $error->get_soap_array());
}
$class_name = $beanList[$module_name];
require_once $beanFiles[$class_name];
$ids = array();
$count = 1;
$total = sizeof($name_value_lists);
foreach ($name_value_lists as $name_value_list) {
$seed = new $class_name();
$seed->update_vcal = false;
//See if we can retrieve the seed by a given id value
foreach ($name_value_list as $value) {
if ($value['name'] == 'id') {
$seed->retrieve($value['value']);
break;
}
}
$dataValues = array();
foreach ($name_value_list as $value) {
$val = $value['value'];
if ($seed->field_name_map[$value['name']]['type'] == 'enum' || $seed->field_name_map[$value['name']]['type'] == 'radioenum') {
$vardef = $seed->field_name_map[$value['name']];
if (isset($app_list_strings[$vardef['options']]) && !isset($app_list_strings[$vardef['options']][$val])) {
if (in_array($val, $app_list_strings[$vardef['options']])) {
$val = array_search($val, $app_list_strings[$vardef['options']]);
}
}
} else {
if ($seed->field_name_map[$value['name']]['type'] == 'multienum') {
$vardef = $seed->field_name_map[$value['name']];
if (isset($app_list_strings[$vardef['options']]) && !isset($app_list_strings[$vardef['options']][$value])) {
$items = explode(",", $val);
$parsedItems = array();
foreach ($items as $item) {
if (in_array($item, $app_list_strings[$vardef['options']])) {
$keyVal = array_search($item, $app_list_strings[$vardef['options']]);
array_push($parsedItems, $keyVal);
}
}
if (!empty($parsedItems)) {
$val = encodeMultienumValue($parsedItems);
}
}
}
}
//Apply the non-empty values now since this will be used for duplicate checks
//allow string or int of 0 to be updated if set.
if (!empty($val) || ($val === '0' || $val === 0)) {
$seed->{$value['name']} = $val;
}
//Store all the values in dataValues Array to apply later
$dataValues[$value['name']] = $val;
}
if ($count == $total) {
$seed->update_vcal = false;
}
$count++;
//Add the account to a contact
if ($module_name == 'Contacts') {
$GLOBALS['log']->debug('Creating Contact Account');
add_create_account($seed);
$duplicate_id = check_for_duplicate_contacts($seed);
if ($duplicate_id == null) {
if ($seed->ACLAccess('Save') && ($seed->deleted != 1 || $seed->ACLAccess('Delete'))) {
//Now apply the values, since this is not a duplicate we can just pass false for the $firstSync argument
apply_values($seed, $dataValues, false);
$seed->save();
if ($seed->deleted == 1) {
$seed->mark_deleted($seed->id);
}
$ids[] = $seed->id;
}
} else {
//since we found a duplicate we should set the sync flag
if ($seed->ACLAccess('Save')) {
//Determine if this is a first time sync. We find out based on whether or not a contacts_users relationship exists
$seed->id = $duplicate_id;
$seed->load_relationship("user_sync");
$beans = $seed->user_sync->getBeans();
$first_sync = empty($beans);
//Now apply the values and indicate whether or not this is a first time sync
apply_values($seed, $dataValues, $first_sync);
$seed->contacts_users_id = $current_user->id;
$seed->save();
$ids[] = $duplicate_id;
//we have a conflict
}
}
} else {
//.........这里部分代码省略.........
示例5: testNotFoundCreateNew
/**
* Test add_create_account() to see if it will create a new account (non-existent by ID and non-existent by Name)
*/
public function testNotFoundCreateNew()
{
$dummyContact = new Contact();
$dummyContact->account_name = "UniqueAccountNameTest123";
add_create_account($dummyContact);
$this->_tmpacc = new Account();
$this->_tmpacc->retrieve_by_string_fields(array('name' => 'UniqueAccountNameTest123'));
$this->assertNotNull($this->_tmpacc->id);
}