コード例 #1
0
 private function addEditHandler($p_sMode = 'create')
 {
     $this->loginCheck();
     $bEdit = $p_sMode === 'edit';
     $oTicket = new APP_Model_Ticket();
     $oForm = new PPI_Model_Form();
     $oForm->init('ticket_create');
     $oForm->disableSubmit();
     $oForm->setFormStructure($oTicket->getAddEditFormStructure($p_sMode, array('isAdmin' => $this->getAuthData(false)->role_name !== 'member')));
     // Get the ticket ID
     $iTicketID = $this->get($p_sMode, 0);
     if ($oForm->isSubmitted() && $oForm->isValidated()) {
         $aSubmitValues = $oForm->getSubmitValues();
         $aSubmitValues += array('status' => 'open', 'severity' => 'minor', 'assigned_user_id' => 0, 'user_id' => $this->getAuthData(false)->id, 'created' => time());
         if ($bEdit && $iTicketID > 0) {
             $oTicket->update($aSubmitValues, $oTicket->getPrimaryKey() . " = " . $oTicket->quote($iTicketID));
         } else {
             $iTicketID = $oTicket->insert($aSubmitValues);
         }
         $this->setFlashMessage('Ticket successfully ' . ($bEdit ? 'updated.' : 'created'));
         $this->redirect('ticket/view/' . $iTicketID . '/' . str_replace(' ', '-', $aSubmitValues['title']));
     }
     if ($p_sMode === 'edit' && $iTicketID > 0) {
         $oForm->setDefaults($oTicket->find($iTicketID));
     }
     $formBuilder = $oForm->getRenderInformation();
     $aTicket = $oTicket->find($iTicketID);
     $this->load('ticket/create', compact('aTicket', 'formBuilder'));
 }
コード例 #2
0
ファイル: Admin.php プロジェクト: hjr3/ppi-skeleton-app
 /**
  *
  * @param string $p_sMode The Mode (Create or Edit)
  * @return void
  */
 protected function ticketAddEdit($p_sMode = 'create')
 {
     $bEdit = $p_sMode == 'edit';
     $oTicket = new APP_Model_Ticket();
     $oForm = new PPI_Model_Form();
     $oForm->init('admin_ticket_addedit');
     $oForm->setFormStructure($oTicket->getAdminAddEditFormStructure($p_sMode));
     if ($oForm->isSubmitted() && $oForm->isValidated()) {
         $aSubmitValues = $oForm->getSubmitValues();
         if (!$bEdit) {
             $aSubmitValues['user_id'] = $this->getAuthData(false)->id;
             $aSubmitValues['created'] = time();
         }
         // Edit mode to set the primary key so that it performs an update
         if ($bEdit && ($iTicketID = $this->oInput->get($p_sMode)) > 0) {
             $aSubmitValues[$oTicket->getPrimaryKey()] = $iTicketID;
         }
         // Put the record (insert/update)
         $oTicket->putRecord($aSubmitValues);
         $this->setFlashMessage('Ticket successfully ' . ($bEdit ? 'updated' : 'created') . '.');
         $this->redirect('admin/ticket');
     }
     if ($bEdit === true) {
         if (($iTicketID = $this->oInput->get('edit', 0)) < 1) {
             throw new PPI_Exception('Invalid User ID: ' . $iTicketID);
         }
         // Set the defaults here
         $oForm->setDefaults($oTicket->find($iTicketID));
     }
     $aViewVars = array('bEdit' => $bEdit, 'formBuilder' => $oForm->getRenderInformation(), 'leftMenu' => true);
     $this->adminLoad('admin/ticket_addedit', $aViewVars);
 }
コード例 #3
0
ファイル: User.php プロジェクト: revolveweb/ppi-framework
 /**
  * This function cannot be called directly, it must be extended by a child class and then called.
  *
  * @return void
  */
 protected function register()
 {
     // If they are already logged in, send them to the postloginredirect location
     if ($this->isLoggedIn() === true) {
         $this->postLoginRedirect();
     }
     // Init
     $oForm = new PPI_Model_Form();
     $oUser = new APP_Model_User();
     $oForm->init('user_register', '', 'post');
     $oForm->setFormStructure($oUser->_registerFormStructure);
     // If the form has been submitted and has been validated
     if ($oForm->isSubmitted() && $oForm->isValidated()) {
         // Get the info from the form and pass it to the usermodel for insertion
         $oUser->putRecord($oForm->getSubmitValues());
         // Redirect to the login page
         $this->redirect('user/login');
     }
     $this->addStylesheet('formbuilder.css');
     $this->addJavascript('jquery-validate/jquery.validate.min.js');
     // show our registration page
     $this->load('user/register', array('formBuilder' => $oForm->getRenderInformation()));
 }