示例#1
0
 /**
  * Display module contents
  *
  * @return     void
  */
 public function display()
 {
     if (!\App::isAdmin()) {
         return;
     }
     // include group page archive model
     require_once Component::path('com_groups') . DS . 'models' . DS . 'page' . DS . 'archive.php';
     // include group module archive model
     require_once Component::path('com_groups') . DS . 'models' . DS . 'module' . DS . 'archive.php';
     // get unapproved pages
     $groupModelPageArchive = new Models\Page\Archive();
     $this->unapprovedPages = $groupModelPageArchive->pages('unapproved', array('state' => array(0, 1)), true);
     // get unapproved modules
     $groupModelModuleArchive = new Models\Module\Archive();
     $this->unapprovedModules = $groupModelModuleArchive->modules('unapproved', array('state' => array(0, 1)), true);
     // Get the view
     parent::display();
 }
示例#2
0
 /**
  * Set Group Home Page
  *
  * @return 	void
  */
 public function setHomeTask()
 {
     // get request vars
     $pageid = Request::getInt('pageid', 0, 'get');
     // load page model
     $page = new Page($pageid);
     // make sure its out page
     if (!$page->belongsToGroup($this->group)) {
         App::abort(403, Lang::txt('COM_GROUPS_PAGES_PAGE_NOT_AUTH'));
     }
     // make sure we have an approved version
     $version = $page->approvedVersion();
     if ($version === null) {
         $this->setNotification(Lang::txt('COM_GROUPS_PAGES_PAGE_HOME_ERROR', $page->get('title')), 'error');
         App::redirect(Route::url('index.php?option=' . $this->_option . '&cn=' . $this->group->get('cn') . '&controller=pages'));
         return;
     }
     // remove any current home page
     $pageArchive = Page\Archive::getInstance();
     $pageArchive->reset('home', 0, array('gidNumber' => $this->group->get('gidNumber')));
     // toggle home state
     $home = 1;
     if ($page->get('home') == 1) {
         $home = 0;
     }
     $page->set('home', $home);
     // store new group home page
     if (!$page->store()) {
         $this->setNotification($page->getError(), 'error');
         return $this->displayTask();
     }
     // inform user
     $this->setNotification(Lang::txt('COM_GROUPS_PAGES_PAGE_HOME_SET', $page->get('title')), 'passed');
     // redirect
     App::redirect(Route::url('index.php?option=' . $this->_option . '&cn=' . $this->group->get('cn') . '&controller=pages'));
     if ($return = Request::getVar('return', '', 'get')) {
         App::redirect(base64_decode($return));
     }
 }
示例#3
0
 /**
  * Get Page Children
  *
  * @return
  */
 public function getChildren()
 {
     // load pages that are decendents of this page
     $archive = new Page\Archive();
     $children = $archive->pages('list', array('gidNumber' => $this->get('gidNumber'), 'left' => $this->get('lft'), 'right' => $this->get('rgt'), 'orderby' => 'lft ASC'));
     return $children;
 }
示例#4
0
 /**
  * Edit a group page
  *
  * @return void
  */
 public function editTask()
 {
     // get request vars
     $ids = Request::getVar('id', array());
     $id = isset($ids[0]) ? $ids[0] : null;
     // get the page & version objects
     $this->view->page = new Page($id);
     $this->view->version = $this->view->page->version();
     $this->view->firstversion = $this->view->page->version(1);
     // get a list of all pages for creating module menu
     $pageArchive = Page\Archive::getInstance();
     $this->view->pages = $pageArchive->pages('list', array('gidNumber' => $this->group->get('gidNumber'), 'state' => array(0, 1), 'orderby' => 'lft ASC'));
     // get page categories
     $categoryArchive = new Page\Category\Archive();
     $this->view->categories = $categoryArchive->categories('list', array('gidNumber' => $this->group->get('gidNumber'), 'orderby' => 'title'));
     // pass vars to view
     $this->view->group = $this->group;
     // get page templates
     $this->view->pageTemplates = Helpers\View::getPageTemplates($this->group);
     // Set any errors
     foreach ($this->getErrors() as $error) {
         $this->view->setError($error);
     }
     // Output the HTML
     $this->view->setLayout('edit')->display();
 }
