summaryrefslogblamecommitdiffstats
path: root/modules-available/dozmod/page.inc.php
blob: 57e5ca4c03abe1b6e94c8affaeeffd1d860760be (plain) (tree)
1
2
3
4
5
6
7
8
9



                              


                                                         

                                                                                                                    

                         


                                       
                                                 

                                                            
                                                                          















                                                                                                                     
         




                                         
                                          
                                                                


                                                   
                                      





                                                                               

                 






                                                                     
                                                                     
                                                                   
                                                                  
                                                                    
                  
 



                                                                                                                                            
                         
                 



                                     
                                                            

                                                   


                               

         

                                   
                             
                                      


                                                   


                               

         
 
<?php

class Page_DozMod extends Page
{
	/** @var bool true if we have a proper subpage */
	private $haveSubPage = false;

	private $validSections = ['expiredimages', 'mailconfig', 'templates', 'runtimeconfig', 'users', 'actionlog',
		'networkshares', 'ldapfilters', 'runscripts', 'networkrules', 'special'];

	private $section;

	private function setupSubPage()
	{
		if ($this->haveSubPage !== false)
			return;
		/* different pages for different sections */
		$this->section = Request::any('section', false, 'string');
		if ($this->section === false) {
			foreach ($this->validSections as $this->section) {
				if (User::hasPermission($this->section . '.*'))
					break;
			}
		} elseif (!in_array($this->section, $this->validSections)) {
			Util::traceError('Invalid section: ' . $this->section);
		}
		// Check permissions
		User::assertPermission($this->section . '.*');
		$include = 'modules/' . Page::getModule()->getIdentifier() . '/pages/' . $this->section . '.inc.php';
		if (!file_exists($include))
			return;

		require_once $include;
		$this->haveSubPage = true;
	}

	protected function doPreprocess()
	{
		User::load();

		if (!User::isLoggedIn()) {
			Message::addError('main.no-permission');
			Util::redirect('?do=Main');
		}

		$this->setupSubPage();
		if ($this->haveSubPage !== false) {
			SubPage::doPreprocess();
		}
		// Catch unhandled POST redirect
		if (Request::isPost()) {
			Util::redirect('?do=dozmod&section=' . $this->section);
		}

		/* Leave this here for translation module
		Dictionary::translate('submenu_expiredimages', true);
		Dictionary::translate('submenu_mailconfig', true);
		Dictionary::translate('submenu_templates', true);
		Dictionary::translate('submenu_runtimeconfig', true);
		Dictionary::translate('submenu_users', true);
		Dictionary::translate('submenu_actionlog', true);
		Dictionary::translate('submenu_networkshares', true);
		Dictionary::translate('submenu_ldapfilters', true);
		Dictionary::translate('submenu_runscripts', true);
		Dictionary::translate('submenu_networkrules', true);
		*/

		/* add sub-menus */
		foreach ($this->validSections as $section) {
			if (User::hasPermission($section . '.*')) {
				Dashboard::addSubmenu('?do=dozmod&section=' . $section, Dictionary::translate('submenu_' . $section, true));
			}
		}
	}

	protected function doRender()
	{
		/* different pages for different sections */
		if ($this->haveSubPage !== false) {
			SubPage::doRender();
			return;
		}

	}

	protected function doAjax()
	{
		User::load();
		$this->setupSubPage();

		if ($this->haveSubPage !== false) {
			SubPage::doAjax();
			return;
		}

	}

}