/**
  * Commentaires d'une procedure
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2008/01/30
  * @param object $rFiche Recordset de la procedure
  */
 public function _createContent(&$toReturn)
 {
     $tpl = new CopixTpl();
     $rFiche = $this->getParam('rFiche');
     $mondroit = $this->getParam('mondroit');
     $daoinfo =& _dao('infosupp');
     $sql = 'SELECT * FROM module_teleprocedure_infosupp WHERE idinter=' . $rFiche->idinter . '';
     $canCheckVisible = TeleproceduresService::canMakeInTelep('CHECK_VISIBLE', $mondroit);
     $canAddComment = TeleproceduresService::canMakeInTelep('ADD_COMMENT', $mondroit);
     if (!$canCheckVisible) {
         $sql .= " AND info_message!='' AND info_message IS NOT NULL";
     }
     $sql .= " ORDER BY dateinfo ASC, idinfo ASC";
     $results = _doQuery($sql);
     // Pour chaque message on cherche les infos de son auteur
     $list = array();
     foreach ($results as $r) {
         $userInfo = Kernel::getUserInfo("ID", $r->iduser);
         //var_dump($userInfo);
         $avatar = Prefs::get('prefs', 'avatar', $r->iduser);
         $userInfo['avatar'] = $avatar ? CopixConfig::get('prefs|avatar_path') . $avatar : '';
         $r->user = $userInfo;
         $list[] = $r;
     }
     //print_r($rFiche);
     $tpl->assign('info_message_edition', CopixZone::process('kernel|edition', array('field' => 'info_message', 'format' => $rFiche->type_format, 'content' => '', 'width' => 350, 'height' => 135, 'options' => array('toolbarSet' => 'IconitoBasic', 'enterMode' => 'br', 'toolbarStartupExpanded' => 'false'))));
     $tpl->assign('info_commentaire_edition', CopixZone::process('kernel|edition', array('field' => 'info_commentaire', 'format' => $rFiche->type_format, 'content' => '', 'width' => 350, 'height' => 135, 'options' => array('toolbarSet' => 'IconitoBasic', 'enterMode' => 'br', 'toolbarStartupExpanded' => 'false'))));
     $tpl->assign('canCheckVisible', $canCheckVisible);
     $tpl->assign('canAddComment', $canAddComment);
     $tpl->assign('list', $list);
     $tpl->assign('rFiche', $rFiche);
     $toReturn = $tpl->fetch('fiche-comms-zone.tpl');
     return true;
 }
