static function create($params) { if (is_numeric(CRM_Utils_Array::value('is_primary', $params)) || empty($params['id'])) { CRM_Core_BAO_Block::handlePrimary($params, get_class()); } $email = CRM_Core_BAO_Email::add($params); return $email; }
/** * Create email address - note that the create function calls 'add' but * has more business logic * * @param array $params * Input parameters. * * @return object */ public static function create($params) { // if id is set & is_primary isn't we can assume no change if (is_numeric(CRM_Utils_Array::value('is_primary', $params)) || empty($params['id'])) { CRM_Core_BAO_Block::handlePrimary($params, get_class()); } $email = CRM_Core_BAO_Email::add($params); return $email; }
/** * @param $params * * @return object * @throws API_Exception */ static function create($params) { // Ensure mysql phone function exists CRM_Core_DAO::checkSqlFunctionsExist(); if (is_numeric(CRM_Utils_Array::value('is_primary', $params)) || empty($params['id'])) { CRM_Core_BAO_Block::handlePrimary($params, get_class()); } $phone = self::add($params); return $phone; }
public static function create($params) { $entityName = 'HRJob'; $hook = empty($params['id']) ? 'create' : 'edit'; if (is_numeric(CRM_Utils_Array::value('is_primary', $params)) || empty($params['id'])) { CRM_Core_BAO_Block::handlePrimary($params, get_class()); } CRM_Utils_Hook::pre($hook, $entityName, CRM_Utils_Array::value('id', $params), $params); $instance = new self(); $instance->copyValues($params); $instance->save(); $resultRoleGet = civicrm_api3('HRJobRole', 'get', array('job_id' => $instance->id, 'title' => $instance->title)); $duplicate = CRM_Utils_Array::value('action', $params, $hook); if ($hook == 'create' && $resultRoleGet['count'] == 0 && $duplicate != 'duplicate') { civicrm_api3('HRJobRole', 'create', array('job_id' => $instance->id, 'title' => $instance->title, 'location' => $instance->location, 'percent_pay_role' => 100)); } CRM_Utils_Hook::post($hook, $entityName, $instance->id, $instance); return $instance; }
/** * Takes an associative array and adds address. * * @param array $params * (reference ) an assoc array of name/value pairs. * @param bool $fixAddress * True if you need to fix (format) address values. * before inserting in db * * @return CRM_Core_BAO_Address|null */ public static function add(&$params, $fixAddress) { static $customFields = NULL; $address = new CRM_Core_DAO_Address(); // fixAddress mode to be done if ($fixAddress) { CRM_Core_BAO_Address::fixAddress($params); } $hook = empty($params['id']) ? 'create' : 'edit'; CRM_Utils_Hook::pre($hook, 'Address', CRM_Utils_Array::value('id', $params), $params); // if id is set & is_primary isn't we can assume no change if (is_numeric(CRM_Utils_Array::value('is_primary', $params)) || empty($params['id'])) { CRM_Core_BAO_Block::handlePrimary($params, get_class()); } $config = CRM_Core_Config::singleton(); $address->copyValues($params); $address->save(); if ($address->id) { if (!$customFields) { $customFields = CRM_Core_BAO_CustomField::getFields('Address', FALSE, TRUE); } if (!empty($customFields)) { $addressCustom = CRM_Core_BAO_CustomField::postProcess($params, $address->id, 'Address', TRUE); } if (!empty($addressCustom)) { CRM_Core_BAO_CustomValueTable::store($addressCustom, 'civicrm_address', $address->id); } //call the function to sync shared address self::processSharedAddress($address->id, $params); // call the function to create shared relationships // we only create create relationship if address is shared by Individual if (!CRM_Utils_System::isNull($address->master_id)) { self::processSharedAddressRelationship($address->master_id, $params); } // lets call the post hook only after we've done all the follow on processing CRM_Utils_Hook::post($hook, 'Address', $address->id, $address); } return $address; }