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


PHP Misc::isError方法代码示例

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


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

示例1: getByEmail

 public function getByEmail($usr)
 {
     $filter = Net_LDAP2_Filter::create('mail', 'equals', $usr->email);
     $requested_attributes = array('cn', 'uid', 'mail');
     $search = $this->connect()->search($this->basedn, $filter, array('attributes' => $requested_attributes));
     if (Misc::isError($search)) {
         $entry = $search;
         error_log($entry->getCode() . ': ' . $entry->getMessage());
         return null;
     }
     if ($search->count() <= 0) {
         return false;
     }
     $entry = $search->current();
     $usr->uid = $entry->get_value('uid');
     $usr->full_name = $entry->get_value('cn');
     return true;
 }
开发者ID:dabielkabuto,项目名称:eventum,代码行数:18,代码来源:ldap_import.php

示例2: getEmailListing

 /**
  * Method used to get the list of emails to be displayed in the
  * grid layout.
  *
  * @param   array $options The search parameters
  * @param   integer $current_row The current page number
  * @param   integer $max The maximum number of rows per page
  * @return  array The list of issues to be displayed
  */
 public static function getEmailListing($options, $current_row = 0, $max = 5)
 {
     $prj_id = Auth::getCurrentProject();
     if ($max == 'ALL') {
         $max = 9999999;
     }
     $start = $current_row * $max;
     $stmt = 'SELECT
                 sup_id,
                 sup_ema_id,
                 sup_iss_id,
                 sup_customer_id,
                 sup_from,
                 sup_date,
                 sup_to,
                 sup_subject,
                 sup_has_attachment
              FROM
                 (
                 {{%support_email}},
                 {{%email_account}}';
     if (!empty($options['keywords'])) {
         $stmt .= ', {{%support_email_body}} ';
     }
     $stmt .= '
                 )
                 LEFT JOIN
                     {{%issue}}
                 ON
                     sup_iss_id = iss_id';
     $stmt .= self::buildWhereClause($options);
     $stmt .= '
              ORDER BY
                 ' . Misc::escapeString($options['sort_by']) . ' ' . Misc::escapeString($options['sort_order']);
     $total_rows = Pager::getTotalRows($stmt);
     $stmt .= '
              LIMIT
                 ' . Misc::escapeInteger($max) . ' OFFSET ' . Misc::escapeInteger($start);
     try {
         $res = DB_Helper::getInstance()->getAll($stmt);
     } catch (DbException $e) {
         return array('list' => '', 'info' => '');
     }
     if (count($res) < 1 && $current_row > 0) {
         // if there are no results, and the page is not the first page reset page to one and reload results
         Auth::redirect("emails.php?pagerRow=0&rows={$max}");
     }
     if (CRM::hasCustomerIntegration($prj_id)) {
         $crm = CRM::getInstance($prj_id);
         $customer_ids = array();
         foreach ($res as $row) {
             if (!empty($row['sup_customer_id']) && !in_array($row['sup_customer_id'], $customer_ids)) {
                 $customer_ids[] = $row['sup_customer_id'];
             }
         }
         if (count($customer_ids) > 0) {
             $company_titles = $crm->getCustomerTitles($customer_ids);
         }
     }
     foreach ($res as &$row) {
         $row['sup_date'] = Date_Helper::getFormattedDate($row['sup_date']);
         $row['sup_subject'] = Mime_Helper::fixEncoding($row['sup_subject']);
         $row['sup_from'] = implode(', ', Mail_Helper::getName($row['sup_from'], true));
         if (empty($row['sup_to']) && !empty($row['sup_iss_id'])) {
             $row['sup_to'] = 'Notification List';
         } else {
             $to = Mail_Helper::getName($row['sup_to']);
             // Ignore unformattable headers
             if (!Misc::isError($to)) {
                 $row['sup_to'] = Mime_Helper::fixEncoding($to);
             }
         }
         if (CRM::hasCustomerIntegration($prj_id)) {
             // FIXME: $company_titles maybe used uninitialied
             $row['customer_title'] = $company_titles[$row['sup_customer_id']];
         }
     }
     $total_pages = ceil($total_rows / $max);
     $last_page = $total_pages - 1;
     return array('list' => $res, 'info' => array('current_page' => $current_row, 'start_offset' => $start, 'end_offset' => $start + count($res), 'total_rows' => $total_rows, 'total_pages' => $total_pages, 'previous_page' => $current_row == 0 ? '-1' : $current_row - 1, 'next_page' => $current_row == $last_page ? '-1' : $current_row + 1, 'last_page' => $last_page));
 }
