当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Utils_Hook::post方法代码示例

本文整理汇总了PHP中CRM_Utils_Hook::post方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Hook::post方法的具体用法?PHP CRM_Utils_Hook::post怎么用?PHP CRM_Utils_Hook::post使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Utils_Hook的用法示例。


在下文中一共展示了CRM_Utils_Hook::post方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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

示例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: civicrm_api3_generic_setValue

/**
 * params must contain at least id=xx & {one of the fields from getfields}=value
 */
function civicrm_api3_generic_setValue($apiRequest)
{
    $entity = $apiRequest['entity'];
    $params = $apiRequest['params'];
    // we can't use _spec, doesn't work with generic
    civicrm_api3_verify_mandatory($params, NULL, array('id', 'field', 'value'));
    $id = $params['id'];
    if (!is_numeric($id)) {
        return civicrm_api3_create_error(ts('Please enter a number'), array('error_code' => 'NaN', 'field' => "id"));
    }
    $field = CRM_Utils_String::munge($params['field']);
    $value = $params['value'];
    $fields = civicrm_api($entity, 'getFields', array("version" => 3, "sequential"));
    // getfields error, shouldn't happen.
    if ($fields['is_error']) {
        return $fields;
    }
    $fields = $fields['values'];
    if (!array_key_exists($field, $fields)) {
        return civicrm_api3_create_error("Param 'field' ({$field}) is invalid. must be an existing field", array("error_code" => "invalid_field", "fields" => array_keys($fields)));
    }
    $def = $fields[$field];
    if (array_key_exists('required', $def) && empty($value)) {
        return civicrm_api3_create_error(ts("This can't be empty, please provide a value"), array("error_code" => "required", "field" => $field));
    }
    switch ($def['type']) {
        case 1:
            //int
            if (!is_numeric($value)) {
                return civicrm_api3_create_error("Param '{$field}' must be a number", array('error_code' => 'NaN'));
            }
        case 2:
            //string
            require_once "CRM/Utils/Rule.php";
            if (!CRM_Utils_Rule::xssString($value)) {
                return civicrm_api3_create_error(ts('Illegal characters in input (potential scripting attack)'), array('error_code' => 'XSS'));
            }
            if (array_key_exists('maxlength', $def)) {
                $value = substr($value, 0, $def['maxlength']);
            }
            break;
        case 16:
            //boolean
            $value = (bool) $value;
            break;
        case 4:
            //date
        //date
        default:
            return civicrm_api3_create_error("Param '{$field}' is of a type not managed yet. Join the API team and help us implement it", array('error_code' => 'NOT_IMPLEMENTED'));
    }
    if (CRM_Core_DAO::setFieldValue(_civicrm_api3_get_DAO($entity), $id, $field, $value)) {
        $entity = array('id' => $id, $field => $value);
        CRM_Utils_Hook::post('edit', $entity, $id, $entity);
        return civicrm_api3_create_success($entity);
    } else {
        return civicrm_api3_create_error("error assigning {$field}={$value} for {$entity} (id={$id})");
    }
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:62,代码来源:Setvalue.php

示例4: 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

示例5: 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

示例6: 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

示例7: create

 /**
  * Creates a new entry in the database.
  *
  * @param array $params (reference) an assoc array of name/value pairs
  *
  * @return object CRM_Upgrade_Snapshot_V4p2_Price_DAO_LineItem object
  * @access public
  * @static
  */
 static function create(&$params)
 {
     //create mode only as we don't support editing line items
     CRM_Utils_Hook::pre('create', 'LineItem', $params['entity_id'], $params);
     $lineItemBAO = new CRM_Upgrade_Snapshot_V4p2_Price_BAO_LineItem();
     $lineItemBAO->copyValues($params);
     $return = $lineItemBAO->save();
     CRM_Utils_Hook::post('create', 'LineItem', $params['entity_id'], $params);
     return $return;
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:19,代码来源:LineItem.php

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: create

 /**
  * Create a new Appraisal based on array-data
  *
  * @param array $params key-value pairs
  * @return CRM_Appraisals_DAO_Appraisal|NULL
  */
 public static function create(&$params)
 {
     $className = 'CRM_Appraisals_DAO_Appraisal';
     $entityName = 'Appraisal';
     $hook = empty($params['id']) ? 'create' : 'edit';
     if ($hook === 'create') {
         if (empty($params['appraisal_cycle_id'])) {
             throw new Exception("Please specify 'appraisal_cycle_id' value to create Appraisal.");
         }
         $appraisalCycle = civicrm_api3('AppraisalCycle', 'getsingle', array('sequential' => 1, 'id' => (int) $params['appraisal_cycle_id']));
         if (!empty($appraisalCycle['is_error']) && (int) $appraisalCycle['is_error']) {
             throw new Exception("Cannot find Appraisal Cycle with 'id' = " . (int) $params['appraisal_cycle_id'] . '.');
         }
         if (empty($params['self_appraisal_due'])) {
             $params['self_appraisal_due'] = $appraisalCycle['cycle_self_appraisal_due'];
         }
         if (empty($params['manager_appraisal_due'])) {
             $params['manager_appraisal_due'] = $appraisalCycle['cycle_manager_appraisal_due'];
         }
         if (empty($params['grade_due'])) {
             $params['grade_due'] = $appraisalCycle['cycle_grade_due'];
         }
         if (empty($params['status_id'])) {
             $params['status_id'] = 1;
         }
     } else {
         $instance = new $className();
         $instance->id = (int) $params['id'];
         if (!$instance->find()) {
             throw new Exception("Cannot find Appraisal with 'id' = " . (int) $params['id'] . '.');
         }
         $instance->fetch();
         $dueChanged = false;
         if (!empty($params['self_appraisal_due']) && $params['self_appraisal_due'] != $instance->self_appraisal_due) {
             $dueChanged = true;
         }
         if (!empty($params['manager_appraisal_due']) && $params['manager_appraisal_due'] != $instance->manager_appraisal_due) {
             $dueChanged = true;
         }
         if (!empty($params['grade_due']) && $params['grade_due'] != $instance->grade_due) {
             $dueChanged = true;
         }
         if ($dueChanged) {
             $instance->due_changed = 1;
             $instance->save();
         }
     }
     CRM_Utils_Hook::pre($hook, $entityName, CRM_Utils_Array::value('id', $params), $params);
     $instance = new $className();
     $instance->copyValues($params);
     $instance->save();
     CRM_Utils_Hook::post($hook, $entityName, $instance->id, $instance);
     ////TODO: trigger on post: CRM_Tasksassignments_Reminder::sendReminder((int)$instance->id);
     return $instance;
 }
开发者ID:JoeMurray,项目名称:civihr,代码行数:61,代码来源:Appraisal.php

示例14: create

 public static function create($params)
 {
     $entityName = 'PayScale';
     $hook = empty($params['id']) ? 'create' : 'edit';
     CRM_Utils_Hook::pre($hook, $entityName, CRM_Utils_Array::value('id', $params), $params);
     $instance = new self();
     $instance->copyValues($params);
     $instance->save();
     CRM_Utils_Hook::post($hook, $entityName, $instance->id, $instance);
     return $instance;
 }
开发者ID:JoeMurray,项目名称:civihr,代码行数:11,代码来源:PayScale.php

示例15: create

 /**
  * Create a new MyEmmaFieldMap based on array-data
  *
  * @param array $params key-value pairs
  * @return CRM_Myemma_DAO_MyEmmaAccount|NULL
  */
 public static function create($params)
 {
     $entityName = 'MyEmmaFieldMap';
     $hook = empty($params['id']) ? 'create' : 'edit';
     CRM_Utils_Hook::pre($hook, $entityName, CRM_Utils_Array::value('id', $params), $params);
     $instance = new CRM_Myemma_DAO_MyEmmaFieldMap();
     $instance->copyValues($params);
     $instance->save();
     CRM_Utils_Hook::post($hook, $entityName, $instance->id, $instance);
     return $instance;
 }
开发者ID:CiviCooP,项目名称:org.civicoop.myemma,代码行数:17,代码来源:MyEmmaFieldMap.php


注:本文中的CRM_Utils_Hook::post方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。