<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
class CRM_Contact_BAO_SavedSearch extends CRM_Contact_DAO_SavedSearch {
/**
- * class constructor
+ * Class constructor
*
* @return \CRM_Contact_BAO_SavedSearch CRM_Contact_BAO_SavedSearch
*/
- function __construct() {
+ public function __construct() {
parent::__construct();
}
/**
- * query the db for all saved searches.
+ * Query the db for all saved searches.
*
- * @return array $aSavedSearch - contains the search name as value and and id as key
- *
- * @access public
+ * @return array
+ * contains the search name as value and and id as key
*/
- function getAll() {
+ public function getAll() {
$savedSearch = new CRM_Contact_DAO_SavedSearch();
$savedSearch->selectAdd();
$savedSearch->selectAdd('id, name');
* 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 CRM_Contact_BAO_SavedSearch
- * @access public
- * @static
*/
- static function retrieve(&$params, &$defaults) {
+ public static function retrieve(&$params, &$defaults) {
$savedSearch = new CRM_Contact_DAO_SavedSearch();
$savedSearch->copyValues($params);
if ($savedSearch->find(TRUE)) {
}
/**
- * 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) {
}
/**
- * @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')) {
}
/**
- * 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);
}
/**
- * @param $id
+ * @param int $id
*
* @return array
*/
- static function fromWhereEmail($id) {
+ public static function fromWhereEmail($id) {
$params = self::getSearchParams($id);
if ($params) {
}
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);
}
}
}
/**
- * 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) {
$this->where_tables = serialize($whereTables);
}
}
-
- return;
}
- function save() {
+ public function save() {
// first build the computed fields
$this->buildClause();
}
/**
- * 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)) {
* 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'])
return $savedSearch;
}
}
-