當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CRM_Utils_Hook::pre方法代碼示例

本文整理匯總了PHP中CRM_Utils_Hook::pre方法的典型用法代碼示例。如果您正苦於以下問題:PHP CRM_Utils_Hook::pre方法的具體用法?PHP CRM_Utils_Hook::pre怎麽用?PHP CRM_Utils_Hook::pre使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CRM_Utils_Hook的用法示例。


在下文中一共展示了CRM_Utils_Hook::pre方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: add

 /**
  * takes an associative array and creates a contribution object
  *
  * the function extract all the params it needs to initialize the create a
  * contribution object. the params array could contain additional unused name/value
  * pairs
  *
  * @param array  $params (reference ) an assoc array of name/value pairs
  * @param array $ids    the array that holds all the db ids
  *
  * @return object CRM_Contribute_BAO_Contribution object
  * @access public
  * @static
  */
 function add(&$params, &$ids)
 {
     require_once 'CRM/Utils/Hook.php';
     $duplicates = array();
     if (CRM_Contribute_BAO_Contribution::checkDuplicate($params, $duplicates)) {
         $error =& CRM_Core_Error::singleton();
         $d = implode(', ', $duplicates);
         $error->push(CRM_CORE_ERROR_DUPLICATE_CONTRIBUTION, 'Fatal', array($d), "Found matching contribution(s): {$d}");
         return $error;
     }
     if (CRM_Utils_Array::value('contribution', $ids)) {
         CRM_Utils_Hook::pre('edit', 'Contribution', $ids['contribution'], $params);
     } else {
         CRM_Utils_Hook::pre('create', 'Contribution', null, $params);
     }
     $contribution =& new CRM_Contribute_BAO_Contribution();
     $contribution->copyValues($params);
     $contribution->domain_id = CRM_Utils_Array::value('domain', $ids, CRM_Core_Config::domainID());
     $contribution->id = CRM_Utils_Array::value('contribution', $ids);
     require_once 'CRM/Utils/Rule.php';
     if (!CRM_Utils_Rule::currencyCode($contribution->currency)) {
         require_once 'CRM/Core/Config.php';
         $config =& CRM_Core_Config::singleton();
         $contribution->currency = $config->defaultCurrency;
     }
     $result = $contribution->save();
     if (CRM_Utils_Array::value('contribution', $ids)) {
         CRM_Utils_Hook::post('edit', 'Contribution', $contribution->id, $contribution);
     } else {
         CRM_Utils_Hook::post('create', 'Contribution', $contribution->id, $contribution);
     }
     return $result;
 }
開發者ID:bhirsch,項目名稱:voipdrupal-4.7-1.0,代碼行數:47,代碼來源:Contribution.php

示例2: create

 /**
  * Creates a new entry in the database.
  *
  * @param array $params
  *   (reference) an assoc array of name/value pairs.
  *
  * @return CRM_Price_DAO_LineItem
  */
 public static function create(&$params)
 {
     $id = CRM_Utils_Array::value('id', $params);
     if ($id) {
         CRM_Utils_Hook::pre('edit', 'LineItem', $id, $params);
         $op = CRM_Core_Action::UPDATE;
     } else {
         CRM_Utils_Hook::pre('create', 'LineItem', $params['entity_id'], $params);
         $op = CRM_Core_Action::ADD;
     }
     // unset entity table and entity id in $params
     // we never update the entity table and entity id during update mode
     if ($id) {
         unset($params['entity_id'], $params['entity_table']);
     }
     if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus() && CRM_Utils_Array::value('check_permissions', $params)) {
         if (empty($params['financial_type_id'])) {
             throw new Exception('Mandatory key(s) missing from params array: financial_type_id');
         }
         CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($types, $op);
         if (!in_array($params['financial_type_id'], array_keys($types))) {
             throw new Exception('You do not have permission to create this line item');
         }
     }
     $lineItemBAO = new CRM_Price_BAO_LineItem();
     $lineItemBAO->copyValues($params);
     $return = $lineItemBAO->save();
     if ($id) {
         CRM_Utils_Hook::post('edit', 'LineItem', $id, $lineItemBAO);
     } else {
         CRM_Utils_Hook::post('create', 'LineItem', $lineItemBAO->id, $lineItemBAO);
     }
     return $return;
 }
開發者ID:saurabhbatra96,項目名稱:civicrm-core,代碼行數:42,代碼來源:LineItem.php

