Merge remote-tracking branch 'upstream/4.5' into 4.5-master-2014-12-22-22-01-44
[civicrm-core.git] / tools / extensions / org.civicrm.search.activity / ActivitySearch.php
index e85f4cebd8d5c4ffa9dcbeb40f37e67022319b77..64f69b97b398a175757f6c0f7a3535d743a03b2e 100644 (file)
  */
 
 require_once 'CRM/Contact/Form/Search/Interface.php';
+
+/**
+ * Class org_civicrm_search_activityimplementsCRM_Contact_Form_Search_Interface
+ */
 class org_civicrm_search_activityimplementsCRM_Contact_Form_Search_Interface {
 
   protected $_formValues;
 
+  /**
+   * @param $formValues
+   */
   function __construct(&$formValues) {
     $this->_formValues = $formValues;
 
@@ -86,6 +93,9 @@ class org_civicrm_search_activityimplementsCRM_Contact_Form_Search_Interface {
     //end custom fields
   }
 
+  /**
+   * @param CRM_Core_Form $form
+   */
   function buildForm(&$form) {
 
     /**
@@ -223,34 +233,43 @@ class org_civicrm_search_activityimplementsCRM_Contact_Form_Search_Interface {
 
   // Alters the date display in the Activity Date Column. We do this after we already have
   // the result so that sorting on the date column stays pertinent to the numeric date value
+  /**
+   * @param $row
+   */
   function alterRow(&$row) {
     $row['activity_date'] = CRM_Utils_Date::customFormat($row['activity_date'], '%B %E%f, %Y %l:%M %P');
   }
 
   // Regular JOIN statements here to limit results to contacts who have activities.
+  /**
+   * @return string
+   */
   function from() {
     return "
         civicrm_contact contact_a
-            JOIN civicrm_activity activity 
+            JOIN civicrm_activity activity
                  ON contact_a.id = activity.source_contact_id
-            JOIN civicrm_option_value ov1 
+            JOIN civicrm_option_value ov1
                  ON activity.activity_type_id = ov1.value AND ov1.option_group_id = 2
-            JOIN civicrm_option_value ov2 
+            JOIN civicrm_option_value ov2
                  ON activity.status_id = ov2.value AND ov2.option_group_id = {$this->_groupId}
-            JOIN civicrm_contact contact_b 
+            JOIN civicrm_contact contact_b
                  ON activity.source_contact_id = contact_b.id
-            LEFT JOIN civicrm_case_activity cca 
+            LEFT JOIN civicrm_case_activity cca
                  ON activity.id = cca.activity_id
-            LEFT JOIN civicrm_activity_assignment assignment 
+            LEFT JOIN civicrm_activity_assignment assignment
                  ON activity.id = assignment.activity_id
-            LEFT JOIN civicrm_contact contact_c 
+            LEFT JOIN civicrm_contact contact_c
                  ON assignment.assignee_contact_id = contact_c.id ";
   }
 
-  /*
-     * WHERE clause is an array built from any required JOINS plus conditional filters based on search criteria field values
-     *
-     */
+  /**
+   * WHERE clause is an array built from any required JOINS plus conditional filters based on search criteria field values
+   *
+   * @param bool $includeContactIDs
+   *
+   * @return string
+   */
   function where($includeContactIDs = FALSE) {
     $clauses = array();
 
@@ -259,8 +278,8 @@ class org_civicrm_search_activityimplementsCRM_Contact_Form_Search_Interface {
     if (!empty($contactname)) {
       $dao         = new CRM_Core_DAO();
       $contactname = $dao->escape($contactname);
-      $clauses[]   = "(contact_a.sort_name LIKE '%{$contactname}%' OR 
-                           contact_b.sort_name LIKE '%{$contactname}%' OR 
+      $clauses[]   = "(contact_a.sort_name LIKE '%{$contactname}%' OR
+                           contact_b.sort_name LIKE '%{$contactname}%' OR
                            contact_c.display_name LIKE '%{$contactname}%')";
     }
 
@@ -321,9 +340,13 @@ class org_civicrm_search_activityimplementsCRM_Contact_Form_Search_Interface {
     return implode(' AND ', $clauses);
   }
 
-  /* 
-     * Functions below generally don't need to be modified
-     */
+  /*
+   * Functions below generally don't need to be modified
+   */
+
+  /**
+   * @return mixed
+   */
   function count() {
     $sql = $this->all();
 
@@ -333,14 +356,27 @@ class org_civicrm_search_activityimplementsCRM_Contact_Form_Search_Interface {
     return $dao->N;
   }
 
+  /**
+   * @param int $offset
+   * @param int $rowcount
+   * @param null $sort
+   *
+   * @return string
+   */
   function contactIDs($offset = 0, $rowcount = 0, $sort = NULL) {
     return $this->all($offset, $rowcount, $sort, FALSE, TRUE);
   }
 
+  /**
+   * @return array
+   */
   function &columns() {
     return $this->_columns;
   }
 
+  /**
+   * @param $title
+   */
   function setTitle($title) {
     if ($title) {
       CRM_Utils_System::setTitle($title);
@@ -350,6 +386,9 @@ class org_civicrm_search_activityimplementsCRM_Contact_Form_Search_Interface {
     }
   }
 
+  /**
+   * @return null
+   */
   function summary() {
     return NULL;
   }