public function create($infos = array())
 {
     $blogDAO = _dao('blog|blog');
     $res = null;
     $tabBlogFunctions = returnAllBlogFunctions();
     $blog = _record('blog|blog');
     if ($infos['title']) {
         $blog->name_blog = $infos['title'] . (isset($infos['subtitle']) && strlen($infos['subtitle']) > 0 ? ' (' . $infos['subtitle'] . ')' : '');
     } else {
         $blog->name_blog = CopixI18N::get('blog|blog.default.titre');
     }
     $blog->id_ctpt = 1;
     $blog->style_blog_file = 0;
     $is_public_default = CopixConfig::exists('blog|blog.default.is_public') ? CopixConfig::get('blog|blog.default.is_public') : 1;
     $blog->is_public = isset($infos['is_public']) ? $infos['is_public'] : $is_public_default;
     $blog->has_comments_activated = 0;
     $blog->type_moderation_comments = CopixConfig::get('blog|blog.default.type_moderation_comments');
     $blog->default_format_articles = CopixConfig::get('blog|blog.default.default_format_articles');
     $blog->privacy = CopixConfig::exists('blog|blog.default.privacy') ? CopixConfig::get('blog|blog.default.privacy') : 0;
     $blogDAO->insert($blog);
     if ($blog->id_blog !== NULL) {
         // On détermine l'URL titre
         $blog->url_blog = KernelBlog::calcule_url_blog($blog->id_blog, $blog->name_blog);
         $blogDAO->update($blog);
         // On ajoute une catégorie
         $categoryDAO = _dao('blog|blogarticlecategory');
         $category = _record('blog|blogarticlecategory');
         $category->id_blog = $blog->id_blog;
         $category->name_bacg = CopixI18N::get('blog|blog.default.categorie');
         $category->url_bacg = killBadUrlChars($category->name_bacg) . date('YmdHis');
         $category->order_bacg = $categoryDAO->getNewPos($blog->id_blog);
         $categoryDAO->insert($category);
     }
     return $blog->id_blog !== NULL ? $blog->id_blog : NULL;
 }
 public function processDefault()
 {
     $tpl = new CopixTpl();
     $tplModule = new CopixTpl();
     //if user is not connected :
     if (1) {
         // S'il y a un blog prevu a l'accueil
         $dispBlog = false;
         $getKernelLimitsIdBlog = Kernel::getKernelLimits('id_blog');
         if ($getKernelLimitsIdBlog) {
             _classInclude('blog|kernelblog');
             if ($blog = _ioDao('blog|blog')->getBlogById($getKernelLimitsIdBlog)) {
                 // On v�rifie qu'il y a au moins un article
                 $stats = KernelBlog::getStats($blog->id_blog);
                 if ($stats['nbArticles']['value'] > 0) {
                     $dispBlog = true;
                 }
             }
         }
         if ($dispBlog) {
             //return CopixActionGroup::process ('blog|frontblog::getListArticle', array ('blog'=>$blog->url_blog));
             return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('blog||', array('blog' => $blog->url_blog)));
         }
         if (!CopixConfig::exists('|can_public_rssfeed') || CopixConfig::get('|can_public_rssfeed')) {
             CopixHtmlHeader::addOthers('<link rel="alternate" href="' . CopixUrl::get('public||rss', array()) . '" type="application/rss+xml" title="' . htmlentities(CopixI18N::get('public|public.rss.flux.title')) . '" />');
         }
         CopixHTMLHeader::addCSSLink(_resource("styles/module_fichesecoles.css"));
         $tplModule->assign('user', _currentUser());
         $result = $tplModule->fetch('welcome|welcome_' . CopixI18N::getLang() . '.tpl');
         $tpl->assign('TITLE_PAGE', '' . CopixI18N::get('public|public.welcome.title'));
         $tpl->assign('MAIN', $result);
         return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
     }
 }
 /**
  * Affiche la liste des blogs ayant au moins un article
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2006/03/23
  * @param string $kw Mot-clé pour la recherche (option)
  */
 public function _createContent(&$toReturn)
 {
     CopixHtmlHeader::addJSLink(CopixUrl::get() . 'js/iconito/module_fichesecoles.js');
     $kw = $this->getParam('kw', null);
     $tpl = new CopixTpl();
     $dao = _dao("blog|blog");
     if ($kw) {
         $critere = " SELECT * FROM module_blog WHERE is_public=1 AND name_blog LIKE '%" . addslashes($kw) . "%' ORDER BY name_blog";
     } else {
         $critere = " SELECT * FROM module_blog WHERE is_public=1 AND 1 ORDER BY name_blog";
     }
     $sql = _doQuery($critere);
     $list = array();
     //print_r($sql);
     foreach ($sql as $blog) {
         $parent = Kernel::getModParentInfo("MOD_BLOG", $blog->id_blog);
         if ($parent) {
             $blog->parent = $parent['nom'];
             switch ($parent['type']) {
                 case 'CLUB':
                     $blog->type = CopixI18N::get('public.blog.typeClub');
                     break;
                 case 'BU_CLASSE':
                     $blog->type = CopixI18N::get('public.blog.typeClasse');
                     break;
                 case 'BU_ECOLE':
                     $blog->type = CopixI18N::get('public.blog.typeEcole');
                     break;
                 case 'BU_VILLE':
                     $blog->type = CopixI18N::get('public.blog.typeVille');
                     break;
                 default:
                     $blog->type = $parent['type'];
                     break;
             }
         }
         $blog->stats = KernelBlog::getStats($blog->id_blog);
         //print_r($blog);
         if ($blog->stats['nbArticles']['value'] > 0) {
             $list[] = $blog;
         }
     }
     usort($list, "order_tab_blogs");
     $tpl->assign('list', $list);
     $toReturn = $tpl->fetch('getlistblogszone.tpl');
     return true;
 }
 /**
  * Affiche la liste des blogs ayant au moins un article, pour un groupe de ville, ou une ou plusieurs villes
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2006/03/23
  * @param string $kw Mot-cl� pour la recherche (option)
  * @param integer grville Id de groupe de ville
  * @param array ville Tableau avec les ID des villes
  */
 public function _createContent(&$toReturn)
 {
     CopixHtmlHeader::addJSLink(CopixUrl::get() . 'js/iconito/module_fichesecoles.js');
     $kw = $this->getParam('kw', null);
     $pGrVille = $this->getParam('grville', null);
     $pVille = $this->getParam('ville', null);
     // Tableau
     $tpl = new CopixTpl();
     if ($pVille) {
         $villes = AnnuaireService::getVilles($pVille);
     } else {
         $villes = AnnuaireService::getVillesInGrville($pGrVille);
     }
     //print_r($villes);
     $tpl->assign('villes', $villes);
     $ecoles = array();
     foreach ($villes as $ville) {
         //$ecoles
         $ec = AnnuaireService::getEcolesInVille($ville['id'], array('directeur' => false));
         foreach ($ec as $k => $e) {
             $blog = getNodeBlog('BU_ECOLE', $e['id']);
             //print_r($blog);
             if ($blog && $blog->is_public == 1) {
                 $ec[$k]['blog']['url_blog'] = $blog->url_blog;
             }
         }
         $ecoles[$ville['id']] = $ec;
     }
     //print_r($ecoles);
     $tpl->assign('ecoles', $ecoles);
     if ($kw) {
         $critere = " SELECT * FROM module_blog WHERE is_public=1 AND name_blog LIKE '%" . addslashes($kw) . "%' ORDER BY name_blog";
     } else {
         $critere = " SELECT * FROM module_blog WHERE is_public=1 AND 1 ORDER BY name_blog";
     }
     $sql = _doQuery($critere);
     $list = array();
     $arTypes = array();
     if (CopixConfig::exists('public|blogs.types') && CopixConfig::get('public|blogs.types')) {
         $arTypes = explode(",", CopixConfig::get('public|blogs.types'));
     }
     $arTypes[] = 'CLUB';
     //print_r($sql);
     foreach ($sql as $blog) {
         $parent = Kernel::getModParentInfo("MOD_BLOG", $blog->id_blog);
         if ($parent) {
             if ($arTypes && !in_array($parent['type'], $arTypes)) {
                 continue;
             }
             //var_dump($parent);
             $blog->parent = $parent['nom'];
             switch ($parent['type']) {
                 case 'CLUB':
                     if (Kernel::getKernelLimits('ville')) {
                         $ville = GroupeService::getGroupeVille($parent['id']);
                         if (!in_array($ville, Kernel::getKernelLimits('ville_as_array'))) {
                             continue;
                         }
                     }
                     $blog->type = CopixI18N::get('public.blog.typeClub');
                     break;
                     /*
                     case 'BU_CLASSE' :
                         $blog->type = CopixI18N::get ('public.blog.typeClasse');
                         $blog->parent .= ' - '.$parent['ALL']->eco_nom;
                         if ($parent['ALL']->eco_type)
                             $blog->parent .= ' - '.$parent['ALL']->eco_type.'';
                         break;
                     */
                     //case 'BU_ECOLE' : $blog->type = CopixI18N::get ('public.blog.typeEcole'); break;
                     //case 'BU_VILLE' : $blog->type = CopixI18N::get ('public.blog.typeVille'); break;
                     //case 'BU_GRVILLE' : $blog->type = CopixI18N::get ('public.blog.typeGrville'); break;
                     //default : $blog->type = $parent['type']; break;
             }
             if (!isset($blog->type)) {
                 continue;
             }
             $blog->stats = KernelBlog::getStats($blog->id_blog);
             //print_r($blog);
             /* Activer pour cacher les blogs non lisibles */
             // if( !blogauth::canMakeInBlog('READ', $blog) ) continue;
             if ($blog->stats['nbArticles']['value'] > 0) {
                 $list[] = $blog;
             }
         }
     }
     usort($list, "order_tab_blogs");
     $tpl->assign('list', $list);
     if (!CopixConfig::exists('|can_public_rssfeed') || CopixConfig::get('|can_public_rssfeed')) {
         $tpl->assign('can_public_rssfeed', 1);
     } else {
         $tpl->assign('can_public_rssfeed', 0);
     }
     $toReturn = $tpl->fetch('getlistblogszone2.tpl');
     return true;
 }
 public function doDeleteBlog()
 {
     _classInclude('blog|kernelblog');
     $id_blog = $this->getRequest('id_blog', null);
     $kernel = new KernelBlog();
     $kernel->delete($id_blog);
 }