예제 #1
1
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     parent::preProcess();
     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 = CRM_Core_Session::singleton();
     $url = CRM_Utils_System::url('civicrm/contact/search/custom', $urlParams);
     $session->replaceUserContext($url);
     //get the survey id from user submitted values.
     $this->_surveyId = CRM_Utils_Array::value('survey_id', $this->get('formValues'));
     $isHeld = CRM_Utils_Array::value('status_id', $this->get('formValues'));
     if (!$this->_surveyId || !$isHeld) {
         CRM_Core_Error::statusBounce(ts("Please search with 'Is Held' and 'Survey Id' filters to apply this action."));
     }
     $session = CRM_Core_Session::singleton();
     if (empty($this->_contactIds) || !$session->get('userID')) {
         CRM_Core_Error::statusBounce(ts("Could not find contacts for release voters resevation Or Missing Interviewer contact."));
     }
     $this->_interviewerId = $session->get('userID');
     $surveyDetails = array();
     $params = array('id' => $this->_surveyId);
     $this->_surveyDetails = CRM_Campaign_BAO_Survey::retrieve($params, $surveyDetails);
     $numVoters = CRM_Core_DAO::singleValueQuery("SELECT COUNT(*) FROM " . self::ACTIVITY_SURVEY_DETAIL_TABLE . " WHERE status_id = 'H' AND survey_id = %1 AND interviewer_id = %2", array(1 => array($this->_surveyId, 'Integer'), 2 => array($this->_interviewerId, 'Integer')));
     if (!isset($numVoters) || $numVoters < 1) {
         CRM_Core_Error::statusBounce(ts("All voters held by you are already released for this survey."));
     }
     $this->assign('surveyTitle', $surveyDetails['title']);
 }
예제 #2
0
파일: SMS.php 프로젝트: ksecor/civicrm
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, false);
     if ($cid) {
         // not sure why this is needed :(
         // also add the cid params to the Menu array
         CRM_Core_Menu::addParam('cid', $cid);
         // create menus ..
         $startWeight = CRM_Core_Menu::getMaxWeight('civicrm/contact/view');
         $startWeight++;
         CRM_Core_BAO_CustomGroup::addMenuTabs(CRM_Contact_BAO_Contact::getContactType($cid), 'civicrm/contact/view/cd', $startWeight);
         $this->_contactIds = array($cid);
         $this->_single = true;
         $smsNumbers = CRM_Contact_BAO_Contact::allPhones($cid, 'Mobile');
         $this->_emails = array();
         $toName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $cid, 'display_name');
         foreach ($smsNumbers as $number => $item) {
             $this->_smsNumbers[$number] = '"' . $toName . '" <' . $number . '> ' . $item['locationType'];
             if ($item['is_primary']) {
                 $this->_smsNumbers[$number] .= ' ' . ts('(preferred)');
             }
             $this->_smsNumbers[$number] = htmlspecialchars($this->_emails[$email]);
         }
     } else {
         parent::preProcess();
     }
     $this->assign('single', $this->_single);
 }
예제 #3
0
 /**
  * Set variables up before form is built.
  *
  * @return void
  */
 public function preProcess()
 {
     if (CRM_Core_BAO_MailSettings::defaultDomain() == "EXAMPLE.ORG") {
         CRM_Core_Error::fatal(ts('The <a href="%1">default mailbox</a> has not been configured. You will find <a href="%2">more info in our online user and administrator guide.</a>', array(1 => CRM_Utils_System::url('civicrm/admin/mailSettings', 'reset=1'), 2 => "http://book.civicrm.org/user/advanced-configuration/email-system-configuration/")));
     }
     $this->_mailingID = CRM_Utils_Request::retrieve('mid', 'Integer', $this, FALSE, NULL);
     // when user come from search context.
     $this->_searchBasedMailing = CRM_Contact_Form_Search::isSearchContext($this->get('context'));
     if ($this->_searchBasedMailing) {
         $searchParams = $this->controller->exportValues();
         // number of records that were selected - All or Few.
         $this->_resultSelectOption = $searchParams['radio_ts'];
         if (CRM_Utils_Array::value('task', $searchParams) == 20) {
             parent::preProcess();
         }
     }
     $session = CRM_Core_Session::singleton();
     if ($this->_searchBasedMailing) {
         $config = CRM_Core_Config::singleton();
         $path = CRM_Utils_Array::value($config->userFrameworkURLVar, $_GET);
         $qfKey = CRM_Utils_Array::value('qfKey', $_GET);
         if ($qfKey) {
             $session->pushUserContext(CRM_Utils_System::url($path, "qfKey={$qfKey}"));
         } else {
             $session->pushUserContext(CRM_Utils_System::url('civicrm/mailing', 'reset=1'));
         }
     } elseif (strpos($session->readUserContext(), 'civicrm/mailing') === FALSE) {
         // use previous context unless mailing is not schedule, CRM-4290
         $session->pushUserContext(CRM_Utils_System::url('civicrm/mailing', 'reset=1'));
     }
 }
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     /*
      * initialize the task and row fields
      */
     parent::preProcess();
 }
