|
From: <dts...@us...> - 2003-06-03 22:27:07
|
Update of /cvsroot/phpwebsite-comm/modules/phpwsbb/class
In directory sc8-pr-cvs1:/tmp/cvs-serv9050/class
Modified Files:
Manager.php Message.php Thread.php
Log Message:
Got message deletion working
Index: Manager.php
===================================================================
RCS file: /cvsroot/phpwebsite-comm/modules/phpwsbb/class/Manager.php,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** Manager.php 3 Jun 2003 21:54:28 -0000 1.12
--- Manager.php 3 Jun 2003 22:16:08 -0000 1.13
***************
*** 84,87 ****
--- 84,93 ----
$_REQUEST["PHPWSBB_MESSAGE_OP"] = "edit";
}// END FUNC _new
+
+
+ function _edit() {
+ $this->message = new PHPWSBB_Message($_REQUEST["PHPWS_MAN_ITEMS"][0]);
+ $_REQUEST["PHPWSBB_MESSAGE_OP"] = "edit";
+ }
***************
*** 121,124 ****
--- 127,134 ----
case "reply":
$this->_reply();
+ break;
+
+ case "deletemessage":
+ $this->_deleteMessage();
break;
Index: Message.php
===================================================================
RCS file: /cvsroot/phpwebsite-comm/modules/phpwsbb/class/Message.php,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** Message.php 3 Jun 2003 21:54:28 -0000 1.12
--- Message.php 3 Jun 2003 22:16:08 -0000 1.13
***************
*** 79,85 ****
$tags["POSTED"] = $_SESSION["translate"]->it("Posted by [var1] on [var2]", $poster, $this->getCreated());
!
! if(!empty($this->_tid))
! $tags["REPLY"] = "<a href=\"./index.php?module=phpwsbb&PHPWSBB_MAN_OP=reply&PHPWS_MAN_ITEMS[]=" . $this->_tid . "\">" . $_SESSION["translate"]->it("Reply to Message") . "</a>";
return $GLOBALS["core"]->processTemplate($tags, "phpwsbb", "view.tpl");
--- 79,86 ----
$tags["POSTED"] = $_SESSION["translate"]->it("Posted by [var1] on [var2]", $poster, $this->getCreated());
! if($_SESSION["OBJ_user"]->allow_access("phpwsbb", "edit_messages") || ($_SESSION["OBJ_user"]->username == $this->getOwner())) {
! $tags["EDIT"] = "<a href=\"./index.php?module=phpwsbb&PHPWSBB_MAN_OP=edit&PHPWS_MAN_ITEMS[]=" . $this->getId() . "\">" . $_SESSION["translate"]->it("Edit") . "</a>";
! $tags["DELETE"] = "<a href=\"./index.php?module=phpwsbb&PHPWSBB_MAN_OP=deletemessage&PHPWS_MAN_ITEMS[]=" . $this->getId() . "\">" . $_SESSION["translate"]->it("Delete") . "</a>";
! }
return $GLOBALS["core"]->processTemplate($tags, "phpwsbb", "view.tpl");
***************
*** 89,93 ****
function _edit() {
! if(!empty($this->_id) && !$_SESSION["OBJ_user"]->allow_access("phpwsbb", "edit_messages")) {
//$_REQUEST["PHPWSBB_MAN_OP"] = "access_denied";
//$_SESSION["PHPWSBB_Manager"]->action();
--- 90,94 ----
function _edit() {
! if(!empty($this->_id) && !$_SESSION["OBJ_user"]->allow_access("phpwsbb", "edit_messages") && ($_SESSION["OBJ_user"]->username != $this->getOwner())) {
//$_REQUEST["PHPWSBB_MAN_OP"] = "access_denied";
//$_SESSION["PHPWSBB_Manager"]->action();
***************
*** 161,165 ****
function _save() {
! if(!empty($this->_id) && !$_SESSION["OBJ_user"]->allow_access("phpwsbb", "edit_messages")) {
$message = $_SESSION["translate"]->it("Access to save message $this->_id was denied due to lack of proper permissions.");
$error = new PHPWS_Error("phpwsbb", "PHPWSBB_Manager::_accessDenied()", $message, "exit", 1);
--- 162,166 ----
function _save() {
! if(!empty($this->_id) && !$_SESSION["OBJ_user"]->allow_access("phpwsbb", "edit_messages") && ($_SESSION["OBJ_user"]->username != $this->getOwner())) {
$message = $_SESSION["translate"]->it("Access to save message $this->_id was denied due to lack of proper permissions.");
$error = new PHPWS_Error("phpwsbb", "PHPWSBB_Manager::_accessDenied()", $message, "exit", 1);
***************
*** 205,209 ****
// Update thread object with new statistics
$thread = new PHPWSBB_Thread($this->_tid);
! $thread->updateThreadStats();
$_REQUEST["PHPWSBB_THREAD_OP"] = "view";
--- 206,210 ----
// Update thread object with new statistics
$thread = new PHPWSBB_Thread($this->_tid);
! $thread->updateThread();
$_REQUEST["PHPWSBB_THREAD_OP"] = "view";
***************
*** 213,216 ****
--- 214,267 ----
+ function _delete() {
+ if(!$_SESSION["OBJ_user"]->allow_access("phpwsbb", "delete_messages") && ($_SESSION["OBJ_user"]->username != $this->getOwner())) {
+ $message = $_SESSION["translate"]->it("Access to delete this message was denied due to lack of proper permissions.");
+ $error = new PHWPS_Error("phpwsbb", "PHPWSBB_Message::_delete()", $message, "exit", 1);
+ $error->message();
+ return FALSE;
+ }
+
+ if(isset($_REQUEST["Message_yes"])) {
+ $this->kill();
+
+ // Update thread object with new statistics
+ $thread = new PHPWSBB_Thread($this->_tid);
+ $thread->updateThread();
+
+ $message = $_SESSION["translate"]->it("The message [var1] by [var2] was successfully deleted from the database.", "<b><i>" . $this->getLabel() . "</i></b>", $this->getOwner());
+ $_SESSION["PHPWSBB_Manager"]->notice = new PHPWS_Message($message, "CNT_phpwsbb");
+ //$_REQUEST["PHPWS_MAN_ITEMS"][] = $this->_tid;
+ $_REQUEST["PHPWSBB_MAN_OP"] = "list";
+ $_SESSION["PHPWSBB_Manager"]->action();
+ $_SESSION["PHPWSBB_Manager"]->managerAction();
+
+ } elseif(isset($_REQUEST["Message_no"])) {
+ $message = $_SESSION["translate"]->it("No message was deleted from the database.");
+ $_SESSION["PHPWSBB_Manager"]->notice = new PHPWS_Message($message, "CNT_phpwsbb");
+ //$_REQUEST["PHPWS_MAN_ITEMS"][0] = $this->_tid;
+ $_REQUEST["PHPWSBB_MAN_OP"] = "list";
+ $_SESSION["PHPWSBB_Manager"]->action();
+ $_SESSION["PHPWSBB_Manager"]->managerAction();
+
+ } else {
+ $title = $_SESSION["translate"]->it("Delete Message Confirmation");
+
+ $form = new EZform("PHPWSBB_Message_delete");
+ $form->add("module", "hidden", "phpwsbb");
+ $form->add("PHPWSBB_MESSAGE_OP", "hidden", "delete");
+
+ $form->add("Message_yes", "submit", $_SESSION["translate"]->it("Yes"));
+ $form->add("Message_no", "submit", $_SESSION["translate"]->it("No"));
+
+ $tags = array();
+ $tags = $form->getTemplate();
+ $tags["MESSAGE"] = $_SESSION["translate"]->it("Are you sure you want to delete this message?");
+
+ $content = $GLOBALS["core"]->processTemplate($tags, "phpwsbb", "delete_message.tpl");
+ $_SESSION["OBJ_layout"]->popbox($title, $content, NULL, "CNT_phpwsbb");
+ }
+ }// END FUNC _delete
+
+
function action() {
switch($_REQUEST["PHPWSBB_MESSAGE_OP"]) {
***************
*** 234,237 ****
--- 285,290 ----
break;
case "delete":
+ $this->_delete($this->_tid);
+ break;
case "fork":
case "lock":
Index: Thread.php
===================================================================
RCS file: /cvsroot/phpwebsite-comm/modules/phpwsbb/class/Thread.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Thread.php 3 Jun 2003 21:13:26 -0000 1.3
--- Thread.php 3 Jun 2003 22:16:08 -0000 1.4
***************
*** 87,95 ****
! function updateThreadStats() {
if(!empty($this->_id)) {
$sql = "SELECT id FROM " . $GLOBALS["core"]->tbl_prefix . "mod_phpwsbb_messages WHERE tid=" . $this->getId() . " ORDER BY created;";
$this->messages = $GLOBALS["core"]->getCol($sql);
$this->_replies = count($this->messages) - 1;
} else {
$this->_replies = 0;
--- 87,103 ----
! function updateThread() {
if(!empty($this->_id)) {
$sql = "SELECT id FROM " . $GLOBALS["core"]->tbl_prefix . "mod_phpwsbb_messages WHERE tid=" . $this->getId() . " ORDER BY created;";
$this->messages = $GLOBALS["core"]->getCol($sql);
$this->_replies = count($this->messages) - 1;
+ if($this->_replies < 0) {
+ /*
+ * This means the only message in the thread was deleted via
+ * the message delete inteface. Kill this thread.
+ */
+ $this->kill();
+ return;
+ }
} else {
$this->_replies = 0;
|