/** * Function to set variables up before form is built * * @param null * * @return void * @access public */ public function preProcess() { if ($this->_action & CRM_Core_Action::DELETE) { //check permission for action. if (!CRM_Core_Permission::checkActionPermission('CiviContribute', $this->_action)) { CRM_Core_Error::fatal(ts('You do not have permission to access this page')); } $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this); $this->_title = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_PCP', $this->_id, 'title'); $this->assign('title', $this->_title); parent::preProcess(); } if (!$this->_action) { $action = CRM_Utils_Array::value('action', $_GET); $id = CRM_Utils_Array::value('id', $_GET); switch ($action) { case 'delete': require_once 'CRM/Contribute/BAO/PCP.php'; $title = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_PCP', $id, 'title'); CRM_Contribute_BAO_PCP::delete($id); CRM_Core_Session::setStatus(ts("The Campaign Page '%1' has been deleted.", array(1 => $title))); break; case 'disable': require_once 'CRM/Contribute/BAO/PCP.php'; CRM_Contribute_BAO_PCP::setDisable($id, '0'); break; case 'enable': require_once 'CRM/Contribute/BAO/PCP.php'; CRM_Contribute_BAO_PCP::setDisable($id, '1'); break; } $session =& CRM_Core_Session::singleton(); CRM_Utils_System::redirect($session->popUserContext()); } }
/** * Function to set variables up before form is built * * @param null * * @return void * @access public */ public function preProcess() { if ($this->_action & CRM_Core_Action::DELETE) { //check permission for action. if (!CRM_Core_Permission::checkActionPermission('CiviContribute', $this->_action)) { CRM_Core_Error::fatal(ts('You do not have permission to access this page')); } $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this); $this->_title = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_PCP', $this->_id, 'title'); $this->assign('title', $this->_title); parent::preProcess(); } if (!$this->_action) { $this->_action = CRM_Utils_Array::value('action', $_GET); $this->_id = CRM_Utils_Array::value('id', $_GET); } else { $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this); } $session = CRM_Core_Session::singleton(); $context = $session->popUserContext(); $userID = $session->get('userID'); //do not allow destructive actions without permissions $permission = false; if (CRM_Core_Permission::check('administer CiviCRM') || $userID && CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_PCP', $this->_id, 'contact_id') == $userID) { $permission = true; } if ($permission && $this->_id) { require_once 'CRM/Contribute/BAO/PCP.php'; $this->_title = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_PCP', $this->_id, 'title'); switch ($this->_action) { case CRM_Core_Action::DELETE: case 'delete': CRM_Contribute_BAO_PCP::delete($this->_id); CRM_Core_Session::setStatus(ts("The Campaign Page '%1' has been deleted.", array(1 => $this->_title))); break; case CRM_Core_Action::DISABLE: case 'disable': CRM_Contribute_BAO_PCP::setDisable($this->_id, '0'); CRM_Core_Session::setStatus(ts("The Campaign Page '%1' has been disabled.", array(1 => $this->_title))); break; case CRM_Core_Action::ENABLE: case 'enable': CRM_Contribute_BAO_PCP::setDisable($this->_id, '1'); CRM_Core_Session::setStatus(ts("The Campaign Page '%1' has been enabled.", array(1 => $this->_title))); break; } if ($context) { CRM_Utils_System::redirect($context); } } }