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


PHP CRM_Utils_Rule::email方法代码示例

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


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

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

示例2: mapToAccounts

 /**
  * Map civicrm Array to Accounts package field names.
  *
  * @param array $contact
  *          Contact Array as returned from API
  * @param $accountsID
  *
  * @return array|bool
  *   Contact Object/ array as expected by accounts package
  */
 protected function mapToAccounts($contact, $accountsID)
 {
     $new_contact = array("Name" => $contact['display_name'] . " - " . $contact['contact_id'], "FirstName" => $contact['first_name'], "LastName" => $contact['last_name'], "EmailAddress" => CRM_Utils_Rule::email($contact['email']) ? $contact['email'] : '', "ContactNumber" => $contact['contact_id'], "Addresses" => array("Address" => array(array("AddressType" => 'POBOX', "AddressLine1" => $contact['street_address'], "City" => $contact['city'], "PostalCode" => $contact['postal_code']))), "Phones" => array("Phone" => array("PhoneType" => 'DEFAULT', "PhoneNumber" => $contact['phone'])));
     if (!empty($accountsID)) {
         $new_contact['ContactID'] = $accountsID;
     }
     $proceed = TRUE;
     CRM_Accountsync_Hook::accountPushAlterMapped('contact', $contact, $proceed, $new_contact);
     $new_contact = array($new_contact);
     if (!$proceed) {
         return FALSE;
     }
     return $new_contact;
 }
开发者ID:kidaa30,项目名称:yes,代码行数:24,代码来源:Contact.php

示例3: formRule

 /**
  * global form rule
  *
  * @param array $fields  the input form values
  * @param array $files   the uploaded files if any
  * @param array $options additional user data
  *
  * @return true if no errors, else array of errors
  * @access public
  * @static
  */
 static function formRule($fields, $files, $options)
 {
     $errors = array();
     // if is_email_receipt is set, the receipt message must be non-empty
     if (!empty($fields['is_email_receipt'])) {
         //added for CRM-1348
         $email = trim(CRM_Utils_Array::value('receipt_from_email', $fields));
         if (empty($email) || !CRM_Utils_Rule::email($email)) {
             $errors['receipt_from_email'] = ts('A valid Receipt From Email address must be specified if Email Receipt to Contributor is enabled');
         }
     }
     return $errors;
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:24,代码来源:ThankYou.php

示例4: isErrorInCoreData


//.........这里部分代码省略.........
                         }
                     }
                     break;
                 case 'geo_code_1':
                     if (!empty($value)) {
                         foreach ($value as $codeValue) {
                             if ($codeValue['geo_code_1']) {
                                 if (CRM_Utils_Rule::numeric($codeValue['geo_code_1'])) {
                                     continue;
                                 } 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);
                         }
                     }
开发者ID:bhirsch,项目名称:voipdev,代码行数:67,代码来源:Contact.php