示例#5
0
 /**
  * View Group
  *
  * @return     array
  */
 public function viewTask()
 {
     // set the needed layout
     $this->view->setLayout('view');
     // validate the incoming cname
     if (!$this->_validCn($this->cn, true)) {
         $this->_errorHandler(404, Lang::txt('COM_GROUPS_ERROR_NOT_FOUND'));
     }
     // Load the group object
     $this->view->group = Group::getInstance($this->cn);
     // check to make sure we were able to load group
     if (!is_object($this->view->group) || !$this->view->group->get('gidNumber') || !$this->view->group->get('cn')) {
         $this->suggestNonExistingGroupTask();
         return;
     }
     // Ensure it's an allowable group type to display
     if (!in_array($this->view->group->get('type'), array(1, 3))) {
         $this->_errorHandler(404, Lang::txt('COM_GROUPS_ERROR_NOT_FOUND'));
     }
     // ensure the group is published
     if ($this->view->group->get('published') != 1) {
         $this->_errorHandler(404, Lang::txt('COM_GROUPS_ERROR_NOT_FOUND'));
     }
     // Ensure the group has been published or has been approved
     if ($this->view->group->get('approved') != 1) {
         //get list of members & managers & invitees
         $managers = $this->view->group->get('managers');
         $members = $this->view->group->get('members');
         $invitees = $this->view->group->get('invitees');
         $members_invitees = array_merge($members, $invitees);
         $managers_members_invitees = array_merge($managers, $members, $invitees);
         //if user is not member, manager, or invitee deny access
         if (!in_array(User::get('id'), $managers_members_invitees)) {
             $this->_errorHandler(404, Lang::txt('COM_GROUPS_ERROR_NOT_FOUND'));
         }
         //if user is NOT manager but member or invitee
         if (!in_array(User::get('id'), $managers) && in_array(User::get('id'), $members_invitees)) {
             $this->unapprovedGroupTask();
             return;
         }
         //set notification and clear after
         $this->setNotification(Lang::txt('COM_GROUPS_PENDING_APPROVAL_WARNING'), 'warning');
     }
     // Get the group params
     $this->view->gparams = new \Hubzero\Config\Registry($this->view->group->get('params'));
     // Check authorization
     $this->view->authorized = Helpers\View::authorize($this->view->group);
     // get active tab
     $this->view->tab = Helpers\View::getTab($this->view->group);
     $this->view->trueTab = strtolower(Request::getVar('active', 'overview'));
     // get group pages if any
     $pageArchive = Page\Archive::getInstance();
     $pages = $pageArchive->pages('list', array('gidNumber' => $this->view->group->get('gidNumber'), 'state' => array(0, 1), 'orderby' => 'lft ASC'));
     // custom error handling for super groups
     Helpers\View::attachCustomErrorHandler($this->view->group);
     // add the overview content
     $overviewContent = '';
     $activePage = null;
     if ($this->view->tab == 'overview') {
         // add home page to pages list
         $pages = Helpers\Pages::addHomePage($this->view->group, $pages);
         // fetch the active page
         $activePage = Helpers\Pages::getActivePage($this->view->group, $pages);
         // are we on the login
         if ($this->view->trueTab == 'login') {
             $overviewContent = Helpers\View::superGroupLogin($this->view->group);
         }
         // check to see if we have super group component or php page
         if ($overviewContent == null && $this->config->get('super_components', 0)) {
             $overviewContent = Helpers\View::superGroupComponents($this->view->group, $this->view->trueTab);
         }
         // do we have group php pages
         if ($overviewContent == null) {
             $overviewContent = Helpers\View::superGroupPhpPages($this->view->group);
         }
         //set overview content
         if ($overviewContent == null) {
             $overviewContent = Helpers\Pages::displayPage($this->view->group, $activePage);
         }
     }
     // build the title
     $this->_buildTitle($pages);
     // build pathway
     $this->_buildPathway($pages);
     //set some vars for view
     $this->view->title = $this->_title;
     $this->view->content = Helpers\View::displaySectionsContent($this->view->group, $overviewContent);
     $this->view->activePage = $activePage;
     $this->view->notifications = $this->getNotifications() ? $this->getNotifications() : array();
     //is this a super group?
     if ($this->view->group->isSuperGroup()) {
         //use group template file if we have it
         Request::setVar('tmpl', 'group');
         // must call here cause otherwise doesnt load template
         $this->view->css()->js();
         // load super group template
         // parse & render
         $superGroupTemplate = new Helpers\Template();
         $superGroupTemplate->set('group', $this->view->group)->set('tab', $this->view->trueTab)->set('content', $this->view->content)->set('page', $this->view->activePage)->parse()->render();
         // echo content & stop execution
         return $superGroupTemplate->output(true);
     }
     //display view
     $this->view->display();
 }