Exemplo n.º 2
0
 public function startExec()
 {
     if (_currentUser()->isConnected()) {
         $userId = _currentUser()->getId();
         $userInfos = Kernel::getUserInfo('ID', $userId);
         $this->director = false;
         $this->animator = _currentUser()->hasAssistance();
         $this->idEn = isset($userInfos['id']) ? $userInfos['id'] : null;
         $this->id = $userId * 1;
         $this->type = isset($userInfos['type']) ? $userInfos['type'] : null;
         $this->root = false;
         $this->login = $userInfos['login'];
         $this->nom = $userInfos['nom'];
         $this->prenom = $userInfos['prenom'];
         $this->connected = true;
         $this->chartValid = isset($_SESSION['chartValid']) ? $_SESSION['chartValid'] : false;
     } else {
         $this->director = false;
         $this->animator = false;
         $this->id = 0;
         $this->type = 'USER_ANON';
         $this->root = false;
         $this->login = '******';
         $this->nom = 'Anon';
         $this->prenom = 'Anon';
         $this->connected = false;
         $this->idEn = 0;
         $this->chartValid = 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)
 {
     $type = $this->getParam('type') ? $this->getParam('type') : NULL;
     $id = $this->getParam('id') ? $this->getParam('id') : NULL;
     if ($type && $id) {
         $usr = Kernel::getUserInfo($type, $id);
         //print_r($usr);
         /*
         $res = '<?xml version="1.0" ?>
         <person>
         <login>'.$login.'</login>
         <sexe>'.$usr['sexe'].'</sexe>
         <firstname>'.$usr['prenom'].'</firstname>
         <name>'.$usr['nom'].'</name>
         </person>
         ';
         */
         $tpl = new CopixTpl();
         $tpl->assign('usr', $usr);
         //$toReturn = utf8_encode($tpl->fetch ('getuser.tpl'));
         $toReturn = $tpl->fetch('getuser.tpl');
         //$toReturn = $res;
     }
     return true;
 }
 public function _createContent(&$toReturn)
 {
     $ppo = new CopixPPO();
     _classInclude('classeur|ClasseurService');
     // Récupération des paramètres
     $ppo->classeurId = $this->getParam('classeurId');
     $ppo->dossierId = $this->getParam('dossierId');
     // Gestion des droits
     $ppo->niveauUtilisateur = Kernel::getLevel('MOD_CLASSEUR', $ppo->classeurId);
     $ppo->typeUtilisateur = _currentUser()->getExtra('type');
     $ppo->idUtilisateur = _currentUser()->getExtra('id');
     // Récupération des paramètres d'affichages
     $ppo->tri = ClasseurService::getContentSort();
     // Récupération des dossiers & des fichiers / favoris
     $dossierDAO = _ioDAO('classeur|classeurdossier');
     if ($ppo->dossier = $dossierDAO->get($ppo->dossierId)) {
         if ($ppo->dossier->parent_id != 0) {
             $ppo->dossierParent = $dossierDAO->get($ppo->dossier->parent_id);
         } else {
             $classeurDAO = _ioDAO('classeur|classeur');
             $ppo->classeurParent = $classeurDAO->get($ppo->classeurId);
             $ppo->classeurParent->isPersonnel = ClasseurService::getClasseurPersonnelId() == $ppo->classeurParent->id;
         }
     }
     if (!$ppo->dossier->casier || $ppo->niveauUtilisateur >= PROFILE_CCV_MODERATE) {
         $ppo->contenus = $dossierDAO->getContenus($ppo->classeurId, $ppo->dossierId, $ppo->tri);
         foreach ($ppo->contenus as $contenu) {
             if ($ppo->dossier->casier) {
                 $user = Kernel::getUserInfo($contenu->user_type, $contenu->user_id);
                 $contenu->user = $user['prenom'] . ' ' . $user['nom'];
             }
         }
     }
     $toReturn = $this->_usePPO($ppo, '_vue_liste.tpl');
 }
 public function getSso()
 {
     $id = $this->getRequest('id', null);
     if (!$id) {
         // Récupération des infos de l'utilisateur.
         $userInfo = Kernel::getUserInfo();
         // Création des modules inexistants.
         Kernel::createMissingModules($userInfo["type"], $userInfo["id"]);
         // Liste des modules activés.
         $modsList = Kernel::getModEnabled($userInfo["type"], $userInfo["id"]);
         foreach ($modsList as $modInfo) {
             if ($modInfo->module_type == "MOD_SSO" && $modInfo->module_id) {
                 $urlReturn = CopixUrl::get('sso||getSso', array('id' => $modInfo->module_id));
                 return new CopixActionReturn(COPIX_AR_REDIRECT, $urlReturn);
             }
         }
     }
     if (!$id) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => 'Problème', 'back' => CopixUrl::get('||')));
     }
     $tpl = new CopixTpl();
     $tpl->assign('TITLE_PAGE', CopixI18N::get('sso.title.servext'));
     $dao = CopixDAOFactory::create("sso|sso_auth");
     // $all = $dao->findAll();
     $all = $dao->findBySso($id);
     $tpl->assign('MAIN', CopixZone::process('sso|SsoAuthList', array('list' => $all, 'id' => _request("id"))));
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 public function processLogin()
 {
     include_once COPIX_UTILS_PATH . '../../CAS-1.2.2/CAS.php';
     $_SESSION['chartValid'] = false;
     $ppo = new CopixPPO();
     $ppo->user = _currentUser();
     if ($ppo->user->isConnected()) {
         $url_return = CopixUrl::get('kernel||doSelectHome');
         /*
          * PATCH FOR CHARTE
          */
         $this->user->forceReload();
         if (!$this->service('charte|CharteService')->checkUserValidation()) {
             $this->flash->redirect = $url_return;
             return $this->go('charte|charte|valid');
         }
         return _arRedirect($url_return);
         //return new CopixActionReturn (COPIX_AR_REDIRECT, $url_return);
     } else {
         $conf_Cas_host = CopixConfig::get('default|conf_Cas_host');
         $conf_Cas_port = CopixConfig::get('default|conf_Cas_port');
         $conf_Cas_path = CopixConfig::get('default|conf_Cas_path');
         phpCAS::client(CAS_VERSION_2_0, $conf_Cas_host, (int) $conf_Cas_port, $conf_Cas_path, false);
         phpCAS::setNoCasServerValidation();
         phpCAS::forceAuthentication();
         $ppo->cas_user = phpCAS::getUser();
         if ($ppo->cas_user) {
             $ppo->iconito_user = Kernel::getUserInfo("LOGIN", $ppo->cas_user);
             if ($ppo->iconito_user['login']) {
                 _currentUser()->login(array('login' => $ppo->iconito_user['login'], 'assistance' => true));
                 $url_return = CopixUrl::get('kernel||doSelectHome');
                 // $url_return = CopixUrl::get ('assistance||users');
                 $this->user->forceReload();
                 if (!$this->service('charte|CharteService')->checkUserValidation()) {
                     $this->flash->redirect = $url_return;
                     return $this->go('charte|charte|valid');
                 }
                 return new CopixActionReturn(COPIX_AR_REDIRECT, $url_return);
             } else {
                 $ppo->cas_error = 'no-iconito-user';
                 return _arPpo($ppo, 'cas.tpl');
             }
         }
     }
     $ppo = new CopixPPO();
     $ppo->TITLE_PAGE = $pTitle;
     phpCAS::setDebug();
     $conf_Cas_host = CopixConfig::get('default|conf_Cas_host');
     $conf_Cas_port = CopixConfig::get('default|conf_Cas_port');
     $conf_Cas_path = CopixConfig::get('default|conf_Cas_path');
     phpCAS::client(CAS_VERSION_2_0, $conf_Cas_host, (int) $conf_Cas_port, $conf_Cas_path, false);
     phpCAS::setNoCasServerValidation();
     phpCAS::forceAuthentication();
     if (isset($_REQUEST['logout'])) {
         phpCAS::logout();
     }
     die(phpCAS::getUser());
     die('ok');
     return _arPpo($ppo, 'handlers.list.tpl');
 }
 /**
  * Admins
  *
  * Affiche la liste des administrateurs
  *
  * @package	Comptes
  * @author	Frédéric Mossmann <*****@*****.**>
  */
 public function processDefault()
 {
     if (!Kernel::isAdmin()) {
         return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('||'));
     }
     $roles = _request('role');
     $new_admin = _request('new_admins');
     if ($roles) {
         $sql = "\n                SELECT dbuser.*, kernel_link_bu2user.*\n                FROM dbuser\n                JOIN kernel_link_bu2user ON dbuser.id_dbuser=kernel_link_bu2user.user_id\n                WHERE dbuser.id_dbuser IN (" . implode(',', array_keys($roles)) . ")\n            ";
         $admins_mod = _doQuery($sql);
         foreach ($admins_mod as $admins_mod_item) {
             $sql = "\n                    DELETE FROM kernel_link_user2node\n                    WHERE node_type='ROOT' AND node_id=0\n                    AND   user_type=:bu_type AND user_id=:bu_id\n                ";
             _doQuery($sql, array(':bu_type' => $admins_mod_item->bu_type, ':bu_id' => $admins_mod_item->bu_id));
             $sql = "\n                    DELETE FROM dbgroup_users\n                    WHERE id_dbgroup=:id_dbgroup AND userhandler_dbgroup=:userhandler_dbgroup AND user_dbgroup=:user_dbgroup";
             $params = array(':id_dbgroup' => 1, ':userhandler_dbgroup' => 'auth|dbuserhandler', ':user_dbgroup' => $admins_mod_item->id_dbuser);
             _doQuery($sql, $params);
             if ($roles[$admins_mod_item->id_dbuser]) {
                 $sql = "\n                        INSERT INTO kernel_link_user2node\n                            ( user_type,  user_id,  node_type,  node_id,  droit)\n                        VALUES\n                            (:user_type, :user_id, :node_type, :node_id, :droit)\n                        ";
                 $params = array(':user_type' => $admins_mod_item->bu_type, ':user_id' => $admins_mod_item->bu_id, ':node_type' => 'ROOT', ':node_id' => 0, ':droit' => $roles[$admins_mod_item->id_dbuser]);
                 _doQuery($sql, $params);
                 $sql = "\n                        INSERT INTO dbgroup_users\n                            ( id_dbgroup,  userhandler_dbgroup,  user_dbgroup)\n                        VALUES\n                            (:id_dbgroup, :userhandler_dbgroup, :user_dbgroup)\n                        ";
                 $params = array(':id_dbgroup' => 1, ':userhandler_dbgroup' => 'auth|dbuserhandler', ':user_dbgroup' => $admins_mod_item->id_dbuser);
                 _doQuery($sql, $params);
             }
         }
     }
     if ($new_admin) {
         $new_admin_array = split(',', $new_admin);
         $new_admin_array_clean = array_map('trim', $new_admin_array);
         $sql_newadmins = "OR dbuser.login_dbuser IN (";
         $first = true;
         foreach ($new_admin_array_clean as $new_admin_array_item) {
             $sql_newadmins .= (!$first ? ", " : "") . "'" . addslashes($new_admin_array_item) . "'";
             $first = false;
         }
         $sql_newadmins .= ")";
     } else {
         $sql_newadmins = '';
     }
     $sql = "\n            SELECT dbuser.*, kernel_link_bu2user.*, kernel_link_user2node.*\n            FROM dbuser\n            JOIN kernel_link_bu2user ON dbuser.id_dbuser=kernel_link_bu2user.user_id\n            LEFT JOIN kernel_link_user2node ON kernel_link_bu2user.bu_type=kernel_link_user2node.user_type AND kernel_link_bu2user.bu_id=kernel_link_user2node.user_id AND kernel_link_user2node.node_type='ROOT' AND kernel_link_user2node.node_id=0\n            WHERE (node_type='ROOT' AND node_id=0)\n            " . $sql_newadmins . "\n            ORDER BY kernel_link_user2node.droit DESC,dbuser.login_dbuser\n        ";
     $admins = _doQuery($sql);
     foreach ($admins as &$admin) {
         $admin->user_infos = Kernel::getUserInfo($admin->bu_type, $admin->bu_id);
     }
     /*
     dbuser : id_dbuser 	login_dbuser 	password_dbuser 	email_dbuser 	enabled_dbuser
     kernel_link_bu2user : user_id 	bu_type 	bu_id
     kernel_link_user2node : user_type 	user_id 	node_type 	node_id 	droit 	debut 	fin
     */
     $tpl = new CopixTpl();
     $tplListe = new CopixTpl();
     $tplListe->assign("admins", $admins);
     $tplListe->assign("user_id", _currentUser()->getExtra('user_id'));
     $tplListe->assign("admin_fonctionnel", Kernel::isAdminFonctionnel());
     $main = $tplListe->fetch("admins-list.tpl");
     $tpl->assign('TITLE_PAGE', CopixI18N::get('comptes.moduleDescription') . " &raquo; " . CopixI18N::get('comptes.title.admins'));
     $tpl->assign('MAIN', $main);
     $tpl->assign('MENU', $this->menu);
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 /**
  * Récupération de tous les agendas en base de données
  * @author Audrey Vassal <*****@*****.**>
  * @since 2006/07/24
  * @return array tableau d'objet agenda
  */
 public function getAvailableAgenda()
 {
     //var_dump($_SESSION);
     if (!_sessionGet('modules|agenda|his')) {
         $serviceAuth = new AgendaAuth();
         $res = array();
         $ags = array();
         // 1. Son agenda perso
         $userInfo = Kernel::getUserInfo();
         // Création des modules inexistants.
         Kernel::createMissingModules($userInfo["type"], $userInfo["id"]);
         // Liste des modules activés.
         $modsList = Kernel::getModEnabled($userInfo["type"], $userInfo["id"]);
         foreach ($modsList as $modInfo) {
             if ($modInfo->module_type == "MOD_AGENDA" && $modInfo->module_id) {
                 $ags[] = $modInfo->module_id;
             }
         }
         // 2. Ceux de sa classe, son école, ses groupes...
         $mynodes = Kernel::getNodes();
         foreach ($mynodes as $nodes) {
             foreach ($nodes as $node) {
                 //print_r($node);
                 if (substr($node['type'], 0, 5) == 'USER_') {
                     continue;
                 }
                 $modules = Kernel::getModEnabled($node['type'], $node['id']);
                 $agenda = Kernel::filterModuleList($modules, 'MOD_AGENDA');
                 if ($agenda && $serviceAuth->getCapability($agenda[0]->module_id) >= $serviceAuth->getRead()) {
                     $ags[] = $agenda[0]->module_id;
                 }
             }
         }
         //print_r($ags);
         $daoAgenda =& CopixDAOFactory::getInstanceOf('agenda|agenda');
         $agendas = $daoAgenda->findAgendasInIds($ags);
         foreach ($agendas as $agenda) {
             $tmp = new stdClass();
             $tmp->id_agenda = $agenda->id_agenda;
             $tmp->title_agenda = $agenda->title_agenda;
             $tmp->desc_agenda = $agenda->desc_agenda;
             $tmp->type_agenda = $agenda->type_agenda;
             /*
                       $tmp = array (
                           'id_agenda' => $agenda->id_agenda,
                           'title_agenda' => $agenda->title_agenda,
                           'desc_agenda' => $agenda->desc_agenda,
                           'type_agenda' => $agenda->type_agenda,
                       );
             */
             $res[] = $tmp;
         }
         //die();
         //$sess = $daoAgenda->findAll ();
         _sessionSet('modules|agenda|his', serialize($res));
     }
     return unserialize(_sessionGet('modules|agenda|his'));
 }
 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 beforeProcess(&$action)
 {
     if (CopixConfig::get('conf_Saml_actif') != 1) {
         return;
     }
     require_once COPIX_UTILS_PATH . '../../simplesamlphp/lib/_autoload.php';
     $asId = 'iconito-sql';
     if (CopixConfig::exists('default|conf_Saml_authSource') && CopixConfig::get('default|conf_Saml_authSource')) {
         $asId = CopixConfig::get('default|conf_Saml_authSource');
     }
     $as = new SimpleSAML_Auth_Simple($asId);
     $ppo->user = _currentUser();
     if ($as->isAuthenticated() && !$ppo->user->isConnected()) {
         $attributes = $as->getAttributes();
         $uidAttribute = 'login_dbuser';
         if (CopixConfig::exists('default|conf_Saml_uidAttribute') && CopixConfig::get('default|conf_Saml_uidAttribute')) {
             $uidAttribute = CopixConfig::get('default|conf_Saml_uidAttribute');
         }
         $ppo->saml_user = null;
         if (isset($attributes[$uidAttribute]) && isset($attributes[$uidAttribute][0])) {
             $ppo->saml_user = $attributes[$uidAttribute][0];
         }
         if ($ppo->saml_user) {
             $ppo->iconito_user = Kernel::getUserInfo("LOGIN", $ppo->saml_user);
             if ($ppo->iconito_user['login']) {
                 _currentUser()->login(array('login' => $ppo->iconito_user['login'], 'assistance' => true));
                 $url_return = CopixUrl::get('kernel||doSelectHome');
                 // $url_return = CopixUrl::get ('assistance||users');
                 return new CopixActionReturn(COPIX_AR_REDIRECT, $url_return);
             } else {
                 $ppo->cas_error = 'no-iconito-user';
                 return _arPpo($ppo, 'cas.tpl');
             }
         }
     }
     if (!$as->isAuthenticated() && $ppo->user->isConnected()) {
         $ppo->user = _currentUser();
         if ($ppo->user->isConnected()) {
             CopixAuth::getCurrentUser()->logout(array());
             CopixEventNotifier::notify('logout', array('login' => CopixAuth::getCurrentUser()->getLogin()));
             CopixAuth::destroyCurrentUser();
             CopixSession::destroyNamespace('default');
         }
     }
 }
