Thread: [Isocial-svn] SF.net SVN: isocial: [48] app/controllers/message_controller.php
Status: Pre-Alpha
Brought to you by:
aguidrevitch
From: <agu...@us...> - 2008-03-09 12:53:12
|
Revision: 48 http://isocial.svn.sourceforge.net/isocial/?rev=48&view=rev Author: aguidrevitch Date: 2008-03-09 05:53:18 -0700 (Sun, 09 Mar 2008) Log Message: ----------- unread message count updated Modified Paths: -------------- app/controllers/message_controller.php Modified: app/controllers/message_controller.php =================================================================== --- app/controllers/message_controller.php 2008-03-09 12:49:47 UTC (rev 47) +++ app/controllers/message_controller.php 2008-03-09 12:53:18 UTC (rev 48) @@ -117,9 +117,8 @@ } function inbox_count () { - $messages = $this->Message->find('all', array('conditions' => array('is_read' => '0'))); - return $this->render(array('partial' =>'count', - 'locals' => array('count' => count($messages)))); + $this->count = $this->Message->count('id', array('conditions' => array("recipient_id = ? AND is_read = 0", $this->current_user->getId()))); + return $this->render(array('partial' =>'count')); } function mark_unread () { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <agu...@us...> - 2008-03-09 13:06:18
|
Revision: 49 http://isocial.svn.sourceforge.net/isocial/?rev=49&view=rev Author: aguidrevitch Date: 2008-03-09 06:06:23 -0700 (Sun, 09 Mar 2008) Log Message: ----------- recipient is required field for message Modified Paths: -------------- app/controllers/message_controller.php Modified: app/controllers/message_controller.php =================================================================== --- app/controllers/message_controller.php 2008-03-09 12:53:18 UTC (rev 48) +++ app/controllers/message_controller.php 2008-03-09 13:06:23 UTC (rev 49) @@ -49,12 +49,18 @@ } function send () { - if (!empty($this->params['message'])){ + if (!empty($this->params['message']) && + !empty($this->params['message']['recipient']) && + !empty($this->params['message']['body'])) { $recipient = $this->User->findFirst(array( 'id' => $this->params['message']['recipient'] )); if ($recipient) { $message = $this->current_user->outbox_message->build(); + $message->setAttributes($this->params['message']); $message->recipient->assign($recipient); - $message->setAttributes($this->params['message']); + if (empty($message->subject)) { + $message->subject = $this->t('(no subject)'); + } + if ($message->save()) { if (!$message->thread_id) { $message->thread_id = $message->getId(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <di...@us...> - 2008-03-09 14:16:30
|
Revision: 51 http://isocial.svn.sourceforge.net/isocial/?rev=51&view=rev Author: dim0s77 Date: 2008-03-09 07:16:35 -0700 (Sun, 09 Mar 2008) Log Message: ----------- fix message_threads calculation Modified Paths: -------------- app/controllers/message_controller.php Modified: app/controllers/message_controller.php =================================================================== --- app/controllers/message_controller.php 2008-03-09 13:53:21 UTC (rev 50) +++ app/controllers/message_controller.php 2008-03-09 14:16:35 UTC (rev 51) @@ -10,14 +10,10 @@ function inbox () { $this->inbox_messages = $this->_getBoxMessages('inbox_message'); - $this->message_threads = $this->Message->count('thread_id', array('distinct' => 'thread_id', - 'conditions' => "sender_id = " . $this->current_user->getId())); } function outbox () { $this->outbox_messages = $this->_getBoxMessages('outbox_message'); - $this->message_threads = $this->Message->count('thread_id', array('distinct' => 'thread_id', - 'conditions' => "recipient_id = " . $this->current_user->getId())); } function _getBoxMessages ($box_message) { @@ -30,6 +26,9 @@ } } } + $user_id = $box_message == 'inbox_message' ? 'sender_id' : 'recipient_id'; + $this->message_threads = $this->Message->count('thread_id', array('distinct' => 'thread_id', + 'conditions' => "$user_id = " . $this->current_user->getId())); return $box_messages; } @@ -143,7 +142,7 @@ } } return $this->render(array('partial' => 'rows', - 'locals' => array('messages' => $this->_getInboxMessages(), + 'locals' => array('messages' => $this->_getBoxMessages('inbox_message'), 'target' => 'sender'))); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <agu...@us...> - 2008-03-11 19:54:12
|
Revision: 64 http://isocial.svn.sourceforge.net/isocial/?rev=64&view=rev Author: aguidrevitch Date: 2008-03-11 12:54:15 -0700 (Tue, 11 Mar 2008) Log Message: ----------- deletion problems fixed, try 2 Modified Paths: -------------- app/controllers/message_controller.php Modified: app/controllers/message_controller.php =================================================================== --- app/controllers/message_controller.php 2008-03-11 19:52:18 UTC (rev 63) +++ app/controllers/message_controller.php 2008-03-11 19:54:15 UTC (rev 64) @@ -170,7 +170,7 @@ foreach ($threads as $thread_loop_key => $thread) { $is_del = $thread->sender_id == $this->current_user->getId() ? 'is_sender_del' : 'is_recipient_del'; $this->Message->updateAll("$is_del = 1", "thread_id = " . $thread->thread_id); - $this->Message->destroyAll("is_sender_del = 1 AND is_recipient_del = 1", "thread_id = " . $thread->thread_id); + $this->Message->destroyAll("is_sender_del = 1 AND is_recipient_del = 1 AND thread_id = " . $thread->thread_id); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <agu...@us...> - 2008-03-11 20:02:20
|
Revision: 65 http://isocial.svn.sourceforge.net/isocial/?rev=65&view=rev Author: aguidrevitch Date: 2008-03-11 13:02:15 -0700 (Tue, 11 Mar 2008) Log Message: ----------- deletion problems fixed, try 3 Modified Paths: -------------- app/controllers/message_controller.php Modified: app/controllers/message_controller.php =================================================================== --- app/controllers/message_controller.php 2008-03-11 19:54:15 UTC (rev 64) +++ app/controllers/message_controller.php 2008-03-11 20:02:15 UTC (rev 65) @@ -168,8 +168,10 @@ ); if ($threads) { foreach ($threads as $thread_loop_key => $thread) { - $is_del = $thread->sender_id == $this->current_user->getId() ? 'is_sender_del' : 'is_recipient_del'; - $this->Message->updateAll("$is_del = 1", "thread_id = " . $thread->thread_id); + list($user_col, $del_col) = $thread->sender_id == $this->current_user->getId() + ? array('sender_id', 'is_sender_del') + : array('recipient_id', 'is_recipient_del'); + $this->Message->updateAll("$del_col = 1", "$user_col = " . $this->current_user->getId() . " AND thread_id = " . $thread->thread_id); $this->Message->destroyAll("is_sender_del = 1 AND is_recipient_del = 1 AND thread_id = " . $thread->thread_id); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <agu...@us...> - 2008-03-11 20:06:45
|
Revision: 66 http://isocial.svn.sourceforge.net/isocial/?rev=66&view=rev Author: aguidrevitch Date: 2008-03-11 13:05:46 -0700 (Tue, 11 Mar 2008) Log Message: ----------- deletion problems fixed, try 4 Modified Paths: -------------- app/controllers/message_controller.php Modified: app/controllers/message_controller.php =================================================================== --- app/controllers/message_controller.php 2008-03-11 20:02:15 UTC (rev 65) +++ app/controllers/message_controller.php 2008-03-11 20:05:46 UTC (rev 66) @@ -168,10 +168,8 @@ ); if ($threads) { foreach ($threads as $thread_loop_key => $thread) { - list($user_col, $del_col) = $thread->sender_id == $this->current_user->getId() - ? array('sender_id', 'is_sender_del') - : array('recipient_id', 'is_recipient_del'); - $this->Message->updateAll("$del_col = 1", "$user_col = " . $this->current_user->getId() . " AND thread_id = " . $thread->thread_id); + $this->Message->updateAll("is_sender_del = 1", "sender_id = " . $this->current_user->getId() . " AND thread_id = " . $thread->thread_id); + $this->Message->updateAll("is_recipient_del = 1", "recipient_id = " . $this->current_user->getId() . " AND thread_id = " . $thread->thread_id); $this->Message->destroyAll("is_sender_del = 1 AND is_recipient_del = 1 AND thread_id = " . $thread->thread_id); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <agu...@us...> - 2008-03-11 20:07:07
|
Revision: 63 http://isocial.svn.sourceforge.net/isocial/?rev=63&view=rev Author: aguidrevitch Date: 2008-03-11 12:52:18 -0700 (Tue, 11 Mar 2008) Log Message: ----------- deletion problems fixed Modified Paths: -------------- app/controllers/message_controller.php Modified: app/controllers/message_controller.php =================================================================== --- app/controllers/message_controller.php 2008-03-11 19:36:02 UTC (rev 62) +++ app/controllers/message_controller.php 2008-03-11 19:52:18 UTC (rev 63) @@ -160,15 +160,17 @@ function _delete_thread () { if (!empty($this->params['check_messages'])) { $threads = $this->Message->find('all', - array('conditions' => array("id IN (" . $this->Message->_make_in_statement_from_array('id', $this->params['check_messages']) . ")", ))); + array('conditions' => + array("id IN (" . $this->Message->_make_in_statement_from_array('id', $this->params['check_messages']) . ") AND sender_id = ? OR recipient_id = ?", + $this->current_user->getId(), $this->current_user->getId() + ) + ) + ); if ($threads) { foreach ($threads as $thread_loop_key => $thread) { - if ($thread->sender_id == $this->current_user->getId() || - $thread->recipient_id == $this->current_user->getId()) { - $is_del = $thread->sender_id == $this->current_user->getId() ? 'is_sender_del' : 'is_recipient_del'; - $this->Message->updateAll("$is_del = 1", "thread_id = " . $thread->getId()); - $this->Message->destroyAll("is_sender_del = 1 AND is_recipient_del = 1"); - } + $is_del = $thread->sender_id == $this->current_user->getId() ? 'is_sender_del' : 'is_recipient_del'; + $this->Message->updateAll("$is_del = 1", "thread_id = " . $thread->thread_id); + $this->Message->destroyAll("is_sender_del = 1 AND is_recipient_del = 1", "thread_id = " . $thread->thread_id); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <agu...@us...> - 2008-03-11 20:13:56
|
Revision: 67 http://isocial.svn.sourceforge.net/isocial/?rev=67&view=rev Author: aguidrevitch Date: 2008-03-11 13:13:41 -0700 (Tue, 11 Mar 2008) Log Message: ----------- thread deletion improvements Modified Paths: -------------- app/controllers/message_controller.php Modified: app/controllers/message_controller.php =================================================================== --- app/controllers/message_controller.php 2008-03-11 20:05:46 UTC (rev 66) +++ app/controllers/message_controller.php 2008-03-11 20:13:41 UTC (rev 67) @@ -170,7 +170,10 @@ foreach ($threads as $thread_loop_key => $thread) { $this->Message->updateAll("is_sender_del = 1", "sender_id = " . $this->current_user->getId() . " AND thread_id = " . $thread->thread_id); $this->Message->updateAll("is_recipient_del = 1", "recipient_id = " . $this->current_user->getId() . " AND thread_id = " . $thread->thread_id); - $this->Message->destroyAll("is_sender_del = 1 AND is_recipient_del = 1 AND thread_id = " . $thread->thread_id); + $thread->reload(); + if ($thread->is_sender_del && $thread->is_recipient_del) { + $this->Message->destroyAll("thread_id = " . $thread->thread_id); + } } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |