X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FContact%2FBAO%2FSavedSearch.php;h=fe1f399a78e0b01438775f0d5ce8d5b0fe13a631;hb=acb1052ec2199198d0ca02bda45e61cc95ec6d35;hp=b13a2f35fde3e0c46039c5e5a3d71470b39922eb;hpb=68acd6ae8e764d8e713829675cfadfdefff770e8;p=civicrm-core.git diff --git a/CRM/Contact/BAO/SavedSearch.php b/CRM/Contact/BAO/SavedSearch.php index b13a2f35fd..fe1f399a78 100644 --- a/CRM/Contact/BAO/SavedSearch.php +++ b/CRM/Contact/BAO/SavedSearch.php @@ -1,7 +1,7 @@ selectAdd(); $savedSearch->selectAdd('id, name'); @@ -70,14 +69,14 @@ class CRM_Contact_BAO_SavedSearch extends CRM_Contact_DAO_SavedSearch { * Takes a bunch of params that are needed to match certain criteria and * retrieves the relevant objects. * - * @param array $params (reference ) an assoc array of name/value pairs - * @param array $defaults (reference ) an assoc array to hold the flattened values + * @param array $params + * (reference ) an assoc array of name/value pairs. + * @param array $defaults + * (reference ) an assoc array to hold the flattened values. * - * @return object CRM_Contact_BAO_SavedSearch - * @access public - * @static + * @return CRM_Contact_BAO_SavedSearch */ - static function retrieve(&$params, &$defaults) { + public static function retrieve(&$params, &$defaults) { $savedSearch = new CRM_Contact_DAO_SavedSearch(); $savedSearch->copyValues($params); if ($savedSearch->find(TRUE)) { @@ -88,15 +87,15 @@ class CRM_Contact_BAO_SavedSearch extends CRM_Contact_DAO_SavedSearch { } /** - * given an id, extract the formValues of the saved search + * Given an id, extract the formValues of the saved search * - * @param int $id the id of the saved search + * @param int $id + * The id of the saved search. * - * @return array the values of the posted saved search - * @access public - * @static + * @return array + * the values of the posted saved search */ - static function &getFormValues($id) { + public static function &getFormValues($id) { $fv = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $id, 'form_values'); $result = NULL; if ($fv) { @@ -131,11 +130,11 @@ class CRM_Contact_BAO_SavedSearch extends CRM_Contact_DAO_SavedSearch { } /** - * @param $id + * @param int $id * * @return array */ - static function getSearchParams($id) { + public static function getSearchParams($id) { $fv = self::getFormValues($id); //check if the saved search has mapping id if (CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $id, 'mapping_id')) { @@ -150,34 +149,37 @@ class CRM_Contact_BAO_SavedSearch extends CRM_Contact_DAO_SavedSearch { } /** - * get the where clause for a saved search + * Get the where clause for a saved search * - * @param int $id saved search id - * @param array $tables (reference ) add the tables that are needed for the select clause - * @param array $whereTables (reference ) add the tables that are needed for the where clause + * @param int $id + * Saved search id. + * @param array $tables + * (reference ) add the tables that are needed for the select clause. + * @param array $whereTables + * (reference ) add the tables that are needed for the where clause. * - * @return string the where clause for this saved search - * @access public - * @static + * @return string + * the where clause for this saved search */ - static function whereClause($id, &$tables, &$whereTables) { + public static function whereClause($id, &$tables, &$whereTables) { $params = self::getSearchParams($id); if ($params) { if (!empty($params['customSearchID'])) { // this has not yet been implemented - } else { - return CRM_Contact_BAO_Query::getWhereClause($params, NULL, $tables, $whereTables); - } + } + else { + return CRM_Contact_BAO_Query::getWhereClause($params, NULL, $tables, $whereTables); + } } return NULL; } /** - * @param $id + * @param int $id * * @return string */ - static function contactIDsSQL($id) { + public static function contactIDsSQL($id) { $params = self::getSearchParams($id); if ($params && !empty($params['customSearchID'])) { return CRM_Contact_BAO_SearchCustom::contactIDSQL(NULL, $id); @@ -197,11 +199,11 @@ WHERE $where"; } /** - * @param $id + * @param int $id * * @return array */ - static function fromWhereEmail($id) { + public static function fromWhereEmail($id) { $params = self::getSearchParams($id); if ($params) { @@ -210,8 +212,8 @@ WHERE $where"; } else { $tables = $whereTables = array('civicrm_contact' => 1, 'civicrm_email' => 1); - $where = CRM_Contact_BAO_SavedSearch::whereClause($id, $tables, $whereTables); - $from = CRM_Contact_BAO_Query::fromClause($whereTables); + $where = CRM_Contact_BAO_SavedSearch::whereClause($id, $tables, $whereTables); + $from = CRM_Contact_BAO_Query::fromClause($whereTables); return array($from, $where); } } @@ -229,10 +231,10 @@ LEFT JOIN civicrm_email ON (contact_a.id = civicrm_email.contact_id AND civicrm_ } /** - * given a saved search compute the clause and the tables + * Given a saved search compute the clause and the tables * and store it for future use */ - function buildClause() { + public function buildClause() { $fv = unserialize($this->form_values); if ($this->mapping_id) { @@ -252,11 +254,9 @@ LEFT JOIN civicrm_email ON (contact_a.id = civicrm_email.contact_id AND civicrm_ $this->where_tables = serialize($whereTables); } } - - return; } - function save() { + public function save() { // first build the computed fields $this->buildClause(); @@ -264,17 +264,17 @@ LEFT JOIN civicrm_email ON (contact_a.id = civicrm_email.contact_id AND civicrm_ } /** - * given an id, get the name of the saved search + * Given an id, get the name of the saved search * - * @param int $id the id of the saved search + * @param int $id + * The id of the saved search. * * @param string $value * - * @return string the name of the saved search - * @access public - * @static + * @return string + * the name of the saved search */ - static function getName($id, $value = 'name') { + public static function getName($id, $value = 'name') { $group = new CRM_Contact_DAO_Group(); $group->saved_search_id = $id; if ($group->find(TRUE)) { @@ -287,7 +287,7 @@ LEFT JOIN civicrm_email ON (contact_a.id = civicrm_email.contact_id AND civicrm_ * Given a label and a set of normalized POST * formValues, create a smart group with that */ - static function create(&$params) { + public static function create(&$params) { $savedSearch = new CRM_Contact_DAO_SavedSearch(); if (isset($params['formValues']) && !empty($params['formValues']) @@ -308,4 +308,3 @@ LEFT JOIN civicrm_email ON (contact_a.id = civicrm_email.contact_id AND civicrm_ return $savedSearch; } } -