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; }
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; }
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; } }
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 { if ($msg = $obj->store()) { $AppUI->setMsg($msg, UI_MSG_ERROR); } else { $AppUI->setMsg($isNotNew ? 'updated' : 'added', UI_MSG_OK, true); } $AppUI->redirect(); }