/** * Retourne les données du chart * */ public function processGetChartsDatas() { $cle = CopixRequest::get('cle'); echo CopixSession::get("charts|datas|{$cle}"); CopixSession::set("charts|datas|{$cle}", null); return _arNone(); }
public function _createContent(&$toReturn) { //load PPO $ppo = new CopixPPO(); $ppo->user = _currentUser(); //if user is connected : load personal informations if ($ppo->user->isConnected()) { $ppo->animateur = _sessionGet('user_animateur') ? 1 : 0; $ppo->ien = _sessionGet('prisedecontrole_ien') ? 1 : 0; $type = $ppo->user->getExtra('type'); $sexe = $ppo->user->getExtra('sexe') == 2 ? 2 : ''; $ppo->usertype = strtolower($type) . $sexe; } // Get vocabulary catalog to use if ($myNode = CopixSession::get('myNode')) { $nodeVocabularyCatalogDAO = _ioDAO('kernel|kernel_i18n_node_vocabularycatalog'); $vocabularyCatalog = $nodeVocabularyCatalogDAO->getCatalogForNode($myNode['type'], $myNode['id']); } $ppo->vocabularyCatalogId = isset($vocabularyCatalog) ? $vocabularyCatalog->id_vc : CopixConfig::get('kernel|defaultVocabularyCatalog'); $this->addJs('js/iconito/module_auth.js'); $this->addCss('styles/module_auth.css'); $ppo->conf_Cas_actif = CopixConfig::exists('default|conf_Cas_actif') ? CopixConfig::get('default|conf_Cas_actif') : 0; $ppo->conf_Saml_actif = CopixConfig::exists('default|conf_Saml_actif') ? CopixConfig::get('default|conf_Saml_actif') : 0; //load tpl $toReturn = $this->_usePPO($ppo, 'userlogged.tpl'); }
public function _createContent(&$toReturn) { $arModuleToInstall = CopixSession::get('arModuleToInstall', 'copix'); $arInstalledModule = CopixSession::get('arInstalledModule', 'copix'); $moduleName = array_pop($arModuleToInstall); $url = $this->getParam('url'); if (($message = CopixModule::installModule($moduleName)) === true) { $toReturn = _i18n('install.module.install') . ' ' . $moduleName . ' <img src="' . _resource('img/tools/valid.png') . '" />'; if (count($arModuleToInstall) > 0) { $toReturn .= _tag('copixzone', array('id' => uniqid(), 'process' => 'admin|installmodule', 'url' => $url, 'auto' => true, 'ajax' => true)); } elseif ($url) { $toReturn .= sprintf('<form action="%s" method="post"><input type="submit" value="%s"/></form>', htmlspecialchars($url), _i18n('copix:common.buttons.next')); } else { $toReturn .= "<script>\$('back').setStyle('display','');</script>"; } array_push($arInstalledModule, $moduleName); } else { array_push($arInstalledModule, $moduleName); $toReturn = _i18n('install.module.install') . ' ' . $moduleName . ' ' . _tag('popupinformation', array('img' => _resource('img/tools/delete.png')), $message); $toReturn .= '<div class="errorMessage">' . $message . '</div>'; if (count($arInstalledModule) > 0) { CopixSession::set('arModuleToDelete', $arInstalledModule, 'copix'); CopixSession::set('arInstalledModule', null, 'copix'); CopixSession::set('arModuleToInstall', null, 'copix'); $toReturn .= _tag('copixzone', array('id' => uniqid(), 'process' => 'admin|deletemodule', 'auto' => true, 'ajax' => true)); } } CopixSession::set('arModuleToInstall', $arModuleToInstall, 'copix'); CopixSession::set('arInstalledModule', $arInstalledModule, 'copix'); return true; }
/** * Récupération de l'utilisateur courant * * @return CopixUser */ public static function getCurrentUser() { if (($user = CopixSession::get('copix|auth|user')) === null) { CopixSession::set('copix|auth|user', new CopixUser()); } elseif (!$user instanceof ICopixUser) { CopixSession::set('copix|auth|user', new CopixUser()); } return CopixSession::get('copix|auth|user'); }
/** * Page de choix de thème */ public function processDefault() { $ppo = new CopixPPO(); $ppo->TITLE_PAGE = _i18n('admin|themes.titlePage.selectTheme'); $arThemes = CopixPluginRegistry::getConfig('themechooser|themechooser', true)->getThemeList(); $ppo->arThemes = array(); foreach ($arThemes as $theme) { $ppo->arThemes[] = CopixTpl::getThemeInformations($theme); } $ppo->selectedTheme = CopixSession::get('themechooser|theme'); return _arPpo($ppo, 'theme.list.tpl'); }
/** * Retourne les logs sous forme d'idérateur * * @param string $pProfil Nom du profil dont on souhaite afficher le contenu * @param int $pNbItems Nombres d'items à afficher * @return Iterator */ public function getLog($pProfil, $pNbItems = 20) { // Mise en place des limites $page = CopixSession::get('log|numpage') - 1; $start = $page * $pNbItems; // Création du Search Params $sp = _daoSP()->addCondition('profile', '=', $pProfil)->orderBy(array('date', 'DESC')); $dbNbLines = _ioDAO('copixlog')->countBy($sp); CopixSession::set('log|nbpage', ceil($dbNbLines / $pNbItems)); $sp = $sp->setLimit($start, $pNbItems); return _ioDAO('copixlog')->findBy($sp); }
/** * Envoie du mail */ public function processSend() { $ppo->mail = CopixSession::get('admin|email|donnees'); $ppo->mail['send'] = true; $ppo->mail['dest'] = _request("maildest"); $ppo->mail['cc'] = _request("mailcc"); $ppo->mail['cci'] = _request("mailcci"); $ppo->mail['from'] = _request("mailfrom"); $ppo->mail['fromname'] = _request("mailfromname"); $ppo->mail['subject'] = _request("mailtitle"); $ppo->mail['msg'] = _request("mailmsg"); CopixSession::set('admin|email|donnees', $ppo->mail); $arrErrors = _class("emailservices")->sendMail($ppo->mail); return CopixActionGroup::process('admin|Email::create', array('error' => $arrErrors, 'sending' => 'true')); }
public function _createContent(&$toReturn) { if (!CopixPluginRegistry::isRegistered('themechooser|themechooser')) { $toReturn = ""; return true; } $tpl = new CopixTpl(); $arThemes = CopixPluginRegistry::getConfig('themechooser|themechooser')->getThemeList(); $arThemesToReturn = array(); foreach ($arThemes as $theme) { $arThemesToReturn[] = CopixTpl::getThemeInformations($theme); } $selectedTheme = CopixSession::get('themechooser|theme'); $tpl->assign('selectedTheme', $selectedTheme); $tpl->assign('arThemes', $arThemesToReturn); $toReturn = $tpl->fetch('combo.list.tpl'); return true; }
/** * Page de modification d'un utilisateur */ public function processEdit() { //création du tableau d'erreur $errors = array(); if (CopixRequest::get('loginNotAvailable', '0') == 1) { $errors[] = _i18n('auth.error.loginNotAvailable'); } if (CopixRequest::get('loginEmpty', '0') == 1) { $errors[] = _i18n('auth.error.loginEmpty'); } if (CopixRequest::get('passwordDoNotMatch', '0') == 1) { $errors[] = _i18n('auth.error.passwordDoNotMatch'); } if (CopixRequest::get('passwordEmpty', '0') == 1) { $errors[] = _i18n('auth.error.passwordEmpty'); } if (CopixRequest::get('emailEmpty', '0') == 1) { $errors[] = _i18n('auth.error.emailEmpty'); } if (CopixRequest::get('emailIsBad', '0') == 1) { $errors[] = _i18n('auth.error.emailIsBad'); } if (CopixRequest::get('confirmCodeBad', '0') == 1) { $errors[] = _i18n('auth.error.confirmCodeBad'); } //Affichage de la page $ppo = new CopixPPO(); $ppo->TITLE_PAGE = _i18n('auth.newUser'); $ppo->errors = $errors; $ppo->createInProcess = "true"; $ppo->createUser = Copixconfig::get('auth|createUser'); $ppo->typeConfirm = Copixconfig::get('auth|typeConfirm'); // Cherche les valeurs du formulaire si l'ont est en mode réédition if (($idForm = CopixRequest::get('idForm', '0')) != 0) { $user = CopixSession::get('auth|createForm', $idForm); if ($user !== null) { CopixSession::destroyNamespace($idForm); $ppo->user = $user; } } return _arPPO($ppo, 'user.edit.php'); }
public function _createContent(&$toReturn) { $arModuleToDelete = CopixSession::get('arModuleToDelete', 'copix'); $moduleName = array_pop($arModuleToDelete); if (($message = CopixModule::deleteModule($moduleName)) === true) { $toReturn = _i18n('install.module.delete') . ' ' . $moduleName . ' <img src="' . _resource('img/tools/valid.png') . '" />'; if (count($arModuleToDelete) > 0) { $toReturn .= _tag('copixzone', array('id' => uniqid(), 'process' => 'admin|deletemodule', 'auto' => true, 'ajax' => true)); } else { $toReturn .= "<script>\$('back').setStyle('display','');</script>"; } } else { $toReturn = _i18n('install.module.delete') . ' ' . $moduleName . ' ' . _tag('popupinformation', array('img' => _resource('img/tools/delete.png')), $message); $toReturn .= '<div class="errorMessage">' . $message . '</div>'; if (count($arModuleToDelete) > 0) { $toReturn .= _tag('copixzone', array('id' => uniqid(), 'process' => 'admin|deletemodule', 'auto' => true, 'ajax' => true)); } else { $toReturn .= "<script>\$('back').setStyle('display','');</script>"; } } CopixSession::set('arModuleToDelete', $arModuleToDelete, 'copix'); return true; }
/** * Retourne les logs sous forme d'itérateur * @param string $pProfil Le nom du profil dont on souhaite récupérer les logs * @return array */ public function getLog($pProfil) { if (is_array($profile = CopixSession::get('copix|log|firebug|' . $pProfil))) { $arLog = array(); foreach ($profile as $log) { $object = new StdClass(); $object->date = $log['date']; $object->classname = $log['classname']; $object->message = $log['message']; $object->line = $log['line']; $object->file = $log['file']; $object->functionname = $log['functionname']; $object->user = $log['user']; $object->level = $log['level']; $object->profil = $pProfil; $object->type = $log['type']; $arLog[] = $object; } $arrayObject = new ArrayObject(array_reverse($arLog)); return $arrayObject->getIterator(); } return new ArrayObject(); }
/** * Récupération / création d'un formulaire * @param string $pId l'identifiant du formulaire à créer. * Si rien n'est donné, un nouveau formulaire est crée * @return CopixList */ public static function get($pId = null) { //Aucun identifiant donné ? bizarre, mais créons lui un identifiant if ($pId === null) { if (CopixListFactory::getCurrentId() === null) { //@TODO I18N throw new CopixException("Aucun ID en cours, vous devez en spécifier un pour votre formulaire"); } else { $pId = CopixListFactory::getCurrentId(); } } if ($pId != CopixListFactory::getCurrentId()) { CopixListFactory::pushCurrentId($pId); } //le formulaire existe ? $list = CopixSession::get($pId, 'COPIXLIST'); if ($list != null) { return $list; } $list = new CopixList($pId); CopixSession::set($pId, $list, 'COPIXLIST'); //Création du nouveau formulaire return $list; }
/** * Validation des modification sur le profil de cache */ public function processValid() { $type = CopixSession::get('admin|cache|edit'); if (_request('enabled')) { $type['enabled'] = true; } $type['strategy'] = _request('strategy'); if (_request('strategy_class', null, true)) { $type['strategy'] = _request('strategy_class'); } if ($dir = _request('dir')) { $type['dir'] = $dir; } $type['duration'] = _request('duration'); if ($link = _request('link')) { $type['link'] .= $type['link'] == "" ? $link : "|" . $link; } CopixSession::set('admin|cache|edit', $type); if (_request('save')) { $types = CopixConfig::instance()->copixcache_getRegisteredProfiles(); $types[$type['name']] = $type; _class('cacheConfigurationFile')->write($types); CopixSession::set('admin|cache|edit', null); return _arRedirect(_url('cache|admin')); } else { return _arRedirect(_url('cache|edit')); } }
/** * Supression d'un handleExcept pour le profil en cours de modification */ public function processRemoveHandleExcept() { if ($handleExceptToRemove = _request('handleExcept')) { if ($profile = CopixSession::get('admin|log|edit')) { unset($profile['handleExcept'][array_search($handleExceptToRemove, $profile['handleExcept'])]); CopixSession::set('admin|log|edit', $profile); } } return _arRedirect(_url('log|edit')); }
public function go() { $myNode = CopixSession::get('myNode'); if (!is_null($id = _request('id', null))) { if ($myNode['type'] == 'USER_ELE') { return _arRedirect(CopixUrl::get('cahierdetextes||voirTravaux', array('cahierId' => $id, 'eleve' => $myNode['id']))); } else { return _arRedirect(CopixUrl::get('cahierdetextes||voirTravaux', array('cahierId' => $id))); } } }
/** * Récupération en session de l'aide simple en édition * @access: private. */ private function _getSessionSimpleHelp() { _daoInclude('simplehelp'); $oEdit = CopixSession::get('edithelp_object', 'simplehelp'); return isset($oEdit) ? unserialize($oEdit) : null; }
/** * Confirmation de l'installation et affichage des infos login / mot de passe * * @return CopixActionReturn */ public function processDone() { _currentUser()->logout(); if (($loginInformations = CopixSession::get('admin|database|loginInformations')) !== null) { //CopixSession::set ('admin|database|loginInformations', null); $ppo = new CopixPpo(); $ppo->TITLE_PAGE = _i18n("install.result.installok"); $ppo->loginInformations = $loginInformations; return _arPpo($ppo, 'install.done.tpl'); } return _arRedirect(_url('||')); }
/** * On regarde s'il existe des informations de sélection en session * * Si c'est le cas, on met à jour les variables d'état du plugin * @return bool */ private function _alreadyDefinied() { $lang = null; $country = null; if (CopixSession::get('plugin|i18n|lang') !== null) { $this->_lang = CopixSession::get('plugin|i18n|lang'); } if (CopixSession::get('plugin|i18n|country') !== null) { $this->_country = CopixSession::get('plugin|i18n|country'); } return $this->_lang || $this->_country; }
public function processList() { CopixRequest::assert('id_group', 'handler_group'); $id_group = _request('id_group'); $handler_group = _request('handler_group'); $arDroit = array(); $arDroitSansModule = array(); foreach (CopixModule::getList() as $module) { $arDroitSansModule = array_merge($arDroitSansModule, CopixModule::getInformations($module)->credential_notspecific); $arDroit[$module] = CopixModule::getInformations($module)->credential; //Creation des droits si ils n'existent pas foreach ($arDroit[$module] as $name => $values) { $results = _dao('modulecredentials')->findBy(_daoSP()->addCondition('name_mc', '=', $name)->addCondition('module_mc', '=', $module)); $id_mc = null; if (count($results) == 0) { $record = _record('modulecredentials'); $record->name_mc = $name; $record->module_mc = $module; _dao('modulecredentials')->insert($record); $id_mc = $record->id_mc; } else { $id_mc = $results[0]->id_mc; } foreach ($values as $value) { $results = _dao('modulecredentialsvalues')->findBy(_daoSP()->addCondition('id_mc', '=', $id_mc)->addCondition('value_mcv', '=', $value->name)->addCondition('level_mcv', '=', $value->level)); if (count($results) == 0) { $record = _record('modulecredentialsvalues'); $record->id_mc = $id_mc; $record->value_mcv = $value->name; $record->level_mcv = $value->level; _dao('modulecredentialsvalues')->insert($record); } } } //Fin de création des droits } $arData = array(); $arModuleCredential = _dao('modulecredentials')->findBy(_daoSP()->groupBy('module_mc')); foreach ($arModuleCredential as $module) { $module = $module->module_mc; $droits = new StdClass(); $droits->name = $module; $droits->delete = false; if ($module != null) { if (!isset($arDroit[$module]) || count($arDroit[$module]) == 0) { $droits->delete = true; } } $arMc = _dao('modulecredentials')->findBy(_daoSP()->addCondition('module_mc', '=', $module)); $arDroitMc = array(); foreach ($arMc as $mc) { $arDroitMCTemp = new stdClass(); $arDroitMCTemp->record = $mc; $arDroitMCTemp->checked = count(_dao('modulecredentialsgroups')->findBy(_daoSP()->addCondition('id_mc', '=', $mc->id_mc)->addCondition('id_mcv', '=', null)->addCondition('id_group', '=', $id_group)->addCondition('handler_group', '=', $handler_group))) > 0 ? 'checked' : ''; $arDroitMCTemp->delete = true; if ($module != null) { if (isset($arDroit[$module]) && isset($arDroit[$module][$mc->name_mc])) { $arDroitMCTemp->delete = false; } } else { if (isset($arDroitSansModule[$mc->name_mc])) { $arDroitMCTemp->delete = false; } } $arValues = array(); foreach (_dao('modulecredentialsvalues')->findBy(_daoSP()->addCondition('id_mc', '=', $mc->id_mc)->orderBy('level_mcv')) as $value) { $value->checked = count(_dao('modulecredentialsgroups')->findBy(_daoSP()->addCondition('id_mc', '=', $mc->id_mc)->addCondition('id_mcv', '=', $value->id_mcv)->addCondition('id_group', '=', $id_group)->addCondition('handler_group', '=', $handler_group))) > 0 ? 'checked' : ''; $value->delete = true; if ($module != null) { if (isset($arDroit[$module]) && isset($arDroit[$module][$mc->name_mc])) { $valueName = $value->value_mcv; foreach ($arDroit[$mc->module_mc][$mc->name_mc] as $ssDroit) { if ($ssDroit->name == $valueName) { $value->delete = false; } } } } else { if (isset($arDroitSansModule[$mc->name_mc])) { $valueName = $value->value_mcv; foreach ($arDroitSansModule[$mc->name_mc] as $ssDroit) { if ($ssDroit->name == $valueName) { $value->delete = false; } } } } $arValues[] = $value; } $arDroitMCTemp->data = $arValues; $arDroitMc[] = $arDroitMCTemp; } $droits->data = $arDroitMc; $arData[] = $droits; } //Le groupe en cours de modification est en session, on peut le récupérer. if ($group = CopixSession::get('auth|group')) { $groupName = $group->id_dbgroup === null ? _i18n('auth.newGroup') : $group->caption_dbgroup; } else { $groupName = _i18n('auth.newGroup'); } return _arPpo(new CopixPpo(array('TITLE_PAGE' => _i18n('auth.editModuleCredentials', $groupName), 'id_group' => $id_group, 'handler_group' => $handler_group, 'list' => $arData, 'url_return' => _request('url_return', _url('#')))), 'modules.list.php'); }
/** * Renvoie l'ecole sur laquelle on travaille selon la session utilisateur, uniquement pour les directeurs * * @author Christophe Beyer <*****@*****.**> * @since 2009/01/23 * @return integer Id de l'ecole, ou NULL si aucune (anormal) */ public function getTelepEcole() { $myNode = CopixSession::get('myNode'); return $myNode && $myNode['type'] == 'BU_ECOLE' ? $myNode['id'] : null; }
/** * Alias pour CopixSession::get * @param string $pPath le chemin de l'élément en session que l'on souhaite récupérer * @param string $pNamespace le nom du namespace de session dans lequel on souhaite récupérer l'élément * @return mixed */ function _sessionGet($pPath, $pNamespace = 'default') { return CopixSession::get($pPath, $pNamespace); }
/** * Validation des modifications apportées sur un utilisateur */ public function processValid() { CopixRequest::assert('login_dbuser'); $user = CopixSession::get('auth|user'); $user->login_dbuser = CopixRequest::get('login_dbuser'); $user->email_dbuser = CopixRequest::get('email_dbuser'); if (CopixRequest::get('enabled_dbuser') == 0) { $user->enabled_dbuser = 0; } else { $user->enabled_dbuser = 1; } CopixSession::set('auth|user', $user); //on vérifie si le login n'est pas déja pris $sp = _daoSp()->addCondition('login_dbuser', '=', $user->login_dbuser); if ($user->id_dbuser) { //l'utilisateur existe déja, on demande à vérifier l'unicité du login pour l'utilisateur courant $sp->addCondition('id_dbuser', '<>', $user->id_dbuser); } if (count(_ioDAO('dbuser')->findBy($sp))) { return _arRedirect(_url('auth|users|edit', array('loginNotAvailable' => '1'))); } //on vérifie si un mot de passe est donné qu'ils soient bien identiques if (CopixRequest::get('password_dbuser')) { if (CopixRequest::get('password_dbuser') != CopixRequest::get('password_confirmation_dbuser')) { return _arRedirect(_url('auth|users|edit', array('passwordDoNotMatch' => '1'))); } else { $user->password_dbuser = md5(CopixRequest::get('password_dbuser')); } } else { //si c'est un nouvel utilisateur, il est obligatoire de saisir un nouveau mot de passe. if (!$user->id_dbuser) { return _arRedirect(_url('auth|users|edit', array('passwordEmpty' => '1'))); } } if (!$user->email_dbuser) { return _arRedirect(_url('auth|users|edit', array('emailEmpty' => '1'))); } //sauvegarde de l'utilisateur if ($user->id_dbuser) { _ioDAO('dbuser')->update($user); } else { _ioDAO('dbuser')->insert($user); } CopixSession::set('auth|user', null); return _arRedirect(_url('auth|users|')); }
/** * Récupération d'un flash message * * @author Christophe Beyer <*****@*****.**> * @since 2012/06/21 * @param string $type : warning, success, error * @return string Contenu du flash message */ public function getFlashMessage($type) { return CopixSession::get('flash|' . $type); }
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'); }
public function beforeDisplay(&$display) { $jscode = array(); $logs = array(); foreach (CopixConfig::instance()->copixlog_getRegistered() as $profil) { $name = CopixConfig::instance()->copixlog_getProfile($profil); $name = $name['strategy']; if (strtoupper($name) == "FIREBUG") { $logs[] = CopixLog::getLog($profil); } } //merge last logs to new logs if (CopixSession::get('plugin|firebug|log') !== null) { $logs = array_merge(CopixSession::get('plugin|firebug|log'), $logs); CopixSession::set('plugin|firebug|log', null); } $logs = array_reverse($logs); foreach ($logs as $arlog) { foreach ($arlog as $log) { foreach (array('message', 'file', 'line', 'level', 'classname', 'functionname', 'type') as $var) { if (isset($log->{$var})) { ${$var} = $log->{$var}; unset($log->{$var}); } else { ${$var} = null; } } $log->date = CopixDateTime::yyyymmddhhiissToDateTime($log->date); $log->location = "{$file}:{$line}"; $log->function = ($classname ? "{$classname}::" : "") . $functionname; switch ($level) { case CopixLog::INFORMATION: $type = "info"; break; case CopixLog::WARNING: case CopixLog::NOTICE: $type = "warn"; break; case CopixLog::EXCEPTION: case CopixLog::ERROR: case CopixLog::FATAL_ERROR: $type = "error"; break; default: $type = "log"; } unset($log->level); $jscode[] = sprintf('_l(%s,%s,%s,%s);', CopixJSON::encode($type), CopixJSON::encode($message), CopixJSON::encode($log->location), CopixJSON::encode($log)); } } foreach (CopixConfig::instance()->copixlog_getRegistered() as $profil) { $name = CopixConfig::instance()->copixlog_getProfile($profil); $name = $name['strategy']; if (strtoupper($name) == "FIREBUG") { CopixLog::deleteProfile($profil); } } if (count($jscode) > 0) { $jscode[] = "if(window.console && console.firebug){var _l=function(t,m,l,e){console.group('[COPIX] - '+t+' - '+l);console[t](m);console.dir(e);console.groupEnd();}"; $jscode = array_reverse($jscode); $jscode[] = "}"; CopixHTMLHeader::addJSCode(implode("\n", $jscode)); } }
/** * Supression d'un utilisateur du groupe */ public function processRemoveUser() { $this->_validFromRequest(); $users = CopixSession::get('auth|usersgroup'); unset($users[CopixRequest::get('handlerUser')][CopixRequest::get('idUser')]); CopixSession::set('auth|usersgroup', $users); return _arRedirect(_url('auth|groups|edit')); }
/** * Retourne les travaux en classe pour un agenda et une période de date donnés * * @param int $agendaId Identifiant de l'agenda * @param string $dateDebutSemaine Date de début (YYYYmmdd) * @param string $dateFinSemaine Date de fin (YYYYmmdd) * @param string $nodeType Type du node de l'agenda * @param int $nodeId Id du node de l'agenda * @param int $agendaLevel Level de l'utilisateur sur l'agenda * * @return array */ public function findTravauxEnClasseByAgendaParJour($agendaId, $dateDebutSemaine, $dateFinSemaine, $nodeType, $nodeId, $agendaLevel) { $arTravauxParJour = array(); $dateService = new DateService(); $dateCourante = $dateDebutSemaine; while ($dateCourante <= $dateFinSemaine) { $arTravauxParJour[$dateCourante] = ''; $dateCourante = $dateService->addToDate($dateService->dateBddToDateFr($dateCourante), 1, 0, 0, '/'); $dateCourante = $dateService->dateFrToDateBdd($dateCourante); } // Eleve if ($agendaLevel == PROFILE_CCV_WRITE) { $sql = 'SELECT count(module_cahierdetextes_travail.id) as count, module_agenda_work.module_agenda_agenda_id_agenda as id_agenda, "' . $nodeType . '" as node_type, ' . $nodeId . ' as node_id, module_cahierdetextes_travail.date_creation as date_creation, module_cahierdetextes_domaine.nom' . ' FROM module_cahierdetextes_travail' . ' LEFT JOIN module_agenda_work ON (module_agenda_work.module_agenda_agenda_id_agenda = :agendaId)' . ' LEFT JOIN module_cahierdetextes_travail2eleve ON (module_cahierdetextes_travail.id = module_cahierdetextes_travail2eleve.module_cahierdetextes_travail_id)' . ' LEFT JOIN module_cahierdetextes_domaine ON (module_cahierdetextes_domaine.id = module_cahierdetextes_travail.module_cahierdetextes_domaine_id)' . ' WHERE module_agenda_work.module_cahierdetextes_travail_id = module_cahierdetextes_travail.id' . ' AND module_cahierdetextes_travail2eleve.kernel_bu_eleve_idEleve=:idEleve' . ' AND module_cahierdetextes_travail.supprime = 0' . ' AND module_cahierdetextes_travail.a_faire = ' . self::TYPE_EN_CLASSE . ' AND module_cahierdetextes_travail.date_creation >= :dateDebut' . ' AND module_cahierdetextes_travail.date_creation <= :dateFin' . ' GROUP BY module_cahierdetextes_travail.id'; $results = _doQuery($sql, array('dateDebut' => $dateDebutSemaine, 'dateFin' => $dateFinSemaine, 'idEleve' => _currentUser()->getExtra('id'), 'agendaId' => $agendaId)); foreach ($results as $result) { $arTravauxParJour[$result->date_creation][] = $result; } } elseif ($agendaLevel == PROFILE_CCV_NONE && _currentUser()->getExtra('type') == 'USER_RES') { $myNode = CopixSession::get('myNode'); $eleveId = $myNode['type'] == "USER_ELE" ? $myNode['id'] : null; $sql = 'SELECT count(module_cahierdetextes_travail.id) as count, module_agenda_work.module_agenda_agenda_id_agenda as id_agenda, "' . $nodeType . '" as node_type, ' . $nodeId . ' as node_id, module_cahierdetextes_travail.date_creation as date_creation, module_cahierdetextes_domaine.nom' . ' FROM module_cahierdetextes_travail' . ' LEFT JOIN module_agenda_work ON (module_agenda_work.module_agenda_agenda_id_agenda = :agendaId)' . ' LEFT JOIN module_cahierdetextes_travail2eleve ON (module_cahierdetextes_travail.id = module_cahierdetextes_travail2eleve.module_cahierdetextes_travail_id)' . ' LEFT JOIN module_cahierdetextes_domaine ON (module_cahierdetextes_domaine.id = module_cahierdetextes_travail.module_cahierdetextes_domaine_id)' . ' WHERE module_agenda_work.module_cahierdetextes_travail_id = module_cahierdetextes_travail.id' . ' AND module_cahierdetextes_travail2eleve.kernel_bu_eleve_idEleve = :eleveId' . ' AND module_cahierdetextes_travail.supprime = 0' . ' AND module_cahierdetextes_travail.a_faire = ' . self::TYPE_EN_CLASSE . ' AND module_cahierdetextes_travail.date_creation >= :dateDebut' . ' AND module_cahierdetextes_travail.date_creation <= :dateFin' . ' GROUP BY module_cahierdetextes_travail.id'; $results = _doQuery($sql, array('dateDebut' => $dateDebutSemaine, 'dateFin' => $dateFinSemaine, 'agendaId' => $agendaId, 'eleveId' => $eleveId)); foreach ($results as $result) { $arTravauxParJour[$result->date_creation][] = $result; } } elseif ($agendaLevel == PROFILE_CCV_ADMIN) { $sql = 'SELECT count(module_cahierdetextes_travail.id) as count, module_agenda_work.module_agenda_agenda_id_agenda as id_agenda, "' . $nodeType . '" as node_type, ' . $nodeId . ' as node_id, module_cahierdetextes_travail.date_creation as date_creation, module_cahierdetextes_domaine.nom' . ' FROM module_cahierdetextes_travail' . ' LEFT JOIN module_agenda_work ON (module_agenda_work.module_agenda_agenda_id_agenda = :agendaId)' . ' LEFT JOIN module_cahierdetextes_domaine ON (module_cahierdetextes_domaine.id = module_cahierdetextes_travail.module_cahierdetextes_domaine_id)' . ' WHERE module_cahierdetextes_domaine.kernel_bu_ecole_classe_id=:nodeId' . ' AND module_agenda_work.module_cahierdetextes_travail_id = module_cahierdetextes_travail.id' . ' AND module_cahierdetextes_travail.supprime = 0' . ' AND module_cahierdetextes_travail.a_faire = ' . self::TYPE_EN_CLASSE . ' AND module_cahierdetextes_travail.date_creation >= :dateDebut' . ' AND module_cahierdetextes_travail.date_creation <= :dateFin' . ' GROUP BY module_cahierdetextes_travail.id'; $results = _doQuery($sql, array('dateDebut' => $dateDebutSemaine, 'dateFin' => $dateFinSemaine, 'nodeId' => $nodeId, 'agendaId' => $agendaId)); foreach ($results as $result) { $arTravauxParJour[$result->date_creation][] = $result; } } return $arTravauxParJour; }
public function processGetMultipleSelectContent() { $currentId = null; $classString = CopixSession::get(CopixRequest::get('class')); $arClass = explode('::', $classString); $class = _ioClass($arClass[0]); $values = $class->{$arClass}[1](); $objectMap = CopixRequest::get('objectMap'); if (!empty($objectMap)) { $tab = explode(';', $objectMap); if (count($tab) != 2) { throw new CopixTemplateTagException("[plugin select] parameter 'objectMap' must looks like idProp;captionProp"); } $idProp = $tab[0]; $captionProp = $tab[1]; } $id = CopixRequest::get('idselect'); $name = CopixRequest::get('nameselect'); $toReturn = ''; $compteur = 0; if (empty($objectMap)) { foreach ((array) $values as $key => $caption) { $currentId = uniqid(); $compteur++; $color = $compteur % 2 == 0 ? '#cccccc' : '#ffffff'; $toReturn .= '<div style="width:100%;background-color:' . $color . '"><input type="checkbox" class="check_' . $id . '" id="' . $currentId . '" value="' . $key . '" /><label id="label_' . $currentId . '" for="' . $currentId . '">' . _copix_utf8_htmlentities($caption) . '</label></div>'; } } else { //if given an object mapping request. foreach ((array) $values as $object) { $color = $compteur % 2 == 0 ? '#cccccc' : '#ffffff'; $toReturn .= '<div style="width:100%;background-color:' . $color . '"><input type="checkbox" id="' . $currentId . '" class="check_' . $id . '" value="' . $object->{$idProp} . '" /><label id="label_' . $currentId . '" for="' . $currentId . '">' . _copix_utf8_htmlentities($object->{$captionProp}) . '</label></div>'; } } //CopixSession::set(CopixRequest::get('class'),null); CopixHTMLHeader::addJsCode("\n window.addEvent('domready', function () {\n var input = \$('{$id}');\n \$\$('.check_{$id}').each (function (el) {\n el.addEvent ('change', function () {\n var value = '';\n \$('hidden_{$id}').setHTML('');\n \$\$('.check_{$id}').each ( function (el) {\n if (el.checked) {\n if (value!='') {\n value += ',';\n }\n value += \$('label_'+el.getProperty('id')).innerHTML;\n \$('hidden_{$id}').setHTML (\$('hidden_{$id}').innerHTML+'<input type=\"hidden\" name=\"" . $name . "[]\" value=\"'+el.value+'\" />');\n }\n });\n input.value = value;\n });\n });\n });\n "); return _arDirectPPO(new CopixPPO(array('MAIN' => $toReturn)), 'generictools|blank.tpl'); }
public function beforeProcess() { if (in_array(CopixSession::get('themechooser|theme'), $this->config->getThemeList())) { CopixTpl::setTheme(CopixSession::get('themechooser|theme')); } }
/** * Retourne les logs sous forme d'itérateur */ public function getLog($pProfil, $pNbItems = 20) { $page = CopixSession::get('log|numpage') - 1; if (file_exists($this->_getFileName($pProfil))) { // Création d'un objet CopixCSV pour contenir le contenu du fichier $csvLog = new CopixCsv($this->_getFileName($pProfil)); // Récupération de l'itérateur et compte du nombre de ligne $csvLines = $csvLog->getIterator(); $csvNbLines = $csvLines->count(); // Calcul de la position et des offset $pPosition = $csvNbLines - $page * $pNbItems - $pNbItems; // Calcul de la position de départ pour parcourir la portion du fichier à afficher if ($pPosition < 0) { $pOffset = $pNbItems + $pPosition; $pPosition = 0; } else { $pOffset = $pNbItems; $pPosition -= 1; } $csvLines->seek($pPosition); $content = array(); for ($i = 0; $i < $pOffset; $i++) { $content[] = $csvLines->current(); $csvLines->next(); } $content = array_reverse($content); CopixSession::set('log|nbpage', ceil($csvNbLines / $pNbItems)); $arrayObject = new ArrayObject(array_map(array($this, 'toObject'), $content)); return $arrayObject->getIterator(); } return new ArrayObject(); }