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;
 }
Exemple #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;
 }
Exemple #4
0
 public function store()
 {
     $msg = $this->check();
     if ($msg) {
         return 'CForumMessage::store-check failed ' . $msg;
     }
     $q = new DBQuery();
     if ($this->message_id) {
         // First we need to remove any forum visits for this message
         // otherwise nobody will see that it has changed.
         $q->setDelete('forum_visits');
         $q->addWhere('visit_message = ' . (int) $this->message_id);
         $q->exec();
         // No error if this fails, it is not important.
         $q->clear();
         $ret = $q->updateObject('forum_messages', $this, 'message_id', false);
         // ! Don't update null values
         $q->clear();
     } else {
         $date = new CDate();
         $this->message_date = $date->format(FMT_DATETIME_MYSQL);
         $new_id = $q->insertObject('forum_messages', $this, 'message_id');
         ## TODO handle error now
         echo db_error();
         ## TODO handle error better
         $q->clear();
         $q->addTable('forum_messages');
         $q->addQuery('count(message_id), MAX(message_date)');
         $q->addWhere('message_forum = ' . (int) $this->message_forum);
         $res = $q->exec();
         echo db_error();
         ## TODO handle error better
         $reply = $q->fetchRow();
         $q->clear();
         //update forum descriptor
         $forum = new CForum();
         $forum->forum_id = $this->message_forum;
         $forum->forum_message_count = $reply[0];
         $forum->forum_last_date = $reply[1];
         $forum->forum_last_id = $this->message_id;
         $forum->store();
         ## TODO handle error now
         return $this->sendWatchMail(false);
     }
     if (!$ret) {
         return 'CForumMessage::store failed ' . db_error();
     } else {
         return null;
     }
 }
<?php

if (!defined('W2P_BASE_DIR')) {
    die('You should not access this file directly.');
}
// @todo    convert to template
// @todo    I think this file should actually be named 'addedit_message.php'
$message_parent = (int) w2PgetParam($_GET, 'message_parent', -1);
$message_id = (int) w2PgetParam($_GET, 'message_id', 0);
$forum_id = (int) w2PgetParam($_REQUEST, 'forum_id', 0);
$myForum = new CForum();
$myForum->forum_id = $forum_id;
$obj = $myForum;
$canAddEdit = $obj->canAddEdit();
$canAdd = $obj->canCreate();
$canEdit = $obj->canEdit();
if (!$canAddEdit) {
    $AppUI->redirect(ACCESS_DENIED);
}
//Pull forum information
$myForum->load($forum_id);
if (!$myForum) {
    $AppUI->setMsg('Forum');
    $AppUI->setMsg('invalidID', UI_MSG_ERROR, true);
    $AppUI->redirect('m=forums');
}
// 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}";
<?php

$g =& CGroup::getInstance();
$fr =& CForum::getInstance();
if (isset($_GET['sort'])) {
    $sort = $_GET['sort'] == 'name' ? 0 : 1;
} else {
    $sort = 0;
}
$groups_array = $g->groups($_USER_ID, false, 'all', $sort);
$limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5;
?>

<script laguage="javascript">
  var _checked = ',';
</script>

<table border="0" cellpadding="0" cellspacing="0" width="545">
  <tr>
    <td><img src="images/pixel_md_grey.gif" height="1" width="545" border="0" /></td>
  </tr>
  <tr>
    <td background="images/pixel_lt_grey.gif" class="f_8 f_black">
      <table border="0" cellpadding="0" cellspacing="0" width="545">
        <tr>
          <td width="10"><img src="images/spacer.gif" width="10" height="15" border="0" /></td>
          <td align="left" valign="middle" width="370">You are currently active in <?php 
echo count($groups_array);
?>
 groups</td>
          <td align="right" valign="middle" width="50">sort by&nbsp;</td>
Exemple #7
0
<?php

