• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP CRM_Utils_Hook类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

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


示例2: tearDown

 public function tearDown()
 {
     CRM_Utils_Hook::singleton()->reset();
     parent::tearDown();
     $this->callAPISuccess('system', 'flush', array());
     $this->quickCleanup(array('civicrm_domain'));
 }
开发者ID:nganivet,项目名称:civicrm-core,代码行数:7,代码来源:SettingTest.php


示例3: tearDown

 /**
  *
  */
 function tearDown()
 {
     $this->_mut->stop();
     $this->quickCleanup(array('civicrm_mailing', 'civicrm_mailing_job', 'civicrm_contact'));
     CRM_Utils_Hook::singleton()->reset();
     parent::tearDown();
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:10,代码来源:JobProcessMailingTest.php


示例4: getModules

 /**
  * Get a list of AngularJS modules which should be autoloaded.
  *
  * @return array
  *   Each item has some combination of these keys:
  *   - ext: string
  *     The Civi extension which defines the Angular module.
  *   - js: array(string $relativeFilePath)
  *     List of JS files (relative to the extension).
  *   - css: array(string $relativeFilePath)
  *     List of CSS files (relative to the extension).
  *   - partials: array(string $relativeFilePath)
  *     A list of partial-HTML folders (relative to the extension).
  *     This will be mapped to "~/moduleName" by crmResource.
  *   - settings: array(string $key => mixed $value)
  *     List of settings to preload.
  */
 public function getModules()
 {
     if ($this->modules === NULL) {
         $config = \CRM_Core_Config::singleton();
         $angularModules = array();
         $angularModules['angularFileUpload'] = array('ext' => 'civicrm', 'js' => array('bower_components/angular-file-upload/dist/angular-file-upload.min.js'));
         $angularModules['crmApp'] = array('ext' => 'civicrm', 'js' => array('ang/crmApp.js'));
         $angularModules['crmAttachment'] = array('ext' => 'civicrm', 'js' => array('ang/crmAttachment.js'), 'css' => array('ang/crmAttachment.css'), 'partials' => array('ang/crmAttachment'), 'settings' => array('token' => \CRM_Core_Page_AJAX_Attachment::createToken()));
         $angularModules['crmAutosave'] = array('ext' => 'civicrm', 'js' => array('ang/crmAutosave.js'));
         $angularModules['crmCxn'] = array('ext' => 'civicrm', 'js' => array('ang/crmCxn.js', 'ang/crmCxn/*.js'), 'css' => array('ang/crmCxn.css'), 'partials' => array('ang/crmCxn'));
         //$angularModules['crmExample'] = array(
         //  'ext' => 'civicrm',
         //  'js' => array('ang/crmExample.js'),
         //  'partials' => array('ang/crmExample'),
         //);
         $angularModules['crmResource'] = array('ext' => 'civicrm', 'js' => array('js/angular-crmResource/all.js'));
         $angularModules['crmUi'] = array('ext' => 'civicrm', 'js' => array('ang/crmUi.js'), 'partials' => array('ang/crmUi'), 'settings' => array('browseUrl' => $config->userFrameworkResourceURL . 'packages/kcfinder/browse.php', 'uploadUrl' => $config->userFrameworkResourceURL . 'packages/kcfinder/upload.php'));
         $angularModules['crmUtil'] = array('ext' => 'civicrm', 'js' => array('ang/crmUtil.js'));
         // https://github.com/jwstadler/angular-jquery-dialog-service
         $angularModules['dialogService'] = array('ext' => 'civicrm', 'js' => array('bower_components/angular-jquery-dialog-service/dialog-service.js'));
         $angularModules['ngRoute'] = array('ext' => 'civicrm', 'js' => array('bower_components/angular-route/angular-route.min.js'));
         $angularModules['ngSanitize'] = array('ext' => 'civicrm', 'js' => array('bower_components/angular-sanitize/angular-sanitize.min.js'));
         $angularModules['ui.utils'] = array('ext' => 'civicrm', 'js' => array('bower_components/angular-ui-utils/ui-utils.min.js'));
         $angularModules['ui.sortable'] = array('ext' => 'civicrm', 'js' => array('bower_components/angular-ui-sortable/sortable.min.js'));
         $angularModules['unsavedChanges'] = array('ext' => 'civicrm', 'js' => array('bower_components/angular-unsavedChanges/dist/unsavedChanges.min.js'));
         foreach (\CRM_Core_Component::getEnabledComponents() as $component) {
             $angularModules = array_merge($angularModules, $component->getAngularModules());
         }
         \CRM_Utils_Hook::angularModules($angularModules);
         $this->modules = $this->resolvePatterns($angularModules);
     }
     return $this->modules;
 }
开发者ID:utkarshsharma,项目名称:civicrm-core,代码行数:50,代码来源:Manager.php


示例5: run

 /**
  * Run dashboard.
  *
  * @return void
  */
 public function run()
 {
     // Add dashboard js and css
     $resources = CRM_Core_Resources::singleton();
     $resources->addScriptFile('civicrm', 'js/jquery/jquery.dashboard.js', 0, 'html-header', FALSE);
     $resources->addStyleFile('civicrm', 'css/dashboard.css');
     $resetCache = CRM_Utils_Request::retrieve('resetCache', 'Positive', CRM_Core_DAO::$_nullObject);
     CRM_Utils_System::setTitle(ts('CiviCRM Home'));
     $session = CRM_Core_Session::singleton();
     $contactID = $session->get('userID');
     if ($resetCache) {
         CRM_Core_BAO_Dashboard::resetDashletCache($contactID);
     }
     // call hook to get html from other modules
     // ignored but needed to prevent warnings
     $contentPlacement = CRM_Utils_Hook::DASHBOARD_BELOW;
     $html = CRM_Utils_Hook::dashboard($contactID, $contentPlacement);
     if (is_array($html)) {
         $this->assign_by_ref('hookContent', $html);
         $this->assign('hookContentPlacement', $contentPlacement);
     }
     $communityMessages = CRM_Core_CommunityMessages::create();
     if ($communityMessages->isEnabled()) {
         $message = $communityMessages->pick();
         if ($message) {
             $this->assign('communityMessages', $communityMessages->evalMarkup($message['markup']));
         }
     }
     return parent::run();
 }
开发者ID:utkarshsharma,项目名称:civicrm-core,代码行数:35,代码来源:DashBoard.php


示例6: check

 /**
  * Check function.
  *
  * This function includes the IDS vendor parts and runs the
  * detection routines on the request array.
  *
  * @param array $args
  *   List of path parts.
  *
  * @return bool
  */
 public function check($args)
 {
     // lets bypass a few civicrm urls from this check
     $skip = array('civicrm/admin/setting/updateConfigBackend', 'civicrm/admin/messageTemplates');
     CRM_Utils_Hook::idsException($skip);
     $this->path = implode('/', $args);
     if (in_array($this->path, $skip)) {
         return NULL;
     }
     // Add request url and user agent.
     $_REQUEST['IDS_request_uri'] = $_SERVER['REQUEST_URI'];
     if (isset($_SERVER['HTTP_USER_AGENT'])) {
         $_REQUEST['IDS_user_agent'] = $_SERVER['HTTP_USER_AGENT'];
     }
     $configFile = self::createConfigFile(FALSE);
     // init the PHPIDS and pass the REQUEST array
     require_once 'IDS/Init.php';
     try {
         $init = IDS_Init::init($configFile);
         $ids = new IDS_Monitor($_REQUEST, $init);
     } catch (Exception $e) {
         // might be an old stale copy of Config.IDS.ini
         // lets try to rebuild it again and see if it works
         $configFile = self::createConfigFile(TRUE);
         $init = IDS_Init::init($configFile);
         $ids = new IDS_Monitor($_REQUEST, $init);
     }
     $result = $ids->run();
     if (!$result->isEmpty()) {
         $this->react($result);
     }
     return TRUE;
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:44,代码来源:IDS.php


示例7: testHookAlterMailer

 public function testHookAlterMailer()
 {
     $test = $this;
     $mockMailer = new CRM_Utils_FakeObject(array('send' => function ($recipients, $headers, $body) use($test) {
         $test->calls['send']++;
         $test->assertEquals(array('[email protected]'), $recipients);
         $test->assertEquals('Subject Example', $headers['Subject']);
     }));
     CRM_Utils_Hook::singleton()->setHook('civicrm_alterMailer', function (&$mailer, $driver, $params) use($test, $mockMailer) {
         $test->calls['civicrm_alterMailer']++;
         $test->assertTrue(is_string($driver) && !empty($driver));
         $test->assertTrue(is_array($params));
         $test->assertTrue(is_callable(array($mailer, 'send')));
         $mailer = $mockMailer;
     });
     $params = array();
     $params['groupName'] = 'CRM_Core_Config_MailerTest';
     $params['from'] = 'From Example <[email protected]>';
     $params['toName'] = 'To Example';
     $params['toEmail'] = '[email protected]';
     $params['subject'] = 'Subject Example';
     $params['text'] = 'Example text';
     $params['html'] = '<p>Example HTML</p>';
     CRM_Utils_Mail::send($params);
     $this->assertEquals(1, $this->calls['civicrm_alterMailer']);
     $this->assertEquals(1, $this->calls['send']);
     // once more, just to make sure the hooks are called right #times
     CRM_Utils_Mail::send($params);
     CRM_Utils_Mail::send($params);
     $this->assertEquals(1, $this->calls['civicrm_alterMailer']);
     $this->assertEquals(3, $this->calls['send']);
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:32,代码来源:MailerTest.php


示例8: getManagedEntities

 public function getManagedEntities()
 {
     // Use hook_civicrm_caseTypes to build a list of OptionValues
     // In the long run, we may want more specialized logic for this, but
     // this design is fairly convenient and will allow us to replace it
     // without changing the hook_civicrm_caseTypes interface.
     $entities = array();
     $caseTypes = array();
     CRM_Utils_Hook::caseTypes($caseTypes);
     $proc = new CRM_Case_XMLProcessor();
     $caseTypesGroupId = civicrm_api3('OptionGroup', 'getvalue', array('name' => 'case_type', 'return' => 'id'));
     if (!is_numeric($caseTypesGroupId)) {
         throw new CRM_Core_Exception("Found invalid ID for OptionGroup (case_type)");
     }
     foreach ($caseTypes as $name => $caseType) {
         $xml = $proc->retrieve($name);
         if (!$xml) {
             throw new CRM_Core_Exception("Failed to load XML for case type (" . $name . ")");
         }
         if (isset($caseType['module'], $caseType['name'], $caseType['file'])) {
             $entities[] = array('module' => $caseType['module'], 'name' => $caseType['name'], 'entity' => 'OptionValue', 'params' => array('version' => 3, 'name' => $caseType['name'], 'label' => (string) $xml->name, 'description' => (string) $xml->description, 'option_group_id' => $caseTypesGroupId, 'is_reserved' => 1));
         } else {
             throw new CRM_Core_Exception("Invalid case type");
         }
     }
     return $entities;
 }
开发者ID:hguru,项目名称:224Civi,代码行数:27,代码来源:Info.php


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


示例10: initTasks

 static function initTasks()
 {
     if (!self::$_tasks) {
         self::$_tasks = array(1 => array('title' => ts('Add Contacts to Group'), 'class' => 'CRM_Contact_Form_Task_AddToGroup', 'result' => true), 2 => array('title' => ts('Remove Contacts from Group'), 'class' => 'CRM_Contact_Form_Task_RemoveFromGroup', 'result' => true), 3 => array('title' => ts('Tag Contacts (assign tags)'), 'class' => 'CRM_Contact_Form_Task_AddToTag', 'result' => true), 4 => array('title' => ts('Untag Contacts (remove tags)'), 'class' => 'CRM_Contact_Form_Task_RemoveFromTag', 'result' => true), 5 => array('title' => ts('Export Contacts'), 'class' => array('CRM_Export_Form_Select', 'CRM_Export_Form_Map'), 'result' => false), 6 => array('title' => ts('Send Email to Contacts'), 'class' => 'CRM_Contact_Form_Task_Email', 'result' => false), 7 => array('title' => ts('Send SMS to Contacts'), 'class' => 'CRM_Contact_Form_Task_SMS', 'result' => true), 8 => array('title' => ts('Delete Contacts'), 'class' => 'CRM_Contact_Form_Task_Delete', 'result' => false), 9 => array('title' => ts('Add Contacts to Household'), 'class' => 'CRM_Contact_Form_Task_AddToHousehold', 'result' => true), 10 => array('title' => ts('Add Contacts to Organization'), 'class' => 'CRM_Contact_Form_Task_AddToOrganization', 'result' => true), 11 => array('title' => ts('Record Activity for Contacts'), 'class' => 'CRM_Activity_Form_Activity', 'result' => true), 13 => array('title' => ts('New Smart Group'), 'class' => 'CRM_Contact_Form_Task_SaveSearch', 'result' => true), 14 => array('title' => ts('Update Smart Group'), 'class' => 'CRM_Contact_Form_Task_SaveSearch_Update', 'result' => true), 15 => array('title' => ts('Print Contacts'), 'class' => 'CRM_Contact_Form_Task_Print', 'result' => false), 16 => array('title' => ts('Mailing Labels'), 'class' => 'CRM_Contact_Form_Task_Label', 'result' => true), 17 => array('title' => ts('Batch Update via Profile'), 'class' => array('CRM_Contact_Form_Task_PickProfile', 'CRM_Contact_Form_Task_Batch'), 'result' => true), 19 => array('title' => ts('Print PDF Letter for Contacts'), 'class' => 'CRM_Contact_Form_Task_PDF', 'result' => true), 21 => array('title' => ts('Merge Contacts'), 'class' => 'CRM_Contact_Form_Task_Merge', 'result' => true));
         //CRM-4418, check for delete
         if (!CRM_Core_Permission::check('delete contacts')) {
             unset(self::$_tasks[8]);
         }
         //show map action only if map provider and key is set
         $config =& CRM_Core_Config::singleton();
         if ($config->mapProvider && $config->mapAPIKey) {
             self::$_tasks[12] = array('title' => ts('Map Contacts'), 'class' => 'CRM_Contact_Form_Task_Map', 'result' => false);
         }
         if (CRM_Core_Permission::access('CiviEvent')) {
             self::$_tasks[18] = array('title' => ts('Add Contacts to Event'), 'class' => 'CRM_Event_Form_Participant', 'result' => true);
         }
         if (CRM_Core_Permission::access('CiviMail')) {
             self::$_tasks[20] = array('title' => ts('Schedule/Send a Mass Mailing'), 'class' => array('CRM_Mailing_Form_Group', 'CRM_Mailing_Form_Settings', 'CRM_Mailing_Form_Upload', 'CRM_Mailing_Form_Test', 'CRM_Mailing_Form_Schedule'), 'result' => false);
         }
         self::$_tasks += CRM_Core_Component::taskList();
         require_once 'CRM/Utils/Hook.php';
         CRM_Utils_Hook::searchTasks('contact', self::$_tasks);
         asort(self::$_tasks);
     }
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:25,代码来源:Task.php


示例11: tearDown

 function tearDown()
 {
     $this->quickCleanup(array('civicrm_job', 'civicrm_action_log', 'civicrm_action_schedule'));
     $this->quickCleanUpFinancialEntities();
     CRM_Utils_Hook::singleton()->reset();
     parent::tearDown();
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:7,代码来源:JobTest.php


示例12: doDirectPayment

 /**
  * Submit a payment using Advanced Integration Method
  *
  * @param  array $params assoc array of input parameters for this transaction
  * @return array the result in a nice formatted array (or an error object)
  * @public
  */
 function doDirectPayment(&$params)
 {
     // Invoke hook_civicrm_paymentProcessor
     // In Dummy's case, there is no translation of parameters into
     // the back-end's canonical set of parameters.  But if a processor
     // does this, it needs to invoke this hook after it has done translation,
     // but before it actually starts talking to its proprietary back-end.
     $cookedParams = $params;
     // no translation in Dummy processor
     CRM_Utils_Hook::alterPaymentProcessorParams($this, $params, $cookedParams);
     //end of hook invokation
     if ($this->_mode == 'test') {
         $query = "SELECT MAX(trxn_id) FROM civicrm_contribution WHERE trxn_id LIKE 'test\\_%'";
         $p = array();
         $trxn_id = strval(CRM_Core_Dao::singleValueQuery($query, $p));
         $trxn_id = str_replace('test_', '', $trxn_id);
         $trxn_id = intval($trxn_id) + 1;
         $params['trxn_id'] = sprintf('test_%08d', $trxn_id);
     } else {
         $query = "SELECT MAX(trxn_id) FROM civicrm_contribution WHERE trxn_id LIKE 'live_%'";
         $p = array();
         $trxn_id = strval(CRM_Core_Dao::singleValueQuery($query, $p));
         $trxn_id = str_replace('live_', '', $trxn_id);
         $trxn_id = intval($trxn_id) + 1;
         $params['trxn_id'] = sprintf('live_%08d', $trxn_id);
     }
     $params['gross_amount'] = $params['amount'];
     return $params;
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:36,代码来源:Dummy.php


示例13: getTemplateFileName

 function getTemplateFileName()
 {
     $profID = CRM_Utils_Request::retrieve('gid', 'String', $this);
     $this->_params['contact_type'] = 'Individual';
     $selector = new CRM_Profile_Selector_Listings($this->_params, $this->_customFields, $profID, $this->_map, FALSE, 0);
     $extraWhereClause = NULL;
     $grpParams = array('name' => 'HRJobContract_Summary');
     CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomGroup', $grpParams, $cGrp);
     $fdParams = array('name' => 'Final_Termination_Date', 'custom_group_id' => $cGrp['id']);
     CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomField', $fdParams, $fdField);
     $idParams = array('name' => 'Initial_Join_Date', 'custom_group_id' => $cGrp['id']);
     CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomField', $idParams, $idField);
     $extraWhereClause = " (({$cGrp['table_name']}.{$fdField['column_name']} >= CURDATE() OR {$cGrp['table_name']}.{$fdField['column_name']} IS NULL) AND\n      ({$cGrp['table_name']}.{$idField['column_name']} IS NOT NULL AND {$cGrp['table_name']}.{$idField['column_name']} <= CURDATE()))";
     $column = $columnHeaders = $selector->getColumnHeaders();
     $rows = $selector->getRows(4, 0, 0, NULL, NULL, $extraWhereClause);
     CRM_Utils_Hook::searchColumns('profile', $columnHeaders, $rows, $this);
     $this->assign('aaData', json_encode($rows));
     /* to bring column names in [
     			{ "sTitle": "Engine" },
     			{ "sTitle": "Browser" },] format*/
     $colunmH = "[";
     foreach ($column as $k => $v) {
         if (!empty($v['name'])) {
             $name = '{"sTitle":"' . $v['name'] . '"}';
         } else {
             $name = '{"bSortable": false}';
         }
         $colunmH .= $name . ",";
     }
     $colunmH .= "]";
     $this->assign('aaColumn', $colunmH);
     return 'CRM/HRProfile/Page/HRProfile.tpl';
 }
开发者ID:JoeMurray,项目名称:civihr,代码行数:33,代码来源:HRProfile.php


示例14: onEvaluate

 /**
  * Load token data.
  *
  * @param TokenValueEvent $e
  * @throws TokenException
  */
 public function onEvaluate(TokenValueEvent $e)
 {
     // For reasons unknown, replaceHookTokens requires a pre-computed list of
     // hook *categories* (aka entities aka namespaces). We'll cache
     // this in the TokenProcessor's context.
     $hookTokens = array();
     \CRM_Utils_Hook::tokens($hookTokens);
     $categories = array_keys($hookTokens);
     $e->getTokenProcessor()->context['hookTokenCategories'] = $categories;
     $messageTokens = $e->getTokenProcessor()->getMessageTokens();
     foreach ($e->getRows() as $row) {
         if (empty($row->context['contact'])) {
             $params = array(array('contact_id', '=', $row->context['contactId'], 0, 0));
             list($contact, $_) = \CRM_Contact_BAO_Query::apiQuery($params);
             $contact = reset($contact);
             //CRM-4524
             if (!$contact || is_a($contact, 'CRM_Core_Error')) {
                 // FIXME: Need to differentiate errors which kill the batch vs the individual row.
                 throw new TokenException("Failed to generate token data. Invalid contact ID: " . $row->context['contactId']);
             }
         } else {
             $contact = $row->context['contact'];
         }
         if (!empty($row->context['tmpTokenParams'])) {
             // merge activity tokens with contact array
             // this is pretty weird.
             $contact = array_merge($contact, $row->context['tmpTokenParams']);
         }
         // Note: This is a small contract change from the past; data should be missing
         // less randomly.
         //\CRM_Utils_Hook::tokenValues($contact, $row->context['contactId']);
         \CRM_Utils_Hook::tokenValues($contact, $row->context['contactId'], empty($row->context['mailingJob']) ? NULL : $row->context['mailingJob']->id, $messageTokens, $row->context['controller']);
         $row->context('contact', $contact);
     }
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:41,代码来源:TokenCompatSubscriber.php


示例15: doDirectPayment

 function doDirectPayment(&$params)
 {
     $logon = $this->_paymentProcessor['user_name'];
     $password = $this->_paymentProcessor['password'];
     $url_site = $this->_paymentProcessor['url_site'];
     // create pjpgCustInfo object
     $pjpgCustInfo = new pjpgCustInfo();
     $pjpgCustInfo->setEmail($params['email']);
     $billing = array("logon" => $logon, "password" => $password, "url_site" => $url_site, "first_name" => $params['first_name'], "last_name" => $params['last_name'], "address" => $params['street_address'], "city" => $params['city'], "province" => $params['state_province'], "postal_code" => $params['postal_code'], "country" => $params['country']);
     $pjpgCustInfo->setBilling($billing);
     // create pjpgTransaction object
     $my_orderid = $params['invoiceID'];
     $expiry_string = sprintf('%04d%02d', $params['year'], $params['month']);
     $txnArray = array('type' => 'purchase', 'order_id' => $my_orderid, 'amount' => sprintf('%01.2f', $params['amount']), 'pan' => $params['credit_card_number'], 'expdate' => $expiry_string, 'crypt_type' => '7', 'cust_id' => $params['contact_id']);
     // Allow further manipulation of params via custom hooks
     CRM_Utils_Hook::alterPaymentProcessorParams($this, $params, $txnArray);
     $pjpgTxn = new pjpgTransaction($txnArray);
     // set customer info (level 3 data) for the transaction
     $pjpgTxn->setCustInfo($pjpgCustInfo);
     // empty installments convert to 999 because PayJunction do not allow open end donation
     if ($params['installments'] == "") {
         $params['installments'] = "999";
     }
     // create recurring object
     if ($params['is_recur'] == true && $params['installments'] > 1) {
         // schedule start date as today
         $params['dc_schedule_start'] = date("Y-m-d");
         // format: YYYY-MM-DD
         // Recur Variables
         $dc_schedule_create = $params['is_recur'];
         $recurUnit = $params['frequency_unit'];
         $recurInterval = $params['frequency_interval'];
         $dc_schedule_start = $params['dc_schedule_start'];
         $startDate = date("Y/m/d", $next);
         // next payment in moneris required format
         $numRecurs = $params['installments'];
         $recurArray = array('dc_schedule_create' => $dc_schedule_create, 'recur_unit' => $recurUnit, 'start_date' => $startDate, 'num_recurs' => $numRecurs, 'start_now' => 'false', 'period' => $recurInterval, 'dc_schedule_start' => $dc_schedule_start, 'amount' => sprintf('%01.2f', $params['amount']));
         $pjpgRecur = new pjpgRecur($recurArray);
         $pjpgTxn->setRecur($pjpgRecur);
     }
     // create a pjpgRequest object passing the transaction object
     $pjpgRequest = new pjpgRequest($pjpgTxn);
     $pjpgHttpPost = new pjpgHttpsPost($pjpgRequest);
     // get an pjpgResponse object
     $pjpgResponse = $pjpgHttpPost->getPJpgResponse();
     if (self::isError($pjpgResponse)) {
         return self::error($pjpgResponse);
     }
     /* Check for application errors */
     $result =& self::checkResult($pjpgResponse);
     if (is_a($result, 'CRM_Core_Error')) {
         return $result;
     }
     // Success
     $params['trxn_result_code'] = $pjpgResponse['dc_response_code'];
     $params['trxn_id'] = $pjpgResponse['dc_transaction_id'];
     $params['gross_amount'] = $params['amount'];
     return $params;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:59,代码来源:PayJunction.php


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


示例17: tearDown

 public function tearDown()
 {
     CRM_Utils_Hook::singleton()->reset();
     $this->quickCleanup(array('civicrm_group'));
     $config = CRM_Core_Config::singleton();
     unset($config->userPermissionClass->permissions);
     parent::tearDown();
 }
开发者ID:vakeesan26,项目名称:civicrm-core,代码行数:8,代码来源:AjaxTest.php


示例18: testHookCron

 public function testHookCron()
 {
     $hook = $this->getMock('stdClass', array('civicrm_cron'));
     $hook->expects($this->once())->method('civicrm_cron')->with($this->isInstanceOf('CRM_Core_JobManager'));
     CRM_Utils_Hook::singleton()->setMock($hook);
     $jobManager = new CRM_Core_JobManager();
     $jobManager->execute(FALSE);
 }
开发者ID:sdekok,项目名称:civicrm-core,代码行数:8,代码来源:JobManagerTest.php


示例19: tearDown

 /**
  * (non-PHPdoc)
  * @see CiviUnitTestCase::tearDown()
  */
 function tearDown()
 {
     CRM_Utils_Hook::singleton()->reset();
     $tablesToTruncate = array('civicrm_contact');
     $this->quickCleanup($tablesToTruncate);
     $config = CRM_Core_Config::singleton();
     unset($config->userPermissionClass->permissions);
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:12,代码来源:ACLPermissionTest.php


示例20: pdf_shared_token

 /**
  * This hook is called once for every batch before the pdf template is rendered.
  * You should use this for performance reasons when the token can be shared between chunk items (for example a contact
  * address that is the same for all files)
  *
  * You can implement this hook to add/modify template tokens
  * e.g. in your hook implementation call $template->assign('myCustomToken', 'my custom token');
  * and place a token called {$myCustomToken} in the template.
  *
  * @param object $template
  *
  * @return mixed based on op. pre-hooks return a boolean or
  * an error message which aborts the operation
  * @access public
  */
 static function pdf_shared_token(&$template, &$chunk)
 {
     if (version_compare(CRM_Utils_System::version(), '4.5', '<')) {
         return CRM_Utils_Hook::singleton()->invoke(1, $template, $chunk_item, self::$null, self::$null, self::$null, 'civicrm_pdf_shared_token');
     } else {
         return CRM_Utils_Hook::singleton()->invoke(1, $template, $chunk_item, self::$null, self::$null, self::$null, self::$null, 'civicrm_pdf_shared_token');
     }
 }
开发者ID:systopia,项目名称:de.systopia.donrec,代码行数:23,代码来源:DonrecCustomisationHooks.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP CRM_Utils_JSON类代码示例发布时间:2022-05-20
下一篇:
PHP CRM_Utils_File类代码示例发布时间:2022-05-20
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap