Ejemplo n.º 1
0
 /**
  * Build the common elements between the search/advanced form.
  */
 public function buildQuickForm()
 {
     parent::buildQuickForm();
     CRM_Core_Resources::singleton()->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();
     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 (isset($this->_ssID)) {
         if ($permission == CRM_Core_Permission::EDIT) {
             $tasks = $tasks + CRM_Contact_Task::optionalTaskTitle();
         }
         $search_custom_id = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_ssID, 'search_custom_id');
         $savedSearchValues = array('id' => $this->_ssID, 'name' => CRM_Contact_BAO_SavedSearch::getName($this->_ssID, 'title'), 'search_custom_id' => $search_custom_id);
         $this->assign_by_ref('savedSearch', $savedSearchValues);
         $this->assign('ssID', $this->_ssID);
     }
     if ($this->_context === 'smog') {
         // CRM-11788, we might want to do this for all of search where force=1
         $formQFKey = CRM_Utils_Array::value('qfKey', $this->_formValues);
         $getQFKey = CRM_Utils_Array::value('qfKey', $_GET);
         $postQFKey = CRM_Utils_Array::value('qfKey', $_POST);
         if ($formQFKey && empty($getQFKey) && empty($postQFKey)) {
             $url = CRM_Utils_System::makeURL('qfKey') . $formQFKey;
             CRM_Utils_System::redirect($url);
         }
         $permissionForGroup = FALSE;
         if (!empty($this->_groupID)) {
             // 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)) {
                 $permissionForGroup = TRUE;
             }
             // check if _groupID exists, it might not if
             // we are displaying a hidden group
             if (!isset($this->_group[$this->_groupID])) {
                 $this->_group[$this->_groupID] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID, 'title');
             }
             // set the group title
             $groupValues = array('id' => $this->_groupID, 'title' => $this->_group[$this->_groupID]);
             $this->assign_by_ref('group', $groupValues);
             // also set ssID if this is a saved search
             $ssID = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID, 'saved_search_id');
             $this->assign('ssID', $ssID);
             //get the saved search mapping id
             if ($ssID) {
                 $this->_ssID = $ssID;
                 $ssMappingId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $ssID, 'mapping_id');
                 $this->assign('ssMappingID', $ssMappingId);
             }
             // Set dynamic page title for 'Show Members of Group'
             CRM_Utils_System::setTitle(ts('Contacts in Group: %1', array(1 => $this->_group[$this->_groupID])));
         }
         $group_contact_status = array();
         foreach (CRM_Core_SelectValues::groupContactStatus() as $k => $v) {
             if (!empty($k)) {
                 $group_contact_status[] = $this->createElement('checkbox', $k, NULL, $v);
             }
         }
         $this->addGroup($group_contact_status, 'group_contact_status', ts('Group Status'));
         $this->assign('permissionedForGroup', $permissionForGroup);
     }
     // add the go button for the action form, note it is of type 'next' rather than of type 'submit'
     if ($this->_context === 'amtg') {
         // check if _groupID exists, it might not if
         // we are displaying a hidden group
         if (!isset($this->_group[$this->_amtgID])) {
             $this->assign('permissionedForGroup', FALSE);
             $this->_group[$this->_amtgID] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $this->_amtgID, 'title');
         }
         // Set dynamic page title for 'Add Members Group'
         CRM_Utils_System::setTitle(ts('Add to Group: %1', array(1 => $this->_group[$this->_amtgID])));
         // also set the group title and freeze the action task with Add Members to Group
         $groupValues = array('id' => $this->_amtgID, 'title' => $this->_group[$this->_amtgID]);
         $this->assign_by_ref('group', $groupValues);
         $this->add('submit', $this->_actionButtonName, ts('Add Contacts to %1', array(1 => $this->_group[$this->_amtgID])), array('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']);
     }
     $selectedContactIds = array();
     $qfKeyParam = CRM_Utils_Array::value('qfKey', $this->_formValues);
     // We use ajax to handle selections only if the search results component_mode is set to "contacts"
     if ($qfKeyParam && ($this->get('component_mode') <= 1 || $this->get('component_mode') == 7)) {
         $this->addClass('crm-ajax-selection-form');
         $qfKeyParam = "civicrm search {$qfKeyParam}";
         $selectedContactIdsArr = CRM_Core_BAO_PrevNextCache::getSelection($qfKeyParam);
         $selectedContactIds = array_keys($selectedContactIdsArr[$qfKeyParam]);
     }
     $this->assign_by_ref('selectedContactIds', $selectedContactIds);
     $rows = $this->get('rows');
     if (is_array($rows)) {
         $this->addRowSelectors($rows);
     }
 }