示例3: add

 /**
  * takes an associative array and adds email
  *
  * @param array  $params         (reference ) an assoc array of name/value pairs
  *
  * @return object       CRM_Core_BAO_Email object on success, null otherwise
  * @access public
  * @static
  */
 static function add(&$params)
 {
     $email = new CRM_Core_DAO_Email();
     $email->copyValues($params);
     // CRM-11006 move calls to pre hook from create function to add function
     if (!empty($params['id'])) {
         CRM_Utils_Hook::pre('edit', 'Email', $params['id'], $email);
     } else {
         CRM_Utils_Hook::pre('create', 'Email', NULL, $e);
     }
     // lower case email field to optimize queries
     $strtolower = function_exists('mb_strtolower') ? 'mb_strtolower' : 'strtolower';
     $email->email = $strtolower($email->email);
     // since we're setting bulkmail for 1 of this contact's emails, first reset all their emails to is_bulkmail false
     // (only 1 email address can have is_bulkmail = true)
     if ($email->is_bulkmail != 'null' && $params['contact_id'] && !self::isMultipleBulkMail()) {
         $sql = "\nUPDATE civicrm_email\nSET    is_bulkmail = 0\nWHERE  contact_id = {$params['contact_id']}\n";
         CRM_Core_DAO::executeQuery($sql);
     }
     // handle if email is on hold
     self::holdEmail($email);
     $email->save();
     // CRM-11006 move calls to pre hook from create function to add function
     if (!empty($params['id'])) {
         CRM_Utils_Hook::post('edit', 'Email', $email->id, $email);
     } else {
         CRM_Utils_Hook::post('create', 'Email', $email->id, $email);
     }
     return $email;
 }
開發者ID:peteainsworth,項目名稱:civicrm-4.2.9-drupal,代碼行數:39,代碼來源:Email.php

示例4: create

 /**
  * Add the membership Payments.
  *
  * @param array $params
  *   Reference array contains the values submitted by the form.
  *
  *
  * @return object
  */
 public static function create($params)
 {
     $hook = empty($params['id']) ? 'create' : 'edit';
     CRM_Utils_Hook::pre($hook, 'MembershipPayment', CRM_Utils_Array::value('id', $params), $params);
     $dao = new CRM_Member_DAO_MembershipPayment();
     $dao->copyValues($params);
     $dao->id = CRM_Utils_Array::value('id', $params);
     //Fixed for avoiding duplicate entry error when user goes
     //back and forward during payment mode is notify
     if (!$dao->find(TRUE)) {
         $dao->save();
     }
     CRM_Utils_Hook::post($hook, 'MembershipPayment', $dao->id, $dao);
     // CRM-14197 we are in the process on phasing out membershipPayment in favour of storing both contribution_id & entity_id (membership_id) on the line items
     // table. However, at this stage we have both - there is still quite a bit of refactoring to do to set the line_iten entity_id right the first time
     // however, we can assume at this stage that any contribution id will have only one line item with that membership type in the line item table
     // OR the caller will have taken responsibility for updating the line items themselves so we will update using SQL here
     if (!isset($params['membership_type_id'])) {
         $membership_type_id = civicrm_api3('membership', 'getvalue', array('id' => $dao->membership_id, 'return' => 'membership_type_id'));
     } else {
         $membership_type_id = $params['membership_type_id'];
     }
     $sql = "UPDATE civicrm_line_item li\n      LEFT JOIN civicrm_price_field_value pv ON pv.id = li.price_field_value_id\n      SET entity_table = 'civicrm_membership', entity_id = %1\n      WHERE pv.membership_type_id = %2\n      AND contribution_id = %3";
     CRM_Core_DAO::executeQuery($sql, array(1 => array($dao->membership_id, 'Integer'), 2 => array($membership_type_id, 'Integer'), 3 => array($dao->contribution_id, 'Integer')));
     return $dao;
 }
開發者ID:hyebahi,項目名稱:civicrm-core,代碼行數:35,代碼來源:MembershipPayment.php