예제 #5
0
 /**
  * Build all the data structures needed to build the form.
  *
  * @return void
  */
 public function preProcess()
 {
     // initialize the task and row fields
     parent::preProcess();
     $session = CRM_Core_Session::singleton();
     // Step 1: if we can't get team ID, there's no point continuing.
     $this->_id = $this->get('amtgID');
     if (!isset($this->_id)) {
         $this->_id = CRM_Utils_Request::retrieve('amtgID', 'Positive');
     }
     if (!isset($this->_id)) {
         $this->_id = $session->get('amtgID');
     }
     $session->set('amtgID', $this->_id);
     //@todo Exit more gracefully if id still isn't set
     if (!isset($this->_id)) {
         return;
     }
     $this->_teamValues = array();
     $params = array('id' => $this->_id);
     $this->_team = CRM_Contact_BAO_Group::retrieve($params, $this->_teamValues);
     $this->_context = $this->get('context');
     $this->findTeamPlayers();
     $this->findEligiblePlayers();
     $session = CRM_Core_Session::singleton();
     //$urlParams = 'reset=1&force=1';
     $session->replaceUserContext(CRM_Utils_System::url('civicrm/tournament/team'));
     //search', $urlParams));
 }
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     //check for permission to edit contributions
     if (!CRM_Core_Permission::check('issue cdn tax receipts')) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page', array('domain' => 'org.civicrm.cdntaxreceipts')));
     }
     parent::preProcess();
     $thisYear = date("Y");
     $this->_years = array($thisYear, $thisYear - 1, $thisYear - 2);
     $receipts = array();
     foreach ($this->_years as $year) {
         $receipts[$year] = array('email' => 0, 'print' => 0, 'total' => 0, 'contrib' => 0);
     }
     // count and categorize contributions
     foreach ($this->_contactIds as $id) {
         foreach ($this->_years as $year) {
             list($issuedOn, $receiptId) = cdntaxreceipts_annual_issued_on($id, $year);
             $eligible = count(cdntaxreceipts_contributions_not_receipted($id, $year));
             if ($eligible > 0) {
                 list($method, $email) = cdntaxreceipts_sendMethodForContact($id);
                 $receipts[$year][$method]++;
                 $receipts[$year]['total']++;
                 $receipts[$year]['contrib'] += $eligible;
             }
         }
     }
     $this->_receipts = $receipts;
 }
예제 #7
0
 /**
  * Build all the data structures needed to build the form.
  */
 public function preProcess()
 {
     // initialize the task and row fields
     parent::preProcess();
     $this->_context = $this->get('context');
     $this->_id = $this->get('amtgID');
 }
예제 #8
0
 public function preProcess()
 {
     parent::preProcess();
     list($groupId, $ssId) = $this->createHiddenGroup();
     $mailing = civicrm_api3('Mailing', 'create', array('name' => "", 'campaign_id' => NULL, 'replyto_email' => "", 'subject' => "", 'body_html' => "", 'body_text' => "", 'groups' => array('include' => array($groupId), 'exclude' => array(), 'base' => array()), 'mailings' => array('include' => array(), 'exclude' => array())));
     CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/a/', NULL, TRUE, '/mailing/' . $mailing['id']));
 }
 /**
  * Build all the data structures needed to build the form
  *
  * @access public
  *
  * @return void
  */
 function preProcess()
 {
     parent::preProcess();
     // get rows
     $rows = $this->getContactRows();
     // our array now contains all contacts who can be synced to WordPress
     $this->assign('rows', $rows);
 }
