/** * Retourne un user selon un identifiant * * @param string $login * * @return DAORecordDBUser or false */ public function getByUserLogin($login) { $criteria = _daoSp(); $criteria->addCondition('login_dbuser', '=', $login); $results = $this->findBy($criteria); return isset($results[0]) ? $results[0] : false; }
/** * Retourne l'année scolaire courante * * @return DAORecordKernel_bu_annee_scolaire */ public function getCurrent() { $criteria = _daoSp(); $criteria->addCondition('current', '=', 1); $results = $this->findBy($criteria); return isset($results[0]) ? $results[0] : false; }
public function _createContent(&$toReturn) { $ppo = new CopixPPO(); $ppo->conf = new CopixPPO(); $ppo->conf->directorGlobalAffectation = CopixConfig::get('gestionautonome|directorGlobalAffectation'); // Récupérations des filtres en session $ppo->selected = $this->getParam('selected', 0); $ppo->withLabel = $this->getParam('with_label', true); $ppo->withEmpty = $this->getParam('with_empty', true); $ppo->labelEmpty = $this->getParam('label_empty', null); $ppo->name = $this->getParam('name', null); $ppo->cityGroupsIds = array(); $ppo->cityGroupsNames = array(); $citiesGroupDAO = _ioDAO('kernel|kernel_bu_groupe_villes'); if (_currentUser()->testCredential('module:*||cities_group|create@gestionautonome') || _currentUser()->isDirector && $ppo->conf->directorGlobalAffectation) { $criteria = _daoSp(); $criteria->orderBy('nom_groupe'); $cityGroups = $citiesGroupDAO->findBy($criteria); } else { $groups = _currentUser()->getGroups(); $cityGroups = $citiesGroupDAO->findByUserGroups($groups['gestionautonome|iconitogrouphandler']); } foreach ($cityGroups as $cityGroup) { $ppo->cityGroupsIds[] = $cityGroup->id_grv; $ppo->cityGroupsNames[] = $cityGroup->nom_groupe; } $toReturn = $this->_usePPO($ppo, '_filter_groupcity.tpl'); }
/** * Renvoie les infos de la dernière connexion d'un login * * @author Frédéric Mossmann <*****@*****.**> * @since 2006/05/10 * @param string $login Login de l'utilisateur * @return mixed Objet DAO */ public function lastLogin($login) { $dao = _dao("logs|logs"); $criteres = _daoSp(); $criteres->addCondition('logs_type', '=', 'LOG'); $criteres->addCondition('logs_mod_name', '=', 'auth'); $criteres->addCondition('logs_mod_action', '=', 'in'); $criteres->addCondition('logs_message', '=', 'Login ok: ' . $login); $criteres->orderBy(array('logs_date', 'DESC')); $lastlog = $dao->findBy($criteres); $criteres = _daoSp(); $criteres->addCondition('logs_type', '=', 'LOG'); $criteres->addCondition('logs_mod_name', '=', 'auth'); $criteres->addCondition('logs_mod_action', '=', 'in'); $criteres->addCondition('logs_message', ' LIKE ', 'Login failed: ' . $login . '/%'); $criteres->orderBy(array('logs_date', 'DESC')); $lastfailed = $dao->findBy($criteres); $return = false; if (sizeof($lastlog) > 0) { $return['nb'] = sizeof($lastlog); $return['last'] = $lastlog[0]; if (sizeof($lastfailed) > 0) { $return['failed'] = $lastfailed[0]; } } return $return; }
/** * Retourne les domaines d'une classe * * @param int $idClasse Identifiant d'une classe * * @return CopixDAORecordIterator */ public function findByClasse($idClasse) { $criteria = _daoSp(); $criteria->addCondition('classe_id', '=', $idClasse); $criteria->orderBy(array('nom', 'ASC')); return $this->findBy($criteria); }
/** * Retourne les classes pour une ville donnée * * @param int $idVille Identifiant d'une ville * * @return CopixDAORecordIterator */ public function getByCity($idVille) { $criteria = _daoSp(); $criteria->addCondition('id_ville', '=', $idVille); $criteria->orderBy('nom'); return $this->findBy($criteria); }
/** * Retourne les mots pour un catalogue et une langue donnée * * @param int $vocabularyCatalogId * @param string $lang * * @return CopixDAORecordIterator */ public function findByCatalogAndLang($vocabularyCatalogId, $lang) { $criteria = _daoSp(); $criteria->addCondition('vocabulary_catalog_id', '=', $vocabularyCatalogId); $criteria->addCondition('lang_word', '=', $lang); return $this->findBy($criteria); }
public function _createContent(&$toReturn) { $tpl = new CopixTpl(); $blog = $this->getParam('blog', ''); $cat = $this->getParam('cat', null); $critere = $this->getParam('critere', null); //on récupère l'ensemble des articles du blog $dao = _dao('blog|blogarticle'); if ($cat == null) { $date = $this->getParam('date', null); $arData = $dao->getAllArticlesFromBlog($blog->id_blog, $date); } else { $arData = $dao->getAllArticlesFromBlogByCat($blog->id_blog, $cat->id_bacg); $tpl->assign('cat', $cat); } //on filtre si on a fait une recherche sur les articles if ($critere != null) { $arData = $dao->getAllArticlesFromBlogByCritere($blog->id_blog, $critere); } //var_dump($arData); //on construit un tableau associatif entre l'identifiant de l'article et le nombre de commentaires foreach ($arData as $article) { //var_dump($article); $daoArticleComment =& CopixDAOFactory::getInstanceOf('blog|blogarticlecomment'); $record = _record('blog|blogarticlecomment'); $criteres = _daoSp(); $criteres->addCondition('id_bact', '=', $article->id_bact); $criteres->addCondition('is_online', '=', 1); $resultat = $daoArticleComment->findBy($criteres); $arNbCommentByArticle[$article->id_bact] = count($resultat); } if (count($arData) > 0) { //encodage des URL des catégories pour caractères spéciaux foreach ($arData as $key => $data) { //Modification suite à apparition d'un warning due à l'absence de catégories , vboniface 06.11.2006 $arData[$key]->key = $key; if (isset($arData[$key]->categories)) { foreach ($arData[$key]->categories as $keyCat => $categorie) { $arData[$key]->categories[$keyCat]->url_bacg = urlencode($categorie->url_bacg); } } } if (count($arData) <= intval(CopixConfig::get('blog|nbMaxArticles'))) { $tpl->assign('pager', ""); $tpl->assign('listArticle', $arData); $tpl->assign('arNbCommentByArticle', $arNbCommentByArticle); } else { $params = array('perPage' => intval(CopixConfig::get('blog|nbMaxArticles')), 'delta' => 5, 'recordSet' => $arData, 'template' => '|pager.tpl'); $Pager = CopixPager::Load($params); $tpl->assign('pager', $Pager->GetMultipage()); $tpl->assign('listArticle', $Pager->data); $tpl->assign('arNbCommentByArticle', $arNbCommentByArticle); } //rajout suite à bug mantis 54 vboniface 06.11.2006 $tpl->assign('blog', $blog); } // retour de la fonction : $toReturn = $tpl->fetch('listarticle.tpl'); return true; }
/** * Retourne le catalogue de vocabulaire à partir de son nom * * @return DAORecordKernel_i18n_vocabulary_catalog or false */ public function findByName($name) { $criteria = _daoSp(); $criteria->addCondition('name_vc', '=', $name); $results = $this->findBy($criteria); return isset($results[0]) ? $results[0] : false; }
/** * Visualisation de l'aide * * @param string $toReturn * @return string */ public function _createContent(&$toReturn) { $tpl = new CopixTpl(); $displayAide = true; $daoAide = _ioDao('simplehelp'); $sp = _daoSp()->addCondition('page_sh', '=', $this->getParam('page_sh', null, null))->addCondition('key_sh', '=', $this->getParam('key_sh', null, null)); $arAide = $daoAide->findBy($sp); if (count($arAide) > 0) { $aide = $arAide[0]; } else { $displayAide = false; $aide = null; } // cette variable est crée pour différencier si l'aide doit être afficher dans un popup classique ou un popuinformation $popup = false; if ($this->getParam('popup', null, true) === "true") { $popup = true; } $tpl->assign('aide', $aide); $tpl->assign('displayAide', $displayAide); $tpl->assign('popup', $popup); // $tpl->assign ('nofloat', $this->getParam ('nofloat', false)); $toReturn = $tpl->fetch('showaide.tpl'); return true; }
/** * Retourne le lien d'un travail avec un élève * * @param int $travailId Identifiant du travail * @param int $eleveId Identifiant de l'élève * * @return DAORecordCahierDeTextesTravail2eleve or false */ public function getByTravailAndEleve($travailId, $eleveId) { $criteria = _daoSp(); $criteria->addCondition('travail_id', '=', $travailId); $criteria->addCondition('eleve_id', '=', $eleveId); $results = $this->findBy($criteria); return isset($results[0]) ? $results[0] : false; }
/** * Get all article from a blog */ public function getAllPagesFromBlog($id_blog) { $sp = _daoSp(); $sp->addCondition('id_blog', '=', $id_blog); $sp->addCondition('is_online', '=', 1); $sp->orderBy('order_bpge'); return $this->findBy($sp); }
public function testOffsetExistsDAO() { $results = _ioDao('copix:copixconfig')->iFindBy(_daoSp()->addCondition('id_ccfg', '=', 'FOOOOOOOOOOOOVALUE')); $this->assertFalse(isset($results[0])); $results = _ioDAO('copix:copixconfig')->iFindAll(); $this->assertTrue(count($results) > 10); $this->assertTrue(isset($results[0])); }
/** * Retourne les événements d'un agenda pour un intervalle donné * * @param integer $agendaId Identifiant de l'agenda * @param string $dateDebut Date de début de l'intervalle (format Ymd) * @param string $dateFin Date de fin de l'intervalle (format Ymd) * * @return CopixDAORecordIterator */ public function findByAgendaAndDateInterval($agendaId, $dateDebut, $dateFin) { $c = _daoSp(); $c->addCondition('id_agenda', '=', $agendaId); $c->addCondition('datedeb_event', '<=', $dateFin); $c->startGroup(); $c->addCondition('datefin_event', '>=', $dateDebut); $c->addCondition('endrepeatdate_event', '>=', $dateDebut, 'or'); $c->endGroup(); return $this->findBy($c); }
/** * Retourne l'admission pour un élève et une école * * @param int $studentId Identifiant d'un élève * @param int $schoolId Identifiant d'une école * * @return DAORecord */ public function getByStudentAndSchool($studentId, $schoolId, $state = null) { $criteria = _daoSp(); $criteria->addCondition('admission_eleve', '=', $studentId); $criteria->addCondition('admission_etablissement', '=', $schoolId); if (!is_null($state)) { $criteria->addCondition('admission_etat_eleve', '=', $state); } $results = $this->findBy($criteria); return isset($results[0]) ? $results[0] : false; }
/** * get blog by name * @param name * @return */ public function getBlogById($id_blog) { $sp = _daoSp(); $sp->addCondition('id_blog', '=', $id_blog); $arBlog = $this->findBy($sp); if (count($arBlog) > 0) { foreach ($arBlog as $blog) { return $blog; } } else { return false; } }
/** * Retourne les mémos pour une classe donnée * * @param int $idClasse * @param bool $current (mémos valide à la date du jour ?) * * @return CopixDAORecordIterator */ public function findByClasse($idClasse, $current = false) { $criteria = _daoSp(); $criteria->addCondition('classe_id', '=', $idClasse); $criteria->addCondition('supprime', '=', 0); if ($current) { $criteria->startGroup()->addCondition('date_validite', '>=', date('Ymd'))->addCondition('date_validite', '=', null, 'or')->endGroup(); } $criteria->groupBy('id'); $criteria->orderBy(array('date_creation', 'DESC')); $criteria->orderBy(array('id', 'DESC')); return $this->findBy($criteria); }
/** * Suppression définitive d'une liste * * @author Christophe Beyer <*****@*****.**> * @since 2006/01/09 * @param integer $id Id de la liste * @return boolean true si la suppression s'est bien passée, false sinon */ public function delete($id) { $daoListes = _dao("liste|liste_listes"); $rListe = $daoListes->get($id); $res = false; if ($rListe) { $criteres = _daoSp()->addCondition('liste', '=', $id); _dao('module_liste_messages')->deleteBy($criteres); $daoListes->delete($id); $res = true; } Kernel::unregisterModule("MOD_LISTE", $id); return $res; }
public function get($id) { $get = false; $sp = _daoSp(); $sp->addCondition('idinter', '=', $id); if (count($r = $this->findBy($sp)) > 0) { $get = $r[0]; $now = date('d/m/Y'); $d1 = CopixDateTime::yyyymmddhhiissToTimeStamp($get->datederniere); $d2 = CopixDateTime::timestampToyyyymmdd($d1); $datederniere = CopixDateTime::yyyymmddToDate($d2, '/'); $get->depuis = round(CopixDateTime::timeBetween($datederniere, $now) / (60 * 60 * 24)); //var_dump($get->depuis); } return $get; }
/** * Affichage des groupes de villes */ public function _createContent(&$toReturn) { $ppo = new CopixPPO(); $citiesGroupDAO = _ioDAO('kernel|kernel_bu_groupe_villes'); if (_currentUser()->testCredential('module:*||cities_group|create@gestionautonome')) { $criteria = _daoSp(); $criteria->orderBy('nom_groupe'); $ppo->citiesGroups = $citiesGroupDAO->findBy($criteria); } else { $groups = _currentUser()->getGroups(); $ppo->citiesGroups = $citiesGroupDAO->findByUserGroups($groups['gestionautonome|iconitogrouphandler']); } // Récupération des noeuds ouvert $ppo->nodes = _sessionGet('cities_groups_nodes'); if (is_null($ppo->nodes)) { $ppo->nodes = array(); } $toReturn = $this->_usePPO($ppo, '_cities_group.tpl'); }
/** * Suppression d'une malle * * @author Christophe Beyer <*****@*****.**> * @since 2006/01/09 * @param integer $id Id de la malle * @return boolean true si la suppression s'est bien pass�e, false sinon */ public function delete($id) { $daoMalles = _dao('malle|malle_malles'); $rMalle = $daoMalles->get($id); $res = false; if ($rMalle) { // On vide le r�pertoire $path2data = realpath('./static/malle'); $folder = $path2data . '/' . $rMalle->id . '_' . $rMalle->cle; MalleService::deleteDir($folder); $criteres = _daoSp()->addCondition('malle', '=', $id); _dao('module_malle_files')->deleteBy($criteres); _dao('module_malle_folders')->deleteBy($criteres); $daoMalles->delete($id); $res = true; } Kernel::unregisterModule("MOD_MALLE", $id); return $res; }
public function cleanCode(&$content, $title = "") { $content = preg_replace('/<</', '«', $content); $content = preg_replace('/>>/', '»', $content); $content = preg_replace('/\\(c\\)/', '©', $content); $content = preg_replace('/\\(r\\)/', '®', $content); $content = preg_replace('/¿/', '¿', $content); //money $content = preg_replace('/€/', '€', $content); $content = preg_replace('/¥/', '¥', $content); $content = preg_replace('/¢/', '¢', $content); $content = preg_replace('/£/', '£', $content); //arrows $content = preg_replace('/-->/', '→', $content); $content = preg_replace('/<--/', '←', $content); $content = preg_replace('/<->/', '↔', $content); $content = preg_replace('/==>/', '⇒', $content); $content = preg_replace('/<==/', '⇐', $content); $content = preg_replace('/<=>/', '⇔', $content); //math //$content = preg_replace('/`(.*?)`/', '&\\1;', $content); $content = preg_replace('/=</', '≤', $content); $content = preg_replace('/>=/', '≥', $content); $content = preg_replace('/!=/', '≠', $content); $content = preg_replace('/~=/', '≅', $content); //remove tags $content = str_replace('<', '_lower_', $content); $content = str_replace('>', '_greater_', $content); //now replace _lower_ and _greater_ codes... $content = str_replace('_lower_', '<', $content); $content = str_replace('_greater_', '>', $content); //recreate some tags $content = str_replace('_end_strike_', "</del>", $content); $content = str_replace('_strike_', "<del>", $content); //rule $content = preg_replace('/\\n*\\-{4}\\n*/', "<hr />", $content); //code $content = preg_replace('/\'\'(.*?)\'\'/', "<code>\\1</code>", $content); //links $links = array(); preg_match_all('/\\[\\[(.*?)\\]\\]/', $content, $links); $foundlinks = $links[1]; $i = 0; foreach ($foundlinks as $foundlink) { //seek if we have | to set caption $elem = explode("|", $foundlink); $link = $elem[0]; $caption = isset($elem[1]) ? $elem[1] : $elem[0]; $style = "wiki_exists"; //anchors $anchor = explode("#", $link); $link = strlen($anchor[0]) ? $anchor[0] : $title; if (isset($anchor[1])) { $anchor = $anchor[1]; } else { $anchor = ""; } //is it an external link ? if (!preg_match('/http:/', $link)) { //no, so i think this is a wiki link //page exists ? $parts = explode('/', $link); $heading = ''; $lang = ''; if (count($parts) == 3) { $heading = $parts[0]; $link = $parts[1]; } elseif (count($parts) == 2) { $heading = $parts[0]; $link = $parts[1]; } $dao = _ioDao('wikipages'); $res = $dao->findBy(_daoSp()->startGroup()->addCondition('title_wiki', "=", CopixUrl::escapeSpecialChars($link))->addCondition('heading_wiki', '=', $heading)->endGroup()); if (!$res) { $style = "wiki_no_exists"; } else { $anchor = preg_replace("/[^a-zA-Z0-9]/", $this->anchor_separator, $anchor); } $link = _url('wiki||show', array('title' => $link, 'heading' => $heading)); } $link .= isset($anchor) && strlen($anchor) ? "#" . $anchor : ""; //now, replace link $link = "<a href=\"" . $link . "\" title=\"" . $caption . "\" class=\"{$style}\">{$caption}</a>"; //link has "//" but this is used for italic... so we have to //change it for now... see end function to restore links $link = str_replace("//", "_double_slashes_", $link); $content = str_replace($links[0][$i], $link, $content); $i++; } //images $images = array(); preg_match_all('/\\{\\{(.*?)\\}\\}/', $content, $images); $foundimages = $images[1]; $i = 0; foreach ($foundimages as $foundimg) { $elem = explode(":", $foundimg); if ($elem[0] == "file") { //case of file $class = "wiki_dl_file"; $image = "<a href=\"" . _url('wiki|file|getfile', array('title' => $elem[1])) . "\" title=\"" . $elem[1] . "\" class=\"{$class}\">" . $elem[1] . "</a>"; } else { $elem = explode("|", $foundimg); $foundimg = $elem[0]; $width = isset($elem[1]) ? $elem[1] : ""; $align = isset($elem[2]) ? $elem[2] : ""; $disp = ""; //is it an external link ? if (preg_match('/http:/', $foundimg)) { $alt = explode("/", $foundimg); $alt = $alt[count($alt) - 1]; $alt = explode('.', $alt); $alt = $alt[0]; if ($width) { //$disp = '<a href="' . $foundimg . '" target="_blank" title="' . _i18n ("wiki|wiki.show.fullsize") . '">(-)</a>'; $icon = "<img src=\"" . _resource('img/tools/loupe.png') . "\" alt=\"download\"/>"; $disp = '<a href="' . $foundimg . '" target="_blank" title="' . _i18n("wiki|wiki.show.fullsize") . '">' . $icon . '</a>'; $disp = "<span style=\"height:15px;margin-left: -15px;\">{$disp}</span>"; } } else { //no, so i think this is a wiki link $alt = $foundimg; $foundimg = _url('wiki|file|getFile', array('title' => $alt, 'size' => $width)); $_foundimg = _url('wiki|file|getFile', array('title' => $alt)); //$_foundimg="javascript:WikiSeeImage('$_foundimg','$alt')"; $_foundimg = '<a href="' . $_foundimg . '" rel="lightbox[' . $title . ']" title="' . $alt . '">'; if ($width) { $icon = "<img src=\"" . _resource("img/tools/loupe.png") . "\" alt=\"download\" style=\"z-index: 99\" />"; $disp = $_foundimg . $icon . "</a>"; $disp = "<span style=\"height:20px;margin-left: -15px;\">{$disp}</span>"; } if (function_exists("gd_info")) { $width = ""; //because gd resized image } } if (strlen($align) > 0) { $align = ' align="' . $align . '"'; } if (strlen($width) > 0) { $width = ' width="' . $width . '"'; } $image = ""; $image = "<span style=\"display: inline\">"; $image .= '<img name="wiki_image" src="' . $foundimg . '"' . $width . $align . ' alt="' . $alt . '" />'; $image .= $disp . "</span>"; } $content = str_replace($images[0][$i], $image, $content); $i++; } //footnotes preg_match_all('/\\(\\((.*?)\\)\\)/', $content, $fn); $fns = $fn[1]; $i = count($this->footnotes); $j = 0; foreach ($fns as $footnote) { $this->footnotes[] = $footnote; $content = str_replace($fn[0][$j], "<a href=\"#wiki_footnotes\" title=\"{$footnote}\"><sup>" . ($i + 1) . "</sup></a>", $content); $i++; $j++; } //other $content = preg_replace('/\\*{2}(.*?)\\*{2}/', "<strong>\\1</strong>", $content); $content = str_replace("http://", "_URI_STRING_", $content); $content = preg_replace('/\\/{2}(.*?)\\/{2}/', "<em>\\1</em>", $content); $content = str_replace("_URI_STRING_", "http://", $content); $content = preg_replace('/_{2}(.*?)_{2}/', "<u>\\1</u>", $content); //sup $content = preg_replace('/(.+?)\\^\\((.+?)\\)/', '\\1<sup>\\2</sup>', $content); $content = preg_replace('/sqrt\\((.+?)\\)/', ' √<span style="text-decoration: overline">\\1</span>', $content); //last modification: //$content = preg_replace("/(\s)+/", "\\1", $content); $content = str_replace("<br>", "<br />", $content); $content = preg_replace('/<h(\\d)><br \\/>/', "<h\\1>", $content); $content = str_replace("_double_slashes_", "//", $content); }
/** * Retourne les travaux à rendre à partir du casier où ils doivent être rendu * * @param int $casierId Identifiant du casier où les travaux doivent être rendu * * @return DAORecordCahierDeTextesTravail or false */ public function findTravailARendreByCasier($casierId) { $criteria = _daoSp(); $criteria->addCondition('a_rendre', '=', 1); $criteria->addCondition('dossier_id', '=', $casierId); $results = $this->findBy($criteria); return isset($results[0]) ? $results[0] : false; }
/** * Retourne l'affectation pour un responsable * * @param int $personId Identifiant du responsable * * @return DAORecord */ public function getByPerson($personId) { $criteria = _daoSp(); $criteria->addCondition('res2ele_id_responsable', '=', $personId); return $this->findBy($criteria); }
/** * Retourne les dossiers directs du classeur ou dossier donné * * @param int $idClasseur Identifiant du classeur * @param int $idDossier Identifiant du dossier * @param bool $withLockers Récupère également les dossiers de type "casier" * @param array $tri Tableau spécifiant la colonne et la direction à utiliser pour le tri * * @return CopixDAORecordIterator */ public function getEnfantsDirects($idClasseur, $idDossier = null, $withLockers = true, $tri = array()) { $criteria = _daoSp(); $criteria->addCondition('classeur_id', '=', $idClasseur); if (!is_null($idDossier)) { $criteria->addCondition('parent_id', '=', $idDossier); } else { $criteria->addCondition('parent_id', '=', 0); } if (!$withLockers) { $criteria->addCondition('casier', '=', 0); } if (!empty($tri)) { $criteria->orderBy(array($tri['colonne'], $tri['direction'])); } else { $criteria->orderBy(array('nom', 'ASC')); } return $this->findBy($criteria); }
public static function getModNotifications(&$module) { if (!_currentUser()->getExtra("user_id")) { return $module; } // echo('-'); $module_name = preg_replace('/^MOD_/', '', $module->module_type); $lastvisit = _dao('kernel|kernel_notifications_lastvisit')->findBy(_daoSp()->addCondition('user_id', '=', _currentUser()->getExtra("user_id"))->addCondition('node_type', '=', $module->node_type)->addCondition('node_id', '=', $module->node_id)->addCondition('module_type', '=', $module_name)->addCondition('module_id', '=', $module->module_id)); if (count($lastvisit)) { // Déjà une visite -> On vérifie le cache // echo "XXX"; if ($lastvisit[0]->last_check && $lastvisit[0]->last_check >= date('YmdHis', strtotime("-10 sec"))) { // Si le cache est encore valide -> On retourne les infos du cache // echo "cached($module_name/$module->module_id) "; $module->notification_number = $lastvisit[0]->last_number; $module->notification_message = $lastvisit[0]->last_message; } else { // S'il n'y a pas de cache ou qu'il est invalide -> On demande les infos au module // echo "not-cached($module_name/$module->module_id) "; $arModulesPath = CopixConfig::instance()->arModulesPath; foreach ($arModulesPath as $modulePath) { $class_file = $modulePath . strtolower($module_name) . '/' . COPIX_CLASSES_DIR . 'kernel' . strtolower($module_name) . '.class.php'; if (!file_exists($class_file)) { continue; } $module_class =& CopixClassesFactory::Create($module_name . '|Kernel' . $module_name); if (is_callable(array($module_class, 'getNotifications'))) { $module_class->getNotifications($module, $lastvisit[0]); $lastvisit[0]->last_check = date('Y-m-d H:i:s'); $lastvisit[0]->last_number = $module->notification_number; $lastvisit[0]->last_message = $module->notification_message; _dao('kernel|kernel_notifications_lastvisit')->update($lastvisit[0]); /* echo "<pre>"; print_r($module); print_r($lastvisit[0]); die(); */ } } } } else { // Pas encore de visite -> Pas de notif pour l'instant // echo "NOT_visited "; $module->notification_number = 0; $module->notification_message = ''; // Initialisation, même sans entrer dans le module $lastvisit = _record("kernel|kernel_notifications_lastvisit"); $lastvisit->user_id = _currentUser()->getExtra("user_id"); // id Copix $lastvisit->date = date('Y-m-d H:i:s'); $lastvisit->node_type = $module->node_type; $lastvisit->node_id = $module->node_id; $lastvisit->module_type = $module_name; $lastvisit->module_id = $module->module_id; _dao("kernel|kernel_notifications_lastvisit")->insert($lastvisit); } // [module_nom] => Agenda // echo "<pre>"; print_r($module); die(); return $module; }
public function testUnTrainDB() { //DB mode $bayeszero = _Class('bayes|bayes'); $bayeszero->setDataMode("db", "CopixTests"); $bayeszero->train('foo', "foo bar baz"); $bayeszero->train('bar', "foo bar baz"); $bayeszero->train('bar', "foo2 bar2 baz2"); $find = ";foo2;bar2;baz2;"; $bayeszero->untrain('bar', "foo2 bar2 baz2"); $res = _ioDao('bayesian')->findBy(_daoSp()->addCondition('dataset_bayes', '=', 'CopixTests')->addCondition('category_bayes', '=', 'bar')->addCondition('datas_bayes', '=', $find)); $this->assertEquals(count($res), 0); //check if we haven't erased the first data $find = ";foo;bar;baz;"; $res = _ioDao('bayesian')->findBy(_daoSp()->addCondition('dataset_bayes', '=', 'CopixTests')->addCondition('category_bayes', '=', 'bar')->addCondition('datas_bayes', '=', $find)); $this->assertEquals(count($res), 1); }
/** * Untrain remove the data from dataset * @param string $categoryname * @param string $text */ public function untrain($cat, $text) { $texts = $this->prepareText($text); if ($this->mode != "db") { if (isset($this->categories[$cat]) && isset($this->categories[$cat]->texts)) { $i = 0; foreach ($this->categories[$cat]->texts as $t) { if ($texts == $t) { unset($this->categories[$cat]->texts[$i]); break; } $i++; } if (count($this->categories[$cat]->texts) < 1) { unset($this->categories[$cat]); } } } else { $find = ';' . implode(';', $texts) . ';'; $rec = _ioDao($this->dataset, $this->connectionName)->findBy(_daoSp()->addCondition('datas_bayes', '=', $find)->addCondition('category_bayes', '=', $cat)); if (count($rec)) { _ioDao($this->dataset, $this->connectionName)->delete($rec[0]->id_bayes); } } }
public function processSave() { if (!$this->flash->has('nextAnsw')) { return $this->error('quiz.errors.badOperation'); } if (is_null(qSession('id'))) { return CopixActionGroup::process('quiz|default::Quiz', array('id' => false)); } //get url's answ id $qId = $this->request('qId') * 1; //test id validity if ($qId != $this->flash->currentAnsw) { return $this->error('quiz.errors.badOperation'); } //get responses form datas $pResponse = CopixRequest::get('response', false); if (!$pResponse) { $this->flash->error = $this->i18n('quiz.errors.emptyResponse'); return $this->go('quiz|default|question', array('id' => qSession('id'), 'qId' => $this->flash->currentAnsw)); } $optType = $this->flash->typeAnsw == 'choice' ? 'radio' : 'txt'; $userId = $this->user->id; //delete previous info $criteres = _daoSp()->addCondition('id_user', '=', $userId)->addCondition('id_question', '=', $this->flash->currentAnsw, 'and'); _dao('quiz_response_insert')->deleteBy($criteres); if ($optType == 'radio') { $i = 0; foreach ($pResponse as $response) { $record = _record('quiz_response_insert'); $record->id_user = $userId; $record->id_choice = $response + 0; $record->id_question = $this->flash->currentAnsw; $record->date = time(); $responses[] = $response + 0; _dao('quiz_response_insert')->insert($record); $i++; } } else { //cas du submit txt } //lock test $quizData = _dao('quiz_quiz')->get(qSession('id')); if ($quizData->lock == 1) { return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('quiz.errors.lock'), 'back' => CopixUrl::get('quiz||'))); } $nextQ = $this->flash->nextAnsw; //if next answ = flash : end of quiz if (!$nextQ) { return _arRedirect(_url('quiz|default|endQuestions', array('id' => qSession('id')))); } return _arRedirect(_url('quiz|default|question', array('id' => qSession('id'), 'qId' => $nextQ))); }
/** * Get all links from a blog */ public function getAllLinksFromBlog($id_blog) { $sp = _daoSp(); $sp->addCondition('id_blog', '=', $id_blog); $sp->orderBy('order_blnk'); return $this->findBy($sp); }