/** * Function to build the form * * @return None * @access public */ public function buildQuickForm() { $profileID = CRM_Core_DAO::getFieldValue('CRM_Auction_DAO_Auction', $this->_aid, 'donor_profile_id'); if (!$profileID) { CRM_Core_Error::fatal('Profile not configured for this auction.'); } require_once 'CRM/Auction/BAO/Item.php'; if (CRM_Auction_BAO_Item::isEmailInProfile($profileID)) { $this->assign('profileDisplay', TRUE); } $fields = NULL; require_once "CRM/Core/BAO/UFGroup.php"; if ($this->_donorID) { if (CRM_Core_BAO_UFGroup::filterUFGroups($profileID, $this->_donorID)) { $fields = CRM_Core_BAO_UFGroup::getFields($profileID, FALSE, CRM_Core_Action::ADD); } $this->addFormRule(array('CRM_Auction_Form_ItemAccount', 'formRule'), $this); } else { require_once 'CRM/Core/BAO/CMSUser.php'; CRM_Core_BAO_CMSUser::buildForm($this, $profileID, TRUE); $fields = CRM_Core_BAO_UFGroup::getFields($profileID, FALSE, CRM_Core_Action::ADD); } if ($fields) { $this->assign('fields', $fields); $addCaptcha = FALSE; foreach ($fields as $key => $field) { if (isset($field['data_type']) && $field['data_type'] == 'File') { // ignore file upload fields continue; } require_once "CRM/Core/BAO/UFGroup.php"; require_once "CRM/Profile/Form.php"; CRM_Core_BAO_UFGroup::buildProfile($this, $field, CRM_Profile_Form::MODE_CREATE); $this->_fields[$key] = $field; if ($field['add_captcha']) { $addCaptcha = TRUE; } } if ($addCaptcha) { require_once 'CRM/Utils/ReCAPTCHA.php'; $captcha =& CRM_Utils_ReCAPTCHA::singleton(); $captcha->add($this); $this->assign("isCaptcha", TRUE); } } $button[] = array('type' => 'next', 'name' => ts('Continue >>'), 'spacing' => ' ', 'isDefault' => TRUE); $this->addButtons($button); }
/** * 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); // 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/Item.php'; CRM_Auction_BAO_Item::setIsActive($id, 0); } elseif ($action & CRM_Core_Action::ENABLE) { require_once 'CRM/Auction/BAO/Item.php'; CRM_Auction_BAO_Item::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_Item_Delete', 'Delete Item', $action); $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, 0); $controller->set('id', $id); $controller->process(); return $controller->run(); } elseif ($action & CRM_Core_Action::COPY) { $this->copy(); } // finally browse the auctions $this->browse(); // parent run parent::run(); }
/** * Function to process the form * * @access public * @return None */ public function postProcess() { if ($this->_action & CRM_Core_Action::VIEW) { return; } else { if ($this->_action & CRM_Core_Action::DELETE) { CRM_Auction_BAO_Item::del($this->_id); return; } } $params = $this->controller->exportValues($this->_name); $params['id'] = $this->_id; $params['auction_id'] = $this->_aid; $params['donor_id'] = $this->_donorID; if ($this->_action == CRM_Core_Action::ADD) { $params['creator_id'] = $this->_donorID; $params['created_date'] = date('YmdHis'); } // format checkboxes foreach ($this->_checkboxes as $name => $title) { $params[$name] = CRM_Utils_Array::value($name, $params, false); } // does this auction require approval $params['is_approved'] = $this->_auctionValues['is_approval_needed'] ? 0 : 1; CRM_Auction_BAO_Item::add($params); if ($this->controller->getButtonName() == $this->getButtonName('next', 'new')) { $session =& CRM_Core_Session::singleton(); //CRM_Core_Session::setStatus(ts(' You can add another profile field.')); $session->replaceUserContext(CRM_Utils_System::url('civicrm/auction/item', "reset=1&action=add&aid={$this->_aid}")); } }