예제 #10
0
 /**
  * Build all the data structures needed to build the form.
  */
 public function preProcess()
 {
     $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE);
     $this->_searchKey = CRM_Utils_Request::retrieve('key', 'String', $this);
     // sort out whether it’s a delete-to-trash, delete-into-oblivion or restore (and let the template know)
     $values = $this->controller->exportValues();
     $this->_skipUndelete = (CRM_Core_Permission::check('access deleted contacts') and (CRM_Utils_Request::retrieve('skip_undelete', 'Boolean', $this) or CRM_Utils_Array::value('task', $values) == CRM_Contact_Task::DELETE_PERMANENTLY));
     $this->_restore = (CRM_Utils_Request::retrieve('restore', 'Boolean', $this) or CRM_Utils_Array::value('task', $values) == CRM_Contact_Task::RESTORE);
     if ($this->_restore && !CRM_Core_Permission::check('access deleted contacts')) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this contact.'));
     } elseif (!CRM_Core_Permission::check('delete contacts')) {
         CRM_Core_Error::fatal(ts('You do not have permission to delete this contact.'));
     }
     $this->assign('trash', Civi::settings()->get('contact_undelete') and !$this->_skipUndelete);
     $this->assign('restore', $this->_restore);
     if ($this->_restore) {
         CRM_Utils_System::setTitle(ts('Restore Contact'));
     }
     if ($cid) {
         if (!CRM_Contact_BAO_Contact_Permission::allow($cid, CRM_Core_Permission::EDIT)) {
             CRM_Core_Error::fatal(ts('You do not have permission to delete this contact. Note: you can delete contacts if you can edit them.'));
         } elseif (CRM_Contact_BAO_Contact::checkDomainContact($cid)) {
             CRM_Core_Error::fatal(ts('This contact is a special one for the contact information associated with the CiviCRM installation for this domain. No one is allowed to delete it because the information is used for special system purposes.'));
         }
         $this->_contactIds = array($cid);
         $this->_single = TRUE;
         $this->assign('totalSelectedContacts', 1);
     } else {
         parent::preProcess();
     }
     $this->_sharedAddressMessage = $this->get('sharedAddressMessage');
     if (!$this->_restore && !$this->_sharedAddressMessage) {
         // we check for each contact for shared contact address
         $sharedContactList = array();
         $sharedAddressCount = 0;
         foreach ($this->_contactIds as $contactId) {
             // check if a contact that is being deleted has any shared addresses
             $sharedAddressMessage = CRM_Core_BAO_Address::setSharedAddressDeleteStatus(NULL, $contactId, TRUE);
             if ($sharedAddressMessage['count'] > 0) {
                 $sharedAddressCount += $sharedAddressMessage['count'];
                 $sharedContactList = array_merge($sharedContactList, $sharedAddressMessage['contactList']);
             }
         }
         $this->_sharedAddressMessage = array('count' => $sharedAddressCount, 'contactList' => $sharedContactList);
         if ($sharedAddressCount > 0) {
             if (count($this->_contactIds) > 1) {
                 // more than one contact deleted
                 $message = ts('One of the selected contacts has an address record that is shared with 1 other contact.', array('plural' => 'One or more selected contacts have address records which are shared with %count other contacts.', 'count' => $sharedAddressCount));
             } else {
                 // only one contact deleted
                 $message = ts('This contact has an address record which is shared with 1 other contact.', array('plural' => 'This contact has an address record which is shared with %count other contacts.', 'count' => $sharedAddressCount));
             }
             CRM_Core_Session::setStatus($message . ' ' . ts('Shared addresses will not be removed or altered but will no longer be shared.'), ts('Shared Addesses Owner'));
         }
         // set in form controller so that queries are not fired again
         $this->set('sharedAddressMessage', $this->_sharedAddressMessage);
     }
 }
예제 #11
0
 public function preProcess()
 {
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE);
     CRM_Contact_Form_Task_SMSCommon::preProcessProvider($this);
     if (!$cid && $this->_context != 'standalone') {
         parent::preProcess();
     }
     $this->assign('single', $this->_single);
     if (CRM_Core_Permission::check('administer CiviCRM')) {
         $this->assign('isAdmin', 1);
     }
 }
예제 #12
0
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     $cid = CRM_Utils_Request::retrieve('cid', $this, false);
     $lid = CRM_Utils_Request::retrieve('lid', $this, false);
     if ($cid) {
         $this->_contactIds = array($cid);
         $this->_single = true;
     } else {
         parent::preProcess();
     }
     $this->createLocation($this->_contactIds, $lid);
     $this->assign('single', $this->_single);
 }
 public function preProcess()
 {
     parent::preProcess();
     // TODO: These would probably not be needed if the logic in \CRM_Simplemail_BAO_SimpleMail::createSmartContactGroupForSearchContacts() is moved into this class' postProcess() method
     simplemail_civicrm_addToSessionScope('createdFromSearch', TRUE);
     simplemail_civicrm_addToSessionScope('contactCountFromSearch', count($this->_contactIds));
     simplemail_civicrm_addToSessionScope('contactIds', $this->_contactIds);
     simplemail_civicrm_addToSessionScope('searchParams', $this->controller->exportValues());
     simplemail_civicrm_addToSessionScope('formValues', $this->get('formValues'));
     simplemail_civicrm_addToSessionScope('customSearchId', $this->get('customSearchID'));
     simplemail_civicrm_addToSessionScope('context', $this->get('context'));
     CRM_Utils_System::redirect('/civicrm/simple-mail#/mailings/new');
 }
