Location: PHPKode > projects > Web2.0 community/group web site > web20groups_pre-alpha-2/include/CommonCustomControllerAction.php
<?php
	class CommonCustomControllerAction extends CustomControllerAction
	{
        const DEFAULT_PP_BLOGPOSTS  = 5;
        const DEFAULT_PP_VIDEOS     = 2;
        const DEFAULT_PP_GALLERIES  = 2;
        const DEFAULT_PP_POLLS      = 5;

		protected $usermenu, $selected_usermenu_item;

		protected $commonmenu, $selected_commonmenu_item;

		protected $submenu1, $submenu1_title, $selected_submenu1_item;
		
		protected $submenu2, $submenu2_title, $selected_submenu2_item;

        protected $tagspace, $selected_tag, $tagspace_title;

		public function init()
		{
			parent::init();

            $this->user_settings= new DatabaseObject_UserSettings($this->db);

			//initialize variables, as we won't check, whether the var is already defined or not
			$this->pagetitle= '';
			$this->currentpage= '';

            $submenu1= array();
            $submenu2= array();

			$this->logger = Zend_Registry::get('logger');

            $index= 0;
			//fill up common menu
			$this->commonmenu[$index]->controller= 'index';
			$this->commonmenu[$index]->name= 'Home';
			$this->commonmenu[$index]->action= 'index';
			$this->commonmenu[$index]->title= 'Unvisited/Unread items';
            $index++;

			$this->commonmenu[$index]->controller= 'blog';
			$this->commonmenu[$index]->name= 'Blog_posts';
			$this->commonmenu[$index]->action= 'view';
			$this->commonmenu[$index]->title= 'Blog Posts';
            $index++;

			$this->commonmenu[$index]->controller= 'poll';
			$this->commonmenu[$index]->name= 'Polls';
			$this->commonmenu[$index]->action= 'view';
			$this->commonmenu[$index]->title= 'Polls Archive';
            $index++;

			$this->commonmenu[$index]->controller= 'gallery';
			$this->commonmenu[$index]->name= 'Galleries';
			$this->commonmenu[$index]->action= 'view';
			$this->commonmenu[$index]->title= 'Photo Gallery';
            $index++;

			$this->commonmenu[$index]->controller= 'video';
			$this->commonmenu[$index]->name= 'Videos';
			$this->commonmenu[$index]->action= 'view';
			$this->commonmenu[$index]->title= 'Videos';
            $index++;

			$this->commonmenu[$index]->controller= 'profile';
			$this->commonmenu[$index]->name= 'Profiles';
			$this->commonmenu[$index]->action= 'view';
			$this->commonmenu[$index]->title= 'Profiles';
            $index++;

			$this->commonmenu[$index]->controller= 'game';
			$this->commonmenu[$index]->name= 'Games';
			$this->commonmenu[$index]->action= 'index';
			$this->commonmenu[$index]->title= 'Game Konsole';
            $index++;

            $group_params=Zend_Registry::get('group');
            $this->view->grouptitle= $group_params->title;
            $this->view->groupcaption= $group_params->caption;

            $this->view->pagetitle= $group_params->caption;
		}

		public function preDispatch()
		{
			parent::preDispatch();

            //todo: This should be moved to some other location to be efficient

            if ($this->user_id != '') {
                $this->user_settings->load($this->user_id);
            }

            if ($this->user_settings->pp_blogposts == 0)
    			$this->user_settings->pp_blogposts= self::DEFAULT_PP_BLOGPOSTS;

            if ($this->user_settings->pp_videos == 0)
    			$this->user_settings->pp_videos= self::DEFAULT_PP_VIDEOS;

            if ($this->user_settings->pp_galleries == 0)
    			$this->user_settings->pp_galleries= self::DEFAULT_PP_GALLERIES;

            if ($this->user_settings->pp_polls == 0)
    			$this->user_settings->pp_polls= self::DEFAULT_PP_POLLS;
        
		}

		protected function addUserMenu()
		{
		    $usermenu_index= count($this->usermenu);

            if ($this->user_type == 'administrator') {
                $this->usermenu[$usermenu_index]->controller= 'admin';
                $this->usermenu[$usermenu_index]->name= 'Admin tasks';
                $this->usermenu[$usermenu_index]->action= 'index';
                $this->usermenu[$usermenu_index]->url= '';
                $this->usermenu[$usermenu_index]->title= 'Add/delete/suspend Accounts';
                $usermenu_index += 1;
            }

			$this->usermenu[$usermenu_index]->controller= 'account';
			$this->usermenu[$usermenu_index]->name= 'My Account';
			$this->usermenu[$usermenu_index]->action= 'details';
			$this->usermenu[$usermenu_index]->url= '';
			$this->usermenu[$usermenu_index]->title= 'Edit Your Account Details';
			$usermenu_index += 1;

			$this->usermenu[$usermenu_index]->controller='account';
			$this->usermenu[$usermenu_index]->name= 'Logout ('. $this->username . ')';
			$this->usermenu[$usermenu_index]->action= 'logout';
			$this->usermenu[$usermenu_index]->url= '';
			$this->usermenu[$usermenu_index]->title= 'Logout';
			$usermenu_index += 1;
		}

		protected function fillViewVariables()
		{
			$this->view->commonmenu= $this->commonmenu;

			$this->view->usermenu= $this->usermenu;
			$this->view->selected_usermenu_item= $this->selected_usermenu_item; 
			//This has to be a class object TODO later
			$this->objectinfo->objtype= $this->getRequest()->getControllerName();
		
			$this->view->selected_commonmenu_item= $this->selected_commonmenu_item;

			$this->view->objectinfo= $this->objectinfo;

			$this->view->selected_submenu1_item= $this->selected_submenu1_item;
			$this->view->submenu1_title= $this->submenu1_title;
			$this->view->submenu1= $this->submenu1;

			$this->view->selected_submenu2_item= $this->selected_submenu2_item;
			$this->view->submenu2_title= $this->submenu2_title;
			$this->view->submenu2= $this->submenu2;

			$this->view->selected_tag= $this->selected_tag;
			$this->view->tagspace_title= $this->tagspace_title;
			$this->view->tagspace= $this->tagspace;

			$this->view->currentpage= $this->currentpage;

			if ($this->pagetitle != '' )
                $this->view->pagetitle= $this->pagetitle;
		}

	}
?>
Return current item: Web2.0 community/group web site