Ejemplo n.º 2
0
 /**
  * Build the common elements between the search/advanced form
  *
  * @access public
  *
  * @return void
  */
 function buildQuickForm()
 {
     $permission = CRM_Core_Permission::getPermission();
     // some tasks.. what do we want to do with the selected contacts ?
     $tasks = array('' => ts('- actions -'));
     if ($this->_componentMode == 1 || $this->_componentMode == 7) {
         $tasks += CRM_Contact_Task::permissionedTaskTitles($permission, CRM_Utils_Array::value('deleted_contacts', $this->_formValues));
     } else {
         require_once str_replace('_', DIRECTORY_SEPARATOR, $this->_modeValue['taskClassName']) . '.php';
         eval('$tasks += ' . $this->_modeValue['taskClassName'] . '::permissionedTaskTitles( $permission );');
     }
     if (isset($this->_ssID)) {
         if ($permission == CRM_Core_Permission::EDIT) {
             $tasks = $tasks + CRM_Contact_Task::optionalTaskTitle();
         }
         $search_custom_id = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_ssID, 'search_custom_id');
         $savedSearchValues = array('id' => $this->_ssID, 'name' => CRM_Contact_BAO_SavedSearch::getName($this->_ssID, 'title'), 'search_custom_id' => $search_custom_id);
         $this->assign_by_ref('savedSearch', $savedSearchValues);
         $this->assign('ssID', $this->_ssID);
     }
     if ($this->_context === 'smog') {
         if (!empty($this->_groupID)) {
             // set the group title
             $groupValues = array('id' => $this->_groupID, 'title' => $this->_group[$this->_groupID]);
             $this->assign_by_ref('group', $groupValues);
             // also set ssID if this is a saved search
             $ssID = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID, 'saved_search_id');
             $this->assign('ssID', $ssID);
             //get the saved search mapping id
             if ($ssID) {
                 $this->_ssID = $ssID;
                 $ssMappingId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $ssID, 'mapping_id');
                 $this->assign('ssMappingID', $ssMappingId);
             }
         }
         $group_contact_status = array();
         foreach (CRM_Core_SelectValues::groupContactStatus() as $k => $v) {
             if (!empty($k)) {
                 $group_contact_status[] = $this->createElement('checkbox', $k, NULL, $v);
             }
         }
         $this->addGroup($group_contact_status, 'group_contact_status', ts('Group Status'));
         $this->assign('permissionedForGroup', FALSE);
         if (!empty($this->_groupID)) {
             // Set dynamic page title for 'Show Members of Group'
             CRM_Utils_System::setTitle(ts('Contacts in Group: %1', array(1 => $this->_group[$this->_groupID])));
             // check if user has permission to edit members of this group
             $permission = CRM_Contact_BAO_Group::checkPermission($this->_groupID, $this->_group[$this->_groupID]);
             if ($permission && in_array(CRM_Core_Permission::EDIT, $permission)) {
                 $this->assign('permissionedForGroup', TRUE);
             }
         }
     }
     // add the go button for the action form, note it is of type 'next' rather than of type 'submit'
     if ($this->_context === 'amtg') {
         // Set dynamic page title for 'Add Members Group'
         CRM_Utils_System::setTitle(ts('Add to Group: %1', array(1 => $this->_group[$this->_amtgID])));
         // also set the group title and freeze the action task with Add Members to Group
         $groupValues = array('id' => $this->_amtgID, 'title' => $this->_group[$this->_amtgID]);
         $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);"));
         $this->add('hidden', 'task', CRM_Contact_Task::GROUP_CONTACTS);
     } 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, " . (int) empty($this->_customSearchClass) . ");"));
     }
     // 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);
         $selectedContactIds = array_keys($selectedContactIdsArr[$qfKeyParam]);
     }
     $this->assign_by_ref('selectedContactIds', $selectedContactIds);
     $allRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_all', array('onclick' => $this->getName() . ".toggleSelect.checked = false; toggleCheckboxVals('mark_x_', this);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('onclick' => "toggleTaskAction( true );  toggleCheckboxVals('mark_x_',this);return 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 ); return checkSelectedBox('" . $row['checkbox'] . "');"));
             if (!in_array($row['contact_id'], $selectedContactIds)) {
                 $unselectedContactIds[] = $row['contact_id'];
             }
         }
         $this->assign_by_ref('unselectedContactIds', $unselectedContactIds);
     }
     // add buttons
     $this->addButtons(array(array('type' => 'refresh', 'name' => ts('Search'), 'isDefault' => TRUE)));
     $this->add('submit', $this->_printButtonName, ts('Print'), array('class' => 'form-submit', 'id' => 'Print', 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 1, 1);"));
     $this->setDefaultAction('refresh');
 }
