Beispiel #1
0
 /**
  * These tasks are the core set of tasks that the user can perform
  * on a voter / group of voters
  *
  * @return array the set of tasks for a group of voters.
  * @static
  * @access public
  */
 static function &tasks()
 {
     if (!self::$_tasks) {
         self::$_tasks = array(1 => array('title' => ts('Record Respondents Interview'), 'class' => array('CRM_Campaign_Form_Task_Interview', 'CRM_Campaign_Form_Task_Release'), 'result' => FALSE), 2 => array('title' => ts('Reserve Respondents'), 'class' => array('CRM_Campaign_Form_Task_Reserve', 'CRM_Campaign_Form_Task_Interview', 'CRM_Campaign_Form_Task_Release'), 'result' => FALSE), 3 => array('title' => ts('Release Respondents'), 'class' => 'CRM_Campaign_Form_Task_Release', 'result' => FALSE), 4 => array('title' => ts('Print Respondents'), 'class' => 'CRM_Campaign_Form_Task_Print', 'result' => FALSE));
     }
     CRM_Utils_Hook::searchTasks('campaign', self::$_tasks);
     asort(self::$_tasks);
     return self::$_tasks;
 }
 /**
  * Determine the form name based on the action. This allows us
  * to avoid using  conditional state machine, much more efficient
  * and simpler
  *
  * @param CRM_Core_Controller $controller the controller object
  *
  * @return string the name of the form that will handle the task
  * @access protected
  */
 function taskName($controller, $formName = 'Search')
 {
     // total hack, check POST vars and then session to determine stuff
     $value = CRM_Utils_Array::value('task', $_POST);
     if (!isset($value)) {
         $value = $this->_controller->get('task');
     }
     $this->_controller->set('task', $value);
     return CRM_Campaign_Task::getTask($value);
 }
Beispiel #3
0
 /**
  * build all the data structures needed to build the form
  *
  * @param
  * @return void
  * @access public
  */
 function preProcess()
 {
     $values = $this->controller->exportValues('Search');
     $this->_task = $values['task'];
     $campaignTasks = CRM_Campaign_Task::tasks();
     $taskName = CRM_Utils_Array::value($this->_task, $campaignTasks);
     $this->assign('taskName', $taskName);
     $ids = array();
     if ($values['radio_ts'] == 'ts_sel') {
         foreach ($values as $name => $value) {
             if (substr($name, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX) {
                 $ids[] = substr($name, CRM_Core_Form::CB_PREFIX_LEN);
             }
         }
     } else {
         $queryParams = $this->get('queryParams');
         $query = new CRM_Contact_BAO_Query($queryParams, null, null, false, false, CRM_Contact_BAO_Query::MODE_CAMPAIGN);
         $result = $query->searchQuery(0, 0, null);
         while ($result->fetch()) {
             $ids[] = $result->contact_id;
         }
         $this->assign('totalSelectedVoters', $this->get('rowCount'));
     }
     if (!empty($ids)) {
         $this->_componentClause = 'contact_a.id IN ( ' . implode(',', $ids) . ' ) ';
         $this->assign('totalSelectedVoters', count($ids));
     }
     $this->_voterIds = $this->_contactIds = $this->_componentIds = $ids;
     $this->assign('totalSelectedContacts', count($this->_contactIds));
     //set the context for redirection for any task actions
     $session = CRM_Core_Session::singleton();
     require_once 'CRM/Utils/Rule.php';
     $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this);
     $urlParams = 'force=1';
     if (CRM_Utils_Rule::qfKey($qfKey)) {
         $urlParams .= '&qfKey=' . $qfKey;
     }
     $session->replaceUserContext(CRM_Utils_System::url('civicrm/survey/search', $urlParams));
 }