示例5: add

 /**
  * Takes an associative array and adds email.
  *
  * @param array $params
  *   (reference ) an assoc array of name/value pairs.
  *
  * @return object
  *   CRM_Core_BAO_Email object on success, null otherwise
  */
 public static function add(&$params)
 {
     $hook = empty($params['id']) ? 'create' : 'edit';
     CRM_Utils_Hook::pre($hook, 'Email', CRM_Utils_Array::value('id', $params), $params);
     $email = new CRM_Core_DAO_Email();
     $email->copyValues($params);
     // lower case email field to optimize queries
     $strtolower = function_exists('mb_strtolower') ? 'mb_strtolower' : 'strtolower';
     $email->email = $strtolower($email->email);
     /*
      * since we're setting bulkmail for 1 of this contact's emails, first reset all their other emails to is_bulkmail false
      *  We shouldn't not set the current email to false even though we
      *  are about to reset it to avoid contaminating the changelog if logging is enabled
      * (only 1 email address can have is_bulkmail = true)
      */
     if ($email->is_bulkmail != 'null' && $params['contact_id'] && !self::isMultipleBulkMail()) {
         $sql = "\nUPDATE civicrm_email\nSET    is_bulkmail = 0\nWHERE  contact_id = {$params['contact_id']}\n";
         if ($hook == 'edit') {
             $sql .= " AND id <> {$params['id']}";
         }
         CRM_Core_DAO::executeQuery($sql);
     }
     // handle if email is on hold
     self::holdEmail($email);
     $email->save();
     if ($email->is_primary) {
         // update the UF user email if that has changed
         CRM_Core_BAO_UFMatch::updateUFName($email->contact_id);
     }
     CRM_Utils_Hook::post($hook, 'Email', $email->id, $email);
     return $email;
 }
開發者ID:BorislavZlatanov,項目名稱:civicrm-core,代碼行數:41,代碼來源:Email.php

示例6: add

 /**
  * Takes an associative array and creates a contribution object.
  *
  * the function extract all the params it needs to initialize the create a
  * contribution object. the params array could contain additional unused name/value
  * pairs
  *
  * @param array $params
  *   (reference ) an assoc array of name/value pairs.
  *
  * @return CRM_Contribute_BAO_Contribution
  * @todo move hook calls / extended logic to create - requires changing calls to call create not add
  */
 public static function add(&$params)
 {
     if (!empty($params['id'])) {
         CRM_Utils_Hook::pre('edit', 'ContributionRecur', $params['id'], $params);
     } else {
         CRM_Utils_Hook::pre('create', 'ContributionRecur', NULL, $params);
     }
     // make sure we're not creating a new recurring contribution with the same transaction ID
     // or invoice ID as an existing recurring contribution
     $duplicates = array();
     if (self::checkDuplicate($params, $duplicates)) {
         $error = CRM_Core_Error::singleton();
         $d = implode(', ', $duplicates);
         $error->push(CRM_Core_Error::DUPLICATE_CONTRIBUTION, 'Fatal', array($d), "Found matching recurring contribution(s): {$d}");
         return $error;
     }
     $recurring = new CRM_Contribute_BAO_ContributionRecur();
     $recurring->copyValues($params);
     $recurring->id = CRM_Utils_Array::value('id', $params);
     // set currency for CRM-1496
     if (empty($params['id']) && !isset($recurring->currency)) {
         $config = CRM_Core_Config::singleton();
         $recurring->currency = $config->defaultCurrency;
     }
     $result = $recurring->save();
     if (!empty($params['id'])) {
         CRM_Utils_Hook::post('edit', 'ContributionRecur', $recurring->id, $recurring);
     } else {
         CRM_Utils_Hook::post('create', 'ContributionRecur', $recurring->id, $recurring);
     }
     if (!empty($params['custom']) && is_array($params['custom'])) {
         CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_contribution_recur', $recurring->id);
     }
     return $result;
 }
開發者ID:kcristiano,項目名稱:civicrm-core,代碼行數:48,代碼來源:ContributionRecur.php

示例7: create

 /**
  * Add Dashboard.
  *
  * @param array $params
  *   Values.
  *
  *
  * @return object
  */
 public static function create($params)
 {
     $hook = empty($params['id']) ? 'create' : 'edit';
     CRM_Utils_Hook::pre($hook, 'Dashboard', CRM_Utils_Array::value('id', $params), $params);
     $dao = self::addDashlet($params);
     CRM_Utils_Hook::post($hook, 'Dashboard', $dao->id, $dao);
     return $dao;
 }
開發者ID:saurabhbatra96,項目名稱:civicrm-core,代碼行數:17,代碼來源:Dashboard.php

