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


PHP CRM_Utils_Rule::url方法代码示例

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


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

示例1: isErrorInCoreData


//.........这里部分代码省略.........
                                 } else {
                                     self::addToErrorMsg(ts('Geo code 1'), $errorMessage);
                                 }
                             }
                         }
                     }
                     break;
                 case 'geo_code_2':
                     if (!empty($value)) {
                         foreach ($value as $codeValue) {
                             if ($codeValue['geo_code_2']) {
                                 if (CRM_Utils_Rule::numeric($codeValue['geo_code_2'])) {
                                     continue;
                                 } else {
                                     self::addToErrorMsg(ts('Geo code 2'), $errorMessage);
                                 }
                             }
                         }
                     }
                     break;
                     //check for any error in email/postal greeting, addressee,
                     //custom email/postal greeting, custom addressee, CRM-4575
                 //check for any error in email/postal greeting, addressee,
                 //custom email/postal greeting, custom addressee, CRM-4575
                 case 'email_greeting':
                     $emailGreetingFilter = array('contact_type' => $this->_contactType, 'greeting_type' => 'email_greeting');
                     if (!self::in_value($value, CRM_Core_PseudoConstant::greeting($emailGreetingFilter))) {
                         self::addToErrorMsg(ts('Email Greeting must be one of the configured format options. Check Administer >> Option Lists >> Email Greetings for valid values'), $errorMessage);
                     }
                     break;
                 case 'postal_greeting':
                     $postalGreetingFilter = array('contact_type' => $this->_contactType, 'greeting_type' => 'postal_greeting');
                     if (!self::in_value($value, CRM_Core_PseudoConstant::greeting($postalGreetingFilter))) {
                         self::addToErrorMsg(ts('Postal Greeting must be one of the configured format options. Check Administer >> Option Lists >> Postal Greetings for valid values'), $errorMessage);
                     }
                     break;
                 case 'addressee':
                     $addresseeFilter = array('contact_type' => $this->_contactType, 'greeting_type' => 'addressee');
                     if (!self::in_value($value, CRM_Core_PseudoConstant::greeting($addresseeFilter))) {
                         self::addToErrorMsg(ts('Addressee must be one of the configured format options. Check Administer >> Option Lists >> Addressee for valid values'), $errorMessage);
                     }
                     break;
                 case 'email_greeting_custom':
                     if (array_key_exists('email_greeting', $params)) {
                         $emailGreetingLabel = key(CRM_Core_OptionGroup::values('email_greeting', true, null, null, 'AND v.name = "Customized"'));
                         if (CRM_Utils_Array::value('email_greeting', $params) != $emailGreetingLabel) {
                             self::addToErrorMsg(ts('Email Greeting - Custom'), $errorMessage);
                         }
                     }
                     break;
                 case 'postal_greeting_custom':
                     if (array_key_exists('postal_greeting', $params)) {
                         $postalGreetingLabel = key(CRM_Core_OptionGroup::values('postal_greeting', true, null, null, 'AND v.name = "Customized"'));
                         if (CRM_Utils_Array::value('postal_greeting', $params) != $postalGreetingLabel) {
                             self::addToErrorMsg(ts('Postal Greeting - Custom'), $errorMessage);
                         }
                     }
                     break;
                 case 'addressee_custom':
                     if (array_key_exists('addressee', $params)) {
                         $addresseeLabel = key(CRM_Core_OptionGroup::values('addressee', true, null, null, 'AND v.name = "Customized"'));
                         if (CRM_Utils_Array::value('addressee', $params) != $addresseeLabel) {
                             self::addToErrorMsg(ts('Addressee - Custom'), $errorMessage);
                         }
                     }
                     break;
                 case 'home_URL':
                     if (CRM_Utils_Rule::url($value) === false) {
                         self::addToErrorMsg(ts('Website'), $errorMessage);
                     }
                     break;
                 case 'do_not_email':
                 case 'do_not_phone':
                 case 'do_not_mail':
                 case 'do_not_sms':
                 case 'do_not_trade':
                     if (CRM_Utils_Rule::boolean($value) == false) {
                         $key = ucwords(str_replace("_", " ", $key));
                         self::addToErrorMsg($key, $errorMessage);
                     }
                     break;
                 case 'email':
                     if (is_array($value)) {
                         foreach ($value as $values) {
                             if (CRM_Utils_Array::value('email', $values) && !CRM_Utils_Rule::email($values['email'])) {
                                 self::addToErrorMsg($key, $errorMessage);
                                 break;
                             }
                         }
                     }
                     break;
                 default:
                     if (is_array($params[$key]) && isset($params[$key]["contact_type"])) {
                         //check for any relationship data ,FIX ME
                         self::isErrorInCoreData($params[$key], $errorMessage);
                     }
             }
         }
     }
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:101,代码来源:Contact.php

