Beispiel #1
0
 public function createPage($pageName, $parentId = 0, $contentTemplate = null, $showOnMenu = null)
 {
     if (empty($pageName)) {
         $pageName = $this->_defaultPageName;
     }
     if ($contentTemplate == null) {
         $contentTemplate = $this->_defaultTemplate;
     }
     if ($showOnMenu !== null) {
         if ($showOnMenu == true) {
             $makeMenuLinks = 1;
         } else {
             $makeMenuLinks = 0;
         }
     } else {
         $settings = new Model_SiteSettings();
         $makeMenuLinks = $settings->get('add_menu_links');
     }
     $u = new Model_User();
     $user = $u->getCurrentUser();
     if ($user) {
         $userId = $user->id;
     } else {
         $userId = 0;
     }
     //first create the new page
     $data = array('namespace' => $this->_namespace, 'create_date' => time(), 'author_id' => $userId, 'name' => $pageName, 'content_template' => $contentTemplate, 'parent_id' => $parentId, 'show_on_menu' => $makeMenuLinks);
     $this->insert($data);
     $id = $this->_db->lastInsertId();
     $this->_flushCache();
     //return the new page
     return $this->find($id)->current();
 }
 /**
  * comments
  */
 public function currentAdminUser($id = 'currentUser')
 {
     $u = new Model_User();
     $user = $u->getCurrentUser();
     if (isset($user) && Model_Group::GUEST_ROLE != $user->name) {
         $xhtml = '<ul id="' . $id . '">' . '<li title="' . $user->first_name . ' ' . $user->last_name . '">' . '    ' . $this->view->getTranslation('Current User') . ': ' . $user->name . '</li>' . '<li>' . $this->view->getTranslation('Role') . ': ' . $user->role . '</li>' . '<li><a href="' . $this->view->getBaseUrl() . '/admin/auth/logout/">' . $this->view->getTranslation('Log Out') . '</a></li>' . '</ul>';
         return $xhtml;
     }
     return false;
 }
Beispiel #3
0
 /**
  * comments
  */
 public function CurrentAdminUser($id = 'current-user')
 {
     $u = new Model_User();
     $user = $u->getCurrentUser();
     if ($user) {
         $xhtml = "<ul id='{$id}'>\r\n                    <li>Current User : <a href='{$this->view->getBaseUrl()}/admin/user/edit/id/{$user->user_id}'>{$user->first_name} {$user->last_name}</a></li>\r\n                    <li>Role : {$user->role}</li>\r\n                    <li>[<a href='{$this->view->getBaseUrl()}/admin/auth/logout/'>Log Out</a>]</li>\r\n                </ul>";
         return $xhtml;
     } else {
         return false;
     }
 }
 public function RenderAdminMainMenu()
 {
     $userModel = new Model_User();
     $currentUser = $userModel->getCurrentUser();
     $cache = Digitalus_Cache_Manager::getInstance();
     $key = 'admin_main_menu_' . $currentUser->user_id;
     if (($data = $cache->loadCache($key)) != false) {
         return $data;
     }
     $this->view->addScriptPath(BASE_TEMPLATES);
     $data = $this->view->render('main_menu.phtml');
     $cache->saveCache($data, $key);
     return $data;
 }
 public function RenderAdminMainMenu()
 {
     $userModel = new Model_User();
     $currentUser = $userModel->getCurrentUser();
     $objMenus = new Model_Menus();
     $rsRootLevel = $objMenus->fetchAll('parent = 0', 'order ASC');
     $html = "<div id='main_menu'><ul class='menu' id='menu'>";
     foreach ($rsRootLevel as $rowRootLevel) {
         $html .= "<li>";
         if (empty($rowRootLevel->admin_menu_link)) {
             $html .= "<a href='javascript:void(0)' class='menulink'>{$rowRootLevel->name}</a>";
         } else {
             $html .= "<a href='{$rowRootLevel->admin_menu_link}' class='menulink'>{$rowRootLevel->name}</a>";
         }
         $rsNextLevel = $rowRootLevel->findDependentRowset($rowRootLevel->getTableClass(), null, $rowRootLevel->select()->order('order ASC'));
         if (count($rsNextLevel) > 0) {
             $html .= self::RenderAdminMenu($rsNextLevel, 0);
         }
         $html .= "</li>";
     }
     $html .= "</ul></div>";
     return $html;
 }
 /**
  * The default action
  *
  * Displays the admin dashboard
  *
  * @return void
  */
 public function indexAction()
 {
     $notes = new Model_Note();
     $this->view->notes = $notes->getUsersNotes();
     $content = new Model_Page();
     $this->view->pages = $content->getCurrentUsersPages('create_date DESC', 5);
     $user = new Model_User();
     $identity = $user->getCurrentUser();
     $form = new Admin_Form_User();
     $form->onlyIndexIndexActionElements();
     $form->setAction($this->baseUrl . '/admin/user/update-my-account');
     $firstName = $form->getElement('first_name');
     $firstName->setValue($identity->first_name);
     $lastName = $form->getElement('last_name');
     $lastName->setValue($identity->last_name);
     $email = $form->getElement('email');
     $email->setValue($identity->email);
     $submit = $form->getElement('submitAdminUserForm');
     $submit->setLabel($this->view->getTranslation('Update My Account'));
     $displayGroup = $form->getDisplayGroup('adminUserGroup');
     $displayGroup->setLegend($this->view->getTranslation('My Account'))->setAttrib('class', 'formColumn');
     $this->view->form = $form;
 }