if (!defined('W2P_BASE_DIR')) {
    die('You should not access this file directly.');
}
// @todo    convert to template
$object_id = (int) w2PgetParam($_GET, 'forum_id', 0);
$object = new CForum();
$object->setId($object_id);
$obj = $object;
$canAddEdit = $obj->canAddEdit();
$canAuthor = $obj->canCreate();
$canEdit = $obj->canEdit();
if (!$canAddEdit) {
    $AppUI->redirect(ACCESS_DENIED);
}
$obj = $AppUI->restoreObject();
if ($obj) {
    $object = $obj;
    $object_id = $object->getId();
} else {
    $object->load($object_id);
}
if (!$object && $object_id > 0) {
    $AppUI->setMsg('Forum');
    $AppUI->setMsg('invalidID', UI_MSG_ERROR, true);
    $AppUI->redirect('m=' . $m);
}
$status = isset($object->forum_status) ? $object->forum_status : -1;
$prj = new CProject();
if ($object_id) {
Exemple #8
0
 public function fetchAllForums($category)
 {
     $this->db->select('id,name,description,icon')->where('category', (int) $category)->order_by("id", "asc");
     $query = $this->db->get('website_forum_forums');
     $result = array();
     if ($query->rowCount() > 1) {
         $rows = $this->db->fetchAll($query);
         do {
             $row = $rows->current();
             $forum = new CForum();
             $forum->setName($row->name)->setID($row->id)->setDesc($row->description)->setIcon($row->icon);
             $result[] = $forum;
         } while ($rows->next());
     } else {
         if ($query->rowCount() == 1) {
             $row = $this->db->fetch($query);
             $forum = new CForum();
             $forum->setName($row->name)->setID($row->id)->setDesc($row->description)->setIcon($row->icon);
             $result[] = $forum;
         } else {
             $forum = new CForum();
             $forum->setID(0);
             $forum->setDesc('There are no forums into this category');
             $result[] = $forum;
         }
     }
     return $result;
 }
Exemple #9
0
<?php

/* $Id: view_pdf.php 1916 2011-05-10 06:01:01Z caseydk $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/tags/version2.4/modules/forums/view_pdf.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', $message_id)) {
    $AppUI->redirect('m=public&a=access_denied');
}
$forum = new CForum();
$forum->loadFull($AppUI, $forum_id);
$messages = $forum->getMessages($AppUI, $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';
$temp_dir = W2P_BASE_DIR . '/files/temp';
Exemple #10
0
//view posts
$forum_id = (int) w2PgetParam($_GET, 'forum_id', 0);
$message_id = (int) w2PgetParam($_GET, 'message_id', 0);
$post_message = (int) w2PgetParam($_GET, 'post_message', 0);
$f = w2PgetParam($_POST, 'f', 0);
// check permissions
$perms =& $AppUI->acl();
$canAuthor = canAdd('forums');
$canDelete = canDelete('forums');
$canRead = $perms->checkModuleItem('forums', 'view', $forum_id);
$canEdit = $perms->checkModuleItem('forums', 'edit', $forum_id);
$canAdminEdit = canEdit('admin');
if (!$canRead) {
    $AppUI->redirect('m=public&a=access_denied');
}
$forum = new CForum();
$forum->loadFull($AppUI, $forum_id);
if (!$forum) {
    $AppUI->setMsg('Forum');
    $AppUI->setMsg('invalidID', UI_MSG_ERROR, true);
    $AppUI->redirect();
} else {
    $AppUI->savePlace();
}
$df = $AppUI->getPref('SHDATEFORMAT');
$tf = $AppUI->getPref('TIMEFORMAT');
$start_date = $AppUI->formatTZAwareTime($forum->forum_create_date, $df);
// setup the title block
$titleBlock = new CTitleBlock('Forum', 'support.png', $m, $m . '.' . $a);
$titleBlock->addCell(arraySelect($filters, 'f', 'size="1" class="text" onchange="document.filterFrm.submit();"', $f, true), '', '<form action="?m=forums&a=viewer&forum_id=' . $forum_id . '" method="post" name="filterFrm" accept-charset="utf-8">', '</form>');
$titleBlock->show();
Exemple #11
0
    $AppUI->redirect('m=public&a=access_denied');
}
$AppUI->savePlace();
// retrieve any state parameters
if (isset($_GET['orderby'])) {
    $orderdir = $AppUI->getState('ForumIdxOrderDir') ? $AppUI->getState('ForumIdxOrderDir') == 'asc' ? 'desc' : 'asc' : 'desc';
    $AppUI->setState('ForumIdxOrderBy', w2PgetParam($_GET, 'orderby', null));
    $AppUI->setState('ForumIdxOrderDir', $orderdir);
}
$orderby = $AppUI->getState('ForumIdxOrderBy') ? $AppUI->getState('ForumIdxOrderBy') : 'forum_name';
$orderdir = $AppUI->getState('ForumIdxOrderDir') ? $AppUI->getState('ForumIdxOrderDir') : 'asc';
$perms =& $AppUI->acl();
$df = $AppUI->getPref('SHDATEFORMAT');
$tf = $AppUI->getPref('TIMEFORMAT');
$f = w2PgetParam($_POST, 'f', 0);
$forum = new CForum();
$project = new CProject();
$max_msg_length = 30;
/* Query modified by Fergus McDonald 2005/08/12 to address slow join issue */
$q = new DBQuery();
$q->addTable('forums');
$q->addTable('projects', 'pr');
$q->addTable('users', 'u');
$q->addQuery('forum_id, forum_project, forum_description, forum_owner, forum_name');
$q->addQuery('forum_moderated, forum_create_date, forum_last_date');
$q->addQuery('sum(if(c.message_parent=-1,1,0)) as forum_topics, sum(if(c.message_parent>0,1,0)) as forum_replies');
$q->addQuery('user_username, project_name, project_color_identifier, CONCAT(contact_first_name,\' \',contact_last_name) owner_name');
$q->addQuery('SUBSTRING(l.message_body,1,' . $max_msg_length . ') message_body');
$q->addQuery('LENGTH(l.message_body) message_length, watch_user, l.message_parent, l.message_id');
$q->addQuery('count(distinct v.visit_message) as visit_count, count(distinct c.message_id) as message_count');
$q->addJoin('forum_messages', 'l', 'l.message_id = forum_last_id');
Exemple #12
0
$isNotNew = $_POST['forum_id'];
$perms =& $AppUI->acl();
if ($del) {
    if (!$perms->checkModule('forums', 'delete')) {
        $AppUI->redirect('m=public&a=access_denied');
    }
} elseif ($isNotNew) {
    if (!$perms->checkModule('forums', 'edit')) {
        $AppUI->redirect('m=public&a=access_denied');
    }
} else {
    if (!$perms->checkModule('forums', 'add')) {
        $AppUI->redirect('m=public&a=access_denied');
    }
}
$obj = new CForum();
if ($msg = $obj->bind($_POST)) {
    $AppUI->setMsg($msg, UI_MSG_ERROR);
    $AppUI->redirect();
}
// prepare (and translate) the module name ready for the suffix
$AppUI->setMsg('Forum');
if ($del) {
    if ($msg = $obj->delete()) {
        $AppUI->setMsg($msg, UI_MSG_ERROR);
        $AppUI->redirect();
    } else {
        $AppUI->setMsg('deleted', UI_MSG_ALERT, true);
        $AppUI->redirect('m=forums');
    }
} else {
Exemple #13
0
<?php

if (!defined('W2P_BASE_DIR')) {
    die('You should not access this file directly');
}
// @todo    convert to template
$forum = new CForum();
$canRead = $forum->canView();
$canAdd = $forum->canCreate();
if (!$canRead) {
    $AppUI->redirect(ACCESS_DENIED);
}
// retrieve any state parameters
if (isset($_GET['orderby'])) {
    $orderdir = $AppUI->getState('ForumIdxOrderDir') ? $AppUI->getState('ForumIdxOrderDir') == 'asc' ? 'desc' : 'asc' : 'desc';
    $AppUI->setState('ForumIdxOrderBy', w2PgetParam($_GET, 'orderby', null));
    $AppUI->setState('ForumIdxOrderDir', $orderdir);
}
$orderby = $AppUI->getState('ForumIdxOrderBy') ? $AppUI->getState('ForumIdxOrderBy') : 'forum_name';
$orderdir = $AppUI->getState('ForumIdxOrderDir') ? $AppUI->getState('ForumIdxOrderDir') : 'asc';
$f = w2PgetParam($_REQUEST, 'f', 0);
$items = $forum->getAllowedForums($AppUI->user_id, $AppUI->user_company, $f, $orderby, $orderdir);
$filters = array('- Filters -');
if (isset($a) && $a == 'viewer') {
    array_push($filters, 'My Watched', 'Last 30 days');
} else {
    array_push($filters, 'My Forums', 'My Watched', 'My Projects', 'My Company', 'Inactive Projects');
}
// setup the title block
$titleBlock = new w2p_Theme_TitleBlock('Forums', 'icon.png', $m);
$titleBlock->addFilterCell('Filter', 'f', $filters, $f);
Exemple #14
0
if (!defined('W2P_BASE_DIR')) {
    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}";
    }
}
Exemple #15
0
<?php

