Esempio n. 1
0
 public function store($unused = null)
 {
     $stored = false;
     $q = $this->_getQuery();
     if ($this->{$this->_tbl_key} && $this->canEdit()) {
         $q->setDelete('forum_visits');
         $q->addWhere('visit_message = ' . (int) $this->message_id);
         $q->exec();
         $stored = parent::store();
     }
     if (0 == $this->{$this->_tbl_key} && $this->canCreate()) {
         $this->message_date = $q->dbfnNowWithTZ();
         $stored = parent::store();
         if ($stored) {
             $q->addTable('forum_messages');
             $q->addQuery('count(message_id), MAX(message_date)');
             $q->addWhere('message_forum = ' . (int) $this->message_forum);
             $reply = $q->fetchRow();
             //update forum descriptor
             $forum = new CForum();
             $forum->overrideDatabase($this->_query);
             $forum->load($this->message_forum);
             $forum->forum_message_count = $reply[0];
             /*
              * Note: the message_date here has already been adjusted for the
              *    timezone above, so don't do it again!
              */
             $forum->forum_last_date = $this->message_date;
             $forum->forum_last_id = $this->message_id;
             $forum->store();
             $this->sendWatchMail(false);
         }
     }
     return $stored;
 }
Esempio n. 2
0
 public function store()
 {
     $stored = false;
     $this->_error = $this->check();
     if (count($this->_error)) {
         return $this->_error;
     }
     $q = $this->_getQuery();
     //TODO: this is an oddball permissions object where the module doesn't determine the access..
     if ($this->{$this->_tbl_key} && $this->_perms->checkModuleItem('forums', 'edit', $this->{$this->_tbl_module})) {
         $q->setDelete('forum_visits');
         $q->addWhere('visit_message = ' . (int) $this->message_id);
         $q->exec();
         if ($msg = parent::store()) {
             $this->_error['store'] = $msg;
         } else {
             $stored = true;
         }
     }
     if (0 == $this->{$this->_tbl_key} && $this->_perms->checkModuleItem('forums', 'add')) {
         $this->message_date = $q->dbfnNowWithTZ();
         if ($msg = parent::store()) {
             $this->_error['store'] = $msg;
         } else {
             $q->addTable('forum_messages');
             $q->addQuery('count(message_id), MAX(message_date)');
             $q->addWhere('message_forum = ' . (int) $this->message_forum);
             $reply = $q->fetchRow();
             //update forum descriptor
             $forum = new CForum();
             $forum->overrideDatabase($this->_query);
             $forum->load(null, $this->message_forum);
             $forum->forum_message_count = $reply[0];
             /*
              * Note: the message_date here has already been adjusted for the
              *    timezone above, so don't do it again!
              */
             $forum->forum_last_date = $this->message_date;
             $forum->forum_last_id = $this->message_id;
             $forum->store();
             $this->sendWatchMail(false);
             $stored = true;
         }
     }
     return $stored;
 }
 public function store(CAppUI $AppUI = null)
 {
     global $AppUI;
     $perms = $AppUI->acl();
     $stored = false;
     $this->_error = $this->check();
     if (count($this->_error)) {
         return $this->_error;
     }
     $q = new w2p_Database_Query();
     if ($this->message_id && $perms->checkModuleItem('forums', 'edit', $this->forum_id)) {
         $q->setDelete('forum_visits');
         $q->addWhere('visit_message = ' . (int) $this->message_id);
         $q->exec();
         if ($msg = parent::store()) {
             return $msg;
         }
         $stored = true;
     }
     if (0 == $this->message_id && $perms->checkModuleItem('forums', 'add')) {
         $this->message_date = $q->dbfnNowWithTZ();
         if ($msg = parent::store()) {
             return $msg;
         }
         $q->addTable('forum_messages');
         $q->addQuery('count(message_id), MAX(message_date)');
         $q->addWhere('message_forum = ' . (int) $this->message_forum);
         $reply = $q->fetchRow();
         //update forum descriptor
         $forum = new CForum();
         $forum->load($AppUI, $this->message_forum);
         $forum->forum_message_count = $reply[0];
         /*
          * Note: the message_date here has already been adjusted for the
          *    timezone above, so don't do it again!
          */
         $forum->forum_last_date = $this->message_date;
         $forum->forum_last_id = $this->message_id;
         $forum->store($AppUI);
         $this->sendWatchMail(false);
         $stored = true;
     }
     return $stored;
 }
Esempio n. 4
0
<?php

if (!defined('W2P_BASE_DIR')) {
    die('You should not call this file directly.');
}
$sort = w2PgetParam($_REQUEST, 'sort', 'asc');
$forum_id = w2PgetParam($_REQUEST, 'forum_id', 0);
$message_id = w2PgetParam($_REQUEST, 'message_id', 0);
$perms =& $AppUI->acl();
if (!$perms->checkModuleItem('forums', 'view', $forum_id)) {
    $AppUI->redirect(ACCESS_DENIED);
}
$forum = new CForum();
$forum->load($forum_id);
$project = new CProject();
$project->load($forum->forum_project);
$messages = $forum->getMessages(null, $forum_id, $message_id, $sort);
// get the prefered date format
$df = $AppUI->getPref('SHDATEFORMAT');
$df .= ' ' . $AppUI->getPref('TIMEFORMAT');
$pdfdata = array();
$pdfhead = array('Date', 'User', 'Message');
foreach ($messages as $row) {
    // Find the parent message - the topic.
    if ($row['message_id'] == $message_id) {
        $topic = $row['message_title'];
    }
    $date = new w2p_Utilities_Date($AppUI->formatTZAwareTime($row['message_date'], '%Y-%m-%d %T'));
    $pdfdata[] = array($date->format($df), $row['contact_display_name'], '<b>' . $row['message_title'] . '</b>' . "\n" . $row['message_body']);
}
$font_dir = W2P_BASE_DIR . '/lib/ezpdf/fonts';
Esempio n. 5
0
    die('You should not access this file directly.');
}
// Add / Edit forum
$message_parent = (int) w2PgetParam($_GET, 'message_parent', -1);
$message_id = (int) w2PgetParam($_GET, 'message_id', 0);
$forum_id = (int) w2PgetParam($_REQUEST, 'forum_id', 0);
$perms =& $AppUI->acl();
$canAdd = $perms->checkModuleItem('forums', 'add');
$canEdit = $perms->checkModuleItem('forums', 'edit', $forum_id);
// check permissions
if (!$canEdit && !$canAdd) {
    $AppUI->redirect('m=public&a=access_denied');
}
//Pull forum information
$myForum = new CForum();
$myForum->load($AppUI, $forum_id);
if (!$myForum) {
    $AppUI->setMsg('Forum');
    $AppUI->setMsg('invalidID', UI_MSG_ERROR, true);
    $AppUI->redirect('m=forums');
} else {
    $AppUI->savePlace();
}
// Build a back-url for when the back button is pressed
$back_url_params = array();
foreach ($_GET as $k => $v) {
    if ($k != 'post_message') {
        $back_url_params[] = "{$k}={$v}";
    }
}
$back_url = implode('&', $back_url_params);