| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
*
* This defines two actions- View and Edit.
*
* @var array
- * @static
*/
static $_links = NULL;
* We use desc to remind us what that column is, name is used in the tpl
*
* @var array
- * @static
*/
static $_columnHeaders;
/**
* Properties of contact we're interested in displaying
* @var array
- * @static
*/
static $_properties = array(
- 'contact_id', 'contact_type', 'contact_sub_type',
- 'sort_name', 'street_address',
- 'city', 'state_province', 'postal_code', 'country',
- 'geo_code_1', 'geo_code_2', 'is_deceased',
- 'email', 'on_hold', 'phone', 'status',
- 'do_not_email', 'do_not_phone', 'do_not_mail',
+ 'contact_id',
+ 'contact_type',
+ 'contact_sub_type',
+ 'sort_name',
+ 'street_address',
+ 'city',
+ 'state_province',
+ 'postal_code',
+ 'country',
+ 'geo_code_1',
+ 'geo_code_2',
+ 'is_deceased',
+ 'email',
+ 'on_hold',
+ 'phone',
+ 'status',
+ 'do_not_email',
+ 'do_not_phone',
+ 'do_not_mail',
);
/**
* the HTML_QuickForm_Controller for that page.
*
* @var array
- * @access protected
*/
public $_formValues;
* The contextMenu
*
* @var array
- * @access protected
*/
protected $_contextMenu;
* Params is the array in a value used by the search query creator
*
* @var array
- * @access protected
*/
public $_params;
* The return properties used for search
*
* @var array
- * @access protected
*/
protected $_returnProperties;
* Represent the type of selector
*
* @var int
- * @access protected
*/
protected $_action;
* The public visible fields to be shown to the user
*
* @var array
- * @access protected
*/
protected $_fields;
/**
- * Class constructor
+ * Class constructor.
*
* @param $customSearchClass
- * @param array $formValues array of form values imported
- * @param array $params array of parameters for query
+ * @param array $formValues
+ * Array of form values imported.
+ * @param array $params
+ * Array of parameters for query.
* @param null $returnProperties
* @param \const|int $action - action of search basic or advanced.
*
* @param null $contextMenu
*
* @return CRM_Contact_Selector
- * @access public
*/
- function __construct(
+ public function __construct(
$customSearchClass,
$formValues = NULL,
$params = NULL,
* - Edit
*
* @return array
- * @access public
- *
*/
- static function &links() {
+ public static function &links() {
list($context, $contextMenu, $key) = func_get_args();
$extraParams = ($key) ? "&key={$key}" : NULL;
$searchContext = ($context) ? "&context=$context" : NULL;
*
* @param $action
* @param array $params
- *
- * @access public
*/
- function getPagerParams($action, &$params) {
- $params['status'] = ts('Contact %%StatusMessage%%');
+ public function getPagerParams($action, &$params) {
+ $params['status'] = ts('Contact %%StatusMessage%%');
$params['csvString'] = NULL;
- $params['rowCount'] = CRM_Utils_Pager::ROWCOUNT;
+ $params['rowCount'] = CRM_Utils_Pager::ROWCOUNT;
$params['buttonTop'] = 'PagerTopButton';
$params['buttonBottom'] = 'PagerBottomButton';
*
* @return array
*/
- function &getColHeads($action = NULL, $output = NULL) {
+ public function &getColHeads($action = NULL, $output = NULL) {
$colHeads = self::_getColumnHeaders();
$colHeads[] = array('desc' => ts('Actions'), 'name' => ts('Action'));
return $colHeads;
* Returns the column headers as an array of tuples:
* (name, sortName (key to the sort array))
*
- * @param string $action the action being performed
- * @param enum $output what should the result set include (web/email/csv)
+ * @param string $action
+ * The action being performed.
+ * @param string $output
+ * What should the result set include (web/email/csv).
*
- * @return array the column headers that need to be displayed
- * @access public
+ * @return array
+ * the column headers that need to be displayed
*/
- function &getColumnHeaders($action = NULL, $output = NULL) {
+ public function &getColumnHeaders($action = NULL, $output = NULL) {
$headers = NULL;
// unset return property elements that we don't care
'contact_sub_type',
'sort_name',
);
- foreach ( $doNotCareElements as $value) {
+ foreach ($doNotCareElements as $value) {
unset($this->_returnProperties[$value]);
}
}
$direction = CRM_Utils_Sort::ASCENDING;
$empty = TRUE;
if (!self::$_columnHeaders) {
- self::$_columnHeaders = array(array('name' => ''),
+ self::$_columnHeaders = array(
+ array('name' => ''),
array(
'name' => ts('Name'),
'sort' => 'sort_name',
}
if (in_array($fieldName, array(
- 'phone', 'im', 'email'))) {
+ 'phone',
+ 'im',
+ 'email',
+ ))) {
if ($type) {
$name = "`$locationTypeName-$fieldName-$type`";
}
$headers = self::$_columnHeaders;
}
elseif (!empty($this->_returnProperties)) {
- self::$_columnHeaders = array(array('name' => ''),
+ self::$_columnHeaders = array(
+ array('name' => ''),
array(
'name' => ts('Name'),
'sort' => 'sort_name',
*
* @param
*
- * @return int Total number of rows
- * @access public
+ * @return int
+ * Total number of rows
*/
- function getTotalCount($action) {
+ public function getTotalCount($action) {
// Use count from cache during paging/sorting
if (!empty($_GET['crmPID']) || !empty($_GET['crmSID'])) {
$count = CRM_Core_BAO_Cache::getItem('Search Results Count', $this->_key);
}
/**
- * Returns all the rows in the given offset and rowCount
+ * Returns all the rows in the given offset and rowCount.
*
- * @param enum $action the action being performed
- * @param int $offset the row number to start from
- * @param int $rowCount the number of rows to return
- * @param string $sort the sql string that describes the sort order
- * @param enum $output what should the result set include (web/email/csv)
+ * @param string $action
+ * The action being performed.
+ * @param int $offset
+ * The row number to start from.
+ * @param int $rowCount
+ * The number of rows to return.
+ * @param string $sort
+ * The sql string that describes the sort order.
+ * @param string $output
+ * What should the result set include (web/email/csv).
*
- * @return int the total number of rows for this action
+ * @return int
+ * the total number of rows for this action
*/
- function &getRows($action, $offset, $rowCount, $sort, $output = NULL) {
+ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) {
$config = CRM_Core_Config::singleton();
if (($output == CRM_Core_Selector_Controller::EXPORT ||
$locationTypeName = str_replace(' ', '_', $locationTypeName);
if (in_array($fieldName, array(
- 'phone', 'im', 'email'))) {
+ 'phone',
+ 'im',
+ 'email',
+ ))) {
if ($type) {
$names[] = "{$locationTypeName}-{$fieldName}-{$type}";
}
if (in_array('world_region', $names)) {
$pseudoconstants['world_region'] = array(
'dbName' => 'world_region_id',
- 'values' => CRM_Core_PseudoConstant::worldRegion()
+ 'values' => CRM_Core_PseudoConstant::worldRegion(),
);
}
elseif (strpos($property, '-im')) {
$row[$property] = $result->$property;
if (!empty($result->$property)) {
- $imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id');
- $providerId = $property . "-provider_id";
- $providerName = $imProviders[$result->$providerId];
+ $imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id');
+ $providerId = $property . "-provider_id";
+ $providerName = $imProviders[$result->$providerId];
$row[$property] = $result->$property . " ({$providerName})";
}
}
elseif (in_array($property, array(
- 'addressee', 'email_greeting', 'postal_greeting'))) {
+ 'addressee',
+ 'email_greeting',
+ 'postal_greeting',
+ ))) {
$greeting = $property . '_display';
$row[$property] = $result->$greeting;
}
$websiteFld = $websiteKey . '-' . array_pop($propertyArray);
if (!empty($result->$websiteFld)) {
$websiteTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id');
- $websiteType = $websiteTypes[$result->{"$websiteKey-website_type_id"}];
+ $websiteType = $websiteTypes[$result->{"$websiteKey-website_type_id"}];
$websiteValue = $result->$websiteFld;
- $websiteUrl = "<a href=\"{$websiteValue}\">{$websiteValue} ({$websiteType})</a>";
+ $websiteUrl = "<a href=\"{$websiteValue}\">{$websiteValue} ({$websiteType})</a>";
}
$row[$property] = $websiteUrl;
}
// allow components to add more actions
CRM_Core_Component::searchAction($row, $result->contact_id);
- $row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ?
- $result->contact_sub_type : $result->contact_type,
+ $row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type,
FALSE,
$result->contact_id
);
$row['contact_type_orig'] = $result->contact_sub_type ? $result->contact_sub_type : $result->contact_type;
- $row['contact_sub_type'] = $result->contact_sub_type ?
- CRM_Contact_BAO_ContactType::contactTypePairs(FALSE, $result->contact_sub_type, ', ') : $result->contact_sub_type;
+ $row['contact_sub_type'] = $result->contact_sub_type ? CRM_Contact_BAO_ContactType::contactTypePairs(FALSE, $result->contact_sub_type, ', ') : $result->contact_sub_type;
$row['contact_id'] = $result->contact_id;
$row['sort_name'] = $result->sort_name;
if (array_key_exists('id', $row)) {
*
* @return string
*/
- function buildPrevNextCache($sort) {
+ public function buildPrevNextCache($sort) {
$cacheKey = 'civicrm search ' . $this->_key;
// We should clear the cache in following conditions:
// check for current != previous to ensure cache is not reset if paging is done without changing
// sort criteria
- if (!$pageNum || (!empty($currentSortID) && $currentSortID != $previousSortID) ) {
+ if (!$pageNum || (!empty($currentSortID) && $currentSortID != $previousSortID)) {
CRM_Core_BAO_PrevNextCache::deleteItem(NULL, $cacheKey, 'civicrm_contact');
// this means it's fresh search, so set pageNum=1
if (!$pageNum) {
/**
* @param $rows
*/
- function addActions(&$rows) {
+ public function addActions(&$rows) {
$config = CRM_Core_Config::singleton();
$permissions = array(CRM_Core_Permission::getPermission());
$links = self::links($this->_context, $this->_contextMenu, $this->_key);
-
foreach ($rows as $id => & $row) {
if (!empty($this->_formValues['deleted_contacts']) && CRM_Core_Permission::check('access deleted contacts')
) {
}
$row['action'] = CRM_Core_Action::formLink(
$links,
- null,
+ NULL,
array('id' => $row['contact_id']),
ts('more'),
FALSE,
/**
* @param $rows
*/
- function removeActions(&$rows) {
+ public function removeActions(&$rows) {
foreach ($rows as $rid => & $rValue) {
unset($rValue['contact_type']);
unset($rValue['action']);
* @param int $start
* @param int $end
*/
- function fillupPrevNextCache($sort, $cacheKey, $start = 0, $end = 500) {
+ public function fillupPrevNextCache($sort, $cacheKey, $start = 0, $end = 500) {
$coreSearch = TRUE;
// For custom searches, use the contactIDs method
if (is_a($this, 'CRM_Contact_Selector_Custom')) {
}
/**
- * This function is called to rebuild prev next cache using full sql in case of core search ( excluding custom search)
+ * called to rebuild prev next cache using full sql in case of core search ( excluding custom search)
*
- * @param int $start start for limit clause
- * @param int $end end for limit clause
+ * @param int $start
+ * Start for limit clause.
+ * @param int $end
+ * End for limit clause.
* @param CRM_Utils_Sort $sort
- * @param string $cacheKey cache key
+ * @param string $cacheKey
+ * Cache key.
*
* @return void
*/
- function rebuildPreNextCache($start, $end, $sort, $cacheKey) {
+ public function rebuildPreNextCache($start, $end, $sort, $cacheKey) {
// generate full SQL
$sql = $this->_query->searchQuery($start, $end, $sort, FALSE, $this->_query->_includeContactIds,
FALSE, FALSE, TRUE);
// build insert query, note that currently we build cache for 500 contact records at a time, hence below approach
$insertValues = array();
- while($dao->fetch()) {
+ while ($dao->fetch()) {
$insertValues[] = "('civicrm_contact', {$dao->contact_id}, {$dao->contact_id}, '{$cacheKey}', '" . CRM_Core_DAO::escapeString($dao->sort_name) . "')";
}
//update pre/next cache using single insert query
if (!empty($insertValues)) {
$sql = 'INSERT INTO civicrm_prevnext_cache ( entity_table, entity_id1, entity_id2, cacheKey, data ) VALUES
-'.implode(',', $insertValues);
+' . implode(',', $insertValues);
$result = CRM_Core_DAO::executeQuery($sql);
}
}
/**
- * Given the current formValues, gets the query in local
- * language
- *
- * @param array(
- reference) $formValues submitted formValues
- *
- * @return array $qill which contains an array of strings
- * @access public
+ * @inheritDoc
*/
-
- // the current internationalisation is bad, but should more or less work
- // for most of "European" languages
public function getQILL() {
return $this->_query->qill();
}
/**
* Name of export file.
*
- * @param string $output type of output
+ * @param string $output
+ * Type of output.
*
- * @return string name of the file
+ * @return string
+ * name of the file
*/
- function getExportFileName($output = 'csv') {
+ public function getExportFileName($output = 'csv') {
return ts('CiviCRM Contact Search');
}
/**
- * Get colunmn headers for search selector
+ * Get colunmn headers for search selector.
*
- *
- * @return array $_columnHeaders
- * @access private
+ * @return array
*/
private static function &_getColumnHeaders() {
if (!isset(self::$_columnHeaders)) {
/**
* @return CRM_Contact_BAO_Query
*/
- function &getQuery() {
+ public function &getQuery() {
return $this->_query;
}
/**
* @return CRM_Contact_DAO_Contact
*/
- function alphabetQuery() {
+ public function alphabetQuery() {
return $this->_query->searchQuery(NULL, NULL, NULL, FALSE, FALSE, TRUE);
}
*
* @return CRM_Contact_DAO_Contact
*/
- function contactIDQuery($params, $action, $sortID, $displayRelationshipType = NULL, $queryOperator = 'AND') {
+ public function contactIDQuery($params, $action, $sortID, $displayRelationshipType = NULL, $queryOperator = 'AND') {
$sortOrder = &$this->getSortOrder($this->_action);
$sort = new CRM_Utils_Sort($sortOrder, $sortID);
*
* @return array
*/
- function &makeProperties(&$returnProperties) {
+ public function &makeProperties(&$returnProperties) {
$properties = array();
foreach ($returnProperties as $name => $value) {
if ($name != 'location') {
}
return $properties;
}
-}
+}