예제 #14
0
파일: PDF.php 프로젝트: bhirsch/voipdev
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     CRM_Contact_Form_Task_PDFLetterCommon::preProcess($this);
     // store case id if present
     $this->_caseId = CRM_Utils_Request::retrieve('caseid', 'Positive', $this, false);
     $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, false);
     if ($cid) {
         CRM_Contact_Form_Task_PDFLetterCommon::preProcessSingle($this, $cid);
     } else {
         parent::preProcess();
     }
     $this->assign('single', $this->_single);
 }
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     parent::preProcess();
     // display name and email of all contact ids
     $contactIDs = implode(',', $this->_contactIds);
     $query = "\nSELECT c.id as contact_id, c.display_name as name,\n       c.contact_type as contact_type, e.email as email\nFROM   civicrm_contact c, civicrm_email e\nWHERE  e.contact_id = c.id\nAND    e.is_primary = 1\nAND    c.id IN ( {$contactIDs} )";
     $rows = array();
     $dao = CRM_Core_DAO::executeQuery($query);
     while ($dao->fetch()) {
         $rows[] = array('id' => $dao->contact_id, 'name' => $dao->name, 'contact_type' => $dao->contact_type, 'email' => $dao->email);
     }
     $this->assign('rows', $rows);
 }
예제 #16
0
파일: Delete.php 프로젝트: ksecor/civicrm
 /** 
  * build all the data structures needed to build the form 
  * 
  * @return void 
  * @access public 
  */
 function preProcess()
 {
     //check for delete
     if (!CRM_Core_Permission::check('delete contacts')) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
     }
     $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, false);
     if ($cid) {
         $this->_contactIds = array($cid);
         $this->_single = true;
         $this->assign('totalSelectedContacts', 1);
     } else {
         parent::preProcess();
     }
 }
예제 #17
0
파일: Group.php 프로젝트: ksecor/civicrm
 /** 
  * Function to set variables up before form is built 
  *                                                           
  * @return void 
  * @access public 
  */
 public function preProcess()
 {
     //when user come from search context.
     $context = $this->get('context');
     if ($context == 'search') {
         $searchParams = $this->controller->exportValues();
         if (CRM_Utils_Array::value('task', $searchParams) == 20) {
             parent::preProcess();
         }
     }
     // use previous context unless mailing is not schedule, CRM-4290
     $session =& CRM_Core_Session::singleton();
     if (strpos($session->readUserContext(), 'civicrm/mailing') === false) {
         $session->pushUserContext(CRM_Utils_System::url('civicrm/mailing', 'reset=1'));
     }
 }
예제 #18
0
파일: Email.php 프로젝트: bhirsch/voipdev
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     // store case id if present
     $this->_caseId = CRM_Utils_Request::retrieve('caseid', 'Positive', $this, false);
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, false);
     if ($cid || $this->_context == 'standalone') {
         CRM_Contact_Form_Task_EmailCommon::preProcessSingle($this, $cid);
     } else {
         parent::preProcess();
     }
     $this->assign('single', $this->_single);
     require_once 'CRM/Core/Permission.php';
     if (CRM_Core_Permission::check('administer CiviCRM')) {
         $this->assign('isAdmin', 1);
     }
 }
예제 #19
0
 /** 
  * Function to set variables up before form is built 
  *                                                           
  * @return void 
  * @access public 
  */
 public function preProcess()
 {
     //when user come from search context.
     require_once 'CRM/Contact/Form/Search.php';
     $this->_searchBasedMailing = CRM_Contact_Form_Search::isSearchContext($this->get('context'));
     if ($this->_searchBasedMailing) {
         $searchParams = $this->controller->exportValues();
         if (CRM_Utils_Array::value('task', $searchParams) == 20) {
             parent::preProcess();
         }
     }
     // use previous context unless mailing is not schedule, CRM-4290
     $session = CRM_Core_Session::singleton();
     if (strpos($session->readUserContext(), 'civicrm/mailing') === false) {
         $session->pushUserContext(CRM_Utils_System::url('civicrm/mailing', 'reset=1'));
     }
 }
예제 #20
0
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     parent::preProcess();
     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 = CRM_Core_Session::singleton();
     $url = CRM_Utils_System::url('civicrm/contact/search/custom', $urlParams);
     $session->replaceUserContext($url);
     if (empty($this->_contactIds) || !$session->get('userID')) {
         CRM_Core_Error::statusBounce(ts("Could not find contacts for voter reservation Or Missing Interviewer contact."));
     }
     $this->_interviewerId = $session->get('userID');
 }
예제 #21
0
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     $this->skipOnHold = $this->skipDeceased = FALSE;
     CRM_Contact_Form_Task_PDFLetterCommon::preProcess($this);
     // store case id if present
     $this->_caseId = CRM_Utils_Request::retrieve('caseid', 'Positive', $this, FALSE);
     // retrieve contact ID if this is 'single' mode
     $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE);
     $this->_activityId = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE);
     if ($cid) {
         CRM_Contact_Form_Task_PDFLetterCommon::preProcessSingle($this, $cid);
         $this->_single = TRUE;
         $this->_cid = $cid;
     } else {
         parent::preProcess();
     }
     $this->assign('single', $this->_single);
 }