/**
 * Affichage des infos d'une personne selon son ID utilisateur
 * @author   Christophe Beyer <*****@*****.**>
 * @since    2010/12/13
 * @param    integer  $id Id utilisateur (cf table dbuser)
 * @return   string
 */
function smarty_function_user_id($params, &$smarty)
{
    if (!isset($params['id'])) {
        $smarty->trigger_error("mailto: missing 'id' parameter");
        return;
    }
    $res = '';
    if ($userInfo = Kernel::getUserInfo("ID", $params['id'])) {
        $label = trim($userInfo['prenom'] . ' ' . $userInfo['nom']);
        $res = '<a ' . $params['linkAttribs'] . ' class="viewuser" user_type="' . $userInfo['type'] . '" user_id="' . $userInfo['id'] . '">' . $label . '</a>';
    }
    if (isset($params['assign'])) {
        $smarty->assign($params['assign'], $res);
        return '';
    } else {
        return $res;
    }
}
 public function _createContent(&$toReturn)
 {
     $ppo = new CopixPPO();
     _classInclude('classeur|ClasseurService');
     // Récupération des paramètres
     $ppo->classeurId = $this->getParam('classeurId');
     $ppo->dossierId = $this->getParam('dossierId');
     // Gestion des droits
     $ppo->niveauUtilisateur = Kernel::getLevel('MOD_CLASSEUR', $ppo->classeurId);
     $ppo->typeUtilisateur = _currentUser()->getExtra('type');
     $ppo->idUtilisateur = _currentUser()->getExtra('id');
     // Récupération des paramètres d'affichages
     $ppo->tri = ClasseurService::getContentSort();
     // Récupération des dossiers & des fichiers / favoris
     $fichierDAO = _ioDAO('classeur|classeurfichier');
     $dossierDAO = _ioDAO('classeur|classeurdossier');
     if ($ppo->dossier = $dossierDAO->get($ppo->dossierId)) {
         if ($ppo->dossier->parent_id != 0) {
             $ppo->dossierParent = $dossierDAO->get($ppo->dossier->parent_id);
         } else {
             $classeurDAO = _ioDAO('classeur|classeur');
             $ppo->classeurParent = $classeurDAO->get($ppo->classeurId);
             $ppo->classeurParent->isPersonnel = ClasseurService::getClasseurPersonnelId() == $ppo->classeurParent->id;
         }
     }
     if (!$ppo->dossier->casier || $ppo->niveauUtilisateur >= PROFILE_CCV_MODERATE) {
         $imgTypes = array('PNG', 'GIF', 'JPG', 'JPEG', 'png', 'gif', 'jpg', 'jpeg');
         $ppo->contenus = $dossierDAO->getContenus($ppo->classeurId, $ppo->dossierId, $ppo->tri);
         foreach ($ppo->contenus as $contenu) {
             if ($contenu->content_type == 'fichier' && in_array($contenu->type, $imgTypes)) {
                 $fichier = $fichierDAO->get($contenu->id);
                 $contenu->lienMiniature = $fichier->getLienMiniature(90);
             }
             if ($ppo->dossier->casier) {
                 $user = Kernel::getUserInfo($contenu->user_type, $contenu->user_id);
                 $contenu->user = $user['prenom'] . ' ' . $user['nom'];
             }
         }
         $ppo->fileExtensionAllowed = array('ai', 'avi', 'bmp', 'css', 'csv', 'doc', 'docx', 'eps', 'gif', 'html', 'ico', 'jpg', 'jpeg', 'js', 'json', 'mov', 'mp3', 'odp', 'ods', 'odt', 'pdf', 'png', 'ppt', 'pptx', 'psd', 'svg', 'swf', 'tiff', 'ttf', 'txt', 'wav', 'xls', 'xlsx', 'xml', 'zip');
     }
     $toReturn = $this->_usePPO($ppo, '_vue_vignette.tpl');
 }
 /**
  * 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 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;
 }
 public function getPrefs($data = null)
 {
     $toReturn = array();
     $toReturn['name'] = CopixI18N::get('prefs.string.generalprefs');
     $toReturn['form'][] = array('type' => 'titre', 'text' => CopixI18N::get('prefs.config.passwd.title'), 'expl' => CopixI18N::get('prefs.config.passwd.expl'));
     $toReturn['form'][] = array('code' => 'passwd1', 'type' => 'password', 'text' => CopixI18N::get('prefs.config.passwd1.input'), 'value' => '');
     $toReturn['form'][] = array('code' => 'passwd2', 'type' => 'password', 'text' => CopixI18N::get('prefs.config.passwd2.input'), 'value' => '');
     if (!CopixConfig::exists('|can_pref_assistance_animtice') || CopixConfig::get('|can_pref_assistance_animtice')) {
         $toReturn['form'][] = array('type' => 'titre', 'text' => CopixI18N::get('prefs.config.assistance.title'), 'expl' => CopixI18N::get('prefs.config.assistance.expl'));
         $toReturn['form'][] = array('code' => 'assistance', 'type' => 'checkbox', 'text' => CopixI18N::get('prefs.config.assistance'), 'value' => isset($data['assistance']) && $data['assistance'] ? true : false);
     }
     if (!CopixConfig::exists('|can_pref_assistance_ien') || CopixConfig::get('|can_pref_assistance_ien')) {
         $user_infos = Kernel::getUserInfo();
         if ($user_infos['type'] == 'USER_ENS') {
             $toReturn['form'][] = array('type' => 'titre', 'text' => CopixI18N::get('prefs.config.ien.title'), 'expl' => CopixI18N::get('prefs.config.ien.expl'));
             $toReturn['form'][] = array('code' => 'assistance_ien', 'type' => 'checkbox', 'text' => CopixI18N::get('prefs.config.ien'), 'value' => isset($data['assistance_ien']) && $data['assistance_ien'] ? true : false);
         }
     }
     $toReturn['form'][] = array('type' => 'titre', 'text' => CopixI18N::get('prefs.config.avatar.title'), 'expl' => CopixI18N::get('prefs.config.avatar.expl'));
     $avatar = Prefs::get('prefs', 'avatar');
     if ($avatar) {
         $avatar_url = 'static/prefs/avatar/' . $avatar;
         $toReturn['form'][] = array('type' => 'image', 'text' => CopixI18N::get('prefs.config.avatar.image'), 'value' => $avatar_url);
     }
     $toReturn['form'][] = array('code' => 'avatar_upload', 'type' => 'upload', 'text' => CopixI18N::get('prefs.config.avatar.upload'), 'value' => isset($data['nom']) ? $data['nom'] : _currentUser()->getExtra('nom'));
     if ($avatar) {
         $toReturn['form'][] = array('code' => 'avatar_delete', 'type' => 'checkbox', 'text' => CopixI18N::get('prefs.config.avatar.delete'), 'value' => false);
     }
     /////////////////////////// ALERTE MAIL ///////////////////////////
     $toReturn['form'][] = array('type' => 'titre', 'text' => CopixI18N::get('prefs.config.mail.title'), 'expl' => CopixI18N::get('prefs.config.mail.expl'));
     /*
     $toReturn['form'][] = array(
             'code'=>'alerte_mail_active',
             'type'=>'checkbox',
             'text'=>CopixI18N::get ('prefs.config.mail.alerte_mail_active'), // 'Souhaitez-vous être alerté par un email à chaque fois que vous recevez un minimail ?',
             'value'=>($data['alerte_mail_active']?true:false) );
     */
     $toReturn['form'][] = array('code' => 'alerte_mail_email', 'type' => 'string', 'text' => CopixI18N::get('prefs.config.mail.alerte_mail_email'), 'value' => isset($data['alerte_mail_email']) ? $data['alerte_mail_email'] : '');
     return $toReturn;
 }
