/** * Run the page. * * This method is called after the page is created. It checks for the * type of action and executes that action. * Finally it calls the parent's run method. * * @return mixed */ public function run() { // get the requested action $action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse'); // assign vars to templates $this->assign('action', $action); $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, 0); // set breadcrumb to append to 2nd layer pages $breadCrumb = array(array('title' => ts('Manage Contribution Pages'), 'url' => CRM_Utils_System::url(CRM_Utils_System::currentPath(), 'reset=1'))); // what action to take ? if ($action & CRM_Core_Action::ADD) { $session = CRM_Core_Session::singleton(); $session->pushUserContext(CRM_Utils_System::url(CRM_Utils_System::currentPath(), 'action=browse&reset=1')); $controller = new CRM_Contribute_Controller_ContributionPage(NULL, $action); CRM_Utils_System::setTitle(ts('Manage Contribution Page')); CRM_Utils_System::appendBreadCrumb($breadCrumb); return $controller->run(); } elseif ($action & CRM_Core_Action::UPDATE) { $config = CRM_Core_Config::singleton(); // assign vars to templates $this->assign('id', $id); $this->assign('title', CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $id, 'title')); $this->assign('is_active', CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $id, 'is_active')); if (in_array('CiviMember', $config->enableComponents)) { $this->assign('CiviMember', TRUE); } } elseif ($action & CRM_Core_Action::COPY) { // @todo Unused local variable can be safely removed. // But are there any side effects of CRM_Core_Session::singleton() that we // need to preserve? $session = CRM_Core_Session::singleton(); CRM_Core_Session::setStatus(ts('A copy of the contribution page has been created'), ts('Successfully Copied'), 'success'); $this->copy(); } elseif ($action & CRM_Core_Action::DELETE) { CRM_Utils_System::appendBreadCrumb($breadCrumb); $session = CRM_Core_Session::singleton(); $session->pushUserContext(CRM_Utils_System::url(CRM_Utils_System::currentPath(), 'reset=1&action=browse')); $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, 0); $query = "\nSELECT ccp.title\nFROM civicrm_contribution_page ccp\nJOIN civicrm_pcp cp ON ccp.id = cp.page_id\nWHERE cp.page_id = {$id}\nAND cp.page_type = 'contribute'\n"; if ($pageTitle = CRM_Core_DAO::singleValueQuery($query)) { CRM_Core_Session::setStatus(ts('The \'%1\' cannot be deleted! You must Delete all Personal Campaign Page(s) related with this contribution page prior to deleting the page.', array(1 => $pageTitle)), ts('Deletion Error'), 'error'); CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/contribute', 'reset=1')); } $controller = new CRM_Core_Controller_Simple('CRM_Contribute_Form_ContributionPage_Delete', 'Delete Contribution Page', CRM_Core_Action::DELETE); $controller->set('id', $id); $controller->process(); return $controller->run(); } else { // finally browse the contribution pages $this->browse(); CRM_Utils_System::setTitle(ts('Manage Contribution Pages')); } return parent::run(); }
/** * Run the page. * * This method is called after the page is created. It checks for the * type of action and executes that action. * Finally it calls the parent's run method. * * @return void * @access public * */ function run() { // get the requested action $action = CRM_Utils_Request::retrieve('action', 'String', $this, false, 'browse'); // default to 'browse' // assign vars to templates $this->assign('action', $action); $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, false, 0); // set breadcrumb to append to 2nd layer pages $breadCrumb = array(array('title' => ts('Manage Contribution Pages'), 'url' => CRM_Utils_System::url(CRM_Utils_System::currentPath(), 'reset=1'))); // what action to take ? if ($action & CRM_Core_Action::ADD) { $session = CRM_Core_Session::singleton(); $session->pushUserContext(CRM_Utils_System::url(CRM_Utils_System::currentPath(), 'action=browse&reset=1')); require_once 'CRM/Contribute/Controller/ContributionPage.php'; $controller = new CRM_Contribute_Controller_ContributionPage(null, $action); CRM_Utils_System::setTitle(ts('Manage Contribution Page')); CRM_Utils_System::appendBreadCrumb($breadCrumb); return $controller->run(); } else { if ($action & CRM_Core_Action::UPDATE) { CRM_Utils_System::appendBreadCrumb($breadCrumb); $session = CRM_Core_Session::singleton(); $session->pushUserContext(CRM_Utils_System::url(CRM_Utils_System::currentPath(), "action=update&reset=1&id={$id}")); $config = CRM_Core_Config::singleton(); CRM_Utils_System::setTitle(ts('Configure Contribution Page')); // assign vars to templates $this->assign('id', $id); $this->assign('title', CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $id, 'title')); $this->assign('is_active', CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $id, 'is_active')); if (in_array('CiviMember', $config->enableComponents)) { $this->assign('CiviMember', true); } } else { if ($action & CRM_Core_Action::COPY) { $session = CRM_Core_Session::singleton(); CRM_Core_Session::setStatus(ts('A copy of the contribution page has been created')); $this->copy(); } else { if ($action & CRM_Core_Action::DELETE) { CRM_Utils_System::appendBreadCrumb($breadCrumb); $session = CRM_Core_Session::singleton(); $session->pushUserContext(CRM_Utils_System::url(CRM_Utils_System::currentPath(), 'reset=1&action=browse')); $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, false, 0); $query = "\nSELECT ccp.title\nFROM civicrm_contribution_page ccp \nJOIN civicrm_pcp cp ON ccp.id = cp.contribution_page_id\nWHERE cp.contribution_page_id = {$id}"; if ($pageTitle = CRM_Core_DAO::singleValueQuery($query)) { CRM_Core_Session::setStatus(ts('The \'%1\' cannot be deleted! You must Delete all Personal Campaign Page(s) related with this contribution page prior to deleting the page.', array(1 => $pageTitle))); CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/contribute', 'reset=1')); } $controller = new CRM_Core_Controller_Simple('CRM_Contribute_Form_ContributionPage_Delete', 'Delete Contribution Page', CRM_Core_Action::DELETE); $controller->set('id', $id); $controller->process(); return $controller->run(); } else { // finally browse the contribution pages $this->browse(); CRM_Utils_System::setTitle(ts('Manage Contribution Pages')); } } } } return parent::run(); }