예제 #1
0
 /**
  * Set variables up before form is built.
  */
 public function preProcess()
 {
     $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add');
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     // check for action permissions.
     if (!CRM_Core_Permission::checkActionPermission('CiviPledge', $this->_action)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
     }
     $this->assign('action', $this->_action);
     $this->assign('context', $this->_context);
     if ($this->_action & CRM_Core_Action::DELETE) {
         return;
     }
     $this->userDisplayName = $this->userEmail = NULL;
     if ($this->_contactID) {
         list($this->userDisplayName, $this->userEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactID);
         $this->assign('displayName', $this->userDisplayName);
     }
     $this->setPageTitle(ts('Pledge'));
     // build custom data
     CRM_Custom_Form_CustomData::preProcess($this, NULL, NULL, 1, 'Pledge', $this->_id);
     $this->_values = array();
     // current pledge id
     if ($this->_id) {
         // get the contribution id
         $this->_contributionID = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_PledgePayment', $this->_id, 'contribution_id', 'pledge_id');
         $params = array('id' => $this->_id);
         CRM_Pledge_BAO_Pledge::getValues($params, $this->_values);
         $this->_isPending = CRM_Pledge_BAO_Pledge::pledgeHasFinancialTransactions($this->_id, CRM_Utils_Array::value('status_id', $this->_values)) ? FALSE : TRUE;
     }
     // get the pledge frequency units.
     $this->_freqUnits = CRM_Core_OptionGroup::values('recur_frequency_units');
     $this->_fromEmails = CRM_Core_BAO_Email::getFromEmail();
 }