コード例 #1
0
ファイル: Survey.php プロジェクト: scardinius/civicrm-core
 public function preProcess()
 {
     if (!CRM_Campaign_BAO_Campaign::accessCampaign()) {
         CRM_Utils_System::permissionDenied();
     }
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add', 'REQUEST');
     $this->_surveyId = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE);
     if ($this->_surveyId) {
         $this->_single = TRUE;
         $params = array('id' => $this->_surveyId);
         CRM_Campaign_BAO_Survey::retrieve($params, $surveyInfo);
         $this->_surveyTitle = $surveyInfo['title'];
         $this->assign('surveyTitle', $this->_surveyTitle);
         CRM_Utils_System::setTitle(ts('Configure Survey - %1', array(1 => $this->_surveyTitle)));
     }
     $this->assign('action', $this->_action);
     $this->assign('surveyId', $this->_surveyId);
     // when custom data is included in this page
     if (!empty($_POST['hidden_custom'])) {
         $this->set('type', 'Event');
         $this->set('entityId', $this->_surveyId);
         CRM_Custom_Form_CustomData::preProcess($this, NULL, NULL, 1, 'Survey', $this->_surveyId);
         CRM_Custom_Form_CustomData::buildQuickForm($this);
         CRM_Custom_Form_CustomData::setDefaultValues($this);
     }
     // CRM-11480, CRM-11682
     // Preload libraries required by the "Questions" tab
     CRM_UF_Page_ProfileEditor::registerProfileScripts();
     CRM_UF_Page_ProfileEditor::registerSchemas(array('IndividualModel', 'ActivityModel'));
     CRM_Campaign_Form_Survey_TabHeader::build($this);
 }
コード例 #2
0
 public function preProcess()
 {
     if (!CRM_Campaign_BAO_Campaign::accessCampaign()) {
         CRM_Utils_System::permissionDenied();
     }
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $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'));
         }
     }
     $this->_cdType = CRM_Utils_Array::value('type', $_GET);
     $this->assign('cdType', FALSE);
     if ($this->_cdType) {
         $this->assign('cdType', TRUE);
         return CRM_Custom_Form_CustomData::preProcess($this);
     }
     // when custom data is included in this page
     if (!empty($_POST['hidden_custom'])) {
         CRM_Custom_Form_CustomData::preProcess($this);
         CRM_Custom_Form_CustomData::buildQuickForm($this);
     }
     $session = CRM_Core_Session::singleton();
     $url = CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=survey');
     $session->pushUserContext($url);
     $this->_values = $this->get('values');
     if (!is_array($this->_values)) {
         $this->_values = array();
         if ($this->_surveyId) {
             $params = array('id' => $this->_surveyId);
             CRM_Campaign_BAO_Survey::retrieve($params, $this->_values);
         }
         $this->set('values', $this->_values);
     }
     $this->assign('action', $this->_action);
     $this->assign('surveyId', $this->_surveyId);
     // for custom data
     $this->assign('entityID', $this->_surveyId);
     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 Petition'));
         } else {
             CRM_Utils_System::setTitle(ts('Delete Petition'));
         }
     }
     $session = CRM_Core_Session::singleton();
     $url = CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=petition');
     $session->pushUserContext($url);
     CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('Petition Dashboard'), 'url' => $url)));
 }
コード例 #3
0
ファイル: Survey.php プロジェクト: hguru/224Civi
 function run()
 {
     if (!CRM_Campaign_BAO_Campaign::accessCampaign()) {
         CRM_Utils_System::permissionDenied();
     }
     $action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 0);
     $this->assign('action', $action);
     $this->browse();
     return parent::run();
 }
コード例 #4
0
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 public function preProcess()
 {
     if (!CRM_Campaign_BAO_Campaign::accessCampaign()) {
         CRM_Utils_System::permissionDenied();
     }
     $this->_surveyId = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE);
     $params = array('id' => $this->_surveyId);
     CRM_Campaign_BAO_Survey::retrieve($params, $surveyInfo);
     $this->_surveyTitle = $surveyInfo['title'];
     $this->assign('surveyTitle', $this->_surveyTitle);
     CRM_Utils_System::setTitle(ts('Delete Survey') . ' - ' . $this->_surveyTitle);
 }
