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


PHP CRM_Utils_Rule类代码示例

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


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

示例1: preProcess

 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     parent::preProcess();
     require_once 'CRM/Utils/Rule.php';
     $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this);
     $urlParams = 'force=1';
     if (CRM_Utils_Rule::qfKey($qfKey)) {
         $urlParams .= '&qfKey=' . $qfKey;
     }
     $session = CRM_Core_Session::singleton();
     $url = CRM_Utils_System::url('civicrm/contact/search/custom', $urlParams);
     $session->replaceUserContext($url);
     //get the survey id from user submitted values.
     $this->_surveyId = CRM_Utils_Array::value('survey_id', $this->get('formValues'));
     $isHeld = CRM_Utils_Array::value('status_id', $this->get('formValues'));
     if (!$this->_surveyId || !$isHeld) {
         CRM_Core_Error::statusBounce(ts("Please search with 'Is Held' and 'Survey Id' filters to apply this action."));
     }
     $session = CRM_Core_Session::singleton();
     if (empty($this->_contactIds) || !$session->get('userID')) {
         CRM_Core_Error::statusBounce(ts("Could not find contacts for release voters resevation Or Missing Interviewer contact."));
     }
     $this->_interviewerId = $session->get('userID');
     $surveyDetails = array();
     $params = array('id' => $this->_surveyId);
     $this->_surveyDetails = CRM_Campaign_BAO_Survey::retrieve($params, $surveyDetails);
     $numVoters = CRM_Core_DAO::singleValueQuery("SELECT COUNT(*) FROM " . self::ACTIVITY_SURVEY_DETAIL_TABLE . " WHERE status_id = 'H' AND survey_id = %1 AND interviewer_id = %2", array(1 => array($this->_surveyId, 'Integer'), 2 => array($this->_interviewerId, 'Integer')));
     if (!isset($numVoters) || $numVoters < 1) {
         CRM_Core_Error::statusBounce(ts("All voters held by you are already released for this survey."));
     }
     $this->assign('surveyTitle', $surveyDetails['title']);
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:38,代码来源:ReleaseVoters.php

