/**
* Builds the list of tasks or actions that a searcher can perform on a result set.
*
- * The result is passed to $this->addTaskList, which is responsible for building
- * the menu and adding it to the form.
- *
- * @access public
* @return array
*/
- public function buildTaskList() {
- $tasks = array();
- $permission = CRM_Core_Permission::getPermission();
+ function buildTaskList() {
+ if ($this->_context !== 'amtg') {
+ $permission = CRM_Core_Permission::getPermission();
- if ($this->_componentMode == 1 || $this->_componentMode == 7) {
- $tasks += CRM_Contact_Task::permissionedTaskTitles($permission,
- CRM_Utils_Array::value('deleted_contacts', $this->_formValues)
- );
- } else {
- $className = $this->_modeValue['taskClassName'];
- $tasks += $className::permissionedTaskTitles($permission, false);
- }
+ if ($this->_componentMode == 1 || $this->_componentMode == 7) {
+ $this->_taskList += CRM_Contact_Task::permissionedTaskTitles($permission,
+ CRM_Utils_Array::value('deleted_contacts', $this->_formValues)
+ );
+ } else {
+ $className = $this->_modeValue['taskClassName'];
+ $this->_taskList += $className::permissionedTaskTitles($permission, false);
+ }
- // Only offer the "Update Smart Group" task if a smart group/saved search is already in play
- if (isset($this->_ssID) && $permission == CRM_Core_Permission::EDIT) {
- $tasks = $tasks + CRM_Contact_Task::optionalTaskTitle();
+ // Only offer the "Update Smart Group" task if a smart group/saved search is already in play
+ if (isset($this->_ssID) && $permission == CRM_Core_Permission::EDIT) {
+ $this->_taskList += CRM_Contact_Task::optionalTaskTitle();
+ }
}
- return $tasks;
+ return $this->_taskList;
}
/**
$this->assign('ts_sel_id', $selectedRowsRadio->_attributes['id']);
$this->assign('ts_all_id', $allRowsRadio->_attributes['id']);
}
- else {
- $tasks = $this->buildTaskList();
- $this->addTaskMenu($tasks);
- }
$selectedContactIds = array();
$qfKeyParam = CRM_Utils_Array::value('qfKey', $this->_formValues);
return $this->_formValues;
}
+ /**
+ * Builds the list of tasks or actions that a searcher can perform on a result set.
+ *
+ * @return array
+ */
function buildTaskList() {
- if (method_exists($this->_customSearchClass, 'buildTaskList')) {
- return $this->_customClass->buildTaskList();
- }
- return parent::buildTaskList();
+ // call the parent method to populate $this->_taskList for the custom search
+ parent::buildTaskList();
+ return $this->_customClass->buildTaskList($this);
}
function buildQuickForm() {
$this->_formValues = &$formValues;
}
+ /**
+ * Builds the list of tasks or actions that a searcher can perform on a result set.
+ *
+ * The returned array completely replaces the task list, so a child class that
+ * wants to modify the existing list should manipulate the result of this method.
+ *
+ * @param CRM_Core_Form_Search $form
+ * @return array
+ */
+ function buildTaskList(CRM_Core_Form_Search $form) {
+ return $form->getVar('_taskList');
+ }
+
/**
* @return null|string
*/
*/
protected $_context = NULL;
+ /**
+ * The list of tasks or actions that a searcher can perform on a result set.
+ *
+ * @var array
+ */
+ protected $_taskList = array();
+
+ /**
+ * Builds the list of tasks or actions that a searcher can perform on a result set.
+ *
+ * To modify the task list, child classes should alter $this->_taskList,
+ * preferably by extending this method.
+ *
+ * @return array
+ */
+ protected function buildTaskList() {
+ return $this->_taskList;
+ }
+
/**
* Common buildform tasks required by all searches
*/
));
$this->addClass('crm-search-form');
+
+ // for backwards compatibility we pass an argument to addTaskMenu even though
+ // it could just as well access $this->_taskList internally
+ $tasks = $this->buildTaskList();
+ $this->addTaskMenu($tasks);
}
/**