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 function searchAction() { if ($this->_request->isPost() && Digitalus_Filter_Post::has('submitSearchForm')) { $index = Zend_Search_Lucene::open('./application/modules/search/data/index'); $queryString = Digitalus_Filter_Post::get('keywords'); $query = Zend_Search_Lucene_Search_QueryParser::parse($queryString); $this->view->searchResults = $index->find($query); $this->view->keywords = $queryString; } }
public function contactFormAction() { //create the form $form = new Zend_Form(); //this page should post back to itself $form->setAction($_SERVER['REQUEST_URI']); $form->setMethod('post'); $name = $form->createElement('text', 'name'); $name->setLabel($this->view->getTranslation('Your Name') . ': '); $name->setRequired(TRUE); $name->addFilter('StripTags'); $name->addErrorMessage($this->view->getTranslation('Your name is required!')); $name->setAttrib('size', 30); $email = $form->createElement('text', 'email'); $email->setLabel($this->view->getTranslation('Your Email') . ': '); $email->setRequired(TRUE); $email->addValidator('EmailAddress'); $email->addErrorMessage($this->view->getTranslation('Invalid email address!')); $email->setAttrib('size', 30); $subject = $form->createElement('text', 'subject'); $subject->setLabel($this->view->getTranslation('Subject') . ': '); $subject->setRequired(TRUE); $subject->addFilter('StripTags'); $subject->addErrorMessage($this->view->getTranslation('The subject is required!')); $subject->setAttrib('size', 40); $message = $form->createElement('textarea', 'message'); $message->setLabel($this->view->getTranslation('Message') . ': '); $message->setRequired(TRUE); $message->addErrorMessage($this->view->getTranslation('The message is required!')); $message->setAttrib('cols', 35); $message->setAttrib('rows', 10); $captcha = new Zend_Form_Element_Captcha('captcha', array('label' => $this->view->getTranslation('Please verify you\'re a human'), 'captcha' => array('captcha' => 'Figlet', 'wordLen' => 6, 'timeout' => 300))); $form->addElement($name); $form->addElement($email); $form->addElement($subject); $form->addElement($message); $form->addElement($captcha); $form->addElement('submit', 'submitContactForm', array('label' => $this->view->getTranslation('Send Message'))); $this->view->form = $form; if ($this->_request->isPost() && Digitalus_Filter_Post::has('submitContactForm')) { if ($form->isValid($_POST)) { //get form data $data = $form->getValues(); //get the module data $module = new Digitalus_Module(); $moduleData = $module->getData(); //render the message $this->view->data = $data; $htmlMessage = $this->view->render('public/message.phtml'); $mail = new Digitalus_Mail(); $this->view->isSent = $mail->send($moduleData->email, array($data['email'], $data['name']), $data['subject'], $htmlMessage); } } }
/** * Edit action * * Update the site settings file * * @return void */ public function editAction() { $settings = Digitalus_Filter_Post::raw('setting'); $s = new Model_SiteSettings(); foreach ($settings as $k => $v) { $s->set($k, $v); } $s->save(); $this->_message->add("Global parameters have been updated !!"); $this->_redirect($this->_currentControllerUrl); }
public function searchAction() { $searchForm = new Search_Form(); if ($this->_request->isPost() && $searchForm->isValid($_POST) && Digitalus_Filter_Post::has('submitSearchForm')) { $index = Zend_Search_Lucene::open(APPLICATION_PATH . '/modules/search/data/index'); $queryString = Digitalus_Filter_Post::get('keywords'); $query = Zend_Search_Lucene_Search_QueryParser::parse($queryString); $this->view->searchResults = $index->find($query); if (!empty($queryString)) { $keywordsElement = $searchForm->getElement('keywords'); $keywordsElement->setValue($queryString); } } $this->view->form = $searchForm; }
/** * this helper renders a language selector * it also processes the selected language * it must be rendered above the content in order for the current * content to reflect the language selection */ public function languageForm() { //process form if this is a post back if (Digitalus_Filter_Post::has('setLang')) { Digitalus_Language::setLanguage($_POST['language']); // @todo: this needs to redirect so it loads the whole page in the new language } $currentLanguage = Digitalus_Language::getLanguage(); $languageSelector = $this->view->selectLanguage('language', $currentLanguage); $xhtml = '<form action="' . $this->view->ModuleAction() . '" method="post">'; $xhtml .= '<p>' . $languageSelector . '</p>'; $xhtml .= '<p>' . $this->view->formSubmit('setLang', $this->view->getTranslation('Set Language')) . '</p>'; $xhtml .= '</form>'; return $xhtml; }
public function contactFormAction() { //create the form $form = new Contact_Form(); // retrieve the id that is set in the <DigitalusControl>-tag $digControlId = $this->view->getFilter('DigitalusControl')->getId(); $this->view->form = $form; if ($this->_request->isPost() && Digitalus_Filter_Post::has('submitContactForm')) { if ($form->isValid($_POST)) { //get form data $data = $form->getValues(); //get the module data $module = new Digitalus_Module($digControlId); $moduleData = $module->getData(); //render the message $this->view->data = $data; $htmlMessage = $this->view->render('public/message.phtml'); $mail = new Digitalus_Mail(); $this->view->isSent = $mail->send($moduleData->email, array($data['email'], $data['name']), $data['subject'], $htmlMessage); } } }
/** * Login action * * if the form has not been submitted this renders the login form * if it has then it validates the data * if it is sound then it runs the Digitalus_Auth_Adapter function * to authorise the request * on success it redirect to the admin home page * * @return void */ public function loginAction() { // Neu dang nhap roi thi chuyen den trang chu if (Digitalus_Auth::getIdentity()) { $this->_redirect('admin'); } if ($this->_request->isPost()) { $uri = Digitalus_Filter_Post::get('uri'); $uri = str_replace(BASE_URL . "/", "", $uri); $username = Digitalus_Filter_Post::get('username'); $password = Digitalus_Filter_Post::raw('password'); if ($username == '') { $this->_errors->add('You must enter a username.'); } if ($password == '') { $this->_errors->add('You must enter a password.'); } if (!$this->_errors->hasErrors()) { $auth = new Digitalus_Auth($username, $password); $result = $auth->authenticate(); if ($result) { if ($uri == '' || $uri == 'admin/auth/login') { $uri = 'admin'; } $this->_redirect($uri); } else { $this->_errors->add('The username or password you entered was not correct.'); } } $this->view->uri = $uri; } else { // $this->view->uri = Digitalus_Uri::get(); $this->view->uri = $_SERVER['REQUEST_URI']; } $this->_helper->layout->setLayout('login'); $this->_cacheManager->doNotCache(true); }
public function isSubmitted() { if (Digitalus_Filter_Post::has('form_instance')) { $instance = Digitalus_Filter_Post::get('form_instance'); if ($this->_isValidInstance($instance)) { return true; } } return false; }
/** * The public challenge action for getting a new password * * @return void */ public function changepasswordAction() { $uri = new Digitalus_Uri(); $uriParams = $uri->getParams(); if (!isset($uriParams['u']) || !isset($uriParams['c'])) { $this->_error; } else { $userName = $uriParams['u']; $challengeId = $uriParams['c']; $mdlChallenge = new Login_Challenge(); if (!$mdlChallenge->isValid($challengeId, $userName)) { $this->_error = $this->view->getTranslation('Error: No valid challenge was found. Please try again!'); } else { $changePasswordForm = new User_Form(); $uri = $this->baseUrl . '/' . Digitalus_Toolbox_Page::getCurrentPageName() . '/p/a/changepassword/u/' . $userName . '/c/' . $challengeId; $changePasswordForm->setAction($uri); $changePasswordForm->getElement('name')->addValidators(array(array('UsernameExists', true))); $changePasswordForm->onlyChangepasswordActionElements(array('legend' => 'Change Password')); if ($this->_request->isPost() && $changePasswordForm->isValid($_POST)) { $password = Digitalus_Filter_Post::get('password'); $passwordConfirm = Digitalus_Filter_Post::get('password_confirm'); $mdlUser = new Model_User(); if (!$mdlUser->updatePassword($userName, $password, true, $passwordConfirm)) { $this->_error = $this->view->getTranslation("Error: Your password hasn't been updated!"); } else { $mdlChallenge->invalidate($challengeId); $this->_message = $this->view->getTranslation('Your password has been updated successfully!'); } } else { $this->_message = $this->view->getTranslation('Please type in Your user name and Your new password.'); $this->view->form = $changePasswordForm; } } } $this->view->error = $this->_error; $this->view->message = $this->_message; }
public function editAction() { $active_tab = 0; if ($this->_request->isPost()) { // Change password action if (Digitalus_Filter_Post::has('change_password')) { $user_id = Digitalus_Filter_Post::int('user_id'); $password = Digitalus_Filter_Post::get('password'); $passwordConfirm = Digitalus_Filter_Post::get('confirm_password'); if ($this->_objUser->validateExtData($_POST)) { if ($this->_objUser->updatePassword($user_id, $password, true, $passwordConfirm)) { $this->_redirect($this->_currentControllerUrl); return; } } $active_tab = 1; } elseif ($this->_objUser->updateFromPost()) { $this->_redirect($this->_currentControllerUrl); return; } $rowUser = $this->_objUser->find(Digitalus_Filter_Post::int('user_id'))->current(); } else { $id = $this->_request->getParam('id'); $rowUser = $this->_objUser->find($id)->current(); if (!$rowUser) { $this->_redirect($this->_currentControllerUrl); } } $this->view->active_tab = $active_tab; $this->view->rowUser = $rowUser; $this->view->title_action = $this->view->getTranslation("Edit"); $this->view->action = "Edit"; }
/** * Redirector action * * @return void */ public function redirectorAction() { $r = new Model_Redirector(); if ($this->_request->isPost()) { $request = Digitalus_Filter_Post::raw('request'); $response = Digitalus_Filter_Post::raw('response'); $responseCode = Digitalus_Filter_Post::raw('response_code'); $r->setFromArray($request, $response, $responseCode); } $this->view->redirectors = $r->fetchAll(); }
/** * Open Folder Action * * @return void */ public function openFolderAction() { $folder = $this->_request->getParam('folder'); $folder = str_replace('media_', '', $folder); $folder = Digitalus_Toolbox_String::stripLeading('_', $folder); $data = array(); $data['path'] = $folder; $folderArray = explode('_', $folder); if (is_array($folderArray)) { foreach ($folderArray as $pathPart) { if (!empty($pathPart)) { $fullPathParts[] = $pathPart; $fullPath = implode('_', $fullPathParts); $folderPathParts[$fullPath] = $pathPart; } } } if (isset($folderPathParts) && !empty($folderPathParts)) { $data['folderPathParts'] = $folderPathParts; $data['label'] = array_pop($folderPathParts); } $pathToFolder = Digitalus_Toolbox_String::stripUnderscores($folder); $data['filepath'] = $pathToFolder; $data['mediapath'] = $folder; $data['folders'] = Digitalus_Filesystem_Dir::getDirectories($this->_pathToMedia . '/' . $pathToFolder); $data['files'] = Digitalus_Filesystem_File::getFilesByType($this->_pathToMedia . '/' . $pathToFolder, false, false, true); $data['mediaFolder'] = $this->view->mediaFolder; $form = new Admin_Form_Media(null, $data); $form->setDecorators(array('FormElements', 'Form', array('FormErrors', array('placement' => 'prepend')))); if ($this->_request->isPost() && Digitalus_Filter_Post::has('form_instance')) { $path = Digitalus_Filter_Post::get('path'); $filePath = Digitalus_Filter_Post::get('filepath'); $mediaPath = Digitalus_Filter_Post::get('mediapath'); $folderName = Digitalus_Filter_Post::get('folder_name'); $newFolderName = Digitalus_Filter_Post::get('new_folder_name'); // indicator if it is a return of one of the other actions if (false == $this->_request->getParam('return')) { // createFolderAction if ($form->isValidPartial(array('path' => $path, 'folder_name' => $folderName)) && isset($_POST['createFolderSubmit']) && !empty($_POST['createFolderSubmit'])) { $this->_request->setParam('path', $path); $this->_request->setParam('folder_name', $folderName); $this->_forward('create-folder'); // renameFolderAction } else { if ($form->isValidPartial(array('filepath' => $filePath, 'new_folder_name' => $newFolderName)) && isset($_POST['renameFolderSubmit']) && !empty($_POST['renameFolderSubmit'])) { $this->_request->setParam('filepath', $filePath); $this->_request->setParam('new_folder_name', $newFolderName); $this->_forward('rename-folder'); // uploadAction } else { if ($form->isValidPartial(array('filepath' => $filePath, 'mediapath' => $mediaPath)) && isset($_POST['uploadSubmit']) && !empty($_POST['uploadSubmit'])) { $this->_request->setParam('filepath', $filePath); $this->_request->setParam('mediapath', $mediaPath); $this->_forward('upload'); } } } } } $this->view->form = $form; $tmpPath = Digitalus_Toolbox_String::addUnderscores($folder); $this->view->toolbarLinks['Add to my bookmarks'] = $this->baseUrl . '/admin/index/bookmark' . '/url/admin_media_open-folder_folder_' . $tmpPath . '/label/' . $this->view->getTranslation('Media') . ':' . $pathToFolder; $this->view->toolbarLinks['Delete'] = $this->baseUrl . '/admin/media/delete-folder/folder/' . $folder; $this->view->breadcrumbs[$this->view->getTranslation('Open Folder') . ': ' . Digitalus_Toolbox_String::stripUnderscores($folder)] = $this->baseUrl . '/admin/media/open-folder/folder/' . $folder; }
/** * Console action * * The console provides an interface for simple command scripts. * those scripts go in library/Digitalus/Command/{script name} * * @return void */ public function consoleAction() { //set up a unique id for this session $session = new Zend_Session_Namespace('console_session'); $previousId = $session->id; $session->id = md5(time()); $this->view->consoleSession = $session->id; //you must validate that the session ids match if ($this->_request->isPost() && !empty($previousId)) { $this->view->commandExecuted = true; $this->view->command = 'Command: ' . Digitalus_Filter_Post::get('command'); $this->view->date = time(); //execute command //validate the session if (Digitalus_Filter_Post::get('consoleSession') == $previousId) { $this->view->lastCommand = Digitalus_Filter_Post::get('command'); if (Digitalus_Filter_Post::get('runCommand')) { $results = Digitalus_Command::run(Digitalus_Filter_Post::get('command')); } elseif (Digitalus_Filter_Post::get('getInfo')) { $results = Digitalus_Command::info(Digitalus_Filter_Post::get('command')); } else { $results = array('ERROR: invalid request'); } } else { $results[] = 'ERROR: invalid session'; } $this->view->results = $results; } $breadcrumbLabel = $this->view->getTranslation('Site Console'); $this->view->breadcrumbs[$breadcrumbLabel] = $this->getFrontController()->getBaseUrl() . '/admin/site/console'; $this->view->toolbarLinks = array(); $this->view->toolbarLinks['Add to my bookmarks'] = $this->getFrontController()->getBaseUrl() . '/admin/index/bookmark/url/admin_site_console'; }
public function reorderAction() { $mdlShow = new Slideshow_Show(); $mdlSlide = new Slideshow_Slide(); if ($this->_request->isPost()) { //sort the slides $ids = Digitalus_Filter_Post::raw('id'); $mdlSlide->sortSlides($ids); $show = Digitalus_Filter_Post::get('show'); $url = '/mod_slideshow/show/edit/id/' . $show; $this->_redirect($url); } else { $show = $this->_request->getParam('show'); } $this->view->slides = $mdlSlide->getSlides($show); $this->view->show = $mdlShow->find($show)->current(); }
/** * Notes action * * @return void */ public function notesAction() { $notes = new Model_Note(); $myNotes = Digitalus_Filter_Post::get('content'); $notes->saveUsersNotes($myNotes); $this->_redirect('admin/index'); }
/** * Update my account action * * @return void */ public function updateMyAccountAction() { $u = new Model_User(); $user = $u->getCurrentUser(); $user->first_name = Digitalus_Filter_Post::get('first_name'); $user->last_name = Digitalus_Filter_Post::get('last_name'); $user->email = Digitalus_Filter_Post::get('email'); $user->save(); if (Digitalus_Filter_Post::int('update_password') === 1) { $password = Digitalus_Filter_Post::get('password'); $passwordConfirm = Digitalus_Filter_Post::get('password_confirm'); $u->updatePassword($user->name, $password, true, $passwordConfirm); } $url = 'admin/index'; $this->_redirect($url); }
/** * Rename Folder Action * * @return void */ public function renameFolderAction() { $filepath = Digitalus_Filter_Post::get('filepath'); $folderName = Digitalus_Filter_Post::get('folder_name'); Digitalus_Media::renameFolder($filepath, $folderName); $folder = Digitalus_Toolbox_String::addUnderscores(Digitalus_Toolbox_String::getParentFromPath($filepath) . '/' . $folderName); $this->_request->setParam('folder', $folder); $this->_forward('open-folder'); }
/** * this method assumes you have registered the post data * it loads each of the fields from the current table and sets * the data hash with the unvalidated data * */ private function _loadPost() { if (isset($_POST['active'])) { $_POST['active'] = intval($_POST['active']); } if (isset($_POST['order'])) { $_POST['order'] = intval($_POST['order']); } foreach ($this->_getCols() as $col) { if (Digitalus_Filter_Post::has($col)) { $this->_data[$col] = Digitalus_Filter_Post::raw($col); } } }
/** * 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); } }
/** * Update action * * @return void */ public function updateAction() { $mdlDesign = new Model_Design(); $this->view->designs = $mdlDesign->listDesigns(); if ($this->_request->isPost()) { // NOTE: we will turn this into a Zend_Form after were sure it will work this way $id = Digitalus_Filter_Post::int('id'); $mdlDesign->updateDesign($id, Digitalus_Filter_Post::get('name'), Digitalus_Filter_Post::get('notes'), Digitalus_Filter_Post::get('layout'), Digitalus_Filter_Post::raw('skin'), Digitalus_Filter_Post::get('inline_styles'), Digitalus_Filter_Post::int('is_default')); } else { $id = $this->_request->getParam('id'); } $mdlDesign->setDesign($id); $mdlPage = new Model_Page(); $this->view->pages = $mdlPage->getPagesByDesign($id); $this->view->breadcrumbs[$this->view->getTranslation('Open') . ': ' . $this->view->getTranslation($mdlDesign->getValue('name'))] = $this->baseUrl . '/admin/design/update/id/' . $id; $this->view->toolbarLinks = array(); $this->view->toolbarLinks['Add to my bookmarks'] = $this->baseUrl . '/admin/index/bookmark' . '/url/admin_design_update_id_' . $id . '/label/' . $this->view->getTranslation('Design') . ':' . $mdlDesign->getValue('name'); $this->view->toolbarLinks['Delete'] = $this->baseUrl . '/admin/design/delete/id/' . $id; $this->view->design = $mdlDesign; }
/** * Related content action * * @return void */ public function relatedContentAction() { $pageId = Digitalus_Filter_Post::int('page_id'); foreach ($_POST as $k => $v) { if (substr($k, 0, 5) == 'file_' && $v == 1) { $relatedFiles[] = str_replace('file_', '', $k); } } if (is_array($relatedFiles)) { $page = new Model_Page(); $page->setRelatedPages($pageId, $relatedFiles); } $this->_redirect('admin/page/edit/id/' . $pageId); }
/** * Copy ACL action * * @return void */ public function copyAclAction() { $currentGroup = Digitalus_Filter_Post::get('name'); $copyFrom = Digitalus_Filter_Post::get('from_groupname'); if (!empty($currentGroup) && !empty($copyFrom)) { $mdlGroup = new Model_Group(); $mdlGroup->copyPermissions($copyFrom, $currentGroup); } $url = 'admin/group/open/groupname/' . $currentGroup; $this->_redirect($url); }
/** * Publish page action * * @return void */ public function publishAction() { if ($this->_request->isPost()) { $action = Digitalus_Filter_Post::text('publish'); $id = $this->_request->getParam('id'); $mdlPage = new Model_Page(); $mdlPage->publishPage($id, $action); $this->_redirect('admin/page/edit/id/' . $id); } }
/** * this method assumes you have registered the post data * it loads each of the fields from the current table and sets * the data hash with the unvalidated data * */ private function _loadPost() { foreach ($this->_cols as $col) { if (Digitalus_Filter_Post::has($col)) { $this->_data[$col] = Digitalus_Filter_Post::raw($col); } } }
public function updatePermissionsAction() { if (Digitalus_Filter_Post::has('update_permissions')) { //update the users permissions $objGroups = new Model_Groups(); $resources = Digitalus_Filter_Post::raw('acl_resources'); $group_id = Digitalus_Filter_Post::int('group_id'); $rowGroup = $objGroups->find($group_id)->current(); $rowGroup->updateAclResources($resources); } $this->_redirect($this->_currentControllerUrl); }