public function getNomComplet($sansexclusion = false) { if ($sansexclusion) { $sql = " WITH RECURSIVE s(id, nom, groupe_id, est_exclu_arbre) AS" . " ( SELECT id, CAST(nom as VARCHAR(500)) as nom, groupe_id,est_exclu_arbre" . " FROM igo_groupe" . " UNION SELECT g.id, " . " CAST( s.nom||'/'||g.nom as VARCHAR(500))," . " g.groupe_id, g.est_exclu_arbre FROM igo_groupe g, s, igo_groupe_groupe gg " . " WHERE s.id = gg.parent_groupe_id and gg.groupe_id= g.id) " . " SELECT id, last(nom) as nom, last(groupe_id) as groupe_id " . " FROM s where id=" . $this->id . " group by id ORDER BY nom;"; } else { $sql = " WITH RECURSIVE s(id, nom, groupe_id, est_exclu_arbre) AS" . " ( SELECT id, CAST(nom as VARCHAR(500)) as nom, groupe_id,est_exclu_arbre " . " FROM igo_groupe" . " UNION SELECT g.id," . " CASE WHEN NOT s.est_exclu_arbre AND NOT g.est_exclu_arbre THEN CAST( s.nom||'/'||g.nom as VARCHAR(500))" . " WHEN s.est_exclu_arbre AND NOT g.est_exclu_arbre THEN CAST(g.nom as VARCHAR(500)) " . " WHEN NOT s.est_exclu_arbre AND g.est_exclu_arbre THEN CAST(s.nom as VARCHAR(500)) " . " ELSE CAST('' as VARCHAR(500)) " . " END, " . " g.groupe_id, g.est_exclu_arbre FROM igo_groupe g, s, igo_groupe_groupe gg " . " WHERE s.id = gg.parent_groupe_id and gg.groupe_id= g.id) " . " SELECT id, last(nom) as nom, last(groupe_id) as groupe_id, bool_or(est_exclu_arbre) " . " FROM s where id=" . $this->id . " group by id ORDER BY nom;"; } $igo_groupe = new IgoGroupe(); $igo_groupe = new Resultset(null, $igo_groupe, $igo_groupe->getReadConnection()->query($sql)); return $igo_groupe[0]->nom; }
public function arbreCouchesEditAction($param = null) { //var_dump($this->udate()); $deleted = false; $params = array(); parse_str($param, $params); $contexte_id = isset($params['contexte_id']) ? $params['contexte_id'] : $this->request->get('contexte_id'); if (!$contexte_id) { $this->flash->error("igo_contexte non-trouvé"); return $this->dispatcher->forward(array("controller" => "igo_contexte", "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 $igoCoucheContexte = false; foreach ($valeurs as $name => $valeur) { if (!$deleted) { $phql = "DELETE FROM IgoCoucheContexte WHERE contexte_id={$contexte_id}"; $this->modelsManager->executeQuery($phql); $deleted = true; //var_dump($deleted); } $arbre_id = null; $couche_id = null; $changed = false; $type = null; $titre = null; $ordre = 0; if ('T' == substr($name, 1, 1)) { $titre = $valeur; } if ('O' == substr($name, 1, 1)) { $ordre = $valeur; } //Déterminer à quoi on a affaire if ('G' == substr($name, 0, 1)) { $type = 'groupe'; $a = explode("_", substr($name, 2)); array_shift($a); $arbre_id = implode('_', $a); $groupe_id = array_pop($a); } elseif ('CX' == substr($name, 0, 2)) { $type = 'colonne'; $a = explode("_", substr($name, 2)); $attribut_id = array_pop($a); array_shift($a); $arbre_id = implode('_', $a); $couche_id = substr($name, 2, strpos($name, "_") - 2); } elseif ('C' == substr($name, 0, 1)) { $type = 'couche'; $a = explode("_", substr($name, 2)); array_shift($a); $arbre_id = implode('_', $a); $couche_id = explode("_", substr($name, 2))[0]; } if (isset($valeur) && $valeur != 0) { // printf("name: %s, arbre_id: %s, groupe_id: %s, couche_id: %s, type: %s, valeur: %s<br>", $name, $arbre_id, $groupe_id, $couche_id, $type, $valeur); } //Tenter de récupérer le igo_couche_contexte associé switch ($type) { case 'groupe': // echo "1"; if (!$igoCoucheContexte || $igoCoucheContexte->arbre_id != $arbre_id || $igoCoucheContexte->couche_id != null || $igoCoucheContexte->attribut_id != null) { // echo "-1R"; $igoCoucheContexte = null; //$igoCoucheContexte = IgoCoucheContexte::findFirst("contexte_id={$contexte_id} AND groupe_id={$groupe_id} AND couche_id IS NULL AND attribut_id is null"); // var_dump($igoCoucheContexte); } break; case 'colonne': // echo "3"; if (!$igoCoucheContexte || $igoCoucheContexte->arbre_id != $arbre_id || $igoCoucheContexte->couche_id != $couche_id || $igoCoucheContexte->attribut_id != $attribut_id) { // echo "-3R"; $igoCoucheContexte = null; //$igoCoucheContexte = IgoCoucheContexte::findFirst("contexte_id={$contexte_id} AND groupe_id={$groupe_id} AND attribut_id={$attribut_id} AND couche_id={$couche_id}"); } break; case 'couche': // echo "2"; if (!$igoCoucheContexte || $igoCoucheContexte->arbre_id != $arbre_id || $igoCoucheContexte->couche_id != $couche_id || $igoCoucheContexte->attribut_id != null) { // echo "-2R"; $igoCoucheContexte = null; //$igoCoucheContexte = IgoCoucheContexte::findFirst("contexte_id={$contexte_id} AND groupe_id={$groupe_id} AND couche_id={$couche_id} AND attribut_id is null"); //var_dump("contexte_id={$contexte_id} AND groupe_id={$groupe_id} AND couche_id={$couche_id} AND attribut_id is null"); } break; } //On n'a pas trouvé le igo_couche_contexte associé if (!$igoCoucheContexte && $valeur) { //echo "***Création***"; $changed = true; $igoCoucheContexte = new IgoCoucheContexte(); $igoCoucheContexte->contexte_id = $contexte_id; //Initialiser les champs du contexte switch ($type) { case 'groupe': $igoGroupe = IgoGroupe::findFirst("id=" . $groupe_id); if (!$igoGroupe) { $this->flash->error("Le groupe « {$groupe_id} » n'existe pas."); } $igoCoucheContexte->groupe_id = $groupe_id; $igoCoucheContexte->arbre_id = $arbre_id; $igoCoucheContexte->ind_fond_de_carte = 'D'; $igoCoucheContexte->mf_layer_meta_name = $igoGroupe->nom; $igoCoucheContexte->mf_layer_meta_title = $igoGroupe->nom; if (!is_null($titre) && "" != $titre) { $igoCoucheContexte->mf_layer_meta_group_title = $titre; } if (!is_null($ordre)) { $igoCoucheContexte->layer_a_order = $ordre; } $igoCoucheContexte->mf_layer_meta_z_order = $igoGroupe->mf_layer_meta_z_order; break; case 'colonne': $igoCoucheContexte->couche_id = $couche_id; $igoCoucheContexte->groupe_id = $groupe_id; $igoCoucheContexte->arbre_id = $arbre_id; $igoCoucheContexte->attribut_id = $attribut_id; $igoCoucheContexte->ind_fond_de_carte = 'D'; //$igoCoucheContexte->couche_id = $couche_id; break; case 'couche': $igoCouche = IgoCouche::findFirst('id=' . $couche_id); if (!$igoCouche) { $this->flash->error("La couche ayant le igo_couche.id « {$couche_id} » n'existe pas."); } $igoCoucheContexte->groupe_id = $groupe_id; $igoCoucheContexte->couche_id = $couche_id; $igoCoucheContexte->arbre_id = $arbre_id; $igoCoucheContexte->ind_fond_de_carte = 'D'; $igoCoucheContexte->mf_layer_meta_name = $igoCouche->mf_layer_meta_name; $igoCoucheContexte->mf_layer_meta_title = $igoCouche->mf_layer_meta_title; $igoCoucheContexte->mf_layer_meta_z_order = $igoCouche->mf_layer_meta_z_order; if (!is_null($titre)) { $igoCoucheContexte->mf_layer_meta_group_title = $titre; $igoCoucheContexte->mf_layer_meta_title = $titre; } if (!is_null($ordre)) { $igoCoucheContexte->layer_a_order = $ordre; } break; } } if ($igoCoucheContexte) { //Modifier la valeur de l'attribut $valeur = $valeur == '1'; $attribut = substr($name, 1, 1); switch ($attribut) { case "V": $changed = $changed || $igoCoucheContexte->est_visible != $valeur; $igoCoucheContexte->est_visible = $valeur; break; case "A": $changed = $changed || $igoCoucheContexte->est_active != $valeur; $igoCoucheContexte->est_active = $valeur; break; case "X": $changed = $changed || $igoCoucheContexte->est_exclu != $valeur; $igoCoucheContexte->est_exclu = $valeur; break; case "T": if (!is_null($titre) && "" != $titre) { $changed = $changed || $igoCoucheContexte->mf_layer_meta_group_title != $titre; $igoCoucheContexte->mf_layer_meta_group_title = $titre; } break; case "O": if (!is_null($ordre)) { $changed = $changed || $igoCoucheContexte->layer_a_order != $ordre; $igoCoucheContexte->layer_a_order = $ordre; } break; } } if ($changed) { if (!$igoCoucheContexte->save()) { foreach ($igoCoucheContexte->getMessages() as $message) { $this->flash->error($message); } } } } $contexteController = new IgoContexteController(); $contexteController->saveMapFile($contexte_id); $igo_contexte = IgoContexte::findFirstByid($contexte_id); if (!$igo_contexte) { $this->flash->error("igo_contexte non-trouvé"); return $this->dispatcher->forward(array("controller" => "igo_contexte", "action" => "index")); } $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,\r\n gr.groupe_id as id,\r\n gr.nom,\r\n cc.mf_layer_meta_group_title AS mf_layer_meta_group_title,\r\n gr.groupe_id AS groupe_id,\r\n NULL::integer AS attribut_id,\r\n COALESCE(cc.est_visible, false) AS visible,\r\n COALESCE(cc.est_active, false) AS active,\r\n COALESCE(cc.est_exclu, false) AS exclu,\r\n NULL::text AS colonne,\r\n NULL::boolean AS est_commune,\r\n NULL::integer AS couche_id,\r\n cc.id AS couche_contexte_id,\r\n cc.layer_a_order AS layer_a_order,\r\n true AS association_est_association,\r\n COALESCE(cc.arbre_id, gr.grp) as grp,\r\n (length(grp) - length(replace(grp, '_'::text, ''::text))) as len\r\n from igo_vue_groupes_recursif gr\r\n LEFT JOIN igo_couche_contexte cc ON cc.arbre_id=grp AND cc.contexte_id={$contexte_id} and cc.couche_id IS NULL\r\n --LEFT JOIN igo_vue_permissions_pour_groupes pg ON pg.profil_id IN ({$liste_profil_id_utilisateur})\r\n UNION\r\n select 'C'::character varying(1) AS type,\r\n c.id,\r\n c.mf_layer_meta_title AS nom,\r\n cc.mf_layer_meta_group_title AS mf_layer_meta_group_title,\r\n gc.groupe_id AS groupe_id,\r\n igo_attribut.id AS attribut_id,\r\n COALESCE(cc.est_visible,false) AND cc.arbre_id = gr.grp AS visible,\r\n COALESCE(cc.est_active,false) AND cc.arbre_id = gr.grp AS active,\r\n COALESCE(cc2.est_exclu,false) AND igo_attribut.id = cc2.attribut_id AS exclu,\r\n igo_attribut.colonne AS colonne,\r\n c.est_commune AS est_commune,\r\n c.id AS couche_id,\r\n cc.id AS couche_contexte_id,\r\n COALESCE(NULLIF(cc.layer_a_order, 0), c.layer_a_order) AS layer_a_order,\r\n igo_vue_permissions_pour_couches.est_association AS association_est_association,\r\n COALESCE(cc.arbre_id, gr.grp) as grp,\r\n (length(grp) - length(replace(grp, '_'::text, ''::text))) as len\r\n from igo_vue_groupes_recursif gr\r\n JOIN igo_groupe_couche gc ON gc.groupe_id=gr.groupe_id\r\n JOIN igo_couche c ON gc.couche_id=c.id\r\n JOIN igo_geometrie ON c.geometrie_id = igo_geometrie.id\r\n LEFT JOIN igo_attribut ON igo_attribut.geometrie_id = igo_geometrie.id\r\n LEFT JOIN igo_couche_contexte cc ON c.id=cc.couche_id AND cc.contexte_id={$contexte_id} and cc.arbre_id=grp and cc.attribut_id IS NULL\r\n LEFT JOIN igo_couche_contexte cc2 ON c.id=cc.couche_id AND cc.contexte_id={$contexte_id} and cc.arbre_id=grp and cc2.attribut_id IS NOT NULL and cc2.attribut_id=igo_attribut.id\r\n LEFT JOIN igo_vue_permissions_pour_couches ON igo_vue_permissions_pour_couches.couche_id = cc.id \r\nORDER BY grp, len, type DESC, layer_a_order"; //echo $sql; $igo_groupe = new IgoGroupe(); $igo_groupe = new Resultset(null, $igo_groupe, $igo_groupe->getReadConnection()->query($sql)); //$igo_groupe=$this->modelsManager->executeQuery($sql); $this->view->setVar("arbre", $igo_groupe); // var_dump($this->udate()); }
public function importExternalTable($nameFile = null) { if (is_null($nameFile)) { throw new Exception('Nome do arquivo ausente.'); } $saStatement = new \Telephony\Models\SaStatement(); $sqlLocation = "ALTER TABLE SA_EXTRATO LOCATION (ETL: 'FAT{$nameFile}.TXT')"; $location = new Resultset(null, $saStatement, $saStatement->getReadConnection()->query($sqlLocation)); if (!$location) { throw new Exception('Erro ao alterar location da tabela EXTRATO.'); } $statement = new \Telephony\Models\Statement(); $sqlDelete = 'DELETE FROM EXTRATO WHERE MESREF IN (SELECT DISTINCT MESREF FROM SA_EXTRATO)'; $delete = new Resultset(null, $statement, $statement->getReadConnection()->query($sqlDelete)); if (!$delete) { throw new Exception('Erro ao deletar tabela EXTRATO.'); } $sqlInsert = 'INSERT INTO EXTRATO ( SELECT NUMNF, NUMIDCLI, MESREF, NUMACS, PLANO, NOME, TPSERV, DATA, HORA, ORIGEM, DESTINO, NUMCHAM, TIPO, DURACAO, TO_NUMBER(REPLACE(REPLACE(VALOR, \'.\', \'\'), \',\', \'.\'), \'999999999999.99\'), OPERLD, TIMID, ALIQUOTA, CODFEBRABAN, TOTALGERAL FROM SA_EXTRATO)'; $insert = new Resultset(null, $statement, $statement->getReadConnection()->query($sqlInsert)); if (!$insert) { throw new Exception('Erro ao inserir na tabela EXTRATO.'); } $saStatement = new \Telephony\Models\SaStatement(); $sqlCount = 'SELECT COUNT(1) M FROM SA_EXTRATO'; $count = new Resultset(null, $saStatement, $saStatement->getReadConnection()->query($sqlCount)); if (!$count) { throw new Exception('Erro ao contar número de alterações da tabela EXTRATO pela SA_EXTRATO.'); } return $count->toArray(0)[0]['M']; }
/** * Format content for DataTable plugin * @param \Phalcon\Mvc\Model\Resultset\Simple $query * @param array $params * @return array */ public static function toDataTable(\Phalcon\Mvc\Model\Resultset\Simple $query, array $params = array()) { $result = ['draw' => $params['sEcho'], 'recordsFiltered' => $params['iTotal'], 'recordsTotal' => $query->count(), 'data' => []]; foreach ($query->toArray() as $aRow) { $row = []; foreach ($params['aColumns'] as $col) { $row[] = $aRow[substr($col, 2)]; } // pre define first row as empty for checkboxes $result['data'][] = array_merge([null], $row); } return $result; }
public static function findByRawSql($what, $conditions, $params = null) { $sql = "SELECT {$what} FROM user_profile WHERE {$conditions}"; $userProfile = new static(); $pdoResult = $userProfile->getReadConnection()->query($sql, $params); $result = new Resultset(null, $userProfile, $pdoResult); $result->setHydrateMode(Resultset::HYDRATE_OBJECTS); return $result; }
private function getAnswer($userId, $limit, $offset) { $sql = <<<SQL SELECT \tu.user_id AS user_id, \tu.user_nickname AS user_nickname, \tu.user_cover AS user_cover, \tquestion.question_id AS question_id, \tquestion.question_content AS question_content, \tquestion.question_pics AS question_pics, \tquestion.answer_num AS answer_num, \tquestion.question_browsers AS browser_num, \tquestion.question_follows AS follow_num, \tquestion.question_addtime AS addtime FROM question_answer AS qa LEFT JOIN question ON question.question_id = qa.question_id LEFT JOIN user_base AS u ON question.user_id = u.user_id WHERE question.question_state > 0 AND qa.user_id = :uid GROUP BY question.question_id ORDER BY question_id DESC LIMIT {$limit} OFFSET {$offset} SQL; $model = new QuestionAnswer(); $result = new ResultSet(null, $model, $model->getReadConnection()->query($sql, ['uid' => $userId])); return $result->toArray(); }
public function last() { $sql = 'select oneproxy_seq_nextval("pd_info")'; $robot = new PdInfo(); $info = new Resultset(null, $robot, $robot->getReadConnection()->query($sql)); if ($info) { $last = $info->toArray(); if (!empty($last) && is_array($last) && isset($last[0]['oneproxy_seq_nextval("pd_info")'])) { $pidArr = explode(',', $last[0]['oneproxy_seq_nextval("pd_info")']); if (is_array($pidArr) && isset($pidArr['0']) && !empty($pidArr['0'])) { $pid = (int) $pidArr['0']; if (is_int($pid) and $pid > 0) { return $pid; } } } } return 0; }
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); }