Exemplo n.º 1
0
 public function preProcess()
 {
     require_once 'CRM/Campaign/BAO/Campaign.php';
     if (!CRM_Campaign_BAO_Campaign::accessCampaignDashboard()) {
         CRM_Utils_System::permissionDenied();
     }
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     if ($this->_context) {
         $this->assign('context', $this->_context);
     }
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this);
     if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::DELETE)) {
         $this->_surveyId = CRM_Utils_Request::retrieve('id', 'Positive', $this, true);
         if ($this->_action & CRM_Core_Action::UPDATE) {
             CRM_Utils_System::setTitle(ts('Edit Survey'));
         } else {
             CRM_Utils_System::setTitle(ts('Delete Survey'));
         }
     }
     $session = CRM_Core_Session::singleton();
     $url = CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=survey');
     $session->pushUserContext($url);
     if ($this->_name != 'Petition') {
         CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('Survey Dashboard'), 'url' => $url)));
     }
     $this->_values = array();
     if ($this->_surveyId) {
         $this->assign('surveyId', $this->_surveyId);
         $values = $this->get('values');
         // get contact values.
         if (!empty($values)) {
             $this->_values = $values;
         } else {
             $params = array('id' => $this->_surveyId);
             CRM_Campaign_BAO_Survey::retrieve($params, $this->_values, true);
             $this->set('values', $this->_values);
         }
     }
     $this->assign('action', $this->_action);
 }
Exemplo n.º 2
0
 public function preProcess()
 {
     require_once 'CRM/Campaign/BAO/Campaign.php';
     if (!CRM_Campaign_BAO_Campaign::accessCampaignDashboard()) {
         CRM_Utils_System::permissionDenied();
     }
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     if ($this->_context) {
         $this->assign('context', $this->_context);
     }
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this);
     if ($this->_action & (CRM_Core_Action::UPDATE | $this->_action & CRM_Core_Action::DELETE)) {
         $this->_campaignId = CRM_Utils_Request::retrieve('id', 'Positive', $this, true);
         if ($this->_action & CRM_Core_Action::UPDATE) {
             CRM_Utils_System::setTitle(ts('Edit Campaign'));
         } else {
             CRM_Utils_System::setTitle(ts('Delete Campaign'));
         }
     }
     $session = CRM_Core_Session::singleton();
     $session->pushUserContext(CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=campaign'));
     $this->assign('action', $this->_action);
 }
Exemplo n.º 3
0
 /** 
  * processing needed for buildForm and later 
  * 
  * @return void 
  * @access public 
  */
 function preProcess()
 {
     $this->_search = CRM_Utils_Array::value('search', $_GET);
     $this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', $this, false);
     $this->_surveyId = CRM_Utils_Request::retrieve('sid', 'Positive', $this);
     $this->_interviewerId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     //does control come from voting tab interface.
     $this->_votingTab = $this->get('votingTab');
     $this->_subVotingTab = $this->get('subVotingTab');
     $this->_searchVoterFor = 'gotv';
     if ($this->_votingTab) {
         if ($this->_subVotingTab == 'searchANDReserve') {
             $this->_searchVoterFor = 'reserve';
         } else {
             if ($this->_subVotingTab == 'searchANDInterview') {
                 $this->_searchVoterFor = 'interview';
             }
         }
     }
     $this->assign('force', $this->_force);
     $this->assign('votingTab', $this->_votingTab);
     $this->assign('searchParams', json_encode($this->get('searchParams')));
     $this->assign('buildSelector', $this->_search);
     $this->assign('searchVoterFor', $this->_searchVoterFor);
     $this->assign('doNotReloadCRMAccordion', $this->get('doNotReloadCRMAccordion'));
     $surveyTitle = null;
     if ($this->_surveyId) {
         $surveyTitle = CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $this->_surveyId, 'title');
     }
     $this->assign('surveyTitle', $surveyTitle);
     //append breadcrumb to survey dashboard.
     require_once 'CRM/Campaign/BAO/Campaign.php';
     if (CRM_Campaign_BAO_Campaign::accessCampaignDashboard()) {
         $url = CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=survey');
         CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('Survey(s)'), 'url' => $url)));
     }
     //set the form title.
     CRM_Utils_System::setTitle(ts('GOTV (Voter Tracking)'));
 }