Exemplo n.º 16
0
/**
 * Smarty {user} function plugin
 *
 * Type:     function<br>
 * Name:     user<br>
 * Date:     06/04/2006
 * Purpose:  Affiche une personne en rendant éventuellement son nom cliquable pour détailler son profil, et éventuellement l'enveloppe pour lui écrire un minimail.<br>
 * Input:<br>
 *         - label = nom à afficher (nom, nom+prénom, login...)
 *         - userType = (optional) type d'utilisateur. Nécessaire pour rendre le label cliquable et afficher son profil
 *         - userId = (optional) id d'utilisateur. Nécessaire pour rendre le label cliquable et afficher son profil
 *         - dispMail = (optional) 1 pour afficher l'enveloppe permettant d'écrire un minimail
 *         - login = (optional) login de l'utilisateur. Nécessaire pour afficher l'enveloppe
 *         - linkAttribs = (optional) attributs HTML de la balise A HREF entourant le label
 *				 - assign   = (optional) name of the template variable we'll assign
 *                      the output to instead of displaying it directly
 *				 - fromLogin = a partir du login, se charge d'afficher les infos du compte
 * Examples:
 * <pre>
 * {user label="Marc Dupond"}
 * {user label="Marc Dupond" userType="USER_ENS" userId=1}
 * {user label="Marc Dupond" userType="USER_ENS" userId=1 login="******" dispMail=1}
 * {user label="Marc Dupond" userType="USER_ENS" userId=1 login="******" dispMail=1 linkAttribs='CLASS="link"'}
 * {user fromLogin="******"}
 * </pre>
 * @version  1.0
 * @author   Christophe Beyer <*****@*****.**>
 * @author   CAP-TIC
 * @param    array
 * @param    Smarty
 * @return   string
 */