示例8: create

 public static function create(&$params)
 {
     $vacancy = new self();
     if (!empty($params['id'])) {
         CRM_Core_DAO::executeQuery("DELETE FROM civicrm_hrvacancy_stage WHERE vacancy_id = {$params['id']}");
         CRM_Core_DAO::executeQuery("DELETE FROM civicrm_hrvacancy_permission WHERE vacancy_id = {$params['id']}");
     }
     $vacancyParams = CRM_HRRecruitment_BAO_HRVacancy::formatParams($params);
     $entityName = 'HRVacancy';
     $hook = empty($params['id']) ? 'create' : 'edit';
     CRM_Utils_Hook::pre($hook, $entityName, CRM_Utils_Array::value('id', $params), $params);
     if (!empty($params['id'])) {
         $vacancy->find($params['id']);
         $vacancy->created_date = $vacancy->created_date ? CRM_Utils_Date::processDate($vacancy->created_date) : date('YmdHis');
         $vacancy->created_id = $vacancy->created_id ? $vacancy->created_id : CRM_Core_Session::singleton()->get('userID');
     } else {
         $vacancyParams['created_date'] = date('YmdHis');
         $vacancyParams['created_id'] = CRM_Core_Session::singleton()->get('userID');
     }
     $vacancy->copyValues($vacancyParams);
     $vacancy->save();
     if (isset($params['stages']) && count($params['stages'])) {
         foreach ($params['stages'] as $key => $stage_id) {
             $dao = new CRM_HRRecruitment_DAO_HRVacancyStage();
             $dao->case_status_id = $stage_id;
             $dao->vacancy_id = $vacancy->id;
             $dao->weight = $key + 1;
             $dao->save();
         }
     }
     foreach (array('application_profile', 'evaluation_profile') as $profileName) {
         if (!empty($params[$profileName])) {
             $dao = new CRM_Core_DAO_UFJoin();
             $dao->module = 'Vacancy';
             $dao->entity_table = 'civicrm_hrvacancy';
             $dao->entity_id = $vacancy->id;
             $dao->module_data = $profileName;
             if (!empty($params['id'])) {
                 $dao->find(TRUE);
             }
             $dao->uf_group_id = $params[$profileName];
             $dao->save();
         }
     }
     if (!empty($params['permission']) && !empty($params['permission_contact_id'])) {
         foreach ($params['permission'] as $key => $permission) {
             if ($permission && $params['permission_contact_id'][$key]) {
                 $dao = new CRM_HRRecruitment_DAO_HRVacancyPermission();
                 $dao->contact_id = $params['permission_contact_id'][$key];
                 $dao->permission = $permission;
                 $dao->vacancy_id = $vacancy->id;
                 $dao->save();
             }
         }
     }
     CRM_Utils_Hook::post($hook, $entityName, $vacancy->id, $vacancy);
     return $vacancy;
 }
開發者ID:JoeMurray,項目名稱:civihr,代碼行數:58,代碼來源:HRVacancy.php

示例9: add

 /**
  * Takes an associative array and adds im.
  *
  * @param array $params
  *   (reference ) an assoc array of name/value pairs.
  *
  * @return object
  *   CRM_Core_BAO_IM object on success, null otherwise
  */
 public static function add(&$params)
 {
     $hook = empty($params['id']) ? 'create' : 'edit';
     CRM_Utils_Hook::pre($hook, 'IM', CRM_Utils_Array::value('id', $params), $params);
     $im = new CRM_Core_DAO_IM();
     $im->copyValues($params);
     $im->save();
     CRM_Utils_Hook::post($hook, 'IM', $im->id, $im);
     return $im;
 }
開發者ID:hyebahi,項目名稱:civicrm-core,代碼行數:19,代碼來源:IM.php

示例10: add

 /**
  * @param array  $params         (reference ) an assoc array of name/value pairs
  *
  * @return object       CRM_Core_BAO_SEPASddFile object on success, null otherwise
  * @access public
  * @static
  */
 static function add(&$params)
 {
     $hook = empty($params['id']) ? 'create' : 'edit';
     CRM_Utils_Hook::pre($hook, 'SepaSddFile', CRM_Utils_Array::value('id', $params), $params);
     $dao = new CRM_Sepa_DAO_SEPASddFile();
     $dao->copyValues($params);
     $dao->save();
     CRM_Utils_Hook::post($hook, 'SepaSddFile', $dao->id, $dao);
     return $dao;
 }