예제 #22
0
 /** 
  * build all the data structures needed to build the form 
  * 
  * @return void 
  * @access public 
  */
 function preProcess()
 {
     $cid = CRM_Utils_Request::retrieve('cid', $this, false);
     if ($cid) {
         // not sure why this is needed :(
         // also add the cid params to the Menu array
         CRM_Utils_Menu::addParam('cid', $cid);
         // create menus ..
         $startWeight = CRM_Utils_Menu::getMaxWeight('civicrm/contact/view');
         $startWeight++;
         CRM_Core_BAO_CustomGroup::addMenuTabs(CRM_Contact_BAO_Contact::getContactType($cid), 'civicrm/contact/view/cd', $startWeight);
         $this->_contactIds = array($cid);
         $this->_single = true;
         $this->assign('totalSelectedContacts', 1);
     } else {
         parent::preProcess();
     }
 }
예제 #23
0
파일: Delete.php 프로젝트: bhirsch/voipdev
 /** 
  * build all the data structures needed to build the form 
  * 
  * @return void 
  * @access public 
  */
 function preProcess()
 {
     //check for delete
     if (!CRM_Core_Permission::check('delete contacts')) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
     }
     $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, false);
     if ($cid) {
         require_once 'CRM/Contact/BAO/Contact/Permission.php';
         if (!CRM_Contact_BAO_Contact_Permission::allow($cid, CRM_Core_Permission::EDIT)) {
             CRM_Core_Error::fatal(ts('You do not have permission to delete this contact. Note: you can delete contacts if you can edit them.'));
         }
         $this->_contactIds = array($cid);
         $this->_single = true;
         $this->assign('totalSelectedContacts', 1);
     } else {
         parent::preProcess();
     }
 }
예제 #24
0
 /**
  * Build all the data structures needed to build the form.
  */
 public function preProcess()
 {
     parent::preProcess();
     $statusMsg = NULL;
     $contactIds = array();
     if (is_array($this->_contactIds)) {
         $contactIds = array_unique($this->_contactIds);
     }
     if (count($contactIds) != 2) {
         $statusMsg = ts('Merge operation requires selecting two contacts.');
     }
     // do check for same contact type.
     $contactTypes = array();
     if (!$statusMsg) {
         $sql = "SELECT contact_type FROM civicrm_contact WHERE id IN (" . implode(',', $contactIds) . ")";
         $contact = CRM_Core_DAO::executeQuery($sql);
         while ($contact->fetch()) {
             $contactTypes[$contact->contact_type] = TRUE;
             if (count($contactTypes) > 1) {
                 break;
             }
         }
         if (count($contactTypes) > 1) {
             $statusMsg = ts('Selected records must all be the same contact type (i.e. all Individuals).');
         }
     }
     if ($statusMsg) {
         CRM_Core_Error::statusBounce($statusMsg);
     }
     // redirect to merge form directly.
     $cid = $contactIds[0];
     $oid = $contactIds[1];
     //don't allow to delete logged in user.
     $session = CRM_Core_Session::singleton();
     if ($oid == $session->get('userID')) {
         $oid = $cid;
         $cid = $session->get('userID');
     }
     $url = CRM_Utils_System::url('civicrm/contact/merge', "reset=1&cid={$cid}&oid={$oid}");
     // redirect to merge page.
     CRM_Utils_System::redirect($url);
 }
예제 #25
0
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     // store case id if present
     $this->_caseId = CRM_Utils_Request::retrieve('caseid', 'Positive', $this, false);
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, false);
     CRM_Contact_Form_Task_EmailCommon::preProcessFromAddress($this);
     if (!$cid && $this->_context != 'standalone') {
         parent::preProcess();
     }
     //early prevent, CRM-6209
     if (count($this->_contactIds) > CRM_Contact_Form_Task_EmailCommon::MAX_EMAILS_KILL_SWITCH) {
         CRM_Core_Error::statusBounce(ts('Please do not use this task to send a lot of emails (greater than %1). We recommend using CiviMail instead.', array(1 => CRM_Contact_Form_Task_EmailCommon::MAX_EMAILS_KILL_SWITCH)));
     }
     $this->assign('single', $this->_single);
     require_once 'CRM/Core/Permission.php';
     if (CRM_Core_Permission::check('administer CiviCRM')) {
         $this->assign('isAdmin', 1);
     }
 }