コード例 #5
0
ファイル: Campaign.php プロジェクト: kidaa30/yes
 public function preProcess()
 {
     if (!CRM_Campaign_BAO_Campaign::accessCampaign()) {
         CRM_Utils_System::permissionDenied();
     }
     //check for custom data type.
     $this->_cdType = CRM_Utils_Array::value('type', $_GET);
     $this->assign('cdType', FALSE);
     if ($this->_cdType) {
         $this->assign('cdType', TRUE);
         return CRM_Custom_Form_CustomData::preProcess($this);
     }
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $this->assign('context', $this->_context);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this);
     $this->_campaignId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $title = NULL;
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $title = ts('Edit Campaign');
     }
     if ($this->_action & CRM_Core_Action::DELETE) {
         $title = ts('Delete Campaign');
     }
     if ($title) {
         CRM_Utils_System::setTitle($title);
     }
     $session = CRM_Core_Session::singleton();
     $session->pushUserContext(CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=campaign'));
     $this->assign('action', $this->_action);
     //load the values;
     $this->_values = $this->get('values');
     if (!is_array($this->_values)) {
         $this->_values = array();
         // if we are editing
         if (isset($this->_campaignId) && $this->_campaignId) {
             $params = array('id' => $this->_campaignId);
             CRM_Campaign_BAO_Campaign::retrieve($params, $this->_values);
         }
         //lets use current object session.
         $this->set('values', $this->_values);
     }
     // when custom data is included in form.
     if (!empty($_POST['hidden_custom'])) {
         $this->set('type', 'Campaign');
         $this->set('subType', CRM_Utils_Array::value('campaign_type_id', $_POST));
         $this->set('entityId', $this->_campaignId);
         CRM_Custom_Form_CustomData::preProcess($this);
         CRM_Custom_Form_CustomData::buildQuickForm($this);
         CRM_Custom_Form_CustomData::setDefaultValues($this);
     }
 }
コード例 #6
0
ファイル: Survey.php プロジェクト: hguru/224Civi
 public function preProcess()
 {
     if (!CRM_Campaign_BAO_Campaign::accessCampaign()) {
         CRM_Utils_System::permissionDenied();
     }
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add', 'REQUEST');
     $this->_surveyId = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE);
     if ($this->_surveyId) {
         $this->_single = TRUE;
         $params = array('id' => $this->_surveyId);
         CRM_Campaign_BAO_Survey::retrieve($params, $surveyInfo);
         $this->_surveyTitle = $surveyInfo['title'];
         $this->assign('surveyTitle', $this->_surveyTitle);
         CRM_Utils_System::setTitle(ts('Configure Survey - %1', array(1 => $this->_surveyTitle)));
     }
     $this->assign('action', $this->_action);
     $this->assign('surveyId', $this->_surveyId);
     // CRM-11480, CRM-11682
     // Preload libraries required by the "Questions" tab
     CRM_UF_Page_ProfileEditor::registerProfileScripts();
     CRM_UF_Page_ProfileEditor::registerSchemas(array('IndividualModel', 'ActivityModel'));
     CRM_Campaign_Form_Survey_TabHeader::build($this);
 }
コード例 #7
0
ファイル: Gotv.php プロジェクト: FundingWorks/civicrm-core
 /**
  * Processing needed for buildForm and later.
  */
 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';
         } elseif ($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->set('searchVoterFor', $this->_searchVoterFor);
     $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.
     if (CRM_Campaign_BAO_Campaign::accessCampaign()) {
         $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)'));
 }