開發者ID:FundingWorks,項目名稱:org.project60.sepa,代碼行數:17,代碼來源:SEPASddFile.php

示例11: add

 /**
  * Add the Message Templates.
  *
  * @param array $params
  *   Reference array contains the values submitted by the form.
  *
  *
  * @return object
  */
 public static function add(&$params)
 {
     $hook = empty($params['id']) ? 'create' : 'edit';
     CRM_Utils_Hook::pre($hook, 'MessageTemplate', CRM_Utils_Array::value('id', $params), $params);
     $messageTemplates = new CRM_Core_DAO_MessageTemplate();
     $messageTemplates->copyValues($params);
     $messageTemplates->save();
     CRM_Utils_Hook::post($hook, 'MessageTemplate', $messageTemplates->id, $messageTemplates);
     return $messageTemplates;
 }
開發者ID:sarehag,項目名稱:civicrm-core,代碼行數:19,代碼來源:MessageTemplate.php

示例12: create

 /**
  * function to add the membership Blocks
  *
  * @param array $params reference array contains the values submitted by the form
  *
  * @access public
  * @static
  *
  * @return object
  */
 static function create(&$params)
 {
     $hook = empty($params['id']) ? 'create' : 'edit';
     CRM_Utils_Hook::pre($hook, 'MembershipBlock', CRM_Utils_Array::value('id', $params), $params);
     $dao = new CRM_Member_DAO_MembershipBlock();
     $dao->copyValues($params);
     $dao->id = CRM_Utils_Array::value('id', $params);
     CRM_Utils_Hook::post($hook, 'MembershipBlock', $dao->id, $dao);
     return $dao;
 }
開發者ID:hguru,項目名稱:224Civi,代碼行數:20,代碼來源:MembershipBlock.php

示例13: add

 /**
  * Takes an associative array and adds OpenID.
  *
  * @param array $params
  *   (reference ) an assoc array of name/value pairs.
  *
  * @return object
  *   CRM_Core_BAO_OpenID object on success, null otherwise
  */
 public static function add(&$params)
 {
     $hook = empty($params['id']) ? 'create' : 'edit';
     CRM_Utils_Hook::pre($hook, 'OpenID', CRM_Utils_Array::value('id', $params), $params);
     $openId = new CRM_Core_DAO_OpenID();
     $openId->copyValues($params);
     $openId->save();
     CRM_Utils_Hook::post($hook, 'OpenID', $openId->id, $openId);
     return $openId;
 }
開發者ID:FundingWorks,項目名稱:civicrm-core,代碼行數:19,代碼來源:OpenID.php

示例14: add

 /**
  * @param array  $params         (reference ) an assoc array of name/value pairs
  *
  * @return object       CRM_Banking_BAO_BankAccount object on success, null otherwise
  * @access public
  * @static
  */
 static function add(&$params)
 {
     $hook = empty($params['id']) ? 'create' : 'edit';
     CRM_Utils_Hook::pre($hook, 'BankAccountReference', CRM_Utils_Array::value('id', $params), $params);
     $dao = new CRM_Banking_DAO_BankAccountReference();
     $dao->copyValues($params);
     $dao->save();
     CRM_Utils_Hook::post($hook, 'BankAccountReference', $dao->id, $dao);
     return $dao;
 }
開發者ID:aydun,項目名稱:org.project60.banking,代碼行數:17,代碼來源:BankAccountReference.php

示例15: add

 /**
  * Takes an associative array and adds im.
  *
  * @param array $params
  *   (reference ) an assoc array of name/value pairs.
  *
  * @return object
  *   CRM_Core_BAO_Website object on success, null otherwise
  */
 public static function add(&$params)
 {
     $hook = empty($params['id']) ? 'create' : 'edit';
     CRM_Utils_Hook::pre($hook, 'Website', CRM_Utils_Array::value('id', $params), $params);
     $website = new CRM_Core_DAO_Website();
     $website->copyValues($params);
     $website->save();
     CRM_Utils_Hook::post($hook, 'Website', $website->id, $website);
     return $website;
 }
開發者ID:hyebahi,項目名稱:civicrm-core,代碼行數:19,代碼來源:Website.php


注:本文中的CRM_Utils_Hook::pre方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。