开发者ID:korusdipl,项目名称:eventum,代码行数:90,代码来源:class.support.php

示例3: getUserIDByEmail

 /**
  * Method used to lookup the user ID of a given email address.
  *
  * @param   string $email The email address associated with the user account
  * @param   boolean $check_aliases If user aliases should be checked as well.
  * @return  integer The user ID
  */
 public static function getUserIDByEmail($email, $check_aliases = false)
 {
     static $returns;
     if (!is_string($email)) {
         if (Misc::isError($email)) {
             Error_Handler::logError(array($email->getMessage(), $email->getDebugInfo()), __FILE__, __LINE__);
             return null;
         }
         Error_Handler::logError('$email parameter is not a string: ' . gettype($email), __FILE__, __LINE__);
         return null;
     }
     if (!empty($returns[$email])) {
         return $returns[$email];
     }
     $stmt = 'SELECT
                 usr_id
              FROM
                 {{%user}}
              WHERE
                 usr_email=?';
     $res = DB_Helper::getInstance()->getOne($stmt, array($email));
     if (empty($res) && $check_aliases) {
         $res = self::getUserIDByAlias($email);
     }
     $returns[$email] = $res;
     return $returns[$email];
 }
开发者ID:korusdipl,项目名称:eventum,代码行数:34,代码来源:class.user.php

示例4: getUserIDByEmail

 /**
  * Method used to lookup the user ID of a given email address.
  *
  * @param   string $email The email address associated with the user account
  * @param   boolean $check_aliases If user aliases should be checked as well.
  * @return  integer The user ID
  */
 public static function getUserIDByEmail($email, $check_aliases = false)
 {
     static $returns;
     if (!is_string($email)) {
         if (Misc::isError($email)) {
             Logger::app()->error($email->getMessage(), array('debug' => $email->getDebugInfo()));
             return null;
         }
         Logger::app()->error('$email parameter is not a string', array('type' => gettype($email)));
         return null;
     }
     if (!empty($returns[$email])) {
         return $returns[$email];
     }
     $stmt = 'SELECT
                 usr_id
              FROM
                 {{%user}}
              WHERE
                 usr_email=?';
     $res = DB_Helper::getInstance()->getOne($stmt, array($email));
     if (empty($res) && $check_aliases) {
         $res = self::getUserIDByAlias($email);
     }
     $returns[$email] = $res;
     return $returns[$email];
 }
开发者ID:dabielkabuto,项目名称:eventum,代码行数:34,代码来源:class.user.php

示例5: getRemoteUserInfo

 /**
  * Retrieve information from LDAP
  *
  * @param string $uid login or email
  * @return array
  */
 public function getRemoteUserInfo($uid)
 {
     if (strpos($uid, '@') === false) {
         $filter = Net_LDAP2_Filter::create('uid', 'equals', $uid);
     } else {
         $filter = Net_LDAP2_Filter::create('mail', 'equals', $uid);
     }
     if (!empty($this->user_filter_string)) {
         $user_filter = Net_LDAP2_Filter::parse($this->user_filter_string);
         $filter = Net_LDAP2_Filter::combine('and', array($filter, $user_filter));
     }
     $search = $this->connect()->search($this->basedn, $filter, array('sizelimit' => 1));
     $entry = $search->shiftEntry();
     if (!$entry || Misc::isError($entry)) {
         return null;
     }
     $details = array('uid' => $entry->get_value('uid'), 'full_name' => Misc::trim($entry->get_value('cn')), 'emails' => Misc::trim(Misc::lowercase($entry->get_value('mail', 'all'))), 'customer_id' => Misc::trim($entry->get_value($this->customer_id_attribute)) ?: null, 'contact_id' => Misc::trim($entry->get_value($this->contact_id_attribute)) ?: null);
     return $details;
 }
开发者ID:dabielkabuto,项目名称:eventum,代码行数:25,代码来源:class.ldap_auth_backend.php