示例2: _civicrm_api3_custom_field_validate_field

/**
 * Helper function to validate custom field value
 *
 * @params String $fieldName    Custom field name (eg: custom_8 )
 * @params Mixed  $value        Field value to be validate
 * @params Array  $fieldDetails Field Details
 * @params Array  $errors       Collect validation  errors
 *
 * @param $fieldName
 * @param $value
 * @param $fieldDetails
 * @param array $errors
 *
 * @return Array  Validation errors
 * @todo remove this function - not in use but need to review functionality before
 * removing as it might be useful in wrapper layer
 */
function _civicrm_api3_custom_field_validate_field($fieldName, $value, $fieldDetails, &$errors = array())
{
    return;
    //see comment block
    if (!$value) {
        return $errors;
    }
    $dataType = $fieldDetails['data_type'];
    $htmlType = $fieldDetails['html_type'];
    switch ($dataType) {
        case 'Int':
            if (!CRM_Utils_Rule::integer($value)) {
                $errors[$fieldName] = 'Invalid integer value for ' . $fieldName;
            }
            break;
        case 'Float':
            if (!CRM_Utils_Rule::numeric($value)) {
                $errors[$fieldName] = 'Invalid numeric value for ' . $fieldName;
            }
            break;
        case 'Money':
            if (!CRM_Utils_Rule::money($value)) {
                $errors[$fieldName] = 'Invalid numeric value for ' . $fieldName;
            }
            break;
        case 'Link':
            if (!CRM_Utils_Rule::url($value)) {
                $errors[$fieldName] = 'Invalid link for ' . $fieldName;
            }
            break;
        case 'Boolean':
            if ($value != '1' && $value != '0') {
                $errors[$fieldName] = 'Invalid boolean (use 1 or 0) value for ' . $fieldName;
            }
            break;
        case 'Country':
            if (empty($value)) {
                break;
            }
            if ($htmlType != 'Multi-Select Country' && is_array($value)) {
                $errors[$fieldName] = 'Invalid country for ' . $fieldName;
                break;
            }
            if (!is_array($value)) {
                $value = array($value);
            }
            $query = "SELECT count(*) FROM civicrm_country WHERE id IN (" . implode(',', $value) . ")";
            if (CRM_Core_DAO::singleValueQuery($query) < count($value)) {
                $errors[$fieldName] = 'Invalid country(s) for ' . $fieldName;
            }
            break;
        case 'StateProvince':
            if (empty($value)) {
                break;
            }
            if ($htmlType != 'Multi-Select State/Province' && is_array($value)) {
                $errors[$fieldName] = 'Invalid State/Province for ' . $fieldName;
                break;
            }
            if (!is_array($value)) {
                $value = array($value);
            }
            $query = "\nSELECT count(*)\n  FROM civicrm_state_province\n WHERE id IN ('" . implode("','", $value) . "')";
            if (CRM_Core_DAO::singleValueQuery($query) < count($value)) {
                $errors[$fieldName] = 'Invalid State/Province for ' . $fieldName;
            }
            break;
        case 'ContactReference':
            //FIX ME
            break;
    }
    if (in_array($htmlType, array('Select', 'Multi-Select', 'CheckBox', 'Radio', 'AdvMulti-Select')) && !isset($errors[$fieldName])) {
        $options = CRM_Core_OptionGroup::valuesByID($fieldDetails['option_group_id']);
        if (!is_array($value)) {
            $value = array($value);
        }
        $invalidOptions = array_diff($value, array_keys($options));
        if (!empty($invalidOptions)) {
            $errors[$fieldName] = "Invalid option(s) for field '{$fieldName}': " . implode(',', $invalidOptions);
        }
    }
    return $errors;
}
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:100,代码来源:CustomField.php

