/** * Charge les listes d'un utilisateur * * @param int $user_id User ID * @param int $function_id Function ID * * @return self[] */ static function loadAllFor($user_id, $function_id) { $user = CMediusers::get($user_id); $function = new CFunctions(); $function->load($function_id); // Accès aux listes de choix de la fonction et de l'établissement $module = CModule::getActive("dPcompteRendu"); $is_admin = $module && $module->canAdmin(); $access_function = $is_admin || CAppUI::conf("compteRendu CListeChoix access_function"); $access_group = $is_admin || CAppUI::conf("compteRendu CListeChoix access_group"); $listes = array(); if ($user->_id && !$function_id) { $listes["prat"] = array(); } if ($access_function) { $listes["func"] = array(); } if ($access_group) { $listes["etab"] = array(); } if ($user->_id && !$function_id) { foreach ($user->getOwners() as $type => $owner) { if (isset($listes[$type])) { $listes[$type] = $owner->loadBackRefs("listes_choix", "nom"); } } } else { foreach ($function->getOwners() as $type => $owner) { if (isset($listes[$type])) { $listes[$type] = $owner->loadBackRefs("listes_choix", "nom"); } } } return $listes; }
* @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version SVN: $Id:\$ * @link http://www.mediboard.org */ CCanDo::checkRead(); $liste_id = CValue::getOrSession("liste_id"); $user_id = CValue::getOrSession("user_id"); $function_id = CValue::getOrSession("function_id"); if ($user_id) { $user = CMediusers::get($user_id); $owners = $user->getOwners(); } else { $function = new CFunctions(); $function->load($function_id); $owners = $function->getOwners(); $user_id = ""; } $listes = CListeChoix::loadAllFor($user_id, $function_id); // Modèles associés foreach ($listes as $_listes) { foreach ($_listes as $_liste) { /** @var $_liste CListeChoix */ $_liste->loadRefModele(); } } // Création du template $smarty = new CSmartyDP(); $smarty->assign("liste_id", $liste_id); $smarty->assign("owners", $owners); $smarty->assign("listes", $listes);