示例6: assertError

 /**
  * Check if $e is PEAR error, if so, throw as DbException
  *
  * @param $e PEAR_Error|array|object|int
  */
 private function assertError($e, $depth = 2)
 {
     if (!Misc::isError($e)) {
         return;
     }
     list($file, $line) = self::getTrace($depth);
     Error_Handler::logError(array($e->getMessage(), $e->getDebugInfo()), $file, $line);
     $de = new DbException($e->getMessage(), $e->getCode());
     $de->setExceptionLocation($file, $line);
     error_log($de->getMessage());
     error_log($de->getTraceAsString());
     throw $de;
 }
开发者ID:korusdipl,项目名称:eventum,代码行数:18,代码来源:DbPear.php

示例7: _sendEmail

 /**
  * Connects to the SMTP server and sends the queued message.
  *
  * @param   string $recipient The recipient of this message
  * @param   string $text_headers The full headers of this message
  * @param   string $body The full body of this message
  * @param   string $status The status of this message
  * @return  true, or a PEAR_Error object
  */
 private function _sendEmail($recipient, $text_headers, &$body, $status)
 {
     $header_names = Mime_Helper::getHeaderNames($text_headers);
     $_headers = self::_getHeaders($text_headers, $body);
     $headers = array();
     foreach ($_headers as $lowercase_name => $value) {
         // need to remove the quotes to avoid a parsing problem
         // on senders that have extended characters in the first
         // or last words in their sender name
         if ($lowercase_name == 'from') {
             $value = Mime_Helper::removeQuotes($value);
         }
         $value = Mime_Helper::encode($value);
         // add the quotes back
         if ($lowercase_name == 'from') {
             $value = Mime_Helper::quoteSender($value);
         }
         $headers[$header_names[$lowercase_name]] = $value;
     }
     // remove any Reply-To:/Return-Path: values from outgoing messages
     unset($headers['Reply-To']);
     unset($headers['Return-Path']);
     // mutt sucks, so let's remove the broken Mime-Version header and add the proper one
     if (in_array('Mime-Version', array_keys($headers))) {
         unset($headers['Mime-Version']);
         $headers['MIME-Version'] = '1.0';
     }
     $mail = Mail::factory('smtp', Mail_Helper::getSMTPSettings());
     $res = $mail->send($recipient, $headers, $body);
     if (Misc::isError($res)) {
         // special handling of errors when the mail server is down
         $msg = $res->getMessage();
         $cant_notify = $status == 'error' || strstr($msg, 'unable to connect to smtp server') || stristr($msg, 'Failed to connect to') !== false;
         Error_Handler::logError(array($msg, $res->getDebugInfo()), __FILE__, __LINE__, !$cant_notify);
         return $res;
     }
     return true;
 }
开发者ID:korusdipl,项目名称:eventum,代码行数:47,代码来源:class.mail_queue.php

示例8: _sendEmail

 /**
  * Connects to the SMTP server and sends the queued message.
  *
  * @param   string $recipient The recipient of this message
  * @param   string $text_headers The full headers of this message
  * @param   string $body The full body of this message
  * @param   string $status The status of this message
  * @return  true, or a PEAR_Error object
  */
 private function _sendEmail($recipient, $text_headers, &$body, $status)
 {
     $header_names = Mime_Helper::getHeaderNames($text_headers);
     $_headers = self::_getHeaders($text_headers, $body);
     $headers = array();
     foreach ($_headers as $lowercase_name => $value) {
         // need to remove the quotes to avoid a parsing problem
         // on senders that have extended characters in the first
         // or last words in their sender name
         if ($lowercase_name == 'from') {
             $value = Mime_Helper::removeQuotes($value);
         }
         $value = Mime_Helper::encode($value);
         // add the quotes back
         if ($lowercase_name == 'from') {
             $value = Mime_Helper::quoteSender($value);
         }
         $headers[$header_names[$lowercase_name]] = $value;
     }
     // remove any Reply-To:/Return-Path: values from outgoing messages
     unset($headers['Reply-To']);
     unset($headers['Return-Path']);
     // mutt sucks, so let's remove the broken Mime-Version header and add the proper one
     if (in_array('Mime-Version', array_keys($headers))) {
         unset($headers['Mime-Version']);
         $headers['MIME-Version'] = '1.0';
     }
     $mail = Mail::factory('smtp', Mail_Helper::getSMTPSettings());
     $res = $mail->send($recipient, $headers, $body);
     if (Misc::isError($res)) {
         Logger::app()->error($res->getMessage(), array('debug' => $res->getDebugInfo()));
         return $res;
     }
     return true;
 }