Ejemplo n.º 3
0
 /**
  * Build the common elements between the search/advanced form
  *
  * @access public
  * @return void
  */
 function buildQuickForm()
 {
     $permission = CRM_Core_Permission::getPermission();
     // some tasks.. what do we want to do with the selected contacts ?
     $tasks = array('' => ts('- more actions -')) + CRM_Contact_Task::permissionedTaskTitles($permission);
     if (isset($this->_ssID)) {
         if ($permission == CRM_Core_Permission::EDIT) {
             $tasks = $tasks + CRM_Contact_Task::optionalTaskTitle();
         }
         $savedSearchValues = array('id' => $this->_ssID, 'name' => CRM_Contact_BAO_SavedSearch::getName($this->_ssID, 'title'));
         $this->assign_by_ref('savedSearch', $savedSearchValues);
         $this->assign('ssID', $this->_ssID);
     }
     if ($this->_context === 'smog') {
         // need to figure out how to freeze a bunch of checkboxes, hack for now
         if ($this->_action != CRM_Core_Action::ADVANCED) {
             //Fix ME
             //$this->_groupElement->freeze( );
         }
         // also set the group title
         $groupValues = array('id' => $this->_groupID, 'title' => $this->_group[$this->_groupID]);
         $this->assign_by_ref('group', $groupValues);
         // also set ssID if this is a saved search
         $ssID = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID, 'saved_search_id');
         $this->assign('ssID', $ssID);
         //get the saved search mapping id
         if ($ssID) {
             $ssMappingId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $ssID, 'mapping_id');
         }
         if (isset($ssMappingId)) {
             $this->assign('ssMappingID', $ssMappingId);
         }
         $group_contact_status = array();
         foreach (CRM_Core_SelectValues::groupContactStatus() as $k => $v) {
             if (!empty($k)) {
                 $group_contact_status[] = HTML_QuickForm::createElement('checkbox', $k, null, $v);
             }
         }
         $this->addGroup($group_contact_status, 'group_contact_status', ts('Group Status'));
         /* 
          * commented out to fix CRM-4268
          *
          * $this->addGroupRule( 'group_contact_status',
          *                  ts( 'Please select at least Group Status value.' ), 'required', null, 1 );
          */
         // Set dynamic page title for 'Show Members of Group'
         CRM_Utils_System::setTitle(ts('Group Members: %1', array(1 => $this->_group[$this->_groupID])));
         // check if user has permission to edit members of this group
         require_once 'CRM/Contact/BAO/Group.php';
         $permission = CRM_Contact_BAO_Group::checkPermission($this->_groupID, $this->_group[$this->_groupID]);
         if ($permission && in_array(CRM_Core_Permission::EDIT, $permission)) {
             $this->assign('permissionedForGroup', true);
         } else {
             $this->assign('permissionedForGroup', false);
         }
     }
     /*
      * add the go button for the action form, note it is of type 'next' rather than of type 'submit'
      *
      */
     if ($this->_context === 'amtg') {
         // Set dynamic page title for 'Add Members Group'
         CRM_Utils_System::setTitle(ts('Add Members: %1', array(1 => $this->_group[$this->_amtgID])));
         // also set the group title and freeze the action task with Add Members to Group
         $groupValues = array('id' => $this->_amtgID, 'title' => $this->_group[$this->_amtgID]);
         $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);"));
         $this->add('hidden', 'task', CRM_Contact_Task::GROUP_CONTACTS);
     } 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);"));
     }
     // 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', 'onclick' => 'toggleTaskAction( true );'));
     $this->addElement('radio', 'radio_ts', null, '', 'ts_all', array('onclick' => $this->getName() . ".toggleSelect.checked = false; toggleCheckboxVals('mark_x_', this);toggleTaskAction( true );"));
     /*
      * 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('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'] . "', '" . $this->getName() . "');"));
         }
     }
     // add buttons
     $this->addButtons(array(array('type' => 'refresh', 'name' => ts('Search'), 'isDefault' => true)));
     $this->add('submit', $this->_printButtonName, ts('Print'), array('class' => 'form-submit', 'id' => 'Print', 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 1);"));
     $this->setDefaultAction('refresh');
 }
Ejemplo n.º 4
0
 /**
  * Build the common elements between the search/advanced form
  *
  * @access public
  *
  * @return void
  */
 function buildQuickForm()
 {
     CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.searchForm.js')->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 -'));
     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 (isset($this->_ssID)) {
         if ($permission == CRM_Core_Permission::EDIT) {
             $tasks = $tasks + CRM_Contact_Task::optionalTaskTitle();
         }
         $search_custom_id = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_ssID, 'search_custom_id');
         $savedSearchValues = array('id' => $this->_ssID, 'name' => CRM_Contact_BAO_SavedSearch::getName($this->_ssID, 'title'), 'search_custom_id' => $search_custom_id);
         $this->assign_by_ref('savedSearch', $savedSearchValues);
         $this->assign('ssID', $this->_ssID);
     }
     if ($this->_context === 'smog') {
         // CRM-11788, we might want to do this for all of search where force=1
         $formQFKey = CRM_Utils_Array::value('qfKey', $this->_formValues);
         $getQFKey = CRM_Utils_Array::value('qfKey', $_GET);
         $postQFKey = CRM_Utils_Array::value('qfKey', $_POST);
         if ($formQFKey && empty($getQFKey) && empty($postQFKey)) {
             $url = CRM_Utils_System::makeURL('qfKey') . $formQFKey;
             CRM_Utils_System::redirect($url);
         }
         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)) {
                 $permissionForGroup = TRUE;
             }
             // 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);
             // also set ssID if this is a saved search
             $ssID = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID, 'saved_search_id');
             $this->assign('ssID', $ssID);
             //get the saved search mapping id
             if ($ssID) {
                 $this->_ssID = $ssID;
                 $ssMappingId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $ssID, 'mapping_id');
                 $this->assign('ssMappingID', $ssMappingId);
             }
             // Set dynamic page title for 'Show Members of Group'
             CRM_Utils_System::setTitle(ts('Contacts in Group: %1', array(1 => $this->_group[$this->_groupID])));
         }
         $group_contact_status = array();
         foreach (CRM_Core_SelectValues::groupContactStatus() as $k => $v) {
             if (!empty($k)) {
                 $group_contact_status[] = $this->createElement('checkbox', $k, NULL, $v);
             }
         }
         $this->addGroup($group_contact_status, 'group_contact_status', ts('Group Status'));
         $this->assign('permissionedForGroup', FALSE);
     }
     // add the go button for the action form, note it is of type 'next' rather than of type 'submit'
     if ($this->_context === 'amtg') {
         // check if _groupID exists, it might not if
         // we are displaying a hidden group
         if (!isset($this->_group[$this->_amtgID])) {
             $this->assign('permissionedForGroup', FALSE);
             $this->_group[$this->_amtgID] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $this->_amtgID, 'title');
         }
         // Set dynamic page title for 'Add Members Group'
         CRM_Utils_System::setTitle(ts('Add to Group: %1', array(1 => $this->_group[$this->_amtgID])));
         // also set the group title and freeze the action task with Add Members to Group
         $groupValues = array('id' => $this->_amtgID, 'title' => $this->_group[$this->_amtgID]);
         $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);"));
         $this->add('hidden', 'task', CRM_Contact_Task::GROUP_CONTACTS);
     } 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);"));
     }
     // 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);
         $selectedContactIds = array_keys($selectedContactIdsArr[$qfKeyParam]);
     }
     $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);
     }
     // add buttons
     $this->addButtons(array(array('type' => 'refresh', 'name' => ts('Search'), 'isDefault' => TRUE)));
     $this->setDefaultAction('refresh');
 }