/** * Affiche les infos d'une classe (enseignant et �l�ves) * * @author Christophe Beyer <*****@*****.**> * @since 2006/01/18 * @param integer $rClasse Recordset de la classe */ public function _createContent(&$toReturn) { $tpl = new CopixTpl(); $annuaireService =& CopixClassesFactory::Create('annuaire|AnnuaireService'); $rClasse = $this->getParam('rClasse') ? $this->getParam('rClasse') : NULL; if ($rClasse) { $classe = $rClasse['id']; $enseignants = $annuaireService->getEnseignantInClasse($classe); $eleves = $annuaireService->getElevesInClasse($classe); $rClasse["eleves"] = $eleves; $rClasse["enseignants"] = $enseignants; $matrix =& enic::get('matrixCache'); $matrix->display(); $droit = $matrix->classe($classe)->_right->USER_ENS->voir; if (!$droit) { $rClasse["enseignants"] = 'NONE'; } $canWrite = $matrix->classe($classe)->_right->USER_ENS->communiquer; $tpl->assign('canWriteUSER_ENS', $canWrite); $droit = $matrix->classe($classe)->_right->USER_ELE->voir; if (!$droit) { $rClasse["eleves"] = 'NONE'; } $canWrite = $matrix->classe($classe)->_right->USER_ELE->communiquer; $tpl->assign('canWriteUSER_ELE', $canWrite); $tpl->assign('classe', $rClasse); $toReturn = $tpl->fetch('infosclasse.tpl'); } return true; }
/** * Accueil des stats * * @author Christophe Beyer <*****@*****.**> * @since 2007/03/19 */ public function home() { if (!Admin::canAdmin()) { return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('kernel|kernel.error.noRights'), 'back' => CopixUrl::get())); } $tpl = new CopixTpl(); $tpl->assign('TITLE_PAGE', CopixI18N::get('sysutils|admin.menu.stats')); $tpl->assign('MENU', Admin::getMenu('stats')); $tplStats = new CopixTpl(); $modules = Kernel::getAllModules(); $tab = array(); foreach ($modules as $mod_val) { $arModulesPath = CopixConfig::instance()->arModulesPath; foreach ($arModulesPath as $modulePath) { $class_file = $modulePath . $mod_val . '/' . COPIX_CLASSES_DIR . 'kernel' . $mod_val . '.class.php'; if (!file_exists($class_file)) { continue; } $module_class =& CopixClassesFactory::Create($mod_val . '|Kernel' . $mod_val); //print_r($module_class); if (!is_callable(array($module_class, 'getStatsRoot'))) { continue; } //$classeModule = CopixClassesFactory::create("$label|Kernel$label"); $tab[$mod_val]['module_nom'] = Kernel::Code2Name('mod_' . $mod_val); $tab[$mod_val]['stats'] = $module_class->getStatsRoot(); } } //print_r($tab); $tplStats->assign('tab', $tab); $tpl->assign('MAIN', $tplStats->fetch('sysutils|stats.modules.tpl')); return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl); }
/** * Enregistre les valeurs des préférences * * @author Frederic Mossmann <*****@*****.**> * @since 2006/12/01 * @param string $module Nom du module * @param array $data Valeurs */ public function setPrefs($module, $data) { if (!isset($data['alerte_carnet'])) { $data['alerte_carnet'] = 0; } $pref_service =& CopixClassesFactory::Create('prefs|prefs'); $pref_service->setPrefs($module, $data); }
/** * Statistiques d'un groupe * * Renvoie des éléments chiffrés relatifs à un groupe : nombre de membres * * @author Christophe Beyer <*****@*****.**> * @since 2005/11/17 * @return array Tableau dont les clefs représentent les libellés des stats et les valeurs les stats chiffrées. Clefs utilisées : ["Membres"] */ public function getStats($id_groupe) { //$kernelService = & CopixClassesFactory::Create ('kernel|kernel'); $groupeService =& CopixClassesFactory::Create('groupe|groupeService'); $res = array(); $members = $groupeService->getNbMembersInGroupe($id_groupe); $res['nbMembers'] = array('name' => CopixI18N::get('groupe|groupe.stats.nbMembers', array($members['inscrits']))); if ($members['waiting']) { $res['nbMembersWaiting'] = array('name' => CopixI18N::get('groupe|groupe.stats.nbMembersWaiting', array($members['waiting']))); } return $res; }
/** * Zone qui affiche un lien permettant d'ouvrir l'annuaire avec les utilisateurs * * @author Christophe Beyer <*****@*****.**> * @since 2006/01/23 * @param string $field Nom du champ où vont figurer les logins * @param string $profil (option) Profil qu'on veut afficher par defaut * @param string $right (option) Droit à vérifier */ public function _createContent(&$toReturn) { $annuaireService =& CopixClassesFactory::Create('annuaire|AnnuaireService'); $field = $this->getParam('field') ? $this->getParam('field') : NULL; $profil = $this->getParam('profil'); $tpl = new CopixTpl(); $tpl->assign('field', $field); $tpl->assign('profil', $profil); $tpl->assign('right', $this->getParam('right')); $toReturn = $tpl->fetch('linkpopup.tpl'); return true; }
public function getSwitchUser() { $login = _request('login'); if ($login != '') { $me_info = Kernel::getUserInfo("ME", 0); $animateurs_dao =& CopixDAOFactory::create("kernel|kernel_animateurs"); $animateur = $animateurs_dao->get($me_info['type'], $me_info['id']); $ien_dao =& CopixDAOFactory::create("kernel|kernel_ien"); $ien = $ien_dao->get($me_info['type'], $me_info['id']); // echo "<pre>"; print_r($ien); die("</pre>"); if (!$ien && (!$animateur || !isset($animateur->can_connect) || !$animateur->can_connect)) { return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('assistance||users', array('error' => 'forbidden'))); } $user_info = Kernel::getUserInfo("LOGIN", $login); // $user_info->user_id if (!$user_info) { return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('assistance||users', array('error' => 'forbidden'))); } $ok = false; $assistance_service =& CopixClassesFactory::Create('assistance|assistance'); $user_assistance = $assistance_service->getAssistanceUsers(); if (!$user_assistance) { return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('assistance||users', array('error' => 'forbidden'))); } foreach ($user_assistance as $ville_id => $ville) { foreach ($ville as $ecole_id => $ecole) { foreach ($ecole->personnels as $personnel_id => $personnel) { if ($personnel->id_copix == $user_info['user_id']) { $ok = $personnel->assistance; } } } } if (!$ok) { return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('assistance||users', array('error' => 'forbidden'))); } $currentUserLogin = _currentUser()->getLogin(); CopixSession::destroyNamespace('default'); _sessionSet('user_animateur', $currentUserLogin); _sessionSet('prisedecontrole_ien', $ien ? true : false); _currentUser()->login(array('login' => $login, 'assistance' => true)); $url_return = CopixUrl::get('kernel||doSelectHome'); } else { if ($session = _sessionGet('user_animateur')) { CopixSession::destroyNamespace('default'); //_sessionSet('user_animateur', null); _currentUser()->login(array('login' => $session, 'assistance' => true)); } $url_return = CopixUrl::get('assistance||users'); } return new CopixActionReturn(COPIX_AR_REDIRECT, $url_return); }
public function _createContent(&$toReturn) { //load TPL $tpl = new CopixTpl(); //get the id for current zone $idZone = $this->getParam('idZone'); $annuaireService =& CopixClassesFactory::Create('annuaire|AnnuaireService'); $ecolesDatas = $annuaireService->getEcolesInVille($idZone); $tpl->assign('ecoles', $ecolesDatas); //return the html content $toReturn = $tpl->fetch('zone.dashboard.ville.tpl'); return true; }
public function _createContent(&$toReturn) { //load TPL $tpl = new CopixTpl(); //get the id for current zone (force int) $idZone = $this->getParam('idZone') * 1; $catalog = $this->getParam('catalog'); $enseignants = array(); $oEns = array(); //check the matrix right for current classe : if ($this->matrix->ecole($idZone)->_right->enseignant->voir) { $annuaireService =& CopixClassesFactory::Create('annuaire|AnnuaireService'); //get the children's node $childNodeDatas = Kernel::getNodeChilds('BU_ECOLE', $idZone, false, array('skip_user' => true)); //if the child is a CLASSE get the enseignant foreach ($childNodeDatas as $child) { if ($child['type'] == 'BU_CLASSE') { $enseignants[] = $annuaireService->getEnseignantInClasse($child['id']); } } /* * delete the multiple ereg */ $uniqueEnsId = array(); foreach ($enseignants as $enseignant) { foreach ($enseignant as $ens) { //check if the ens is already ereg if (in_array($ens['id'], $uniqueEnsId)) { continue; } else { $oEns[] = $ens; $uniqueEnsId[] = $ens['id']; } } } /* * get the school's picture */ $pic = $this->model->query('SELECT photo FROM module_fiches_ecoles WHERE id = ' . $idZone)->toString(); $tpl->assign('ens', $oEns); $tpl->assign('pic', $pic); $tpl->assign('idZone', $idZone); $tpl->assign('catalog', $catalog); //return the html content $toReturn = $tpl->fetch('zone.dashboard.ecole.tpl'); return true; } //if the uses have no right : display a default tpl $toReturn = $tpl->fetch('zone.dashboard.noRight.tpl'); return true; }
/** * Pour le dashboard, zone affichant le lien vers l'annuaire des groupes, et le bouton pour creer un groupe * * @author Christophe Beyer <*****@*****.**> * @since 2010/06/11 */ public function _createContent(&$toReturn) { $groupeService =& CopixClassesFactory::Create('groupe|groupeService'); $tpl = new CopixTpl(); //$tpl->assign ('list', $groupes); $tpl->assign('canCreate', $groupeService->canMakeInGroupe('ADD_GROUP', NULL) ? 1 : 0); if (!CopixConfig::exists('|can_group_showlist') || CopixConfig::get('|can_group_showlist')) { $tpl->assign('can_group_showlist', 1); } else { $tpl->assign('can_group_showlist', 0); } $toReturn = $tpl->fetch('dashboardgroups.tpl'); return true; }
/** * Ajoute un message à une liste, et s'occupe de l'envoyer à tous ses membres en minimail * * @author Christophe Beyer <*****@*****.**> * @since 2005/11/23 * @param integer $liste Id de la liste * @param integer $auteur Id de l'utilisateur auteur du message * @param string $titre Titre du message * @param string $message Corps du message * @return integer l'Id du message inséré ou NULL si erreur */ public function addListeMessage($liste, $auteur, $titre, $message) { $daoListes = _dao("liste|liste_listes"); $daoMessages = _dao("liste|liste_messages"); $kernelService =& CopixClassesFactory::Create('kernel|kernel'); $minimailService =& CopixClassesFactory::Create('minimail|minimailService'); $res = NULL; $rListe = $daoListes->get($liste); if ($rListe) { $parent = $kernelService->getModParentInfo("MOD_LISTE", $liste); //print_r($parent); $rListe->parent = $parent; //die(); $newMessage = _record("liste|liste_messages"); $newMessage->liste = $liste; $newMessage->auteur = $auteur; $newMessage->titre = $titre; $newMessage->message = $message; $newMessage->date = date("Y-m-d H:i:s"); $daoMessages->insert($newMessage); if ($newMessage->id !== NULL) { $dest = array(); // On cherche le parent $parent = $kernelService->getModParentInfo("MOD_LISTE", $liste); // Puis les membres du parent $childs = $kernelService->getNodeChilds($parent["type"], $parent["id"]); // On parcourt les membres foreach ($childs as $child) { $userInfo = $kernelService->getUserInfo($child["type"], $child["id"]); if ($userInfo && $userInfo["user_id"] && $userInfo["user_id"] != $auteur) { $dest[$userInfo["user_id"]] = 1; } } if ($dest) { $format = CopixConfig::get('minimail|default_format'); if ($format == 'dokuwiki' || $format == 'wiki') { $message .= "\n\n----\n" . CopixI18N::get('liste|liste.message.footer', array(1 => $rListe->parent["nom"], 2 => CopixUrl::get($rListe->parent["module"] . '||getHomeAdmin', array("id" => $rListe->parent["id"])))); } else { $message .= "<p>-- </p><p>" . CopixI18N::get('liste|liste.message.footerHtml', array(1 => $rListe->parent["nom"], 2 => CopixUrl::get($rListe->parent["module"] . '||getHomeAdmin', array("id" => $rListe->parent["id"])))) . "</p>"; } $send = $minimailService->sendMinimail($titre, $message, $auteur, $dest, CopixConfig::get('minimail|default_format')); } $res = $newMessage->id; } } return $res; }
/** * Affiche la liste déroulante avec toutes les écoles d'une ville * * @author Christophe Beyer <*****@*****.**> * @since 2006/01/06 * @param integer $ville Id de la ville * @param integer $value Valeur actuelle de la combo * @param string $fieldName Nom du champ de type SELECT qui en résulte * @param string $attribs Attributs HTML de la liste (STYLE, ONCHANGE...) * @param string $droit Si on ne veut afficher que les ecoles sur lesquelles l'usager a un certain droit (VOIR / COMM, ou voir / communiquer) */ public function _createContent(&$toReturn) { $annuaireService =& CopixClassesFactory::Create('annuaire|AnnuaireService'); $ville = $this->getParam('ville') ? $this->getParam('ville') : NULL; $value = $this->getParam('value') ? $this->getParam('value') : 0; $fieldName = $this->getParam('fieldName') ? $this->getParam('fieldName') : NULL; $attribs = $this->getParam('attribs') ? $this->getParam('attribs') : NULL; $pDroit = $this->getParam('droit'); $ecoles = $annuaireService->getEcolesInVille($ville, array('droit' => $pDroit)); $tpl = new CopixTpl(); $tpl->assign('items', $ecoles); $tpl->assign('value', $value); $tpl->assign('fieldName', $fieldName); $tpl->assign('attribs', $attribs); $toReturn = $tpl->fetch('comboecoles.tpl'); return true; }
/** * Affiche les infos d'une �cole (coordonn�es, directeur, classes...) * * @author Christophe Beyer <*****@*****.**> * @since 2006/01/18 * @param integer $rEcole Recordset de l'�cole */ public function _createContent(&$toReturn) { $tpl = new CopixTpl(); $annuaireService =& CopixClassesFactory::Create('annuaire|AnnuaireService'); $rEcole = $this->getParam('rEcole') ? $this->getParam('rEcole') : NULL; if ($rEcole) { //print_r($rEcole); $ecole = $rEcole['id']; // BOOST 2.5s if ($this->getParam('classes')) { $classes = $this->getParam('classes'); } else { $classes = $annuaireService->getClassesInEcole($ecole, array('droit' => 'VOIR')); } $matrix =& enic::get('matrixCache'); $droit = $matrix->ecole($ecole)->_right->USER_DIR->voir; if ($droit) { $rEcole['directeur'] = $annuaireService->getDirecteurInEcole($ecole); $canWrite = $matrix->ecole($ecole)->_right->USER_DIR->communiquer; $tpl->assign('canWriteUSER_DIR', $canWrite); } //$droit = $matrix->ecole($ecole)->_right->USER_ADM->voir; $droit = 1; if ($droit) { $rEcole['administratif'] = $annuaireService->getAdministratifInEcole($ecole); $canWrite = $matrix->ecole($ecole)->_right->USER_DIR->communiquer; $tpl->assign('canWriteUSER_ADM', $canWrite); } $tpl->assign('canWriteUSER_ENS', $matrix->ecole($ecole)->_right->USER_ENS->communiquer); //$rEcole['directeur'] = $annuaireService->checkVisibility( $rEcole['directeur'] ); //$rEcole['administratif'] = $annuaireService->checkVisibility( $rEcole['administratif'] ); $tpl->assign('ecole', $rEcole); $tpl->assign('classes', $classes); // BOOST 1s if (CopixConfig::exists('|can_annuaire_menu') && !CopixConfig::get('|can_annuaire_menu')) { $tpl->assign('displayComboEcoles', false); } else { $tpl->assign('displayComboEcoles', true); } $tpl->assign('comboecoles', CopixZone::process('annuaire|comboecolesinville', array('droit' => 'VOIR', 'ville' => $rEcole['ALL']->vil_id_vi, 'value' => $ecole, 'fieldName' => 'ecole', 'attribs' => 'CLASS="annu_combo_popup" ONCHANGE="if (this.value) this.form.submit();"'))); $toReturn = $tpl->fetch('infosecole.tpl'); } return true; }
public function _createContent(&$toReturn) { //load TPL $tpl = new CopixTpl(); //get the id for current zone $idZone = $this->getParam('idZone'); //check the matrix right for current classe : if ($this->matrix->classe($idZone)->_right->eleve->voir) { $annuaireService =& CopixClassesFactory::Create('annuaire|AnnuaireService'); $elevesDatas = $annuaireService->getElevesInClasse($idZone); $tpl->assign('eleves', $elevesDatas); //return the html content $toReturn = $tpl->fetch('zone.dashboard.classe.tpl'); return true; } //if the uses have no right : display a default tpl $toReturn = $tpl->fetch('zone.dashboard.noRight.tpl'); return true; }
/** * Affiche la liste déroulante avec toutes les classes d'une ville * * @author Christophe Beyer <*****@*****.**> * @since 2006/01/06 * @param integer $ville Id de la ville * @param integer $value Valeur actuelle de la combo * @param string $fieldName Nom du champ de type SELECT qui en résulte * @param string $attribs Attributs HTML de la liste (STYLE, ONCHANGE...) * @param array $linesSup Lignes supplémentaires à ajouter en haut de la liste au-dessus des dossiers (ex: "Choisissez l'école"). Chaque ligne est un tableau, de type array ("value"=>"", "libelle"=>"Choisissez") */ public function _createContent(&$toReturn) { $annuaireService =& CopixClassesFactory::Create('annuaire|AnnuaireService'); $ville = $this->getParam('ville') ? $this->getParam('ville') : NULL; $value = $this->getParam('value') ? $this->getParam('value') : 0; $fieldName = $this->getParam('fieldName') ? $this->getParam('fieldName') : NULL; $attribs = $this->getParam('attribs') ? $this->getParam('attribs') : NULL; $linesSup = $this->getParam('linesSup') ? $this->getParam('linesSup') : NULL; $classes = $annuaireService->getClassesInVille($ville, array('getNodeInfo_light' => 1)); //echo "<pre>"; print_r($classes); die(); $tpl = new CopixTpl(); $tpl->assign('items', $classes); $tpl->assign('value', $value); $tpl->assign('fieldName', $fieldName); $tpl->assign('attribs', $attribs); $tpl->assign('linesSup', $linesSup); $toReturn = $tpl->fetch('comboclasses.tpl'); return true; }
/** * Affiche la liste des personnes ayant des droits spécifiques sur un blog * * @author Christophe Beyer <*****@*****.**> * @since 2007/05/31 * @param object $blog Blog (recordset) * @param integer $kind Numéro générique de la rubrique (ne pas y toucher) * @param string $attribs Attributs HTML de la liste (STYLE, ONCHANGE...) */ public function _createContent(&$toReturn) { //Getting the user. //Create Services, and DAO $tpl = new CopixTpl(); $blog = $this->getParam('blog', null); $kind = $this->getParam('kind', null); $droit = $this->getParam('droit', null); $errors = $this->getParam('errors'); $membres = $this->getParam('membres'); $droit = $this->getParam('droit'); //Kernel::deb("droit=$droit"); //print_r($blog); // On vérifie le droit d'être ici if (!BlogAuth::canMakeInBlog("ADMIN_DROITS", $blog)) { return false; } $groupeService =& CopixClassesFactory::Create('groupe|groupeService'); $childs = Kernel::getNodeChilds("MOD_BLOG", $blog->id_blog); foreach ($childs as $k => $v) { //print_r($v); $userInfo = Kernel::getUserInfo($v["type"], $v["id"]); $childs[$k]["login"] = $userInfo["login"]; $childs[$k]["nom"] = $userInfo["nom"]; $childs[$k]["prenom"] = $userInfo["prenom"]; $childs[$k]["droitnom"] = $groupeService->getRightName($v['droit']); } //print_r($childs); $tplHome = new CopixTpl(); //$tplHome->assign ('groupe', $groupe[0]); $tpl->assign('kind', $kind); $tpl->assign('droit', $droit); $tpl->assign('list', $childs); $tpl->assign('errors', $errors); $tpl->assign('membres', $membres); $tpl->assign('linkpopup', CopixZone::process('annuaire|linkpopup', array('field' => 'membres'))); $tpl->assign('droit_values', array(PROFILE_CCV_VALID => $groupeService->getRightName(PROFILE_CCV_VALID), PROFILE_CCV_MODERATE => $groupeService->getRightName(PROFILE_CCV_MODERATE))); $tpl->assign('blog', $blog); // retour de la fonction : $toReturn = $tpl->fetch('blog.show.droits.tpl'); return true; }
/** * Affiche la liste déroulante avec tous les dossiers d'une malle * * @author Christophe Beyer <*****@*****.**> * @since 2005/12/07 * @param integer $malle Id de la malle * @param integer $folder Id du dossier (0 si racine) * @param string $fieldName Nom du champ de type SELECT qui en résulte * @param string $attribs Attributs HTML de la liste (STYLE, ONCHANGE...) * @param array $linesSup Lignes supplémentaires à ajouter en haut de la liste au-dessus des dossiers (ex: "Choisissez le dossier"). Chaque ligne est un tableau, de type array ("value"=>"", "libelle"=>"Choisissez") */ public function _createContent(&$toReturn) { //$daoFolders = _dao("malle|malle_folders"); $malleService =& CopixClassesFactory::Create('malle|malleService'); $tpl = new CopixTpl(); $res = array(); $malle = $this->getParam('malle') ? $this->getParam('malle') : NULL; $folder = $this->getParam('folder') ? $this->getParam('folder') : 0; $fieldName = $this->getParam('fieldName') ? $this->getParam('fieldName') : NULL; $attribs = $this->getParam('attribs') ? $this->getParam('attribs') : NULL; $linesSup = $this->getParam('linesSup') ? $this->getParam('linesSup') : NULL; $res = $malleService->buildComboFolders($malle); //print_r($res); $tpl->assign('combofolders', $res); $tpl->assign('folder', $folder); $tpl->assign('fieldName', $fieldName); $tpl->assign('attribs', $attribs); $tpl->assign('linesSup', $linesSup); $toReturn = $tpl->fetch('combofolders.tpl'); return true; }
/** * Affiche la fiche détaillée d'un utilisateur (login, nom, prénom...) * * @author Christophe Beyer <*****@*****.**> * @since 2006/01/04 * @param string $type Type de personne (USER_ELE, USER_ELE...) * @param integer $id Id */ public function _createContent(&$toReturn) { $annuaireService =& CopixClassesFactory::Create('annuaire|AnnuaireService'); $type = $this->getParam('type') ? $this->getParam('type') : NULL; $id = $this->getParam('id') ? $this->getParam('id') : NULL; $canWrite = $canView = false; if ($type && $id) { $usr = Kernel::getUserInfo($type, $id); $usr['type_nom'] = Kernel::Code2Name($usr['type']); //Kernel::myDebug($usr); $droits = Kernel::getUserInfoMatrix($usr); $canView = $droits['voir']; $canWrite = $droits['communiquer']; if ($canView) { // Avatar $avatar = ''; if (isset($usr['user_id'])) { $avatar = Prefs::get('prefs', 'avatar', $usr['user_id']); } $usr['avatar'] = $avatar ? CopixConfig::get('prefs|avatar_path') . $avatar : ''; $parents = $enfants = array(); if ($type == 'USER_ELE') { // Pour un élève, on cherche ses parents $parents = $annuaireService->getParentsFromEleve($id); } elseif ($type == 'USER_RES') { // Pour un parent, on cherche ses enfants $enfants = $annuaireService->getEnfantsFromParent($id); } } else { $usr = $parents = $enfants = false; } $tpl = new CopixTpl(); $tpl->assign('usr', $usr); $tpl->assign('canWrite', $canWrite); $tpl->assign('parents', $parents); $tpl->assign('enfants', $enfants); $toReturn = $tpl->fetch('getuserprofilzone.tpl'); } return true; }
/** * Affiche la liste déroulante avec toutes les villes d'un groupe de ville * * @author Christophe Beyer <*****@*****.**> * @since 2006/01/17 * @param integer $grville Id du groupe de ville * @param integer $value Valeur actuelle de la combo * @param string $fieldName Nom du champ de type SELECT qui en résulte * @param string $attribs Attributs HTML de la liste (STYLE, ONCHANGE...) * @param array $linesSup Lignes supplémentaires à ajouter en haut de la liste au-dessus des dossiers (ex: "Choisissez la ville"). Chaque ligne est un tableau, de type array ("value"=>"", "libelle"=>"Choisissez") * @param string $droit Si on ne veut afficher que les villes sur lesquelles l'usager a un certain droit (VOIR / COMM, ou voir / communiquer) */ public function _createContent(&$toReturn) { $annuaireService =& CopixClassesFactory::Create('annuaire|AnnuaireService'); $grville = $this->getParam('grville') ? $this->getParam('grville') : NULL; $value = $this->getParam('value') ? $this->getParam('value') : 0; $fieldName = $this->getParam('fieldName') ? $this->getParam('fieldName') : NULL; $attribs = $this->getParam('attribs') ? $this->getParam('attribs') : NULL; $linesSup = $this->getParam('linesSup') ? $this->getParam('linesSup') : NULL; $pDroit = $this->getParam('droit'); if ($ville_as_array = Kernel::getKernelLimits('ville_as_array')) { $villes = $annuaireService->getVilles($ville_as_array, array('droit' => $pDroit)); } else { $villes = $annuaireService->getVillesInGrville($grville, array('droit' => $pDroit)); } $tpl = new CopixTpl(); $tpl->assign('items', $villes); $tpl->assign('value', $value); $tpl->assign('fieldName', $fieldName); $tpl->assign('attribs', $attribs); $tpl->assign('linesSup', $linesSup); $toReturn = $tpl->fetch('combovilles.tpl'); return true; }
/** * T�l�chargement d'une pi�ce jointe (download) * * @author Christophe Beyer <*****@*****.**> * @since 2005/10/18 * @param string $file Nom du fichier � t�l�charger * @todo V�rifier les droits par rapport au minimail contenant cette pi�ce jointe */ public function downloadAttachment() { $minimailService =& CopixClassesFactory::Create('minimail|minimailService'); $malleService =& CopixClassesFactory::Create('malle|malleService'); $file = _request("file") ? _request("file") : NULL; $fullFile = realpath("../var/data") . "/minimail/" . $file; $errors = array(); if (!$file || !file_exists($fullFile)) { $errors[] = CopixI18N::get('minimail.error.noFile'); } if ($errors) { $urlReturn = CopixUrl::get('minimail||getListRecv'); return new CopixActionReturn(COPIX_AR_REDIRECT, $urlReturn); } $fileDl = $minimailService->getAttachmentName($file); return _arFile($fullFile, array('filename' => $fileDl, 'content-type' => $malleService->getMimeType($fileDl))); }
public function publish($id, $image) { // $image['file'] -> nom de fichier // $image['title'] -> titre (ou nom � d�faut) // $image['body'] -> commentaire // $image['data'] -> donn�es if (!isset($image['file']) || trim($image['file']) == '' || !isset($image['data']) || $image['data'] == '') { return false; } $album_dao = _dao("album|album"); $album = $album_dao->get($id); if ($album == null) { return false; } $ext = ''; switch (strtolower(strrchr($image['file'], "."))) { case '.jpg': case '.jpeg': case '.jpe': $ext = "jpg"; break; case '.gif': $ext = "gif"; break; case '.png': $ext = "png"; break; default: continue; break; } if ($ext != '') { $album_service =& CopixClassesFactory::Create('album|album'); $photo_dao =& _dao("album|photo"); $nouvelle_photo = _record("album|photo"); $nouvelle_photo->photo_album = $album->album_id; $nouvelle_photo->photo_dossier = 0; if (trim($image['title']) != '') { $nouvelle_photo->photo_nom = $image['title']; } else { $nouvelle_photo->photo_nom = $image['file']; } $nouvelle_photo->photo_comment = ''; $nouvelle_photo->photo_date = date("Y-m-d H:i:s"); $nouvelle_photo->photo_ext = $ext; $nouvelle_photo->photo_cle = $album_service->createKey(); $photo_dao->insert($nouvelle_photo); if ($nouvelle_photo->photo_id) { $path2data = realpath("static"); $path2album = $path2data . "/album/" . $album->album_id . "_" . $album->album_cle; $photofile = $path2album . "/" . $nouvelle_photo->photo_id . "_" . $nouvelle_photo->photo_cle . '.' . $ext; $file = fopen($photofile, 'w'); fwrite($file, $image['data']); fclose($file); } $ok = $album_service->createThumbnails($album->album_id . '_' . $album->album_cle, $nouvelle_photo->photo_id . '_' . $nouvelle_photo->photo_cle, $ext); if ($ok) { $results = array('title' => $nouvelle_photo->photo_nom, 'album_id' => $album->album_id, 'album_key' => $album->album_cle, 'photo_id' => $nouvelle_photo->photo_id, 'photo_key' => $nouvelle_photo->photo_cle, 'photo_ext' => $ext); } else { $photo_dao->delete($nouvelle_photo->photo_id); } return $results; } return false; }
/** * Affichage de l'annuaire en version popup * * Affiche les discussions d'un forum et les informations sur les discussions (titre, dernier message...), avec un lien pour lire chaque discussion. * * @author Christophe Beyer <*****@*****.**> * @since 2006/01/18 */ public function getPopup() { if (!Kernel::is_connected()) { return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('annuaire|annuaire.error.noLogged'), 'back' => CopixUrl::get('||'))); } CopixHTMLHeader::addJSLink(_resource("js/iconito/module_annuaire_popup.js")); CopixHTMLHeader::addJSLink(_resource("js/jquery/jquery.tablesorter.min.js")); CopixHTMLHeader::addJSLink(_resource("js/jquery/jquery.metadata.js")); CopixHTMLHeader::addCSSLink(_resource("js/jquery/css/jquery.tablesorter.css")); $grville = _request('grville') ? _request('grville') : NULL; $ville = _request('ville') ? _request('ville') : NULL; $ecole = _request('ecole') ? _request('ecole') : NULL; $classe = _request('classe') ? _request('classe') : NULL; $field = _request('field') ? _request('field') : ''; $profils = _request('profils') ? _request('profils') : array(); $profil = $this->getRequest('profil'); // Si on force sur un profil unique a afficher $ALL = CopixConfig::get('annuaire|annu_combo_all'); $annuaireService =& CopixClassesFactory::Create('annuaire|AnnuaireService'); // Annuaire par défaut, on regarde sa session if (!$classe && !$ecole && !$ville) { $home = $annuaireService->getAnnuaireHome(); //print_r($home); switch ($home['type']) { case 'BU_GRVILLE': $grville = $home['id']; $ville = $ALL; $ecole = $ALL; $classe = $ALL; break; case 'BU_VILLE': $info = Kernel::getNodeInfo($home['type'], $home['id']); if ($info) { $grville = $info['ALL']->vil_id_grville; } $ville = $home['id']; $ecole = $ALL; $classe = $ALL; break; case 'BU_ECOLE': $info = Kernel::getNodeInfo($home['type'], $home['id']); if ($info) { $grville = $info['ALL']->vil_id_grville; $ville = $info['ALL']->eco_id_ville; } $ecole = $home['id']; $classe = $ALL; break; case 'BU_CLASSE': $info = Kernel::getNodeInfo($home['type'], $home['id']); //_dump($info); if ($info) { $grville = $info['parent']['ALL']->vil_id_grville; $ville = $info['parent']['ALL']->eco_id_ville; $ecole = $info['parent']['id']; } $classe = $home['id']; //echo "grville=$grville / ville=$ville / ecole=$ecole / classe=$classe"; break; } } $comboEcoles = $comboClasses = true; // On force les valeurs des combos if ($profil) { switch ($profil) { case 'USER_VIL': $comboEcoles = $comboClasses = false; $ecole = $classe = $ALL; break; } } $matrix =& enic::get('matrixCache'); $helper =& enic::get('matrixHelpers'); $right = _request('right', 'voir'); // voir ou communiquer $iCan = 'communiquer' == $right ? 'iCanTalkToThisType' : 'iCanSeeThisType'; $tplListe = new CopixTpl(); $visib = array('USER_ELE' => $helper->{$iCan}('USER_ELE'), 'USER_ENS' => $helper->{$iCan}('USER_ENS') || $helper->{$iCan}('USER_DIR'), 'USER_RES' => $helper->{$iCan}('USER_RES'), 'USER_EXT' => $helper->{$iCan}('USER_EXT'), 'USER_ADM' => $helper->{$iCan}('USER_ADM'), 'USER_VIL' => $helper->{$iCan}('USER_VIL')); //_dump($visib); $debug = false; $start = microtime(true); $tplListe->assign('combogrvilles', CopixZone::process('annuaire|combogrvilles', array('droit' => $right, 'value' => $grville, 'fieldName' => 'grville', 'attribs' => 'class="annu_combo_popup" ONCHANGE="change_grville(this,this.form);"', 'linesSup' => array()))); if ($debug) { echo "combogrvilles " . date("H:i:s") . " " . (microtime(true) - $start) . "<br />"; } $start = microtime(true); $tplListe->assign('combovilles', CopixZone::process('annuaire|combovilles', array('droit' => $right, 'grville' => $grville, 'value' => $ville, 'fieldName' => 'ville', 'attribs' => 'class="annu_combo_popup" ONCHANGE="change_ville(this,this.form);"', 'linesSup' => array(0 => array('value' => $ALL, 'libelle' => CopixI18N::get('annuaire|annuaire.comboAllVilles')))))); if ($debug) { echo "combovilles " . date("H:i:s") . " " . (microtime(true) - $start) . "<br />"; } $start = microtime(true); if ($ville == $ALL && $comboEcoles) { $tplListe->assign('comboecoles', CopixZone::process('annuaire|comboecolesingrville', array('droit' => $right, 'grville' => $grville, 'value' => $ecole, 'fieldName' => 'ecole', 'attribs' => 'class="annu_combo_popup" ONCHANGE="change_ecole(this,this.form);"', 'linesSup' => array(0 => array('value' => $ALL, 'libelle' => CopixI18N::get('annuaire|annuaire.comboAllEcoles')))))); if ($debug) { echo "comboecolesingrville " . date("H:i:s") . " " . (microtime(true) - $start) . "<br />"; } } elseif ($comboEcoles) { $tplListe->assign('comboecoles', CopixZone::process('annuaire|comboecolesinville', array('droit' => $right, 'ville' => $ville, 'value' => $ecole, 'fieldName' => 'ecole', 'attribs' => 'class="annu_combo_popup" ONCHANGE="change_ecole(this,this.form);"', 'linesSup' => array(0 => array('value' => $ALL, 'libelle' => CopixI18N::get('annuaire|annuaire.comboAllEcoles')))))); if ($debug) { echo "comboecolesinville " . date("H:i:s") . " " . (microtime(true) - $start) . "<br />"; } } $start = microtime(true); if ($ville == $ALL && $ecole == $ALL && $comboClasses) { $tplListe->assign('comboclasses', CopixZone::process('annuaire|comboclassesingrville', array('droit' => $right, 'grville' => $grville, 'value' => $classe, 'fieldName' => 'classe', 'attribs' => 'class="annu_combo_popup" ONCHANGE="change_classe(this,this.form);"', 'linesSup' => array(0 => array('value' => $ALL, 'libelle' => CopixI18N::get('annuaire|annuaire.comboAllClasses')))))); if ($debug) { echo "comboclassesingrville " . date("H:i:s") . " " . (microtime(true) - $start) . "<br />"; } } elseif ($ecole == $ALL && $comboClasses) { $tplListe->assign('comboclasses', CopixZone::process('annuaire|comboclassesinville', array('droit' => $right, 'ville' => $ville, 'value' => $classe, 'fieldName' => 'classe', 'attribs' => 'class="annu_combo_popup" ONCHANGE="change_classe(this,this.form);"', 'linesSup' => array(0 => array('value' => $ALL, 'libelle' => CopixI18N::get('annuaire|annuaire.comboAllClasses')))))); if ($debug) { echo "comboclassesinville " . date("H:i:s") . " " . (microtime(true) - $start) . "<br />"; } } elseif ($ecole && $comboClasses) { $tplListe->assign('comboclasses', CopixZone::process('annuaire|comboclassesinecole', array('droit' => $right, 'ecole' => $ecole, 'value' => $classe, 'fieldName' => 'classe', 'attribs' => 'class="annu_combo_popup" ONCHANGE="change_classe(this,this.form);"', 'linesSup' => array(0 => array('value' => $ALL, 'libelle' => CopixI18N::get('annuaire|annuaire.comboAllClasses')))))); if ($debug) { echo "comboclassesinecole " . date("H:i:s") . " " . (microtime(true) - $start) . "<br />"; } } elseif ($comboClasses) { $tplListe->assign('comboclasses', CopixZone::process('annuaire|comboempty', array('fieldName' => 'classe', 'attribs' => 'class="annu_combo_popup" ONCHANGE="change_classe(this,this.form);"'))); if ($debug) { echo "comboempty " . date("H:i:s") . " " . (microtime(true) - $start) . "<br />"; } } if ($ville_as_array = Kernel::getKernelLimits('ville_as_array')) { // Limitation par URL, on verifie les parametres if ($ville && $ville != $ALL && !in_array($ville, $ville_as_array)) { $ville = 0; } if ($ecole && $ecole != $ALL && ($rEcole = Kernel::getNodeInfo('BU_ECOLE', $ecole, false)) && !in_array($rEcole['ALL']->vil_id_grville, $ville_as_array)) { $ecole = 0; } if ($classe && $classe != $ALL && ($rClasse = Kernel::getNodeInfo('BU_CLASSE', $classe, false)) && !in_array($rClasse['ALL']->eco_id_ville, $ville_as_array)) { $classe = 0; } } //kernel::myDebug ("grville=$grville / ville=$ville / ecole=$ecole / classe=$classe"); //kernel::myDebug ($profils); if ($classe && $classe !== $ALL) { // Une classe précise $visib['USER_ELE'] = $matrix->classe($classe)->_right->USER_ELE->{$right}; $visib['USER_ENS'] = $matrix->classe($classe)->_right->USER_ENS->{$right} || $matrix->classe($classe)->_right->USER_DIR->{$right}; $visib['USER_RES'] = $matrix->classe($classe)->_right->USER_RES->{$right}; $visib['USER_ADM'] = $matrix->classe($classe)->_right->USER_ADM->{$right}; $visib['USER_EXT'] = $matrix->classe($classe)->_right->USER_EXT->{$right}; $visib['USER_VIL'] = $matrix->classe($classe)->_right->USER_VIL->{$right}; } elseif ($ecole && $classe == $ALL && $ecole !== $ALL) { // Une école $visib['USER_ELE'] = $matrix->ecole($ecole)->_right->USER_ELE->{$right}; $visib['USER_ENS'] = $matrix->ecole($ecole)->_right->USER_ENS->{$right} || $matrix->ecole($ecole)->_right->USER_DIR->{$right}; $visib['USER_RES'] = $matrix->ecole($ecole)->_right->USER_RES->{$right}; $visib['USER_ADM'] = $matrix->ecole($ecole)->_right->USER_ADM->{$right}; $visib['USER_EXT'] = $matrix->ecole($ecole)->_right->USER_EXT->{$right}; $visib['USER_VIL'] = $matrix->ecole($ecole)->_right->USER_VIL->{$right}; } elseif ($ville && $classe == $ALL && $ecole == $ALL && $ville !== $ALL) { // Une ville $visib['USER_ELE'] = $matrix->ville($ville)->_right->USER_ELE->{$right}; $visib['USER_ENS'] = $matrix->ville($ville)->_right->USER_ENS->{$right} || $matrix->ville($ville)->_right->USER_DIR->{$right}; $visib['USER_RES'] = $matrix->ville($ville)->_right->USER_RES->{$right}; $visib['USER_ADM'] = $matrix->ville($ville)->_right->USER_ADM->{$right}; $visib['USER_EXT'] = $matrix->ville($ville)->_right->USER_EXT->{$right}; $visib['USER_VIL'] = $matrix->ville($ville)->_right->USER_VIL->{$right}; } elseif ($grville && $classe == $ALL && $ecole == $ALL && $ville == $ALL) { // Un groupe de villes $visib['USER_ELE'] = $matrix->grville($grville)->_right->USER_ELE->{$right}; $visib['USER_ENS'] = $matrix->grville($grville)->_right->USER_ENS->{$right} || $matrix->grville($grville)->_right->USER_DIR->{$right}; $visib['USER_RES'] = $matrix->grville($grville)->_right->USER_RES->{$right}; $visib['USER_ADM'] = $matrix->grville($grville)->_right->USER_ADM->{$right}; $visib['USER_EXT'] = $matrix->grville($grville)->_right->USER_EXT->{$right}; $visib['USER_VIL'] = $matrix->grville($grville)->_right->USER_VIL->{$right}; } //_dump($visib); // Si on restreint a un profil if ($profil && $visib[$profil]) { switch ($profil) { case 'USER_VIL': $profils = array(); $profils['VIL'] = 1; break; } } if (!$profils && $visib['USER_ELE']) { $profils['ELE'] = 1; } elseif (!$profils && $visib['USER_ENS']) { $profils['PEC'] = 1; } elseif (!$profils && $visib['USER_RES']) { $profils['PAR'] = 1; } elseif (!$profils && $visib['USER_EXT']) { $profils['EXT'] = 1; } elseif (!$profils && $visib['USER_ADM']) { $profils['ADM'] = 1; } elseif (!$profils && $visib['USER_VIL']) { $profils['VIL'] = 1; } //kernel::myDebug($visib); // =============== ELEVES ========================= $eleves = array(); if (isset($profils['ELE']) && $grville && $ville && $ecole && $classe && $visib['USER_ELE']) { if ($classe != $ALL) { // Une classe précise $eleves = $annuaireService->getEleves('BU_CLASSE', $classe); } elseif ($classe == $ALL && $ecole != $ALL) { // Les eleves d'une école $eleves = $annuaireService->getEleves('BU_ECOLE', $ecole); } elseif ($classe == $ALL && $ecole == $ALL && $ville != $ALL) { // Les eleves d'une ville $eleves = $annuaireService->getEleves('BU_VILLE', $ville); } elseif ($classe == $ALL && $ecole == $ALL && $ville == $ALL) { // Les eleves d'un groupe de villes $eleves = $annuaireService->getEleves('BU_GRVILLE', $grville); } } // =============== PERSONNEL ========================= $personnel = array(); if (isset($profils['PEC']) && $grville && $ville && $ecole && $classe && $visib['USER_ENS']) { if ($classe != $ALL) { // Une classe précise $personnel = $annuaireService->getPersonnel('BU_CLASSE', $classe); } elseif ($classe == $ALL && $ecole != $ALL) { // Les classes d'une école $personnel = $annuaireService->getPersonnel('BU_ECOLE', $ecole); } elseif ($classe == $ALL && $ecole == $ALL && $ville != $ALL) { // Les classes d'une ville $personnel = $annuaireService->getPersonnel('BU_VILLE', $ville); } elseif ($classe == $ALL && $ecole == $ALL && $ville == $ALL) { // Les classes d'un groupe de villes $personnel = $annuaireService->getPersonnel('BU_GRVILLE', $grville); } } // =============== PARENTS ========================= $parents = array(); if (isset($profils['PAR']) && $grville && $ville && $ecole && $classe && $visib['USER_RES']) { if ($classe != $ALL) { // Une classe précise $parents = $annuaireService->getParents('BU_CLASSE', $classe); } elseif ($classe == $ALL && $ecole != $ALL) { // Les classes d'une école $parents = $annuaireService->getParents('BU_ECOLE', $ecole); } elseif ($classe == $ALL && $ecole == $ALL && $ville != $ALL) { // Les classes d'une ville $parents = $annuaireService->getParents('BU_VILLE', $ville); } elseif ($classe == $ALL && $ecole == $ALL && $ville == $ALL) { // Les classes d'un groupe de villes $parents = $annuaireService->getParents('BU_GRVILLE', $grville); } } // =============== PERSONNEL ADMINISTRATIF ========================= $adm = array(); if (isset($profils['ADM']) && $grville && $ville && $ecole && $classe && $visib['USER_ADM']) { if (($classe != $ALL || $classe == $ALL) && $ecole != $ALL) { // Les classes d'une école $adm = $annuaireService->getPersonnelAdm('BU_ECOLE', $ecole); } elseif ($classe == $ALL && $ecole == $ALL && $ville != $ALL) { // Les classes d'une ville $adm = $annuaireService->getPersonnelAdm('BU_VILLE', $ville); } elseif ($classe == $ALL && $ecole == $ALL && $ville == $ALL) { // Les classes d'un groupe de villes $adm = $annuaireService->getPersonnelAdm('BU_GRVILLE', $grville); } } // =============== PERSONNEL EXTERIEUR ========================= $ext = array(); if (isset($profils['EXT']) && $grville && $ville && $ecole && $classe && $visib['USER_EXT']) { $ext = $annuaireService->getPersonnelExt('ROOT', 0); } // =============== PERSONNEL VILLE ========================= $vil = array(); if (isset($profils['VIL']) && $grville && $ville && $visib['USER_VIL']) { if ($ville != $ALL) { // Dans une ville $vil = $annuaireService->getPersonnelVil('BU_VILLE', $ville); } elseif ($ville == $ALL) { // Dans un groupe de villes $vil = $annuaireService->getPersonnelVil('BU_GRVILLE', $grville); } } $droits = array('checkAll' => $annuaireService->canMakeInAnnuaire('POPUP_CHECK_ALL')); $users = array(); foreach ($eleves as $user) { $users[$user->bu_type . '-' . $user->bu_id] = $user; } foreach ($parents as $user) { $users[$user->bu_type . '-' . $user->bu_id] = $user; } foreach ($personnel as $user) { $users[$user->bu_type . '-' . $user->bu_id] = $user; } foreach ($adm as $user) { $users[$user->bu_type . '-' . $user->bu_id] = $user; } foreach ($vil as $user) { $users[$user->bu_type . '-' . $user->bu_id] = $user; } foreach ($ext as $user) { $users[$user->bu_type . '-' . $user->bu_id] = $user; } //_dump($eleves); /* if ('communiquer' === $right) { foreach ($users as $k => $user) { //print_r($user); //$matrix->communiquer(); } } */ usort($users, array('ActionGroupAnnuaire', '_usortPopup')); $tplListe->assign('field', $field); $tplListe->assign('grville', $grville); $tplListe->assign('eleves', $eleves); $tplListe->assign('personnel', $personnel); $tplListe->assign('parents', $parents); $tplListe->assign('ext', $ext); $tplListe->assign('adm', $adm); $tplListe->assign('vil', $vil); $tplListe->assign('profils', $profils); $tplListe->assign('droits', $droits); $tplListe->assign('ville', $ville); $tplListe->assign('ecole', $ecole); $tplListe->assign('classe', $classe); $tplListe->assign('visib', $visib); $tplListe->assign('profil', $profil); $tplListe->assign('users', $users); $tplListe->assign('right', $right); $result = $tplListe->fetch('getpopup.tpl'); $ppo = new CopixPPO(); $ppo->result = $result; $ppo->TITLE_PAGE = CopixI18N::get('annuaire|annuaire.moduleDescription'); CopixHTMLHeader::addJSLink(_resource("js/iconito/module_annuaire.js")); return _arPPO($ppo, array('template' => 'getpopup_ppo.tpl', 'mainTemplate' => 'default|main_popup.php')); }
/** * Affiche l'aide * * @author Christophe Beyer <*****@*****.**> * @since 2006/04/12 */ public function processViewHelp() { $rubrique = $this->getRequest('rubrique', null); $page = $this->getRequest('page', null); $tpl = new CopixTpl(); $tpl->assign('TITLE_PAGE', CopixI18N::get('aide|aide.description')); //$tpl->assign ('MENU', $menu); if ($rubrique) { $hasHelpRub = false; $arModulesPath = CopixConfig::instance()->arModulesPath; foreach ($arModulesPath as $modulePath) { $file = $modulePath . $rubrique . '/' . COPIX_CLASSES_DIR . 'help' . $rubrique . '.class.php'; if (file_exists($file)) { $hasHelpRub = true; $modhelp =& CopixClassesFactory::Create($rubrique . '|help' . $rubrique); if (method_exists($modhelp, 'getPages')) { $pages = $modhelp->getPages(); } if ($page && is_array($pages) && isset($pages[$page])) { // Page précise $tpl->assign('TITLE_PAGE', Kernel::Code2Name('mod_' . $rubrique) . ' - ' . $pages[$page]['title']); $tpl->assign('MENU', '<a href="' . CopixUrl::get('aide||', array('rubrique' => $rubrique)) . '">' . CopixI18N::get('aide|aide.link.top') . '</a> :: <a href="' . CopixUrl::get('aide||') . '">' . CopixI18N::get('aide|aide.link.index') . '</a>'); // On vérifie que le fichier existe bien $lg = CopixI18N::getLang(); $file = $modulePath . $rubrique . '/' . COPIX_TEMPLATES_DIR . 'help_' . $page . '_' . $lg . '.html'; if (file_exists($file)) { //$tpl->assignStatic ('text', $rubrique.'|help_'.$page.'_'.$lg.'.html'); $tpl2 = new CopixTpl(); $text = $tpl2->fetch($rubrique . '|help_' . $page . '_' . $lg . '.html'); $tpl->assign('text', $text); $tpl->assign('rubrique', $rubrique); $tpl->assign('pages', $pages); $see = array(); if (isset($pages[$page]['links']) && is_array($pages[$page]['links'])) { $links = $pages[$page]['links']; //print_r($links); foreach ($links as $link) { $l = explode('|', $link); //print_r($l); if (count($l) == 1) { // Même module $see[] = array('rubrique' => $rubrique, 'page' => $l[0], 'title' => $pages[$l[0]]['title']); } else { // Autre module $arModulesPath2 = CopixConfig::instance()->arModulesPath; foreach ($arModulesPath2 as $modulePath2) { $file = $modulePath2 . $l[0] . '/' . COPIX_CLASSES_DIR . 'help' . $l[0] . '.class.php'; if (file_exists($file)) { $modhelp2 =& CopixClassesFactory::Create($l[0] . '|help' . $l[0]); if (method_exists($modhelp2, 'getPages')) { $pages2 = $modhelp2->getPages(); //print_r($pages2); $see[] = array('rubrique' => $l[0], 'page' => $l[1], 'title' => $pages2[$l[1]]['title']); } } } } } } $tpl->assign('links', $see); } $MAIN = $tpl->fetch('viewhelprubpage.tpl'); } else { // Sommaire de l'aide du module $tpl->assign('TITLE_PAGE', Kernel::Code2Name('mod_' . $rubrique)); $tpl->assign('MENU', '<a href="' . CopixUrl::get('aide||') . '">' . CopixI18N::get('aide|aide.link.index') . '</a>'); $tpl->assign('rubrique', $rubrique); $tpl->assign('pages', $pages); $MAIN = $tpl->fetch('viewhelprub.tpl'); } } } if (!$hasHelpRub) { $MAIN = $tpl->fetch('viewhelp.tpl'); } } else { $rubs = array('minimail', 'album'); // Compléter avec les modules dont l'aide est écrite $rubriques = array(); foreach ($rubs as $rub) { $rubriques[] = array('name' => $rub, 'title' => Kernel::Code2Name('mod_' . $rub)); } $tpl->assign('rubriques', $rubriques); $MAIN = $tpl->fetch('viewhelp.tpl'); } $tpl->assign('MAIN', $MAIN); return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl); }
public static function getModNotifications(&$module) { if (!_currentUser()->getExtra("user_id")) { return $module; } // echo('-'); $module_name = preg_replace('/^MOD_/', '', $module->module_type); $lastvisit = _dao('kernel|kernel_notifications_lastvisit')->findBy(_daoSp()->addCondition('user_id', '=', _currentUser()->getExtra("user_id"))->addCondition('node_type', '=', $module->node_type)->addCondition('node_id', '=', $module->node_id)->addCondition('module_type', '=', $module_name)->addCondition('module_id', '=', $module->module_id)); if (count($lastvisit)) { // Déjà une visite -> On vérifie le cache // echo "XXX"; if ($lastvisit[0]->last_check && $lastvisit[0]->last_check >= date('YmdHis', strtotime("-10 sec"))) { // Si le cache est encore valide -> On retourne les infos du cache // echo "cached($module_name/$module->module_id) "; $module->notification_number = $lastvisit[0]->last_number; $module->notification_message = $lastvisit[0]->last_message; } else { // S'il n'y a pas de cache ou qu'il est invalide -> On demande les infos au module // echo "not-cached($module_name/$module->module_id) "; $arModulesPath = CopixConfig::instance()->arModulesPath; foreach ($arModulesPath as $modulePath) { $class_file = $modulePath . strtolower($module_name) . '/' . COPIX_CLASSES_DIR . 'kernel' . strtolower($module_name) . '.class.php'; if (!file_exists($class_file)) { continue; } $module_class =& CopixClassesFactory::Create($module_name . '|Kernel' . $module_name); if (is_callable(array($module_class, 'getNotifications'))) { $module_class->getNotifications($module, $lastvisit[0]); $lastvisit[0]->last_check = date('Y-m-d H:i:s'); $lastvisit[0]->last_number = $module->notification_number; $lastvisit[0]->last_message = $module->notification_message; _dao('kernel|kernel_notifications_lastvisit')->update($lastvisit[0]); /* echo "<pre>"; print_r($module); print_r($lastvisit[0]); die(); */ } } } } else { // Pas encore de visite -> Pas de notif pour l'instant // echo "NOT_visited "; $module->notification_number = 0; $module->notification_message = ''; // Initialisation, même sans entrer dans le module $lastvisit = _record("kernel|kernel_notifications_lastvisit"); $lastvisit->user_id = _currentUser()->getExtra("user_id"); // id Copix $lastvisit->date = date('Y-m-d H:i:s'); $lastvisit->node_type = $module->node_type; $lastvisit->node_id = $module->node_id; $lastvisit->module_type = $module_name; $lastvisit->module_id = $module->module_id; _dao("kernel|kernel_notifications_lastvisit")->insert($lastvisit); } // [module_nom] => Agenda // echo "<pre>"; print_r($module); die(); return $module; }
public function getEdit() { if (!Kernel::isAdmin()) { return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('||')); } CopixHTMLHeader::addCSSLink(_resource("styles/module_comptes.css")); $tpl = new CopixTpl(); $tplAnimateurs = new CopixTpl(); $comptes_service =& CopixClassesFactory::Create('comptes|ComptesService'); $animateurs_dao =& CopixDAOFactory::create("kernel|kernel_animateurs"); $animateurs2regroupements_dao =& CopixDAOFactory::create("kernel|kernel_animateurs2regroupements"); $pUserType = _request('user_type'); $pUserId = _request('user_id'); $pSave = _request('save'); $user = Kernel::getUserInfo(); $ppo->pouvoirs = array(array('id' => 'can_connect', 'nom' => 'Se connecter en tant qu\'un enseignant/directeur'), array('id' => 'can_tableaubord', 'nom' => 'Tableau de bord des usages'), array('id' => 'can_comptes', 'nom' => 'Administration des comptes d\'accès')); $grvilles = $comptes_service->getGrvillesList(); $ppo->grvilles = array(); foreach ($grvilles as $grville) { $ppo->grvilles[$grville->id] = $grville; } $grecoles = $comptes_service->getGrecolesList(); $ppo->grecoles = array(); foreach ($grecoles as $grecole) { $ppo->grecoles[$grecole->id] = $grecole; } if (!$pUserType || !$pUserId) { return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('comptes|animateurs|list')); } $ppo->animateur = $animateurs_dao->get($pUserType, $pUserId); $new = false; if (!$ppo->animateur) { $ppo->animateur = _record("kernel|kernel_animateurs"); $ppo->animateur->user_type = $pUserType; $ppo->animateur->user_id = $pUserId; $ppo->animateur->can_connect = 0; $ppo->animateur->can_tableaubord = 0; $ppo->animateur->can_comptes = 0; $ppo->animateur->is_visibleannuaire = 0; $ppo->animateur->updated_at = date("Y-m-d H:i:s"); $ppo->animateur->updated_by = $user['login']; $new = true; // return new CopixActionReturn (COPIX_AR_REDIRECT, CopixUrl::get ('comptes|animateurs|list')); } if ($pSave == 1) { foreach ($ppo->pouvoirs as $pouvoir) { $ppo->animateur->{$pouvoir}['id'] = _request('pouvoir_' . $pouvoir['id']) * 1; } $ppo->animateur->is_visibleannuaire = _request('annuaire') * 1; $ppo->animateur->updated_at = date("Y-m-d H:i:s"); $ppo->animateur->updated_by = $user['login']; if ($new) { $animateurs_dao->insert($ppo->animateur); } $animateurs_dao->update($ppo->animateur); $animateurs2regroupements_dao->deleteByUser($pUserType, $pUserId); $animateurs2regroupements = _record("kernel|kernel_animateurs2regroupements"); $animateurs2regroupements->user_type = $pUserType; $animateurs2regroupements->user_id = $pUserId; $animateurs2regroupements->regroupement_type = 'villes'; foreach ($ppo->grvilles as $grville) { if (_request('groupe_villes_' . $grville->id) == 1) { $animateurs2regroupements->regroupement_id = $grville->id; _dao("kernel|kernel_animateurs2regroupements")->insert($animateurs2regroupements); } } $animateurs2regroupements->regroupement_type = 'ecoles'; foreach ($ppo->grecoles as $grecole) { if (_request('groupe_ecoles_' . $grecole->id) == 1) { $animateurs2regroupements->regroupement_id = $grecole->id; _dao("kernel|kernel_animateurs2regroupements")->insert($animateurs2regroupements); } } return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('comptes|animateurs|list')); } $ppo->animateur->user_infos = Kernel::getUserInfo($pUserType, $pUserId); $animateur_regroupements = $animateurs2regroupements_dao->findByUser($pUserType, $pUserId); $ppo->animateur_grville = array(); foreach ($animateur_regroupements as $animateur_regroupement) { if ($animateur_regroupement->regroupement_type == 'villes') { $ppo->animateur_grville[$animateur_regroupement->regroupement_id] = 1; } if ($animateur_regroupement->regroupement_type == 'ecoles') { $ppo->animateur_grecole[$animateur_regroupement->regroupement_id] = 1; } } $tplAnimateurs->assign('ppo', $ppo); $result = $tplAnimateurs->fetch("animateurs-edit.tpl"); $tpl->assign('TITLE_PAGE', CopixI18N::get('comptes.moduleDescription') . " » " . CopixI18N::get('comptes.title.animateur_edit')); $tpl->assign('MAIN', $result); $tpl->assign('MENU', $this->menu); return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl); }
/** * Telechargement d'un document joint a une fiche * * @author Christophe Beyer <*****@*****.**> * @since 2011/01/31 * @param string $fichier Nom du fichier * */ public function processDoc() { $iFichier = CopixRequest::get('fichier'); $malleService =& CopixClassesFactory::Create('malle|malleService'); preg_match('/^([0-9]+)_(.+)$/', $iFichier, $regs); $file = COPIX_VAR_PATH . CopixConfig::get('fichesecoles|docPath') . $iFichier; if (@file_exists($file)) { $filename = $regs[2]; return _arFile($file, array('filename' => $filename, 'content-type' => $malleService->getMimeType($file), 'content-disposition' => 'attachement')); } header("HTTP/1.0 404 Not Found"); return new CopixActionReturn(COPIX_AR_NONE, 0); }
public function setUserPasswd() { $from = _request('from', ''); if (0 && Kernel::isDemo()) { return Kernel::noDemo(); } $comptes_service =& CopixClassesFactory::Create('comptes|ComptesService'); $userinfo = $comptes_service->checkLoginAccess(_request('login')); $passwd1 = trim(_request('passwd1')); $passwd2 = trim(_request('passwd2')); if ($passwd1 == '' || strlen($passwd1) < 6) { $urlReturn = CopixUrl::get('comptes||getUser', array('node_type' => _request('node_type'), 'node_id' => _request('node_id'), 'login' => _request('login'), 'error' => 'tooshortpassword', 'from' => $from)); return new CopixActionReturn(COPIX_AR_REDIRECT, $urlReturn); } if ($passwd2 == '' || $passwd1 != $passwd2) { $urlReturn = CopixUrl::get('comptes||getUser', array('node_type' => _request('node_type'), 'node_id' => _request('node_id'), 'login' => _request('login'), 'error' => 'notsamepassword', 'from' => $from)); return new CopixActionReturn(COPIX_AR_REDIRECT, $urlReturn); } $user_dao =& CopixDAOFactory::create("kernel|kernel_copixuser"); $user_new = $user_dao->getByLogin(_request('login')); $user_new[0]->password_dbuser = md5(_request('passwd1')); $user_dao->update($user_new[0]); //print_r($user_new); if ($from == 'assistance') { $urlReturn = CopixUrl::get('assistance||users'); } else { $urlReturn = CopixUrl::get('comptes||getNode', array('type' => _request('node_type'), 'id' => _request('node_id'))); } return new CopixActionReturn(COPIX_AR_REDIRECT, $urlReturn); }
public function publish($id, $image) { // $image['file'] -> nom de fichier // $image['title'] -> titre (ou nom à défaut) // $image['body'] -> commentaire // $image['data'] -> données if (!isset($image['file']) || trim($image['file']) == '' || !isset($image['data']) || $image['data'] == '') { return false; } $classeur_dao = _dao("classeur|classeur"); $classeur = $classeur_dao->get($id); if ($classeur == null) { return false; } $ext = ''; switch (strtolower(strrchr($image['file'], "."))) { case '.jpg': case '.jpe': $ext = "jpg"; break; case '.jpeg': $ext = "jpeg"; break; case '.gif': $ext = "gif"; break; case '.png': $ext = "png"; break; default: continue; break; } if ($ext != '') { $classeur_service =& CopixClassesFactory::Create('classeur|ClasseurService'); $photo_dao =& _dao("classeur|classeurfichier"); $nouvelle_photo = _record("classeur|classeurfichier"); $nouvelle_photo->classeur_id = $classeur->id; $nouvelle_photo->dossier_id = 0; if (trim($image['title']) != '') { $nouvelle_photo->titre = $image['title']; } else { $nouvelle_photo->titre = $image['file']; } $nouvelle_photo->commentaire = ''; $nouvelle_photo->fichier = $image['file']; $nouvelle_photo->taille = strlen($image['data']); $nouvelle_photo->user_type = ''; $nouvelle_photo->user_id = 0; $nouvelle_photo->date_upload = date("Y-m-d H:i:s"); $nouvelle_photo->type = $ext; $nouvelle_photo->cle = $classeur_service->createKey(); $photo_dao->insert($nouvelle_photo); if ($nouvelle_photo->id) { $path2data = realpath("static"); $path2album = $path2data . "/classeur/" . $classeur->id . "-" . $classeur->cle; $photofile = $path2album . "/" . $nouvelle_photo->id . "-" . $nouvelle_photo->cle . '.' . $ext; $file = fopen($photofile, 'w'); fwrite($file, $image['data']); fclose($file); } $results = array('title' => $nouvelle_photo->titre, 'album_id' => $classeur->id, 'album_key' => $classeur->cle, 'photo_id' => $nouvelle_photo->id, 'photo_key' => $nouvelle_photo->cle, 'photo_ext' => $ext); return $results; } return false; }
public function processDefault() { ini_set('max_execution_time', 0); $classeurservice =& CopixClassesFactory::Create('classeur|classeurservice'); /* DEBUG if (!Admin::canAdmin()) return CopixActionGroup::process ('genericTools|Messages::getError', array ('message'=>CopixI18N::get ('kernel|kernel.error.noRights'), 'back'=>CopixUrl::get ())); */ $tpl = new CopixTpl(); // $tpl->assign ('TITLE_PAGE', CopixI18N::get ('sysutils|admin.menu.cache')); // $tpl->assign ('MENU', Admin::getMenu('cache')); /////////////// //// ALBUM //// /////////////// $sql = "\n SELECT\n A.id AS album_id, A.nom AS album_nom, A.prefs AS album_prefs, A.date AS album_date, A.cle AS album_cle, A.public AS album_public\n FROM module_album_albums A\n ORDER BY A.id\n "; $album_list = _doQuery($sql); $album_tree = array(); foreach ($album_list as $album_item) { if (!isset($album_tree[$album_item->album_id])) { $album_tree[$album_item->album_id] = new CopixPPO(); $album_tree[$album_item->album_id]->info = $album_item; $parent = Kernel::getModParent("MOD_ALBUM", $album_item->album_id); if (!$parent) { unset($album_tree[$album_item->album_id]); continue; } $album_tree[$album_item->album_id]->parent = $parent[0]; $album_tree[$album_item->album_id]->dossier = array(); $album_tree[$album_item->album_id]->photo = array(); } $root = $this->albumScanFolder($album_item->album_id, 0); $album_tree[$album_item->album_id]->dossier = $root->dossier; $album_tree[$album_item->album_id]->photo = $root->photo; } // module_malle_malles : id titre date_creation cle // module_malle_folders : id malle parent nom nb_folders nb_files taille date_creation // module_malle_files : id malle folder nom fichier taille type cle date_upload /////////////// //// MALLE //// /////////////// $sql = "\n SELECT\n id, titre, date_creation, cle\n FROM module_malle_malles\n ORDER BY id\n "; $malle_list = _doQuery($sql); $malle_tree = array(); foreach ($malle_list as $malle_item) { if (!isset($malle_tree[$malle_item->id])) { $malle_tree[$malle_item->id] = new CopixPPO(); $malle_tree[$malle_item->id]->info = $malle_item; $parent = Kernel::getModParent("MOD_MALLE", $malle_item->id); if (!$parent) { unset($malle_tree[$malle_item->id]); continue; } $malle_tree[$malle_item->id]->parent = $parent[0]; $user_parents = Kernel::getNodeParents($parent[0]->node_type, $parent[0]->node_id); $malle_tree[$malle_item->id]->user_parents = $user_parents; $malle_tree[$malle_item->id]->dossier = array(); $malle_tree[$malle_item->id]->docs = array(); } $root = $this->malleScanFolder($malle_item->id, 0); $malle_tree[$malle_item->id]->dossier = $root->dossier; $malle_tree[$malle_item->id]->docs = $root->docs; } ///////////////////////////////////// ///////////////////////////////////// // kernel_mod_enabled : node_type node_id module_type module_id // module_classeur : id titre cle date_creation date_publication public // module_classeur_dossier : id module_classeur_id parent_id nom nb_dossiers nb_fichiers taille cle date_creation user_type user_id date_publication public // module_classeur_fichier : id module_classeur_id module_classeur_dossier_id titre commentaire fichier taille type cle date_upload user_type user_id // IMPORT ALBUMS if (1) { foreach ($album_tree as $album_item) { if (!isset($album_item->parent->node_type)) { continue; } //// RECHERCHE D'UN CLASSEUR EXISTANT $sql = "\n SELECT module_id\n FROM kernel_mod_enabled\n WHERE node_type=:node_type AND node_id=:node_id AND module_type=:module_type\n "; $param = array('node_type' => $album_item->parent->node_type, 'node_id' => $album_item->parent->node_id, 'module_type' => 'MOD_CLASSEUR'); $mod_classeur = _doQuery($sql, $param); if (!isset($mod_classeur[0])) { $node_infos = $this->getNodeInfos($album_item->parent->node_type, $album_item->parent->node_id); $file =& CopixSelectorFactory::create("classeur|classeur"); $filePath = $file->getPath() . COPIX_CLASSES_DIR . "kernel" . strtolower($file->fileName) . '.class.php'; $modservice =& CopixClassesFactory::Create('classeur|kernelclasseur'); if (method_exists($modservice, "create")) { $modid = $modservice->create(array('title' => $node_infos->nom, 'subtitle' => '', 'node_type' => $album_item->parent->node_type, 'node_id' => $album_item->parent->node_id)); if ($modid != null) { Kernel::registerModule('MOD_CLASSEUR', $modid, $album_item->parent->node_type, $album_item->parent->node_id); } } $classeur_id = $modid; } else { $classeur_id = $mod_classeur[0]->module_id; } $classeurDAO = _ioDAO('classeur|classeur'); $classeur = $classeurDAO->get($classeur_id); $new_dir = realpath('./static/classeur') . '/' . $classeur->id . '-' . $classeur->cle . '/'; if (!file_exists($new_dir)) { mkdir($new_dir, 0755, true); } //// CREATION D'UN DOSSIER D'IMPORT $dossierDAO = _ioDAO('classeur|classeurdossier'); $dossier = _record('classeur|classeurdossier'); $dossier->classeur_id = $classeur_id; $dossier->parent_id = 0; $dossier->nom = "Import Album " . $album_item->info->album_id; $dossier->cle = $album_item->info->album_cle; $dossier->date_creation = $album_item->info->album_date; $dossier->user_type = ""; $dossier->user_id = ""; $dossier->nb_dossiers = 0; $dossier->nb_fichiers = 0; $dossier->taille = 0; $dossier->casier = 0; $dossierDAO->insert($dossier); // $dossier->id $this->albumImport($album_item, $dossier); $classeurservice->updateFolderInfosWithDescendants($dossier); } } // IMPORT MALLES if (1) { foreach ($malle_tree as $malle_item) { if (!isset($malle_item->parent->node_type)) { continue; } //// RECHERCHE D'UN CLASSEUR EXISTANT $sql = "\n SELECT module_id\n FROM kernel_mod_enabled\n WHERE node_type=:node_type AND node_id=:node_id AND module_type=:module_type\n "; $param = array('node_type' => $malle_item->parent->node_type, 'node_id' => $malle_item->parent->node_id, 'module_type' => 'MOD_CLASSEUR'); $mod_classeur = _doQuery($sql, $param); if (!isset($mod_classeur[0])) { $node_infos = $this->getNodeInfos($malle_item->parent->node_type, $malle_item->parent->node_id); $file =& CopixSelectorFactory::create("classeur|classeur"); $filePath = $file->getPath() . COPIX_CLASSES_DIR . "kernel" . strtolower($file->fileName) . '.class.php'; $modservice =& CopixClassesFactory::Create('classeur|kernelclasseur'); if (method_exists($modservice, "create")) { $modid = $modservice->create(array('title' => $node_infos->nom, 'subtitle' => '', 'node_type' => $malle_item->parent->node_type, 'node_id' => $malle_item->parent->node_id)); if ($modid != null) { Kernel::registerModule('MOD_CLASSEUR', $modid, $malle_item->parent->node_type, $malle_item->parent->node_id); } } $classeur_id = $modid; } else { $classeur_id = $mod_classeur[0]->module_id; } $classeurDAO = _ioDAO('classeur|classeur'); $classeur = $classeurDAO->get($classeur_id); $new_dir = realpath('./static/classeur') . '/' . $classeur->id . '-' . $classeur->cle . '/'; if (!file_exists($new_dir)) { mkdir($new_dir, 0755, true); } //// CREATION D'UN DOSSIER D'IMPORT $dossierDAO = _ioDAO('classeur|classeurdossier'); $dossier = _record('classeur|classeurdossier'); $dossier->classeur_id = $classeur_id; $dossier->parent_id = 0; $dossier->nom = "Import documents " . $malle_item->info->id; $dossier->cle = $malle_item->info->cle; $dossier->date_creation = $malle_item->info->date_creation; $dossier->user_type = ""; $dossier->user_id = ""; $dossier->nb_dossiers = 0; $dossier->nb_fichiers = 0; $dossier->taille = 0; $dossierDAO->insert($dossier); // $dossier->id $this->malleImport($malle_item, $dossier); $classeurservice->updateFolderInfosWithDescendants($dossier); } } $sql = "\n UPDATE kernel_mod_available\n SET node = CONCAT(node, '_OFF')\n WHERE module = 'MOD_MALLE' OR module = 'MOD_ALBUM'"; _doQuery($sql); $sql = "\n UPDATE kernel_mod_enabled\n SET node_type = CONCAT(node_type, '_OFF')\n WHERE module_type = 'MOD_MALLE' OR module_type = 'MOD_ALBUM' AND node_type != 'MOD_TELEPROCEDURES'"; _doQuery($sql); echo "<h1>Fin</h1>"; echo "<pre>"; print_r($album_tree); print_r($malle_tree); die; }
public function getGroup() { if (!Kernel::isAdmin()) { return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('||')); } $tpl = new CopixTpl(); $tplGrVilles = new CopixTpl(); CopixHTMLHeader::addCSSLink(_resource("styles/module_regroupements.css")); $regroupements_service =& CopixClassesFactory::Create('regroupements|regroupements'); $tpl->assign('TITLE_PAGE', CopixI18N::get('regroupements|regroupements.villes.titre')); $tpl->assign('MENU', $regroupements_service->getMenu()); $dao_grvilles_gr2ville = CopixDAOFactory::create("regroupements|grvilles_gr2ville"); $dao_grvilles = CopixDAOFactory::create("regroupements|grvilles"); $dao_villes = CopixDAOFactory::create("kernel|kernel_tree_vil"); $villes = $dao_villes->findAll(); $tplGrVilles->assign('villes', $villes); if (_request("delete")) { $dao_grvilles->delete(_request("delete")); $dao_grvilles_gr2ville->deleteByGroupe(_request("delete")); return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('regroupements|villes|')); } if (_request("save") && _request("save") == 1) { $date = date("Y-m-d H:i:s"); $user = Kernel::getUserInfo(); if (_request("form_id") > 0) { $grvilles_infos = $dao_grvilles->get(_request("form_id")); $grvilles_infos->nom = _request("form_nom"); $grvilles_infos->updated_at = $date; $grvilles_infos->updated_by = $user['login']; $dao_grvilles->update($grvilles_infos); $dao_grvilles_gr2ville->deleteByGroupe(_request("form_id")); } else { $grvilles_infos = CopixDAOFactory::createRecord("regroupements|grvilles"); $grvilles_infos->nom = _request("form_nom"); if ($grvilles_infos->nom == '') { $grvilles_infos->nom = 'Sans nom'; } $grvilles_infos->updated_at = date("Y-m-d H:i:s"); $grvilles_infos->updated_by = $user['login']; $dao_grvilles->insert($grvilles_infos); } $grvilles_gr2ville = _record("regroupements|grvilles_gr2ville"); $grvilles_gr2ville->id_groupe = $grvilles_infos->id; $grvilles_gr2ville->updated_at = $date; $grvilles_gr2ville->updated_by = $user['login']; foreach ($villes as $ville) { if (_request("ville_" . $ville->vil_id_vi) == 1) { $grvilles_gr2ville->id_ville = $ville->vil_id_vi; _dao("regroupements|grvilles_gr2ville")->insert($grvilles_gr2ville); } } if (_request("form_id") == 0) { return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('regroupements|villes|', array('groupe' => $grvilles_infos->id))); } } if (_request("groupe")) { $tplGrVilles->assign('grvilles_id', _request("groupe")); $tplGrVilles->assign('grvilles_form', true); if (_request("groupe") > 0) { // Edition d'un groupe $grvilles_infos = $dao_grvilles->get(_request("groupe")); $grvilles_villes_raw = $dao_grvilles_gr2ville->findByGroupe(_request("groupe")); // Tableau indexé par id de ville $grvilles_villes = array(); foreach ($grvilles_villes_raw as $grvilles_villes_item) { $grvilles_villes[$grvilles_villes_item->id_ville] = $grvilles_villes_item; } $tplGrVilles->assign('grvilles_infos', $grvilles_infos); $tplGrVilles->assign('grvilles_villes', $grvilles_villes); } else { // Création d'un nouveau groupe } } $grvilles_list = $dao_grvilles->findAll(); // print_r($grvilles_list); $tplGrVilles->assign('grvilles_list', $grvilles_list); $main = $tplGrVilles->fetch('getgrvilles.tpl'); $tpl->assign('MAIN', $main); return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl); }
public function processDoCreateAccounts() { $comptes_service =& CopixClassesFactory::Create('comptes|ComptesService'); if (!Admin::canAdmin()) { return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('kernel|kernel.error.noRights'), 'back' => CopixUrl::get())); } $limit = $this->getRequest('limit', 5); $password = $this->getRequest('password', '123456'); $ppo = new CopixPPO(); // dbuser : id_dbuser login_dbuser password_dbuser email_dbuser enabled_dbuser // kernel_link_bu2user : user_id bu_type bu_id $sql_params = array(); $sql = ' SELECT E.idEleve, E.nom, E.prenom1 AS prenom, KLB2U.* FROM kernel_bu_eleve E LEFT JOIN kernel_link_bu2user KLB2U ON E.idEleve=KLB2U.bu_id AND KLB2U.bu_type="USER_ELE" WHERE bu_type IS NULL'; $ppo->user_ele = CopixDB::getConnection()->doQuery($sql, $sql_params); $sql = ' SELECT P.numero, P.nom, P.prenom1 AS prenom, P.civilite, P.id_sexe, PE.role, KLB2U.* FROM kernel_bu_personnel_entite PE, kernel_bu_personnel P LEFT JOIN kernel_link_bu2user KLB2U ON P.numero=KLB2U.bu_id AND KLB2U.bu_type="USER_ENS" WHERE PE.type_ref="ECOLE" AND (PE.role=1 OR PE.role=2) AND PE.id_per=P.numero AND bu_type IS NULL'; $ppo->user_ens = CopixDB::getConnection()->doQuery($sql, $sql_params); $sql = ' SELECT P.numero, P.nom, P.prenom1 AS prenom, P.civilite, P.id_sexe, PE.role, KLB2U.* FROM kernel_bu_personnel_entite PE, kernel_bu_personnel P LEFT JOIN kernel_link_bu2user KLB2U ON P.numero=KLB2U.bu_id AND KLB2U.bu_type="USER_VIL" WHERE PE.type_ref="VILLE" AND PE.role=4 AND PE.id_per=P.numero AND bu_type IS NULL'; $ppo->user_vil = CopixDB::getConnection()->doQuery($sql, $sql_params); $sql = ' SELECT R.numero, R.nom, R.prenom1 AS prenom, R.civilite, R.id_sexe, KLB2U.* FROM kernel_bu_responsable R LEFT JOIN kernel_link_bu2user KLB2U ON R.numero=KLB2U.bu_id AND KLB2U.bu_type="USER_RES" WHERE bu_type IS NULL'; $ppo->user_res = CopixDB::getConnection()->doQuery($sql, $sql_params); $fusible = $limit; echo "<pre>"; foreach ($ppo->user_ele as $eleve) { if ($fusible-- <= 0) { break; } $user_infos = Kernel::getUserInfo('USER_ELE', $eleve->idEleve); $login = $comptes_service->createLogin($user_infos); $user_new = CopixDAOFactory::createRecord("kernel|kernel_copixuser"); $user_new->login_dbuser = $login; $user_new->password_dbuser = md5($password); $user_new->email_dbuser = ''; $user_new->enabled_dbuser = 1; _dao("kernel|kernel_copixuser")->insert($user_new); $bu_new = _record("kernel|kernel_bu2user2"); $bu_new->user_id = $user_new->id_dbuser; $bu_new->bu_type = 'USER_ELE'; $bu_new->bu_id = $eleve->idEleve; _dao("kernel|kernel_bu2user2")->insert($bu_new); echo $eleve->nom . ";" . $eleve->prenom . ";" . $login . ";" . $password . "\n"; } foreach ($ppo->user_ens as $ens) { if ($fusible-- <= 0) { break; } $user_infos = Kernel::getUserInfo('USER_ENS', $ens->numero); $login = $comptes_service->createLogin($user_infos); $user_new = CopixDAOFactory::createRecord("kernel|kernel_copixuser"); $user_new->login_dbuser = $login; $user_new->password_dbuser = md5($password); $user_new->email_dbuser = ''; $user_new->enabled_dbuser = 1; _dao("kernel|kernel_copixuser")->insert($user_new); $bu_new = _record("kernel|kernel_bu2user2"); $bu_new->user_id = $user_new->id_dbuser; $bu_new->bu_type = 'USER_ENS'; $bu_new->bu_id = $ens->numero; _dao("kernel|kernel_bu2user2")->insert($bu_new); echo $ens->nom . ";" . $ens->prenom . ";" . $login . ";" . $password . "\n"; } foreach ($ppo->user_vil as $vil) { if ($fusible-- <= 0) { break; } $user_infos = Kernel::getUserInfo('USER_VIL', $vil->numero); $login = $comptes_service->createLogin($user_infos); $user_new = CopixDAOFactory::createRecord("kernel|kernel_copixuser"); $user_new->login_dbuser = $login; $user_new->password_dbuser = md5($password); $user_new->email_dbuser = ''; $user_new->enabled_dbuser = 1; _dao("kernel|kernel_copixuser")->insert($user_new); $bu_new = _record("kernel|kernel_bu2user2"); $bu_new->user_id = $user_new->id_dbuser; $bu_new->bu_type = 'USER_VIL'; $bu_new->bu_id = $vil->numero; _dao("kernel|kernel_bu2user2")->insert($bu_new); echo $vil->nom . ";" . $vil->prenom . ";" . $login . ";" . $password . "\n"; } foreach ($ppo->user_res as $res) { if ($fusible-- <= 0) { break; } $user_infos = Kernel::getUserInfo('USER_RES', $res->numero); $login = $comptes_service->createLogin($user_infos); $user_new = CopixDAOFactory::createRecord("kernel|kernel_copixuser"); $user_new->login_dbuser = $login; $user_new->password_dbuser = md5($password); $user_new->email_dbuser = ''; $user_new->enabled_dbuser = 1; _dao("kernel|kernel_copixuser")->insert($user_new); $bu_new = _record("kernel|kernel_bu2user2"); $bu_new->user_id = $user_new->id_dbuser; $bu_new->bu_type = 'USER_RES'; $bu_new->bu_id = $res->numero; _dao("kernel|kernel_bu2user2")->insert($bu_new); echo $res->nom . ";" . $res->prenom . ";" . $login . ";" . $password . "\n"; } echo "</pre>"; die; /* * * * * $user_infos = Kernel::getUserInfo( $user_type, $user_id ); // V�rification de l'existance d'un login. // -> Si c'est le cas, il ne faut pas proposer un nouveau login. $bu_user = $bu_dao->getByBUID( $user_type, $user_id ); if( !count($bu_user) ) { $user_infos['login'] = $comptes_service->createLogin( $user_infos ); $user_new = CopixDAOFactory::createRecord("kernel|kernel_copixuser"); $user_new->login_dbuser = $pLogin[$typeid]; $user_new->password_dbuser = md5($pPasswd[$typeid]); $user_new->email_dbuser = ''; $user_new->enabled_dbuser = 1; if( $user_dao->insert( $user_new ) ) { // Cr�ation du lien entre l'utilisateur de la base unique et le login. $bu_new = _record("kernel|kernel_bu2user2"); $bu_new->user_id = $user_new->id_dbuser; $bu_new->bu_type = $user_type; $bu_new->bu_id = $user_id; // Enregistrement et v�rification de l'insertion. if( _dao("kernel|kernel_bu2user2")->insert( $bu_new ) ) { */ }