Merge pull request #5605 from sfe-ev/fix-upgrade-option_value
[civicrm-core.git] / CRM / Utils / Mail / Incoming.php
index 8cfe6f90ef9faf2bd57d6d6719a7d2c8e32f47c7..a8fa85b9dc3647dc88d479af876f2676ae711058 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014                                |
+ | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
+ * @copyright CiviCRM LLC (c) 2004-2015
  * $Id$
  *
  */
@@ -280,22 +280,22 @@ class CRM_Utils_Mail_Incoming {
       !trim(file_get_contents($file))
     ) {
       return CRM_Core_Error::createAPIError(ts('%1 does not exists or is empty',
-          array(1 => $file)
-        ));
+        array(1 => $file)
+      ));
     }
 
     require_once 'ezc/Base/src/ezc_bootstrap.php';
     require_once 'ezc/autoload/mail_autoload.php';
 
     // explode email to digestable format
-    $set    = new ezcMailFileSet(array($file));
+    $set = new ezcMailFileSet(array($file));
     $parser = new ezcMailParser();
-    $mail   = $parser->parseMail($set);
+    $mail = $parser->parseMail($set);
 
     if (!$mail) {
       return CRM_Core_Error::createAPIError(ts('%1 could not be parsed',
-          array(1 => $file)
-        ));
+        array(1 => $file)
+      ));
     }
 
     // since we only have one fileset
@@ -324,7 +324,7 @@ class CRM_Utils_Mail_Incoming {
     // we definitely need a contact id for the from address
     // if we dont have one, skip this email
     if (empty($params['from']['id'])) {
-      return;
+      return NULL;
     }
 
     $emailFields = array('to', 'cc', 'bcc');
@@ -347,9 +347,9 @@ class CRM_Utils_Mail_Incoming {
       $config = CRM_Core_Config::singleton();
       for ($i = 0; $i < count($attachments); $i++) {
         $attachNum = $i + 1;
-        $fileName  = basename($attachments[$i]['fullName']);
-        $newName   = CRM_Utils_File::makeFileName($fileName);
-        $location  = $config->uploadDir . $newName;
+        $fileName = basename($attachments[$i]['fullName']);
+        $newName = CRM_Utils_File::makeFileName($fileName);
+        $location = $config->uploadDir . $newName;
 
         // move file to the civicrm upload directory
         rename($attachments[$i]['fullName'], $location);
@@ -383,7 +383,6 @@ class CRM_Utils_Mail_Incoming {
     $subParam['email'] = $address->email;
     $subParam['name'] = $address->name;
 
-
     $contactID = self::getContactID($subParam['email'],
       $subParam['name'],
       TRUE,
@@ -409,7 +408,7 @@ class CRM_Utils_Mail_Incoming {
   }
 
   /**
-   * Retrieve a contact ID and if not present
+   * Retrieve a contact ID and if not present.
    * create one with this email
    */
   public static function getContactID($email, $name = NULL, $create = TRUE, &$mail) {
@@ -455,4 +454,5 @@ class CRM_Utils_Mail_Incoming {
       CRM_Core_DAO::$_nullArray
     );
   }
+
 }