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


PHP SugarEmailAddress::isValidEmail方法代码示例

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


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

示例1: evaluate

 /**
  * Returns itself when evaluating.
  */
 function evaluate()
 {
     $emailStr = $this->getParameters()->evaluate();
     if ($emailStr == "") {
         return AbstractExpression::$TRUE;
     }
     $lastChar = $emailStr[strlen($emailStr) - 1];
     if (!preg_match('/[^\\.]/i', $lastChar)) {
         return AbstractExpression::$FALSE;
     }
     // validate it
     $emailArr = preg_split('/[,;]/', $emailStr);
     for ($i = 0; $i < sizeof($emailArr); $i++) {
         $emailAddress = trim($emailArr[$i]);
         if ($emailAddress != '' && !SugarEmailAddress::isValidEmail($emailAddress)) {
             return AbstractExpression::$FALSE;
         }
     }
     return AbstractExpression::$TRUE;
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:23,代码来源:IsValidEmailExpression.php

示例2: apiSave

 /**
  * This should be called when the bean is saved from the API. 
  * Most fields can just use default, which calls the field's 
  * individual ->save() function instead.
  * 
  * @param SugarBean $bean the bean performing the save
  * @param array $params an array of parameters relevant to the save, which will be an array passed up to the API
  * @param string $field The name of the field to save (the vardef name, not the form element name)
  * @param array $properties Any properties for this field
  */
 public function apiSave(SugarBean $bean, array $params, $field, $properties)
 {
     if (!is_array($params[$field])) {
         // Not an array, don't do anything.
         return;
     }
     if (!isset($bean->emailAddress)) {
         $bean->emailAddress = BeanFactory::getBean('EmailAddresses');
     }
     if (empty($bean->emailAddress->addresses) && !isset($bean->emailAddress->hasFetched)) {
         $oldAddresses = $bean->emailAddress->getAddressesByGUID($bean->id, $bean->module_name);
     } else {
         $oldAddresses = $bean->emailAddress->addresses;
     }
     array_walk($params[$field], array($this, 'formatEmails'));
     $bean->emailAddress->addresses = array();
     foreach ($params[$field] as $email) {
         if (empty($email['email_address'])) {
             // Can't save an empty email address
             continue;
         }
         // Search each one for a matching set, otherwise use the defaults
         $mergeAddr = array('primary_address' => false, 'invalid_email' => false, 'opt_out' => false);
         foreach ($oldAddresses as $address) {
             if (strtolower($address['email_address']) == strtolower($email['email_address'])) {
                 $mergeAddr = $address;
                 break;
             }
         }
         $email = array_merge($mergeAddr, $email);
         if (!SugarEmailAddress::isValidEmail($email['email_address'])) {
             require_once 'include/api/SugarApiException.php';
             throw new SugarApiExceptionInvalidParameter("{$email['email_address']} is an invalid email address");
         }
         $bean->emailAddress->addAddress($email['email_address'], $email['primary_address'], false, $email['invalid_email'], $email['opt_out']);
     }
     $bean->emailAddress->save($bean->id, $bean->module_dir, $params[$field]);
     // Here is a hack for SugarEmailAddress.php so it doesn't attempt a legacy save
     $bean->emailAddress->dontLegacySave = true;
     $bean->emailAddress->populateLegacyFields($bean);
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:51,代码来源:SugarFieldEmail.php

示例3: requestPassword

 /**
  * Resets password and sends email to user
  * @param $api
  * @param array $args
  * @return bool
  * @throws SugarApiExceptionRequestMethodFailure
  * @throws SugarApiExceptionMissingParameter
  */
 public function requestPassword($api, $args)
 {
     require_once 'modules/Users/language/en_us.lang.php';
     $res = $GLOBALS['sugar_config']['passwordsetting'];
     $requiredParams = array('email', 'username');
     if (!$GLOBALS['sugar_config']['passwordsetting']['forgotpasswordON']) {
         throw new SugarApiExceptionRequestMethodFailure(translate('LBL_FORGOTPASSORD_NOT_ENABLED', 'Users'), $args);
     }
     foreach ($requiredParams as $key => $param) {
         if (!isset($args[$param])) {
             throw new SugarApiExceptionMissingParameter('Error: Missing argument.', $args);
         }
     }
     $usr = empty($this->usr) ? new User() : $this->usr;
     $useremail = $args['email'];
     $username = $args['username'];
     if (!empty($username) && !empty($useremail)) {
         $usr_id = $usr->retrieve_user_id($username);
         $usr->retrieve($usr_id);
         if (!$usr->isPrimaryEmail($useremail)) {
             throw new SugarApiExceptionRequestMethodFailure(translate('LBL_PROVIDE_USERNAME_AND_EMAIL', 'Users'), $args);
         }
         if ($usr->portal_only || $usr->is_group) {
             throw new SugarApiExceptionRequestMethodFailure(translate('LBL_PROVIDE_USERNAME_AND_EMAIL', 'Users'), $args);
         }
         // email invalid can not reset password
         if (!SugarEmailAddress::isValidEmail($usr->emailAddress->getPrimaryAddress($usr))) {
             throw new SugarApiExceptionRequestMethodFailure(translate('ERR_EMAIL_INCORRECT', 'Users'), $args);
         }
         $isLink = !$GLOBALS['sugar_config']['passwordsetting']['SystemGeneratedPasswordON'];
         // if i need to generate a password (not a link)
         $password = $isLink ? '' : User::generatePassword();
         // Create URL
         // if i need to generate a link
         if ($isLink) {
             $guid = create_guid();
             $url = $GLOBALS['sugar_config']['site_url'] . "/index.php?entryPoint=Changenewpassword&guid={$guid}";
             $time_now = TimeDate::getInstance()->nowDb();
             $q = "INSERT INTO users_password_link (id, username, date_generated) VALUES('" . $guid . "','" . $username . "','" . $time_now . "') ";
             $usr->db->query($q);
         }
         if ($isLink && isset($res['lostpasswordtmpl'])) {
             $emailTemp_id = $res['lostpasswordtmpl'];
         } else {
             $emailTemp_id = $res['generatepasswordtmpl'];
         }
         $additionalData = array('link' => $isLink, 'password' => $password);
         if (isset($url)) {
             $additionalData['url'] = $url;
         }
         $result = $usr->sendEmailForPassword($emailTemp_id, $additionalData);
         if ($result['status']) {
             return true;
         } elseif ($result['message'] != '') {
             throw new SugarApiExceptionRequestMethodFailure($result['message'], $args);
         } else {
             throw new SugarApiExceptionRequestMethodFailure('LBL_EMAIL_NOT_SENT', $args);
         }
     } else {
         throw new SugarApiExceptionMissingParameter('Error: Empty argument', $args);
     }
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:70,代码来源:PasswordApi.php

示例4: splitEmailAddress

 public function splitEmailAddress($addr)
 {
     $email = $this->_cleanAddress($addr);
     if (!SugarEmailAddress::isValidEmail($email)) {
         $email = '';
         // remove bad email addr
     }
     $name = trim(str_replace(array($email, '<', '>', '"', "'"), '', $addr));
     return array("name" => $name, "email" => strtolower($email));
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:10,代码来源:SugarEmailAddress.php

示例5: validateEmailAddresses

 /**
  * Validates email addresses. The return value is an array of key-value pairs where the keys are the email
  * addresses and the values are booleans indicating whether or not the email address is valid.
  *
  * @param $api
  * @param $args
  * @return array
  * @throws SugarApiException
  */
 public function validateEmailAddresses($api, $args)
 {
     $validatedEmailAddresses = array();
     unset($args["__sugar_url"]);
     if (!is_array($args)) {
         throw new SugarApiExceptionInvalidParameter('Invalid argument: cannot validate');
     }
     if (empty($args)) {
         throw new SugarApiExceptionMissingParameter('Missing email address(es) to validate');
     }
     $emailAddresses = $args;
     foreach ($emailAddresses as $emailAddress) {
         $validatedEmailAddresses[$emailAddress] = SugarEmailAddress::isValidEmail($emailAddress);
     }
     return $validatedEmailAddresses;
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:25,代码来源:MailApi.php

示例6: email

 /**
  * Validate email fields
  *
  * @param  $value  string
  * @param  $vardef array
  * @param  $focus  object bean of the module we're importing into
  * @return string sanitized and validated value on success, bool false on failure
  */
 public function email($value, $vardef)
 {
     if (!empty($value) && !SugarEmailAddress::isValidEmail($value)) {
         return false;
     }
     return $value;
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:15,代码来源:ImportFieldSanitize.php


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