예제 #26
0
파일: PickProfile.php 프로젝트: kidaa30/yes
 /**
  * Build all the data structures needed to build the form.
  *
  * @return void
  */
 public function preProcess()
 {
     // initialize the task and row fields
     parent::preProcess();
     $session = CRM_Core_Session::singleton();
     $this->_userContext = $session->readUserContext();
     $validate = FALSE;
     //validations
     if (count($this->_contactIds) > $this->_maxContacts) {
         CRM_Core_Session::setStatus(ts("The maximum number of contacts you can select for Batch Update is %1. You have selected %2. Please select fewer contacts from your search results and try again.", array(1 => $this->_maxContacts, 2 => count($this->_contactIds))), ts('Maximum Exceeded'), 'error');
         $validate = TRUE;
     }
     if (CRM_Contact_BAO_Contact_Utils::checkContactType($this->_contactIds)) {
         CRM_Core_Session::setStatus(ts("Batch update requires that all selected contacts be the same basic type (e.g. all Individuals OR all Organizations...). Please modify your selection and try again."), ts('Contact Type Mismatch'), 'error');
         $validate = TRUE;
     }
     // than redirect
     if ($validate) {
         CRM_Utils_System::redirect($this->_userContext);
     }
 }
예제 #27
0
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 public function preProcess()
 {
     if (CRM_Core_BAO_MailSettings::defaultDomain() == "FIXME.ORG") {
         CRM_Core_Error::fatal(ts('The <a href="%1">default mailbox</a> has not been configured. You will find <a href="%2">more info in our online user and administrator guide.</a>', array(1 => CRM_Utils_System::url('civicrm/admin/mailSettings', 'reset=1'), 2 => "http://book.civicrm.org/user/initial-set-up/email-system-configuration")));
     }
     //when user come from search context.
     $this->_searchBasedMailing = CRM_Contact_Form_Search::isSearchContext($this->get('context'));
     if ($this->_searchBasedMailing) {
         $searchParams = $this->controller->exportValues();
         // number of records that were selected - All or Few.
         $this->_resultSelectOption = $searchParams['radio_ts'];
         if (CRM_Utils_Array::value('task', $searchParams) == 20) {
             parent::preProcess();
         }
     }
     // use previous context unless mailing is not schedule, CRM-4290
     $session = CRM_Core_Session::singleton();
     if (strpos($session->readUserContext(), 'civicrm/mailing') === FALSE) {
         $session->pushUserContext(CRM_Utils_System::url('civicrm/mailing', 'reset=1'));
     }
 }
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     /*
      * initialize the task and row fields
      */
     parent::preProcess();
     $session = CRM_Core_Session::singleton();
     $this->_userContext = $session->readUserContext();
     $validate = FALSE;
     //validations
     if (count($this->_contactIds) > $this->_maxContacts) {
         CRM_Core_Session::setStatus("The maximum number of contacts you can select for Batch Update is {$this->_maxContacts}. You have selected " . count($this->_contactIds) . ". Please select fewer contacts from your search results and try again.");
         $validate = TRUE;
     }
     if (CRM_Contact_BAO_Contact_Utils::checkContactType($this->_contactIds)) {
         CRM_Core_Session::setStatus("Batch update requires that all selected contacts be the same type (e.g. all Individuals OR all Organizations...). Please modify your selected contacts and try again.");
         $validate = TRUE;
     }
     // than redirect
     if ($validate) {
         CRM_Utils_System::redirect($this->_userContext);
     }
 }
예제 #29
0
 /**
  * Build all the data structures needed to build the form.
  */
 public function preProcess()
 {
     $this->skipOnHold = $this->skipDeceased = FALSE;
     CRM_Contact_Form_Task_PDFLetterCommon::preProcess($this);
     // store case id if present
     $this->_caseId = CRM_Utils_Request::retrieve('caseid', 'Positive', $this, FALSE);
     // retrieve contact ID if this is 'single' mode
     $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE);
     if ($cid) {
         // this is true in non-search context / single mode
         // in search context 'id' is the default profile id for search display
         // CRM-11227
         $this->_activityId = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE);
     }
     if ($cid) {
         CRM_Contact_Form_Task_PDFLetterCommon::preProcessSingle($this, $cid);
         $this->_single = TRUE;
         $this->_cid = $cid;
     } else {
         parent::preProcess();
     }
     $this->assign('single', $this->_single);
 }
