/** * @todo Sprawdzić wysyłanie maili, być może jest zdublowany mechanizm wysyłania powiadomien w przypadku akceptacji * * @param type $data * @param Zend_Db_Table_Row $row * @return type * @throws Exception */ public function saveFormData($data, Zend_Db_Table_Row $row = null) { $utils = new Logic_Utilities(); $delegation = new Delegation(); $dataRow = array_shift($data); if (null === $row) { $id_state = $dataRow["id_state"]; unset($dataRow["id_state"]); try { $idRow = $delegation->createRow($dataRow)->save(); } catch (Exception $exc) { throw new Exception('Błąd podczas zapisu do bazy danych! Treść: ' . $exc->getMessage()); } $delegationNo = Logic_Utilities::generate_deleg_no($idRow); try { $delegation->findOne($idRow)->setFromArray(array('deleg_no' => $delegationNo, 'id_state' => $id_state, 'send_mail' => $dataRow['send_mail']))->save(); } catch (Exception $exc) { throw new Exception('Błąd podczas zapisu numeru delegacji! Treść: ' . $exc->getMessage()); } } else { try { if ($data['id_state'] != Logic_ItemAbstract::STATE_NEW) { if ($row->id_state != $data['id_state']) { $row->setFromArray($data)->save(); } else { throw new Exception('Krok który próbowałeś zapisać został już wykonany.'); } } else { if (!(($row->id_state == Logic_ItemAbstract::STATE_APPROVED || $row->id_state == Logic_ItemAbstract::STATE_ACCEPTED) && $data['id_state'] == Logic_ItemAbstract::STATE_NEW)) { $row->setFromArray($data)->save(); } else { throw new Exception('Delegacja jest już w przesłana do kolejnego etapu'); } } } catch (Exception $exc) { throw new Exception('Błąd podczas zapisu do bazy danych! Treść: ' . $exc->getMessage()); } } if ($dataRow['id_state'] === self::STATE_NEW) { return $delegationNo; } // to może być zdublowany mechanizm wysyłania maila /* if ($dataRow['id_state'] !== self::STATE_ACCEPTED) { $mailer = new Logic_Mailer(Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('view'), null); $user = Zend_Auth::getInstance()->getIdentity(); $params['user_full_name'] = $user->first_name . ' ' . $user->surname; $params['email'] = $user->email; try { $mailer->acceptDelegation($params); } catch (Exception $exc) { throw new Exception('Błąd podczas wysyłania maila do osoby akceptującej delegację! Treść: ' . $exc->getMessage()); } } */ return $delegationNo; }
private function _rowToObject(Zend_Db_Table_Row $row) { $userRow = $row->findParentRow('User_Model_DbTable_Staffmembre', 'Staffmembre'); $user = new User_Model_Staffmembre(); $user->setId($userRow->usm_id)->setName($userRow->usm_name); $issueStatus = new Project_Model_IssueStatus(); $issueStatus->setId($row->istut_id)->setTitle($row->istut_title)->setUser($user); return $issueStatus; }
/** * @return string */ public function get($field, $default = NULL) { $data = $this->_row->toArray(); if (array_key_exists($field, $data)) { return $data[$field]; } else { return $default; } }
/** * adds a new message * * @return void * @param Zend_Db_Table_Row $feed the related feed * @param string $message the message text */ public function add($feed, $message) { // insert new error message $this->insert(array('feed' => $feed->id, 'datetime' => date('Y-m-d H:i:s'), 'message' => $message)); // set error in feed table $feed->error = 1; $feed->save(); return $message; }
private function _rowToObject(Zend_Db_Table_Row $row) { $issueRow = $row->findParentRow('Project_Model_Issue', 'Issue'); $issue = new Project_Model_Issue(); $issue->setId($issueRow->iss_id)->setName($issueRow->iss_name); $userRow = $row->findParentRow('User_Model_DbTable_Staffmembre', 'Staffmembre'); $user = new User_Model_Staffmembre(); $user->setId($userRow->usm_id)->setName($userRow->usm_name); $issueComment = new Project_Model_IssueComment(); $issueComment->setId($row->isc_id)->setContent($row->isc_content)->setDate($row->isc_date)->setIssue($issue)->setUser($user); return $issueComment; }
public function save() { // write to master database pool $this->getTable()->getMasterAdapter(); //logStd(get_class($this).'->save()', 'Write to MASTER.'); return parent::save(); }
public function process(array $post, Zend_Db_Table_Row $row) { $this->setDefaults($row->toArray()); // if (sizeof($post) && $this->isValid($post)) { try { $row->setFromArray($this->getValues()); $row->save(); return true; } catch (Exception $e) { $this->addDescription('There was an error saving your details'); return $this; } } return $this; }
public function save() { if (!isset($this->_struct)) { throw new Axis_NSTree_Node_Exception('Операция save() для узлов присутствующих в дереве. ' . 'Предварительно вставьте узел appendChild() или insertSibling()'); } parent::save(); }
protected function _fetchPageOptions($id, $idsOnly = true) { $entries = array(); $row = new Zend_Db_Table_Row(array('table' => $this, 'data' => array('id' => $id))); $optionsData = $row->findManyToManyRowset('Application_Model_DbTable_PageOption', 'Application_Model_DbTable_PageHasOption')->toArray(); if ($idsOnly) { if (empty($optionsData)) { return $optionsData; } foreach ($optionsData as $optionData) { $entries[] = $optionData['id']; } return $entries; } return $optionsData; }
public function save() { $dbtable = $this->_table; if ($dbtable->_cache) { $dbtable->_cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG); } return parent::save(); }
/** * Reconnect primary table row to database after unserializing. * * @return void */ public function __wakeup() { if (false === is_null($this->_primaryTableRow)) { $tableclass = $this->_primaryTableRow->getTableClass(); $table = Opus_Db_TableGateway::getInstance($tableclass); $this->_primaryTableRow->setTable($table); } }
/** * Get the default form values */ protected function _getDefaultFormValues() { $return = array(); if ($this->_item !== null) { $return = $this->_item->toArray(); } return $return; }
public function delete() { // сначала грохнем параметры подтовара $db = $this->getTable()->getAdapter(); $where = array(); $where[] = "subproduct_id = " . $this->id; $db->delete("subproduct_params_values", $where); return parent::delete(); }
function delete() { $model = new RM_Dependencies(); $dependencies = $model->getDependencies($this); foreach ($dependencies as $row) { $row->delete(); } parent::delete(); }
public function delete() { if ($this->task == self::JOB_TASK_IMPORT) { $params = $this->getParams(); if (!@unlink($params['destination'] . '/' . $params['name'])) { throw new Zend_Db_Table_Row_Exception(_('Failed to delete file') . ' `' . $params['name'] . '`'); } } return parent::delete(); }
/** * Seta o form como de edição de registro * * A diferença entre o form de cadastro e edição é que o no form de edição * não se deve comparar o ID do usuário na hora de procurar por um nome * ou email existentes na base de dados. * Por isso, adicionamos a option 'exclude' do validator * Zend_Validate_Db_NoRecordExists passando o campo ID e o valor do usuário * que está sendo editado para ser utilizado na clausua where da query, * buscando apenas registros cujo id seja diferente do id do usuário * * @param Zend_Db_Table_Row $row * @return Application_Form_User */ public function setAsEditForm(Zend_Db_Table_Row $row) { $this->populate($row->toArray()); $this->setAction(sprintf('/users/edit/id/%d', $row->id)); $this->getElement('name') ->getValidator('Db_NoRecordExists') ->setExclude(array( 'field' => 'id', 'value' => $row->id )); $this->getElement('email') ->getValidator('Db_NoRecordExists') ->setExclude(array( 'field' => 'id', 'value' => $row->id )); return $this; }
/** * @todo Wysyłka maila * @param type $data */ public function saveFormData($data, Zend_Db_Table_Row $row = null) { $delegation = new DelegationSettlement(); $utils = new Logic_Utilities(); $idConvert = Zend_Controller_Action_HelperBroker::getStaticHelper('IdConvert'); $uri = 'delegations/accept/id_delegation/' . $idConvert->strToHex($data['id_delegation']); $data['id_address_history'] = $this->getCurrentAddress(); //$data['id_address_history'] = $this->addAddressToHistory(); try { $db = Base_Model_Table::getDefaultAdapter(); $db->beginTransaction(); if ($row) { if ($data['id_state'] != Logic_ItemAbstract::STATE_NEW_2) { if ($row->id_state != $data['id_state'] && !($row->id_state == Logic_ItemAbstract::STATE_APPROVED_2 && $data['id_state'] == Logic_ItemAbstract::STATE_NEW_2)) { $row->findParentRow('DelegationSettlement')->setFromArray(array_merge($this->getCurrentValuesIds(), $data))->save(); $this->saveLocations($row->id, $data['departure']); } else { throw new Exception('Krok który próbowałeś zapisać został już wykonany.'); } } else { if (!($row->id_state == Logic_ItemAbstract::STATE_APPROVED_2 && $data['id_state'] == Logic_ItemAbstract::STATE_NEW_2)) { $row->findParentRow('DelegationSettlement')->setFromArray(array_merge($this->getCurrentValuesIds(), $data))->save(); $this->saveLocations($row->id, $data['departure']); } else { throw new Exception('Delegacja została już wysłana do zatwierdzenia.'); } } } else { $idRow = $delegation->createRow(array_merge($this->getCurrentValuesIds(), $data))->save(); $this->saveLocations($idRow, $data['departure']); } $db->commit(); } catch (Exception $exc) { $db->rollBack(); //diee($exc->getTraceAsString()); throw new Exception("Błąd podczas dodawania nowego rozliczenia! Treść: " . $exc->getMessage()); } }
/** * (non-PHPdoc) * @see Zend_Controller_Action::init() */ public function init() { parent::init(); // Load the module, controller and action names $this->view->module_name = $this->_moduleName = ucfirst($this->getRequest()->getModuleName()); $this->view->controller_name = $this->_controllerName = ucfirst($this->getRequest()->getControllerName()); $this->view->action_name = $this->_actionName = ucfirst($this->getRequest()->getActionName()); // Load the translation name $this->view->translation_name = $this->_translationName = $this->_moduleName . $this->_controllerName . $this->_actionName; // Load the log $this->_log = $this->getInvokeArg('bootstrap')->log; // Load the flashmessenger $this->_flashMessenger = $this->_helper->getHelper('FlashMessenger'); $this->view->messages = $this->_flashMessenger->getMessages(); // Load the user $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $this->_user = $auth->getIdentity(); if ($this->_user->isConnected()) { $this->_user->connect(); } } }
public function __call($func, $args) { if (preg_match("/get(\\w+)/", $func, $matches)) { $key = strtolower($matches[1]); $value = $this->{$key}; if ($value) { return htmlspecialchars($value); } if (!array_key_exists($key, $this->_defaultValues)) { throw new Exception("No default value for {$key}"); } return $this->_defaultValues[$key]; } else { parent::__call($func, $args); } }
public function delete($doAudit = true) { //Fire the before delete function if ($this->beforeDelete() === false) { return false; } $this->row->delete(); // only unharvest if this item is harvested if ($this->harvestOnProcess) { $this->unharvest(); } if ($doAudit) { $this->audit('Delete'); } //Fire the after delete function $this->afterDelete(); return true; }
/** * Factory method to turn one * database row into an * instantiated object * @param Zend_Db_Table_Row $item * @return mixed */ public function factoryItem(Zend_Db_Table_Row $item) { $arr_data = $item->toArray(); $object = new $this->model_class($arr_data); return $object; }
/** * Delete a role from the database */ public function delete() { $this->row->delete(); return $this; }
public function rowToObject(Zend_Db_Table_Row $row) { $userRow = $row->findParentRow('User_Model_DbTable_Staffmembre', 'Staffmembre'); $user = new User_Model_Staffmembre(); $user->setId($userRow->usm_id)->setLogin($userRow->usm_login); $project = new Project_Model_Project(); $project->setId($row->proj_id)->setName($row->proj_name)->setDescription($row->proj_desc)->setDate($row->proj_date)->setStatus($row->proj_statut)->setHomepageUrl($row->proj_hpurl)->setDocUrl($row->proj_docurl)->setUser($user); return $project; }
/** * fix the positions of all feeds in this category * feed positions of 0 1 3 4 5 will become 0 1 2 3 4 * * @return void * @param Zend_Db_Table_Row $category category model */ public function fixPositions($category) { $position = 0; foreach ($category->findDependentRowset('application_models_feeds', null, $this->select()->order('position ASC')) as $feed) { $feed->position = $position++; $feed->save(); } }
/** * saves the new icon * * @return void * @param Zend_Db_Table_Row $feed the current feed */ public function saveIcon($feed) { $icon = false; $iconLoader = Zend_Controller_Action_HelperBroker::getStaticHelper('icon'); // use favicon url (if given) if (strlen(trim($feed->favicon)) != 0) { if (@file_get_contents($feed->favicon) !== false) { $icon = $iconLoader->loadIconFile($feed->favicon, Zend_Registry::get('config')->favicons->path); } } // try url of the htmlurl rss feed if ($icon === false && strlen($feed->htmlurl) > 0) { $icon = $iconLoader->load($feed->htmlurl, Zend_Registry::get('config')->favicons->path); } // use datasource icon if ($icon === false) { $icon = Zend_Controller_Action_HelperBroker::getStaticHelper('pluginloader')->getPlugin($feed->source)->icon; } // save icon url $feed->icon = $icon; $feed->dirtyicon = 0; $feed->save(); }
/** * Set a row field value. * * @internal */ public function __set($columnName, $value) { $setter = Benri_Util_String::camelize($columnName, true); if (method_exists($this, $setter = "set{$setter}")) { $value = call_user_func_array([$this, $setter], [$value]); } return parent::__set($columnName, $value); }
public function delete() { $tenant = $this->code; $result = parent::delete(); $solr = OpenSKOS_Solr::getInstance()->delete('tenant:' . $tenant); return $result; }
/** * Save the row * * @param object $result The current result item * @return void * @throws */ protected function _saveRow($result) { try { $this->_tableRow->setFromArray($this->_data); unset($this->_data); $this->_tableRow->save(); if ($this->_showProgress && !empty($result->id) && !empty($result->name)) { echo '<h1>' . 'Successful ' . $this->_rowAction . ' of ' . $result->id . ': ' . $result->name . '</h1>' . PHP_EOL; } } catch (Exception $e) { if ($this->_showProgress && !empty($result->id) && !empty($result->name)) { echo '<h1 class="error">' . 'Error attempting to ' . $this->_rowAction . ' ' . $result->id . ': ' . $result->name . '</h1>' . PHP_EOL; } throw new TicketEvolution_DataLoader_Exception($e); } }
/** * Deletes this model response */ public function delete() { $this->modelResponseRow->delete(); }
public function testTableRowExceptionBogusPrimaryKey() { $table = $this->_table['bugs_products']; $bogusData = array('bug_id' => 3, 'foo' => 'bar'); $row = new Zend_Db_Table_Row(array('table' => $table, 'data' => $bogusData)); try { $rowsAffected = $row->delete(); $this->fail('Expected to catch Zend_Db_Table_Row_Exception'); } catch (Zend_Exception $e) { $this->assertType('Zend_Db_Table_Row_Exception', $e, 'Expecting object of type Zend_Db_Table_Row_Exception, got ' . get_class($e)); $this->assertEquals("The specified Table 'My_ZendDbTable_TableBugsProducts' does not have the same primary key as the Row", $e->getMessage()); } }