Beispiel #7
0
 public function createPage($pageName, $parentId = 0, $contentTemplate = null, $showOnMenu = null, $publishPage = null)
 {
     if (empty($pageName)) {
         $pageName = $this->_defaultPageName;
     }
     if ($contentTemplate == null) {
         $contentTemplate = $this->_defaultTemplate;
     }
     if ($showOnMenu !== null) {
         if ($showOnMenu == true) {
             $makeMenuLinks = 1;
         } else {
             $makeMenuLinks = 0;
         }
     } else {
         $settings = new Model_SiteSettings();
         $makeMenuLinks = $settings->get('add_menu_links');
     }
     // get current time to ensure create and publish date are exactly the same
     $time = time();
     if ($publishPage === null) {
         $settings = new Model_SiteSettings();
         $publishPage = $settings->get('publish_pages');
     }
     if ($publishPage == true) {
         $publishDate = $time;
         $publishLevel = self::PUBLISH_ID;
     } else {
         $publishDate = 'NULL';
         $publishLevel = self::UNPUBLISH_ID;
     }
     $u = new Model_User();
     $user = $u->getCurrentUser();
     if ($user) {
         $userName = $user->name;
     } else {
         $userName = NULL;
     }
     //first create the new page
     $data = array('namespace' => $this->_namespace, 'create_date' => $time, 'publish_date' => $publishDate, 'publish_level' => $publishLevel, 'user_name' => $userName, 'name' => $pageName, 'content_template' => $contentTemplate, 'parent_id' => $parentId, 'show_on_menu' => $makeMenuLinks);
     $this->insert($data);
     $id = $this->_db->lastInsertId();
     $this->_flushCache();
     //return the new page
     return $this->find($id)->current();
 }
Beispiel #8
0
 public function loadCurrentUsersPermissions()
 {
     $user = new Model_User();
     $currentUser = $user->getCurrentUser();
     $permissions = $user->getCurrentUsersAclResources();
     if ($permissions) {
         foreach ($permissions as $key => $value) {
             if ($this->has($key)) {
                 if ($value == 1) {
                     $this->allow($currentUser->role, $key);
                 } else {
                     $this->deny($currentUser->role, $key);
                 }
             }
         }
     }
 }
 /**
  * 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);
 }
Beispiel #10
0
 public function loadCurrentUsersPermissions()
 {
     $mdlUser = new Model_User();
     $user = $mdlUser->getCurrentUser();
     $group = $mdlUser->getGroupByUsername($user->name);
     $permissions = $mdlUser->getCurrentUsersAclResources();
     if (Model_Group::SUPERUSER_ROLE != $group && !empty($permissions)) {
         foreach ($permissions as $key => $value) {
             if ($this->has($key)) {
                 if ($value == 1) {
                     $this->allow($group, $key);
                 } else {
                     $this->deny($group, $key);
                 }
             }
         }
     }
 }