开发者ID:dabielkabuto,项目名称:eventum,代码行数:44,代码来源:class.mail_queue.php

示例9: assertError

 /**
  * Check if $e is PEAR error, if so, throw as DbException
  *
  * @param $e PEAR_Error|array|object|int
  */
 private function assertError($e)
 {
     if (!Misc::isError($e)) {
         return;
     }
     $context = array('debuginfo' => $e->getDebugInfo());
     // walk up in $e->backtrace until we find ourself
     // and from it we can get method name and it's arguments
     foreach ($e->backtrace as $i => $stack) {
         if (!isset($stack['object'])) {
             continue;
         }
         if (!$stack['object'] instanceof self) {
             continue;
         }
         $context['method'] = $stack['function'];
         $context['arguments'] = $stack['args'];
         // add these last, they are least interesting ones
         $context['code'] = $e->getCode();
         $context['file'] = $stack['file'];
         $context['line'] = $stack['line'];
         break;
     }
     Logger::db()->error($e->getMessage(), $context);
     $de = new DbException($e->getMessage(), $e->getCode());
     if (isset($context['file'])) {
         $de->setExceptionLocation($context['file'], $context['line']);
     }
     throw $de;
 }
开发者ID:dabielkabuto,项目名称:eventum,代码行数:35,代码来源:DbPear.php

示例10: saveOutgoingEmailCopy

 /**
  * Method used to save a copy of the given email to a configurable address.
  *
  * @param   array $email The email to save.
  */
 public static function saveOutgoingEmailCopy(&$email)
 {
     // check early: do we really want to save every outgoing email?
     $setup = Setup::load();
     $save_outgoing_email = !empty($setup['smtp']['save_outgoing_email']) && $setup['smtp']['save_outgoing_email'] == 'yes';
     if (!$save_outgoing_email || empty($setup['smtp']['save_address'])) {
         return false;
     }
     static $subjects = array();
     $hdrs =& $email['headers'];
     $body =& $email['body'];
     $issue_id = $email['maq_iss_id'];
     $sender_usr_id = $email['maq_usr_id'];
     // ok, now parse the headers text and build the assoc array
     $full_email = $hdrs . "\n\n" . $body;
     $structure = Mime_Helper::decode($full_email, false, false);
     $_headers =& $structure->headers;
     $header_names = Mime_Helper::getHeaderNames($hdrs);
     $headers = array();
     foreach ($_headers as $lowercase_name => $value) {
         // need to remove the quotes to avoid a parsing problem
         // on senders that have extended characters in the first
         // or last words in their sender name
         if ($lowercase_name == 'from') {
             $value = Mime_Helper::removeQuotes($value);
         }
         $value = Mime_Helper::encode($value);
         // add the quotes back
         if ($lowercase_name == 'from') {
             $value = Mime_Helper::quoteSender($value);
         }
         $headers[$header_names[$lowercase_name]] = $value;
     }
     // remove any Reply-To:/Return-Path: values from outgoing messages
     unset($headers['Reply-To']);
     unset($headers['Return-Path']);
     // prevent duplicate emails from being sent out...
     $subject = @$headers['Subject'];
     if (@in_array($subject, $subjects)) {
         return false;
     }
     // replace the To: header with the requested address
     $address = $setup['smtp']['save_address'];
     $headers['To'] = $address;
     // add specialized headers if they are not already added
     if (empty($headers['X-Eventum-Type'])) {
         $headers += self::getSpecializedHeaders($issue_id, $email['maq_type'], $headers, $sender_usr_id);
     }
     $params = self::getSMTPSettings($address);
     $mail = Mail::factory('smtp', $params);
     $res = $mail->send($address, $headers, $body);
     if (Misc::isError($res)) {
         Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
     }
     $subjects[] = $subject;
 }
开发者ID:korusdipl,项目名称:eventum,代码行数:61,代码来源:class.mail_helper.php


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