public static function getInstance() { if (self::$_instance === null) { self::$_instance = new self(); } return self::$_instance; }
/** * comments */ public function RenderAlert() { // $m = new Digitalus_View_Message(); $m = Digitalus_View_Message::getInstance(); // $ve = new Digitalus_View_Error(); $ve = Digitalus_View_Error::getInstance(); $alert = false; $message = null; $verror = null; $alert = null; if ($ve->hasErrors()) { // $verror = '<p>'. $this->view->getTranslation('The following errors have occurred') . ':</p>' . $this->view->HtmlList($ve->get()); // $alert .= '<fieldset><legend>'. $this->view->getTranslation('Errors') . '</legend>' . $verror . '</fieldset>'; $verror = "<div class='title'>Errors !!!</div>" . $this->view->HtmlList($ve->get(), false, array('class' => 'box-item')); $alert .= "<div class='box-error'>" . $verror . '</div>'; } if ($m->hasMessage()) { // $message .= '<p>' . $m->get() . '</p>'; // $alert .= '<fieldset><legend>'. $this->view->getTranslation('Message') . '</legend>' . $message . '</fieldset>'; $alert .= "<div class='tag-info'>{$m->get()}</div>"; } //after this renders it clears the errors and messages $m->clear(); $ve->clear(); return $alert; }
/** * comments */ public function renderAlert() { $m = new Digitalus_View_Message(); $ve = new Digitalus_View_Error(); $alert = false; $message = null; $verror = null; $alert = null; if ($ve->hasErrors()) { $verror = '<p>' . $this->view->getTranslation('The following errors have occurred') . ':</p>' . $this->view->htmlList($ve->get()); $alert .= '<fieldset class="warning"><legend>' . $this->view->getTranslation('Errors') . '</legend>' . $verror . '</fieldset>'; } if ($m->hasMessage()) { $message .= '<p>' . $m->get() . '</p>'; $alert .= '<fieldset class="note"><legend>' . $this->view->getTranslation('Message') . '</legend>' . $message . '</fieldset>'; } //after this renders it clears the errors and messages $m->clear(); $ve->clear(); return $alert; }
function init() { $this->_errors = Digitalus_View_Error::getInstance(); $this->_message = Digitalus_View_Message::getInstance(); $this->_cacheManager = Digitalus_Cache_Manager::getInstance(); $this->view->currentModuleUrl = $this->_currentModuleUrl = $this->_request->getBaseUrl() . '/' . $this->_request->getModuleName(); $this->view->currentControllerUrl = $this->_currentControllerUrl = $this->_currentModuleUrl . '/' . $this->_request->getControllerName(); $this->view->currentActionUrl = $this->_currentActionUrl = $this->_currentControllerUrl . '/' . $this->_request->getActionName(); //set Helper // $this->view->addHelperPath('Isc/View/Helper', 'Isc_View_Helper'); // $this->view->addHelperPath('Isc/View/Helper/IscFrom', 'Isc_View_Helper_IscFrom'); }
public function updatePassword($user_id, $password, $confirmationRequire = true, $confirmation = null) { $errors = Digitalus_View_Error::getInstance(); $message = Digitalus_View_Message::getInstance(); $person = $this->find($user_id)->current(); if ($person) { $person->password = md5($password); $result = $person->save(); $message->add('Updated password successfully !'); return $result; } else { $errors->add('User not exists.'); return false; } }
/** * Reset password action * * @return void */ public function resetPasswordAction() { if (strtolower($_SERVER['REQUEST_METHOD']) == 'post') { $userName = Digitalus_Filter_Post::get('name'); $user = new Model_User(); $match = $user->getUserByUsername($userName); if ($match) { //create the password $password = Digitalus_Toolbox_String::random(10); //10 character random string //load the email data $data['username'] = $match->name; $data['first_name'] = $match->first_name; $data['last_name'] = $match->last_name; $data['email'] = $match->email; $data['password'] = $password; //get standard site settings $s = new Model_SiteSettings(); $settings = $s->toObject(); $emailFormat = "Hello %s (<em>%s %s</em>),<br /><br />Your password has been reset to:<br /><br /><strong>%s</strong><br /><br />You can login again with Your new Password.<br /><br />Best wishes,<br />%s"; $emailText = sprintf($emailFormat, $data['username'], $data['first_name'], $data['last_name'], $data['password'], $settings->default_email_sender); //attempt to send the email $mail = new Digitalus_Mail(); if ($mail->send($match->email, array($settings->default_email, $settings->default_email_sender), 'Password Reminder', $emailText)) { //update the user's password $match->password = md5($password); $match->save(); //save the new password $m = new Digitalus_View_Message(); $m->add($this->view->getTranslation('Your password has been reset for security and sent to your email address')); } else { $e = new Digitalus_View_Error(); $e->add($this->view->getTranslation('Sorry, there was an error sending you your updated password. Please contact us for more help.')); } } else { $e = new Digitalus_View_Error(); $e->add($this->view->getTranslation('Sorry, we could not locate your account. Please contact us to resolve this issue.')); } $url = 'admin/auth/login'; $this->_redirect($url); } }
public function updateFromPost() { $this->_action = 'update'; $this->_loadPost(); //try to run the before method if (method_exists($this, 'before')) { $this->before(); } if (method_exists($this, 'beforeUpdate')) { $this->beforeUpdate(); } $this->validateData(); // $id = $this->_data['id']; // unset($this->_data['id']); if (!$this->_errors->hasErrors()) { //there were no errors validating the data $id = $this->_data[$this->_primaryKey]; unset($this->_data[$this->_primaryKey]); // $this->update($this->_data, 'id=' . $id); $number_rows_updated = $this->update($this->_data, $this->_primaryKey . '=' . $id); $this->_message = Digitalus_View_Message::getInstance(); $this->_message->add('Updated current row database successfully !!!'); //try to run the after method if (method_exists($this, 'after')) { $this->after($id); } //return $this->find($id)->current(); //i like to return the whole data object return $number_rows_updated; } return false; }