コード例 #8
0
 /**
  * add all the elements shared between case activity search  and advanaced search
  *
  * @access public
  *
  * @return void
  * @static
  */
 static function buildSearchForm(&$form)
 {
     $activityOptions = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE);
     asort($activityOptions);
     foreach ($activityOptions as $activityID => $activity) {
         $form->_activityElement =& $form->addElement('checkbox', "activity_type_id[{$activityID}]", NULL, $activity, array('onClick' => 'showCustomData( this.id );'));
     }
     CRM_Core_Form_Date::buildDateRange($form, 'activity_date', 1, '_low', '_high', ts('From'), FALSE, FALSE);
     $activityRoles = array(1 => ts('Created by'), 2 => ts('Assigned to'));
     $form->addRadio('activity_role', NULL, $activityRoles, NULL, '<br />');
     $form->addElement('text', 'activity_contact_name', ts('Contact Name'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
     $activityStatus = CRM_Core_PseudoConstant::activityStatus();
     foreach ($activityStatus as $activityStatusID => $activityStatusName) {
         $activity_status[] = $form->createElement('checkbox', $activityStatusID, NULL, $activityStatusName);
     }
     $form->addGroup($activity_status, 'activity_status', ts('Activity Status'));
     $form->setDefaults(array('activity_status[1]' => 1, 'activity_status[2]' => 1));
     $form->addElement('text', 'activity_subject', ts('Subject'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
     $form->addElement('checkbox', 'activity_test', ts('Find Test Activities?'));
     $activity_tags = CRM_Core_BAO_Tag::getTags('civicrm_activity');
     if ($activity_tags) {
         foreach ($activity_tags as $tagID => $tagName) {
             $form->_tagElement =& $form->addElement('checkbox', "activity_tags[{$tagID}]", NULL, $tagName);
         }
     }
     $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_activity');
     CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_activity', NULL, TRUE, FALSE, TRUE);
     $surveys = CRM_Campaign_BAO_Survey::getSurveys();
     if ($surveys) {
         $form->add('select', 'activity_survey_id', ts('Survey'), array('' => ts('- none -')) + $surveys, FALSE);
     }
     $extends = array('Activity');
     $groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, TRUE, $extends);
     if ($groupDetails) {
         $form->assign('activityGroupTree', $groupDetails);
         foreach ($groupDetails as $group) {
             foreach ($group['fields'] as $field) {
                 $fieldId = $field['id'];
                 $elementName = 'custom_' . $fieldId;
                 CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, FALSE, FALSE, TRUE);
             }
         }
     }
     CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($form, 'activity_campaign_id');
     //add engagement level CRM-7775
     $buildEngagementLevel = FALSE;
     if (CRM_Campaign_BAO_Campaign::isCampaignEnable() && CRM_Campaign_BAO_Campaign::accessCampaign()) {
         $buildEngagementLevel = TRUE;
         $form->add('select', 'activity_engagement_level', ts('Engagement Index'), array('' => ts('- select -')) + CRM_Campaign_PseudoConstant::engagementLevel());
     }
     $form->assign('buildEngagementLevel', $buildEngagementLevel);
 }
コード例 #9
0
 public function buildQuickForm()
 {
     if ($this->_action & (CRM_Core_Action::DELETE | CRM_Core_Action::RENEW)) {
         //enable form element (ActivityLinks sets this true)
         $this->assign('suppressForm', FALSE);
         $button = ts('Delete');
         if ($this->_action & CRM_Core_Action::RENEW) {
             $button = ts('Restore');
         }
         $this->addButtons(array(array('type' => 'next', 'name' => $button, 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
         return;
     }
     // Build other activity links.
     CRM_Activity_Form_ActivityLinks::commonBuildQuickForm($this);
     // Enable form element (ActivityLinks sets this true).
     $this->assign('suppressForm', FALSE);
     $element =& $this->add('select', 'activity_type_id', ts('Activity Type'), array('' => '- ' . ts('select') . ' -') + $this->_fields['followup_activity_type_id']['attributes'], FALSE, array('onchange' => "CRM.buildCustomData( 'Activity', this.value );", 'class' => 'crm-select2 required'));
     // Freeze for update mode.
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $element->freeze();
     }
     // Call to RecurringEntity buildQuickForm for add/update mode.
     if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD)) {
         CRM_Core_Form_RecurringEntity::buildQuickForm($this);
     }
     foreach ($this->_fields as $field => $values) {
         if (!empty($this->_fields[$field])) {
             $attribute = CRM_Utils_Array::value('attributes', $values);
             $required = !empty($values['required']);
             if ($values['type'] == 'select' && empty($attribute)) {
                 $this->addSelect($field, array('entity' => 'activity'), $required);
             } elseif ($values['type'] == 'entityRef') {
                 $this->addEntityRef($field, $values['label'], $attribute, $required);
             } else {
                 $this->add($values['type'], $field, $values['label'], $attribute, $required, CRM_Utils_Array::value('extra', $values));
             }
         }
     }
     // CRM-7362 --add campaigns.
     CRM_Campaign_BAO_Campaign::addCampaign($this, CRM_Utils_Array::value('campaign_id', $this->_values));
     // Add engagement level CRM-7775
     $buildEngagementLevel = FALSE;
     if (CRM_Campaign_BAO_Campaign::isCampaignEnable() && CRM_Campaign_BAO_Campaign::accessCampaign()) {
         $buildEngagementLevel = TRUE;
         $this->addSelect('engagement_level', array('entity' => 'activity'));
         $this->addRule('engagement_level', ts('Please enter the engagement index as a number (integers only).'), 'positiveInteger');
     }
     $this->assign('buildEngagementLevel', $buildEngagementLevel);
     // check for survey activity
     $this->_isSurveyActivity = FALSE;
     if ($this->_activityId && CRM_Campaign_BAO_Campaign::isCampaignEnable() && CRM_Campaign_BAO_Campaign::accessCampaign()) {
         $this->_isSurveyActivity = CRM_Campaign_BAO_Survey::isSurveyActivity($this->_activityId);
         if ($this->_isSurveyActivity) {
             $surveyId = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $this->_activityId, 'source_record_id');
             $responseOptions = CRM_Campaign_BAO_Survey::getResponsesOptions($surveyId);
             if ($responseOptions) {
                 $this->add('select', 'result', ts('Result'), array('' => ts('- select -')) + array_combine($responseOptions, $responseOptions));
             }
             $surveyTitle = NULL;
             if ($surveyId) {
                 $surveyTitle = CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $surveyId, 'title');
             }
             $this->assign('surveyTitle', $surveyTitle);
         }
     }
     $this->assign('surveyActivity', $this->_isSurveyActivity);
     // this option should be available only during add mode
     if ($this->_action != CRM_Core_Action::UPDATE) {
         $this->add('advcheckbox', 'is_multi_activity', ts('Create a separate activity for each contact.'));
     }
     $this->addRule('duration', ts('Please enter the duration as number of minutes (integers only).'), 'positiveInteger');
     $this->addDateTime('activity_date_time', ts('Date'), TRUE, array('formatType' => 'activityDateTime'));
     // Add followup date.
     $this->addDateTime('followup_date', ts('in'), FALSE, array('formatType' => 'activityDateTime'));
     // Only admins and case-workers can change the activity source
     if (!CRM_Core_Permission::check('administer CiviCRM') && $this->_context != 'caseActivity') {
         $this->getElement('source_contact_id')->freeze();
     }
     //need to assign custom data type and subtype to the template
     $this->assign('customDataType', 'Activity');
     $this->assign('customDataSubType', $this->_activityTypeId);
     $this->assign('entityID', $this->_activityId);
     CRM_Core_BAO_Tag::getTags('civicrm_activity', $tags, NULL, '&nbsp;&nbsp;', TRUE);
     if (!empty($tags)) {
         $this->add('select', 'tag', ts('Tags'), $tags, FALSE, array('id' => 'tags', 'multiple' => 'multiple', 'class' => 'crm-select2 huge'));
     }
     // we need to hide activity tagset for special activities
     $specialActivities = array('Open Case');
     if (!in_array($this->_activityTypeName, $specialActivities)) {
         // build tag widget
         $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_activity');
         CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, 'civicrm_activity', $this->_activityId);
     }
     // if we're viewing, we're assigning different buttons than for adding/editing
     if ($this->_action & CRM_Core_Action::VIEW) {
         if (isset($this->_groupTree)) {
             CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $this->_groupTree);
         }
         // form should be frozen for view mode
         $this->freeze();
         $buttons = array();
         $buttons[] = array('type' => 'cancel', 'name' => ts('Done'));
         $this->addButtons($buttons);
     } else {
         $message = array('completed' => ts('Are you sure? This is a COMPLETED activity with the DATE in the FUTURE. Click Cancel to change the date / status. Otherwise, click OK to save.'), 'scheduled' => ts('Are you sure? This is a SCHEDULED activity with the DATE in the PAST. Click Cancel to change the date / status. Otherwise, click OK to save.'));
         $js = array('onclick' => "return activityStatus(" . json_encode($message) . ");");
         $this->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'js' => $js, 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
     }
     if ($this->_activityTypeFile) {
         $className = "CRM_{$this->_crmDir}_Form_Activity_{$this->_activityTypeFile}";
         $className::buildQuickForm($this);
         $this->addFormRule(array($className, 'formRule'), $this);
     }
     $this->addFormRule(array('CRM_Activity_Form_Activity', 'formRule'), $this);
     if (Civi::settings()->get('activity_assignee_notification')) {
         $this->assign('activityAssigneeNotification', TRUE);
     } else {
         $this->assign('activityAssigneeNotification', FALSE);
     }
 }