Exemplo n.º 4
0
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     $this->_votingTab = $this->get('votingTab');
     $this->_reserveToInterview = $this->get('reserveToInterview');
     if ($this->_reserveToInterview || $this->_votingTab) {
         //user came from voting tab / reserve form.
         foreach (array('surveyId', 'contactIds', 'interviewerId') as $fld) {
             $this->{"_{$fld}"} = $this->get($fld);
         }
         //get the target voter ids.
         if ($this->_votingTab) {
             $this->getVoterIds();
         }
     } else {
         parent::preProcess();
         //get the survey id from user submitted values.
         $this->_surveyId = CRM_Utils_Array::value('campaign_survey_id', $this->get('formValues'));
         $this->_interviewerId = CRM_Utils_Array::value('survey_interviewer_id', $this->get('formValues'));
     }
     //get the contact read only fields to display.
     require_once 'CRM/Core/BAO/Preferences.php';
     $readOnlyFields = array_merge(array('contact_type' => '', 'sort_name' => ts('Name')));
     //get the read only field data.
     $returnProperties = array_fill_keys(array_keys($readOnlyFields), 1);
     $returnProperties['contact_sub_type'] = true;
     //get the profile id.
     require_once 'CRM/Core/BAO/UFJoin.php';
     $ufJoinParams = array('entity_id' => $this->_surveyId, 'entity_table' => 'civicrm_survey', 'module' => 'CiviCampaign');
     $this->_ufGroupId = CRM_Core_BAO_UFJoin::findUFGroupId($ufJoinParams);
     $this->assign('ufGroupId', $this->_ufGroupId);
     //validate all voters for required activity.
     //get the survey activities for given voters.
     require_once 'CRM/Campaign/BAO/Survey.php';
     $this->_surveyActivityIds = CRM_Campaign_BAO_Survey::voterActivityDetails($this->_surveyId, $this->_contactIds, $this->_interviewerId);
     require_once 'CRM/Core/PseudoConstant.php';
     $activityStatus = CRM_Core_PseudoConstant::activityStatus('name');
     $scheduledStatusId = array_search('Scheduled', $activityStatus);
     $activityIds = array();
     foreach ($this->_contactIds as $key => $voterId) {
         $actVals = CRM_Utils_Array::value($voterId, $this->_surveyActivityIds);
         $statusId = CRM_Utils_Array::value('status_id', $actVals);
         $activityId = CRM_Utils_Array::value('activity_id', $actVals);
         if ($activityId && $statusId && $scheduledStatusId == $statusId) {
             $activityIds["activity_id_{$voterId}"] = $activityId;
         } else {
             unset($this->_contactIds[$key]);
         }
     }
     //retrieve the contact details.
     $voterDetails = CRM_Campaign_BAO_Survey::voterDetails($this->_contactIds, $returnProperties);
     $this->_allowAjaxReleaseButton = false;
     if ($this->_votingTab && (CRM_Core_Permission::check('manage campaign') || CRM_Core_Permission::check('administer CiviCampaign') || CRM_Core_Permission::check('release campaign contacts'))) {
         $this->_allowAjaxReleaseButton = true;
     }
     $this->assign('votingTab', $this->_votingTab);
     $this->assign('componentIds', $this->_contactIds);
     $this->assign('voterDetails', $voterDetails);
     $this->assign('readOnlyFields', $readOnlyFields);
     $this->assign('interviewerId', $this->_interviewerId);
     $this->assign('surveyActivityIds', json_encode($activityIds));
     $this->assign('allowAjaxReleaseButton', $this->_allowAjaxReleaseButton);
     //get the survey values.
     $this->_surveyValues = $this->get('surveyValues');
     if (!is_array($this->_surveyValues)) {
         $this->_surveyValues = array();
         if ($this->_surveyId) {
             require_once 'CRM/Campaign/BAO/Survey.php';
             $surveyParams = array('id' => $this->_surveyId);
             CRM_Campaign_BAO_Survey::retrieve($surveyParams, $this->_surveyValues);
         }
         $this->set('surveyValues', $this->_surveyValues);
     }
     $this->assign('surveyValues', $this->_surveyValues);
     //get the survey result options.
     $this->_resultOptions = $this->get('resultOptions');
     if (!is_array($this->_resultOptions)) {
         $this->_resultOptions = array();
         if ($resultOptionId = CRM_Utils_Array::value('result_id', $this->_surveyValues)) {
             require_once 'CRM/Core/OptionGroup.php';
             $this->_resultOptions = CRM_Core_OptionGroup::valuesByID($resultOptionId);
         }
         $this->set('resultOptions', $this->_resultOptions);
     }
     //validate the required ids.
     $this->validateIds();
     //append breadcrumb to survey dashboard.
     require_once 'CRM/Campaign/BAO/Campaign.php';
     if (CRM_Campaign_BAO_Campaign::accessCampaignDashboard()) {
         $url = CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=survey');
         CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('Survey(s)'), 'url' => $url)));
     }
     //set the title.
     require_once 'CRM/Core/PseudoConstant.php';
     $activityTypes = CRM_Core_PseudoConstant::activityType(false, true, false, 'label', true);
     $this->_surveyTypeId = CRM_Utils_Array::value('activity_type_id', $this->_surveyValues);
     CRM_Utils_System::setTitle(ts('Record %1 Responses', array(1 => $activityTypes[$this->_surveyTypeId])));
 }
