Merge pull request #4887 from pratikshad/broken-webtest
[civicrm-core.git] / CRM / Core / BAO / Email.php
index b2a8e61045e5676d26783b1e1f1da2529709f059..7b459fbfe57745a141d6cbf92b7afe0b3706adbb 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
@@ -42,11 +42,12 @@ class CRM_Core_BAO_Email extends CRM_Core_DAO_Email {
    * Create email address - note that the create function calls 'add' but
    * has more business logic
    *
-   * @param array $params input parameters
+   * @param array $params
+   *   Input parameters.
    *
    * @return object
    */
-  static function create($params) {
+  public static function create($params) {
     // if id is set & is_primary isn't we can assume no change
     if (is_numeric(CRM_Utils_Array::value('is_primary', $params)) || empty($params['id'])) {
       CRM_Core_BAO_Block::handlePrimary($params, get_class());
@@ -60,13 +61,14 @@ class CRM_Core_BAO_Email extends CRM_Core_DAO_Email {
   /**
    * Takes an associative array and adds email
    *
-   * @param array  $params         (reference ) an assoc array of name/value pairs
+   * @param array $params
+   *   (reference ) an assoc array of name/value pairs.
    *
-   * @return object       CRM_Core_BAO_Email object on success, null otherwise
-   * @access public
+   * @return object
+   *   CRM_Core_BAO_Email object on success, null otherwise
    * @static
    */
-  static function add(&$params) {
+  public static function add(&$params) {
     $hook = empty($params['id']) ? 'create' : 'edit';
     CRM_Utils_Hook::pre($hook, 'Email', CRM_Utils_Array::value('id', $params), $params);
 
@@ -89,9 +91,9 @@ UPDATE civicrm_email
 SET    is_bulkmail = 0
 WHERE  contact_id = {$params['contact_id']}
 ";
-    if($hook == 'edit'){
-      $sql .= " AND id <> {$params['id']}";
-    }
+      if ($hook == 'edit') {
+        $sql .= " AND id <> {$params['id']}";
+      }
       CRM_Core_DAO::executeQuery($sql);
     }
 
@@ -113,28 +115,29 @@ WHERE  contact_id = {$params['contact_id']}
    * Given the list of params in the params array, fetch the object
    * and store the values in the values array
    *
-   * @param array $entityBlock   input parameters to find object
+   * @param array $entityBlock
+   *   Input parameters to find object.
    *
    * @return boolean
-   * @access public
    * @static
    */
-  static function &getValues($entityBlock) {
+  public static function &getValues($entityBlock) {
     return CRM_Core_BAO_Block::getValues('email', $entityBlock);
   }
 
   /**
    * Get all the emails for a specified contact_id, with the primary email being first
    *
-   * @param int $id the contact id
+   * @param int $id
+   *   The contact id.
    *
    * @param bool $updateBlankLocInfo
    *
-   * @return array  the array of email id's
-   * @access public
+   * @return array
+   *   the array of email id's
    * @static
    */
-  static function allEmails($id, $updateBlankLocInfo = FALSE) {
+  public static function allEmails($id, $updateBlankLocInfo = FALSE) {
     if (!$id) {
       return NULL;
     }
@@ -159,8 +162,8 @@ ORDER BY  civicrm_email.is_primary DESC, email_id ASC ";
     );
 
     $emails = $values = array();
-    $dao    = CRM_Core_DAO::executeQuery($query, $params);
-    $count  = 1;
+    $dao = CRM_Core_DAO::executeQuery($query, $params);
+    $count = 1;
     while ($dao->fetch()) {
       $values = array(
         'locationType' => $dao->locationType,
@@ -184,14 +187,15 @@ ORDER BY  civicrm_email.is_primary DESC, email_id ASC ";
   /**
    * Get all the emails for a specified location_block id, with the primary email being first
    *
-   * @param array $entityElements the array containing entity_id and
-   * entity_table name
+   * @param array $entityElements
+   *   The array containing entity_id and.
+   *   entity_table name
    *
-   * @return array  the array of email id's
-   * @access public
+   * @return array
+   *   the array of email id's
    * @static
    */
-  static function allEntityEmails(&$entityElements) {
+  public static function allEntityEmails(&$entityElements) {
     if (empty($entityElements)) {
       return NULL;
     }
@@ -199,7 +203,6 @@ ORDER BY  civicrm_email.is_primary DESC, email_id ASC ";
     $entityId = $entityElements['entity_id'];
     $entityTable = $entityElements['entity_table'];
 
-
     $sql = " SELECT email, ltype.name as locationType, e.is_primary as is_primary, e.on_hold as on_hold,e.id as email_id, e.location_type_id as locationTypeId
 FROM civicrm_loc_block loc, civicrm_email e, civicrm_location_type ltype, {$entityTable} ev
 WHERE ev.id = %1
@@ -234,12 +237,13 @@ ORDER BY e.is_primary DESC, email_id ASC ";
   /**
    * Set / reset hold status for an email
    *
-   * @param object $email  email object
+   * @param object $email
+   *   Email object.
    *
    * @return void
    * @static
    */
-  static function holdEmail(&$email) {
+  public static function holdEmail(&$email) {
     //check for update mode
     if ($email->id) {
       $params = array(1 => array($email->id, 'Integer'));
@@ -265,8 +269,8 @@ AND    reset_date IS NULL
 ";
         if (CRM_Core_DAO::singleValueQuery($sql, $params)) {
           //set reset date only if it is not set and if hold date is set
-          $email->on_hold    = FALSE;
-          $email->hold_date  = 'null';
+          $email->on_hold = FALSE;
+          $email->hold_date = 'null';
           $email->reset_date = date('YmdHis');
         }
       }
@@ -282,13 +286,13 @@ AND    reset_date IS NULL
    * Build From Email as the combination of all the email ids of the logged in user and
    * the domain email id
    *
-   * @return array         an array of email ids
-   * @access public
+   * @return array
+   *   an array of email ids
    * @static
    */
-  static function getFromEmail() {
-    $session         = CRM_Core_Session::singleton();
-    $contactID       = $session->get('userID');
+  public static function getFromEmail() {
+    $session = CRM_Core_Session::singleton();
+    $contactID = $session->get('userID');
     $fromEmailValues = array();
 
     // add all configured FROM email addresses
@@ -323,15 +327,14 @@ AND    reset_date IS NULL
   /**
    * @return object
    */
-  static function isMultipleBulkMail() {
+  public static function isMultipleBulkMail() {
     return CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'civimail_multiple_bulk_emails', NULL, FALSE);
   }
 
   /**
    * Call common delete function
    */
-  static function del($id) {
+  public static function del($id) {
     return CRM_Contact_BAO_Contact::deleteObjectWithPrimary('Email', $id);
   }
 }
-