openrat-cms

# OpenRat Content Management System
git clone http://git.code.weiherhei.de/openrat-cms.git
Log | Files | Refs

ProjectlistAction.class.php (3548B)


      1 <?php
      2 
      3 namespace cms\action;
      4 
      5 use cms\model\Acl;
      6 use cms\model\Folder;
      7 use cms\model\Project;
      8 
      9 // OpenRat Content Management System
     10 // Copyright (C) 2002-2012 Jan Dankert, cms@jandankert.de
     11 //
     12 // This program is free software; you can redistribute it and/or
     13 // modify it under the terms of the GNU General Public License
     14 // as published by the Free Software Foundation; either version 2
     15 // of the License, or (at your option) any later version.
     16 //
     17 // This program is distributed in the hope that it will be useful,
     18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
     19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     20 // GNU General Public License for more details.
     21 //
     22 // You should have received a copy of the GNU General Public License
     23 // along with this program; if not, write to the Free Software
     24 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
     25 
     26 
     27 /**
     28  * Action-Klasse zum Bearbeiten eines Projektes
     29  * @author $Author$
     30  * @version $Revision$
     31  * @package openrat.actions
     32  */
     33 class ProjectlistAction extends BaseAction
     34 {
     35 	public $security = Action::SECURITY_USER;
     36 	
     37 	function __construct()
     38 	{
     39         parent::__construct();
     40 	}
     41 
     42 
     43 	/**
     44 	 * Liste aller Projekte anzeigen.
     45 	 *
     46 	 */
     47 	public function editView()
     48 	{
     49 		// Projekte ermitteln
     50 		$list = array();
     51 
     52 		foreach(Project::getAllProjects() as $id=> $name )
     53 		{
     54 
     55             // Schleife ueber alle Projekte
     56             foreach (Project::getAllProjects() as $id => $name) {
     57 
     58                 $project = new Project($id);
     59                 $rootFolder = new Folder($project->getRootObjectId());
     60                 $rootFolder->load();
     61 
     62                 // Berechtigt für das Projekt?
     63                 if ($rootFolder->hasRight(Acl::ACL_READ)) {
     64                     $list[$id]             = array();
     65                     $list[$id]['id'      ] = $id;
     66                     $list[$id]['name'    ] = $name;
     67                 }
     68             }
     69         }
     70 
     71 		$this->setTemplateVar('projects',$list);
     72 		$this->setTemplateVar('add',$this->userIsAdmin());
     73 	}
     74 	
     75 	
     76 	
     77 	function addView()
     78 	{
     79 	    if( ! $this->userIsAdmin() )
     80 	        throw new \SecurityException('user is not allowed to add a project');
     81 
     82 		$this->setTemplateVar( 'projects',Project::getAllProjects() );
     83 	}
     84 	
     85 
     86 	/**
     87 	 * Projekt hinzufuegen.
     88 	 *
     89 	 */
     90 	function addPost()
     91 	{
     92 	    if( !$this->userIsAdmin())
     93 	        throw new \SecurityException("user is not allowed to add a project");
     94 
     95         switch( $this->getRequestVar('type') )
     96         {
     97             case 'empty':
     98             case '':
     99                 if	( !$this->hasRequestVar('name') )
    100                     throw new \ValidationException('name');
    101 
    102                 $project = new Project();
    103                 $project->name = $this->getRequestVar('name');
    104                 $project->add();
    105                 $this->addNotice('project',$project->name,'ADDED');
    106                 break;
    107             case 'copy':
    108                 $db = db_connection();
    109                 $project = new Project($this->getRequestVar('projectid'));
    110                 $project->load();
    111                 $project->export($db->id);
    112                 $this->addNotice('project',$project->name,'DONE');
    113                 break;
    114             default:
    115                 throw new \LogicException('Unknown type while adding project '.$this->getRequestVar('type') );
    116         }
    117 
    118 	}
    119 	
    120 	
    121 	/**
    122 	 * Ermittelt die letzten Änderungen, die in allen Projekten gemacht worden sind.
    123 	 */
    124 	function historyView()
    125 	{
    126 		$result = Project::getAllLastChanges();
    127 		$this->setTemplateVar('timeline', $result);
    128 	}
    129 
    130 
    131 }