Пример #1
0
 /**
  * Stocke dans la vue, pour un groupe, les groupes et les couches, qui sont son enfant et qui ne sont pas son enfant
  * @param int $id Groupe courant
  */
 private function definirCouchesPourSelecteur($id = 0)
 {
     $id = intval($id);
     $couchesEnfantDeGroupe = array();
     $couchesPasEnfantDeGroupe = array();
     $groupe = IgoGroupe::findFirst($id);
     $estAdmin = $this->session->get("info_utilisateur")->estAdmin;
     if ($estAdmin) {
         //Couches qui ne sont pas dans le groupe
         $sql = "SELECT DISTINCT c.id , c.mf_layer_name AS valeur " . "FROM igo_couche AS c " . "LEFT JOIN igo_groupe_couche AS gc ON c.id = gc.couche_id WHERE gc.groupe_id <> {$id} " . "AND NOT EXISTS (SELECT id FROM igo_groupe_couche AS sr_gc WHERE sr_gc.couche_id = c.id AND sr_gc.groupe_id = {$id}) ";
         $igo_groupe = new IgoGroupe();
         $couchesPasEnfantDeGroupe = new Resultset(null, $igo_groupe, $igo_groupe->getReadConnection()->query($sql));
     } else {
         $profils = $this->getDi()->getSession()->get("profils");
         $ids_profil = array();
         foreach ($profils as $profil) {
             $ids_profil[] = $profil["id"];
         }
         $ids_profil = implode(',', $ids_profil);
         //Couches qui ne sont pas dans le groupe
         $sql = "SELECT DISTINCT c.id , c.mf_layer_name AS valeur\n                    FROM igo_couche AS c \n                    LEFT JOIN igo_groupe_couche AS gc  ON c.id = gc.couche_id \n                    INNER JOIN IgoVuePermissionsPourCouches AS vpc\n                    ON vpc.couche_id = gc.id\n                    WHERE gc.groupe_id <> :groupe_id:\n                    AND est_association AND profil_id IN ({$ids_profil})";
         $couchesPasEnfantDeGroupe = $this->modelsManager->executeQuery($sql, array('groupe_id' => $id));
     }
     $estGroupeDeCouche = $groupe->couches->count();
     $this->view->setVar("estGroupeDeCouche", $estGroupeDeCouche);
     //Couches qui sont dans le groupe
     foreach ($groupe->couches as $value) {
         $couchesEnfantDeGroupe[] = array("id" => $value->id, "valeur" => $value->mf_layer_name);
     }
     $this->view->setVar("couchesPasEnfantDeGroupe", $couchesPasEnfantDeGroupe);
     $this->view->setVar("couchesEnfantDeGroupe", $couchesEnfantDeGroupe);
 }
Пример #2
0
 public static function findEstAssociable($params = null)
 {
     $profils = \Phalcon\DI::getDefault()->getSession()->get("info_utilisateur")->profils;
     $profil_ids = array();
     foreach ($profils as $profil) {
         array_push($profil_ids, $profil["id"]);
     }
     $profil_ids = implode(",", $profil_ids);
     $sql = "SELECT DISTINCT igo_vue_permissions_pour_groupes.groupe_id AS id, " . " igo_groupe.nom AS nom " . "FROM igo_vue_permissions_pour_groupes " . "INNER JOIN igo_groupe ON igo_groupe.id = igo_vue_permissions_pour_groupes.groupe_id " . "WHERE igo_vue_permissions_pour_groupes.profil_id IN ({$profil_ids}) AND igo_vue_permissions_pour_groupes.est_association ";
     $igo_groupe = new IgoGroupe();
     return new \Phalcon\Mvc\Model\Resultset\Simple(null, $igo_groupe, $igo_groupe->getReadConnection()->query($sql, $params));
 }