コード例 #10
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.
     $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;
     //validate all voters for required activity.
     //get the survey activities for given voters.
     $this->_surveyActivityIds = CRM_Campaign_BAO_Survey::voterActivityDetails($this->_surveyId, $this->_contactIds, $this->_interviewerId);
     $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;
     }
     //validate voter ids across profile.
     $this->filterVoterIds();
     $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) {
             $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)) {
             $this->_resultOptions = CRM_Core_OptionGroup::valuesByID($resultOptionId);
         }
         $this->set('resultOptions', $this->_resultOptions);
     }
     //validate the required ids.
     $this->validateIds();
     //append breadcrumb to survey dashboard.
     if (CRM_Campaign_BAO_Campaign::accessCampaign()) {
         $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.
     $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])));
 }
コード例 #11
0
ファイル: Reserve.php プロジェクト: kcristiano/civicrm-core
 /**
  * Build all the data structures needed to build the form.
  */
 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.
     $activityStatus = CRM_Core_PseudoConstant::activityStatus('name');
     $statusIds = array();
     foreach (array('Scheduled') as $name) {
         if ($statusId = array_search($name, $activityStatus)) {
             $statusIds[] = $statusId;
         }
     }
     // these are the activities count that are linked to the current
     // interviewer and current survey and not the list of ALL survey activities
     $this->_numVoters = CRM_Campaign_BAO_Survey::getSurveyActivities($this->_surveyId, $this->_interviewerId, $statusIds, NULL, TRUE);
     //validate the selected survey.
     $this->validateSurvey();
     $this->assign('surveyTitle', $this->_surveyDetails['title']);
     $this->assign('activityType', $this->_surveyDetails['activity_type_id']);
     $this->assign('surveyId', $this->_surveyId);
     //append breadcrumb to survey dashboard.
     if (CRM_Campaign_BAO_Campaign::accessCampaign()) {
         $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'));
 }
