function updateAction() { // ****************************** UPDATE record ********************************** $media_id = trim($this->_request->getPost('mediaid')); $pool_id = trim($this->_request->getPost('poolid')); $volume_name = trim($this->_request->getPost('volumename')); if (!empty($media_id) && !empty($pool_id)) { $media = new Media(); // remember old value of poolid for this mediaid $old_pool_id = $media->getPoolId($media_id); // update Media record $data = array('poolid' => $pool_id, 'volstatus' => trim($this->_request->getPost('volstatus')), 'volretention' => (int) trim($this->_request->getPost('volretention')) * 86400, 'voluseduration' => (int) trim($this->_request->getPost('voluseduration')), 'recycle' => trim($this->_request->getPost('recycle')), 'slot' => trim($this->_request->getPost('slot')), 'inchanger' => trim($this->_request->getPost('inchanger')), 'maxvoljobs' => trim($this->_request->getPost('maxvoljobs')), 'maxvolfiles' => trim($this->_request->getPost('maxvolfiles')), 'comment' => trim($this->_request->getPost('comment'))); $where = $media->getAdapter()->quoteInto('MediaId = ?', $media_id); $res = $media->update($data, $where); // if Volume moved to another Pool if ($old_pool_id != $pool_id) { // to count Volume count on both Pools $old_volume_count = $media->getVolumeCountByPool($old_pool_id); $volume_count = $media->getVolumeCountByPool($pool_id); $pool = new Pool(); // update old Pool record $data = array('numvols' => $old_volume_count); $where = $pool->getAdapter()->quoteInto('PoolId = ?', $old_pool_id); $res = $pool->update($data, $where); // update new Pool record $data = array('numvols' => $volume_count); $where = $pool->getAdapter()->quoteInto('PoolId = ?', $pool_id); $res = $pool->update($data, $where); } // send email if ($res) { $email = new MyClass_SendEmail(); // $from_email, $from_name, $to_email, $to_name, $subj, $body $email->mySendEmail($this->view->config->webacula->email->from, 'Webacula Volume controller', $this->view->config->webacula->email->to_admin, 'Webacula admin', $this->view->translate->_('Webacula : Updated Volume parameters'), $this->view->translate->_('Media Id') . ': ' . $media_id . "\n" . $this->view->translate->_('Volume Name') . ': ' . $volume_name . "\n\n"); } } $this->_redirect("/volume/detail/mediaid/{$media_id}"); return; }
/** * LogBook modify Record action * */ function modifyAction() { $this->view->title = $this->view->translate->_("Logbook: modify record"); $this->view->wblogbook = new Wblogbook(); $this->view->amessages = array(); // ****************************** UPDATE record ********************************** if ($this->_request->isPost() && $this->_request->getPost('hiddenModify') && $this->_request->getPost('act') == 'update') { $logid = trim($this->_request->getPost('logid')); // ********************* validate datetime $validator_datetime = new MyClass_Validate_Datetime(); $logDateCreate = trim($this->_request->getPost('logDateCreate')); if (!$validator_datetime->isValid($logDateCreate)) { $this->view->amessages = array_merge($this->view->amessages, $validator_datetime->getMessages()); } // ********************* validate text // This filter returns the input string, with all HTML and PHP tags stripped from it, // except those that have been explicitly allowed. Zend_Loader::loadClass('Zend_Filter_StripTags'); // allow : // construct($tagsAllowed = null, $attributesAllowed = null, $commentsAllowed = false) $strip_tags = new Zend_Filter_StripTags($this->aAllowedTags, $this->aAllowedAttrs, false); $logTxt = trim($strip_tags->filter($this->_request->getPost('logTxt'))); $validator_nonempty = new Zend_Validate_NotEmpty(); if (!$validator_nonempty->isValid($logTxt)) { $this->view->amessages = array_merge($this->view->amessages, $validator_nonempty->getMessages()); } // *** validate pseudo tag BACULA_JOBID $validator_baculajobid = new MyClass_Validate_BaculaJobId(); if (!$validator_baculajobid->isValid($logTxt)) { $this->view->amessages = array_merge($this->view->amessages, $validator_baculajobid->getMessages()); } // *** validate pseudo tag LOGBOOK_ID $validator_logbookid = new MyClass_Validate_LogbookId(); if (!$validator_logbookid->isValid($logTxt)) { $this->view->amessages = array_merge($this->view->amessages, $validator_logbookid->getMessages()); } // ********************* final // update record into database if (empty($this->view->amessages)) { // validation is OK. add record into logbook $table = new wbLogBook(); $data = array('logDateCreate' => $logDateCreate, 'logDateLast' => date('Y-m-d H:i:s', time()), 'logTypeId' => (int) trim($this->_request->getPost('logTypeId')), 'logTxt' => $logTxt, 'logIsDel' => (int) trim($this->_request->getPost('isdel'))); $where = $table->getAdapter()->quoteInto('logId = ?', $logid); $res = $table->update($data, $where); // send email if ($res) { $email = new MyClass_SendEmail(); // $from_email, $from_name, $to_email, $to_name, $subj, $body $email->mySendEmail($this->view->config->webacula->email->from, $this->view->translate->_('Webacula Logbook'), $this->view->config->webacula->email->to_admin, $this->view->translate->_('Webacula admin'), $this->view->translate->_('Webacula Logbook Update record'), $this->view->translate->_('Create record :') . ' ' . $data['logDateCreate'] . "\n" . $this->view->translate->_('Update record :') . ' ' . $data['logDateLast'] . "\n" . $this->view->translate->_('Type record :') . ' ' . $data['logTypeId'] . "\n" . $this->view->translate->_("Text :") . "\n-------\n" . $data['logTxt'] . "\n-------\n\n"); } $this->_redirect('/wblogbook/index'); return; } // ********************* save user input for correct this $this->view->wblogbook->logTxt = $strip_tags->filter($this->_request->getPost('logTxt')); $this->view->wblogbook->logTypeId = $this->_request->getPost('logTypeId'); } // ****************************** DELETE record ********************************** if ($this->_request->isPost() && $this->_request->getPost('hiddenModify') && $this->_request->getPost('act') == 'delete') { $logid = trim($this->_request->getPost('logid')); $table = new wbLogBook(); $data = array('logIsDel' => '1'); $where = $table->getAdapter()->quoteInto('logId = ?', $logid); $res = $table->update($data, $where); // send email if ($res) { $email = new MyClass_SendEmail(); // $from_email, $from_name, $to_email, $to_name, $subj, $body $email->mySendEmail($this->view->config->webacula->email->from, $this->view->translate->_('Webacula Logbook'), $this->view->config->webacula->email->to_admin, $this->view->translate->_('Webacula admin'), $this->view->translate->_('Webacula Logbook Delete record'), $this->view->translate->_("LogId record :") . " " . $logid . "\n"); } $this->_redirect('/wblogbook/index'); return; } // ****************************** UNDELETE record ********************************** if ($this->_request->isPost() && $this->_request->getPost('hiddenModify') && $this->_request->getPost('act') == 'undelete') { $logid = trim($this->_request->getPost('logid')); $table = new wbLogBook(); $data = array('logIsDel' => '0'); $where = $table->getAdapter()->quoteInto('logId = ?', $logid); $res = $table->update($data, $where); // send email if ($res) { $email = new MyClass_SendEmail(); // $from_email, $from_name, $to_email, $to_name, $subj, $body $email->mySendEmail($this->view->config->webacula->email->from, $this->view->translate->_('Webacula Logbook'), $this->view->config->webacula->email->to_admin, $this->view->translate->_('Webacula admin'), $this->view->translate->_('Webacula Logbook UnDelete record'), $this->view->translate->_("LogId record :") . " " . $logid . "\n"); } $this->_redirect('/wblogbook/index'); return; } // ********************* READ ORIGINAL RECORD from database **************** if ($this->_request->isPost()) { $logid = trim($this->_request->getPost('logid')); // get data from table $logs = new wbLogBook(); $where = $logs->getAdapter()->quoteInto('logId = ?', $logid); $row = $logs->fetchRow($where); if ($row) { $this->view->wblogbook->logId = $row->logid; $this->view->wblogbook->logDateCreate = $row->logdatecreate; $this->view->wblogbook->logTxt = $row->logtxt; $this->view->wblogbook->logTypeId = $row->logtypeid; $this->view->wblogbook->logIsDel = $row->logisdel; } } // for draw form Zend_Loader::loadClass('Wblogtype'); // get data from wbLogType $typs = new Wblogtype(); $this->view->typs = $typs->fetchAll(); // common fileds $this->view->wblogbook->logDateLast = date('Y-m-d H:i:s', time()); $this->view->hiddenModify = 1; $this->view->aAllowedTags = $this->aAllowedTags; }
protected function emailForgotPassword($user_email, $user_name = '', $pwd) { Zend_Loader::loadClass('MyClass_SendEmail'); $config = Zend_Registry::get('config'); $email = new MyClass_SendEmail(); $body = sprintf($this->view->translate->_("Hello,\n\nThis is an automated message from site %s, please do not reply!\n\nYou have or someone impersonating you has requested to change your password\nfrom IP : %s\n\nNew Password: %s\n\nOnce logged in you can change your password.\n\nIf you are not the person who made this request\nsend email to the site admin : %s\n\nThanks! \n"), $this->_request->getServer('SERVER_NAME'), $this->_request->getServer('REMOTE_ADDR'), $pwd, $config->webacula->email->to_admin); // $from_email, $from_name, $to_email, $to_name, $subj, $body return $email->mySendEmail($config->webacula->email->from, $this->view->translate->_('Webacula password manager'), $user_email, $user_name, $this->view->translate->_('New Webacula password'), $body); }