/* $Id: view_messages.php 1517 2010-12-05 08:07:54Z caseydk $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/forums/view_messages.php $ */
if (!defined('W2P_BASE_DIR')) {
    die('You should not access this file directly.');
}
$AppUI->savePlace();
$sort = w2PgetParam($_REQUEST, 'sort', 'asc');
$viewtype = w2PgetParam($_REQUEST, 'viewtype', 'normal');
$hideEmail = w2PgetConfig('hide_email_addresses', false);
$forum = new CForum();
$messages = $forum->getMessages($AppUI, $forum_id, $message_id, $sort);
?>
<script language="javascript" type="text/javascript">
<?php 
if ($viewtype != 'normal') {
    ?>
	function toggle(id) {
        <?php 
    if ($viewtype == 'single') {
        ?>
		var elems = document.getElementsByTagName('div');
		for (var i=0, i_cmp=elems.length; i<i_cmp; i++)
			if (elems[i].className == 'message') {
				elems[i].style.display = 'none';
			}
			document.getElementById(id).style.display = 'block';

        <?php 
    } elseif ($viewtype == 'short') {
        ?>
Exemple #16
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';
Exemple #17
0
    $AppUI->redirect('m=public&a=access_denied');
}
$AppUI->savePlace();
// retrieve any state parameters
if (isset($_GET['orderby'])) {
    $orderdir = $AppUI->getState('ForumIdxOrderDir') ? $AppUI->getState('ForumIdxOrderDir') == 'asc' ? 'desc' : 'asc' : 'desc';
    $AppUI->setState('ForumIdxOrderBy', w2PgetParam($_GET, 'orderby', null));
    $AppUI->setState('ForumIdxOrderDir', $orderdir);
}
$orderby = $AppUI->getState('ForumIdxOrderBy') ? $AppUI->getState('ForumIdxOrderBy') : 'forum_name';
$orderdir = $AppUI->getState('ForumIdxOrderDir') ? $AppUI->getState('ForumIdxOrderDir') : 'asc';
$perms =& $AppUI->acl();
$df = $AppUI->getPref('SHDATEFORMAT');
$tf = $AppUI->getPref('TIMEFORMAT');
$f = w2PgetParam($_POST, 'f', 0);
$forum = new CForum();
$forums = $forum->getAllowedForums($AppUI->user_id, $AppUI->user_company, $f, $orderby, $orderdir);
// setup the title block
$titleBlock = new CTitleBlock('Forums', 'support.png', $m, $m . '.' . $a);
$titleBlock->addCell(arraySelect($filters, 'f', 'size="1" class="text" onChange="document.forum_filter.submit();"', $f, true), '', '<form name="forum_filter" action="?m=forums" method="post" accept-charset="utf-8">', '</form>');
$canAdd = canAdd($m);
if ($canAdd) {
    $titleBlock->addCell('<input type="submit" class="button" value="' . $AppUI->_('new forum') . '">', '', '<form action="?m=forums&a=addedit" method="post" accept-charset="utf-8">', '</form>');
}
$titleBlock->show();
?>

<form name="watcher" action="./index.php?m=forums&f=<?php 
echo $f;
?>
" method="post" accept-charset="utf-8">