[Isocial-svn] SF.net SVN: isocial: [61] app
Status: Pre-Alpha
Brought to you by:
aguidrevitch
From: <di...@us...> - 2008-03-11 19:21:34
|
Revision: 61 http://isocial.svn.sourceforge.net/isocial/?rev=61&view=rev Author: dim0s77 Date: 2008-03-11 12:21:38 -0700 (Tue, 11 Mar 2008) Log Message: ----------- delete message after mark it as deleted by two interlocutors Modified Paths: -------------- app/controllers/message_controller.php app/installers/message_installer.php app/locales/message/ru.php app/models/user.php app/views/message/outbox.tpl Modified: app/controllers/message_controller.php =================================================================== --- app/controllers/message_controller.php 2008-03-11 18:57:11 UTC (rev 60) +++ app/controllers/message_controller.php 2008-03-11 19:21:38 UTC (rev 61) @@ -165,7 +165,9 @@ foreach ($threads as $thread_loop_key => $thread) { if ($thread->sender_id == $this->current_user->getId() || $thread->recipient_id == $this->current_user->getId()) { - $this->Message->destroyAll("thread_id = $thread->thread_id"); + $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"); } } } Modified: app/installers/message_installer.php =================================================================== --- app/installers/message_installer.php 2008-03-11 18:57:11 UTC (rev 60) +++ app/installers/message_installer.php 2008-03-11 19:21:38 UTC (rev 61) @@ -5,14 +5,16 @@ { $this->execute( "CREATE TABLE `messages` ( - `id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT, - `sender_id` int(11) NOT NULL DEFAULT 0, - `recipient_id` int(11) NOT NULL DEFAULT 0, - `thread_id` int(11) NOT NULL DEFAULT 0, - `subject` char(255) NOT NULL DEFAULT '', - `body` text NOT NULL DEFAULT '', - `created_at` datetime NOT NULL, - `is_read` tinyint(1) NOT NULL DEFAULT '0', + `id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT, + `sender_id` int(11) NOT NULL DEFAULT 0, + `recipient_id` int(11) NOT NULL DEFAULT 0, + `thread_id` int(11) NOT NULL DEFAULT 0, + `subject` char(255) NOT NULL DEFAULT '', + `body` text NOT NULL DEFAULT '', + `created_at` datetime NOT NULL, + `is_read` tinyint(1) NOT NULL DEFAULT '0', + `is_sender_del` tinyint(1) NOT NULL DEFAULT '0', + `is_recipient_del` tinyint(1) NOT NULL DEFAULT '0', FOREIGN KEY (sender_id) REFERENCES users(id), FOREIGN KEY (recipient_id) REFERENCES users(id) ) ENGINE=InnoDB"); Modified: app/locales/message/ru.php =================================================================== --- app/locales/message/ru.php 2008-03-11 18:57:11 UTC (rev 60) +++ app/locales/message/ru.php 2008-03-11 19:21:38 UTC (rev 61) @@ -21,7 +21,7 @@ $dictionary['Delete'] = 'Удалить'; $dictionary['New message'] = 'Новое сообщение'; $dictionary['Message is readed'] = 'Сообщение прочитано'; -$dictionary['Message successfully sended'] = 'Сообщение отправлено'; +$dictionary['Message successfully sent'] = 'Сообщение отправлено'; $dictionary['Thread unavailable'] = 'Нить сообщений недоступна'; $dictionary['Sorry, the contents of this thread are temporarily unavailable. Please check back later.'] = 'К сожалению, содержание этой нити сообщений временно недоступно. Повторите попытку позже.'; $dictionary['Between'] = 'в беседе участвуют:'; Modified: app/models/user.php =================================================================== --- app/models/user.php 2008-03-11 18:57:11 UTC (rev 60) +++ app/models/user.php 2008-03-11 19:21:38 UTC (rev 61) @@ -2,8 +2,14 @@ class User extends ActiveRecord { - var $has_many = array('outbox_messages' => array('class_name' => 'Message', 'order' => 'created_at desc', 'foreign_key' => 'sender_id'), - 'inbox_messages' => array('class_name' => 'Message', 'order' => 'created_at desc', 'foreign_key' => 'recipient_id'), + var $has_many = array('outbox_messages' => array('class_name' => 'Message', + 'order' => 'created_at desc', + 'foreign_key' => 'sender_id', + 'conditions' => 'is_sender_del = 0'), + 'inbox_messages' => array('class_name' => 'Message', + 'order' => 'created_at desc', + 'foreign_key' => 'recipient_id', + 'conditions' => 'is_recipient_del = 0'), ); function login($email, $password) { Modified: app/views/message/outbox.tpl =================================================================== --- app/views/message/outbox.tpl 2008-03-11 18:57:11 UTC (rev 60) +++ app/views/message/outbox.tpl 2008-03-11 19:21:38 UTC (rev 61) @@ -28,7 +28,7 @@ <script> var checkids = new Array(); function oncheck (element, is_read) { - checkids = $$('input[type=checkbox]:checked').toArray(); + checked = $$('input[type=checkbox]:checked'); checkids.clear(); for (var index = 0; index < checked.length; index++) { checkids.push(checked[index].id); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |