Location: PHPKode > projects > Web2.0 community/group web site > web20groups_pre-alpha-2/include/Controllers/AdminController.php
<?php
	
class AdminController extends CommonCustomControllerAction
{
    const ONEDAY= 8640;//24*60*60;

    public function init()
    {
        parent::init();
        $this->view->extra_styles= array(
                                            '/css/main.css',
                                            '/css/windowstyle.css',
                                        );
        $this->view->extra_scripts= array(
                                            '/js/main.js',
                                            '/js/mylib.inlineframe.class.js',
                                            '/js/mylib.menu.class.js'
                                         );
    }

	public function indexAction()
	{
        $this->createSubMenu();

        $this->addUserMenu();

        $this->selected_submenu1_item= $this->submenu1[0]->name;
        $this->selected_usermenu_item= 'Admin tasks';

        $this->fillViewVariables();
	}

    public function analyzelogsAction()
    {
        
    }

    public function pendingAction()
    {
        $msgcount= 0;
        $present_time= time();
        $time_48hrs_old= $present_time - 2* self::ONEDAY;

        $options['to']= date('Y-m-d H:i:s', $time_48hrs_old);
        $options['limit']= 1;

        $messages= DatabaseObject_Message::GetMessages($this->db, $options);

        if (count ($messages) > 0) {
            $pendingmsgflag= true;

            $request= $this->getRequest();
            $param_backup= $request->getParam('chatbackup');

            if ($param_backup != '') {
                //check if any messages are in database, which are more than 48 hrs
                //old move the messages which are older than 24hrs to files
                $time_24hrs_old= $present_time - self::ONEDAY;
                $options= array();  //don;t use the one used above. so reset
                $options['to']= date('Y-m-d H:i:s', $time_24hrs_old);
                $msgcount= DatabaseObject_Message::
                                backupOldMessages($this->db, $options);
            }
        }
        else {
            $pendingmsgflag= false;
        }
        
        $this->view->pendingmessages= $pendingmsgflag;
        $this->view->backupmsgcount= $msgcount;

    }

    public function createSubMenu()
    {
        $menu_index= 0;

        $this->submenu1[$menu_index]->controller= 'admin';
        $this->submenu1[$menu_index]->name= 'Pending Tasks';
        $this->submenu1[$menu_index]->action= 'pending';
        $this->submenu1[$menu_index]->title= 'Complete pending tasks';
        $this->submenu1[$menu_index]->url= $this->getUrl('pending', 'admin') ;
        $menu_index+= 1;

        $this->submenu1[$menu_index]->controller= 'account';
        $this->submenu1[$menu_index]->name= 'Create New Account';
        $this->submenu1[$menu_index]->action= 'register';
        $this->submenu1[$menu_index]->title= 'Register a new Account';
        $this->submenu1[$menu_index]->url= $this->getUrl('register', 'account') ;
        $menu_index+= 1;

        $this->submenu1[$menu_index]->controller= 'account';
        $this->submenu1[$menu_index]->name= 'Activate Account';
        $this->submenu1[$menu_index]->action= 'activate';
        $this->submenu1[$menu_index]->title= 'Activate a pending Account';
        $this->submenu1[$menu_index]->url= $this->getUrl('activate', 'account') ;
        $menu_index+= 1;

        $this->submenu1[$menu_index]->controller= 'account';
        $this->submenu1[$menu_index]->name= 'Suspend Account';
        $this->submenu1[$menu_index]->action= 'supsend';
        $this->submenu1[$menu_index]->title= 'Suspend existing Account';
        $this->submenu1[$menu_index]->url= $this->getUrl('suspend', 'account') ;
        $menu_index+= 1;

        $this->submenu1[$menu_index]->controller= 'account';
        $this->submenu1[$menu_index]->name= 'Resume Account';
        $this->submenu1[$menu_index]->action= 'resume';
        $this->submenu1[$menu_index]->title= 'Resume a suspended Account';
        $this->submenu1[$menu_index]->url= $this->getUrl('resume', 'account') ;
        $menu_index+= 1;

        $this->submenu1[$menu_index]->controller= 'account';
        $this->submenu1[$menu_index]->name= 'Delete Account';
        $this->submenu1[$menu_index]->action= 'delete';
        $this->submenu1[$menu_index]->title= 'Delete an exisiting Account';
        $this->submenu1[$menu_index]->url= $this->getUrl('delete', 'account') ;
        $menu_index+= 1;

        $this->submenu1[$menu_index]->controller= 'admin';
        $this->submenu1[$menu_index]->name= 'Analyze Logs';
        $this->submenu1[$menu_index]->action= 'analyzelogs';
        $this->submenu1[$menu_index]->title= 'Register a new Account';
        $this->submenu1[$menu_index]->url= $this->getUrl('analyzelogs', 'admin') ;
        $menu_index+= 1;
    }
}
	
?>
Return current item: Web2.0 community/group web site