示例#6
0
    /**
     * Preview Group Module
     *
     * @return void
     */
    public function previewTask()
    {
        // make sure we are approvers
        if (!Helpers\Pages::isPageApprover()) {
            App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&gid=' . $this->gid, false), Lang::txt('COM_GROUPS_MODULES_AUTHORIZED_APPROVERS_ONLY'), 'error');
            return;
        }
        // get reqest vars
        $moduleid = Request::getInt('moduleid', 0, 'get');
        // page object
        $module = new Module($moduleid);
        // make sure page belongs to this group
        if (!$module->belongsToGroup($this->group)) {
            App::abort(403, Lang::txt('COM_GROUPS_MODULES_NOT_AUTHORIZED'));
        }
        // get first module menu's page id
        $pageid = $module->menu()->first()->get('pageid');
        // check if pageid 0
        if ($pageid == 0) {
            // get a list of all pages
            $pageArchive = Page\Archive::getInstance();
            $pages = $pageArchive->pages('list', array('gidNumber' => $this->group->get('gidNumber'), 'state' => array(1), 'orderby' => 'ordering'));
            // get first page
            $pageid = $pages->first()->get('id');
        }
        // load page
        $page = new Page($pageid);
        // load page version
        $content = $page->version()->content('parsed');
        // create new group document helper
        $groupDocument = new Helpers\Document();
        // strip out scripts & php tags if not super group
        if (!$this->group->isSuperGroup()) {
            $content = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $content);
            $content = preg_replace('/<\\?[\\s\\S]*?\\?>/', '', $content);
        }
        // are we allowed to display group modules
        if (!$this->group->isSuperGroup() && !$this->config->get('page_modules', 0)) {
            $groupDocument->set('allowed_tags', array());
        }
        // set group doc needed props
        // parse and render content
        $groupDocument->set('group', $this->group)->set('page', $page)->set('document', $content)->set('allMods', true)->parse()->render();
        // get doc content
        $content = $groupDocument->output();
        // only parse php if Super Group
        if ($this->group->isSuperGroup()) {
            // run as closure to ensure no $this scope
            $eval = function () use($content) {
                ob_start();
                unset($this);
                eval("?> {$content} <?php ");
                $content = ob_get_clean();
                return $content;
            };
            $content = $eval();
        }
        // get group css
        $pageCss = Helpers\View::getPageCss($this->group);
        $css = '';
        foreach ($pageCss as $p) {
            $css .= '<link rel="stylesheet" href="' . $p . '" />';
        }
        // output html
        $html = '<!DOCTYPE html>
				<html>
					<head>
						<title>' . $this->group->get('description') . '</title>
						' . $css . '
					</head>
					<body>
						' . $content . '
					</body>
				</html>';
        //echo content and exit
        echo $html;
        exit;
    }
示例#7
0
 /**
  * Get a count of all the group pages
  *
  * @param      string $gid Group alias
  * @return     integer
  */
 public static function getGroupPagesCount($gid)
 {
     if (!$gid) {
         return 0;
     }
     // get group pages if any
     $pageArchive = \Components\Groups\Models\Page\Archive::getInstance();
     $pages = $pageArchive->pages('list', array('gidNumber' => $gid, 'state' => array(0, 1)));
     return count($pages);
 }
示例#8
0
 /**
  * Edit Module
  *
  * @return void
  */
 public function editTask()
 {
     //set to edit layout
     $this->view->setLayout('edit');
     // get request vars
     $moduleid = Request::getInt('moduleid', 0);
     // get the category object
     $this->view->module = new Module($moduleid);
     // are we passing a module object
     if ($this->module) {
         $this->view->module = $this->module;
     }
     // get a list of all pages for creating module menu
     $pageArchive = Page\Archive::getInstance();
     $this->view->pages = $pageArchive->pages('list', array('gidNumber' => $this->group->get('gidNumber'), 'state' => array(0, 1), 'orderby' => 'lft asc'));
     // get a list of all pages for creating module menu
     $moduleArchive = Module\Archive::getInstance();
     $this->view->order = $moduleArchive->modules('list', array('gidNumber' => $this->group->get('gidNumber'), 'position' => $this->view->module->get('position'), 'state' => array(0, 1), 'orderby' => 'ordering'));
     // get stylesheets for editor
     $this->view->stylesheets = Helpers\View::getPageCss($this->group);
     // build the title
     $this->_buildTitle();
     // build pathway
     $this->_buildPathway();
     // get view notifications
     $this->view->notifications = $this->getNotifications() ? $this->getNotifications() : array();
     $this->view->group = $this->group;
     //display layout
     $this->view->display();
 }
示例#9
0
 /**
  * Display group menu
  *
  * @return    string
  */
 public static function displaySections($group, $classOrId = 'id="page_menu"')
 {
     // create view object
     $view = new \Hubzero\Component\View(array('name' => 'groups', 'layout' => '_menu'));
     // get group pages if any
     // only get published items that arent set as the home page
     $pageArchive = Archive::getInstance();
     $pages = $pageArchive->pages('tree', array('gidNumber' => $group->get('gidNumber'), 'state' => array(1), 'orderby' => 'lft ASC'), true);
     // pass vars to view
     $view->group = $group;
     $view->user = User::getRoot();
     $view->classOrId = $classOrId;
     $view->tab = self::getTab($group);
     $view->sections = self::getSections();
     $view->sectionsContent = self::getSectionsContent($group);
     $view->pages = $pages;
     $view->pluginAccess = \Hubzero\User\Group\Helper::getPluginAccess($group);
     // return template
     return $view->loadTemplate();
 }