public function formAction() { // action body $defaultFormData = null; $shortId = $this->_getParam('id'); if (!empty($shortId) && ($this->_config->site->allow->anonymousEdit || $this->_config->site->allow->ownEdit)) { if ($this->_config->site->allow->ownEdit && !$this->_config->site->allow->anonymousEdit) { $row = $this->_pastebinObj->findShortId($shortId); if ($row->ipAddress != $_SERVER['REMOTE_ADDR']) { throw new Exception('You do not have permission to edit this'); } } $defaultFormData = $this->_pastebinObj->findShortId($shortId); } $request = $this->getRequest(); $form = new Default_Form_Pastebin($defaultFormData); if ($this->getRequest()->isPost()) { if ($form->isValid($request->getPost())) { $model = new Default_Model_Pastebin($form->getValues()); $shortId = $model->save(); $this->_redirect('/pastebin/index/id/' . $shortId); } } $this->view->form = $form; }
public function fetchAll() { $resultSet = $this->getDbTable()->fetchAll(null, 'created DESC'); $entries = array(); foreach ($resultSet as $row) { $entry = new Default_Model_Pastebin(); $entry->setId($row->id)->setShortId($row->short_id)->setName($row->name)->setLanguage($row->language)->setCode($row->code)->setIpAddress($row->ip_address)->setCreated($row->created)->setMapper($this); $entries[] = $entry; } return $entries; }