コード例 #12
0
ファイル: Release.php プロジェクト: FundingWorks/civicrm-core
 /**
  * Build all the data structures needed to build the form.
  */
 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'));
     }
     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);
     $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.
     if (CRM_Campaign_BAO_Campaign::accessCampaign()) {
         $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'));
 }
コード例 #13
0
 /**
  * Build all the data structures needed to build the form.
  */
 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'));
     }
     if ($this->_surveyId) {
         $params = array('id' => $this->_surveyId);
         CRM_Campaign_BAO_Survey::retrieve($params, $this->_surveyDetails);
     }
     $orderClause = FALSE;
     $buttonName = $this->controller->getButtonName();
     if ($buttonName == '_qf_Interview_submit_orderBy' && !empty($_POST['order_bys'])) {
         $orderByParams = CRM_Utils_Array::value('order_bys', $_POST);
     } elseif (CRM_Core_OptionGroup::getValue('activity_type', 'WalkList') == $this->_surveyDetails['activity_type_id']) {
         $orderByParams = array(1 => array('column' => 'civicrm_address.street_name', 'order' => 'ASC'), 2 => array('column' => 'civicrm_address.street_number%2', 'order' => 'ASC'), 3 => array('column' => 'civicrm_address.street_number', 'order' => 'ASC'), 4 => array('column' => 'contact_a.sort_name', 'order' => 'ASC'));
     }
     $orderBy = array();
     if (!empty($orderByParams)) {
         foreach ($orderByParams as $key => $val) {
             if (!empty($val['column'])) {
                 $orderBy[] = "{$val['column']} {$val['order']}";
             }
         }
         if (!empty($orderBy)) {
             $orderClause = "ORDER BY " . implode(', ', $orderBy);
         }
     }
     $this->_contactIds = array_unique($this->_contactIds);
     if (!empty($this->_contactIds) && $orderClause) {
         $clause = 'contact_a.id IN ( ' . implode(',', $this->_contactIds) . ' ) ';
         $sql = "\nSELECT contact_a.id\nFROM civicrm_contact contact_a\nLEFT JOIN civicrm_address ON contact_a.id = civicrm_address.contact_id\nWHERE {$clause}\n{$orderClause}";
         $this->_contactIds = array();
         $dao = CRM_Core_DAO::executeQuery($sql);
         while ($dao->fetch()) {
             $this->_contactIds[] = $dao->id;
         }
     }
     //get the contact read only fields to display.
     $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;
     //validate all voters for required activity.
     //get the survey activities for given voters.
     $this->_surveyActivityIds = CRM_Campaign_BAO_Survey::voterActivityDetails($this->_surveyId, $this->_contactIds, $this->_interviewerId);
     $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;
     }
     //validate voter ids across profile.
     $this->filterVoterIds();
     $this->assign('votingTab', $this->_votingTab);
     $this->assign('componentIds', $this->_contactIds);
     $this->assign('componentIdsJson', json_encode($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) {
             $surveyParams = array('id' => $this->_surveyId);
             CRM_Campaign_BAO_Survey::retrieve($surveyParams, $this->_surveyValues);
         }
         $this->set('surveyValues', $this->_surveyValues);
     }
     $this->assign('surveyValues', $this->_surveyValues);
     $result = CRM_Campaign_BAO_Survey::getReportID($this->_surveyId);
     $this->assign("instanceId", $result);
     //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)) {
             $this->_resultOptions = CRM_Core_OptionGroup::valuesByID($resultOptionId);
         }
         $this->set('resultOptions', $this->_resultOptions);
     }
     //validate the required ids.
     $this->validateIds();
     //append breadcrumb to survey dashboard.
     if (CRM_Campaign_BAO_Campaign::accessCampaign()) {
         $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.
     $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])));
 }