示例2: preProcess

 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 public function preProcess()
 {
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     $this->_caseId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $context = CRM_Utils_Request::retrieve('context', 'String', $this);
     //get current client name.
     require_once 'CRM/Contact/BAO/Contact.php';
     $this->assign('currentClientName', CRM_Contact_BAO_Contact::displayName($this->_contactId));
     //set the context.
     $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&force=1&cid={$this->_contactId}&selectedChild=case");
     if ($context == 'search') {
         $qfKey = CRM_Utils_Request::retrieve('key', 'String', $this);
         //validate the qfKey
         require_once 'CRM/Utils/Rule.php';
         $urlParams = 'force=1';
         if (CRM_Utils_Rule::qfKey($qfKey)) {
             $urlParams .= "&qfKey={$qfKey}";
         }
         $url = CRM_Utils_System::url('civicrm/case/search', $urlParams);
     } else {
         if ($context == 'dashboard') {
             $url = CRM_Utils_System::url('civicrm/case', 'reset=1');
         }
     }
     $session = CRM_Core_Session::singleton();
     $session->pushUserContext($url);
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:33,代码来源:EditClient.php

示例3: _encodeHeaders

 function _encodeHeaders($input, $params = array())
 {
     require_once 'CRM/Utils/Rule.php';
     $emailValues = array();
     foreach ($input as $fieldName => $fieldValue) {
         $fieldNames = $emails = array();
         $hasValue = false;
         //multiple email w/ comma separate.
         $fieldValues = explode(',', $fieldValue);
         foreach ($fieldValues as $index => $value) {
             $value = trim($value);
             //might be case we have only email address.
             if (CRM_Utils_Rule::email($value)) {
                 $hasValue = true;
                 $emails[$index] = $value;
                 $fieldNames[$index] = 'FIXME_HACK_FOR_NO_NAME';
             } else {
                 $matches = array();
                 if (preg_match('/^(.*)<([^<]*)>$/', $value, $matches)) {
                     $hasValue = true;
                     $emails[$index] = $matches[2];
                     $fieldNames[$index] = trim($matches[1]);
                 }
             }
         }
         //get formatted values back in input
         if ($hasValue) {
             $input[$fieldName] = implode(',', $fieldNames);
             $emailValues[$fieldName] = implode(',', $emails);
         }
     }
     // encode the email-less headers
     $input = parent::_encodeHeaders($input, $params);
     // add emails back to headers, quoting these headers along the way
     foreach ($emailValues as $fieldName => $value) {
         $emails = explode(',', $value);
         $fieldNames = explode(',', $input[$fieldName]);
         foreach ($fieldNames as $index => &$name) {
             $name = str_replace('\\', '\\\\', $name);
             $name = str_replace('"', '\\"', $name);
             // CRM-5640 -if the name was actually doubly-quoted,
             // strip these(the next line will add them back);
             if (substr($name, 0, 2) == '\\"' && substr($name, -2) == '\\"') {
                 $name = substr($name, 2, -2);
             }
         }
         //combine fieldNames and emails.
         $mergeValues = array();
         foreach ($emails as $index => $email) {
             if ($fieldNames[$index] == 'FIXME_HACK_FOR_NO_NAME') {
                 $mergeValues[] = $email;
             } else {
                 $mergeValues[] = "\"{$fieldNames[$index]}\" <{$email}>";
             }
         }
         //finally get values in.
         $input[$fieldName] = implode(',', $mergeValues);
     }
     return $input;
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:60,代码来源:FixedMailMIME.php

示例4: preProcess

 /**
  * Build all the data structures needed to build the form.
  */
 public function preProcess()
 {
     $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
     CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
     $context = CRM_Utils_Request::retrieve('context', 'String', $this);
     //get current client name.
     $this->assign('currentClientName', CRM_Contact_BAO_Contact::displayName($cid));
     //set the context.
     $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&force=1&cid={$cid}&selectedChild=case");
     if ($context == 'search') {
         $qfKey = CRM_Utils_Request::retrieve('key', 'String', $this);
         //validate the qfKey
         $urlParams = 'force=1';
         if (CRM_Utils_Rule::qfKey($qfKey)) {
             $urlParams .= "&qfKey={$qfKey}";
         }
         $url = CRM_Utils_System::url('civicrm/case/search', $urlParams);
     } elseif ($context == 'dashboard') {
         $url = CRM_Utils_System::url('civicrm/case', 'reset=1');
     } elseif (in_array($context, array('dashlet', 'dashletFullscreen'))) {
         $url = CRM_Utils_System::url('civicrm/dashboard', 'reset=1');
     }
     $session = CRM_Core_Session::singleton();
     $session->pushUserContext($url);
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:28,代码来源:EditClient.php

示例5: preProcess

 function preProcess()
 {
     $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE);
     $oid = CRM_Utils_Request::retrieve('oid', 'Positive', $this, FALSE);
     if ($oid) {
         $this->_id = CRM_Utils_Request::retrieve('oid', 'Positive', $this, FALSE);
     } else {
         $this->assign('hide_contact', TRUE);
         $this->_id = $cid;
     }
     if (!CRM_Utils_Rule::positiveInteger($this->_id)) {
         CRM_Core_Error::fatal('We need a valid discount ID for view');
     }
     $this->assign('id', $this->_id);
     $defaults = array();
     $params = array('id' => $this->_id);
     require_once 'CRM/CiviDiscount/BAO/Item.php';
     CRM_CiviDiscount_BAO_Item::retrieve($params, $defaults);
     require_once 'CRM/CiviDiscount/BAO/Track.php';
     if ($cid) {
         $rows = CRM_CiviDiscount_BAO_Track::getUsageByContact($this->_id);
     } else {
         $rows = CRM_CiviDiscount_BAO_Track::getUsageByOrg($this->_id);
     }
     $this->assign('rows', $rows);
     $this->assign('code_details', $defaults);
     $this->ajaxResponse['tabCount'] = count($rows);
     if (!empty($defaults['code'])) {
         CRM_Utils_System::setTitle($defaults['code']);
     }
 }
开发者ID:mathavanveda,项目名称:org.civicrm.module.cividiscount,代码行数:31,代码来源:Usage.php

示例6: create

 /**
  * takes an associative array and creates a financial transaction object
  *
  * @param array  $params (reference ) an assoc array of name/value pairs
  *
  * @return object CRM_Core_BAO_FinancialTrxn object
  * @access public
  * @static
  */
 static function create(&$params)
 {
     $trxn = new CRM_Core_DAO_FinancialTrxn();
     $trxn->copyValues($params);
     require_once 'CRM/Utils/Rule.php';
     if (!CRM_Utils_Rule::currencyCode($trxn->currency)) {
         require_once 'CRM/Core/Config.php';
         $config = CRM_Core_Config::singleton();
         $trxn->currency = $config->defaultCurrency;
     }
     // if a transaction already exists for a contribution id, lets get the finTrxnId and entityFinTrxId
     $fids = self::getFinancialTrxnIds($params['contribution_id'], 'civicrm_contribution');
     if ($fids['financialTrxnId']) {
         $trxn->id = $fids['financialTrxnId'];
     }
     $trxn->save();
     $contributionAmount = CRM_Utils_Array::value('net_amount', $params);
     if (!$contributionAmount && isset($params['total_amount'])) {
         $contributionAmount = $params['total_amount'];
     }
     // save to entity_financial_trxn table
     $entity_financial_trxn_params = array('entity_table' => "civicrm_contribution", 'entity_id' => $params['contribution_id'], 'financial_trxn_id' => $trxn->id, 'amount' => $contributionAmount, 'currency' => $trxn->currency);
     $entity_trxn =& new CRM_Core_DAO_EntityFinancialTrxn();
     $entity_trxn->copyValues($entity_financial_trxn_params);
     if ($fids['entityFinancialTrxnId']) {
         $entity_trxn->id = $fids['entityFinancialTrxnId'];
     }
     $entity_trxn->save();
     return $trxn;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:39,代码来源:FinancialTrxn.php

示例7: preProcess

 /**
  * Build all the data structures needed to build the form.
  *
  * @return void
  */
 public function preProcess()
 {
     $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE);
     if ($id) {
         $this->_contributionIds = array($id);
         $this->_componentClause = " civicrm_contribution.id IN ( {$id} ) ";
         $this->_single = TRUE;
         $this->assign('totalSelectedContributions', 1);
     } else {
         parent::preProcess();
     }
     // check that all the contribution ids have pending status
     $query = "\nSELECT count(*)\nFROM   civicrm_contribution\nWHERE  contribution_status_id != 1\nAND    {$this->_componentClause}";
     $count = CRM_Core_DAO::singleValueQuery($query);
     if ($count != 0) {
         CRM_Core_Error::statusBounce("Please select only online contributions with Completed status.");
     }
     // we have all the contribution ids, so now we get the contact ids
     parent::setContactIDs();
     $this->assign('single', $this->_single);
     $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this);
     $urlParams = 'force=1';
     if (CRM_Utils_Rule::qfKey($qfKey)) {
         $urlParams .= "&qfKey={$qfKey}";
     }
     $url = CRM_Utils_System::url('civicrm/contribute/search', $urlParams);
     $breadCrumb = array(array('url' => $url, 'title' => ts('Search Results')));
     CRM_Utils_System::appendBreadCrumb($breadCrumb);
     CRM_Utils_System::setTitle(ts('Print Contribution Receipts'));
 }
开发者ID:rajeshrhino,项目名称:civicrm-core,代码行数:35,代码来源:PDF.php

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

示例9: titleToVar

 /**
  * Convert a display name into a potential variable
  * name that we could use in forms/code
  * 
  * @param  name    Name of the string
  * @return string  An equivalent variable name
  *
  * @access public
  * @return string (or null)
  * @static
  */
 static function titleToVar($title, $maxLength = 31)
 {
     $variable = self::munge($title);
     require_once "CRM/Utils/Rule.php";
     if (CRM_Utils_Rule::title($variable, $maxLength)) {
         return $variable;
     }
     return null;
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:20,代码来源:String.php

示例10: titleToVar

 /**
  * Convert a display name into a potential variable
  * name that we could use in forms/code
  *
  * @param  name    Name of the string
  *
  * @param int $maxLength
  *
  * @return string  An equivalent variable name
  *
  * @access public
  *
  * @return string (or null)
  * @static
  */
 static function titleToVar($title, $maxLength = 31)
 {
     $variable = self::munge($title, '_', $maxLength);
     if (CRM_Utils_Rule::title($variable, $maxLength)) {
         return $variable;
     }
     // if longer than the maxLength lets just return a substr of the
     // md5 to prevent errors downstream
     return substr(md5($title), 0, $maxLength);
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:25,代码来源:String.php

示例11: titleToVar

 /**
  * Convert a display name into a potential variable
  * name that we could use in forms/code
  * 
  * @param  name    Name of the string
  * @return string  An equivalent variable name
  *
  * @access public
  * @return string (or null)
  * @static
  */
 function titleToVar($title)
 {
     if (!CRM_Utils_Rule::title($title)) {
         return null;
     }
     $variable = CRM_Utils_String::munge($title);
     if (CRM_Utils_Rule::variable($variable)) {
         return $variable;
     }
     return null;
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:22,代码来源:String.php

示例12: __construct

 /**
  * @param string $name
  *   Symbolic name for the check.
  * @param string $message
  *   Printable message (short or long).
  * @param string $title
  *   Printable message (short).
  * @param string $level
  *   The severity of the message. Use PSR-3 log levels.
  *
  * @see Psr\Log\LogLevel
  */
 public function __construct($name, $message, $title, $level = \Psr\Log\LogLevel::WARNING)
 {
     $this->name = $name;
     $this->message = $message;
     $this->title = $title;
     // Handle non-integer severity levels.
     if (!CRM_Utils_Rule::integer($level)) {
         $level = CRM_Utils_Check::severityMap($level);
     }
     $this->level = $level;
 }
开发者ID:nganivet,项目名称:civicrm-core,代码行数:23,代码来源:Message.php

示例13: isContactInGroup

 /**
  * Checks wether a contact is a member of a group
  *
  * This function is a copy of CRM_Contact_BAO_GroupContact::isContactInGroup but with
  * a change so that the group contact cache won't be rebuild. Which somehow resulted
  * in a deadlock
  *
  * @param $contact_id
  * @param $group_id
  * @return bool
  */
 public static function isContactInGroup($contact_id, $group_id)
 {
     if (!CRM_Utils_Rule::positiveInteger($contact_id) || !CRM_Utils_Rule::positiveInteger($group_id)) {
         return FALSE;
     }
     $params = array(array('group', 'IN', array($group_id => 1), 0, 0), array('contact_id', '=', $contact_id, 0, 0));
     list($contacts, $_) = CRM_Contact_BAO_Query::apiQuery($params, array('contact_id'), null, null, 0, 1, false, false, true);
     if (!empty($contacts)) {
         return TRUE;
     }
     return FALSE;
 }
开发者ID:alejandro-ixiam,项目名称:org.civicoop.civirules,代码行数:23,代码来源:GroupContact.php

示例14: array

 /**
  * Form rule to validate the date selector and/or if we should deliver
  * immediately.
  *
  * Warning: if you make changes here, be sure to also make them in
  * Retry.php
  * 
  * @param array $params     The form values
  * @return boolean          True if either we deliver immediately, or the
  *                          date is properly set.
  * @static
  */
 function &formRule(&$params)
 {
     if ($params['now']) {
         return true;
     }
     if (!CRM_Utils_Rule::qfDate($params['start_date'])) {
         return array('start_date' => ts('Start date is not valid.'));
     }
     if (CRM_Utils_Date::format($params['start_date']) < date('YmdHi00')) {
         return array('start_date' => ts('Start date cannot be earlier than the current time.'));
     }
     return true;
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:25,代码来源:Schedule.php

示例15: create

 /**
  * takes an associative array and creates a financial transaction object
  *
  * @param array  $params (reference ) an assoc array of name/value pairs
  *
  * @return object CRM_Contribute_BAO_FinancialTrxn object
  * @access public
  * @static
  */
 function create(&$params)
 {
     $trxn =& new CRM_Contribute_DAO_FinancialTrxn();
     $trxn->copyValues($params);
     $trxn->domain_id = CRM_Core_Config::domainID();
     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;
     }
     return $trxn->save();
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:22,代码来源:FinancialTrxn.php


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