/** * Class constructor. * * @param array $queryParams * Array of parameters for query. * @param \const|int $action - action of search basic or advanced. * @param string $activityClause * If the caller wants to further restrict the search (used in activities). * @param bool $single * Are we dealing only with one contact?. * @param int $limit * How many activities do we want returned. * * @param string $context * @param null $compContext * * @return \CRM_Activity_Selector_Search */ public function __construct(&$queryParams, $action = CRM_Core_Action::NONE, $activityClause = NULL, $single = FALSE, $limit = NULL, $context = 'search', $compContext = NULL) { // submitted form values $this->_queryParams =& $queryParams; $this->_single = $single; $this->_limit = $limit; $this->_context = $context; $this->_compContext = $compContext; $this->_activityClause = $activityClause; // CRM-12675 $components = CRM_Core_Component::getNames(); $componentClause = array(); foreach ($components as $componentID => $componentName) { if (!CRM_Core_Permission::check("access {$componentName}")) { $componentClause[] = " (activity_type.component_id IS NULL OR activity_type.component_id <> {$componentID}) "; } } if (!empty($componentClause)) { $componentRestriction = implode(' AND ', $componentClause); if (empty($this->_activityClause)) { $this->_activityClause = $componentRestriction; } else { $this->_activityClause .= ' AND ' . $componentRestriction; } } // type of selector $this->_action = $action; $this->_query = new CRM_Contact_BAO_Query($this->_queryParams, CRM_Activity_BAO_Query::defaultReturnProperties(CRM_Contact_BAO_Query::MODE_ACTIVITY, FALSE), NULL, FALSE, FALSE, CRM_Contact_BAO_Query::MODE_ACTIVITY); $this->_query->_distinctComponentClause = '( civicrm_activity.id )'; $this->_query->_groupByComponentClause = " GROUP BY civicrm_activity.id "; }
/** * Build the form object. */ public function buildQuickForm() { parent::buildQuickForm(); $this->addElement('text', 'sort_name', ts('Name or Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')); CRM_Activity_BAO_Query::buildSearchForm($this); $rows = $this->get('rows'); if (is_array($rows)) { if (!$this->_single) { $this->addRowSelectors($rows); } $permission = CRM_Core_Permission::getPermission(); $this->addTaskMenu(CRM_Activity_Task::permissionedTaskTitles($permission)); } }
/** * default set of return properties * * @return void * @access public */ static function &defaultReturnProperties($mode = 1) { if (!isset(self::$_defaultReturnProperties)) { self::$_defaultReturnProperties = array(); } if (!isset(self::$_defaultReturnProperties[$mode])) { // add activity return properties if ($mode & CRM_Contact_BAO_Query::MODE_ACTIVITY) { self::$_defaultReturnProperties[$mode] = CRM_Activity_BAO_Query::defaultReturnProperties($mode, FALSE); } else { self::$_defaultReturnProperties[$mode] = CRM_Core_Component::defaultReturnProperties($mode, FALSE); } if (empty(self::$_defaultReturnProperties[$mode])) { self::$_defaultReturnProperties[$mode] = array('home_URL' => 1, 'image_URL' => 1, 'legal_identifier' => 1, 'external_identifier' => 1, 'contact_type' => 1, 'contact_sub_type' => 1, 'sort_name' => 1, 'display_name' => 1, 'preferred_mail_format' => 1, 'nick_name' => 1, 'first_name' => 1, 'middle_name' => 1, 'last_name' => 1, 'individual_prefix' => 1, 'individual_suffix' => 1, 'birth_date' => 1, 'gender' => 1, 'street_address' => 1, 'supplemental_address_1' => 1, 'supplemental_address_2' => 1, 'city' => 1, 'postal_code' => 1, 'postal_code_suffix' => 1, 'state_province' => 1, 'country' => 1, 'world_region' => 1, 'geo_code_1' => 1, 'geo_code_2' => 1, 'email' => 1, 'on_hold' => 1, 'phone' => 1, 'im' => 1, 'household_name' => 1, 'organization_name' => 1, 'deceased_date' => 1, 'is_deceased' => 1, 'job_title' => 1, 'legal_name' => 1, 'sic_code' => 1, 'current_employer' => 1, 'do_not_email' => 1, 'do_not_mail' => 1, 'do_not_sms' => 1, 'do_not_phone' => 1, 'do_not_trade' => 1, 'is_opt_out' => 1, 'contact_is_deleted' => 1); } } return self::$_defaultReturnProperties[$mode]; }
/** * @param CRM_Core_Form $form */ public static function activity(&$form) { $form->add('hidden', 'hidden_activity', 1); CRM_Activity_BAO_Query::buildSearchForm($form); }
/** * Class constructor. * * @param array $queryParams * Array of parameters for query. * @param \const|int $action - action of search basic or advanced. * @param string $activityClause * If the caller wants to further restrict the search (used in activities). * @param bool $single * Are we dealing only with one contact?. * @param int $limit * How many activities do we want returned. * * @param string $context * @param null $compContext * * @return \CRM_Activity_Selector_Search */ public function __construct(&$queryParams, $action = CRM_Core_Action::NONE, $activityClause = NULL, $single = FALSE, $limit = NULL, $context = 'search', $compContext = NULL) { // submitted form values $this->_queryParams =& $queryParams; $this->_single = $single; $this->_limit = $limit; $this->_context = $context; $this->_compContext = $compContext; $this->_activityClause = $activityClause; // CRM-12675 $components = CRM_Core_Component::getNames(); $componentClause = array(); foreach ($components as $componentID => $componentName) { // CRM-19201: Add support for searching CiviCampaign and CiviCase // activities. For CiviCase, "access all cases and activities" is // required here rather than "access my cases and activities" to // prevent those with only the later permission from seeing a list // of all cases which might present a privacy issue. if (!CRM_Core_Permission::access($componentName, TRUE, TRUE)) { $componentClause[] = " (activity_type.component_id IS NULL OR activity_type.component_id <> {$componentID}) "; } } if (!empty($componentClause)) { $componentRestriction = implode(' AND ', $componentClause); if (empty($this->_activityClause)) { $this->_activityClause = $componentRestriction; } else { $this->_activityClause .= ' AND ' . $componentRestriction; } } // type of selector $this->_action = $action; $this->_query = new CRM_Contact_BAO_Query($this->_queryParams, CRM_Activity_BAO_Query::defaultReturnProperties(CRM_Contact_BAO_Query::MODE_ACTIVITY, FALSE), NULL, FALSE, FALSE, CRM_Contact_BAO_Query::MODE_ACTIVITY); $this->_query->_distinctComponentClause = '( civicrm_activity.id )'; $this->_query->_groupByComponentClause = " GROUP BY civicrm_activity.id "; }
/** * Build the form object. */ public function buildQuickForm() { parent::buildQuickForm(); $this->addSortNameField(); CRM_Activity_BAO_Query::buildSearchForm($this); $rows = $this->get('rows'); if (is_array($rows)) { if (!$this->_single) { $this->addRowSelectors($rows); } $permission = CRM_Core_Permission::getPermission(); $this->addTaskMenu(CRM_Activity_Task::permissionedTaskTitles($permission)); } }
/** * Class constructor * * @param array $queryParams array of parameters for query * @param int $action - action of search basic or advanced. * @param string $activityClause if the caller wants to further restrict the search (used in activities) * @param boolean $single are we dealing only with one contact? * @param int $limit how many activities do we want returned * * @return CRM_Contact_Selector * @access public */ function __construct(&$queryParams, $action = CRM_Core_Action::NONE, $activityClause = NULL, $single = FALSE, $limit = NULL, $context = 'search', $compContext = NULL) { // submitted form values $this->_queryParams =& $queryParams; $this->_single = $single; $this->_limit = $limit; $this->_context = $context; $this->_compContext = $compContext; $this->_activityClause = $activityClause; // type of selector $this->_action = $action; $this->_query = new CRM_Contact_BAO_Query($this->_queryParams, CRM_Activity_BAO_Query::defaultReturnProperties(CRM_Contact_BAO_Query::MODE_ACTIVITY, FALSE), NULL, FALSE, FALSE, CRM_Contact_BAO_Query::MODE_ACTIVITY); $this->_query->_distinctComponentClause = '( civicrm_activity.id )'; $this->_query->_groupByComponentClause = " GROUP BY civicrm_activity.id "; //CRM_Core_Error::debug( $this->_query ); exit(); }
/** * Given a list of conditions in params generate the required * where clause * * @return void * @access public */ function whereClause() { $this->_where[0] = array(); $this->_qill[0] = array(); $config =& CRM_Core_Config::singleton(); $this->includeContactIds(); if (!empty($this->_params)) { $activity = false; foreach (array_keys($this->_params) as $id) { // check for both id and contact_id if ($this->_params[$id][0] == 'id' || $this->_params[$id][0] == 'contact_id') { if ($this->_params[$id][1] == 'IS NULL' || $this->_params[$id][1] == 'IS NOT NULL') { $this->_where[0][] = "contact_a.id {$this->_params[$id][1]}"; } else { $this->_where[0][] = "contact_a.id {$this->_params[$id][1]} {$this->_params[$id][2]}"; } } else { $this->whereClauseSingle($this->_params[$id]); } if (substr($this->_params[$id][0], 0, 9) == 'activity_') { $activity = true; } } require_once 'CRM/Core/Component.php'; CRM_Core_Component::alterQuery($this, 'where'); if ($activity) { require_once 'CRM/Activity/BAO/Query.php'; CRM_Activity_BAO_Query::where($this); } } if ($this->_customQuery) { // Added following if condition to avoid the wrong value diplay for 'myaccount' / any UF info. // Hope it wont affect the other part of civicrm.. if it does please remove it. if (!empty($this->_customQuery->_where)) { $this->_where = CRM_Utils_Array::crmArrayMerge($this->_where, $this->_customQuery->_where); } $this->_qill = CRM_Utils_Array::crmArrayMerge($this->_qill, $this->_customQuery->_qill); } $clauses = array(); $andClauses = array(); $validClauses = 0; if (!empty($this->_where)) { foreach ($this->_where as $grouping => $values) { if ($grouping > 0 && !empty($values)) { $clauses[$grouping] = ' ( ' . implode(' AND ', $values) . ' ) '; $validClauses++; } } if (!empty($this->_where[0])) { $andClauses[] = ' ( ' . implode(' AND ', $this->_where[0]) . ' ) '; } if (!empty($clauses)) { $andClauses[] = ' ( ' . implode(' OR ', $clauses) . ' ) '; } if ($validClauses > 1) { $this->_useDistinct = true; } } return implode(' AND ', $andClauses); }
/** * Build the form * * @access public * * @return void */ function buildQuickForm() { $this->addElement('text', 'sort_name', ts('Name or Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')); CRM_Activity_BAO_Query::buildSearchForm($this); /* * add form checkboxes for each row. This is needed out here to conform to QF protocol * of all elements being declared in builQuickForm */ $rows = $this->get('rows'); if (is_array($rows)) { if (!$this->_single) { $this->addElement('checkbox', 'toggleSelect', NULL, NULL, array('onclick' => "toggleTaskAction( true ); return toggleCheckboxVals('mark_x_',this);")); foreach ($rows as $row) { $this->addElement('checkbox', $row['checkbox'], NULL, NULL, array('onclick' => "toggleTaskAction( true ); return checkSelectedBox('" . $row['checkbox'] . "');")); } } $permission = CRM_Core_Permission::getPermission(); $tasks = array('' => ts('- actions -')) + CRM_Activity_Task::permissionedTaskTitles($permission); $this->add('select', 'task', ts('Actions:') . ' ', $tasks); $this->add('submit', $this->_actionButtonName, ts('Go'), array('class' => 'form-submit', 'id' => 'Go', 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 0);")); $this->add('submit', $this->_printButtonName, ts('Print'), array('class' => 'form-submit', 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 1);")); // need to perform tasks on all or selected items ? using radio_ts(task selection) for it $this->addElement('radio', 'radio_ts', NULL, '', 'ts_sel', array('checked' => 'checked')); $this->addElement('radio', 'radio_ts', NULL, '', 'ts_all', array('onchange' => $this->getName() . ".toggleSelect.checked = false; toggleCheckboxVals('mark_x_',this); toggleTaskAction( true );")); } // add buttons $this->addButtons(array(array('type' => 'refresh', 'name' => ts('Search'), 'isDefault' => TRUE))); }
static function activity(&$form) { $form->add('hidden', 'hidden_activity', 1); require_once 'CRM/Activity/BAO/Query.php'; CRM_Activity_BAO_Query::buildSearchForm($form); }