/** * Retourne un modèle de nom prédéfini pour un utilisateur et une classe donnés * * @param CMediusers $user User * @param string $object_class Target Class * @param string $name Model Name * * @return CCompteRendu|null */ static function getSpecialModel($user, $object_class, $name) { if (!isset(self::$special_names[$object_class][$name])) { self::error("no_special", $object_class, $name); return null; } $model = new CCompteRendu(); if (!$user->_id) { return $model; } $model->nom = $name; $model->object_class = $object_class; $model->type = CCompteRendu::$special_names[$object_class][$name]; // Utilisateur $model->user_id = $user->_id; $model->loadMatchingObject(); if ($model->_id) { return $model; } // Fonction $model->user_id = null; $model->function_id = $user->function_id; $model->loadMatchingObject(); if ($model->_id) { return $model; } // Etablissement $user->loadRefFunction(); $model->function_id = null; $model->group_id = $user->_ref_function->group_id; $model->loadMatchingObject(); return $model; }