Example #1
0
File: Panel.php Project: ssrsfs/blg
 public function output(Pagemill_Data $data, Pagemill_Stream $stream)
 {
     if (self::$_loaded) {
         return '';
     }
     self::$_loaded = true;
     if (defined('COMMENTS_DISABLED') && COMMENTS_DISABLED) {
         return '';
     }
     $data = $data->fork();
     $urlmeta = Model_UrlMeta::GetUrl();
     if (!$urlmeta->exists()) {
         return '';
     }
     $commeta = Model_Comment_Meta::Get($urlmeta['id']);
     if (!$commeta->exists()) {
         $commeta['urlmetaid'] = $urlmeta['id'];
         $commeta->save();
     } else {
         if ($commeta['closed']) {
             $pm->setVariable('comments_closed', true);
         }
     }
     $data->set('meta', $commeta);
     $comments = new Model_Comment();
     $comments->where('urlmetaid = ?', $urlmeta['id']);
     if (defined('COMMENTS_REQUIRE_APPROVAL') && 1 == COMMENTS_REQUIRE_APPROVAL) {
         $comments->where('approved = 1');
     }
     $comments->order('datecreated ASC');
     $data->set('comments', $comments);
     $data->set('comments_require_captcha', COMMENTS_REQUIRE_CAPTCHA);
     parent::output($data, $stream);
 }
Example #2
0
<?php

if (defined('COMMENTS_DISABLED') && COMMENTS_DISABLED) {
    Typeframe::Redirect('Comments are disabled.', TYPEF_WEB_DIR . '/', -1);
    return;
}
if (defined('COMMENTS_REQUIRE_CAPTCHA')) {
    $pm->setVariable('comments_require_captcha', COMMENTS_REQUIRE_CAPTCHA);
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    //$section = Model_Comment_Section::Get($_POST['sectionid']);
    $section = Model_Comment_Meta::Get($_POST['urlmetaid']);
    if (!$section->exists()) {
        Typeframe::Redirect('Comments are not available at the location specified.', TYPEF_WEB_DIR . '/', -1);
        return;
    }
    $pm->setVariable('meta', $section);
    if ($section['closed']) {
        Typeframe::Redirect('Comments on this page are closed.', TYPEF_WEB_DIR . '/', -1);
        return;
    }
    $form = new Form_Handler_Comment();
    if ($form->validate()) {
        $badCaptcha = false;
        if (defined('COMMENTS_REQUIRE_CAPTCHA') && COMMENTS_REQUIRE_CAPTCHA && !Typeframe::User()->loggedIn()) {
            if (!isset($_SESSION['captcha']) || empty($_SESSION['captcha']) || !isset($_POST['captcha']) || $_POST['captcha'] != $_SESSION['captcha']) {
                $badCaptcha = true;
            }
        }
        if ($badCaptcha) {
            $pm->addLoop('errors', array('message' => 'Captcha code was incorrect.'));
Example #3
0
<?php

/*
	Comments Section admin toggle (open/close) controller

	24 march 2011: cleaned up
	29 march 2011: moved some code to CommentSection class
	2 april 2011: fixed a minor typo (extra parenthesis)
	4 april 2011: added extra check to validate opened/closed
*/
// back link
$back = Plugin_Breadcrumbs::SavedState(TYPEF_WEB_DIR . '/admin/comments');
// can only process POSTs
if ('POST' != $_SERVER['REQUEST_METHOD']) {
    Typeframe::Redirect('Nothing to do.', $back);
    return;
}
// toggle closed flag
//CommentSection::ToggleClosed(@$_POST['sectionid']);
// done
$meta = Model_Comment_Meta::Get($_POST['urlmetaid']);
$meta['closed'] = $_POST['open'] != 'true';
$meta->save();
$mode = isset($_POST['open']) && 'true' == $_POST['open'] ? 'opened' : 'closed';
Typeframe::Redirect("Comment section {$mode}.", $back);