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


PHP Auth_OpenID::normalizeURL方法代碼示例

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


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

示例1: add

 /**
  * takes an associative array and adds OpenID 
  *
  * @param array  $params         (reference ) an assoc array of name/value pairs
  *
  * @return object       CRM_Core_BAO_OpenID object on success, null otherwise
  * @access public
  * @static
  */
 static function add(&$params)
 {
     $openId =& new CRM_Core_DAO_OpenID();
     // normalize the OpenID URL
     require_once 'Auth/OpenID.php';
     $params['openid'] = Auth_OpenID::normalizeURL($params['openid']);
     $openId->copyValues($params);
     return $openId->save();
 }
開發者ID:bhirsch,項目名稱:voipdev,代碼行數:18,代碼來源:OpenID.php

示例2: formRule

 /**
  * global validation rules for the form
  *
  * @param array $fields     posted values of the form
  * @param array $errors     list of errors to be posted back to the form
  * @param int   $contactId  contact id if doing update.
  *
  * @return $primaryID emal/openId
  * @static
  * @access public
  */
 static function formRule(&$fields, &$errors, $contactId = null)
 {
     $config =& CRM_Core_Config::singleton();
     if ($config->civiHRD && !isset($fields['tag'])) {
         $errors["tag"] = ts('Please select at least one tag.');
     }
     // validations.
     //1. for each block only single value can be marked as is_primary = true.
     //2. location type id should be present if block data present.
     //3. check open id across db and other each block for duplicate.
     //4. at least one location should be primary.
     //5. also get primaryID from email or open id block.
     // take the location blocks.
     $blocks = CRM_Core_BAO_Preferences::valueOptions('contact_edit_options', true, null, false, 'name', true, 'AND v.filter = 1');
     $otherEditOptions = CRM_Core_BAO_Preferences::valueOptions('contact_edit_options', true, null, false, 'name', true, 'AND v.filter = 0');
     //get address block inside.
     if (array_key_exists('Address', $otherEditOptions)) {
         $blocks['Address'] = $otherEditOptions['Address'];
     }
     $openIds = array();
     $primaryID = false;
     foreach ($blocks as $name => $label) {
         $hasData = $hasPrimary = array();
         $name = strtolower($name);
         if (CRM_Utils_Array::value($name, $fields) && is_array($fields[$name])) {
             foreach ($fields[$name] as $instance => $blockValues) {
                 $dataExists = self::blockDataExists($blockValues);
                 if (!$dataExists && $name == 'address' && $instance == 1) {
                     $dataExists = CRM_Utils_Array::value('use_household_address', $fields);
                 }
                 if ($dataExists) {
                     $hasData[] = $instance;
                     if (CRM_Utils_Array::value('is_primary', $blockValues)) {
                         $hasPrimary[] = $instance;
                         if (!$primaryID && in_array($name, array('email', 'openid')) && CRM_Utils_Array::value($name, $blockValues)) {
                             $primaryID = $blockValues[$name];
                         }
                     }
                     if (!CRM_Utils_Array::value('location_type_id', $blockValues)) {
                         $errors["{$name}[{$instance}][location_type_id]"] = ts('The Location Type should be set if there is  %1 information.', array(1 => $label));
                     }
                 }
                 if ($name == 'openid' && CRM_Utils_Array::value($name, $blockValues)) {
                     require_once 'CRM/Core/DAO/OpenID.php';
                     require_once 'Auth/OpenID.php';
                     $oid =& new CRM_Core_DAO_OpenID();
                     $oid->openid = $openIds[$instance] = Auth_OpenID::normalizeURL(CRM_Utils_Array::value($name, $blockValues));
                     $cid = isset($contactId) ? $contactId : 0;
                     if ($oid->find(true) && $oid->contact_id != $cid) {
                         $errors["{$name}[{$instance}][openid]"] = ts('%1 already exist.', array(1 => $blocks['OpenID']));
                     }
                 }
             }
             if (empty($hasPrimary) && !empty($hasData)) {
                 $errors["{$name}[1][is_primary]"] = ts('One %1 should be marked as primary.', array(1 => $label));
             }
             if (count($hasPrimary) > 1) {
                 $errors["{$name}[" . array_pop($hasPrimary) . "][is_primary]"] = ts('Only one %1 can be marked as primary.', array(1 => $label));
             }
         }
     }
     //do validations for all opend ids they should be distinct.
     if (!empty($openIds) && count(array_unique($openIds)) != count($openIds)) {
         foreach ($openIds as $instance => $value) {
             if (!array_key_exists($instance, array_unique($openIds))) {
                 $errors["openid[{$instance}][openid]"] = ts('%1 already used.', array(1 => $blocks['OpenID']));
             }
         }
     }
     // street number should be digit + suffix, CRM-5450
     $parseStreetAddress = CRM_Utils_Array::value('street_address_parsing', CRM_Core_BAO_Preferences::valueOptions('address_options'));
     if ($parseStreetAddress) {
         if (is_array($fields['address'])) {
             $invalidStreetNumbers = array();
             foreach ($fields['address'] as $cnt => $address) {
                 if ($streetNumber = CRM_Utils_Array::value('street_number', $address)) {
                     $parsedAddress = CRM_Core_BAO_Address::parseStreetAddress($address['street_number']);
                     if (!CRM_Utils_Array::value('street_number', $parsedAddress)) {
                         $invalidStreetNumbers[] = $cnt;
                     }
                 }
             }
             if (!empty($invalidStreetNumbers)) {
                 $first = $invalidStreetNumbers[0];
                 foreach ($invalidStreetNumbers as &$num) {
                     $num = CRM_Contact_Form_Contact::ordinalNumber($num);
                 }
                 $errors["address[{$first}][street_number]"] = ts('The street number you entered for the %1 address block(s) is not in an expected format. Street numbers may include numeric digit(s) followed by other characters. You can still enter the complete street address (unparsed) by clicking "Edit Complete Street Address".', array(1 => implode(', ', $invalidStreetNumbers)));
             }
//.........這裏部分代碼省略.........
開發者ID:bhirsch,項目名稱:voipdev,代碼行數:101,代碼來源:Contact.php


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