Beispiel #4
0
 /**
  * Build all the data structures needed to build the form.
  */
 public function preProcess()
 {
     $values = $this->controller->exportValues('Search');
     $this->_task = $values['task'];
     $campaignTasks = CRM_Campaign_Task::tasks();
     $taskName = CRM_Utils_Array::value($this->_task, $campaignTasks);
     $this->assign('taskName', $taskName);
     $ids = array();
     if ($values['radio_ts'] == 'ts_sel') {
         foreach ($values as $name => $value) {
             if (substr($name, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX) {
                 $ids[] = substr($name, CRM_Core_Form::CB_PREFIX_LEN);
             }
         }
     } else {
         $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this);
         $cacheKey = "civicrm search {$qfKey}";
         $allCids = CRM_Core_BAO_PrevNextCache::getSelection($cacheKey, "getall");
         $ids = array_keys($allCids[$cacheKey]);
         $this->assign('totalSelectedVoters', count($ids));
     }
     if (!empty($ids)) {
         $this->_componentClause = 'contact_a.id IN ( ' . implode(',', $ids) . ' ) ';
         $this->assign('totalSelectedVoters', count($ids));
     }
     $this->_voterIds = $this->_contactIds = $this->_componentIds = $ids;
     $this->assign('totalSelectedContacts', count($this->_contactIds));
     //set the context for redirection for any task actions
     $session = CRM_Core_Session::singleton();
     $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this);
     $urlParams = 'force=1';
     if (CRM_Utils_Rule::qfKey($qfKey)) {
         $urlParams .= '&qfKey=' . $qfKey;
     }
     $session->replaceUserContext(CRM_Utils_System::url('civicrm/survey/search', $urlParams));
 }
Beispiel #5
0
 /**
  * Determine the form name based on the action. This allows us
  * to avoid using  conditional state machine, much more efficient
  * and simpler
  *
  * @param CRM_Core_Controller $controller the controller object
  *
  * @return string the name of the form that will handle the task
  * @access protected
  */
 function taskName($controller, $formName = 'Search')
 {
     // total hack, check POST vars and then session to determine stuff
     // fix value if print button is pressed
     if (CRM_Utils_Array::value('_qf_' . $formName . '_next_print', $_POST)) {
         $value = CRM_Campaign_Task::PRINT_VOTERS;
     } else {
         $value = CRM_Utils_Array::value('task', $_POST);
     }
     if (!isset($value)) {
         $value = $this->_controller->get('task');
     }
     $this->_controller->set('task', $value);
     return CRM_Campaign_Task::getTask($value);
 }
Beispiel #6
0
 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     parent::buildQuickForm();
     //build the search form.
     CRM_Campaign_BAO_Query::buildSearchForm($this);
     $rows = $this->get('rows');
     if (is_array($rows)) {
         if (!$this->_single) {
             $this->addRowSelectors($rows);
         }
         $permission = CRM_Core_Permission::getPermission();
         $allTasks = CRM_Campaign_Task::permissionedTaskTitles($permission);
         //hack to serve right page to state machine.
         $taskMapping = array('interview' => 1, 'reserve' => 2, 'release' => 3);
         $currentTaskValue = CRM_Utils_Array::value($this->_operation, $taskMapping);
         $taskValue = array($currentTaskValue => $allTasks[$currentTaskValue]);
         if ($this->_operation == 'interview' && !empty($this->_formValues['campaign_survey_id'])) {
             $activityTypes = CRM_Core_PseudoConstant::activityType(FALSE, TRUE, FALSE, 'label', TRUE);
             $surveyTypeId = CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $this->_formValues['campaign_survey_id'], 'activity_type_id');
             $taskValue = array($currentTaskValue => ts('Record %1 Responses', array(1 => $activityTypes[$surveyTypeId])));
         }
         $this->addTaskMenu($taskValue);
     }
 }
 /**
  * Build the form
  *
  * @access public
  *
  * @return void
  */
 function buildQuickForm()
 {
     //build the search form.
     CRM_Campaign_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)) {
         CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.searchForm.js');
         if (!$this->_single) {
             $this->addElement('checkbox', 'toggleSelect', NULL, NULL, array('onclick' => "toggleTaskAction( true );", 'class' => 'select-rows'));
             foreach ($rows as $row) {
                 $this->addElement('checkbox', $row['checkbox'], NULL, NULL, array('onclick' => "toggleTaskAction( true );", 'class' => 'select-row'));
             }
         }
         $total = $cancel = 0;
         $permission = CRM_Core_Permission::getPermission();
         $allTasks = CRM_Campaign_Task::permissionedTaskTitles($permission);
         //hack to serve right page to state machine.
         $taskMapping = array('interview' => 1, 'reserve' => 2, 'release' => 3);
         $currentTaskValue = CRM_Utils_Array::value($this->_operation, $taskMapping);
         $taskValue = array($currentTaskValue => $allTasks[$currentTaskValue]);
         if ($this->_operation == 'interview' && !empty($this->_formValues['campaign_survey_id'])) {
             $activityTypes = CRM_Core_PseudoConstant::activityType(FALSE, TRUE, FALSE, 'label', TRUE);
             $surveyTypeId = CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $this->_formValues['campaign_survey_id'], 'activity_type_id');
             $taskValue = array($currentTaskValue => ts('Record %1 Responses', array(1 => $activityTypes[$surveyTypeId])));
         }
         $this->add('select', 'task', ts('Actions:') . ' ', array('' => ts('- actions -')) + $taskValue);
         $this->add('submit', $this->_actionButtonName, ts('Go'), array('class' => 'form-submit', 'id' => 'Go'));
         // 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('class' => 'select-rows', 'onclick' => $this->getName() . ".toggleSelect.checked = false; toggleTaskAction( true );"));
     }
     // add buttons
     $this->addButtons(array(array('type' => 'refresh', 'name' => ts('Search'), 'isDefault' => TRUE)));
 }
Beispiel #8
0
 /**
  * Build the form
  *
  * @access public
  * @return void
  */
 function buildQuickForm()
 {
     //build the search form.
     require_once 'CRM/Campaign/BAO/Query.php';
     CRM_Campaign_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'] . "', '" . $this->getName() . "');"));
             }
         }
         $total = $cancel = 0;
         require_once "CRM/Core/Permission.php";
         $permission = CRM_Core_Permission::getPermission();
         require_once 'CRM/Campaign/Task.php';
         $allTasks = CRM_Campaign_Task::permissionedTaskTitles($permission);
         //hack to serve right page to state machine.
         $taskMapping = array('interview' => 1, 'reserve' => 2, 'release' => 3);
         $currentTaskValue = CRM_Utils_Array::value($this->_operation, $taskMapping);
         $taskValue = array($currentTaskValue => $allTasks[$currentTaskValue]);
         if ($this->_operation == 'interview' && CRM_Utils_Array::value('campaign_survey_id', $this->_formValues)) {
             require_once 'CRM/Core/PseudoConstant.php';
             $activityTypes = CRM_Core_PseudoConstant::activityType(false, true, false, 'label', true);
             $surveyTypeId = CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $this->_formValues['campaign_survey_id'], 'activity_type_id');
             $taskValue = array($currentTaskValue => ts('Record %1 Responses', array(1 => $activityTypes[$surveyTypeId])));
         }
         $this->add('select', 'task', ts('Actions:') . ' ', $taskValue);
         $this->setDefaults(array('task' => $currentTaskValue));
         $this->add('submit', $this->_actionButtonName, ts('Go'), array('class' => 'form-submit', 'id' => 'Go'));
         $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('onclick' => $this->getName() . ".toggleSelect.checked = false; toggleCheckboxVals('mark_x_',this); toggleTaskAction( true );"));
     }
     // add buttons
     $this->addButtons(array(array('type' => 'refresh', 'name' => ts('Search'), 'isDefault' => true)));
 }