예제 #30
0
 /**
  * Build the form object.
  */
 public function preProcess()
 {
     CRM_Core_Form_RecurringEntity::preProcess('civicrm_activity');
     $this->_atypefile = CRM_Utils_Array::value('atypefile', $_GET);
     $this->assign('atypefile', FALSE);
     if ($this->_atypefile) {
         $this->assign('atypefile', TRUE);
     }
     $session = CRM_Core_Session::singleton();
     $this->_currentUserId = $session->get('userID');
     $this->_currentlyViewedContactId = $this->get('contactId');
     if (!$this->_currentlyViewedContactId) {
         $this->_currentlyViewedContactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     }
     $this->assign('contactId', $this->_currentlyViewedContactId);
     // Give the context.
     if (!isset($this->_context)) {
         $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
         if (CRM_Contact_Form_Search::isSearchContext($this->_context)) {
             $this->_context = 'search';
         } elseif (!in_array($this->_context, array('dashlet', 'dashletFullscreen')) && $this->_currentlyViewedContactId) {
             $this->_context = 'activity';
         }
         $this->_compContext = CRM_Utils_Request::retrieve('compContext', 'String', $this);
     }
     $this->assign('context', $this->_context);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this);
     if ($this->_action & CRM_Core_Action::DELETE) {
         if (!CRM_Core_Permission::check('delete activities')) {
             CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
         }
     }
     // CRM-6957
     // When we come from contact search, activity id never comes.
     // So don't try to get from object, it might gives you wrong one.
     // if we're not adding new one, there must be an id to
     // an activity we're trying to work on.
     if ($this->_action != CRM_Core_Action::ADD && get_class($this->controller) != 'CRM_Contact_Controller_Search') {
         $this->_activityId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     }
     $this->_activityTypeId = CRM_Utils_Request::retrieve('atype', 'Positive', $this);
     $this->assign('atype', $this->_activityTypeId);
     $this->assign('activityId', $this->_activityId);
     // Check for required permissions, CRM-6264.
     if ($this->_activityId && in_array($this->_action, array(CRM_Core_Action::UPDATE, CRM_Core_Action::VIEW)) && !CRM_Activity_BAO_Activity::checkPermission($this->_activityId, $this->_action)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
     }
     if ($this->_action & CRM_Core_Action::VIEW && CRM_Activity_BAO_Activity::checkPermission($this->_activityId, CRM_Core_Action::UPDATE)) {
         $this->assign('permission', 'edit');
     }
     if (!$this->_activityTypeId && $this->_activityId) {
         $this->_activityTypeId = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $this->_activityId, 'activity_type_id');
     }
     // Assigning Activity type name.
     if ($this->_activityTypeId) {
         $activityTName = CRM_Core_OptionGroup::values('activity_type', FALSE, FALSE, FALSE, 'AND v.value = ' . $this->_activityTypeId, 'label');
         if ($activityTName[$this->_activityTypeId]) {
             $this->_activityTypeName = $activityTName[$this->_activityTypeId];
             $this->assign('activityTName', $activityTName[$this->_activityTypeId]);
         }
     }
     // Set title.
     if (isset($activityTName)) {
         $activityName = CRM_Utils_Array::value($this->_activityTypeId, $activityTName);
         $this->assign('pageTitle', ts('%1 Activity', array(1 => $activityName)));
         if ($this->_currentlyViewedContactId) {
             $displayName = CRM_Contact_BAO_Contact::displayName($this->_currentlyViewedContactId);
             // Check if this is default domain contact CRM-10482.
             if (CRM_Contact_BAO_Contact::checkDomainContact($this->_currentlyViewedContactId)) {
                 $displayName .= ' (' . ts('default organization') . ')';
             }
             CRM_Utils_System::setTitle($displayName . ' - ' . $activityName);
         } else {
             CRM_Utils_System::setTitle(ts('%1 Activity', array(1 => $activityName)));
         }
     }
     // Check the mode when this form is called either single or as
     // search task action.
     if ($this->_activityTypeId || $this->_context == 'standalone' || $this->_currentlyViewedContactId) {
         $this->_single = TRUE;
         $this->assign('urlPath', 'civicrm/activity');
     } else {
         // Set the appropriate action.
         $url = CRM_Utils_System::currentPath();
         $urlArray = explode('/', $url);
         $searchPath = array_pop($urlArray);
         $searchType = 'basic';
         $this->_action = CRM_Core_Action::BASIC;
         switch ($searchPath) {
             case 'basic':
                 $searchType = $searchPath;
                 $this->_action = CRM_Core_Action::BASIC;
                 break;
             case 'advanced':
                 $searchType = $searchPath;
                 $this->_action = CRM_Core_Action::ADVANCED;
                 break;
             case 'builder':
                 $searchType = $searchPath;
                 $this->_action = CRM_Core_Action::PROFILE;
                 break;
             case 'custom':
                 $this->_action = CRM_Core_Action::COPY;
                 $searchType = $searchPath;
                 break;
         }
         parent::preProcess();
         $this->_single = FALSE;
         $this->assign('urlPath', "civicrm/contact/search/{$searchType}");
         $this->assign('urlPathVar', "_qf_Activity_display=true&qfKey={$this->controller->_key}");
     }
     $this->assign('single', $this->_single);
     $this->assign('action', $this->_action);
     if ($this->_action & CRM_Core_Action::VIEW) {
         // Get the tree of custom fields.
         $this->_groupTree =& CRM_Core_BAO_CustomGroup::getTree('Activity', $this, $this->_activityId, 0, $this->_activityTypeId);
     }
     if ($this->_activityTypeId) {
         // Set activity type name and description to template.
         list($this->_activityTypeName, $activityTypeDescription) = CRM_Core_BAO_OptionValue::getActivityTypeDetails($this->_activityTypeId);
         $this->assign('activityTypeName', $this->_activityTypeName);
         $this->assign('activityTypeDescription', $activityTypeDescription);
     }
     // set user context
     $urlParams = $urlString = NULL;
     $qfKey = CRM_Utils_Request::retrieve('key', 'String', $this);
     if (!$qfKey) {
         $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this);
     }
     // Validate the qfKey.
     if (!CRM_Utils_Rule::qfKey($qfKey)) {
         $qfKey = NULL;
     }
     if ($this->_context == 'fulltext') {
         $keyName = '&qfKey';
         $urlParams = 'force=1';
         $urlString = 'civicrm/contact/search/custom';
         if ($this->_action == CRM_Core_Action::UPDATE) {
             $keyName = '&key';
             $urlParams .= '&context=fulltext&action=view';
             $urlString = 'civicrm/contact/view/activity';
         }
         if ($qfKey) {
             $urlParams .= "{$keyName}={$qfKey}";
         }
         $this->assign('searchKey', $qfKey);
     } elseif (in_array($this->_context, array('standalone', 'home', 'dashlet', 'dashletFullscreen'))) {
         $urlParams = 'reset=1';
         $urlString = 'civicrm/dashboard';
     } elseif ($this->_context == 'search') {
         $urlParams = 'force=1';
         if ($qfKey) {
             $urlParams .= "&qfKey={$qfKey}";
         }
         $path = CRM_Utils_System::currentPath();
         if ($this->_compContext == 'advanced') {
             $urlString = 'civicrm/contact/search/advanced';
         } elseif ($path == 'civicrm/group/search' || $path == 'civicrm/contact/search' || $path == 'civicrm/contact/search/advanced' || $path == 'civicrm/contact/search/custom' || $path == 'civicrm/group/search') {
             $urlString = $path;
         } else {
             $urlString = 'civicrm/activity/search';
         }
         $this->assign('searchKey', $qfKey);
     } elseif ($this->_context != 'caseActivity') {
         $urlParams = "action=browse&reset=1&cid={$this->_currentlyViewedContactId}&selectedChild=activity";
         $urlString = 'civicrm/contact/view';
     }
     if ($urlString) {
         $session->pushUserContext(CRM_Utils_System::url($urlString, $urlParams));
     }
     // hack to retrieve activity type id from post variables
     if (!$this->_activityTypeId) {
         $this->_activityTypeId = CRM_Utils_Array::value('activity_type_id', $_POST);
     }
     // when custom data is included in this page
     if (!empty($_POST['hidden_custom'])) {
         // We need to set it in the session for the code below to work.
         // CRM-3014
         // Need to assign custom data subtype to the template.
         $this->set('type', 'Activity');
         $this->set('subType', $this->_activityTypeId);
         $this->set('entityId', $this->_activityId);
         CRM_Custom_Form_CustomData::preProcess($this, NULL, $this->_activityTypeId, 1, 'Activity', $this->_activityId);
         CRM_Custom_Form_CustomData::buildQuickForm($this);
         CRM_Custom_Form_CustomData::setDefaultValues($this);
     }
     // add attachments part
     CRM_Core_BAO_File::buildAttachment($this, 'civicrm_activity', $this->_activityId, NULL, TRUE);
     // figure out the file name for activity type, if any
     if ($this->_activityTypeId && ($this->_activityTypeFile = CRM_Activity_BAO_Activity::getFileForActivityTypeId($this->_activityTypeId, $this->_crmDir))) {
         $this->assign('activityTypeFile', $this->_activityTypeFile);
         $this->assign('crmDir', $this->_crmDir);
     }
     $this->setFields();
     if ($this->_activityTypeFile) {
         $className = "CRM_{$this->_crmDir}_Form_Activity_{$this->_activityTypeFile}";
         $className::preProcess($this);
     }
     $this->_values = $this->get('values');
     if (!is_array($this->_values)) {
         $this->_values = array();
         if (isset($this->_activityId) && $this->_activityId) {
             $params = array('id' => $this->_activityId);
             CRM_Activity_BAO_Activity::retrieve($params, $this->_values);
         }
         $this->set('values', $this->_values);
     }
     if ($this->_action & CRM_Core_Action::UPDATE) {
         CRM_Core_Form_RecurringEntity::preProcess('civicrm_activity');
     }
 }