/**
  * Logout
  */
 public function processOut()
 {
     Logs::set(array('type' => 'LOG', 'message' => 'Logout: ' . _currentUser()->getLogin()));
     CopixAuth::getCurrentUser()->logout(array());
     CopixEventNotifier::notify('logout', array('login' => CopixAuth::getCurrentUser()->getLogin()));
     CopixAuth::destroyCurrentUser();
     CopixSession::destroyNamespace('default');
     return _arRedirect(CopixRequest::get('auth_url_return', _url('||')));
 }
 /**
  * Retourne des infos sur un type MIME en clair
  *
  * A partir d'un type MIME ou d'une extension de fichier, retourne des infos en clair dans un tableau index� : type_txt = nom en clair en Fran�ais (ex: Document Word), type_icon = nom de l'image icone � utiliser (dans /www/img/malle/)
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2005/12/06
  * @param string $mime_type Type MIME
  * @return array Tableau index�
  */
 public function getTypeInfos($mime_type, $file_name = '')
 {
     //print_r("getTypeInfos ($mime_type)");
     $point = strrpos($file_name, ".");
     if (!$mime_type) {
         $mime_type = strtolower(substr($file_name, $point + 1));
     }
     switch (strtolower($mime_type)) {
         case "text/plain":
         case "text/cpp":
         case "txt":
             $res = array('type_text' => CopixI18N::get('malle|mime.txt'), 'type_icon' => 'icon_file_txt.png', 'type_icon32' => 'icon_file_txt32.png', 'type_mime' => 'text/plain');
             break;
         case "text/richtext":
         case "application/rtf":
         case "rtf":
             $res = array('type_text' => CopixI18N::get('malle|mime.rtf'), 'type_icon' => 'icon_file_txt.png', 'type_icon32' => 'icon_file_txt32.png', 'type_mime' => 'text/richtext');
             break;
         case "application/msword":
         case "doc":
         case "docx":
         case "application/vnd.oasis.opendocument.text":
         case "odt":
             if (strtolower($mime_type) == 'application/msword' || strtolower($mime_type) == 'doc' || strtolower($mime_type) == 'docx') {
                 $type_mime = 'application/msword';
             } else {
                 $type_mime = 'application/vnd.oasis.opendocument.text';
             }
             $res = array('type_text' => CopixI18N::get('malle|mime.doc'), 'type_icon' => 'icon_file_txt.png', 'type_icon32' => 'icon_file_txt32.png', 'type_mime' => $type_mime);
             break;
         case "application/vnd.ms-powerpoint":
         case "ppt":
         case "pptx":
         case "pps":
         case "odg":
             if (strtolower($mime_type) == 'odg') {
                 $type_mime = 'application/vnd.oasis.opendocument.graphics';
             } else {
                 $type_mime = 'application/vnd.ms-powerpoint';
             }
             $res = array('type_text' => CopixI18N::get('malle|mime.presentation'), 'type_icon' => 'icon_file_presentation.png', 'type_icon32' => 'icon_file_presentation32.png', 'type_mime' => $type_mime);
             break;
         case "image/jpeg":
         case "jpg":
         case "jpeg":
             $res = array('type_text' => CopixI18N::get('malle|mime.image.jpg'), 'type_icon' => 'icon_file_image.png', 'type_icon32' => 'icon_file_image32.png', 'type_mime' => 'image/jpeg');
             break;
         case "image/png":
         case "png":
             $res = array('type_text' => CopixI18N::get('malle|mime.image.png'), 'type_icon' => 'icon_file_image.png', 'type_icon32' => 'icon_file_image32.png', 'type_mime' => 'image/png');
             break;
         case "image/gif":
         case "gif":
             $res = array('type_text' => CopixI18N::get('malle|mime.image.gif'), 'type_icon' => 'icon_file_image.png', 'type_icon32' => 'icon_file_image32.png', 'type_mime' => 'image/gif');
             break;
         case "image/bmp":
         case "bmp":
             $res = array('type_text' => CopixI18N::get('malle|mime.image.bmp'), 'type_icon' => 'icon_file_image.png', 'type_icon32' => 'icon_file_image32.png', 'type_mime' => 'image/bmp');
             break;
         case "audio/wav":
         case "wav":
         case "audio/mpeg":
         case "mp3":
             if (strtolower($mime_type) == 'audio/wav' || strtolower($mime_type) == 'wav') {
                 $type_mime = 'audio/wav';
             } else {
                 $type_mime = 'audio/mpeg';
             }
             $res = array('type_text' => CopixI18N::get('malle|mime.sound'), 'type_icon' => 'icon_file_sound.png', 'type_icon32' => 'icon_file_sound32.png', 'type_mime' => $type_mime);
             break;
         case "application/pdf":
         case "pdf":
             $res = array('type_text' => CopixI18N::get('malle|mime.pdf'), 'type_icon' => 'icon_file_pdf.png', 'type_icon32' => 'icon_file_pdf32.png', 'type_mime' => 'application/pdf');
             break;
         case "application/vnd.ms-excel":
         case "xls":
         case "xlsx":
         case "application/vnd.oasis.opendocument.spreadsheet":
         case "ods":
             if (strtolower($mime_type) == 'application/vnd.ms-excel' || strtolower($mime_type) == 'xls' || strtolower($mime_type) == 'xlsx') {
                 $type_mime = 'application/vnd.ms-excel';
             } else {
                 $type_mime = 'application/vnd.oasis.opendocument.spreadsheet';
             }
             $res = array('type_text' => CopixI18N::get('malle|mime.xls'), 'type_icon' => 'icon_file_spreadsheet.png', 'type_icon32' => 'icon_file_spreadsheet32.png', 'type_mime' => $type_mime);
             break;
         case "video/mpeg":
         case "video/x-ms-wmv":
         case "mpg":
         case "mpeg":
         case "video/3gpp":
         case "3gp":
         case "video/quicktime":
         case "mov":
             if (strtolower($mime_type) == 'video/3gpp' || strtolower($mime_type) == '3gp') {
                 $type_mime = 'video/3gpp';
             } elseif (strtolower($mime_type) == 'video/quicktime' || strtolower($mime_type) == 'mov') {
                 $type_mime = 'video/quicktime';
             } else {
                 $type_mime = 'video/mpeg';
             }
             $res = array('type_text' => CopixI18N::get('malle|mime.video'), 'type_icon' => 'icon_file_video.png', 'type_icon32' => 'icon_file_video32.png', 'type_mime' => $type_mime);
             break;
         case "application/zip":
         case "zip":
         case "application/forcedownload":
             $res = array('type_text' => CopixI18N::get('malle|mime.zip'), 'type_icon' => 'icon_file_zip.png', 'type_icon32' => 'icon_file_zip32.png', 'type_mime' => 'application/zip');
             break;
         case "text/xml":
             $res = array('type_text' => CopixI18N::get('malle|mime.xml'), 'type_icon' => 'icon_file_xml.png', 'type_icon32' => 'icon_file_xml32.png', 'type_mime' => 'text/xml');
             break;
         case "application/x-smarttech-notebook":
         case "nbk":
         case "xbk":
         case "notebook":
             $res = array('type_text' => CopixI18N::get('malle|mime.notebook'), 'type_icon' => 'icon_file_presentation.png', 'type_icon32' => 'icon_file_presentation32.png', 'type_mime' => 'application/x-smarttech-notebook');
             break;
         default:
             if ($point !== false) {
                 $ext = strtolower(substr($file_name, $point + 1));
                 switch ($ext) {
                     case 'flv':
                         $res = array('type_text' => CopixI18N::get('malle|mime.flv'), 'type_icon' => 'icon_file_video.png', 'type_icon32' => 'icon_file_video32.png');
                         break;
                     default:
                         $res = array('type_text' => CopixI18N::get('malle|mime.default'), 'type_icon' => 'icon_file.png', 'type_icon32' => 'icon_file32.png');
                         Logs::set(array('type' => 'INFO', 'message' => "getTypeInfos ({$mime_type}, {$file_name})"));
                 }
             } else {
                 $res = array('type_text' => CopixI18N::get('malle|mime.default'), 'type_icon' => 'icon_file.png', 'type_icon32' => 'icon_file32.png');
                 Logs::set(array('type' => 'INFO', 'message' => "getTypeInfos ({$mime_type}, {$file_name})"));
             }
             break;
     }
     //print_r($res);
     return $res;
 }
 /**
  * Acces direct a un module
  *
  * Fonction generique d'acces a un module depuis un noeud.
  *
  * @author Stephane Holtz <*****@*****.**>
  */
 public function go()
 {
     // NOTIFICATIONS : Préparation de l'enregistrement de la visite. Le module_id est à completer avant enregistrement.
     $lastvisit = _record("kernel|kernel_notifications_lastvisit");
     $lastvisit->user_id = $this->user->id;
     // id Copix
     $lastvisit->date = date('Y-m-d H:i:s');
     $lastvisit->node_type = _request("ntype");
     $lastvisit->node_id = _request("nid");
     $lastvisit->module_type = _request("mtype");
     $lastvisit->module_id = null;
     $mid = _request("mid", 0);
     if (!is_null(_request("ntype")) && !is_null(_request("nid")) && !is_null(_request("mtype"))) {
         CopixSession::set('myNode', array('type' => _request("ntype"), 'id' => _request("nid")));
         if (_request("ntype") == 'CLUB' && _request("mtype") == 'comptes' && !_request("mid")) {
             $loadModule = new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('groupe||getHomeMembers', array('id' => _request("nid"))));
         } elseif (_request("ntype") == 'CLUB' && _request("mtype") == 'admin' && !_request("mid")) {
             $loadModule = new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('groupe||getHomeAdmin', array('id' => _request("nid"))));
         } elseif (strpos(_request("ntype"), 'USER_') === false) {
             // Si on ne connait pas l'ID du module, on tente de le detecter automatiquement
             if (!$mid) {
                 $modules = Kernel::getModEnabled(_request("ntype"), _request("nid"), '', 0, 0, true);
                 foreach ($modules as $module) {
                     if ($module->module_type == 'MOD_' . strtoupper(_request("mtype"))) {
                         if (isset($module->module_id)) {
                             $mid = $module->module_id;
                         } else {
                             $mid = 0;
                         }
                         break;
                     }
                 }
             }
             // die('CopixUrl::get('._request("mtype").'|default|go   id='.$mid);
             $loadModule = new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get(_request("mtype") . '|default|go', array('id' => $mid)));
         } else {
             if ($mid) {
                 $loadModule = new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get(_request("mtype") . '|default|go', array('id' => $mid)));
             } else {
                 $loadModule = new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get(_request("mtype") . '||'));
             }
         }
         // NOTIFICATIONS : Enregistrement de la visite de l'utilisateur (avec suppression de doublons)
         if ($mid) {
             $lastvisit->module_id = $mid;
         }
         if ($lastvisit->user_id) {
             _dao('kernel|kernel_notifications_lastvisit')->deleteBy(_daoSp()->addCondition('user_id', '=', $lastvisit->user_id)->addCondition('node_type', '=', $lastvisit->node_type)->addCondition('node_id', '=', $lastvisit->node_id)->addCondition('module_type', '=', $lastvisit->module_type)->addCondition('module_id', '=', $lastvisit->module_id));
             _dao("kernel|kernel_notifications_lastvisit")->insert($lastvisit);
         }
         // LOGS : Logs d'usage
         Logs::set(array('type' => 'GO', 'node_type' => _request("ntype"), 'node_id' => _request("nid"), 'module_type' => _request("mtype"), 'module_id' => $mid ? $mid : null));
         return $loadModule;
     }
     $loadModule = new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('||'));
     return $loadModule;
 }