[ Index ] |
|
Code source de SPIP Agora 1.4 |
1 <?php 2 /***************************************************** 3 * This file is part of Agora, web based content management system. 4 * 5 * Agora is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; version 2 of the License. 8 * 9 * Agora is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details (file "COPYING"). 13 * 14 * Copyright © Arnaud Martin, Antoine Pitrou et Philippe Rivière. 15 * List of authors detailed in "copyright_fr.html" file. 16 * E-mail : agora@sig.premier-ministre.gouv.fr 17 * Web site : http://www.agora.gouv.fr 18 *****************************************************/ 19 // Base class for Action "changerStatutMessage". 20 // 21 22 if (defined("_AUTHORIZATION_CHANGER_STATUT_MESSAGE_COMMON")) 23 return; 24 25 define("_AUTHORIZATION_CHANGER_STATUT_MESSAGE_COMMON", "1"); 26 27 require_once dirname(__FILE__). "/../Action.php"; 28 require_once(dirname(__FILE__). "/../../bd/inc_rubrique_factory.php"); 29 require_once(dirname(__FILE__). "/../../bd/inc_forum_factory.php"); 30 require_once(dirname(__FILE__). "/../../bd/inc_breve_factory.php"); 31 require_once(dirname(__FILE__). "/../../bd/inc_article_factory.php"); 32 33 /** 34 * changerStatutMessage is an implementation for Common of "changerStatutMessage Action. 35 * @package authorization/common 36 * @author François Xavier LACROIX <fxlacroix@clever-age.com> 37 * @access public 38 */ 39 class changerStatutMessage_common extends Action { 40 41 // {{{ _isAuthorized() 42 43 /** 44 * Get if a user is authorized to access to a command 45 * @access private 46 * @return bool 47 */ 48 49 function _isAuthorized () { 50 51 //Recuperation du type de forum 52 $forumMetier = &recuperer_instance_forum(); 53 $loadOK = $forumMetier->load($this->_parameters['id_forum']); 54 55 if (PEAR::isError($loadOK)) { 56 die($loadOK->getMessage()); 57 } 58 59 if ($forumMetier->getArticleId()) 60 $typeForum = 'article'; 61 62 if ($forumMetier->getBreveId()) 63 $typeForum = 'breve'; 64 65 if ($forumMetier->getRubriqueId()) 66 $typeForum = 'rubrique'; 67 68 switch ($typeForum) { 69 case 'article': 70 71 //verification si l'auteur peut acceder a la rubrique contenant l'article 72 $articleMetier = &recuperer_instance_article(); 73 $loadOK = $articleMetier->load($forumMetier->getArticleId()); 74 if (PEAR::isError($loadOK)) { 75 echo $loadOK->getMessage(); 76 return false; 77 } 78 $rubriqueMetier = &recuperer_instance_rubrique(); 79 //$accesOK = $rubriqueMetier->isManagedByAuteurId($articleMetier->getRubriqueId(), $this->_user->getAuteurId()); 80 $accesOK = $this->cacheAllowsRubrique($articleMetier->getRubriqueId()); 81 break; 82 83 case 'rubrique': 84 //verification si l'auteur peut acceder a la rubrique 85 $rubriqueMetier = &recuperer_instance_rubrique(); 86 // $accesOK = $rubriqueMetier->isManagedByAuteurId($forumMetier->getRubriqueId(), $this->_user->getAuteurId()); 87 $accesOK = $this->cacheAllowsRubrique($forumMetier->getRubriqueId()); 88 break; 89 90 case 'breve': 91 //verification si l'auteur peut acceder a la rubrique contenant la breve 92 $breveMetier = &recuperer_instance_breve(); 93 $loadOK = $breveMetier->load($forumMetier->getBreveId()); 94 if (PEAR::isError($loadOK)) { 95 echo $loadOK->getMessage(); 96 return false; 97 } 98 $rubriqueMetier = &recuperer_instance_rubrique(); 99 // $accesOK = $rubriqueMetier->isManagedByAuteurId($breveMetier->getRubriqueId(), $this->_user->getAuteurId()); 100 $accesOK = $this->cacheAllowsRubrique($breveMetier->getRubriqueId()); 101 break; 102 103 default: 104 $accesOK = false; 105 break; 106 } 107 108 if ($accesOK) { 109 switch ($this->_parameters['statut']) { 110 case 'publie': 111 $authorization = &recuperer_instance_authorization( 112 'publierMessage', $this->_user->getAuteurId(), 113 array('id_auteur_slave' => $this->_parameters['id_auteur'])); 114 return $authorization->isAuthorizedAction(); 115 break; 116 117 case 'off': 118 $authorization = &recuperer_instance_authorization( 119 'refuserMessage', $this->_user->getAuteurId(), 120 array('id_auteur_slave' => $this->_parameters['id_auteur'])); 121 return $authorization->isAuthorizedAction(); 122 break; 123 124 case 'poubelle': 125 $authorization = &recuperer_instance_authorization( 126 'mettrePoubelleMessage', $this->_user->getAuteurId(), 127 array('id_auteur_slave' => $this->_parameters['id_auteur'])); 128 return $authorization->isAuthorizedAction(); 129 break; 130 131 default: 132 return false; 133 break; 134 } 135 } 136 else { 137 return false; 138 } 139 } 140 141 // }}} 142 143 } 144 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 14:40:03 2007 | par Balluche grâce à PHPXref 0.7 |