Exemplo n.º 5
0
 /** 
  * processing needed for buildForm and later 
  * 
  * @return void 
  * @access public 
  */
 function preProcess()
 {
     $this->_done = false;
     $this->_defaults = array();
     //set the button name.
     $this->_searchButtonName = $this->getButtonName('refresh');
     $this->_printButtonName = $this->getButtonName('next', 'print');
     $this->_actionButtonName = $this->getButtonName('next', 'action');
     //we allow the controller to set force/reset externally,
     //useful when we are being driven by the wizard framework
     $this->_limit = CRM_Utils_Request::retrieve('limit', 'Positive', $this);
     $this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', $this, false);
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this, false, 'search');
     $this->_reset = CRM_Utils_Request::retrieve('reset', 'Boolean', CRM_Core_DAO::$_nullObject);
     //operation for state machine.
     $this->_operation = CRM_Utils_Request::retrieve('op', 'String', $this, false, 'reserve');
     //validate operation.
     if (!in_array($this->_operation, array('reserve', 'release', 'interview'))) {
         $this->_operation = 'reserve';
         $this->set('op', $this->_operation);
     }
     //do check permissions.
     if (!CRM_Core_Permission::check('administer CiviCampaign') && !CRM_Core_Permission::check('manage campaign') && !CRM_Core_Permission::check("{$this->_operation} campaign contacts")) {
         CRM_Utils_System::permissionDenied();
         CRM_Utils_System::civiExit();
     }
     $this->assign("context", $this->_context);
     // get user submitted values
     // get it from controller only if form has been submitted, else preProcess has set this
     if (empty($_POST)) {
         $this->_formValues = $this->get('formValues');
     } else {
         $this->_formValues = $this->controller->exportValues($this->_name);
     }
     if ($this->_force) {
         $this->postProcess();
         $this->set('force', 0);
     }
     $sortID = null;
     if ($this->get(CRM_Utils_Sort::SORT_ID)) {
         $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION));
     }
     //get the voter clause.
     $voterClause = $this->voterClause();
     require_once 'CRM/Contact/BAO/Query.php';
     $this->_queryParams =& CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
     $selector = new CRM_Campaign_Selector_Search($this->_queryParams, $this->_action, $voterClause, $this->_single, $this->_limit, $this->_context);
     $prefix = null;
     if ($this->_context == 'user') {
         $prefix = $this->_prefix;
     }
     $this->assign("{$prefix}limit", $this->_limit);
     $this->assign("{$prefix}single", $this->_single);
     $controller = new CRM_Core_Selector_Controller($selector, $this->get(CRM_Utils_Pager::PAGE_ID), $sortID, CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::TRANSFER, $prefix);
     $controller->setEmbedded(true);
     $controller->moveFromSessionToTemplate();
     //append breadcrumb to survey dashboard.
     require_once 'CRM/Campaign/BAO/Campaign.php';
     if (CRM_Campaign_BAO_Campaign::accessCampaignDashboard()) {
         $url = CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=survey');
         CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('Survey(s)'), 'url' => $url)));
     }
     //set the form title.
     CRM_Utils_System::setTitle(ts('Find Respondents To %1', array(1 => ucfirst($this->_operation))));
 }