示例3: formRule

 /**
  * global validation rules for the form
  *
  * @param array  $fields   (referance) posted values of the form
  *
  * @return array    if errors then list of errors to be posted back to the form,
  *                  true otherwise
  * @static
  * @access public
  */
 static function formRule($fields, $files, $self)
 {
     $default = CRM_Utils_Array::value('default_value', $fields);
     $errors = array();
     //validate field label as well as name.
     $title = $fields['label'];
     $name = CRM_Utils_String::munge($title, '_', 64);
     $gId = $self->_gid;
     // CRM-7564
     $query = 'select count(*) from civicrm_custom_field where ( name like %1 OR label like %2 ) and id != %3 and custom_group_id = %4';
     $fldCnt = CRM_Core_DAO::singleValueQuery($query, array(1 => array($name, 'String'), 2 => array($title, 'String'), 3 => array((int) $self->_id, 'Integer'), 4 => array($gId, 'Integer')));
     if ($fldCnt) {
         $errors['label'] = ts('Custom field \'%1\' already exists in Database.', array(1 => $title));
     }
     //checks the given custom field name doesnot start with digit
     if (!empty($title)) {
         // gives the ascii value
         $asciiValue = ord($title[0]);
         if ($asciiValue >= 48 && $asciiValue <= 57) {
             $errors['label'] = ts("Field's Name should not start with digit");
         }
     }
     // ensure that the label is not 'id'
     if (strtolower($title) == 'id') {
         $errors['label'] = ts("You cannot use 'id' as a field label.");
     }
     if (!isset($fields['data_type'][0]) || !isset($fields['data_type'][1])) {
         $errors['_qf_default'] = ts('Please enter valid - Data and Input Field Type.');
     }
     $dataType = self::$_dataTypeKeys[$fields['data_type'][0]];
     if ($default || $dataType == 'ContactReference') {
         switch ($dataType) {
             case 'Int':
                 if (!CRM_Utils_Rule::integer($default)) {
                     $errors['default_value'] = ts('Please enter a valid integer as default value.');
                 }
                 break;
             case 'Float':
                 if (!CRM_Utils_Rule::numeric($default)) {
                     $errors['default_value'] = ts('Please enter a valid number as default value.');
                 }
                 break;
             case 'Money':
                 if (!CRM_Utils_Rule::money($default)) {
                     $errors['default_value'] = ts('Please enter a valid number value.');
                 }
                 break;
             case 'Link':
                 if (!CRM_Utils_Rule::url($default)) {
                     $errors['default_value'] = ts('Please enter a valid link.');
                 }
                 break;
             case 'Date':
                 if (!CRM_Utils_Rule::date($default)) {
                     $errors['default_value'] = ts('Please enter a valid date as default value using YYYY-MM-DD format. Example: 2004-12-31.');
                 }
                 break;
             case 'Boolean':
                 if ($default != '1' && $default != '0') {
                     $errors['default_value'] = ts('Please enter 1 (for Yes) or 0 (for No) if you want to set a default value.');
                 }
                 break;
             case 'Country':
                 if (!empty($default)) {
                     $query = "SELECT count(*) FROM civicrm_country WHERE name = %1 OR iso_code = %1";
                     $params = array(1 => array($fields['default_value'], 'String'));
                     if (CRM_Core_DAO::singleValueQuery($query, $params) <= 0) {
                         $errors['default_value'] = ts('Invalid default value for country.');
                     }
                 }
                 break;
             case 'StateProvince':
                 if (!empty($default)) {
                     $query = "\nSELECT count(*)\n  FROM civicrm_state_province\n WHERE name = %1\n    OR abbreviation = %1";
                     $params = array(1 => array($fields['default_value'], 'String'));
                     if (CRM_Core_DAO::singleValueQuery($query, $params) <= 0) {
                         $errors['default_value'] = ts('The invalid default value for State/Province data type');
                     }
                 }
                 break;
             case 'ContactReference':
                 if ($fields['filter_selected'] == 'Advance' && CRM_Utils_Array::value('filter', $fields)) {
                     if (strpos($fields['filter'], 'entity=') !== FALSE) {
                         $errors['filter'] = ts("Please do not include entity parameter (entity is always 'contact')");
                     } elseif (strpos($fields['filter'], 'action=') === FALSE) {
                         $errors['filter'] = ts("Please specify 'action' parameter, it should be 'lookup' or 'get'");
                     } elseif (strpos($fields['filter'], 'action=get') === FALSE && strpos($fields['filter'], 'action=lookup') === FALSE) {
                         $errors['filter'] = ts("Only 'get' and 'lookup' actions are supported.");
                     }
                 }
//.........这里部分代码省略.........
开发者ID:hguru,项目名称:224Civi,代码行数:101,代码来源:Field.php

示例4: typecheck

 /**
  * Validate a value against a CustomField type.
  *
  * @param string $type
  *   The type of the data.
  * @param string $value
  *   The data to be validated.
  *
  * @return bool
  *   True if the value is of the specified type
  */
 public static function typecheck($type, $value)
 {
     switch ($type) {
         case 'Memo':
             return TRUE;
         case 'String':
             return CRM_Utils_Rule::string($value);
         case 'Int':
             return CRM_Utils_Rule::integer($value);
         case 'Float':
         case 'Money':
             return CRM_Utils_Rule::numeric($value);
         case 'Date':
             if (is_numeric($value)) {
                 return CRM_Utils_Rule::dateTime($value);
             } else {
                 return CRM_Utils_Rule::date($value);
             }
         case 'Boolean':
             return CRM_Utils_Rule::boolean($value);
         case 'ContactReference':
             return CRM_Utils_Rule::validContact($value);
         case 'StateProvince':
             //fix for multi select state, CRM-3437
             $valid = FALSE;
             $mulValues = explode(',', $value);
             foreach ($mulValues as $key => $state) {
                 $valid = array_key_exists(strtolower(trim($state)), array_change_key_case(array_flip(CRM_Core_PseudoConstant::stateProvinceAbbreviation()), CASE_LOWER)) || array_key_exists(strtolower(trim($state)), array_change_key_case(array_flip(CRM_Core_PseudoConstant::stateProvince()), CASE_LOWER));
                 if (!$valid) {
                     break;
                 }
             }
             return $valid;
         case 'Country':
             //fix multi select country, CRM-3437
             $valid = FALSE;
             $mulValues = explode(',', $value);
             foreach ($mulValues as $key => $country) {
                 $valid = array_key_exists(strtolower(trim($country)), array_change_key_case(array_flip(CRM_Core_PseudoConstant::countryIsoCode()), CASE_LOWER)) || array_key_exists(strtolower(trim($country)), array_change_key_case(array_flip(CRM_Core_PseudoConstant::country()), CASE_LOWER));
                 if (!$valid) {
                     break;
                 }
             }
             return $valid;
         case 'Link':
             return CRM_Utils_Rule::url($value);
     }
     return FALSE;
 }
开发者ID:rajeshrhino,项目名称:civicrm-core,代码行数:60,代码来源:CustomValue.php

示例5: escape

 /**
  * Verify that a variable is of a given type, and apply a bit of processing.
  *
  * @param mixed $data
  *   The value to be verified/escaped.
  * @param string $type
  *   The type to verify against.
  * @param bool $abort
  *   If TRUE, the operation will CRM_Core_Error::fatal() on invalid data.
  *
  * @return mixed
  *   The data, escaped if necessary.
  */
 public static function escape($data, $type, $abort = TRUE)
 {
     switch ($type) {
         case 'Integer':
         case 'Int':
             if (CRM_Utils_Rule::integer($data)) {
                 return (int) $data;
             }
             break;
         case 'Positive':
             // CRM-8925 the 3 below are for custom fields of this type
         // CRM-8925 the 3 below are for custom fields of this type
         case 'Country':
         case 'StateProvince':
             // Checked for multi valued state/country value
             if (is_array($data)) {
                 $returnData = TRUE;
                 // @todo Reuse of the $data variable = asking for trouble.
                 // @todo This code will always return the last item in the array. Intended?
                 foreach ($data as $data) {
                     if (CRM_Utils_Rule::positiveInteger($data) || CRM_Core_DAO::escapeString($data)) {
                         $returnData = TRUE;
                     } else {
                         $returnData = FALSE;
                     }
                 }
                 if ($returnData) {
                     return $data;
                 }
             } elseif (!is_numeric($data) && CRM_Core_DAO::escapeString($data)) {
                 return $data;
             } elseif (CRM_Utils_Rule::positiveInteger($data)) {
                 return $data;
             }
             break;
         case 'File':
             if (CRM_Utils_Rule::positiveInteger($data)) {
                 return $data;
             }
             break;
         case 'Link':
             if (CRM_Utils_Rule::url($data = trim($data))) {
                 return $data;
             }
             break;
         case 'Boolean':
             if (CRM_Utils_Rule::boolean($data)) {
                 return $data;
             }
             break;
         case 'Float':
         case 'Money':
             if (CRM_Utils_Rule::numeric($data)) {
                 return $data;
             }
             break;
         case 'String':
         case 'Memo':
         case 'Text':
             return CRM_Core_DAO::escapeString($data);
         case 'Date':
         case 'Timestamp':
             // a null date or timestamp is valid
             if (strlen(trim($data)) == 0) {
                 return trim($data);
             }
             if ((preg_match('/^\\d{8}$/', $data) || preg_match('/^\\d{14}$/', $data)) && CRM_Utils_Rule::mysqlDate($data)) {
                 return $data;
             }
             break;
         case 'ContactReference':
             if (strlen(trim($data)) == 0) {
                 return trim($data);
             }
             if (CRM_Utils_Rule::validContact($data)) {
                 return $data;
             }
             break;
         default:
             CRM_Core_Error::fatal($type . " is not a recognised (camel cased) data type.");
             break;
     }
     // @todo Use exceptions instead of CRM_Core_Error::fatal().
     if ($abort) {
         $data = htmlentities($data);
         CRM_Core_Error::fatal("{$data} is not of the type {$type}");
     }
//.........这里部分代码省略.........
开发者ID:rajeshrhino,项目名称:civicrm-core,代码行数:101,代码来源:Type.php

示例6: escape

 /**
  * Verify that a variable is of a given type, and apply a bit of processing.
  *
  * @param mixed $data
  *   The value to be verified/escaped.
  * @param string $type
  *   The type to verify against.
  * @param bool $abort
  *   If TRUE, the operation will CRM_Core_Error::fatal() on invalid data.
  *
  * @return mixed
  *   The data, escaped if necessary.
  */
 public static function escape($data, $type, $abort = TRUE)
 {
     switch ($type) {
         case 'Integer':
         case 'Int':
             if (CRM_Utils_Rule::integer($data)) {
                 return (int) $data;
             }
             break;
         case 'Positive':
             if (CRM_Utils_Rule::positiveInteger($data)) {
                 return (int) $data;
             }
             break;
             // CRM-8925 for custom fields of this type
         // CRM-8925 for custom fields of this type
         case 'Country':
         case 'StateProvince':
             // Handle multivalued data in delimited or array format
             if (is_array($data) || strpos($data, CRM_Core_DAO::VALUE_SEPARATOR) !== FALSE) {
                 $valid = TRUE;
                 foreach (CRM_Utils_Array::explodePadded($data) as $item) {
                     if (!CRM_Utils_Rule::positiveInteger($item)) {
                         $valid = FALSE;
                     }
                 }
                 if ($valid) {
                     return $data;
                 }
             } elseif (CRM_Utils_Rule::positiveInteger($data)) {
                 return (int) $data;
             }
             break;
         case 'File':
             if (CRM_Utils_Rule::positiveInteger($data)) {
                 return (int) $data;
             }
             break;
         case 'Link':
             if (CRM_Utils_Rule::url($data = trim($data))) {
                 return $data;
             }
             break;
         case 'Boolean':
             if (CRM_Utils_Rule::boolean($data)) {
                 return $data;
             }
             break;
         case 'Float':
         case 'Money':
             if (CRM_Utils_Rule::numeric($data)) {
                 return $data;
             }
             break;
         case 'String':
         case 'Memo':
         case 'Text':
             return CRM_Core_DAO::escapeString($data);
         case 'Date':
         case 'Timestamp':
             // a null date or timestamp is valid
             if (strlen(trim($data)) == 0) {
                 return trim($data);
             }
             if ((preg_match('/^\\d{8}$/', $data) || preg_match('/^\\d{14}$/', $data)) && CRM_Utils_Rule::mysqlDate($data)) {
                 return $data;
             }
             break;
         case 'ContactReference':
             if (strlen(trim($data)) == 0) {
                 return trim($data);
             }
             if (CRM_Utils_Rule::validContact($data)) {
                 return (int) $data;
             }
             break;
         case 'MysqlColumnNameOrAlias':
             if (CRM_Utils_Rule::mysqlColumnNameOrAlias($data)) {
                 $data = str_replace('`', '', $data);
                 $parts = explode('.', $data);
                 $data = '`' . implode('`.`', $parts) . '`';
                 return $data;
             }
             break;
         case 'MysqlOrderByDirection':
             if (CRM_Utils_Rule::mysqlOrderByDirection($data)) {
                 return strtolower($data);
//.........这里部分代码省略.........
开发者ID:nielosz,项目名称:civicrm-core,代码行数:101,代码来源:Type.php

示例7: escape

 /**
  * Verify that a variable is of a given type, and apply a bit of processing.
  *
  * @param mixed $data
  *   The value to be verified/escaped.
  * @param string $type
  *   The type to verify against.
  * @param bool $abort
  *   If TRUE, the operation will CRM_Core_Error::fatal() on invalid data.
  *
  * @return mixed
  *   The data, escaped if necessary.
  */
 public static function escape($data, $type, $abort = TRUE)
 {
     switch ($type) {
         case 'Integer':
         case 'Int':
             if (CRM_Utils_Rule::integer($data)) {
                 return (int) $data;
             }
             break;
         case 'Positive':
             if (CRM_Utils_Rule::positiveInteger($data)) {
                 return (int) $data;
             }
             break;
             // CRM-8925 for custom fields of this type
         // CRM-8925 for custom fields of this type
         case 'Country':
         case 'StateProvince':
             // Handle multivalued data in delimited or array format
             if (is_array($data) || strpos($data, CRM_Core_DAO::VALUE_SEPARATOR) !== FALSE) {
                 $valid = TRUE;
                 foreach (CRM_Utils_Array::explodePadded($data) as $item) {
                     if (!CRM_Utils_Rule::positiveInteger($item)) {
                         $valid = FALSE;
                     }
                 }
                 if ($valid) {
                     return $data;
                 }
             } elseif (CRM_Utils_Rule::positiveInteger($data)) {
                 return (int) $data;
             }
             break;
         case 'File':
             if (CRM_Utils_Rule::positiveInteger($data)) {
                 return (int) $data;
             }
             break;
         case 'Link':
             if (CRM_Utils_Rule::url($data = trim($data))) {
                 return $data;
             }
             break;
         case 'Boolean':
             if (CRM_Utils_Rule::boolean($data)) {
                 return $data;
             }
             break;
         case 'Float':
         case 'Money':
             if (CRM_Utils_Rule::numeric($data)) {
                 return $data;
             }
             break;
         case 'String':
         case 'Memo':
         case 'Text':
             return CRM_Core_DAO::escapeString($data);
         case 'Date':
         case 'Timestamp':
             // a null date or timestamp is valid
             if (strlen(trim($data)) == 0) {
                 return trim($data);
             }
             if ((preg_match('/^\\d{8}$/', $data) || preg_match('/^\\d{14}$/', $data)) && CRM_Utils_Rule::mysqlDate($data)) {
                 return $data;
             }
             break;
         case 'ContactReference':
             if (strlen(trim($data)) == 0) {
                 return trim($data);
             }
             if (CRM_Utils_Rule::validContact($data)) {
                 return (int) $data;
             }
             break;
         default:
             CRM_Core_Error::fatal($type . " is not a recognised (camel cased) data type.");
             break;
     }
     // @todo Use exceptions instead of CRM_Core_Error::fatal().
     if ($abort) {
         $data = htmlentities($data);
         CRM_Core_Error::fatal("{$data} is not of the type {$type}");
     }
     return NULL;
 }
开发者ID:scardinius,项目名称:civicrm-core,代码行数:100,代码来源:Type.php

示例8: foreach

 /**
  * Synchronize the object with the UF Match entry. Can be called stand-alone from
  * the drupalUsers script
  *
  * @param Object  $user    the drupal user object
  * @param string  $userKey the id of the user from the uf object
  * @param string  $uniqId    the OpenID of the user
  * @param string  $uf      the name of the user framework
  * @param integer $status  returns the status if user created or already exits (used for CMS sync)
  *
  * @return the ufmatch object that was found or created
  * @access public
  * @static
  */
 static function &synchronizeUFMatch(&$user, $userKey, $uniqId, $uf, $status = null, $ctype = null, $isLogin = false)
 {
     // validate that uniqId is a valid url. it will either be
     // an OpenID (which should always be a valid url) or a
     // http://uf_username/ construction (so that it can
     // be used as an OpenID in the future)
     require_once 'CRM/Utils/Rule.php';
     if ($uf == 'Standalone') {
         if (!CRM_Utils_Rule::url($uniqId)) {
             return $status ? null : false;
         }
     } else {
         if (!CRM_Utils_Rule::email($uniqId)) {
             return $status ? null : false;
         }
     }
     $newContact = false;
     // make sure that a contact id exists for this user id
     $ufmatch =& new CRM_Core_DAO_UFMatch();
     if (CRM_Core_DAO::checkFieldExists('civicrm_uf_match', 'domain_id')) {
         // FIXME: if() condition check was required especially for upgrade cases (2.2.x -> 3.0.x),
         // where folks if happen to logout, would encounter a column not found fatal error
         $ufmatch->domain_id = CRM_Core_Config::domainID();
     }
     $ufmatch->uf_id = $userKey;
     if (!$ufmatch->find(true)) {
         require_once 'CRM/Core/Transaction.php';
         $transaction = new CRM_Core_Transaction();
         if (!empty($_POST) && !$isLogin) {
             $params = $_POST;
             $params['email'] = $uniqId;
             require_once 'CRM/Dedupe/Finder.php';
             $dedupeParams = CRM_Dedupe_Finder::formatParams($params, 'Individual');
             $ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, 'Individual');
             if (!empty($ids) && defined('CIVICRM_UNIQ_EMAIL_PER_SITE') && CIVICRM_UNIQ_EMAIL_PER_SITE) {
                 // restrict dupeIds to ones that belong to current domain/site.
                 require_once 'CRM/Core/BAO/Domain.php';
                 $siteContacts = CRM_Core_BAO_Domain::getContactList();
                 foreach ($ids as $index => $dupeId) {
                     if (!in_array($dupeId, $siteContacts)) {
                         unset($ids[$index]);
                     }
                 }
                 $ids = array_values($ids);
                 //re-index the array
             }
             if (!empty($ids)) {
                 $dao = new CRM_Core_DAO();
                 $dao->contact_id = $ids[0];
             }
         } else {
             require_once 'CRM/Contact/BAO/Contact.php';
             if ($uf == 'Standalone') {
                 $dao =& CRM_Contact_BAO_Contact::matchContactOnOpenId($uniqId, $ctype);
             } else {
                 $dao =& CRM_Contact_BAO_Contact::matchContactOnEmail($uniqId, $ctype);
             }
         }
         if ($dao) {
             //print "Found contact with uniqId $uniqId<br/>";
             $ufmatch->contact_id = $dao->contact_id;
             $ufmatch->uf_name = $uniqId;
         } else {
             if ($uf == 'Drupal') {
                 $mail = 'mail';
             } else {
                 $mail = 'email';
             }
             if (is_Object($user)) {
                 $params = array('email-Primary' => $user->{$mail});
             }
             if ($ctype == 'Organization') {
                 $params['organization_name'] = $uniqId;
             } else {
                 if ($ctype == 'Household') {
                     $params['household_name'] = $uniqId;
                 }
             }
             if (!$ctype) {
                 $ctype = "Individual";
             }
             $params['contact_type'] = $ctype;
             // extract first / middle / last name
             // for joomla
             if ($uf == 'Joomla' && $user->name) {
                 require_once 'CRM/Utils/String.php';
//.........这里部分代码省略.........
开发者ID:bhirsch,项目名称:voipdev,代码行数:101,代码来源:UFMatch.php

示例9: array

 /**
  * Synchronize the object with the UF Match entry. Can be called stand-alone from
  * the drupalUsers script
  *
  * @param Object  $user    the drupal user object
  * @param string  $userKey the id of the user from the uf object
  * @param string  $uniqId    the OpenID of the user
  * @param string  $uf      the name of the user framework
  * @param integer $status  returns the status if user created or already exits (used for CMS sync)
  *
  * @return the ufmatch object that was found or created
  * @access public
  * @static
  */
 static function &synchronizeUFMatch(&$user, $userKey, $uniqId, $uf, $status = null, $ctype = null)
 {
     // validate that uniqId is a valid url. it will either be
     // an OpenID (which should always be a valid url) or a
     // http://uf_username/ construction (so that it can
     // be used as an OpenID in the future)
     require_once 'CRM/Utils/Rule.php';
     if ($uf == 'Standalone') {
         if (!CRM_Utils_Rule::url($uniqId)) {
             return $status ? null : false;
         }
     } else {
         if (!CRM_Utils_Rule::email($uniqId)) {
             return $status ? null : false;
         }
     }
     $newContact = false;
     // make sure that a contact id exists for this user id
     $ufmatch =& new CRM_Core_DAO_UFMatch();
     if (CRM_Core_DAO::checkFieldExists('civicrm_uf_match', 'domain_id')) {
         // FIXME: if() condition check was required especially for upgrade cases (2.2.x -> 3.0.x),
         // where folks if happen to logout, would encounter a column not found fatal error
         $ufmatch->domain_id = CRM_Core_Config::domainID();
     }
     $ufmatch->uf_id = $userKey;
     if (!$ufmatch->find(true)) {
         require_once 'CRM/Core/Transaction.php';
         $transaction = new CRM_Core_Transaction();
         if (!empty($_POST)) {
             $params = $_POST;
             $params['email'] = $uniqId;
             require_once 'CRM/Dedupe/Finder.php';
             $dedupeParams = CRM_Dedupe_Finder::formatParams($params, 'Individual');
             $ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, 'Individual');
             if (!empty($ids)) {
                 $dao = new CRM_Core_DAO();
                 $dao->contact_id = $ids[0];
             }
         } else {
             require_once 'CRM/Contact/BAO/Contact.php';
             if ($uf == 'Standalone') {
                 $dao =& CRM_Contact_BAO_Contact::matchContactOnOpenId($uniqId, $ctype);
             } else {
                 $dao =& CRM_Contact_BAO_Contact::matchContactOnEmail($uniqId, $ctype);
             }
         }
         if ($dao) {
             //print "Found contact with uniqId $uniqId<br/>";
             $ufmatch->contact_id = $dao->contact_id;
             $ufmatch->uf_name = $uniqId;
         } else {
             if ($uf == 'Drupal') {
                 $mail = 'mail';
             } else {
                 $mail = 'email';
             }
             if (is_Object($user)) {
                 $params = array('email-Primary' => $user->{$mail});
             }
             if ($ctype == 'Organization') {
                 $params['organization_name'] = $uniqId;
             } else {
                 if ($ctype == 'Household') {
                     $params['household_name'] = $uniqId;
                 }
             }
             if (!$ctype) {
                 $ctype = "Individual";
             }
             $params['contact_type'] = $ctype;
             // extract first / middle / last name
             // for joomla
             if ($uf == 'Joomla' && $user->name) {
                 require_once 'CRM/Utils/String.php';
                 CRM_Utils_String::extractName($user->name, $params);
             }
             if ($uf == 'Standalone') {
                 $params['openid-Primary'] = $uniqId;
                 //need to delete below code once profile is
                 //exposed on signup page
                 if (!empty($user->first_name) || !empty($user->last_name)) {
                     $params['first_name'] = $user->first_name;
                     $params['last_name'] = $user->last_name;
                 } elseif (!empty($user->name)) {
                     require_once 'CRM/Utils/String.php';
                     CRM_Utils_String::extractName($user->name, $params);
//.........这里部分代码省略.........
开发者ID:bhirsch,项目名称:civicrm,代码行数:101,代码来源:UFMatch.php

示例10: escape

 /**
  * Verify that a variable is of a given type
  *
  * @param mixed   $data         The variable
  * @param string  $type         The type
  * @param boolean $abort        Should we abort if invalid
  *
  * @return mixed                The data, escaped if necessary
  * @access public
  * @static
  */
 public static function escape($data, $type, $abort = TRUE)
 {
     switch ($type) {
         case 'Integer':
         case 'Int':
             if (CRM_Utils_Rule::integer($data)) {
                 return $data;
             }
             break;
         case 'Positive':
             // the below 2 are for custom fields of this type
             // CRM-8925
         // the below 2 are for custom fields of this type
         // CRM-8925
         case 'Country':
         case 'StateProvince':
             if (CRM_Utils_Rule::positiveInteger($data)) {
                 return $data;
             }
             break;
         case 'Link':
             if (CRM_Utils_Rule::url($data = trim($data))) {
                 return $data;
             }
             break;
         case 'Boolean':
             if (CRM_Utils_Rule::boolean($data)) {
                 return $data;
             }
             break;
         case 'Float':
         case 'Money':
             if (CRM_Utils_Rule::numeric($data)) {
                 return $data;
             }
             break;
         case 'String':
         case 'Memo':
             return CRM_Core_DAO::escapeString($data);
         case 'Date':
         case 'Timestamp':
             // a null date or timestamp is valid
             if (strlen(trim($data)) == 0) {
                 return trim($data);
             }
             if ((preg_match('/^\\d{8}$/', $data) || preg_match('/^\\d{14}$/', $data)) && CRM_Utils_Rule::mysqlDate($data)) {
                 return $data;
             }
             break;
         case 'ContactReference':
             if (strlen(trim($data)) == 0) {
                 return trim($data);
             }
             if (CRM_Utils_Rule::validContact($data)) {
                 return $data;
             }
             break;
         default:
             CRM_Core_Error::fatal("Cannot recognize {$type} for {$data}");
             break;
     }
     if ($abort) {
         $data = htmlentities($data);
         CRM_Core_Error::fatal("{$data} is not of the type {$type}");
     }
     return NULL;
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:78,代码来源:Type.php


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