function smarty_function_user($params, &$smarty)
{
    if (isset($params['fromLogin'])) {
    } elseif (empty($params['label'])) {
        //$smarty->trigger_error("mailto: missing 'label' parameter");
        return;
    } else {
        $label = trim($params['label']);
    }
    if (trim($params['fromLogin'])) {
        $params['fromLogin'] = trim($params['fromLogin']);
        $userInfo = Kernel::getUserInfo("LOGIN", $params['fromLogin']);
        if (count($userInfo) > 0) {
            //var_dump($userInfo);
            $label = trim($userInfo['prenom'] . ' ' . $userInfo['nom']);
            $params['userType'] = $userInfo['type'];
            $params['userId'] = $userInfo['id'];
            $params['login'] = $params['fromLogin'];
        } else {
            $label = $params['fromLogin'];
        }
    }
    if ($params['userType'] && $params['userId']) {
        // $res = '<A '.$params['linkAttribs'].' HREF="javascript:viewUser(\''.$params['userType'].'\', \''.$params['userId'].'\', \''.addslashes(htmlentities(CopixI18N::get ('annuaire|annuaire.profil.loading'))).'\');">'.$label.'</A>';
        $res = '<a ' . $params['linkAttribs'] . ' class="viewuser" user_type="' . $params['userType'] . '" user_id="' . $params['userId'] . '">' . $label . '</a>';
    } else {
        $res = $label;
    }
    if ($params['dispMail'] == 1 && $params['login']) {
        $url = CopixUrl::get('minimail||getNewForm', array('login' => $params['login']));
        $res .= '&nbsp;<A HREF="' . $url . '"><IMG WIDTH="12" HEIGHT="9" SRC="' . CopixUrl::getResource("img/minimail/new_minimail.gif") . '" ALT="' . htmlentities(CopixI18N::get('annuaire|annuaire.writeMinimail')) . '" TITLE="' . htmlentities(CopixI18N::get('annuaire|annuaire.writeMinimail')) . '" BORDER="0" /></A>';
    }
    if (isset($params['assign'])) {
        $smarty->assign($params['assign'], $res);
        return '';
    } else {
        return $res;
    }
}
 public function processDefault()
 {
     $ppo = new CopixPPO();
     $ppo->visio = new CopixPPO();
     $ppo->error = "";
     $user_from = Kernel::getUserInfo("ME", 0);
     $ppo->login_to = $this->request('login', 'str');
     $ppo->login_from = $user_from['login'];
     $ppo->visio->red5 = CopixConfig::exists('default|conf_ModVisio_url') ? CopixConfig::get('default|conf_ModVisio_url') : '';
     $ppo->visio->secondsToWait = CopixConfig::exists('visio|conf_secondsToWait') ? CopixConfig::get('visio|conf_secondsToWait') : 30;
     $ppo->visio->secondsToRetry = CopixConfig::exists('visio|conf_secondsToRetry') ? CopixConfig::get('visio|conf_secondsToRetry') : 60;
     $ppo->visio->textColor = CopixConfig::exists('visio|conf_textColor') ? CopixConfig::get('visio|conf_textColor') : "#FF0000";
     $ppo->visio->textOverColor = CopixConfig::exists('visio|conf_textOverColor') ? CopixConfig::get('visio|conf_textOverColor') : "#00FF00";
     $ppo->visio->infoTextColor = CopixConfig::exists('visio|conf_infoTextColor') ? CopixConfig::get('visio|conf_infoTextColor') : "#0000FF";
     $ppo->visio->bandwidth = CopixConfig::exists('visio|conf_bandwidth') ? CopixConfig::get('visio|conf_bandwidth') : 0;
     $ppo->visio->videoQuality = CopixConfig::exists('visio|conf_videoQuality') ? CopixConfig::get('visio|conf_videoQuality') : 95;
     $ppo->visio->motionLevel = CopixConfig::exists('visio|conf_motionLevel') ? CopixConfig::get('visio|conf_motionLevel') : 60;
     $ppo->visio->motionTimeout = CopixConfig::exists('visio|conf_motionTimeout') ? CopixConfig::get('visio|conf_motionTimeout') : 1500;
     $ppo->visio->keyFrameInterval = CopixConfig::exists('visio|conf_keyFrameInterval') ? CopixConfig::get('visio|conf_keyFrameInterval') : 15;
     $ppo->visio->useEchoSuppression = CopixConfig::exists('visio|conf_useEchoSuppression') ? CopixConfig::get('visio|conf_useEchoSuppression') : 'on';
     $ppo->visio->bufferTime = CopixConfig::exists('visio|conf_bufferTime') ? CopixConfig::get('visio|conf_bufferTime') : 0;
     $ppo->visio->useSpeex = CopixConfig::exists('visio|conf_useSpeex') ? CopixConfig::get('visio|conf_useSpeex') : 'off';
     $ppo->visio->microSilenceLevel = CopixConfig::exists('visio|conf_microSilenceLevel') ? CopixConfig::get('visio|conf_microSilenceLevel') : 20;
     $ppo->visio->microSilenceTimeout = CopixConfig::exists('visio|conf_microSilenceTimeout') ? CopixConfig::get('visio|conf_microSilenceTimeout') : -1;
     $ppo->visio->microSetLoopBack = CopixConfig::exists('visio|conf_microSetLoopBack') ? CopixConfig::get('visio|conf_microSetLoopBack') : 'false';
     $ppo->visio->microGain = CopixConfig::exists('visio|conf_microGain') ? CopixConfig::get('visio|conf_microGain') : 50;
     $ppo->visio->speexEncodeQuality = CopixConfig::exists('visio|conf_speexEncodeQuality') ? CopixConfig::get('visio|conf_speexEncodeQuality') : 6;
     if ($ppo->login_to) {
         $user_to = Kernel::getUserInfo("LOGIN", $ppo->login_to);
         if ($user_to) {
             return _arPPO($ppo, 'visio.tpl');
         } else {
             $ppo->error = "Login inconnu";
         }
     }
     return _arPPO($ppo, 'default.tpl');
 }
 public function getVisioScopia()
 {
     $dao = CopixDAOFactory::create("visioscopia|visioscopia_config");
     $id = $this->getRequest('id', null);
     $user_infos = Kernel::getUserInfo();
     $conf_result = $dao->get($id);
     $title = "Visioconf&eacute;rence";
     $tpl = new CopixTpl();
     $tpl->assign('TITLE_PAGE', $title);
     $tplVisio = new CopixTpl();
     $save = $this->getRequest('save', 0);
     if ($save == 1) {
         $conf_id = $this->getRequest('conf_id', 0);
         $conf_msg = $this->getRequest('conf_msg', '');
         $conf_active = $this->getRequest('conf_active', 0);
         if (1) {
             // test de validité ?
             if (!$conf_result) {
                 $conf_result = _record("visioscopia|visioscopia_config");
             }
             $conf_result->id = (int) $id;
             $conf_result->conf_id = $conf_id;
             $conf_result->conf_msg = $conf_msg;
             $conf_result->conf_active = $conf_active;
             //_dump($conf_result);
             $dao->delete($id);
             $dao->insert($conf_result);
             $tplVisio->assign('saved', 1);
         }
     }
     if ($conf_result) {
         if (CopixConfig::exists('visioscopia|conf_ModVisioScopia_url')) {
             $tplVisio->assign('config_ok', 1);
             $url = CopixConfig::get('visioscopia|conf_ModVisioScopia_url');
         } else {
             $tplVisio->assign('config_ok', 0);
         }
         // $url = CopixConfig::get('visioscopia|url');
         $patterns[0] = '/%ROOM%/';
         $patterns[1] = '/%NAME%/';
         $replacements[0] = $conf_result->conf_id;
         $replacements[1] = urlencode(trim($user_infos['prenom'] . " " . $user_infos['nom']));
         $url = preg_replace($patterns, $replacements, $url);
         $tplVisio->assign('url', $url);
     } else {
         $tplVisio->assign('config_ok', 0);
     }
     $tplVisio->assign('visio_id', $id);
     // _dump($conf_result);
     $tplVisio->assign('config', $conf_result);
     $result = $tplVisio->fetch('visioscopia-user.tpl');
     // echo Kernel::getLevel( "MOD_VISIOSCOPIA", $id );
     if (Kernel::getLevel("MOD_VISIOSCOPIA", $id) >= PROFILE_CCV_ADMIN) {
         $result .= $tplVisio->fetch('visioscopia-admin.tpl');
     } else {
     }
     $menu = array();
     $tpl->assign('MENU', $menu);
     $tpl->assign('MAIN', $result);
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 public function processQuiz()
 {
     $pId = CopixRequest::getInt('id', false);
     //init & secure quiz system !
     if (is_null(CopixSession::get('id')) || $pId != qSession('id')) {
         if ($pId === false || !($quizData = _dao('quiz|quiz_quiz')->get($pId))) {
             return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('quiz.errors.noQuiz'), 'back' => CopixUrl::get('quiz||')));
         }
         //to propagate the quizData
         $quizData =& $quizData;
         //security for quiz
         $gr_id = qSession('id_gr_quiz');
         if ($gr_id != $quizData->gr_id) {
             return $this->error('quiz.errors.noQuiz');
         }
         //session storage :
         qSession('id', $pId);
         qSession('name', $quizData->name);
         qSession('opt', array('save' => $quizData->opt_save, 'show_result' => $quizData->opt_show_results));
         //description
         $desc = $quizData->description == null ? null : $quizData->description;
         if ($quizData->lock == 1) {
             return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('quiz.errors.lock'), 'back' => CopixUrl::get('quiz||')));
         }
         //time test :
         if (time() < $quizData->date_start && $quizData->date_start != 0) {
             return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('quiz.errors.beforeStart'), 'back' => CopixUrl::get('quiz||')));
         }
         if (time() > $quizData->date_end && CopixRequest::get('action') != 'end_quiz' && $quizData->date_end != 0) {
             return CopixActionGroup::process('quiz|default::EndQuiz', array('id' => $pId));
         }
     } else {
         $quizData = _dao('quiz|quiz_quiz')->get($pId);
     }
     //echo CopixRequest::get('action');
     //ICI REROUTAGE EN FONCTION BESOIN !!
     //get informations from DB
     $userId = _currentUser()->getId();
     $authorInfos = Kernel::getUserInfo('ID', $quizData->id_owner);
     $questionsData = _ioDAO('quiz|quiz_questions')->getQuestionsForQuiz($pId);
     $responsesFromUser = _ioDAO('quiz|quiz_responses')->getResponsesFromUser($userId, $pId);
     //si pas de questions : erreur :
     if (empty($questionsData)) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('quiz.errors.noQuestions'), 'back' => CopixUrl::get('quiz||')));
     }
     //if user have already begin the quiz :
     $uResp = false;
     $userResponses = array();
     if (count($responsesFromUser) != 0) {
         $uResp = true;
         foreach ($responsesFromUser as $resp) {
             $userResponses[] = $resp->id_question;
             $userChoices[$resp->id_question] = $resp->id_choice;
         }
         array_unique($userResponses);
     }
     //fetch all question
     $i = 0;
     $userAllQuestions = true;
     foreach ($questionsData as $question) {
         $currentQuestionId = $question->id * 1;
         //pile for question
         $qQueue[] = $currentQuestionId;
         $questionsReturn[$i]['ct'] = $question;
         $questionsReturn[$i]['userResp'] = isset($userChoices[$currentQuestionId]);
         $i++;
     }
     if (!isset($qQueue)) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('quiz.errors.noQuestions'), 'back' => CopixUrl::get('quiz||')));
     }
     //data storage
     $this->session->save('questions', $qQueue);
     $this->session->save('quizId', $pId);
     $this->session->save('authorName', $authorInfos['nom']);
     $this->session->save('authorSurname', $authorInfos['prenom']);
     //load help
     $help = empty($quizData->help) ? $this->i18n('quiz.msg.noHelp') : $quizData->help;
     qSession('help', $help);
     //if qID exists in url : routing to question
     $qId = CopixRequest::get('qId', false);
     if ($qId) {
         return CopixActionGroup::process('quiz|default::Question', array('id' => $pId, 'qId' => (int) $qId));
     } elseif (!$uResp) {
         //if users have not started the quiz :
         return CopixActionGroup::process('quiz|default::Question', array('id' => $pId, 'qId' => $qQueue[0]));
     }
     //var_dump($questionsReturn);
     //start TPL
     $this->addCss('styles/module_quiz.css');
     //        $this->js->button('.button');
     $ppo = new CopixPPO();
     //global data for quiz
     $ppo->name = $quizData->name;
     $ppo->quizId = $pId;
     $ppo->description = stripslashes($desc);
     $ppo->nameAuthor = $authorInfos['nom'];
     $ppo->surname = $authorInfos['prenom'];
     $ppo->img = $quizData->pic;
     //user data for quiz
     $ppo->uResp = $uResp;
     $ppo->uEnd = $userAllQuestions;
     //questions datas
     $ppo->questions = $questionsReturn;
     $ppo->next = $qQueue[0];
     $ppo->TITLE_PAGE = 'Quiz';
     if (Kernel::getLevel('MOD_QUIZ', $pId) >= PROFILE_CCV_ADMIN) {
         $ppo->MENU[] = array('txt' => $this->i18n('quiz.admin.listActive'), 'type' => 'list-active', 'url' => $this->url('quiz|default|default', array('qaction' => 'list')));
         $ppo->MENU[] = array('txt' => $this->i18n('quiz.admin.listAll'), 'type' => 'list', 'url' => $this->url('quiz|admin|list'));
         $ppo->MENU[] = array('txt' => $this->i18n('quiz.admin.new'), 'type' => 'create', 'url' => $this->url('quiz|admin|modif', array('qaction' => 'new')));
     }
     return _arPPO($ppo, 'accueil_quiz.tpl');
 }
 /**
  * Changement des responsables d'une procedure
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2009/01/21
  * @param integer $id Id de la procedure
  * @param string $responsables Nouveaux responsables
  */
 public function changeResponsables()
 {
     $id = $this->getRequest('id', null);
     $daoIntervention = CopixDAOFactory::create("intervention");
     $criticErrors = $errors = array();
     if ($id && ($rFiche = $daoIntervention->get($id))) {
         $title = $rFiche->objet;
         $mondroit = Kernel::getLevel("MOD_TELEPROCEDURES", $rFiche->type_teleprocedure);
         if (!TeleproceduresService::canMakeInTelep('DELEGUE', $mondroit, array('idinter' => $rFiche->idinter))) {
             $criticErrors[] = CopixI18N::get('kernel|kernel.error.noRights');
         }
     } else {
         $criticErrors[] = CopixI18N::get('teleprocedures|teleprocedures.error.prob.telep');
     }
     if ($criticErrors) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => implode('<br/>', $criticErrors), 'back' => CopixUrl::get('teleprocedures||')));
     }
     $reqResponsables = $this->getRequest('responsables');
     // Responsables
     $responsables = $reqResponsables;
     $responsables = str_replace(array(" "), "", $responsables);
     $responsables = str_replace(array(",", ";"), ",", $responsables);
     $responsables = preg_split("/[\\s,]+/", $responsables);
     $tabResponsables = array();
     $deja = array();
     // On vérifie que les membres existent
     while (list(, $login) = each($responsables)) {
         if (!$login) {
             continue;
         }
         $userInfo = Kernel::getUserInfo("LOGIN", $login);
         if (!$userInfo) {
             $errors[] = CopixI18N::get('teleprocedures|teleprocedures.error.memberNoUser', array($login));
         } elseif ($userInfo['type'] != 'USER_VIL') {
             $errors[] = CopixI18N::get('teleprocedures|teleprocedures.error.memberNoVille', array($login));
         } else {
             $tabResponsables[] = $userInfo;
             $deja[] = $login;
         }
     }
     // Lecteurs
     $lecteurs = $this->getRequest('lecteurs');
     $lecteurs = str_replace(array(" "), "", $lecteurs);
     $lecteurs = str_replace(array(",", ";"), ",", $lecteurs);
     $lecteurs = preg_split("/[\\s,]+/", $lecteurs);
     $tabLecteurs = array();
     // On vérifie que les membres existent
     while (list(, $login) = each($lecteurs)) {
         if (!$login) {
             continue;
         }
         $userInfo = Kernel::getUserInfo("LOGIN", $login);
         if (!$userInfo) {
             $errors[] = CopixI18N::get('teleprocedures|teleprocedures.error.memberNoUser', array($login));
         } elseif ($userInfo['type'] != 'USER_VIL') {
             $errors[] = CopixI18N::get('teleprocedures|teleprocedures.error.memberNoVille', array($login));
         } elseif (in_array($login, $deja)) {
             $errors[] = CopixI18N::get('teleprocedures|teleprocedures.error.memberDeja', array($login));
         } else {
             $tabLecteurs[] = $userInfo;
         }
     }
     if (!count($tabResponsables)) {
         $errors[] = CopixI18N::get('teleprocedures|teleprocedures.error.noResp');
     }
     if (!$errors) {
         if ($rFiche->responsables != $reqResponsables) {
             TeleproceduresService::alertChangeResponsables($rFiche, $reqResponsables);
             $rFiche->responsables = $reqResponsables;
             //var_dump($rFiche);
             $daoIntervention->update($rFiche);
             TeleproceduresService::saveDroits('intervention', $rFiche->idinter, 'responsables', $tabResponsables);
         }
         return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('|fiche', array('id' => $id)));
     }
     return CopixActionGroup::process('teleprocedures|default::ficheDroits', array('id' => $id, 'errors' => $errors, 'rFiche' => array('responsables' => $this->getRequest('responsables'), 'lecteurs' => $this->getRequest('lecteurs'))));
 }
 public function getNew()
 {
     if (!Kernel::isAdmin()) {
         return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('||'));
     }
     CopixHTMLHeader::addCSSLink(_resource("styles/module_comptes.css"));
     $tpl = new CopixTpl();
     $tplAnimateurs = new CopixTpl();
     $animateurs_dao = _dao("kernel|kernel_animateurs");
     $animateurs = $animateurs_dao->findAll();
     $ppo->animateurs = array();
     foreach ($animateurs as $animateur) {
         $ppo->animateurs[$animateur->user_type . "-" . $animateur->user_id] = $animateur;
     }
     //// Personnes externes ///////////////////////////////////////
     $userext_dao = _dao("kernel|kernel_ext_user");
     $list = $userext_dao->listUsers();
     $user_key = 0;
     foreach ($list as $user_val) {
         $ppo->userext[$user_key] = $user_val;
         $user_key++;
     }
     foreach ($ppo->userext as $user_key => $user_val) {
         if (isset($ppo->animateurs["USER_EXT-" . $user_val->ext_id])) {
             // Si la personne est déjà animateur
             unset($ppo->userext[$user_key]);
         } else {
             $ppo->userext[$user_key]->user_infos = Kernel::getUserInfo('USER_EXT', $user_val->ext_id);
             if (!isset($ppo->userext[$user_key]->user_infos['login'])) {
                 // Si la personne n'a pas de login de type enseignant
                 unset($ppo->userext[$user_key]);
             }
         }
     }
     $sql = "\n            SELECT PER.nom AS nom, PER.prenom1 AS prenom,\n                   B2U.bu_type AS bu_type, B2U.bu_id AS bu_id,\n                   USR.login_dbuser\n            FROM kernel_bu_personnel PER\n            JOIN kernel_bu_personnel_entite ENT ON PER.numero=ENT.id_per\n            JOIN kernel_link_bu2user B2U ON PER.numero=B2U.bu_id AND B2U.bu_type IN ('USER_VIL','USER_ENS','USER_ADM')\n            JOIN dbuser USR ON B2U.user_id=USR.id_dbuser\n            -- WHERE PER.deleted=0\n            GROUP BY bu_type,bu_id\n        ";
     $pers = _doQuery($sql);
     $ppo->pers = array();
     foreach ($pers as $pers_item) {
         $ppo->pers[$pers_item->bu_type][$pers_item->bu_id] = $pers_item;
     }
     /*
     echo "<pre>";
     // print_r($ppo->animateurs);
     print_r($ppo->userext);
     // print_r($ppo->userens);
     die();
     */
     $tplAnimateurs->assign('ppo', $ppo);
     $result = $tplAnimateurs->fetch("animateurs-new.tpl");
     $tpl->assign('TITLE_PAGE', CopixI18N::get('comptes.moduleDescription') . " &raquo; " . CopixI18N::get('comptes.title.animateur_list'));
     $tpl->assign('MAIN', $result);
     $tpl->assign('MENU', $this->menu);
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 /**
  * L'annuaire (TODO temporaire)
  */
 public function view()
 {
     $annuaireService =& CopixClassesFactory::Create('annuaire|AnnuaireService');
     $classe = _request("classe");
     $id = 1;
     $type = "BU_ECOLE";
     $ecole = Kernel::getNodeInfo($type, $id, false);
     //print_r($ecole);
     $classes = $enseignants = $directeur = array();
     $result = Kernel::getNodeChilds($type, $id);
     foreach ($result as $key => $value) {
         //print_r($value);
         if ($value["type"] == "BU_CLASSE") {
             $nodeInfo = Kernel::getNodeInfo($value["type"], $value["id"], false);
             $result[$key]["info"] = $nodeInfo;
             // Enseignants
             $childs = Kernel::getNodeChilds($value["type"], $value["id"]);
             //print_r($childs);
             $enseignants = array();
             foreach ($childs as $child) {
                 if ($child["type"] == "USER_ENS") {
                     $userInfo = Kernel::getUserInfo($child["type"], $child["id"]);
                     // print_r($userInfo);
                     $enseignants[] = $userInfo;
                 }
             }
             $result[$key]["enseignants"] = $enseignants;
             $classes[] = $result[$key];
         } elseif ($value["type"] == "USER_ENS") {
             $droit = Kernel::getLevel($type, $id, $value["type"], $value["id"]);
             if ($droit >= PROFILE_CCV_ADMIN) {
                 $nodeInfo = Kernel::getUserInfo($value["type"], $value["id"]);
                 //print_r($nodeInfo);
                 $result[$key]["info"] = $nodeInfo;
                 //$enseignants[] = $result[$key];
                 $directeur = $result[$key];
             }
         }
     }
     //print_r($directeur);
     $ecole["directeur"] = $directeur;
     //print_r($ecole);
     $id = $classe;
     $type = "BU_CLASSE";
     $classe = Kernel::getNodeInfo($type, $id, false);
     $eleves = $enseignants = array();
     $result = Kernel::getNodeChilds($type, $id);
     foreach ($result as $key => $value) {
         if ($value["type"] == "USER_ELE") {
             $nodeInfo = Kernel::getUserInfo($value["type"], $value["id"]);
             $result[$key]["info"] = $nodeInfo;
             //print_r($result[$key]);
             $eleves[] = $result[$key];
         } elseif ($value["type"] == "USER_ENS") {
             $userInfo = Kernel::getUserInfo($value["type"], $value["id"]);
             //print_r($userInfo);
             $enseignants[] = $userInfo;
         }
     }
     //print_r($eleves);
     $classe["eleves"] = $annuaireService->order_tab_eleves($eleves);
     $classe["enseignants"] = $annuaireService->order_tab_enseignants($enseignants);
     //$classe["enseignants"]=($enseignants);
     //print_r($classe);
     $tplListe = new CopixTpl();
     $tplListe->assign('ecole', $ecole);
     $tplListe->assign('classes', $classes);
     $tplListe->assign('classe', $classe);
     $tplListe->assign('annu', "<pre>" . $return_str . "</pre>");
     $result = $tplListe->fetch("view.tpl");
     $tpl = new CopixTpl();
     $tpl->assign('TITLE_PAGE', $ecole["nom"] . " (" . $ecole["desc"] . ")");
     $tpl->assign("MAIN", $result);
     $tpl->assign('MENU', $this->menu);
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 /**
  * Retourne les enfants d'un parent
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2006/12/19
  * @param integer $parent Id du parent
  * @return array Tableau avec les enfants
  */
 public function getEnfantsFromParent($parent)
 {
     $res = array();
     $enfants = Kernel::getNodeParents('USER_RES', $parent);
     //print_r($enfants);
     foreach ($enfants as $enfant) {
         if ($enfant['type'] != 'USER_ELE') {
             continue;
         }
         //print_r($parent);
         $userInfo = Kernel::getUserInfo($enfant['type'], $enfant['id']);
         //print_r($userInfo);
         $tmp = array_merge($enfant, $userInfo);
         $res[] = $tmp;
     }
     //print_r($res);
     return $res;
 }
 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 ) ) {
     */
 }
 /**
  * Soumission du formulaire d'�criture d'un minimail (envoie le minimail)
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2005/10/18
  * @see getNewForm()
  * @param string $dest Logins du(des) destinataire(s)
  * @param string $title Titre du minimail
  * @param string $message Corps du minimail
  * @param string $go Forme de soumission : preview (pr�visualiser) ou send (enregistrer)
  */
 public function doSend()
 {
     $dest = _request("dest") ? _request("dest") : "";
     $title = _request("title") ? _request("title") : "";
     $message = _request("message") ? _request("message") : "";
     $format = _request("format") ? _request("format") : "";
     $go = _request("go") ? _request("go") : 'preview';
     $iReply = CopixRequest::getInt('reply');
     $iForward = CopixRequest::getInt('forward');
     $destTxt = $dest;
     $destTxt = str_replace(array(" "), "", $destTxt);
     $destTxt = str_replace(array(",", ";"), ",", $destTxt);
     $destin = array_unique(explode(",", $destTxt));
     $fromId = _currentUser()->getId();
     $errors = array();
     if (!$dest) {
         $errors[] = CopixI18N::get('minimail.error.typeDest');
     }
     if (!$title) {
         $errors[] = CopixI18N::get('minimail.error.typeTitle');
     }
     if (!$message) {
         $errors[] = CopixI18N::get('minimail.error.typeMessage');
     }
     if (!$format) {
         $errors[] = CopixI18N::get('minimail.error.typeFormat');
     }
     $tabDest = array();
     // On v�rifie que les destinataires existent
     while (list(, $login) = each($destin)) {
         if (!$login) {
             continue;
         }
         $userInfo = Kernel::getUserInfo("LOGIN", $login, array('strict' => true));
         //print_r("login=$login");
         //print_r($userInfo);
         if (!$userInfo) {
             $errors[] = CopixI18N::get('minimail.error.badDest', array($login));
         } elseif ($userInfo["user_id"] == $fromId) {
             $errors[] = CopixI18N::get('minimail.error.writeHimself');
         } else {
             $droits = Kernel::getUserInfoMatrix($userInfo);
             if ($droits['communiquer']) {
                 $tabDest[$userInfo["user_id"]] = $userInfo["user_id"];
             } else {
                 $errors[] = CopixI18N::get('minimail.error.cannotWrite', array($login));
             }
         }
     }
     // On v�rifie les pi�ces jointes
     CopixConfig::get('minimail|attachment_size');
     //print_r($_FILES);
     for ($i = 1; $i <= 3; $i++) {
         if (isset($_FILES['attachment' . $i]) && !is_uploaded_file($_FILES['attachment' . $i]['tmp_name'])) {
             switch ($_FILES['attachment' . $i]['error']) {
                 case 0:
                     //no error; possible file attack!
                     $errors[] = CopixI18N::get('minimail|minimail.error.upload_default', $i);
                     break;
                 case 1:
                     //uploaded file exceeds the upload_max_filesize directive in php.ini
                     $errors[] = CopixI18N::get('minimail|minimail.error.upload_toobig', $i);
                     break;
                 case 2:
                     //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
                     $errors[] = CopixI18N::get('minimail|minimail.error.upload_toobig', $i);
                     break;
                 case 3:
                     //uploaded file was only partially uploaded
                     $errors[] = CopixI18N::get('minimail|minimail.error.upload_partial', $i);
                     break;
                 case 4:
                     //no file was uploaded
                     break;
                 default:
                     $errors[] = CopixI18N::get('minimail|minimail.error.upload_default', $i);
                     break;
             }
         }
     }
     if (!$errors) {
         if (!$errors && $go == 'save') {
             $serv = CopixClassesFactory::create("MinimailService");
             $send = $serv->sendMinimail($title, $message, $fromId, $tabDest, $format);
             if (!$send) {
                 $errors[] = CopixI18N::get('minimail.error.send');
             }
         }
         if (!$errors && $go == 'save') {
             // Reponse ou forward ?
             if ($iReply) {
                 // On verifie qu'on est destinataire
                 if ($inDest = _ioDAO('minimail_to')->selectDestFromIdAndToUser($iReply, $fromId)) {
                     _doQuery("UPDATE module_minimail_to SET is_replied=1 WHERE id=:id", array(':id' => $inDest->id2));
                 }
             } elseif ($iForward) {
                 $message = _ioDAO('minimail_from')->get($iForward);
                 // Si on etait l'expediteur
                 if ($message && $message->from_id == $fromId) {
                     _doQuery("UPDATE module_minimail_from SET is_forwarded=1 WHERE id=:id", array(':id' => $iForward));
                     // Si on etait destinataire
                 } elseif ($message && ($inDest = _ioDAO('minimail_to')->selectDestFromIdAndToUser($iForward, $fromId))) {
                     _doQuery("UPDATE module_minimail_to SET is_forwarded=1 WHERE id=:id", array(':id' => $inDest->id2));
                 }
             }
             // Ajout des pieces jointes
             $attachments = array();
             $dataPath = realpath("../var/data");
             for ($i = 1; $i <= 3; $i++) {
                 if (isset($_FILES["attachment" . $i]) && isset($_FILES["attachment" . $i]["name"]) && $_FILES["attachment" . $i]["name"]) {
                     $name = $send . "_" . $_FILES["attachment" . $i]["name"];
                     $uploadFrom = $_FILES["attachment" . $i]["tmp_name"];
                     $uploadTo = $dataPath . "/minimail/" . $name;
                     if (move_uploaded_file($uploadFrom, $uploadTo)) {
                         $attachments[] = $name;
                     } else {
                         $errors[] = CopixI18N::get('minimail.error.send', array($i));
                     }
                 }
             }
             if (count($attachments) > 0) {
                 $DAOminimail_from = CopixDAOFactory::create("minimail_from");
                 $mp = $DAOminimail_from->get($send);
                 $mp->attachment1 = isset($attachments[0]) ? $attachments[0] : NULL;
                 $mp->attachment2 = isset($attachments[1]) ? $attachments[1] : NULL;
                 $mp->attachment3 = isset($attachments[2]) ? $attachments[2] : NULL;
                 $DAOminimail_from->update($mp);
             }
             //    update_message_pj ($res, $pj[0], $pj[1], $pj[2]);
             if (!$errors) {
                 $urlReturn = CopixUrl::get('|getListSend');
                 return new CopixActionReturn(COPIX_AR_REDIRECT, $urlReturn);
             }
         }
     }
     //_dump($message);
     return CopixActionGroup::process('minimail|minimail::getNewForm', array('dest' => $dest, 'title' => $title, 'message' => $message, 'format' => $format, 'errors' => $errors, 'preview' => $go == 'save' ? 0 : 1, 'reply' => $iReply, 'forward' => $iForward));
     //$url_return = CopixConfig::get('minimail|afterMsgSend');
     //$url_return = CopixUrl::get('minimail||getListSend');
 }
 /**
  * Suppression d'un message. Renvoie sur la page demandant confirmation avant de supprimer.
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2005/11/10
  * @param integer $id Id du message a supprimer
  */
 public function getDeleteMessage()
 {
     $errors = $criticErrors = array();
     $id = _request("id") ? _request("id") : NULL;
     $dao_messages = CopixDAOFactory::create("forum_messages_forums");
     $forumService =& CopixClassesFactory::Create('forum|forumService');
     $rMessage = $dao_messages->get($id);
     if ($rMessage && $rMessage->status == 1) {
         //print_r($rMessage);
         $mondroit = Kernel::getLevel("MOD_FORUM", $rMessage->forum_id);
         if (!$forumService->canMakeInForum('DELETE_MESSAGE', $mondroit)) {
             $criticErrors[] = CopixI18N::get('kernel|kernel.error.noRights');
         }
     } else {
         $criticErrors[] = CopixI18N::get('forum|forum.error.noMessage');
     }
     if ($criticErrors) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => implode('<br/>', $criticErrors), 'back' => CopixUrl::get('forum||')));
     } else {
         $userInfo = Kernel::getUserInfo("ID", $rMessage->auteur);
         return CopixActionGroup::process('genericTools|Messages::getConfirm', array('title' => CopixI18N::get('forum|forum.conf.messageFrom', array($userInfo["prenom"] . ' ' . $userInfo["nom"])), 'message' => CopixI18N::get('forum|forum.conf.messageAsk'), 'confirm' => CopixUrl::get('forum||doDeleteMessage', array('id' => $id)), 'cancel' => CopixUrl::get('forum||getTopic', array('message' => $id)) . "#" . $id));
     }
 }