示例5: getEditHTML

 /**
  * get the html for the form that represents this particular group
  *
  * @param int     $userID    the user id that we are actually editing
  * @param string  $title     the title of the group we are interested in
  * @param int     $action    the action of the form
  * @param boolean $register  is this the registration form
  * @param boolean $reset     should we reset the form?
  * @param int     $profileID do we have the profile ID?
  *
  * @return string       the html for the form on success, otherwise empty string
  * @static
  * @access public
  */
 static function getEditHTML($userID, $title, $action = null, $register = false, $reset = false, $profileID = null, $doNotProcess = false, $ctype = null)
 {
     require_once "CRM/Core/Controller/Simple.php";
     $session =& CRM_Core_Session::singleton();
     if ($register) {
         $controller =& new CRM_Core_Controller_Simple('CRM_Profile_Form_Dynamic', ts('Dynamic Form Creator'), $action);
         if ($reset || $doNotProcess) {
             // hack to make sure we do not process this form
             $oldQFDefault = CRM_Utils_Array::value('_qf_default', $_POST);
             unset($_POST['_qf_default']);
             unset($_REQUEST['_qf_default']);
             if ($reset) {
                 $controller->reset();
             }
         }
         $controller->set('id', $userID);
         $controller->set('register', 1);
         $controller->set('skipPermission', 1);
         $controller->set('ctype', $ctype);
         $controller->process();
         if ($doNotProcess) {
             $controller->validate();
         }
         $controller->setEmbedded(true);
         //CRM-5839 - though we want to process form, get the control back.
         $controller->setSkipRedirection($doNotProcess ? false : true);
         $controller->run();
         // we are done processing so restore the POST/REQUEST vars
         if (($reset || $doNotProcess) && $oldQFDefault) {
             $_POST['_qf_default'] = $_REQUEST['_qf_default'] = $oldQFDefault;
         }
         $template =& CRM_Core_Smarty::singleton();
         return trim($template->fetch('CRM/Profile/Form/Dynamic.tpl'));
     } else {
         if (!$profileID) {
             // make sure we have a valid group
             $group =& new CRM_Core_DAO_UFGroup();
             $group->title = $title;
             if ($group->find(true)) {
                 $profileID = $group->id;
             }
         }
         if ($profileID) {
             // make sure profileID and ctype match if ctype exists
             if ($ctype) {
                 require_once 'CRM/Core/BAO/UFField.php';
                 $profileType = CRM_Core_BAO_UFField::getProfileType($profileID);
                 if (CRM_Contact_BAO_ContactType::isaSubType($profileType)) {
                     $profileType = CRM_Contact_BAO_ContactType::getBasicType($profileType);
                 }
                 if ($profileType != 'Contact' && $profileType != $ctype) {
                     return null;
                 }
             }
             $controller =& new CRM_Core_Controller_Simple('CRM_Profile_Form_Dynamic', ts('Dynamic Form Creator'), $action);
             if ($reset) {
                 $controller->reset();
             }
             $controller->set('gid', $profileID);
             $controller->set('id', $userID);
             $controller->set('register', 0);
             $controller->set('skipPermission', 1);
             if ($ctype) {
                 $controller->set('ctype', $ctype);
             }
             $controller->process();
             $controller->setEmbedded(true);
             //CRM-5846 - give the control back to drupal.
             $controller->setSkipRedirection($doNotProcess ? false : true);
             $controller->run();
             $template =& CRM_Core_Smarty::singleton();
             $templateFile = "CRM/Profile/Form/{$profileID}/Dynamic.tpl";
             if (!$template->template_exists($templateFile)) {
                 $templateFile = "CRM/Profile/Form/Dynamic.tpl";
             }
             return trim($template->fetch($templateFile));
         } else {
             require_once 'CRM/Contact/BAO/Contact/Location.php';
             $userEmail = CRM_Contact_BAO_Contact_Location::getEmailDetails($userID);
             // if post not empty then only proceed
             if (!empty($_POST)) {
                 // get the new email
                 $config =& CRM_Core_Config::singleton();
                 $email = CRM_Utils_Array::value('mail', $_POST);
                 if (CRM_Utils_Rule::email($email) && $email != $userEmail[1]) {
                     require_once 'CRM/Core/BAO/UFMatch.php';
//.........这里部分代码省略.........
开发者ID:bhirsch,项目名称:voipdev,代码行数:101,代码来源:UFGroup.php

示例6: getEditHTML


//.........这里部分代码省略.........
  *   the html for the form on success, otherwise empty string
  */
 public static function getEditHTML($userID, $title, $action = NULL, $register = FALSE, $reset = FALSE, $profileID = NULL, $doNotProcess = FALSE, $ctype = NULL)
 {
     if ($register) {
         $controller = new CRM_Core_Controller_Simple('CRM_Profile_Form_Dynamic', ts('Dynamic Form Creator'), $action);
         if ($reset || $doNotProcess) {
             // hack to make sure we do not process this form
             $oldQFDefault = CRM_Utils_Array::value('_qf_default', $_POST);
             unset($_POST['_qf_default']);
             unset($_REQUEST['_qf_default']);
             if ($reset) {
                 $controller->reset();
             }
         }
         $controller->set('id', $userID);
         $controller->set('register', 1);
         $controller->set('skipPermission', 1);
         $controller->set('ctype', $ctype);
         $controller->process();
         if ($doNotProcess || !empty($_POST)) {
             $controller->validate();
         }
         $controller->setEmbedded(TRUE);
         //CRM-5839 - though we want to process form, get the control back.
         $controller->setSkipRedirection($doNotProcess ? FALSE : TRUE);
         $controller->run();
         // we are done processing so restore the POST/REQUEST vars
         if (($reset || $doNotProcess) && $oldQFDefault) {
             $_POST['_qf_default'] = $_REQUEST['_qf_default'] = $oldQFDefault;
         }
         $template = CRM_Core_Smarty::singleton();
         // Hide CRM error messages if they are displayed using drupal form_set_error.
         if (!empty($_POST)) {
             $template->assign('suppressForm', TRUE);
         }
         return trim($template->fetch('CRM/Profile/Form/Dynamic.tpl'));
     } else {
         if (!$profileID) {
             // make sure we have a valid group
             $group = new CRM_Core_DAO_UFGroup();
             $group->title = $title;
             if ($group->find(TRUE)) {
                 $profileID = $group->id;
             }
         }
         if ($profileID) {
             // make sure profileID and ctype match if ctype exists
             if ($ctype) {
                 $profileType = CRM_Core_BAO_UFField::getProfileType($profileID);
                 if (CRM_Contact_BAO_ContactType::isaSubType($profileType)) {
                     $profileType = CRM_Contact_BAO_ContactType::getBasicType($profileType);
                 }
                 if ($profileType != 'Contact' && $profileType != $ctype) {
                     return NULL;
                 }
             }
             $controller = new CRM_Core_Controller_Simple('CRM_Profile_Form_Dynamic', ts('Dynamic Form Creator'), $action);
             if ($reset) {
                 $controller->reset();
             }
             $controller->set('gid', $profileID);
             $controller->set('id', $userID);
             $controller->set('register', 0);
             $controller->set('skipPermission', 1);
             if ($ctype) {
                 $controller->set('ctype', $ctype);
             }
             $controller->process();
             $controller->setEmbedded(TRUE);
             //CRM-5846 - give the control back to drupal.
             $controller->setSkipRedirection($doNotProcess ? FALSE : TRUE);
             $controller->run();
             $template = CRM_Core_Smarty::singleton();
             // Hide CRM error messages if they are displayed using drupal form_set_error.
             if (!empty($_POST) && CRM_Core_Config::singleton()->userFramework == 'Drupal') {
                 if (arg(0) == 'user' || arg(0) == 'admin' && arg(1) == 'people') {
                     $template->assign('suppressForm', TRUE);
                 }
             }
             $templateFile = "CRM/Profile/Form/{$profileID}/Dynamic.tpl";
             if (!$template->template_exists($templateFile)) {
                 $templateFile = 'CRM/Profile/Form/Dynamic.tpl';
             }
             return trim($template->fetch($templateFile));
         } else {
             $userEmail = CRM_Contact_BAO_Contact_Location::getEmailDetails($userID);
             // if post not empty then only proceed
             if (!empty($_POST)) {
                 // get the new email
                 $config = CRM_Core_Config::singleton();
                 $email = CRM_Utils_Array::value('mail', $_POST);
                 if (CRM_Utils_Rule::email($email) && $email != $userEmail[1]) {
                     CRM_Core_BAO_UFMatch::updateContactEmail($userID, $email);
                 }
             }
         }
     }
     return '';
 }
开发者ID:rollox,项目名称:civicrm-core,代码行数:101,代码来源:UFGroup.php

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

示例8: summary

 /**
  * handle the values in summary mode
  *
  * @param array $values the array of values belonging to this line
  *
  * @return boolean      the result of this processing
  * @access public
  */
 function summary(&$values)
 {
     $response = $this->setActiveFieldValues($values);
     $errorMessage = null;
     $errorRequired = false;
     switch ($this->_contactType) {
         case 'Individual':
             if ($this->_firstNameIndex < 0 && $this->_lastNameIndex < 0) {
                 $errorRequired = true;
                 $errorMessage = ts('Missing required fields:') . ' ' . ts('First Name') . ' ' . ts('and') . ' ' . ts('Last Name');
             } else {
                 $errorRequired = !CRM_Utils_Array::value($this->_firstNameIndex, $values) && !CRM_Utils_Array::value($this->_lastNameIndex, $values);
             }
             break;
         case 'Household':
             if ($this->_householdNameIndex < 0) {
                 $errorRequired = true;
                 $errorMessage = ts('Missing required fields:') . ' ' . ts('Household Name');
             } else {
                 $errorRequired = !CRM_Utils_Array::value($this->_householdNameIndex, $values);
             }
             break;
         case 'Organization':
             if ($this->_organizationNameIndex < 0) {
                 $errorRequired = true;
                 $errorMessage = ts('Missing required fields:') . ' ' . ts('Organization Name');
             } else {
                 $errorRequired = !CRM_Utils_Array::value($this->_organizationNameIndex, $values);
             }
             break;
     }
     $statusFieldName = $this->_statusFieldName;
     if ($this->_emailIndex >= 0) {
         /* If we don't have the required fields, bail */
         if ($this->_contactType == 'Individual' && !$this->_updateWithId) {
             if ($errorRequired && !CRM_Utils_Array::value($this->_emailIndex, $values)) {
                 if ($errorMessage) {
                     $errorMessage .= ' ' . ts('OR') . ' ' . ts('Email Address');
                 } else {
                     $errorMessage = ts('Missing required field:') . ' ' . ts('Email Address');
                 }
                 array_unshift($values, $errorMessage);
                 $importRecordParams = array($statusFieldName => 'ERROR', "{$statusFieldName}Msg" => $errorMessage);
                 $this->updateImportRecord($values[count($values) - 1], $importRecordParams);
                 return CRM_Import_Parser::ERROR;
             }
         }
         $email = CRM_Utils_Array::value($this->_emailIndex, $values);
         if ($email) {
             /* If the email address isn't valid, bail */
             if (!CRM_Utils_Rule::email($email)) {
                 $errorMessage = ts('Invalid Email address');
                 array_unshift($values, $errorMessage);
                 $importRecordParams = array($statusFieldName => 'ERROR', "{$statusFieldName}Msg" => $errorMessage);
                 $this->updateImportRecord($values[count($values) - 1], $importRecordParams);
                 return CRM_Import_Parser::ERROR;
             }
             /* otherwise, count it and move on */
             $this->_allEmails[$email] = $this->_lineCount;
         }
     } else {
         if ($errorRequired && !$this->_updateWithId) {
             if ($errorMessage) {
                 $errorMessage .= ' ' . ts('OR') . ' ' . ts('Email Address');
             } else {
                 $errorMessage = ts('Missing required field:') . ' ' . ts('Email Address');
             }
             array_unshift($values, $errorMessage);
             $importRecordParams = array($statusFieldName => 'ERROR', "{$statusFieldName}Msg" => $errorMessage);
             $this->updateImportRecord($values[count($values) - 1], $importRecordParams);
             return CRM_Import_Parser::ERROR;
         }
     }
     //check for duplicate external Identifier
     $externalID = CRM_Utils_Array::value($this->_externalIdentifierIndex, $values);
     if ($externalID) {
         /* If it's a dupe,external Identifier  */
         if ($externalDupe = CRM_Utils_Array::value($externalID, $this->_allExternalIdentifiers)) {
             $errorMessage = ts('External Identifier conflicts with record %1', array(1 => $externalDupe));
             array_unshift($values, $errorMessage);
             $importRecordParams = array($statusFieldName => 'ERROR', "{$statusFieldName}Msg" => $errorMessage);
             $this->updateImportRecord($values[count($values) - 1], $importRecordParams);
             return CRM_Import_Parser::ERROR;
         }
         //otherwise, count it and move on
         $this->_allExternalIdentifiers[$externalID] = $this->_lineCount;
     }
     //Checking error in custom data
     $params =& $this->getActiveFieldParams();
     $params['contact_type'] = $this->_contactType;
     //date-format part ends
     $errorMessage = null;
//.........这里部分代码省略.........
开发者ID:ksecor,项目名称:civicrm,代码行数:101,代码来源:Contact.php

示例9: formRule

 /**  
  * global form rule  
  *  
  * @param array $fields the input form values  
  * @param array $files  the uploaded files if any  
  * @param array $self   current form object. 
  *  
  * @return array array of errors / empty array.   
  * @access public  
  * @static  
  */
 static function formRule(&$fields, &$files, $self)
 {
     $errors = array();
     if ($self->_gName == 'from_email_address') {
         require_once 'CRM/Utils/Mail.php';
         $formEmail = CRM_Utils_Mail::pluckEmailFromHeader($fields['label']);
         if (!CRM_Utils_Rule::email($formEmail)) {
             $errors['label'] = ts('Please enter the valid email address.');
         }
         $formName = explode('"', $fields['label']);
         if (!CRM_Utils_Array::value(1, $formName) || count($formName) != 3) {
             $errors['label'] = ts('Please follow the proper format for From Email Address');
         }
     }
     return $errors;
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:27,代码来源:Options.php

示例10: elseif

 /**
  * Form rule to send out a test mailing.
  *
  * @param array $params     Array of the form values
  * @param array $files      Any files posted to the form
  * @param array $self       an current this object
  *
  * @return boolean          true on succesful SMTP handoff
  * @access public
  */
 static function &testMail($testParams, $files, $self)
 {
     $error = NULL;
     $urlString = 'civicrm/mailing/send';
     $urlParams = "_qf_Test_display=true&qfKey={$testParams['qfKey']}";
     $ssID = $self->get('ssID');
     if ($ssID && $self->_searchBasedMailing) {
         if ($self->_action == CRM_Core_Action::BASIC) {
             $fragment = 'search';
         } elseif ($self->_action == CRM_Core_Action::PROFILE) {
             $fragment = 'search/builder';
         } elseif ($self->_action == CRM_Core_Action::ADVANCED) {
             $fragment = 'search/advanced';
         } else {
             $fragment = 'search/custom';
         }
         $urlString = 'civicrm/contact/' . $fragment;
     }
     $emails = NULL;
     if (CRM_Utils_Array::value('sendtest', $testParams)) {
         if (!($testParams['test_group'] || $testParams['test_email'])) {
             CRM_Core_Session::setStatus(ts('Your did not provided any email address or selected any group. No test mail is sent.'));
             $error = TRUE;
         }
         if ($testParams['test_email']) {
             $emailAdd = explode(',', $testParams['test_email']);
             foreach ($emailAdd as $key => $value) {
                 $email = trim($value);
                 $testParams['emails'][] = $email;
                 $emails .= $emails ? ",'{$email}'" : "'{$email}'";
                 if (!CRM_Utils_Rule::email($email)) {
                     CRM_Core_Session::setStatus(ts('Please enter valid email addresses only.'));
                     $error = TRUE;
                 }
             }
         }
         if ($error) {
             $url = CRM_Utils_System::url($urlString, $urlParams);
             CRM_Utils_System::redirect($url);
             return $error;
         }
     }
     if (CRM_Utils_Array::value('_qf_Test_submit', $testParams)) {
         //when user perform mailing from search context
         //redirect it to search result CRM-3711.
         if ($ssID && $self->_searchBasedMailing) {
             $draftURL = CRM_Utils_System::url('civicrm/mailing/browse/unscheduled', 'scheduled=false&reset=1');
             $status = ts("Your mailing has been saved. You can continue later by clicking the 'Continue' action to resume working on it.<br /> From <a href='%1'>Draft and Unscheduled Mailings</a>.", array(1 => $draftURL));
             CRM_Core_Session::setStatus($status);
             //replace user context to search.
             $context = $self->get('context');
             if (!CRM_Contact_Form_Search::isSearchContext($context)) {
                 $context = 'search';
             }
             $urlParams = "force=1&reset=1&ssID={$ssID}&context={$context}&qfKey={$testParams['qfKey']}";
             $url = CRM_Utils_System::url($urlString, $urlParams);
             CRM_Utils_System::redirect($url);
         } else {
             $status = ts("Your mailing has been saved. Click the 'Continue' action to resume working on it.");
             CRM_Core_Session::setStatus($status);
             $url = CRM_Utils_System::url('civicrm/mailing/browse/unscheduled', 'scheduled=false&reset=1');
             CRM_Utils_System::redirect($url);
         }
     }
     if (CRM_Mailing_Info::workflowEnabled()) {
         if (!CRM_Core_Permission::check('schedule mailings') && CRM_Core_Permission::check('create mailings')) {
             $url = CRM_Utils_System::url('civicrm/mailing/browse/unscheduled', 'scheduled=false&reset=1');
             CRM_Utils_System::redirect($url);
         }
     }
     if (CRM_Utils_Array::value('_qf_Import_refresh', $_POST) || CRM_Utils_Array::value('_qf_Test_next', $testParams) || !CRM_Utils_Array::value('sendtest', $testParams)) {
         $error = TRUE;
         return $error;
     }
     $job = new CRM_Mailing_BAO_Job();
     $job->mailing_id = $self->get('mailing_id');
     $job->is_test = TRUE;
     $job->save();
     $newEmails = NULL;
     $session = CRM_Core_Session::singleton();
     if (!empty($testParams['emails'])) {
         $query = "\n                      SELECT id, contact_id, email  \n                      FROM civicrm_email  \n                      WHERE civicrm_email.email IN ({$emails})";
         $dao = CRM_Core_DAO::executeQuery($query);
         $emailDetail = array();
         // fetch contact_id and email id for all existing emails
         while ($dao->fetch()) {
             $emailDetail[$dao->email] = array('contact_id' => $dao->contact_id, 'email_id' => $dao->id);
         }
         $dao->free();
         foreach ($testParams['emails'] as $key => $email) {
//.........这里部分代码省略.........
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:101,代码来源:Test.php

示例11: emailList

 function emailList($list, $checkDomain = false)
 {
     $emails = explode(',', $list);
     foreach ($emails as $email) {
         $email = trim($email);
         if (!CRM_Utils_Rule::email($email, $checkDomain)) {
             return false;
         }
     }
     return true;
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:11,代码来源:Rule.php

示例12: formRule

 /**
  * global form rule
  *
  * @param array $fields the input form values
  * @param array $files  the uploaded files if any
  * @param array $self   current form object.
  *
  * @return array array of errors / empty array.
  * @access public
  * @static
  */
 static function formRule($fields, $files, $self)
 {
     $errors = array();
     if ($self->_gName == 'case_status' && !CRM_Utils_Array::value('grouping', $fields)) {
         $errors['grouping'] = ts('Status class is a required field');
     }
     if (in_array($self->_gName, array('email_greeting', 'postal_greeting', 'addressee')) && !CRM_Utils_Array::value('is_reserved', $self->_defaultValues)) {
         $label = $fields['label'];
         $condition = " AND v.label = '{$label}' ";
         $values = CRM_Core_OptionGroup::values($self->_gName, FALSE, FALSE, FALSE, $condition, 'filter');
         $checkContactOptions = TRUE;
         if ($self->_id && $self->_defaultValues['contactOptions'] == $fields['contactOptions']) {
             $checkContactOptions = FALSE;
         }
         if ($checkContactOptions && in_array($fields['contactOptions'], $values)) {
             $errors['label'] = ts('This Label already exists in the database for the selected contact type.');
         }
     }
     if ($self->_gName == 'from_email_address') {
         $formEmail = CRM_Utils_Mail::pluckEmailFromHeader($fields['label']);
         if (!CRM_Utils_Rule::email($formEmail)) {
             $errors['label'] = ts('Please enter the valid email address.');
         }
         $formName = explode('"', $fields['label']);
         if (!CRM_Utils_Array::value(1, $formName) || count($formName) != 3) {
             $errors['label'] = ts('Please follow the proper format for From Email Address');
         }
     }
     return $errors;
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:41,代码来源:Options.php

示例13: processDl

 /**
  * handler for dl requests
  */
 static function processDl()
 {
     $config = self::getConfig();
     global $http_return_code;
     /* run this puppy through premailer */
     // DS: not sure why we need premailer as it always sends out mobile (inline) layout.
     // Lets disable it till we figure out why we need it.
     //$premailer = Premailer::html( $_POST[ "html" ], true, "hpricot", $config['BASE_URL'] );
     //$html = $premailer[ "html" ];
     $html = $_POST["html"];
     /* create static versions of resized images */
     $matches = [];
     $num_full_pattern_matches = preg_match_all('#<img.*?src="([^"]*?\\/[^/]*\\.[^"]+)#i', $html, $matches);
     for ($i = 0; $i < $num_full_pattern_matches; $i++) {
         if (preg_match('#/img/(\\?|&amp;)src=#i', $matches[1][$i])) {
             $src_matches = [];
             if (preg_match('#/img/(\\?|&amp;)src=(.*)&amp;method=(.*)&amp;params=(.*)#i', $matches[1][$i], $src_matches) !== FALSE) {
                 $file_name = urldecode($src_matches[2]);
                 $file_name = substr($file_name, strlen($config['BASE_URL']));
                 $method = urldecode($src_matches[3]);
                 $params = urldecode($src_matches[4]);
                 $params = explode(",", $params);
                 $width = (int) $params[0];
                 $height = (int) $params[1];
                 $static_file_name = $method . "_" . $width . "x" . $height . "_" . $file_name;
                 $html = str_ireplace($matches[1][$i], $config['BASE_URL'] . $config['STATIC_URL'] . rawurlencode($static_file_name), $html);
                 //Changed to rawurlencode because space gets into + in the image file name if it has space
                 $image = self::resizeImage($file_name, $method, $width, $height);
                 $image->writeImage($config['BASE_DIR'] . $config['STATIC_DIR'] . $static_file_name);
             }
         }
     }
     /* perform the requested action */
     switch (CRM_Utils_Type::escape($_POST['action'], 'String')) {
         case "download":
             // download
             header("Content-Type: application/force-download");
             header("Content-Disposition: attachment; filename=\"" . $_POST["filename"] . "\"");
             header("Content-Length: " . strlen($html));
             echo $html;
             break;
         case "save":
             $result = array();
             $msgTplId = NULL;
             $hashKey = CRM_Utils_Type::escape($_POST['key'], 'String');
             if (!$hashKey) {
                 CRM_Core_Session::setStatus(ts('Mosaico hask key not found...'));
                 return FALSE;
             }
             $mosTpl = new CRM_Mosaico_DAO_MessageTemplate();
             $mosTpl->hash_key = $hashKey;
             if ($mosTpl->find(TRUE)) {
                 $msgTplId = $mosTpl->msg_tpl_id;
             }
             $name = "Mosaico Template " . date('d-m-Y H:i:s');
             if (CRM_Utils_Type::escape($_POST['name'], 'String')) {
                 $name = $_POST['name'];
             }
             // save to message templates
             $messageTemplate = array('msg_html' => $html, 'is_active' => TRUE);
             $messageTemplate['msg_title'] = $messageTemplate['msg_subject'];
             if ($msgTplId) {
                 $messageTemplate['id'] = $msgTplId;
             }
             $messageTemplate['msg_title'] = $messageTemplate['msg_subject'] = $name;
             $msgTpl = CRM_Core_BAO_MessageTemplate::add($messageTemplate);
             $mosaicoTemplate = array('msg_tpl_id' => $msgTpl->id, 'hash_key' => $hashKey, 'name' => $name, 'html' => $_POST['html'], 'metadata' => $_POST['metadata'], 'template' => $_POST['template']);
             $mosTpl = new CRM_Mosaico_DAO_MessageTemplate();
             $mosTpl->msg_tpl_id = $msgTpl->id;
             $mosTpl->hash_key = $hashKey;
             $mosTpl->find(TRUE);
             $mosTpl->copyValues($mosaicoTemplate);
             $mosTpl->save();
             if ($mosTpl->id) {
                 $result['id'] = $mosTpl->id;
             }
             CRM_Utils_JSON::output($result);
             break;
         case "email":
             $result = array();
             if (!CRM_Utils_Rule::email($_POST['rcpt'])) {
                 CRM_Core_Session::setStatus('Recipient Email address not found');
                 return FALSE;
             }
             $to = $_POST['rcpt'];
             $subject = CRM_Utils_Type::escape($_POST['subject'], 'String');
             list($domainEmailName, $domainEmailAddress) = CRM_Core_BAO_Domain::getNameAndEmail();
             $mailParams = array('from' => $domainEmailAddress, 'toName' => 'Test Recipient', 'toEmail' => $to, 'subject' => $subject, 'html' => $html);
             $sent = FALSE;
             if (CRM_Utils_Mail::send($mailParams)) {
                 $result['sent'] = TRUE;
                 CRM_Utils_JSON::output($result);
             } else {
                 CRM_Utils_JSON::output($result);
                 return FALSE;
             }
             break;
//.........这里部分代码省略.........
开发者ID:Kajakaran,项目名称:uk.co.vedaconsulting.mosaico,代码行数:101,代码来源:Utils.php

示例14: 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 int $status
  *   Returns the status if user created or already exits (used for CMS sync).
  * @param string $ctype
  *   contact type
  * @param bool $isLogin
  *
  * @return CRM_Core_DAO_UFMatch|bool
  */
 public static function &synchronizeUFMatch(&$user, $userKey, $uniqId, $uf, $status = NULL, $ctype = NULL, $isLogin = FALSE)
 {
     $config = CRM_Core_Config::singleton();
     if (!CRM_Utils_Rule::email($uniqId)) {
         $retVal = $status ? NULL : FALSE;
         return $retVal;
     }
     $newContact = FALSE;
     // make sure that a contact id exists for this user id
     $ufmatch = new CRM_Core_DAO_UFMatch();
     $ufmatch->domain_id = CRM_Core_Config::domainID();
     $ufmatch->uf_id = $userKey;
     if (!$ufmatch->find(TRUE)) {
         $transaction = new CRM_Core_Transaction();
         $dao = NULL;
         if (!empty($_POST) && !$isLogin) {
             $params = $_POST;
             $params['email'] = $uniqId;
             $dedupeParams = CRM_Dedupe_Finder::formatParams($params, 'Individual');
             $dedupeParams['check_permission'] = FALSE;
             $ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, 'Individual');
             if (!empty($ids) && Civi::settings()->get('uniq_email_per_site')) {
                 // restrict dupeIds to ones that belong to current domain/site.
                 $siteContacts = CRM_Core_BAO_Domain::getContactList();
                 foreach ($ids as $index => $dupeId) {
                     if (!in_array($dupeId, $siteContacts)) {
                         unset($ids[$index]);
                     }
                 }
                 // re-index the array
                 $ids = array_values($ids);
             }
             if (!empty($ids)) {
                 $dao = new CRM_Core_DAO();
                 $dao->contact_id = $ids[0];
             }
         } else {
             $dao = CRM_Contact_BAO_Contact::matchContactOnEmail($uniqId, $ctype);
         }
         $found = FALSE;
         if ($dao) {
             // ensure there does not exists a contact_id / uf_id pair
             // in the DB. This might be due to multiple emails per contact
             // CRM-9091
             $sql = "\nSELECT id\nFROM   civicrm_uf_match\nWHERE  contact_id = %1\nAND    domain_id = %2\n";
             $params = array(1 => array($dao->contact_id, 'Integer'), 2 => array(CRM_Core_Config::domainID(), 'Integer'));
             $conflict = CRM_Core_DAO::singleValueQuery($sql, $params);
             if (!$conflict) {
                 $found = TRUE;
                 $ufmatch->contact_id = $dao->contact_id;
                 $ufmatch->uf_name = $uniqId;
             }
         }
         if (!$found) {
             if ($config->userSystem->is_drupal) {
                 $mail = 'mail';
             } elseif ($uf == 'WordPress') {
                 $mail = 'user_email';
             } else {
                 $mail = 'email';
             }
             if (is_object($user)) {
                 $params = array('email-Primary' => $user->{$mail});
             }
             if ($ctype == 'Organization') {
                 $params['organization_name'] = $uniqId;
             } elseif ($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) {
                 CRM_Utils_String::extractName($user->name, $params);
             }
             if ($uf == 'WordPress') {
                 if ($user->first_name) {
//.........这里部分代码省略.........
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:101,代码来源:UFMatch.php

示例15: summary

 /**
  * handle the values in summary mode
  *
  * @param array $values the array of values belonging to this line
  *
  * @return boolean      the result of this processing
  * @access public
  */
 function summary(&$values)
 {
     $response = $this->setActiveFieldValues($values);
     $errorRequired = false;
     switch ($this->_contactType) {
         case 'Individual':
             if ($this->_firstNameIndex < 0 || $this->_lastNameIndex < 0) {
                 $errorRequired = true;
             } else {
                 $errorRequired = !CRM_Utils_Array::value($this->_firstNameIndex, $values) && !CRM_Utils_Array::value($this->_lastNameIndex, $values);
             }
             break;
         case 'Household':
             if ($this->_householdNameIndex < 0) {
                 $errorRequired = true;
             } else {
                 $errorRequired = !CRM_Utils_Array::value($this->_householdNameIndex, $values);
             }
             break;
         case 'Organization':
             if ($this->_organizationNameIndex < 0) {
                 $errorRequired = true;
             } else {
                 $errorRequired = !CRM_Utils_Array::value($this->_organizationNameIndex, $values);
             }
             break;
     }
     if ($this->_emailIndex >= 0) {
         /* If we don't have the required fields, bail */
         if ($this->_contactType == 'Individual' && !$this->_updateWithId) {
             if ($errorRequired && !CRM_Utils_Array::value($this->_emailIndex, $values)) {
                 array_unshift($values, ts('Missing required fields'));
                 return CRM_IMPORT_PARSER_ERROR;
             }
         }
         $email = CRM_Utils_Array::value($this->_emailIndex, $values);
         if ($email) {
             /* If the email address isn't valid, bail */
             if (!CRM_Utils_Rule::email($email)) {
                 array_unshift($values, ts('Invalid Email address'));
                 return CRM_IMPORT_PARSER_ERROR;
             }
             /* If it's a dupe, bail */
             if ($dupe = CRM_Utils_Array::value($email, $this->_allEmails)) {
                 array_unshift($values, ts('Email address conflicts with record %1', array(1 => $dupe)));
                 return CRM_IMPORT_PARSER_CONFLICT;
             }
             /* otherwise, count it and move on */
             $this->_allEmails[$email] = $this->_lineCount;
         }
     } else {
         if ($errorRequired && !$this->_updateWithId) {
             array_unshift($values, ts('Missing required fields'));
             return CRM_IMPORT_PARSER_ERROR;
         }
     }
     //checking error in custom data
     $params =& $this->getActiveFieldParams();
     $params['contact_type'] = $this->_contactType;
     //date-format part
     $session =& CRM_Core_Session::singleton();
     $dateType = $session->get("dateType");
     $customFields = CRM_Core_BAO_CustomField::getFields($params['contact_type']);
     foreach ($params as $key => $val) {
         if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) {
             if ($customFields[$customFieldID][2] == 'Date') {
                 CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key);
             }
         }
         if ($key == 'birth_date') {
             if ($val) {
                 CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key);
             }
         }
     }
     //date-format part ends
     $errorMessage = null;
     //checking error in custom data
     $this->isErrorInCustomData($params, $errorMessage);
     //checking error in core data
     $this->isErrorInCoreData($params, $errorMessage);
     if ($errorMessage) {
         $tempMsg = "Invalid value for field(s) : {$errorMessage}";
         array_unshift($values, $tempMsg);
         $errorMessage = null;
         return CRM_IMPORT_PARSER_ERROR;
     }
     return CRM_IMPORT_PARSER_VALID;
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:97,代码来源:Contact.php


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