public function obtenirProfils() { $profils = array(); $profilsIgo = IgoProfil::find(); foreach ($profilsIgo as $profil) { array_push($profils, $profil->toArray()); } return $profils; }
public static function findProfilsByProfilsProprietaires() { $profils = \Phalcon\DI::getDefault()->getSession()->get("info_utilisateur")->profils; $profils_proprietaires_ids = array(); foreach ($profils as $profil) { array_push($profils_proprietaires_ids, $profil["id"]); } $str = implode(',', $profils_proprietaires_ids); $sql = "SELECT id, libelle FROM igo_profil WHERE profil_proprietaire_id IN ({$str})"; $igo_profils = new IgoProfil(); return new \Phalcon\Mvc\Model\Resultset\Simple(null, $igo_profils, $igo_profils->getReadConnection()->query($sql)); }
function obtenirUtilisateurProfilsInQuery() { global $app; $authentificationModule = $app->getDI()->get("authentificationModule"); if (estAnonyme($app->getDI()->getSession())) { $configuration = $app->getDI()->get("config"); if (!isset($configuration->application->authentification->nomProfilAnonyme)) { return (string) '0'; } return (string) '0,' . IgoProfil::findFirst("nom = '{$configuration->application->authentification->nomProfilAnonyme}'")->id; } if (!is_null($app->getDI()->getSession()->get("info_utilisateur")->profilActif)) { $profil = $app->getDI()->getSession()->get("info_utilisateur")->profilActif; return (string) '0,' . $profil; } else { $profils = obtenirProfils($app->getDI()->getSession()); $profilsArray = array(); foreach ($profils as $profil) { array_push($profilsArray, $profil["id"]); } array_push($profilsArray, 0); // défaut return implode(",", $profilsArray); } }
public function anonymeAction($estAuthentifier = FALSE) { $configuration = $this->getDI()->get("config"); if ($configuration->application->authentification->permettreAccesAnonyme) { if (!$this->session->has("info_utilisateur")) { $this->session->set("info_utilisateur", new SessionController()); } if (estAuthentifier !== TRUE) { $this->session->get("info_utilisateur")->estAuthentifie = false; $this->session->get("info_utilisateur")->estAnonyme = true; } if ($configuration->offsetExists("database")) { if ($configuration->application->authentification->activerSelectionRole) { $this->session->get("info_utilisateur")->profilActif = IgoProfil::findFirst("nom = '{$configuration->application->authentification->nomProfilAnonyme}'")->id; } else { $this->session->get("info_utilisateur")->profils = IgoProfil::find("nom = '{$configuration->application->authentification->nomProfilAnonyme}'")->toArray(); } } return $this->redirigeVersPage(); } else { $this->dispatcher->forward(array("controller" => "error", "action" => "error403")); } }
public function beforeExecuteRoute(Phalcon\Events\Event $event, Phalcon\Mvc\Dispatcher $dispatcher) { $authentificationModule = $this->getDI()->get("authentificationModule"); if ($authentificationModule == null) { return; } $controller = $dispatcher->getControllerName(); $action = $dispatcher->getActionName(); $config = $this->getDI()->get("config"); if ($controller === "connexion" || $controller === "error") { $config = $this->getDI()->get("config"); $this->getDI()->get("view")->setViewsDir($config->application->services->viewsDir); } else { if ($controller === "igo" && ($action === "configuration" || $action === "index")) { $configuration = $this->obtenirConfiguration($action, $dispatcher); if (isset($this->getDi()->getConfig()->configurations[$configuration])) { $file = $this->getDi()->getConfig()->configurations[$configuration]; } else { $file = $this->getDi()->getConfig()->configurationsDir . $configuration . '.xml'; } if (!file_exists($file) && !curl_url_exists($file)) { return $this->forwardToErrorPage(); } if ($this->estAuthentificationRequise($configuration) && !$this->estAnonyme() && !$this->estAuthentifie()) { return $this->forwardToLoginPage(); } else { if ($this->estAuthentificationRequise($configuration) && $this->estRoleSelectionneRequis() && !$this->estRoleSelectionne()) { return $this->forwardToRolePage(); } else { if (!$this->estAuthentificationRequise($configuration) && !$this->estAuthentifie()) { $authentificationModule = $this->getDI()->get("authentificationModule"); if (!$this->session->has("info_utilisateur")) { $this->session->set("info_utilisateur", new SessionController()); } $configuration = $this->getDI()->get("config"); if ($configuration->offsetExists("database")) { // Si la BD n'existe pas dans la config on n'ajoute pas de profil et on se base sur le xml if ($this->estRoleSelectionneRequis()) { $this->session->get("info_utilisateur")->profilActif = IgoProfil::findFirst("nom = '{$configuration->application->authentification->nomProfilAnonyme}'")->id; } else { if (isset($configuration->application->authentification->nomProfilAnonyme)) { $this->session->get("info_utilisateur")->profils = IgoProfil::find("nom = '{$configuration->application->authentification->nomProfilAnonyme}'"); } } } $this->session->get("info_utilisateur")->estAnonyme = true; } else { if ($this->estRoleSelectionneRequis() && !$this->estRoleSelectionne()) { return $this->forwardToRolePage(); } } } } if ($this->estAnonyme() && isset($config->application->authentification->permettreAccesAnonyme) && !$config->application->authentification->permettreAccesAnonyme) { return $this->forwardToUnauthorizedPage(); } } else { if ($controller == "igo" && ($action == "contexte" || $action == "couche" || $action == "groupe")) { if (!$this->estAnonyme() && !$this->estAuthentifie()) { return $this->forwardToLoginPage(); } else { if ($this->estRoleSelectionneRequis() && !$this->estRoleSelectionne()) { return $this->forwardToRolePage(); } } if ($this->estAnonyme() && isset($config->application->authentification->permettreAccesAnonyme) && !$config->application->authentification->permettreAccesAnonyme) { return $this->forwardToUnauthorizedPage(); } } } } }
public function arbreCouchesEditAction($param) { $params = array(); $deleted = false; parse_str($param, $params); $profil_id = isset($params['profil_id']) ? $params['profil_id'] : false; if (!$profil_id) { $this->flash->error("igo_profil non-trouvé"); return $this->dispatcher->forward(array("controller" => "igo_profil", "action" => "index")); } //On récupère les données du formulaire Associer des groupes et des couches if (isset($_POST['valeursArbo'])) { $valeurs = json_decode($_POST['valeursArbo']); //On récupères les données de la rétro d'un mapfile } else { $valeurs = $_POST; } //Sauvegarde des items du formulaire $igoPermission = false; foreach ($valeurs as $name => $valeur) { if (!$deleted) { $phql = "DELETE FROM IgoPermission WHERE profil_id={$profil_id}"; $this->modelsManager->executeQuery($phql); $deleted = true; //var_dump($deleted); } $couche_id = null; $changed = false; $type = null; $titre = null; //Déterminer à quoi on a affaire if ('G' == substr($name, 0, 1)) { $type = 'groupe'; $a = explode("_", substr($name, 2)); $groupe_id = array_pop($a); } elseif ('CX' == substr($name, 0, 2)) { $type = 'colonne'; $a = explode("_", substr($name, 2)); $attribut_id = array_pop($a); $couche_id = substr($name, 2, strpos($name, "_") - 2); } elseif ('C' == substr($name, 0, 1)) { $type = 'couche'; $couche_id = explode("_", substr($name, 2))[0]; } //if (isset($valeur)&& $valeur!=0){ // printf("name: %s, groupe_id: %s, couche_id: %s, type: %s, valeur: %s<br>", $name, $groupe_id, $couche_id, $type, $valeur); // } //Tenter de récupérer le igo_couche_contexte associé switch ($type) { case 'groupe': if (!$igoPermission || $igoPermission->groupe_id != $groupe_id) { $igoPermission = IgoPermission::findFirst("profil_id={$profil_id} AND groupe_id={$groupe_id} AND attribut_id is null"); } break; case 'colonne': $igoPermission = IgoPermission::findFirst("profil_id={$profil_id} AND attribut_id={$attribut_id}"); break; case 'couche': if (!$igoPermission || $igoPermission->couche_id != $couche_id) { $igoPermission = IgoPermission::findFirst("profil_id={$profil_id} AND couche_id={$couche_id} AND attribut_id is null"); } break; } if (!$igoPermission && $valeur) { $changed = true; $igoPermission = new IgoPermission(); $igoPermission->profil_id = $profil_id; switch ($type) { case 'groupe': $igoPermission->groupe_id = $groupe_id; break; case 'colonne': //$igoGroupeCouche = IgoGroupeCouche::findFirst('id=' . $couche_id); // if (!$igoGroupeCouche) { // $this->flash->error("La couche ayant le igo_couche.id « $couche_id » n'existe pas."); // } $igoCouche = IgoCouche::findFirst('id=' . $couche_id); if (!$igoCouche) { $this->flash->error("La couche ayant le igo_couche.id « {$couche_id} » n'existe pas."); } $igoPermission->attribut_id = $attribut_id; $igoPermission->couche_id = $couche_id; $igoPermission->est_exclu = null; $igoPermission->couche_id = $couche_id; break; case 'couche': // $igoGroupeCouche = IgoGroupeCouche::findFirst('id=' . $couche_id); //// if (!$igoGroupeCouche) { // $this->flash->error("La couche ayant le igo_couche.id « $couche_id » n'existe pas."); // } $igoCouche = IgoCouche::findFirst('id=' . $couche_id); if (!$igoCouche) { $this->flash->error("La couche ayant le igo_couche.id « {$couche_id} » n'existe pas."); } $igoPermission->couche_id = $couche_id; //$igoPermission->couche_id = $igoGroupeCouche->couche_id; break; } } if ($igoPermission) { $valeur = $valeur == '1'; $attribut = substr($name, 1, 1); switch ($attribut) { case "L": //$changed = $changed || ($igoPermission->est_lecture) <> $valeur; $igoPermission->est_lecture = $igoPermission->est_lecture || $valeur; break; case "A": // $changed = $changed || ($igoPermission->est_analyse) <> $valeur; $igoPermission->est_analyse = $igoPermission->est_analyse || $valeur; break; case "E": // $changed = $changed || ($igoPermission->est_ecriture) <> $valeur; $igoPermission->est_ecriture = $igoPermission->est_ecriture || $valeur; break; case "P": // $changed = $changed || ($igoPermission->est_export) <> $valeur; $igoPermission->est_export = $igoPermission->est_export || $valeur; break; case "S": // $changed = $changed || ($igoPermission->est_association) <> $valeur; $igoPermission->est_association = $igoPermission->est_association || $valeur; break; case "X": // $changed = $changed || ($igoPermission->est_exclu) <> $valeur; $igoPermission->est_exclu = $igoPermission->est_exclu || $valeur; break; } } if ($valeur) { if (!$igoPermission->save()) { foreach ($igoPermission->getMessages() as $message) { $this->flash->error($message); } } } } /* //Supprimer les permissions qui n'ont plus lieu d'être $igoPermissions = IgoPermission::find('NOT (COALESCE(est_lecture,false) OR COALESCE(est_analyse,false) OR COALESCE(est_ecriture,false) OR COALESCE(est_export,false) OR COALESCE(est_association,false) OR COALESCE(est_exclu,false))'); foreach ($igoPermissions as $igoPermission) { $igoPermission->delete(); }*/ $igo_profil = IgoProfil::findFirstByid($profil_id); if (!$igo_profil) { $this->flash->error("igo_permission non-trouvé"); return $this->dispatcher->forward(array("controller" => "igo_permission", "action" => "index")); } $this->view->igo_profil = $igo_profil; ///****À TESTER ****/// $profils = $this->session->get("profils"); $liste_profil_id_utilisateur = array(); if ($profils) { foreach ($profils as $profil) { array_push($liste_profil_id_utilisateur, $profil["id"]); } } $liste_profil_id_utilisateur = implode(",", $liste_profil_id_utilisateur); if (!$liste_profil_id_utilisateur) { $liste_profil_id_utilisateur = 0; } $sql = " select 'G'::character varying(1) AS type,\n gr.groupe_id as id,\n gr.nom,\n gr.nom_complet AS mf_layer_meta_group_title,\n gr.groupe_id AS groupe_id,\n NULL::integer AS attribut_id,\n false AS lecture,\n false AS analyse_spa,\n false AS ecriture,\n false AS export,\n false AS association,\n false AS exclu,\n NULL::text AS colonne,\n NULL::integer AS couche_id,\n p.id AS permission_id,\n true AS association_est_association,\n gr.grp,\n (length(grp) - length(replace(grp, '_'::text, ''::text))) as len\n from igo_vue_groupes_recursif gr\n LEFT JOIN igo_permission p ON p.groupe_id=gr.groupe_id AND p.profil_id={$profil_id} and p.couche_id IS NULL\n --LEFT JOIN igo_vue_permissions_pour_groupes pg ON pg.profil_id IN ({$liste_profil_id_utilisateur})\n WHERE NOT (gr.grp IN ( SELECT substr(grp, strpos(concat(grp, '_'), '_'::text) + 1) AS substr\n FROM igo_vue_groupes_recursif)) \n UNION\n select 'C'::character varying(1) AS type,\n c.id,\n c.mf_layer_meta_title AS nom,\n gr.nom_complet AS mf_layer_meta_group_title,\n gc.groupe_id AS groupe_id,\n igo_attribut.id AS attribut_id,\n COALESCE(p.est_lecture, false) AS lecture,\n COALESCE(p.est_analyse, false) AS analyse_spa,\n COALESCE(p.est_ecriture, false) AS ecriture,\n COALESCE(p.est_export, false) AS export,\n COALESCE(p.est_association, false) AS association,\n COALESCE(p2.est_exclu, false) AND igo_attribut.id = p2.attribut_id AS exclu,\n igo_attribut.colonne AS colonne,\n c.id AS couche_id,\n p.id AS permission_id,\n igo_vue_permissions_pour_couches.est_association AS association_est_association,\n gr.grp,\n (length(grp) - length(replace(grp, '_'::text, ''::text))) as len\n from igo_vue_groupes_recursif gr\n JOIN igo_groupe_couche gc ON gc.groupe_id=gr.groupe_id\n JOIN igo_couche c ON gc.couche_id=c.id\n JOIN igo_geometrie ON c.geometrie_id = igo_geometrie.id\n LEFT JOIN igo_attribut ON igo_attribut.geometrie_id = igo_geometrie.id\n LEFT JOIN igo_permission p ON c.id=p.couche_id AND p.profil_id={$profil_id} and p.attribut_id IS NULL\n LEFT JOIN igo_permission p2 ON c.id=p.couche_id AND p.profil_id={$profil_id} and p2.attribut_id IS NOT NULL and p2.attribut_id=igo_attribut.id\n LEFT JOIN igo_vue_permissions_pour_couches ON igo_vue_permissions_pour_couches.couche_id = p.id \n WHERE NOT (gr.grp IN ( SELECT substr(grp, strpos(concat(grp, '_'), '_'::text) + 1) AS substr\n FROM igo_vue_groupes_recursif)) \n ORDER BY grp, len, type DESC"; //echo $sql; $igo_permission = new IgoPermission(); $igo_permission = new Resultset(null, $igo_permission, $igo_permission->getReadConnection()->query($sql)); $this->view->setVar("arbre", $igo_permission); }