public function loginAction() { $form = new Admin_Form_Login(); $form->setAction($this->baseUrl . '/public/index/login'); if ($this->_request->isPost() && $form->isValid($_POST)) { $uri = Digitalus_Filter_Post::get('uri'); $username = Digitalus_Filter_Post::get('adminUsername'); $password = Digitalus_Filter_Post::get('adminPassword'); $auth = new Digitalus_Auth($username, $password); $result = $auth->authenticate(); if (!$result) { $e = new Digitalus_View_Error(); $e->add($this->view->getTranslation('The username or password you entered was not correct.')); } else { $uri = Digitalus_Toolbox_Page::getHomePageName(); $this->_redirect($uri); } } # ---------------------------------------------------------------------------- # $this->page->content = array('label' => 'Auth', 'headline' => $this->view->getTranslation('Authorisation required'), 'content' => $this->view->partial('partials/login.phtml', array('form' => $form))); $this->page->defaultContent = $this->page->content; // load the view Digitalus_Builder::loadPage(null, 'load_view.xml', $this->page, $this->view); // render the page $this->view->page = $this->page; $this->view->layout()->page = $this->page->getParam('xhtml'); $this->renderScript('index/index.phtml'); }
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; } }
public static function upload($file, $path, $filename = null, $createPath = true, $base = '.') { $view = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->view; $e = new Digitalus_View_Error(); if ($file['error'] == 4 || empty($file['name'])) { return; } if (self::isAllowed($file['type'])) { $path = self::getMediaPath($path); //default to the name on the client machine if (is_null($filename)) { $filename = $file['name']; } $filename = str_replace('_', '-', $filename); $filename = str_replace(' ', '-', $filename); $path = str_replace(self::rootDirectory(), '', $path); $path = Digitalus_Toolbox_String::stripUnderscores($path); $path = Digitalus_Toolbox_String::stripLeading('/', $path); /* * This fixes an issue when the system is installed on a path other than * root. Path should contain a path that is relative to the (cms) root * index.php (not root to the public_html of the web server (as it was trying * to do before). */ $config = Zend_Registry::get('config'); $path = $config->filepath->media . '/' . $path; if ($createPath) { //attempt to create the new path Digitalus_Filesystem_Dir::makeRecursive($base, $path); } //clean the filename $filename = Digitalus_Filesystem_File::cleanFilename($filename); $filename = basename($filename); $path .= '/' . $filename; if (move_uploaded_file($file['tmp_name'], $path)) { //return the filepath if things worked out //this is relative to the site root as this is the format that will be required for links and what not $fullPath = Digitalus_Toolbox_String::stripLeading($base . '/', $path); return $fullPath; } else { $e->add($view->getTranslation('An error occurred uploading the file' . ': ' . $file['name'])); } } else { $e->add($view->getTranslation('This filetype is not allowed' . ': ' . $file['type'])); } }
/** * The default public action - display login form and login * * @return void */ public function indexAction() { $loginForm = new Admin_Form_Login(); $loginForm->setAction($this->baseUrl . '/' . Digitalus_Toolbox_Page::getCurrentPageName(false)); if ($this->_request->isPost() && $loginForm->isValid($_POST)) { $username = Digitalus_Filter_Post::get('adminUsername'); $password = Digitalus_Filter_Post::get('adminPassword'); $auth = new Digitalus_Auth($username, $password); $result = $auth->authenticate(); if (is_null($result)) { $e = new Digitalus_View_Error(); $e->add($this->view->getTranslation('The username or password you entered was not correct.')); # } else { # $this->_redirect(Digitalus_Toolbox_Page::getHomePageName()); } } $this->view->form = $loginForm; }
/** * Edit action * * @return void */ public function editAction() { $page = new Model_Page(); $pageId = $this->_request->getParam('id', 0); $language = $this->_request->getParam('language', $page->getDefaultLanguage()); $currentPage = $page->open($pageId, $language); // load the template and form $template = $page->getTemplate($pageId); // @todo: refactor this into some sort of helper function $templateParts = explode('_', $template); $currentTemplate = $templateParts[0]; $currentTemplatePage = $templateParts[1]; $templatePath = BASE_PATH . '/templates/public/' . $currentTemplate; $templateConfig = new Zend_Config_Xml($templatePath . '/pages/' . $currentTemplatePage . '.xml'); $pageTemplate = new Digitalus_Interface_Template(); $form = $pageTemplate->getForm($templatePath . '/layouts/' . $templateConfig->layout); $form->setAction($this->baseUrl . '/admin/page/edit'); $this->view->contentPanes = $form->modifyEditActionForm(); $elmPageName = $form->getElement('name'); $elmPageName->addValidators(array(array('PagenameExistsNot', true, array('exclude' => $currentPage->page->name)))); if (!is_object($currentPage)) { $url = 'admin/page'; $e = new Digitalus_View_Error(); $e->add($this->view->getTranslation('Sorry, there was an error opening your page')); $this->_redirect($url); } //process the form if this is a post back if ($this->_request->isPost() && $form->isValid($_POST)) { $values = $form->getValues(); unset($values['submit']); unset($values['form_instance']); $currentPage = $page->edit($values); } else { if ($currentPage->content) { $data = $currentPage->content; } else { $data = array(); } $data['id'] = $pageId; $data['name'] = $currentPage->page->name; $data['language'] = $language; $form->populate($data); } $this->view->currentVersion = $language; $this->view->pageId = $pageId; //main content form $this->view->form = $form; $this->view->page = $currentPage; //meta data form $mdlMeta = new Model_MetaData(); $metaData = $mdlMeta->asArray($pageId); $metaData['page_id'] = $pageId; $this->view->metaForm = $this->getMetaForm($metaData); //properties $mdlProperties = new Model_Properties(); $this->view->properties = $mdlProperties->asArray($pageId); //related pages // $this->view->relatedPages = $page->getRelatedPages($pageId); $label = $currentPage->page->name; if (isset($currentPage->page->label) && !empty($currentPage->page->label)) { $label = $currentPage->page->label; } $this->view->breadcrumbs[$this->view->getTranslation('Open') . ': ' . $label] = $this->baseUrl . '/admin/page/edit/id/' . $pageId; $this->view->toolbarLinks = array(); $this->view->toolbarLinks['Add to my bookmarks'] = $this->baseUrl . '/admin/index/bookmark' . '/url/admin_page_edit_id_' . $pageId . '/label/' . $this->view->getTranslation('Page') . ':' . $currentPage->page->name; $this->view->toolbarLinks['Delete'] = $this->baseUrl . '/admin/page/delete/id/' . $pageId; }
/** * 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); } }
/** * this method takes the rawData hash and validates it according to the * rules you set in the model. this is all very simplistic by design. * * set the validation rules as parameters of the model * * $required = required fields * * $text = strip tags * * $rawText = does not strip tags * * $number = numeric * * $email = valid email * * $password = takes three parameters, the password, length, and password confirm. if confirm * is set then it validates that the two are equal * * $date = converts the date to a timestamp * * */ public function validateData() { // $this->_errors = new Digitalus_View_Error(); $this->_errors = Digitalus_View_Error::getInstance(); $validations = array('Required', 'Text', 'Integer', 'Number', 'Email', 'Password', 'Date', 'HTML', 'Unique'); foreach ($validations as $v) { $validateFunction = '_validate' . $v; $this->{$validateFunction}(); } }