Exemplo n.º 6
0
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     $this->_interviewToRelease = $this->get('interviewToRelease');
     if ($this->_interviewToRelease) {
         //user came from interview form.
         foreach (array('surveyId', 'contactIds', 'interviewerId') as $fld) {
             $this->{"_{$fld}"} = $this->get($fld);
         }
         if (!empty($this->_contactIds)) {
             $this->assign('totalSelectedContacts', count($this->_contactIds));
         }
     } else {
         parent::preProcess();
         //get the survey id from user submitted values.
         $this->_surveyId = CRM_Utils_Array::value('campaign_survey_id', $this->get('formValues'));
         $this->_interviewerId = CRM_Utils_Array::value('survey_interviewer_id', $this->get('formValues'));
     }
     $activityStatus = CRM_Core_PseudoConstant::activityStatus('name');
     $surveyActType = CRM_Campaign_BAO_Survey::getSurveyActivityType();
     if (!$this->_surveyId) {
         CRM_Core_Error::statusBounce(ts("Please search with 'Survey', to apply this action."));
     }
     if (!$this->_interviewerId) {
         CRM_Core_Error::statusBounce(ts('Missing Interviewer contact.'));
     }
     if (!is_array($this->_contactIds) || empty($this->_contactIds)) {
         CRM_Core_Error::statusBounce(ts('Could not find respondents to release.'));
     }
     $surveyDetails = array();
     $params = array('id' => $this->_surveyId);
     $this->_surveyDetails = CRM_Campaign_BAO_Survey::retrieve($params, $surveyDetails);
     require_once 'CRM/Core/PseudoConstant.php';
     $activityStatus = CRM_Core_PseudoConstant::activityStatus('name');
     $statusIds = array();
     foreach (array('Scheduled') as $name) {
         if ($statusId = array_search($name, $activityStatus)) {
             $statusIds[] = $statusId;
         }
     }
     //fetch the target survey activities.
     $this->_surveyActivities = CRM_Campaign_BAO_Survey::voterActivityDetails($this->_surveyId, $this->_contactIds, $this->_interviewerId, $statusIds);
     if (count($this->_surveyActivities) < 1) {
         CRM_Core_Error::statusBounce(ts('We could not found respondent for this survey to release.'));
     }
     $this->assign('surveyTitle', $surveyDetails['title']);
     //append breadcrumb to survey dashboard.
     require_once 'CRM/Campaign/BAO/Campaign.php';
     if (CRM_Campaign_BAO_Campaign::accessCampaignDashboard()) {
         $url = CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=survey');
         CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('Survey(s)'), 'url' => $url)));
     }
     //set the title.
     CRM_Utils_System::setTitle(ts('Release Respondents'));
 }
Exemplo n.º 7
0
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     parent::preProcess();
     //get the survey id from user submitted values.
     $this->_surveyId = $this->get('surveyId');
     $this->_interviewerId = $this->get('interviewerId');
     if (!$this->_surveyId) {
         CRM_Core_Error::statusBounce(ts("Could not find Survey Id."));
     }
     if (!$this->_interviewerId) {
         CRM_Core_Error::statusBounce(ts("Missing Interviewer contact."));
     }
     if (!is_array($this->_contactIds) || empty($this->_contactIds)) {
         CRM_Core_Error::statusBounce(ts("Could not find contacts for reservation."));
     }
     $params = array('id' => $this->_surveyId);
     CRM_Campaign_BAO_Survey::retrieve($params, $this->_surveyDetails);
     //get the survey activities.
     require_once 'CRM/Core/PseudoConstant.php';
     $activityStatus = CRM_Core_PseudoConstant::activityStatus('name');
     $statusIds = array();
     foreach (array('Scheduled') as $name) {
         if ($statusId = array_search($name, $activityStatus)) {
             $statusIds[] = $statusId;
         }
     }
     $this->_surveyActivities = CRM_Campaign_BAO_Survey::getSurveyActivities($this->_surveyId, $this->_interviewerId, $statusIds);
     $this->_numVoters = count($this->_surveyActivities);
     //validate the selected survey.
     $this->validateSurvey();
     $this->assign('surveyTitle', $this->_surveyDetails['title']);
     //append breadcrumb to survey dashboard.
     require_once 'CRM/Campaign/BAO/Campaign.php';
     if (CRM_Campaign_BAO_Campaign::accessCampaignDashboard()) {
         $url = CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=survey');
         CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('Survey(s)'), 'url' => $url)));
     }
     //set the title.
     CRM_Utils_System::setTitle(ts('Reserve Respondents'));
 }
Exemplo n.º 8
0
 function run()
 {
     require_once 'CRM/Campaign/BAO/Campaign.php';
     if (!CRM_Campaign_BAO_Campaign::accessCampaignDashboard()) {
         CRM_Utils_System::permissionDenied();
     }
     $this->browse();
     parent::run();
 }