/** * Pr�paration � l'affichage de la liste des commentaires. */ public function getListComment() { $id_bact = $this->getRequest('id_bact', null); $id_blog = $this->getRequest('id_blog', ''); if ($id_bact == null) { return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.param'), 'back' => CopixUrl::get('blog|admin|listBlog'))); } if (!BlogAuth::canMakeInBlog('ADMIN_ARTICLES', create_blog_object($id_blog))) { return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('kernel|kernel.error.noRights'), 'back' => CopixUrl::get('blog||'))); } // Recherche de tous les commentaires de la base $commentDAO = CopixDAOFactory::create('blog|blogarticlecomment'); $res = $commentDAO->findCommentOrderBy($id_bact, NULL); $resultats = array(); foreach ($res as $r) { $r->time_bacc = BDToTime($r->time_bacc); array_push($resultats, $r); } // On r�cup�re l'utilisateur connect� $user = BlogAuth::getUserInfos(); $toEdit = CopixDAOFactory::createRecord('blogarticlecomment'); $toEdit->authorid_bacc = $user->userId; $toEdit->authorname_bacc = $user->name; $toEdit->authoremail_bacc = $user->email; $toEdit->authorweb_bacc = $user->web; $tpl = new CopixTpl(); $tpl->assign('TITLE_PAGE', CopixI18N::get('blog.get.list.comment.title')); //creation of blog object for menu $blogDAO = CopixDAOFactory::create('blog|blog'); $blog = $blogDAO->get($id_blog); $menu = getBlogAdminMenu($blog); $tpl->assign('MENU', $menu); $tpl->assign('MAIN', CopixZone::process('ListComment', array('resultats' => $resultats, 'id_bact' => $id_bact, 'id_blog' => $id_blog, 'toEdit' => $toEdit))); 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; }
/** * 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); }
/** * Validation d'un article. */ public function doValidArticle() { CopixHTMLHeader::addJSLink(_resource("js/jquery/jquery.ui.datepicker-fr.js")); $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_ARTICLES', 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(); // On r�cup�re l'utilisateur connect� $user = BlogAuth::getUserInfos(); $articleDAO = CopixDAOFactory::create('blog|blogarticle'); // Cat�gories coch�es... $tabSelectCat = array(); if (_request('tabSelectCat')) { $tabSelectCat = (array) _request('tabSelectCat'); } $id_bact = $this->getRequest('id_bact', null); if (strlen($id_bact) == 0) { $id_bact = null; } $showErrors = false; if ($id_bact != null) { // EDITION D'UN ARTICLE $article = $articleDAO->get($id_bact); $this->_validFromPostProperties($article); if (!$article->date_bact) { $article->date_bact = date('d/m/Y'); } if (!$article->time_bact) { $article->time_bact = date('H:i'); } $article->date_bact = CopixDateTime::dateToTimestamp($article->date_bact); $article->time_bact = timeToBD($article->time_bact); $article->author_bact = $user->userId; $tpl->assign('TITLE_PAGE', CopixI18N::get('blog.get.edit.article.title')); //print_r($article); $errors = $articleDAO->check($article); if (count($tabSelectCat) == 0) { $errors = array(); array_push($errors, CopixI18N::get('blog.error.nocategoryselect')); } if ($errors != 1) { // Traitement des erreurs $showErrors = true; } elseif ($go == 'save') { // Modification dans la base $article->url_bact = killBadUrlChars($article->id_bact . '-' . $article->name_bact); $article->sumary_html_bact = smarty_modifier_blog_format_article($article->sumary_bact, $article->format_bact); $article->content_html_bact = smarty_modifier_blog_format_article($article->content_bact, $article->format_bact); $articleDAO->update($article); // Insertion dans la base blogarticle_blogarticlecategory $artctgDAO = CopixDAOFactory::create('blog|blogarticle_blogarticlecategory'); $artctgDAO->deleteAndInsert($article->id_bact, $tabSelectCat); return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('blog|admin|showBlog', array("id_blog" => $id_blog, "kind" => $this->getRequest('kind', '0')))); } } else { // CREATION D'UN ARTICLE $article = CopixDAOFactory::createRecord('blogarticle'); $this->_validFromPostProperties($article); if (!$article->date_bact) { $article->date_bact = date('d/m/Y'); } if (!$article->time_bact) { $article->time_bact = date('H:i'); } $article->date_bact = CopixDateTime::dateToTimestamp($article->date_bact); $article->time_bact = timeToBD($article->time_bact); $article->author_bact = $user->userId; $tpl->assign('TITLE_PAGE', CopixI18N::get('blog.get.create.article.title')); $errors = $articleDAO->check($article); if (count($tabSelectCat) == 0) { $errors = array(); array_push($errors, CopixI18N::get('blog.error.nocategoryselect')); } if ($errors != 1) { // Traitement des erreurs $showErrors = true; } elseif ($go == 'save') { // Insertion dans la base $article->sumary_html_bact = smarty_modifier_blog_format_article($article->sumary_bact, $article->format_bact); $article->content_html_bact = smarty_modifier_blog_format_article($article->content_bact, $article->format_bact); $articleDAO->insert($article); $article->url_bact = killBadUrlChars($article->id_bact . '-' . $article->name_bact); $articleDAO->update($article); // Insertion dans la base blogarticle_blogarticlecategory $artctgDAO = CopixDAOFactory::create('blog|blogarticle_blogarticlecategory'); $artctgDAO->deleteAndInsert($article->id_bact, $tabSelectCat); return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('blog|admin|showBlog', array("id_blog" => $id_blog, "kind" => $this->getRequest('kind', '0')))); } } // Pr�paration du filtre CATEGORIES $blogArticleCategoryDAO = CopixDAOFactory::create('blog|blogarticlecategory'); $resArticleCategory = $blogArticleCategoryDAO->findAllOrder($id_blog); $tabArticleCategory = array(); foreach ($resArticleCategory as $cat) { if (in_array($cat->id_bacg, $tabSelectCat)) { $cat->selected = true; } else { $cat->selected = false; } array_push($tabArticleCategory, $cat); } $article->time_bact = BDToTime($article->time_bact); $tpl->assign('BODY_ON_LOAD', "setDatePicker('#date_bact')"); $tpl->assign('MAIN', CopixZone::process('EditArticle', array('id_blog' => $id_blog, 'id_bact' => $id_bact, 'article' => $article, 'kind' => $this->getRequest('kind', '0'), 'errors' => $errors, 'showErrors' => $showErrors, 'tabArticleCategory' => $tabArticleCategory, 'preview' => $go == 'preview' ? 1 : 0))); return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl); }
/** * 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; }