Changeset 156
- Timestamp:
- 12/14/07 20:41:42 (1 year ago)
- Files:
-
- messages/releases/0.2.3-0.8 (copied) (copied from messages/releases/0.2.2.1-0.8)
- messages/releases/0.2.3-0.8/lib/messages_config.php (modified) (1 diff)
- messages/releases/0.2.3-0.8/lib/messages_init.php (modified) (2 diffs)
- messages/releases/0.2.3-0.8/lib/messages_message_detailedview.php (modified) (3 diffs)
- messages/releases/0.2.3-0.8/lib/messages_new.php (modified) (2 diffs)
- messages/releases/0.2.3-0.8/lib/messages_sidebar_link.php (modified) (2 diffs)
- messages/releases/0.2.3-0.8/lib/messages_view.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
messages/releases/0.2.3-0.8/lib/messages_config.php
r154 r156 8 8 * @copyright Corporación Somos Más - 2007 9 9 */ 10 10 11 /** 11 * Configure if the sidebar link display ifavailable for no member communities12 * Configure if the sidebar link display would be available for no member communities 12 13 * Type: boolean 13 14 */ 14 define("MESSAGES_SIDEBAR_NO_MEMBER_LINK",false); 15 define("MESSAGES_SIDEBAR_NO_MEMBER_LINK",true); 16 17 /** 18 * Configure if you want to enable to send messages to communities 19 * Type: boolean 20 */ 21 define("MESSAGES_COMMUNITY_MESSAGES",true); 15 22 ?> messages/releases/0.2.3-0.8/lib/messages_init.php
r154 r156 1 1 <?php 2 3 2 /* 4 3 * This script initialize the enviroment for the private messages plug-in. … … 11 10 global $USER, $messages; 12 11 if ($profile_name = optional_param('profile_name')) { 13 if ($profile_id = user_info_username('ident', $profile_name)) {14 $page_owner = $profile_id;15 }12 if ($profile_id = user_info_username('ident', $profile_name)) { 13 $page_owner = $profile_id; 14 } 16 15 } 17 16 18 17 if (empty ($profile_id)) { 19 $profile_id = optional_param("profile_id", optional_param("profileid", $_SESSION['userid'], PARAM_INT), PARAM_INT);18 $profile_id = optional_param("profile_id", optional_param("profileid", $_SESSION['userid'], PARAM_INT), PARAM_INT); 20 19 } 21 20 22 21 if (!logged_on) { 23 $messages[] = __gettext("You must be logged in to send a message to another user!."); 24 $messages[] = __gettext("If you are not registered in this site yet, please fill the following form."); 25 $_SESSION['messages'] = $messages; 26 header("Location: " . url . "register"); 27 exit; 22 header("Location: " . url); 23 exit; 28 24 } 29 25 if ($profile_id != $USER->ident || !logged_on) { 30 $messages[] = __gettext("You may view only your own messages"); 31 $redirect_url = url . user_info('username', $USER->ident) . "/messages/"; 32 $_SESSION['messages'] = $messages; 33 header("Location: " . $redirect_url); 34 exit; 35 } 36 37 $message = optional_param('message'); 38 if (isset ($message)) { 39 $msg = get_record('messages', 'ident', $message); 40 $sent = optional_param('sent'); 41 42 $authorid = ($sent == 0) ? $msg->to_id : $msg->from_id; 43 error_log($authorid); 44 error_log($USER->ident); 45 46 if ($authorid != $USER->ident || !logged_on) { 47 $messages[] = __gettext("You may view only your own messages"); 48 $redirect_url = url . user_info('username', $USER->ident) . "/messages/"; 49 $_SESSION['messages'] = $messages; 50 header("Location: " . $redirect_url); 51 exit; 52 } 26 $messages[] = __gettext("You may view only your own messages"); 27 $redirect_url = url . user_info('username', $USER->ident) . "/messages/"; 28 $_SESSION['messages'] = $messages; 29 header("Location: " . $redirect_url); 30 exit; 53 31 } 54 32 ?> messages/releases/0.2.3-0.8/lib/messages_message_detailedview.php
r154 r156 30 30 $author->ident= -1; 31 31 } 32 $author->icon= '<a href="' . url . $author->username . '/">' .user_icon_html($author->ident ,60)."</a>";32 $author->icon= '<a href="' . url . $author->username . '/">' .user_icon_html($author->ident)."</a>"; 33 33 34 34 $date= strftime("%d %b %Y, %H:%M", $msg->posted); … … 46 46 $links .= ' <a href="' . $CFG->wwwroot . 'mod/messages/messages_actions.php?action=delete&sent=' . $sent . '&msg_id=' . $msg->ident . '" onclick="return confirm(\'' . $returnConfirm . '\')">' . $Delete . '</a> |'; 47 47 48 // Obtaining the previous and next messages for put the links here for easy navigation49 $msgs_ids = $_SESSION['messages_ids'.$sent];50 51 for($ii=0; $ii < count($msgs_ids); $ii++){52 if($msgs_ids[$ii] == $msg->ident){53 $previous = ($ii>0)? $msgs_ids[$ii-1] : -1;54 $next = (($ii + 1) < count($msgs_ids))? $msgs_ids[$ii+1] : -1;55 }56 }57 58 if($previous!=-1){59 $msg_nav= '<a href="' . url . $_SESSION['username'] . '/messages/view/' . $previous . "/$sent\">" . __gettext("Previous") . "</a>";60 }61 $msg_nav.=" | ";62 if($next!=-1){63 $msg_nav.= '<a href="' . url . $_SESSION['username'] . '/messages/view/' . $next . "/$sent\">" . __gettext("Next") . "</a>";64 }65 66 48 // Updated the message to the read status 67 49 if ($msg->status == "unread" && $msg->to_id == $profile_id) { … … 78 60 'from_icon' => $author->icon, 79 61 'body' => $body, 80 'links' => $links, 81 'msg_nav' => $msg_nav 62 'links' => $links 82 63 )); 83 64 } messages/releases/0.2.3-0.8/lib/messages_new.php
r154 r156 28 28 $friend = get_record("users", "ident", $friend->friend); 29 29 if ($friend) { 30 $to_param[$friend->ident] = $friend->name; 31 if ($friend->user_type == "community") { 32 $to_param[$friend->ident] .= " " . __gettext("(Community)"); 30 if ($friend->user_type == "community" && MESSAGES_COMMUNITY_MESSAGES) { 31 $to_param[$friend->ident] = $friend->name." " . __gettext("(Community)"); 32 } 33 else if($friend->user_type != "community"){ 34 $to_param[$friend->ident] = $friend->name; 33 35 } 34 36 } … … 66 68 $subject = __gettext("Subject:"); 67 69 $message = __gettext("Message:"); 68 $submitButton = ($action == "reply") ? __gettext("Reply") : __gettext("Send");70 $submitButton = ($action == "reply") ? "Reply" : "Send"; 69 71 70 72 $run_result =<<< END messages/releases/0.2.3-0.8/lib/messages_sidebar_link.php
r154 r156 1 1 <?php 2 3 4 2 /* 5 3 * This script shows the 'Send Message' link in the sidebar 6 4 * 7 * @uses $CFG 5 * @uses $CFG,$USER 8 6 * 9 7 * @author Diego Andrés RamÃrez Aragón <diego@somosmas.org> … … 20 18 if (isloggedin() && $page_owner != $_SESSION['userid'] && $page_owner != -1) { 21 19 $messages_link = '<ul><li><a href="' . $CFG->wwwroot . "mod/messages/compose.php?action=compose&to=$page_owner" . '">' . __gettext("Send Message") . '</a></li></ul>'; 22 if (!MESSAGES_SIDEBAR_NO_MEMBER_LINK 20 if (!MESSAGES_SIDEBAR_NO_MEMBER_LINK 23 21 && user_type($page_owner) == "community" 24 22 && count_records_sql($community_membership_query, array ($USER->ident,$page_owner)) == 0) { 25 23 $messages_link = ''; 24 } 25 else if(!MESSAGES_COMMUNITY_MESSAGES && user_type($page_owner) == "community" ){ 26 $messages_link = ''; 26 27 } 27 28 $run_result .= $messages_link; messages/releases/0.2.3-0.8/lib/messages_view.php
r154 r156 51 51 } 52 52 53 //$posts = get_records_select('messages', "$where_sent AND from_id != -1 ", null, 'posted DESC', '*', $msg_offset, $msgs_per_page); 54 //$numberofposts = count_records_select('messages', "$where_sent AND from_id != -1 "); 53 55 54 $posts = get_records_select('messages', "$where_sent", null, 'posted DESC,ident ASC', '*', $msg_offset, $msgs_per_page); 55 $msgs_ids = get_records_sql("SELECT ident FROM {$CFG->prefix}messages WHERE $where_sent ORDER BY posted DESC, ident ASC"); 56 if(!empty($msgs_ids)){ 57 $_SESSION['messages_ids'.$sent] = array_keys($msgs_ids); 58 } 56 $posts = get_records_select('messages', "$where_sent", null, 'posted DESC', '*', $msg_offset, $msgs_per_page); 59 57 $numberofposts = count_records_select('messages', "$where_sent"); 60 58 … … 72 70 $next = __gettext("Next"); 73 71 72 if ($numberofposts - ($msg_offset + $msgs_per_page) > 0) { 73 $display_msg_offset = $msg_offset + $msgs_per_page; 74 $pagging .=<<< END 75 76 <a href="{$CFG->wwwroot}{$msg_name}/messages/{$filterlink}msg_offset/{$display_msg_offset}">$next >></a> 77 78 END; 79 } 74 80 if ($msg_offset > 0) { 75 81 $display_msg_offset = $msg_offset - $msgs_per_page; … … 79 85 $pagging .=<<< END 80 86 81 <a href="{$CFG->wwwroot}{$msg_name}/messages/{$filterlink}msg_offset/{$display_msg_offset}"><small><<</small>$back</a>87 <a href="{$CFG->wwwroot}{$msg_name}/messages/{$filterlink}msg_offset/{$display_msg_offset}"><< $back</a> 82 88 83 89 END; 84 90 } 85 91 86 if ($numberofposts - ($msg_offset + $msgs_per_page) > 0) {87 $display_msg_offset = $msg_offset + $msgs_per_page;88 $pagging .=<<< END89 90 <a href="{$CFG->wwwroot}{$msg_name}/messages/{$filterlink}msg_offset/{$display_msg_offset}">$next <small>>></small></a>91 92 END;93 }94 92 } 95 93
