/**
  * Validation d'une cat�gorie.
  */
 public function doValidCategory()
 {
     $id_blog = $this->getRequest('id_blog', null);
     if ($id_blog == null) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.param'), 'back' => CopixUrl::get('blog|admin|listBlog')));
     }
     if (!BlogAuth::canMakeInBlog('ADMIN_CATEGORIES', create_blog_object($id_blog))) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.cannotManageCategory'), 'back' => CopixUrl::get('blog|admin|listBlog')));
     }
     $tpl = new CopixTpl();
     $categoryDAO = CopixDAOFactory::create('blog|blogarticlecategory');
     $id_bacg = $this->getRequest('id_bacg', null);
     if (strlen($id_bacg) == 0) {
         $id_bacg = null;
     }
     if ($id_bacg != null) {
         // EDITION D'UNE CATEGORIE
         $category = $categoryDAO->get($id_bacg);
         $category->id_blog = $id_blog;
         $category->name_bacg = $this->getRequest('name_bacg');
         $category->url_bacg = $this->getRequest('url_bacg');
         if (strlen($category->url_bacg) == 0) {
             $category->url_bacg = killBadUrlChars($category->name_bacg);
         }
         $tpl->assign('TITLE_PAGE', CopixI18N::get('blog.get.edit.category.title'));
         $errors = _dao('blog|blogarticlecategory')->check($category);
         if ($errors != 1) {
             // Traitement des erreurs
             $showErrors = true;
         } else {
             // Modification dans la base
             $categoryDAO->update($category);
             return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('blog|admin|showBlog', array("id_blog" => $id_blog, "kind" => $this->getRequest('kind', '0'))));
         }
     } else {
         // CREATION D'UNE CATEGORIE
         $category = CopixDAOFactory::createRecord('blogarticlecategory');
         $category->id_blog = $id_blog;
         $category->name_bacg = $this->getRequest('name_bacg');
         $category->order_bacg = $categoryDAO->getNewPos($id_blog);
         $category->url_bacg = killBadUrlChars($category->name_bacg);
         if (strlen($category->url_bacg) == 0) {
             $category->url_bacg = killBadUrlChars($category->name_bacg);
         }
         $tpl->assign('TITLE_PAGE', CopixI18N::get('blog.get.create.category.title'));
         $errors = _dao('blog|blogarticlecategory')->check($category);
         if ($errors != 1) {
             // Traitement des erreurs
             $showErrors = true;
         } else {
             // Insertion dans la base
             $categoryDAO->insert($category);
             $category->url_bacg = killBadUrlChars($category->id_bacg . '-' . $category->name_bacg);
             $categoryDAO->update($category);
             return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('blog|admin|showBlog', array("id_blog" => $id_blog, "kind" => $this->getRequest('kind', '0'))));
         }
     }
     $tpl->assign('MAIN', CopixZone::process('EditCategory', array('id_blog' => $id_blog, 'id_bacg' => $id_bacg, 'category' => $category, 'errors' => $errors, 'showErrors' => $showErrors, 'kind' => $this->getRequest('kind', '0'))));
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 /**
  * Validation d'une catégorie.
  */
 public function doValidRss()
 {
     $id_blog = $this->getRequest('id_blog', null);
     if ($id_blog == null) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.param'), 'back' => CopixUrl::get('blog|admin|listBlog')));
     }
     if (!BlogAuth::canMakeInBlog('ADMIN_RSS', create_blog_object($id_blog))) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.cannotManageRss'), 'back' => CopixUrl::get('blog|admin|listBlog')));
     }
     $tpl = new CopixTpl();
     $fluxRssDAO = CopixDAOFactory::create('blog|blogfluxrss');
     $id_bfrs = $this->getRequest('id_bfrs', null);
     if (strlen($id_bfrs) == 0) {
         $id_bfrs = null;
     }
     if ($id_bfrs != null) {
         // EDITION D'UNE Link
         $fluxRss = $fluxRssDAO->get($id_bfrs);
         $fluxRss->id_blog = $id_blog;
         $fluxRss->name_bfrs = $this->getRequest('name_bfrs');
         $fluxRss->url_bfrs = $this->getRequest('url_bfrs');
         $tpl->assign('TITLE_PAGE', CopixI18N::get('blog.get.edit.rss.title'));
         $errors = _dao('blog|blogfluxrss')->check($fluxRss);
         if ($errors != 1) {
             // Traitement des erreurs
             $showErrors = true;
         } else {
             // Modification dans la base
             $fluxRssDAO->update($fluxRss);
             return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('blog|admin|showBlog', array("id_blog" => $id_blog, "kind" => $this->getRequest('kind', '0'))));
         }
     } else {
         // CREATION D'UNE Link
         $fluxRss = CopixDAOFactory::createRecord('blogfluxrss');
         $fluxRss->id_blog = $id_blog;
         $fluxRss->name_bfrs = $this->getRequest('name_bfrs');
         $fluxRss->url_bfrs = $this->getRequest('url_bfrs');
         $fluxRss->order_bfrs = $fluxRssDAO->getNewPos($id_blog);
         $tpl->assign('TITLE_PAGE', CopixI18N::get('blog.get.create.rss.title'));
         $errors = _dao('blog|blogfluxrss')->check($fluxRss);
         if ($errors != 1) {
             // Traitement des erreurs
             $showErrors = true;
         } else {
             // Insertion dans la base
             $fluxRssDAO->insert($fluxRss);
             return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('blog|admin|showBlog', array("id_blog" => $id_blog, "kind" => $this->getRequest('kind', '0'))));
         }
     }
     $tpl->assign('MAIN', CopixZone::process('EditRss', array('id_blog' => $id_blog, 'id_brfs' => $id_bfrs, 'fluxRss' => $fluxRss, 'errors' => $errors, 'showErrors' => $showErrors, 'kind' => $this->getRequest('kind', '0'))));
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 public function _createContent(&$toReturn)
 {
     $tpl = new CopixTpl();
     $blog = $this->getParam('blog', '');
     $comment = $this->getParam('comment', NULL);
     //on récupère l'ensemble des articles du blog
     $dao = _dao('blog|blogarticle');
     //$article = $dao->getArticleByUrl($blog->id_blog, $this->getParam('article', ''));
     list($id_bact, ) = explode("-", $this->getParam('article', ''));
     $article = $dao->getArticleById($blog->id_blog, $id_bact);
     if (!$article) {
         $toReturn = '{/}' . $tpl->fetch('showarticle.tpl');
         return true;
     }
     //encodage des URL des catégories pour caractères spéciaux
     if (is_array($article->categories)) {
         foreach ($article->categories as $key => $categorie) {
             $article->categories[$key]->url_bacg = urlencode($categorie->url_bacg);
         }
     }
     $tpl->assign('article', $article);
     // Recherche de tous les commentaires associés à cet article
     $commentDAO = _dao('blog|blogarticlecomment');
     $res = $commentDAO->findCommentOrderBy($article->id_bact, 1);
     $listComment = array();
     foreach ($res as $r) {
         $r->time_bacc = BDToTime($r->time_bacc);
         array_push($listComment, $r);
     }
     if ($comment) {
         $toEdit = $comment;
     } else {
         // On récupère l'utilisateur connecté
         $user = BlogAuth::getUserInfos();
         $toEdit = _record('blogarticlecomment');
         $toEdit->authorid_bacc = $user->userId;
         $toEdit->authorname_bacc = $user->name;
         $toEdit->authoremail_bacc = $user->email;
         $toEdit->authorweb_bacc = $user->web;
     }
     $tpl->assign('blog', $blog);
     $tpl->assign('toEdit', $toEdit);
     $tpl->assign('listComment', $listComment);
     $tpl->assign('errors', $this->getParam('errors', null));
     $tpl->assign('showErrors', $this->getParam('showErrors', false));
     $tpl->assign('canComment', BlogAuth::canComment($blog->id_blog));
     $plugStats = CopixPluginRegistry::get("stats|stats");
     $plugStats->setParams(array('objet_a' => $article->id_bact));
     // retour de la fonction :
     $toReturn = $article->name_bact . '{/}' . $tpl->fetch('showarticle.tpl');
     return true;
 }
 public function _createContent(&$toReturn)
 {
     //Getting the user.
     //Create Services, and DAO
     CopixHTMLHeader::addCSSLink(_resource("styles/module_blog_admin.css"));
     CopixHtmlHeader::addJSLink(CopixUrl::get() . 'js/iconito/module_blog.js');
     $tpl = new CopixTpl();
     $id_blog = $this->getParam('id_blog', '');
     $tpl->assign('article', $this->getParam('article', null));
     $tpl->assign('kind', $this->getParam('kind', null));
     $tpl->assign('id_blog', $id_blog);
     $tpl->assign('id_bact', $this->getParam('id_bact', ''));
     $tpl->assign('errors', $this->getParam('errors', ''));
     $tpl->assign('showErrors', $this->getParam('showErrors', false));
     $tpl->assign('preview', $this->getParam('preview', '0'));
     $tpl->assign('tabArticleCategory', $this->getParam('tabArticleCategory', null));
     $tpl->assign('can_format_articles', CopixConfig::get('blog|blog.default.can_format_articles'));
     $tpl->assign('default_format_articles', CopixConfig::get('blog|blog.default.default_format_articles'));
     $formats = CopixConfig::get('blog|blog.formats_articles');
     $tabFormats = explode(',', $formats);
     $values = $output = array();
     foreach ($tabFormats as $k) {
         $values[] = $k;
         $output[] = CopixI18N::get('blog|blog.default_format_articles.' . $k);
     }
     $tpl->assign('format_bact', array('values' => $values, 'output' => $output));
     $art = $this->getParam('article');
     $tpl->assign('edition_sumary', CopixZone::process('kernel|edition', array('field' => 'sumary_bact', 'format' => $art->format_bact, 'content' => $art->sumary_bact, 'options' => array('toolbarSet' => 'IconitoBlog'), 'object' => array('type' => 'MOD_BLOG', 'id' => $this->getParam('id_blog')), 'height' => 160)));
     $tpl->assign('edition_content', CopixZone::process('kernel|edition', array('field' => 'content_bact', 'format' => $art->format_bact, 'content' => $art->content_bact, 'options' => array('toolbarSet' => 'IconitoBlog'), 'object' => array('type' => 'MOD_BLOG', 'id' => $this->getParam('id_blog')), 'height' => 290)));
     //cat�gorie de l'article
     if ($this->getParam('kind', null) == 1) {
         $article = $this->getParam('article', null);
         $idCategorie = $article->tabSelectCat[0];
         foreach ($this->getParam('tabArticleCategory', null) as $key => $obj) {
             if ($obj->id_bacg == $idCategorie) {
                 $categorie = $obj->name_bacg;
             }
         }
         $tpl->assign('categorie', $categorie);
     }
     $tpl->assign('canWriteOnline', BlogAuth::canMakeInBlog('ADMIN_ARTICLE_MAKE_ONLINE', create_blog_object($id_blog)));
     // retour de la fonction :
     $toReturn = $tpl->fetch('article.edit.tpl');
     return true;
 }
 public function _createContent(&$toReturn)
 {
     //Getting the user.
     //Create Services, and DAO
     $tpl = new CopixTpl();
     $id_blog = $this->getParam('id_blog', '');
     $tpl->assign('resultats', $this->getParam('resultats', null));
     $tpl->assign('id_bact', $this->getParam('id_bact', ''));
     $tpl->assign('id_blog', $id_blog);
     $tpl->assign('errors', $this->getParam('errors', null));
     $tpl->assign('showErrors', $this->getParam('showErrors', false));
     $tpl->assign('toEdit', $this->getParam('toEdit', false));
     //capability
     $tpl->assign('canManageComment', BlogAuth::canMakeInBlog('ADMIN_COMMENTS', create_blog_object($id_blog)));
     // retour de la fonction :
     $toReturn = $tpl->fetch('comment.list.tpl');
     return true;
 }
 public function _createContent(&$toReturn)
 {
     //Getting the user.
     //Create Services, and DAO
     $tpl = new CopixTpl();
     $res = $this->getParam('resultats', null);
     //capability
     $tpl->assign('canCreate', BlogAuth::canCreate());
     $resultats = array();
     foreach ($res as $r) {
         $r->canWrite = BlogAuth::canWrite($r->id_blog);
         $r->canRead = BlogAuth::canRead($r->id_blog);
         array_push($resultats, $r);
     }
     $tpl->assign('resultats', $resultats);
     // retour de la fonction :
     $toReturn = $tpl->fetch('blog.get.list.tpl');
     return true;
 }
 /**
  * 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;
 }
 public function _createContent(&$toReturn)
 {
     //Getting the user.
     //Create Services, and DAO
     CopixHTMLHeader::addCSSLink(_resource("styles/module_blog_admin.css"));
     CopixHtmlHeader::addJSLink(CopixUrl::get() . 'js/iconito/module_blog.js');
     $tpl = new CopixTpl();
     $id_blog = $this->getParam('id_blog', '');
     $tpl->assign('page', $this->getParam('page', null));
     $tpl->assign('id_blog', $this->getParam('id_blog', ''));
     $tpl->assign('id_bpge', $this->getParam('id_bpge', ''));
     $tpl->assign('errors', $this->getParam('errors', ''));
     $tpl->assign('showErrors', $this->getParam('showErrors', ''));
     $tpl->assign('preview', $this->getParam('preview', '0'));
     $tpl->assign('kind', $this->getParam('kind', '0'));
     $tpl->assign('can_format_articles', CopixConfig::get('blog|blog.default.can_format_articles'));
     $tpl->assign('default_format_articles', CopixConfig::get('blog|blog.default.default_format_articles'));
     //$tpl->assign ('wikibuttons', CopixZone::process ('kernel|wikibuttons', array('field'=>'content_bpge', 'object'=>array('type'=>'MOD_BLOG', 'id'=>$this->getParam('id_blog')))));
     $formats = CopixConfig::get('blog|blog.formats_articles');
     $tabFormats = explode(',', $formats);
     $values = $output = array();
     foreach ($tabFormats as $k) {
         $values[] = $k;
         $output[] = CopixI18N::get('blog|blog.default_format_articles.' . $k);
     }
     $tpl->assign('format_bpge', array('values' => $values, 'output' => $output));
     $pag = $this->getParam('page');
     //print_r($pag);
     if (!isset($pag->content_bpge)) {
         $pag->content_bpge = '';
     }
     //$content = (isset($pag->content_bpge)) ? $pag->content_bpge : '';
     //$tpl->assign ('content_bpge', CopixZone::process ('kernel|edition', array('field'=>'content_bpge', 'format'=>'wiki', 'content'=>$content, 'object'=>array('type'=>'MOD_BLOG', 'id'=>$this->getParam('id_blog')), 'height'=>290)));
     $tpl->assign('edition_content', CopixZone::process('kernel|edition', array('field' => 'content_bpge', 'format' => $pag->format_bpge, 'content' => $pag->content_bpge, 'object' => array('type' => 'MOD_BLOG', 'id' => $this->getParam('id_blog')), 'height' => 290)));
     $tpl->assign('canWriteOnline', BlogAuth::canMakeInBlog('ADMIN_ARTICLE_MAKE_ONLINE', create_blog_object($id_blog)));
     // retour de la fonction :
     $toReturn = $tpl->fetch('page.edit.tpl');
     return true;
 }
 public function _createContent(&$toReturn)
 {
     //Getting the user.
     //Create Services, and DAO
     $tpl = new CopixTpl();
     $id_blog = $this->getParam('id_blog', null);
     $blog = $this->getParam('blog', null);
     $kind = $this->getParam('kind', '0');
     $selectCategory = $this->getParam('selectCategory', '');
     $selectMonth = $this->getParam('selectMonth', '');
     $id_bact = $this->getParam('id_bact', '');
     // Recherche de toutes les catégories de la base
     $query = null;
     $clause = '';
     if (strlen($selectCategory) > 0) {
         $clause = ' AND ';
         $query = ' artctg.id_bacg = ' . $selectCategory;
     }
     if (strlen($selectMonth) > 0) {
         $query = $query . $clause . ' art.date_bact LIKE \'' . $selectMonth . '%\'';
     }
     $id_bacg = null;
     $blogArticleDAO = _dao('blog|blogarticle');
     $res = $blogArticleDAO->findArticles($id_blog, $id_bacg, $query);
     //print_r($res);
     // Manipulation du tableau résultat.
     $commentDAO = _dao('blog|blogarticlecomment');
     $tabArticles = array();
     foreach ($res as $r) {
         $r->categories = array();
         $r->categories = $blogArticleDAO->findCategoriesForArticle($r->id_bact);
         $r->nbComment = $commentDAO->countNbCommentForArticle($r->id_bact);
         $r->nbComment_offline = $commentDAO->countNbCommentForArticle($r->id_bact, 0);
         if ($id_bact == $r->id_bact) {
             $r->expand = true;
         } else {
             $r->expand = false;
         }
         array_push($tabArticles, $r);
     }
     // Préparation du filtre CATEGORIES
     $blogArticleCategoryDAO = _dao('blog|blogarticlecategory');
     $tabArticleCategory = $blogArticleCategoryDAO->findAllOrder($id_blog);
     // Préparation du filtre MOIS
     $resArticleMonth = $blogArticleDAO->findListMonthForArticle($id_blog);
     $tabArticleMonth = array();
     $lastMonth = null;
     foreach ($resArticleMonth as $month) {
         $monthYear = substr($month->date_bact, 4, 2) . '/' . substr($month->date_bact, 0, 4);
         if ($monthYear != $lastMonth) {
             $tmp = array('value' => substr($month->date_bact, 0, 6), 'text' => $monthYear);
             $tabArticleMonth[] = $tmp;
             $lastMonth = $monthYear;
         }
     }
     //capability
     //$tpl->assign ('canManageArticle' , BlogAuth::canMakeInBlog('ADMIN_ARTICLES',create_blog_object($id_blog)));
     $tpl->assign('id_blog', $id_blog);
     $tpl->assign('blog', $blog);
     $tpl->assign('kind', $kind);
     $tpl->assign('tabArticleMonth', $tabArticleMonth);
     $tpl->assign('tabArticleCategory', $tabArticleCategory);
     $tpl->assign('selectCategory', $selectCategory);
     $tpl->assign('selectMonth', $selectMonth);
     $tpl->assign('id_bact', $id_bact);
     // Uniquement pour la partie Article
     if (count($tabArticles) > 0) {
         $params = array('perPage' => intval(CopixConfig::get('blog|nbMaxArticles')), 'delta' => 5, 'recordSet' => $tabArticles);
         $pager = CopixPager::Load($params);
         //print_r($pager);
         $tpl->assign('pagerArticles', $pager->GetMultipage());
         $tpl->assign('tabArticles', $pager->data);
         $tpl->assign('p', $this->getParam('p', ''));
     } else {
         $tpl->assign('p', $this->getParam('p', ''));
         $tpl->assign('tabArticles', array());
     }
     $tpl->assign('canDelete', BlogAuth::canMakeInBlog('ADMIN_ARTICLE_DELETE', $blog));
     $tpl->assign('canAdminComments', BlogAuth::canMakeInBlog('ADMIN_COMMENTS', $blog));
     // retour de la fonction :
     $toReturn = $tpl->fetch('blog.show.article.tpl');
     return $toReturn;
 }
function getBlogAdminMenu($blog, $action = 99)
{
    $id_blog = $blog->id_blog;
    $menu = array();
    $current = false;
    $txt = CopixI18N::get('blog|blog.nav.blog');
    $type = 'read';
    $size = 56;
    $current = $action == 99 ? true : false;
    $url = CopixUrl::get('|', array("blog" => $blog->url_blog));
    $menu[] = array('txt' => $txt, 'type' => $type, 'size' => $size, 'current' => $current, 'url' => $url);
    if (BlogAuth::canMakeInBlog('ADMIN_CATEGORIES', $blog)) {
        $txt = CopixI18N::get('blog|blog.nav.categories');
        $type = 'tag';
        $current = $action == 1 ? true : false;
        $url = CopixUrl::get('blog|admin|showBlog', array("id_blog" => $id_blog, "kind" => 1));
        $menu[] = array('txt' => $txt, 'type' => $type, 'size' => $size, 'current' => $current, 'url' => $url);
    }
    if (BlogAuth::canMakeInBlog('ADMIN_ARTICLES', $blog)) {
        $txt = CopixI18N::get('blog|blog.nav.articles');
        $type = 'article';
        $current = $action == 0 ? true : false;
        $url = CopixUrl::get('blog|admin|showBlog', array("id_blog" => $id_blog, "kind" => 0));
        $menu[] = array('txt' => $txt, 'type' => $type, 'size' => $size, 'current' => $current, 'url' => $url);
    }
    if (BlogAuth::canMakeInBlog('ADMIN_PAGES', $blog)) {
        $txt = CopixI18N::get('blog|blog.nav.pages');
        $type = 'page';
        $current = $action == 5 ? true : false;
        $url = CopixUrl::get('blog|admin|showBlog', array("id_blog" => $id_blog, "kind" => 5));
        $menu[] = array('txt' => $txt, 'type' => $type, 'size' => $size, 'current' => $current, 'url' => $url);
    }
    if (BlogAuth::canMakeInBlog('ADMIN_LIENS', $blog)) {
        $txt = CopixI18N::get('blog|blog.nav.links');
        $type = 'link';
        $current = $action == 2 ? true : false;
        $url = CopixUrl::get('blog|admin|showBlog', array("id_blog" => $id_blog, "kind" => 2));
        $menu[] = array('txt' => $txt, 'type' => $type, 'size' => $size, 'current' => $current, 'url' => $url);
    }
    if (BlogAuth::canMakeInBlog('ADMIN_RSS', $blog)) {
        $txt = CopixI18N::get('blog|blog.nav.rss');
        $type = 'rss';
        $current = $action == 6 ? true : false;
        $url = CopixUrl::get('blog|admin|showBlog', array("id_blog" => $id_blog, "kind" => 6));
        $menu[] = array('txt' => $txt, 'type' => $type, 'size' => $size, 'current' => $current, 'url' => $url);
    }
    if (BlogAuth::canMakeInBlog('ADMIN_OPTIONS', $blog)) {
        $txt = CopixI18N::get('blog|blog.nav.options');
        $type = 'options';
        $current = $action == 4 ? true : false;
        $url = CopixUrl::get('blog|admin|showBlog', array("id_blog" => $id_blog, "kind" => 4));
        $menu[] = array('txt' => $txt, 'type' => $type, 'size' => $size, 'current' => $current, 'url' => $url);
    }
    if (BlogAuth::canMakeInBlog("ADMIN_DROITS", $blog)) {
        $txt = CopixI18N::get('blog|blog.nav.droits');
        $type = 'acl';
        $current = $action == 8 ? true : false;
        $url = CopixUrl::get('blog|admin|showBlog', array("id_blog" => $id_blog, "kind" => 8));
        $menu[] = array('txt' => $txt, 'type' => $type, 'size' => $size, 'current' => $current, 'url' => $url);
    }
    if (BlogAuth::canMakeInBlog("ADMIN_STATS", $blog)) {
        $txt = CopixI18N::get('blog|blog.nav.stats');
        $type = 'results';
        $current = $action == 9 ? true : false;
        $url = CopixUrl::get('blog|admin|showBlog', array("id_blog" => $id_blog, "kind" => 9));
        $menu[] = array('txt' => $txt, 'type' => $type, 'size' => $size, 'current' => $current, 'url' => $url);
    }
    return $menu;
}
 /**
  * Validation d'une cat�gorie.
  */
 public function doValidModifyComment()
 {
     $id_blog = $this->getRequest('id_blog', null);
     if (strlen($id_blog) == 0) {
         $id_blog = null;
     }
     $id_bact = $this->getRequest('id_bact', null);
     if (strlen($id_bact) == 0) {
         $id_bact = null;
     }
     $id_bacc = $this->getRequest('id_bacc', null);
     if (strlen($id_bacc) == 0) {
         $id_bacc = null;
     }
     if ($id_blog == null || $id_bact == null || $id_bacc == null) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.param'), 'back' => CopixUrl::get('blog|admin|listBlog')));
     }
     if (!BlogAuth::canMakeInBlog('ADMIN_COMMENTS', create_blog_object($id_blog))) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.cannotManageComment'), 'back' => CopixUrl::get('blog|admin|listBlog')));
     }
     $tpl = new CopixTpl();
     $commentDAO = CopixDAOFactory::create('blog|blogarticlecomment');
     // EDITION D'UNE CATEGORIE
     $comment = $commentDAO->get($id_bacc);
     $this->_validFromPostProperties($comment);
     $tpl->assign('TITLE_PAGE', CopixI18N::get('blog.get.edit.comment.title'));
     $errors = _dao('blog|blogarticlecomment')->check($comment);
     if ($errors != 1) {
         // Traitement des erreurs
         $showErrors = true;
     } else {
         // Modification dans la base
         $commentDAO->update($comment);
         return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('blog|admin|listComment', array("id_blog" => $id_blog, "id_bact" => $id_bact)));
     }
     $articleDAO = CopixDAOFactory::create('blog|blogarticle');
     $article = $articleDAO->get($id_bact);
     $comment->name_bact = $article->name_bact;
     $comment->time_bacc = BDToTime($comment->time_bacc);
     $tpl->assign('MAIN', CopixZone::process('EditComment', array('id_blog' => $id_blog, 'id_bact' => $id_bact, 'id_bacc' => $id_bacc, 'comment' => $comment, 'errors' => $errors, 'showErrors' => $showErrors)));
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 /**
  * Validation d'un commentaire.
  */
 public function doValidComment()
 {
     if (Kernel::isSpam()) {
         return new CopixActionReturn(CopixActionReturn::HTTPCODE, CopixHTTPHeader::get404(), "Page introuvable");
     }
     $url_bact = _request('url_bact');
     //On verifit que le blog existe (on r�cup�re le blog avec son nom)
     $dao = CopixDAOFactory::create('blog|blog');
     if (!($blog = $dao->getBlogByName(_request('blog')))) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.unableToFindBlog'), 'back' => CopixUrl::get('')));
     }
     // On v�rifie que le droit de lecture est pr�sent
     if (!BlogAuth::canMakeInBlog('READ', $blog)) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('kernel|kernel.error.noRights'), 'back' => CopixUrl::get('')));
     }
     if (!$blog->has_comments_activated) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.add.comment.closed'), 'back' => CopixUrl::get('', array('blog' => _request('blog')))));
     }
     $id_bact = $this->getRequest('id_bact', null);
     if (!BlogAuth::canComment($blog->id_blog)) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.cannotManageComment'), 'back' => CopixUrl::get('', array('blog' => _request('blog')))));
     }
     $tpl = new CopixTpl();
     $commentDAO = CopixDAOFactory::create('blog|blogarticlecomment');
     $comment = CopixDAOFactory::createRecord('blog|blogarticlecomment');
     $this->_validFromPostProperties($comment);
     $comment->date_bacc = date('Ymd');
     $comment->time_bacc = date('Hi');
     $comment->is_online = $blog->type_moderation_comments != 'POST' ? 0 : 1;
     $comment->authorip_bacc = $_SERVER["REMOTE_ADDR"];
     CopixHTMLHeader::addCSSLink(CopixUrl::get('blog||getBlogCss', array('id_blog' => $blog->id_blog)));
     $tpl->assign('blog', $blog);
     $errors = $commentDAO->check($comment);
     //print_r($comment);
     $showErrors = false;
     if ($errors != 1) {
         // Traitement des erreurs
         $showErrors = true;
     } else {
         // Insertion dans la base
         $commentDAO->insert($comment);
     }
     $zoneArticle = CopixZone::process('ShowArticle', array('blog' => $blog, 'article' => $this->getRequest('article', ''), 'errors' => $errors, 'showErrors' => $showErrors, 'comment' => $comment));
     list($title, $article) = explode("{/}", $zoneArticle);
     $tpl->assign('TITLE_PAGE', $title . ' - ' . $blog->name_blog);
     $tpl->assign('Article', $article);
     $tpl->assign('ListLink', CopixZone::process('ListLink', array('blog' => $blog)));
     $tpl->assign('ListCategory', CopixZone::process('ListCategory', array('blog' => $blog)));
     $tpl->assign('ListArchive', CopixZone::process('ListArchive', array('blog' => $blog)));
     $tpl->assign('ListPage', CopixZone::process('ListPage', array('blog' => $blog)));
     $tpl->assign('ListSearch', CopixZone::process('ListSearch', array('blog' => $blog)));
     if (!$showErrors) {
         if ($comment->is_online == 1) {
             return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('blog||showArticle', array('blog' => urlencode($blog->url_blog), 'article' => _request('article'))) . '#comments');
         } else {
             return CopixActionGroup::process('genericTools|Messages::getInformation', array('message' => CopixI18N::get('blog.comments.offline.info'), 'continue' => CopixUrl::get('blog|default|showArticle', array('blog' => $blog->url_blog, 'article' => $url_bact))));
         }
     }
     //		$menu = array();
     $parent = Kernel::getModParentInfo("MOD_BLOG", $blog->id_blog);
     //print_r($parent);
     $blog->parent = $parent;
     /*
             if ($parent['type']=='CLUB') {
                 $droit = Kernel::getLevel($parent['type'], $parent['id']);
                 //print_r($droit);
                 if (GroupeService::canMakeInGroupe('VIEW_HOME', $droit))
                     $menu[] = array('url'=>CopixUrl::get ('groupe||getHome', array("id"=>$parent['id'])), 'txt'=>CopixI18N::get ('blog.menuToGroup'));
             }
             if (BlogAuth::canMakeInBlog('ACCESS_ADMIN',$blog))
                 $menu[] = array('url'=>CopixUrl::get ('admin|showBlog', array("id_blog"=>$blog->id_blog)), 'txt'=>CopixI18N::get ('blog.menuAdmin'));
     */
     //print_r($menu);
     $menu = array();
     if (BlogAuth::canMakeInBlog('ACCESS_ADMIN', $blog)) {
         $menu = getBlogAdminMenu($blog);
     }
     $tpl->assign('MENU', $menu);
     CopixHtmlHeader::addOthers('<link rel="alternate" href="' . CopixUrl::get('blog||rss', array("blog" => $blog->url_blog)) . '" type="application/rss+xml" title="' . htmlentities($blog->name_blog) . '" />');
     if ($blog->template) {
         $MAIN = $tpl->fetch($blog->template);
     } else {
         $MAIN = $tpl->fetch('blog_main.tpl');
     }
     $tpl->assign('MAIN', $MAIN);
     $tpl->assign('HEADER_MODE', 'compact');
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 /**
  * Validation d'une page.
  */
 public function doValidPage()
 {
     $id_blog = $this->getRequest('id_blog', null);
     $go = $this->getRequest('go', 'preview');
     //die ("go=$go");
     if ($id_blog == null) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.param'), 'back' => CopixUrl::get('blog|admin|listBlog')));
     }
     if (!BlogAuth::canMakeInBlog('ADMIN_PAGES', create_blog_object($id_blog))) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.cannotManagePage'), 'back' => CopixUrl::get('blog|admin|listBlog')));
     }
     $tpl = new CopixTpl();
     $showErrors = false;
     $pageDAO = CopixDAOFactory::create('blog|blogpage');
     $id_bpge = $this->getRequest('id_bpge', null);
     if (strlen($id_bpge) == 0) {
         $id_bpge = null;
     }
     // On r�cup�re l'utilisateur connect�
     $user = BlogAuth::getUserInfos();
     if ($id_bpge != null) {
         // EDITION D'UNE PAGE
         $page = $pageDAO->get($id_bpge);
         $this->_validFromPostProperties($page);
         $tpl->assign('TITLE_PAGE', CopixI18N::get('blog.get.edit.page.title'));
         $errors = _dao('blog|blogpage')->check($page);
         if ($errors != 1) {
             // Traitement des erreurs
             $showErrors = true;
         } elseif ($go == 'save') {
             // Modification dans la base
             $page->content_html_bpge = smarty_modifier_blog_format_article($page->content_bpge, $page->format_bpge);
             $pageDAO->update($page);
             return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('blog|admin|showBlog', array("id_blog" => $id_blog, "kind" => $this->getRequest('kind', '0'))));
         }
     } else {
         // CREATION D'UNE PAGE
         $page = CopixDAOFactory::createRecord('blogpage');
         $this->_validFromPostProperties($page);
         $page->order_bpge = $pageDAO->getNewPos($id_blog);
         $page->date_bpge = date('Ymd');
         $page->author_bpge = $user->userId;
         $tpl->assign('TITLE_PAGE', CopixI18N::get('blog.get.create.page.title'));
         $errors = _dao('blog|blogpage')->check($page);
         if ($errors != 1) {
             // Traitement des erreurs
             $showErrors = true;
         } elseif ($go == 'save') {
             // Insertion dans la base
             $page->content_html_bpge = smarty_modifier_blog_format_article($page->content_bpge, $page->format_bpge);
             $pageDAO->insert($page);
             $page->url_bpge = killBadUrlChars($page->id_bpge . '-' . $page->name_bpge);
             $pageDAO->update($page);
             //on vide la session
             //$this->_setSessionPage(null);
             return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('blog|admin|showBlog', array("id_blog" => $id_blog, "kind" => $this->getRequest('kind', '0'))));
         }
     }
     $tpl->assign('MAIN', CopixZone::process('EditPage', array('id_blog' => $id_blog, 'id_bpge' => $id_bpge, 'page' => $page, 'errors' => $errors, 'showErrors' => $showErrors, 'kind' => $this->getRequest('kind', '0'), 'preview' => $go == 'preview' ? 1 : 0)));
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 /**
  * Suppression des droits atribués à des membres sur un blog
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2007/06/04
  * @param integer $id Id du blog
  * @param integer $kind Numéro générique de la rubrique (ne pas y toucher)
  * @param array $membres Les membres à désinscrire (les valeurs sont de type USER_TYPE|USER_ID)
  */
 public function doUnsubscribe()
 {
     $id = $this->getRequest('id', null);
     $kind = $this->getRequest('kind', null);
     $membres = $this->getRequest('membres', array());
     $groupeService =& CopixClassesFactory::Create('groupe|groupeService');
     $blogDAO = CopixDAOFactory::create('blog|blog');
     $blog = $blogDAO->get($id);
     $errors = array();
     if (!$blog || !$kind) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.param'), 'back' => $blog ? CopixUrl::get('|', array('blog' => $blog->url_blog)) : CopixUrl::get('||')));
     }
     if (!BlogAuth::canMakeInBlog('ADMIN_DROITS', $blog)) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.cannotManageBlog'), 'back' => $blog ? CopixUrl::get('|', array('blog' => $blog->url_blog)) : CopixUrl::get('||')));
     }
     if (!$errors) {
         foreach ($membres as $membre) {
             list($user_type, $user_id) = explode("|", $membre);
             if ($user_type && $user_id) {
                 //print ("user_type=$user_type / user_id=$user_id");
                 Kernel::setLevel("MOD_BLOG", $id, $user_type, $user_id, 0);
                 CopixCache::clear($user_type . '-' . $user_id, 'getnodeparents');
                 CopixCache::clear($user_type . '-' . $user_id, 'getmynodes');
             }
         }
         $back = CopixUrl::get('blog|admin|showBlog', array("id_blog" => $id, 'kind' => $kind));
         return new CopixActionReturn(COPIX_AR_REDIRECT, $back);
     }
 }
 /**
  * Gestion des droits dans un blog
  *
  * Teste si l'usager peut effectuer une certaine opération par rapport à son droit. Le droit sur le blog est calculé ou récupéré de la session dans la fonction
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2007/05/31
  * @param string $action Action pour laquelle on veut tester le droit
  * @param object $r L'objet sur lequel on teste le droit
  * @return bool true s'il a le droit d'effectuer l'action, false sinon
  */
 public function canMakeInBlog($action, $r)
 {
     $can = false;
     if (!$r) {
         return false;
     }
     $userInfos = BlogAuth::getUserInfos($r->id_blog);
     //print_r($userInfos);
     $droit = $userInfos->right;
     // Kernel::deb("action=$action / droit=$droit / privacy=".$r->privacy);
     switch ($action) {
         case "READ":
             $can = $droit >= $r->privacy;
             if ($r->privacy == 10 && Kernel::is_connected()) {
                 $can = true;
             }
             break;
         case "ACCESS_ADMIN":
         case "ADMIN_ARTICLES":
         case "ADMIN_PHOTOS":
         case "ADMIN_DOCUMENTS":
             $can = $droit >= PROFILE_CCV_VALID;
             break;
         case "ADMIN_CATEGORIES":
         case "ADMIN_COMMENTS":
         case "ADMIN_LIENS":
         case "ADMIN_PAGES":
         case "ADMIN_RSS":
         case "ADMIN_ARTICLE_MAKE_ONLINE":
         case "ADMIN_ARTICLE_DELETE":
             $can = $droit >= PROFILE_CCV_MODERATE;
             //$can = false;
             break;
         case "ADMIN_OPTIONS":
         case "ADMIN_DROITS":
         case "ADMIN_STATS":
             $can = $droit >= PROFILE_CCV_ADMIN;
             break;
     }
     return $can;
 }
 public function getNotifications(&$module, &$lastvisit)
 {
     $lastvisit_date = substr($lastvisit->date, 0, 8);
     $lastvisit_time = substr($lastvisit->date, 8, 4);
     $blog = _dao('blog|blog')->get($module->module_id);
     if (BlogAuth::canMakeInBlog('ACCESS_ADMIN', $blog)) {
         // Si on est admin, recherche des nouveaux commentaires
         $new_comments = _dao('blog|blogarticlecomment')->findBy(_daoSp()->addCondition('id_blog', '=', $module->module_id)->addCondition('is_online', '=', 1)->addCondition('authorid_bacc', '!=', _currentUser()->getExtra("user_id"))->startGroup('AND')->addCondition('date_bacc', '>', $lastvisit_date)->startGroup('OR')->addCondition('date_bacc', '=', $lastvisit_date)->addCondition('time_bacc', '>=', $lastvisit_time, 'AND')->endGroup()->endGroup());
         $module->notification_number = count($new_comments);
         $module->notification_message = count($new_comments) . " commentaire" . (count($new_comments) > 1 ? "s" : "");
     } else {
         // Si on n'est pas admin, recherche des nouveaux articles
         $new_posts = _dao('blog|blogarticle')->findBy(_daoSp()->addCondition('id_blog', '=', $module->module_id)->addCondition('is_online', '=', 1)->addCondition('author_bact', '!=', _currentUser()->getExtra("user_id"))->startGroup('AND')->addCondition('date_bact', '>', $lastvisit_date)->startGroup('OR')->addCondition('date_bact', '=', $lastvisit_date)->addCondition('time_bact', '>=', $lastvisit_time, 'AND')->endGroup()->endGroup());
         $module->notification_number = count($new_posts);
         $module->notification_message = count($new_posts) . " article" . (count($new_posts) > 1 ? "s" : "");
     }
     return true;
 }
 /**
  * Suppression d'un article.
  */
 public function doDeleteArticle()
 {
     $id_bact = $this->getRequest('id_bact', null);
     $id_blog = $this->getRequest('id_blog', null);
     if ($id_bact == null) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.param'), 'back' => CopixUrl::get('blog|admin|listBlog')));
     }
     $articleDAO =& CopixDAOFactory::create('blog|blogarticle');
     if (!($toDelete = $articleDAO->get($id_bact))) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.cannotFindBlog'), 'back' => CopixUrl::get('blog|admin|listBlog')));
     }
     if (!BlogAuth::canMakeInBlog('ADMIN_ARTICLE_DELETE', create_blog_object($id_blog))) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('kernel|kernel.error.noRights'), 'back' => CopixUrl::get('blog||')));
     }
     $urlReturn = CopixUrl::get('blog|admin|showBlog', array('id_blog' => $id_blog, 'kind' => $this->getRequest('kind', '0'), 'selectCategory' => $this->getRequest('selectCategory', ''), 'selectMonth' => $this->getRequest('selectMonth', '')));
     if ($this->getRequest('confirm', null) != null) {
         $articleDAO->delete($toDelete);
         return new CopixActionReturn(COPIX_AR_REDIRECT, $urlReturn);
     }
     return CopixActionGroup::process('genericTools|messages::getConfirm', array('confirm' => CopixUrl::get('blog|admin|deleteArticle', array('id_bact' => $id_bact, 'id_blog' => $id_blog, 'kind' => $this->getRequest('kind', '0'), "selectCategory" => $this->getRequest('selectCategory', ''), "selectMonth" => $this->getRequest('selectMonth', ''), 'confirm' => 1)), 'cancel' => $urlReturn, 'message' => CopixI18N::get('blog.messages.confirmDeleteArticle'), 'title' => CopixI18N::get('blog.get.delete.article.title')));
 }