/** * 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'); // assign vars to templates $this->assign('action', $action); $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, 0); $this->_aid = CRM_Utils_Request::retrieve('aid', 'Positive', $this); // set breadcrumb to append to 2nd layer pages $breadCrumb = array(array('title' => ts('Manage Items'), 'url' => CRM_Utils_System::url(CRM_Utils_System::currentPath(), 'reset=1'))); // what action to take ? if ($action & CRM_Core_Action::DISABLE) { require_once 'CRM/Auction/BAO/Auction.php'; CRM_Auction_BAO_Auction::setIsActive($id, 0); } elseif ($action & CRM_Core_Action::ENABLE) { require_once 'CRM/Auction/BAO/Auction.php'; CRM_Auction_BAO_Auction::setIsActive($id, 1); } elseif ($action & CRM_Core_Action::DELETE) { $session = CRM_Core_Session::singleton(); $session->pushUserContext(CRM_Utils_System::url(CRM_Utils_System::currentPath(), 'reset=1&action=browse')); $controller = new CRM_Core_Controller_Simple('CRM_Auction_Form_Auction_Delete', 'Delete Auction', $action); $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, 0); $controller->set('id', $id); $controller->process(); return $controller->run(); } // finally browse the auctions $this->browse(); // parent run parent::run(); }
/** * Function to set variables up before form is built * * @return void * @access public */ function preProcess() { $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, false, 'add'); $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this); $this->_aid = CRM_Utils_Request::retrieve('aid', 'Positive', $this, true); if (($this->_action & CRM_Core_Action::VIEW || $this->_action & CRM_Core_Action::UPDATE || $this->_action & CRM_Core_Action::DELETE) && !$this->_id) { CRM_Core_Error::fatal("I am not sure which item you looking for."); } require_once 'CRM/Auction/BAO/Auction.php'; $params = array('id' => $this->_aid); $this->_auctionValues = array(); CRM_Auction_BAO_Auction::retrieve($params, $this->_auctionValues); $this->assign('auctionTitle', $this->_auctionValues['auction_title']); // set donor id $session =& CRM_Core_Session::singleton(); $this->_donorID = $this->get('donorID'); $this->assign('donorName', CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_donorID, 'display_name')); // also set user context $session->pushUserContext(CRM_Utils_System::url('civicrm/auction/item', "reset=1&aid={$this->_aid}")); }
/** * Function to process the form * * @access public * * @return None */ public function postProcess() { if ($this->_action & CRM_Core_Action::VIEW) { return; } elseif ($this->_action & CRM_Core_Action::DELETE) { CRM_Auction_BAO_Auction::del($this->_id); return; } $params = $this->controller->exportValues($this->_name); $params['id'] = $this->_id; // format date params foreach ($this->_dates as $name => $title) { $params[$name] = CRM_Utils_Date::format($params[$name]); } // format checkboxes foreach ($this->_checkboxes as $name => $title) { $params[$name] = CRM_Utils_Array::value($name, $params, FALSE); } CRM_Auction_BAO_Auction::add($params); }
/** * This function is to make a copy of a Auction, including * all the fields in the event wizard * * @return void * @access public */ function copy() { $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, true, 0, 'GET'); require_once 'CRM/Auction/BAO/Auction.php'; CRM_Auction_BAO_Auction::copy($id); return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/event/manage', 'reset=1')); }