Exemplo n.º 27
0
 public function getUserInfo($type = "ME", $id = 0, $options = array())
 {
     //Kernel::deb("getUserInfo / type=$type / id=$id");
     $user = $users = array();
     switch ($type) {
         case "ID":
             $user_dao = _dao("kernel|kernel_bu2user");
             $users = $user_dao->getByUserID($id);
             break;
         case "LOGIN":
             $user_dao = _dao("kernel|kernel_bu2user");
             $users = $user_dao->getByLogin($id);
             break;
         case "ME":
             if (Kernel::is_connected()) {
                 return Kernel::getUserInfo(_currentUser()->getExtra('type'), _currentUser()->getExtra('id'));
             }
         default:
             $user_dao = _dao("kernel|kernel_bu2user");
             $users = $user_dao->getByBUID($type, $id);
             if (count($users)) {
                 $users[0]->bu_type = $type;
                 $users[0]->bu_id = $id;
             } else {
                 if (!isset($options['strict']) || $options['strict']) {
                     // Si pas strict
                     $record = _record("kernel|kernel_bu2user");
                     $record->bu_type = $type;
                     $record->bu_id = $id;
                     $record->user_id = '';
                     $record->user_login = '';
                     $users = array();
                     $users[0] = $record;
                 }
             }
             break;
     }
     if (!sizeof($users)) {
         if (isset($options['strict']) && $options['strict']) {
             return false;
         }
         return array_merge($user, array('nom' => 'Utilisateur inconnu', 'prenom' => $type . ' ' . $id, 'login' => '', 'ALL' => null));
     } else {
         $userval = $users[0];
         $user["type"] = $users[0]->bu_type;
         $user["id"] = $users[0]->bu_id;
         if (isset($users[0]->user_id)) {
             $user["user_id"] = $users[0]->user_id;
         }
         if (isset($users[0]->user_login)) {
             $user["login"] = $users[0]->user_login;
         }
         switch ($userval->bu_type) {
             case "USER_VIL":
             case "USER_ENS":
             case "USER_ADM":
                 $pers_dao = _dao("kernel|kernel_bu_personnel");
                 $personne = $pers_dao->get($userval->bu_id);
                 if (!$personne) {
                     return array_merge($user, array('nom' => 'Utilisateur inconnu', 'prenom' => $userval->bu_type . ' ' . $userval->bu_id, 'ALL' => null));
                 }
                 $user["nom"] = $personne->pers_nom;
                 $user["prenom"] = $personne->pers_prenom1;
                 $user["civilite"] = $personne->pers_civilite;
                 $user["sexe"] = $personne->pers_id_sexe;
                 $user["cle_privee"] = $personne->pers_cle_privee;
                 $user["ALL"] = $personne;
                 $pers_entite_dao = _dao("kernel|kernel_bu_personnel_entite");
                 $pers_entites = $pers_entite_dao->getById($userval->bu_id);
                 foreach ($pers_entites as $key => $value) {
                     switch ($value->pers_entite_type_ref) {
                         case "VILLE":
                             $user["link"]->ville[$value->pers_entite_reference] = $value->pers_entite_role;
                             break;
                         case "ECOLE":
                             $user["link"]->ecole[$value->pers_entite_reference] = $value->pers_entite_role;
                             break;
                         case "CLASSE":
                             $user["link"]->classe[$value->pers_entite_reference] = $value->pers_entite_role;
                             break;
                     }
                 }
                 break;
             case "USER_ELE":
                 $ele_dao = _dao("kernel|kernel_bu_ele");
                 $eleve = $ele_dao->get($userval->bu_id);
                 if (!$eleve) {
                     return array_merge($user, array('nom' => 'Utilisateur inconnu', 'prenom' => $userval->bu_type . ' ' . $userval->bu_id, 'ALL' => null));
                 }
                 $user["nom"] = $eleve->ele_nom;
                 $user["prenom"] = $eleve->ele_prenom1;
                 $user["civilite"] = $eleve->ele_civilite;
                 $user["sexe"] = $eleve->ele_id_sexe;
                 $user["ALL"] = $eleve;
                 $parents = Kernel::getNodeParents("USER_ELE", $userval->bu_id);
                 foreach ($parents as $key => $value) {
                     switch ($value['type']) {
                         case "BU_CLASSE":
                             $user["link"]->classe[$value['id']] = 1;
                             if (isset($value['ALL'])) {
                                 $user["link"]->ecole[$value['ALL']->cla_ecole] = 1;
                                 $user["link"]->ville[$value['ALL']->eco_id_ville] = 1;
                             }
                             if (isset($options['link_data']) && $options['link_data']) {
                                 $user["link_data"]->classe[$value['id']] = Kernel::getNodeInfo("BU_CLASSE", $value['id'], true);
                             }
                             break;
                     }
                 }
                 break;
             case "USER_RES":
                 $res_dao = _dao("kernel|kernel_bu_res");
                 $reponsable = $res_dao->get($userval->bu_id);
                 if (!$reponsable) {
                     return array_merge($user, array('nom' => 'Utilisateur inconnu', 'prenom' => $userval->bu_type . ' ' . $userval->bu_id, 'ALL' => null));
                 }
                 $user["nom"] = $reponsable->res_nom;
                 $user["prenom"] = $reponsable->res_prenom1;
                 $user["civilite"] = $reponsable->res_civilite;
                 $user["sexe"] = $reponsable->res_id_sexe;
                 $user["ALL"] = $reponsable;
                 $user['link'] = array();
                 $parents = Kernel::getNodeParents("USER_RES", $userval->bu_id);
                 foreach ($parents as $parent) {
                     switch ($parent['type']) {
                         case "USER_ELE":
                             if (isset($parent['link'])) {
                                 foreach ($parent['link'] as $nodeType => $nodeValue) {
                                     if (!isset($user['link'][$nodeType])) {
                                         $user['link'][$nodeType] = array();
                                     }
                                     foreach ($nodeValue as $id => $value) {
                                         $user['link'][$nodeType][$id] = $value;
                                     }
                                 }
                             }
                             break;
                     }
                 }
                 break;
             case "USER_EXT":
                 $ext_dao = _dao("kernel|kernel_ext_user");
                 $extuser = $ext_dao->get($userval->bu_id);
                 if (!$extuser) {
                     return array_merge($user, array('nom' => 'Utilisateur inconnu', 'prenom' => $userval->bu_type . ' ' . $userval->bu_id, 'ALL' => null));
                 }
                 $user["nom"] = $extuser->ext_nom;
                 $user["prenom"] = $extuser->ext_prenom;
                 $user["ALL"] = $extuser;
                 $user['link'] = array();
                 $parents = Kernel::getNodeParents("USER_EXT", $userval->bu_id);
                 foreach ($parents as $parent) {
                     if (!isset($user['link'][$parent['type']])) {
                         $user['link'][$parent['type']] = array();
                     }
                     $user['link'][$parent['type']][$parent['id']] = $parent['droit'];
                 }
                 break;
             default:
                 break;
         }
         // switch( $userval->bu_type )
         // } // foreach( $users as $key => $userval )
     }
     // if( sizeof( $users ) )
     return $user;
 }
 public function checkLoginAccess($login)
 {
     if (trim($login) == '') {
         die('Pas de login dans l\'URL');
     }
     $userinfo = Kernel::getUserInfo('LOGIN', $login);
     if (0 == sizeof($userinfo)) {
         die('Login inconnu');
     }
     $level = 0;
     $level = Kernel::getLevel_r($userinfo['type'], $userinfo['id']);
     $level = max($level, Kernel::getLevel_r('ROOT', '0'));
     // Test via le module assistance
     $ok = false;
     $animateur_dao =& CopixDAOFactory::create("kernel|kernel_animateurs");
     $animateur = $animateur_dao->get(_currentUser()->getExtra("type"), _currentUser()->getExtra("id"));
     if ($animateur && isset($animateur->can_comptes) && $animateur->can_comptes) {
         $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->login == $login) {
                         $ok = true;
                         // echo "<pre>"; print_r($personnel); die("</pre>");
                     }
                 }
             }
         }
         if ($ok) {
             $level = 70;
         }
     }
     if ($level < 70) {
         // A vérifier...
         die('Pas le droit !');
     }
     return $userinfo;
 }
 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);
 }
 /**
  * Envoi de messages prives aux responsables d'une intervention lorsqu'on les change. Envoie un message aux nouveaux responsables
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2009/01/22
  * @param object $rIntervention Recordset de l'intervention
  * @param string $responsables Liste des nouveaux responsables (logins separes par virgules)
  * @return null
  */
 public function alertChangeResponsables($rIntervention, $responsables)
 {
     //print_r($rIntervention);
     //print_r($responsables);
     $minimailService =& CopixClassesFactory::Create('minimail|minimailService');
     $titre = $rIntervention->objet;
     $auteur = $rIntervention->iduser;
     $ecoleInfos = Kernel::getNodeInfo('BU_ECOLE', $rIntervention->idetabliss, false);
     $arOld = $rIntervention->responsables;
     $arOld = str_replace(array(" "), "", $arOld);
     $arOld = str_replace(array(",", ";"), ",", $arOld);
     $arOld = preg_split('/[\\s,]+/', $arOld);
     $arNew = $responsables;
     $arNew = str_replace(array(" "), "", $arNew);
     $arNew = str_replace(array(",", ";"), ",", $arNew);
     $arNew = preg_split('/[\\s,]+/', $arNew);
     //print_r($arOld);
     //print_r($arNew);
     foreach ($arNew as $login) {
         if (!in_array($login, $arOld)) {
             $userInfo = Kernel::getUserInfo('LOGIN', $login);
             if ($userInfo && $userInfo["user_id"]) {
                 $dest = array($userInfo["user_id"] => 1);
                 $ecole = $ecoleInfos['nom'];
                 $url = CopixUrl::get('teleprocedures||fiche', array("id" => $rIntervention->idinter));
                 $message = CopixI18N::get('teleprocedures|teleprocedures.message.alertChangeResp', array(1 => $ecole, 2 => $url, 3 => $url));
                 $message = str_replace("\\n", "\n", $message);
                 $minimailService->sendMinimail($titre, $message, $auteur, $dest, 'dokuwiki');
             }
         }
     }
 }