コード例 #14
0
ファイル: DashBoard.php プロジェクト: nielosz/civicrm-core
 /**
  * @return string
  */
 public function run()
 {
     if (!CRM_Campaign_BAO_Campaign::accessCampaign()) {
         CRM_Utils_System::permissionDenied();
     }
     $this->browse();
     return parent::run();
 }
コード例 #15
0
ファイル: Query.php プロジェクト: rajeshrhino/civicrm-core
 /**
  * Add all the elements shared between case activity search and advanced search.
  *
  *
  * @param CRM_Core_Form $form
  * @return void
  */
 public static function buildSearchForm(&$form)
 {
     $activityOptions = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE);
     $form->addSelect('activity_type_id', array('entity' => 'activity', 'label' => 'Activity Type(s)', 'multiple' => 'multiple', 'option_url' => NULL, 'placeholder' => ts('- any -')));
     CRM_Core_Form_Date::buildDateRange($form, 'activity_date', 1, '_low', '_high', ts('From'), FALSE, FALSE);
     $followUpActivity = array(1 => ts('Yes'), 2 => ts('No'));
     $form->addRadio('parent_id', NULL, $followUpActivity, array('allowClear' => TRUE));
     $form->addRadio('followup_parent_id', NULL, $followUpActivity, array('allowClear' => TRUE));
     $activityRoles = array(3 => ts('With'), 2 => ts('Assigned to'), 1 => ts('Added by'));
     $form->addRadio('activity_role', NULL, $activityRoles, array('allowClear' => TRUE));
     $form->setDefaults(array('activity_role' => 3));
     $activityStatus = CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'status_id', array('flip' => 1, 'labelColumn' => 'name'));
     $form->addSelect('status_id', array('entity' => 'activity', 'multiple' => 'multiple', 'option_url' => NULL, 'placeholder' => ts('- any -')));
     $form->setDefaults(array('status_id' => array($activityStatus['Completed'], $activityStatus['Scheduled'])));
     $form->addElement('text', 'activity_subject', ts('Subject'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
     $form->addYesNo('activity_test', ts('Activity is a Test?'));
     $activity_tags = CRM_Core_BAO_Tag::getTags('civicrm_activity');
     if ($activity_tags) {
         foreach ($activity_tags as $tagID => $tagName) {
             $form->_tagElement =& $form->addElement('checkbox', "activity_tags[{$tagID}]", NULL, $tagName);
         }
     }
     $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_activity');
     CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_activity', NULL, TRUE, TRUE);
     $surveys = CRM_Campaign_BAO_Survey::getSurveys(TRUE, FALSE, FALSE, TRUE);
     if ($surveys) {
         $form->add('select', 'activity_survey_id', ts('Survey / Petition'), array('' => ts('- none -')) + $surveys, FALSE, array('class' => 'crm-select2'));
     }
     $extends = array('Activity');
     $groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, TRUE, $extends);
     if ($groupDetails) {
         $form->assign('activityGroupTree', $groupDetails);
         foreach ($groupDetails as $group) {
             foreach ($group['fields'] as $field) {
                 $fieldId = $field['id'];
                 $elementName = 'custom_' . $fieldId;
                 CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, FALSE, FALSE, TRUE);
             }
         }
     }
     CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($form, 'activity_campaign_id');
     //add engagement level CRM-7775
     $buildEngagementLevel = FALSE;
     $buildSurveyResult = FALSE;
     if (CRM_Campaign_BAO_Campaign::isCampaignEnable() && CRM_Campaign_BAO_Campaign::accessCampaign()) {
         $buildEngagementLevel = TRUE;
         $form->addSelect('activity_engagement_level', array('entity' => 'activity', 'context' => 'search'));
         // Add survey result field.
         $optionGroups = CRM_Campaign_BAO_Survey::getResultSets('name');
         $resultOptions = array();
         foreach ($optionGroups as $gid => $name) {
             if ($name) {
                 $value = array();
                 $value = CRM_Core_OptionGroup::values($name);
                 if (!empty($value)) {
                     while (list($k, $v) = each($value)) {
                         $resultOptions[$v] = $v;
                     }
                 }
             }
         }
         // If no survey result options have been created, don't build
         // the field to avoid clutter.
         if (count($resultOptions) > 0) {
             $buildSurveyResult = TRUE;
             asort($resultOptions);
             $form->add('select', 'activity_result', ts("Survey Result"), $resultOptions, FALSE, array('id' => 'activity_result', 'multiple' => 'multiple', 'class' => 'crm-select2'));
         }
     }
     $form->assign('buildEngagementLevel', $buildEngagementLevel);
     $form->assign('buildSurveyResult', $buildSurveyResult);
     $form->setDefaults(array('activity_test' => 0));
 }
