X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FContact%2FForm%2FSearch.php;h=7a0083b2f1209c69cbcea8df672b2b5b475c3de5;hb=ba0d74843bc8d374fea628929a5ceaa408b45956;hp=1f963e3b74fa85c056a6fc7a6c5e24e2975247b1;hpb=ac30252393b3b9d8162994f59bb63e2b89ddacdc;p=civicrm-core.git diff --git a/CRM/Contact/Form/Search.php b/CRM/Contact/Form/Search.php index 1f963e3b74..7a0083b2f1 100644 --- a/CRM/Contact/Form/Search.php +++ b/CRM/Contact/Form/Search.php @@ -59,14 +59,6 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search { */ static $_modeValues = NULL; - /** - * The context that we are working on - * - * @var string - * @access protected - */ - protected $_context; - /** * The contextMenu * @@ -100,30 +92,6 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search { */ protected $_ssID; - /** - * Are we forced to run a search - * - * @var int - * @access protected - */ - protected $_force; - - /** - * name of search button - * - * @var string - * @access protected - */ - protected $_searchButtonName; - - /** - * name of action button - * - * @var string - * @access protected - */ - protected $_actionButtonName; - /** * the group elements * @@ -143,14 +111,6 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search { public $_tag; public $_tagElement; - /** - * form values that we will be using - * - * @var array - * @access protected - */ - public $_formValues; - /** * The params used for search * @@ -206,14 +166,6 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search { protected $_modeValue; - /** - * have we already done this search - * - * @access protected - * @var boolean - */ - protected $_done; - /** * name of the selector to use */ @@ -245,6 +197,11 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search { return self::$_validContext; } + /** + * @param $context + * + * @return bool + */ static function isSearchContext($context) { $searchContext = CRM_Utils_Array::value($context, self::validContext()); return $searchContext ? TRUE : FALSE; @@ -329,6 +286,11 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search { } } + /** + * @param int $mode + * + * @return mixed + */ static function getModeValue($mode = 1) { self::setModeValues(); @@ -339,6 +301,9 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search { return self::$_modeValues[$mode]; } + /** + * @return array + */ static function getModeSelect() { self::setModeValues(); @@ -372,13 +337,14 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search { */ function buildQuickForm() { parent::buildQuickForm(); + $this->addClass('crm-ajax-selection-form'); CRM_Core_Resources::singleton() // jsTree is needed for tags popup ->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE) ->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header'); $permission = CRM_Core_Permission::getPermission(); // some tasks.. what do we want to do with the selected contacts ? - $tasks = array('' => ts('- actions -')); + $tasks = array(); if ($this->_componentMode == 1 || $this->_componentMode == 7) { $tasks += CRM_Contact_Task::permissionedTaskTitles($permission, CRM_Utils_Array::value('deleted_contacts', $this->_formValues) @@ -415,10 +381,9 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search { $url = CRM_Utils_System::makeURL('qfKey') . $formQFKey; CRM_Utils_System::redirect($url); } + $permissionForGroup = FALSE; if (!empty($this->_groupID)) { - $permissionForGroup = FALSE; - // check if user has permission to edit members of this group $permission = CRM_Contact_BAO_Group::checkPermission($this->_groupID); if ($permission && in_array(CRM_Core_Permission::EDIT, $permission)) { @@ -428,13 +393,10 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search { // check if _groupID exists, it might not if // we are displaying a hidden group if (!isset($this->_group[$this->_groupID])) { - $permissionForGroup = FALSE; $this->_group[$this->_groupID] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID, 'title'); } - $this->assign('permissionedForGroup', $permissionForGroup); - // set the group title $groupValues = array('id' => $this->_groupID, 'title' => $this->_group[$this->_groupID]); $this->assign_by_ref('group', $groupValues); @@ -464,7 +426,7 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search { 'group_contact_status', ts('Group Status') ); - $this->assign('permissionedForGroup', FALSE); + $this->assign('permissionedForGroup', $permissionForGroup); } // add the go button for the action form, note it is of type 'next' rather than of type 'submit' @@ -484,31 +446,19 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search { $this->assign_by_ref('group', $groupValues); $this->add('submit', $this->_actionButtonName, ts('Add Contacts to %1', array(1 => $this->_group[$this->_amtgID])), array( - 'class' => 'form-submit', - 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 1);", + 'class' => 'crm-form-submit', ) ); $this->add('hidden', 'task', CRM_Contact_Task::GROUP_CONTACTS); + $selectedRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_sel', array('checked' => 'checked')); + $allRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_all'); + $this->assign('ts_sel_id', $selectedRowsRadio->_attributes['id']); + $this->assign('ts_all_id', $allRowsRadio->_attributes['id']); } else { - $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, 1);", - ) - ); + $this->addTaskMenu($tasks); } - // need to perform tasks on all or selected items ? using radio_ts(task selection) for it - $selectedRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_sel', array( - 'checked' => 'checked', - 'onclick' => 'toggleTaskAction( true );', - )); - $this->assign('ts_sel_id', $selectedRowsRadio->_attributes['id']); - - if ($qfKeyParam = CRM_Utils_Array::value('qfKey', $this->_formValues)) { $qfKeyParam = "civicrm search {$qfKeyParam}"; $selectedContactIdsArr = CRM_Core_BAO_PrevNextCache::getSelection($qfKeyParam); @@ -517,31 +467,10 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search { $this->assign_by_ref('selectedContactIds', $selectedContactIds); - $allRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_all', array('class' => 'select-rows', 'onclick' => $this->getName() . ".toggleSelect.checked = false; toggleTaskAction( true );toggleContactSelection( 'resetSel', '{$qfKeyParam}', 'reset' );")); - $this->assign('ts_all_id', $allRowsRadio->_attributes['id']); - - /* - * 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)) { - $this->addElement('checkbox', 'toggleSelect', NULL, NULL, array('class' => 'select-rows', 'onclick' => "toggleTaskAction( true ); toggleContactSelection( 'toggleSelect', '" . $qfKeyParam . "' , 'multiple' );")); - - $unselectedContactIds = array(); - foreach ($rows as $row) { - $this->addElement('checkbox', $row['checkbox'], - NULL, NULL, - array('onclick' => "toggleContactSelection( '" . $row['checkbox'] . "', '" . $qfKeyParam . "' , 'single' );toggleTaskAction( true );", 'class' => 'select-row') - ); - - if (!in_array($row['contact_id'], $selectedContactIds)) { - $unselectedContactIds[] = $row['contact_id']; - } - } - $this->assign_by_ref('unselectedContactIds', $unselectedContactIds); + $this->addRowSelectors($rows); } } @@ -795,6 +724,9 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search { $controller->moveFromSessionToTemplate(); } + /** + * @return array + */ function &getFormValues() { return $this->_formValues; } @@ -931,6 +863,9 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search { } } + /** + * @return null + */ function &returnProperties() { return CRM_Core_DAO::$_nullObject; }