Ejemplo n.º 1
0
 /**
  * Open action
  *
  * Open a user for editing
  *
  * @return void
  */
 public function openAction()
 {
     $userName = $this->_request->getParam('username');
     $form = new Admin_Form_User();
     $u = new Model_User();
     $elmUserName = $form->getElement('name');
     $elmUserName->addValidators(array(array('UsernameExistsNot', true, array('exclude' => $userName))));
     $form->onlyOpenActionElements();
     $form->setModel($u);
     $form->populateFromModel($userName);
     $form->setAttrib('id', 'general');
     $submit = $form->getElement('submitAdminUserForm');
     $submit->setAttribs(array('id' => 'update', 'name' => 'update'));
     $submit->setLabel($this->view->getTranslation('Update Account'));
     $form->setAction($this->baseUrl . '/admin/user/open/username/' . $userName);
     if ($this->_request->isPost() && $form->isValid($_POST)) {
         if ($form->update($userName) && Digitalus_Filter_Post::has('admin_user_password')) {
             $userName = Digitalus_Filter_Post::get('username');
             $password = Digitalus_Filter_Post::get('newPassword');
             $passwordConfirm = Digitalus_Filter_Post::get('newConfirmPassword');
             $u->updatePassword($newUserName, $password, true, $passwordConfirm);
         }
     }
     $this->view->userName = $userName;
     $this->view->form = $form;
     $breadcrumbLabel = $this->view->getTranslation('Open User') . ': ' . $userName;
     $this->view->breadcrumbs[$breadcrumbLabel] = $this->baseUrl . '/admin/user/open/username/' . $userName;
     $this->view->toolbarLinks = array();
     $this->view->toolbarLinks['Add to my bookmarks'] = $this->baseUrl . '/admin/index/bookmark' . '/url/admin_user_open_username_' . $userName . '/label/' . $this->view->getTranslation('User') . ':' . $userName;
     $this->view->toolbarLinks['Delete'] = $this->baseUrl . '/admin/user/delete/username/' . $userName;
 }
Ejemplo n.º 2
0
 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;
     }
 }
Ejemplo n.º 3
0
 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);
         }
     }
 }
Ejemplo n.º 4
0
 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;
 }
Ejemplo n.º 5
0
 /**
  *  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;
 }
Ejemplo n.º 6
0
 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);
         }
     }
 }
Ejemplo n.º 7
0
 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;
 }
Ejemplo n.º 8
0
 /**
  * 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);
         }
     }
 }
Ejemplo n.º 9
0
 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);
 }
Ejemplo n.º 10
0
 /**
  * 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);
         }
     }
 }
Ejemplo n.º 11
0
 /**
  * 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;
 }
Ejemplo n.º 12
0
 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";
 }