[Isocial-svn] SF.net SVN: isocial: [58] app
Status: Pre-Alpha
Brought to you by:
aguidrevitch
From: <di...@us...> - 2008-03-10 13:36:48
|
Revision: 58 http://isocial.svn.sourceforge.net/isocial/?rev=58&view=rev Author: dim0s77 Date: 2008-03-10 06:36:49 -0700 (Mon, 10 Mar 2008) Log Message: ----------- added functionality to outbox messages Modified Paths: -------------- app/controllers/message_controller.php app/views/message/_rows.tpl app/views/message/inbox.tpl app/views/message/outbox.tpl Modified: app/controllers/message_controller.php =================================================================== --- app/controllers/message_controller.php 2008-03-10 09:29:13 UTC (rev 57) +++ app/controllers/message_controller.php 2008-03-10 13:36:49 UTC (rev 58) @@ -27,15 +27,14 @@ } } $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())); + $this->message_threads = count($box_messages); return $box_messages; } function send () { if (!empty($this->params['message']) && - !empty($this->params['message']['recipient']) && - !empty($this->params['message']['body'])) { + !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(); @@ -149,7 +148,21 @@ 'target' => 'sender'))); } - function delete_thread () { + function delete_inbox_thread () { + $this->_delete_thread(); + return $this->render(array('partial' => 'rows', + 'locals' => array('messages' => $this->_getBoxMessages('inbox_message'), + 'target' => 'sender'))); + } + + function delete_outbox_thread () { + $this->_delete_thread(); + return $this->render(array('partial' => 'rows', + 'locals' => array('messages' => $this->_getBoxMessages('outbox_message'), + 'target' => 'sender'))); + } + + 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']) . ")", ))); @@ -162,9 +175,6 @@ } } } - return $this->render(array('partial' => 'rows', - 'locals' => array('messages' => $this->_getBoxMessages('inbox_message'), - 'target' => 'sender'))); } } ?> \ No newline at end of file Modified: app/views/message/_rows.tpl =================================================================== --- app/views/message/_rows.tpl 2008-03-10 09:29:13 UTC (rev 57) +++ app/views/message/_rows.tpl 2008-03-10 13:36:49 UTC (rev 58) @@ -2,7 +2,7 @@ <tbody> {loop messages} <? $sender = $message->$target->load() ?> -<tr class="<? if (!$message->is_read) { echo 'new_message'; } ?>"> +<tr class="<? if ($target == 'sender' && !$message->is_read) { echo 'new_message'; } ?>"> <td class="msg_icon"> <? if ($target == 'sender') { echo '<a href="">'; Modified: app/views/message/inbox.tpl =================================================================== --- app/views/message/inbox.tpl 2008-03-10 09:29:13 UTC (rev 57) +++ app/views/message/inbox.tpl 2008-03-10 13:36:49 UTC (rev 58) @@ -81,7 +81,7 @@ function delete_thread (element) { new Ajax.Updater('messages', - '/message/delete_thread', + '/message/delete_inbox_thread', { method:'post', asynchronous:true, parameters:$('messages_form').serialize()}); disable_action_links(); return false; Modified: app/views/message/outbox.tpl =================================================================== --- app/views/message/outbox.tpl 2008-03-10 09:29:13 UTC (rev 57) +++ app/views/message/outbox.tpl 2008-03-10 13:36:49 UTC (rev 58) @@ -3,23 +3,56 @@ <div class="inbox_submenu"> <div class="menu_block selector"> <label for="action_select">_{Select}: - <select class="" onchange="" id="action_select" name="action_selector"> + <select class="" onchange="onselect(this)" id="action_select" name="action_selector"> <option selected="selected" value="_">---------</option> - <option value="">_{None}</option> - <option value="read">_{Read}</option> - <option value="unread">_{Unread}</option> + <option value="none">_{None}</option> <option value="all">_{All}</option> </select> </label> </div> <div class="menu_block"> <ul id="inbox_action" class="buttons"> - <li class="disabled"><a href="#" onclick="" id="delete">_{Delete}</a></li> + <li><a href="#" onclick="delete_thread(this)" id="delete_link" class="disabled">_{Delete}</a></li> </ul> </div> </div> -<?= $controller->render(array('partial' => 'rows', - 'locals' => array('messages' => $outbox_messages, - 'target' => 'recipient'))) ?> +<form id="messages_form" action="/message/inbox" method="post" onsubmit="return false;"> + <div id="messages"> + <?= $controller->render(array('partial' => 'rows', + 'locals' => array('messages' => $outbox_messages, + 'target' => 'recipient'))) ?> + </div> +</form> +<script> +function oncheck (element, is_read) { + checked = $$('input[type=checkbox]:checked'); + checked.length ? $("delete_link").removeClassName('disabled') : $("delete_link").addClassName('disabled'); +}; + +function onselect (element) { + var checkboxes; + switch (element.getValue()) { + case "none": + checkboxes = $$('input[type=checkbox]:checked'); + break; + case "all": + checkboxes = $$('input[type=checkbox]:not(:checked)'); + break; + } + if (checkboxes) { + checkboxes.invoke('click'); + } +}; + +function delete_thread (element) { + new Ajax.Updater('messages', + '/message/delete_outbox_thread', + { method:'post', asynchronous:true, parameters:$('messages_form').serialize()}); + $("delete_link").addClassName('disabled'); + return false; +} + +</script> + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |