Example #1
0
 /**
  * build all the data structures needed to build the form
  *
  * @param
  * @return void
  * @access public
  */
 function preProcess()
 {
     $this->_participantIds = array();
     $values = $this->controller->exportValues('Search');
     $this->_task = $values['task'];
     $eventTasks = CRM_Event_Task::tasks();
     $this->assign('taskName', $eventTasks[$this->_task]);
     $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_EVENT);
         $result = $query->searchQuery(0, 0, null);
         while ($result->fetch()) {
             $ids[] = $result->participant_id;
         }
     }
     if (!empty($ids)) {
         $this->_componentClause = ' civicrm_participant.id IN ( ' . implode(',', $ids) . ' ) ';
         $this->assign('totalSelectedParticipants', count($ids));
     }
     $this->_participantIds = $this->_componentIds = $ids;
     //set the context for redirection for any task actions
     $session =& CRM_Core_Session::singleton();
     $session->replaceUserContext(CRM_Utils_System::url('civicrm/event/search', 'force=1'));
 }
Example #2
0
 /**
  * @param CRM_Core_Form $form
  * @param bool $useTable
  */
 public static function preProcessCommon(&$form, $useTable = FALSE)
 {
     $form->_participantIds = array();
     $values = $form->controller->exportValues($form->get('searchFormName'));
     $form->_task = $values['task'];
     $eventTasks = CRM_Event_Task::tasks();
     $form->assign('taskName', $eventTasks[$form->_task]);
     $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 = $form->get('queryParams');
         $sortOrder = NULL;
         if ($form->get(CRM_Utils_Sort::SORT_ORDER)) {
             $sortOrder = $form->get(CRM_Utils_Sort::SORT_ORDER);
         }
         $query = new CRM_Contact_BAO_Query($queryParams, NULL, NULL, FALSE, FALSE, CRM_Contact_BAO_Query::MODE_EVENT);
         $query->_distinctComponentClause = "civicrm_participant.id";
         $query->_groupByComponentClause = " GROUP BY civicrm_participant.id ";
         $result = $query->searchQuery(0, 0, $sortOrder);
         while ($result->fetch()) {
             $ids[] = $result->participant_id;
         }
     }
     if (!empty($ids)) {
         $form->_componentClause = ' civicrm_participant.id IN ( ' . implode(',', $ids) . ' ) ';
         $form->assign('totalSelectedParticipants', count($ids));
     }
     $form->_participantIds = $form->_componentIds = $ids;
     //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}";
     }
     $searchFormName = strtolower($form->get('searchFormName'));
     if ($searchFormName == 'search') {
         $session->replaceUserContext(CRM_Utils_System::url('civicrm/event/search', $urlParams));
     } else {
         $session->replaceUserContext(CRM_Utils_System::url("civicrm/contact/search/{$searchFormName}", $urlParams));
     }
 }