コード例 #16
0
ファイル: Activity.php プロジェクト: hguru/224Civi
 public function buildQuickForm()
 {
     if ($this->_action & (CRM_Core_Action::DELETE | CRM_Core_Action::RENEW)) {
         //enable form element (ActivityLinks sets this true)
         $this->assign('suppressForm', FALSE);
         $button = ts('Delete');
         if ($this->_action & CRM_Core_Action::RENEW) {
             $button = ts('Restore');
         }
         $this->addButtons(array(array('type' => 'next', 'name' => $button, 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
         return;
     }
     if (!$this->_single && !empty($this->_contactIds)) {
         $withArray = array();
         foreach ($this->_contactIds as $contactId) {
             $withDisplayName = self::_getDisplayNameById($contactId);
             $withArray[] = "\"{$withDisplayName}\" ";
         }
         $this->assign('with', implode(', ', $withArray));
     }
     if ($this->_cdType) {
         return CRM_Custom_Form_CustomData::buildQuickForm($this);
     }
     //build other activity links
     CRM_Activity_Form_ActivityLinks::commonBuildQuickForm($this);
     //enable form element (ActivityLinks sets this true)
     $this->assign('suppressForm', FALSE);
     $element =& $this->add('select', 'activity_type_id', ts('Activity Type'), $this->_fields['followup_activity_type_id']['attributes'], FALSE, array('onchange' => "CRM.buildCustomData( 'Activity', this.value );"));
     //freeze for update mode.
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $element->freeze();
     }
     foreach ($this->_fields as $field => $values) {
         if (CRM_Utils_Array::value($field, $this->_fields)) {
             $attribute = NULL;
             if (CRM_Utils_Array::value('attributes', $values)) {
                 $attribute = $values['attributes'];
             }
             $required = FALSE;
             if (CRM_Utils_Array::value('required', $values)) {
                 $required = TRUE;
             }
             if ($values['type'] == 'wysiwyg') {
                 $this->addWysiwyg($field, $values['label'], $attribute, $required);
             } else {
                 $this->add($values['type'], $field, $values['label'], $attribute, $required);
             }
         }
     }
     //CRM-7362 --add campaigns.
     CRM_Campaign_BAO_Campaign::addCampaign($this, CRM_Utils_Array::value('campaign_id', $this->_values));
     //add engagement level CRM-7775
     $buildEngagementLevel = FALSE;
     if (CRM_Campaign_BAO_Campaign::isCampaignEnable() && CRM_Campaign_BAO_Campaign::accessCampaign()) {
         $buildEngagementLevel = TRUE;
         $this->add('select', 'engagement_level', ts('Engagement Index'), array('' => ts('- select -')) + CRM_Campaign_PseudoConstant::engagementLevel());
         $this->addRule('engagement_level', ts('Please enter the engagement index as a number (integers only).'), 'positiveInteger');
     }
     $this->assign('buildEngagementLevel', $buildEngagementLevel);
     // check for survey activity
     $this->_isSurveyActivity = FALSE;
     if ($this->_activityId && CRM_Campaign_BAO_Campaign::isCampaignEnable() && CRM_Campaign_BAO_Campaign::accessCampaign()) {
         $this->_isSurveyActivity = CRM_Campaign_BAO_Survey::isSurveyActivity($this->_activityId);
         if ($this->_isSurveyActivity) {
             $surveyId = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $this->_activityId, 'source_record_id');
             $responseOptions = CRM_Campaign_BAO_Survey::getResponsesOptions($surveyId);
             if ($responseOptions) {
                 $this->add('select', 'result', ts('Result'), array('' => ts('- select -')) + array_combine($responseOptions, $responseOptions));
             }
             $surveyTitle = NULL;
             if ($surveyId) {
                 $surveyTitle = CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $surveyId, 'title');
             }
             $this->assign('surveyTitle', $surveyTitle);
         }
     }
     $this->assign('surveyActivity', $this->_isSurveyActivity);
     // this option should be available only during add mode
     if ($this->_action != CRM_Core_Action::UPDATE) {
         $this->add('advcheckbox', 'is_multi_activity', ts('Create a separate activity for each contact.'));
     }
     $this->addRule('duration', ts('Please enter the duration as number of minutes (integers only).'), 'positiveInteger');
     $this->addDateTime('activity_date_time', ts('Date'), TRUE, array('formatType' => 'activityDateTime'));
     //add followup date
     $this->addDateTime('followup_date', ts('in'), FALSE, array('formatType' => 'activityDateTime'));
     //autocomplete url
     $dataUrl = CRM_Utils_System::url("civicrm/ajax/rest", "className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&context=activity&reset=1", FALSE, NULL, FALSE);
     $this->assign('dataUrl', $dataUrl);
     //tokeninput url
     $tokenUrl = CRM_Utils_System::url("civicrm/ajax/checkemail", "noemail=1", FALSE, NULL, FALSE);
     $this->assign('tokenUrl', $tokenUrl);
     $admin = CRM_Core_Permission::check('administer CiviCRM');
     //allow to edit source contact field field if context is civicase.
     if ($this->_context == 'caseActivity') {
         $admin = TRUE;
     }
     $this->assign('admin', $admin);
     $sourceContactField =& $this->add($this->_fields['source_contact_id']['type'], 'source_contact_id', $this->_fields['source_contact_id']['label'], NULL, $admin);
     $this->add('hidden', 'source_contact_qid', '', array('id' => 'source_contact_qid'));
     CRM_Contact_Form_NewContact::buildQuickForm($this);
     $this->add('text', 'assignee_contact_id', ts('assignee'));
     if ($sourceContactField->getValue()) {
         $this->assign('source_contact', $sourceContactField->getValue());
     } elseif ($this->_currentUserId) {
         // we're setting currently LOGGED IN user as source for this activity
         $this->assign('source_contact_value', self::_getDisplayNameById($this->_currentUserId));
     }
     //need to assign custom data type and subtype to the template
     $this->assign('customDataType', 'Activity');
     $this->assign('customDataSubType', $this->_activityTypeId);
     $this->assign('entityID', $this->_activityId);
     $tags = CRM_Core_BAO_Tag::getTags('civicrm_activity');
     if (!empty($tags)) {
         $this->add('select', 'tag', ts('Tags'), $tags, FALSE, array('id' => 'tags', 'multiple' => 'multiple', 'title' => ts('- select -')));
     }
     // we need to hide activity tagset for special activities
     $specialActivities = array('Open Case');
     if (!in_array($this->_activityTypeName, $specialActivities)) {
         // build tag widget
         $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_activity');
         CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, 'civicrm_activity', $this->_activityId, TRUE, TRUE);
     }
     // if we're viewing, we're assigning different buttons than for adding/editing
     if ($this->_action & CRM_Core_Action::VIEW) {
         if (isset($this->_groupTree)) {
             CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $this->_groupTree);
         }
         $buttons = array();
         // do check for permissions
         if (CRM_Case_BAO_Case::checkPermission($this->_activityId, 'File On Case', $this->_activityTypeId)) {
             $buttons[] = array('type' => 'cancel', 'name' => ts('File on case'), 'subName' => 'file_on_case', 'js' => array('onClick' => "javascript:fileOnCase( \"file\", {$this->_activityId} ); return false;"));
         }
         // form should be frozen for view mode
         $this->freeze();
         $buttons[] = array('type' => 'cancel', 'name' => ts('Done'));
         $this->addButtons($buttons);
     } else {
         $message = array('completed' => ts('Are you sure? This is a COMPLETED activity with the DATE in the FUTURE. Click Cancel to change the date / status. Otherwise, click OK to save.'), 'scheduled' => ts('Are you sure? This is a SCHEDULED activity with the DATE in the PAST. Click Cancel to change the date / status. Otherwise, click OK to save.'));
         $js = array('onclick' => "return activityStatus(" . json_encode($message) . ");");
         $this->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'js' => $js, 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
     }
     if ($this->_activityTypeFile) {
         $className = "CRM_{$this->_crmDir}_Form_Activity_{$this->_activityTypeFile}";
         $className::buildQuickForm($this);
         $this->addFormRule(array($className, 'formRule'), $this);
     }
     $this->addFormRule(array('CRM_Activity_Form_Activity', 'formRule'), $this);
     if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'activity_assignee_notification')) {
         $this->assign('activityAssigneeNotification', TRUE);
     } else {
         $this->assign('activityAssigneeNotification', FALSE);
     }
 }
コード例 #17
0
ファイル: Search.php プロジェクト: FundingWorks/civicrm-core
 /**
  * Processing needed for buildForm and later.
  */
 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);
     }
     $this->set('searchVoterFor', $this->_operation);
     $this->assign('searchVoterFor', $this->_operation);
     $this->assign('isFormSubmitted', $this->isSubmitted());
     //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();
     $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.
     if (CRM_Campaign_BAO_Campaign::accessCampaign()) {
         $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))));
 }