Changeset 312 for messages

Show
Ignore:
Timestamp:
05/30/08 16:59:14 (6 months ago)
Author:
dramirez
Message:

Messages 0.3

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • messages/trunk/CHANGELOG.txt

    r155 r312  
    1 Version 0.2.3 
    2         Translations to fi (Thanks to Pasi Havia) 
    3         Fixes for work with the 0.9 series (not backward compatibility) 
    4         Added a property for allow/disallow community messages 
     1Version 0.3 
     2        - Refactor for extract the send messages functionality to the  
     3          messages_send_message function to allow other plugins use it for 
     4          send messages 
     5        - Adjustments for use the new Java Script management procedure 
     6Version 0.2.2.1 
     7        Bug fix: You can view other users messages using the message id. 
     8                        Thanks to Federica Oradini (http://eduspaces.net/federicao/) for report it 
     9Version 0.2.2 
     10        Little navigation improvements  
     11        Interface polishing 
    512Version 0.2.1 
    613  Translations to nl (Thanks to Daniel Dubbeldam) 
  • messages/trunk/CONTRIBUTORS.txt

    r155 r312  
    99  Daniel Dubbeldam 
    1010    Translations to nl 
    11   Pasi Havia (http://www.elgg.org/encore) 
    12         Translations to fi 
    13         Some 0.9 compatibility bug fixes 
  • messages/trunk/README.txt

    r155 r312  
     1------------------------------------------------------------------------------------------------------- 
     2NOTE: 
     3  If your are using Elgg (<=0.9.2) or a svn checkout previous to the changeset 1595  
     4  you need to apply the patch provided with the ticket #359 (http://classic.elgg.org/trac/ticket/359) 
     5 
     6------------------------------------------------------------------------------------------------------- 
     7 
    18Add the following lines to the .htacess file: 
    29 
     
    1825If you want to change this behavior you must change the value of MESSAGES_SIDEBAR_NO_MEMBER_LINK 
    1926in the 'messages/lib/messages_config.php' file. 
    20  
    21 By default the plugin enable send messages for communities.  
    22  
    23 If you want to change this behavior you must change the value of MESSAGES_COMMUNITY_MESSAGES in  
    24 the 'messages/lib/messages_config.php' file. 
  • messages/trunk/default_template.php

    r155 r312  
    66 * @copyright Corporación Somos Más - 2007 
    77*/ 
     8global $template; 
     9global $template_definition; 
    810 
    9 // Add CSS 
    10 templates_add_context('css', 'mod/messages/css.css', true, true); 
     11$template['css'] .= file_get_contents($CFG->dirroot . "mod/messages/css.css"); 
    1112 
    12 // Add page templates 
     13// Registering template definitions 
     14$template_definition[] = array ('id' => 'plug_messages', 
     15                                'name' => __gettext("Message List"), 
     16                                'description' => __gettext("A template for the message list"), 
     17                                'glossary' => array ('{{messages}}' => __gettext("The list of messages themselves"), 
     18                                                     '{{paging}}' => __gettext("The list of page links when there are lots of messages"), 
     19                                                     '{{from_to}}' => __gettext("From | To Label for the message list"), 
     20                                                     'action' => "", 
     21                                                     'date' => '', 
     22                                                     'subject' => '', 
     23                                                     'actionMsg' => '', 
     24                                                     'returnConfirm' => '' 
     25                                                     ) 
     26                              ); 
    1327 
    14 templates_add_context('plug_messages',"mod/messages/templates/messages_messages.html"); 
    15 templates_add_context('plug_message',"mod/messages/templates/messages_message.html"); 
    16 templates_add_context('plug_detailedmessage',"mod/messages/templates/messages_detailed_message.html"); 
     28 
     29$template_definition[] = array ('id' => 'plug_message', 
     30                                'name' => __gettext("Message"), 
     31                                'description' => __gettext("A template for each message"), 
     32                                'glossary' => array ('{{date}}' => __gettext("The time and date of the message"), 
     33                                                     '{{title}}' => __gettext("Message title"), 
     34                                                     '{{from_username}}' => __gettext("The username from the sender"), 
     35                                                     '{{from_name}}' => __gettext("The full name from the sender"), 
     36                                                     '{{from_icon}}' => __gettext("The icon from the sender"), 
     37                                                     '{{msg_style}}' => __gettext("The message status style (read|unread)") 
     38                                                     ) 
     39                                ); 
     40 
     41$template_definition[] = array ('id' => 'plug_detailedmessage', 
     42                                'name' => __gettext("Message"), 
     43                                'description' => __gettext("A template for each message"), 
     44                                'glossary' => array ('{{date}}' => __gettext("The time and date of the message"), 
     45                                                     '{{title}}' => __gettext("Message title"), 
     46                                                     '{{from_username}}' => __gettext("The username from the sender"), 
     47                                                     '{{from_name}}' => __gettext("The full name from the sender"), 
     48                                                     '{{from_icon}}' => __gettext("The icon from the sender"), 
     49                                                     '{{body}}' => __gettext("The message body text"), 
     50                                                     '{{links}}' => __gettext("Links related with the message (delete|reply)") 
     51                                                     ) 
     52                                ); 
     53 
     54 
     55$template['plug_messages'] = file_get_contents(dirname(__FILE__)."/templates/messages_messages.html"); 
     56$template['plug_message'] = file_get_contents(dirname(__FILE__)."/templates/messages_message.html"); 
     57$template['plug_detailedmessage'] = file_get_contents(dirname(__FILE__)."/templates/messages_detailed_message.html"); 
    1758 
    1859?> 
  • messages/trunk/index.php

    r152 r312  
    1111 
    1212define("context", "messages"); 
     13 
    1314templates_page_setup(); 
     15templates_js_setup("messages"); 
    1416 
    1517$title = run("profile:display:name") . " :: " . __gettext("Messages"); 
  • messages/trunk/languages/es_CO/LC_MESSAGES/es_CO.po

    r103 r312  
    1 # SOME DESCRIPTIVE TITLE. 
    2 # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER 
     1# Copyright (C) Corporacin Somos ms 2007 
    32# This file is distributed under the same license as the PACKAGE package. 
    4 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR
     3# Nicols Martn <nicolas@somosmas.org>, 2007
    54# 
    65msgid "" 
     
    98"POT-Creation-Date: 2007-01-06 02:52+0000\n" 
    109"PO-Revision-Date: 2007-02-17 16:14+0000\n" 
    11 "Last-Translator: Nicolás Martín <nicolas@somosmas.org>\n" 
     10"Last-Translator: Nicols Martn  nicolas@somosmas.org>\n" 
    1211"Language-Team: Spanish (O2O) <nicolas@somosmas.org>\n" 
    1312"MIME-Version: 1.0\n" 
     
    106105#: lib.php:26 
    107106msgid "Your Messages" 
    108 msgstr "Mis Mensajes" 
     107msgstr "Mensajes" 
    109108 
    110109#: lib.php:40 
     
    114113#: lib.php:45 
    115114msgid "Compose" 
    116 msgstr "Componer" 
     115msgstr "Redactar" 
    117116 
    118117#: lib.php:50 
     
    231230msgid "Send Message" 
    232231msgstr "Enviar mensaje" 
     232 
     233#: lib/messages_new.php:69: 
     234msgid "Send" 
     235msgstr "Enviar" 
     236 
     237#: lib/messages_message_detailedview.php:59: 
     238msgid "Previous" 
     239msgstr "Anterior" 
     240 
     241#: lib/messages_init.php:22: 
     242msgid "You must be logged in to send a message to another user!." 
     243msgstr "Para enviar mensajes a usuarios del sitio debes ingresar primero!" 
     244 
     245#: lib/messages_init.php:23: 
     246msgid "If you are not registered in this site yet, please fill the following form." 
     247msgstr "Si no te has registrado aún, puedes hacerlo llenando el siguiente formulario." 
     248 
  • messages/trunk/lib.php

    r152 r312  
    1010 
    1111  if (isloggedin() && user_info("user_type", $_SESSION['userid']) != "external") { 
    12     // Add the JavaScript functions 
    13     // Lose the trailing slash 
    14     $url= substr($CFG->wwwroot, 0, -1); 
    15     $metatags .= "<script language=\"javascript\" type=\"text/javascript\" src=\"$url/mod/messages/messages.js\"></script>"; 
    1612    $metatags .= "<link rel=\"stylesheet\" href=\"" . $CFG->wwwroot . "mod/messages/css.css\" type=\"text/css\" media=\"screen\" />"; 
    1713 
     
    2117        'name' => 'messages', 
    2218        'html' => '<li><a href="' . $CFG->wwwroot . $_SESSION['username'] . '/messages/" class="selected">' . 
    23                   __gettext("Your Messages") . " ($messages)".'</a></li>'); 
     19      __gettext("Your Messages") . " ($messages)".'</a></li>'); 
    2420    } else { 
    2521      $PAGE->menu[]= array ( 
     
    7975  $function['users:infobox:menu:text'][] = $CFG->dirroot ."/mod/messages/lib/messages_sidebar_link.php"; 
    8076 
    81  
     77  templates_add_js_context("messages","mod/messages/messages.js"); 
     78   
    8279  // Inits the display field module param for the 'select' input field 
    8380  // I know, I know this is a big cannon to kill a fly, but I want to use the display_input_field function :P 
     
    8885    $CFG->display_field_module["as_select"]= "messages"; 
    8986  } 
     87   
    9088} 
    9189 
     
    132130} 
    133131 
     132function messages_send_message($from,$recipients,$title,$message,$sent_user_msg=false){ 
     133  global $CFG,$messages; 
     134 
     135  $recipients = (!is_array($recipients))?array($recipients):$recipients; 
     136 
     137  $msgs = 0; 
     138  $msg = new StdClass; 
     139  $msg->from_id = trim($from); 
     140  $msg->title = trim($title); 
     141  $msg->posted = time(); 
     142 
     143  foreach ($recipients as $rcpt) { 
     144    $msg->to_id = trim($rcpt); 
     145    $message_ = str_replace("{{USER}}",user_info("name",$rcpt),$message); 
     146    $msg->body = trim($message_); 
     147    $insert_id = insert_record('messages', $msg); 
     148    if ($insert_id != -1) { 
     149      $msgs++; 
     150    } 
     151    // Send the email confirmation if configured 
     152    // Don't use the weblog plug-in hook because it inserts data in the messages table too 
     153    $notifications = user_flag_get("emailnotifications", $msg->to_id); 
     154    if ($notifications) { 
     155      $email_from = new StdClass; 
     156      $email_from->email = $CFG->noreplyaddress; 
     157      $email_from->name = $CFG->sitename; 
     158        
     159      if(!$sent_user_msg){ 
     160        $email_message = sprintf(__gettext("You have received a message from %s."), user_info("name", $msg->from_id)); 
     161        $email_message .= "\n\n"; 
     162        $email_message .= sprintf(__gettext("To reply, click here: %s"), $CFG->wwwroot . user_info("username", $msg->to_id) . "/messages/"); 
     163        $email_message = wordwrap($email_message); 
     164      } 
     165      else{ 
     166        $email_message = wordwrap($message); 
     167      } 
     168      if ($email_to = get_record_sql("select * from " . $CFG->prefix . "users where ident = " . $msg->to_id)) { 
     169        if (!email_to_user($email_to, $email_from, $msg->title, $email_message . "\n\n\n" . __gettext("You cannot reply to this message by email."))) { 
     170          $messages[] = __gettext("Failed to send email. An unknown error occurred."); 
     171        } 
     172      } 
     173    } 
     174  } 
     175  return $msgs; 
     176} 
     177 
    134178?> 
  • messages/trunk/lib/messages_config.php

    r155 r312  
    88 * @copyright Corporación Somos Más - 2007 
    99 */ 
    10   
    1110 /** 
    12   * Configure if the sidebar link display would be available for no member communities 
     11  * Configure if the sidebar link display if available for no member communities 
    1312  * Type: boolean 
    1413  */ 
    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);   
     14 define("MESSAGES_SIDEBAR_NO_MEMBER_LINK",false); 
    2215?> 
  • messages/trunk/lib/messages_init.php

    r152 r312  
    11<?php 
     2 
    23/* 
    34 * This script initialize the enviroment for the private messages plug-in. 
     
    1011global $USER, $messages; 
    1112if ($profile_name = optional_param('profile_name')) { 
    12   if ($profile_id = user_info_username('ident', $profile_name)) { 
    13     $page_owner = $profile_id; 
    14  
     13       if ($profile_id = user_info_username('ident', $profile_name)) { 
     14               $page_owner = $profile_id; 
     15       
    1516} 
    1617 
    1718if (empty ($profile_id)) { 
    18   $profile_id = optional_param("profile_id", optional_param("profileid", $_SESSION['userid'], PARAM_INT), PARAM_INT); 
     19       $profile_id = optional_param("profile_id", optional_param("profileid", $_SESSION['userid'], PARAM_INT), PARAM_INT); 
    1920} 
    2021 
    2122if (!logged_on) { 
    22   header("Location: " . url); 
    23   exit; 
     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 . "/login/index.php"); 
     27        exit; 
    2428} 
    2529if ($profile_id != $USER->ident || !logged_on) { 
    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; 
     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'); 
     38if (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        } 
    3153} 
    3254?> 
  • messages/trunk/lib/messages_message_detailedview.php

    r152 r312  
    3030    $author->ident= -1; 
    3131  } 
    32   $author->icon= '<a href="' . url . $author->username . '/">' .user_icon_html($author->ident)."</a>"; 
     32  $author->icon= '<a href="' . url . $author->username . '/">' .user_icon_html($author->ident,60)."</a>"; 
    3333 
    3434  $date= strftime("%d %b %Y, %H:%M", $msg->posted); 
     
    4646  $links .= '&nbsp;<a href="' . $CFG->wwwroot . 'mod/messages/messages_actions.php?action=delete&amp;sent=' . $sent . '&amp;msg_id=' . $msg->ident . '" onclick="return confirm(\'' . $returnConfirm . '\')">' . $Delete . '</a> |'; 
    4747 
     48  // Obtaining the previous and next messages for put the links here for easy navigation 
     49  $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.="&nbsp;|&nbsp;"; 
     62  if($next!=-1){ 
     63    $msg_nav.= '<a href="' . url . $_SESSION['username'] . '/messages/view/' . $next . "/$sent\">" . __gettext("Next") . "</a>"; 
     64  } 
     65   
    4866  // Updated the message to the read status 
    4967  if ($msg->status == "unread" && $msg->to_id == $profile_id) { 
     
    6078    'from_icon' => $author->icon, 
    6179    'body' => $body, 
    62     'links' => $links 
     80    'links' => $links, 
     81    'msg_nav' => $msg_nav 
    6382  )); 
    6483} 
  • messages/trunk/lib/messages_new.php

    r244 r312  
    2828      $friend = get_record("users", "ident", $friend->friend); 
    2929      if ($friend) { 
    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; 
     30        $to_param[$friend->ident] = $friend->name; 
     31        if ($friend->user_type == "community") { 
     32          $to_param[$friend->ident] .= " " . __gettext("(Community)"); 
    3533        } 
    3634      } 
  • messages/trunk/lib/messages_sidebar_link.php

    r307 r312  
    11<?php 
     2 
     3 
    24/* 
    35 * This script shows the 'Send Message' link in the sidebar 
    46 * 
    5  * @uses $CFG,$USER 
     7 * @uses $CFG 
    68 * 
    79 * @author Diego Andrés Ramírez Aragón <diego@somosmas.org> 
     
    1012 
    1113global $CFG, $USER; 
    12 $owner = page_owner(); 
     14$page_owner = page_owner(); 
    1315 
    1416$community_membership_query = 'SELECT COUNT(u.ident) FROM ' . $CFG->prefix . 'friends f'; 
     
    1618$community_membership_query .= ' WHERE f.owner = ? AND f.friend = ?'; 
    1719 
    18 if (isloggedin() && $owner != $_SESSION['userid'] && $owner != -1) { 
    19   $messages_link = '<ul><li><a href="' . $CFG->wwwroot . "mod/messages/compose.php?action=compose&to=$owner" . '">' . __gettext("Send Message") . '</a></li></ul>'; 
    20   if (!MESSAGES_SIDEBAR_NO_MEMBER_LINK 
    21        && user_type($owner) == "community"  
    22        && count_records_sql($community_membership_query, array ($USER->ident,$owner)) == 0) { 
     20if (isloggedin() && $page_owner != $_SESSION['userid'] && $page_owner != -1) { 
     21  $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  
     23       && user_type($page_owner) == "community"  
     24       && count_records_sql($community_membership_query, array ($USER->ident,$page_owner)) == 0) { 
    2325    $messages_link = ''; 
    24   } 
    25   else if(!MESSAGES_COMMUNITY_MESSAGES && user_type($owner) == "community" ){ 
    26         $messages_link = ''; 
    2726  } 
    2827  $run_result .= $messages_link; 
  • messages/trunk/lib/messages_view.php

    r152 r312  
    5151} 
    5252 
    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 "); 
    5553 
    56 $posts = get_records_select('messages', "$where_sent", null, 'posted DESC', '*', $msg_offset, $msgs_per_page); 
     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");  
     56if(!empty($msgs_ids)){ 
     57        $_SESSION['messages_ids'.$sent] = array_keys($msgs_ids); 
     58
    5759$numberofposts = count_records_select('messages', "$where_sent"); 
    5860 
     
    7072  $next = __gettext("Next"); 
    7173 
    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 &gt;&gt;</a> 
    77  
    78 END; 
    79   } 
    8074  if ($msg_offset > 0) { 
    8175    $display_msg_offset = $msg_offset - $msgs_per_page; 
     
    8579    $pagging .=<<< END 
    8680 
    87                 <a href="{$CFG->wwwroot}{$msg_name}/messages/{$filterlink}msg_offset/{$display_msg_offset}">&lt;&lt; $back</a> 
     81               <a href="{$CFG->wwwroot}{$msg_name}/messages/{$filterlink}msg_offset/{$display_msg_offset}"><small>&lt;&lt;</small> $back</a> 
    8882 
    8983END; 
    9084  } 
    9185 
     86  if ($numberofposts - ($msg_offset + $msgs_per_page) > 0) { 
     87    $display_msg_offset = $msg_offset + $msgs_per_page; 
     88    $pagging .=<<< END 
     89 
     90                &nbsp;&nbsp;<a href="{$CFG->wwwroot}{$msg_name}/messages/{$filterlink}msg_offset/{$display_msg_offset}">$next <small>&gt;&gt;</small></a> 
     91 
     92END; 
     93  } 
    9294} 
    9395 
  • messages/trunk/messages_actions.php

    r155 r312  
    3434 * @author Diego Andrés Ramírez Aragón <diego@somosmas.org> 
    3535 * @copyright Corporación Somos Más - 2007 
    36 */ 
     36 */ 
    3737 
    3838require_once (dirname(dirname(__FILE__)) . "/../includes.php"); 
    39 require_once (dirname(__FILE__) . "/lib/messages_config.php"); 
    4039 
    4140/** 
     
    9695    if ($from != -1 && $to != -1) { 
    9796      if (trim($body) != "" && trim($subject) != "") { 
    98         $msg = new StdClass; 
    99         $msg->from_id = trim($from); 
    100         $msg->title = trim($subject); 
    101         $msg->body = trim($body); 
    102         $msg->posted = time(); 
    103  
    10497        $recipients = array (); 
    10598        $recipient = get_record("users", "ident", $to); 
    106         
    107         if($recipient->user_type == "community" && !MESSAGES_COMMUNITY_MESSAGES){ 
    108                 $messages[] = __gettext("The administrator doesn't allow send community messages"); 
    109           define('redirect_url', $redirect_url); 
    110           break; 
    111         } 
    112          
    11399        if ($recipient->user_type == "community") { 
    114100          $members = get_records_sql('SELECT u.*, f.ident AS friendident FROM ' . $CFG->prefix . 'friends f ' . 
    115101                                     'JOIN ' . $CFG->prefix . 'users u ON u.ident = f.owner ' . 
    116102                                     'WHERE f.friend = ? AND u.user_type = ?', array ($to,'person')); 
    117  
    118103          foreach ($members as $key => $infoMember) { 
    119104            $recipients[] = $key; 
    120105          } 
     106          $subject = "[" . $recipient->name . "] " .$subject; 
    121107        } else { 
    122108          $recipients[] = $to; 
    123109        } 
    124110 
    125         $msgs = 0; 
    126         foreach ($recipients as $rcpt) { 
    127           $msg->to_id = trim($rcpt); 
    128           $msg->title = $subject; 
    129           if ($recipient->user_type == "community") { 
    130             $msg->title = "[" . $recipient->name . "] " . $subject; 
    131           } 
    132           $insert_id = insert_record('messages', $msg); 
    133           if ($insert_id != -1) { 
    134             $msgs++; 
    135           } 
    136           // Send the email confirmation if configured 
    137           // Don't use the weblog plug-in hook because it inserts data in the messages table too 
    138           $notifications = user_flag_get("emailnotifications", $msg->to_id); 
    139           if ($notifications) { 
    140             $email_from = new StdClass; 
    141             $email_from->email = $CFG->noreplyaddress; 
    142             $email_from->name = $CFG->sitename; 
    143             $email_message = sprintf(__gettext("You have received a message from %s."), user_info("name", $msg->from_id)); 
    144             $email_message .= "\n\n"; 
    145             $email_message .= sprintf(__gettext("To reply, click here: %s"), $CFG->wwwroot . user_info("username", $msg->to_id) . "/messages/"); 
    146             $email_message = wordwrap($email_message); 
    147  
    148             if ($email_to = get_record_sql("select * from " . $CFG->prefix . "users where ident = " . $msg->to_id)) { 
    149               if (!email_to_user($email_to, $email_from, $msg->title, $email_message . "\n\n\n" . __gettext("You cannot reply to this message by email."))) { 
    150                 $messages[] = __gettext("Failed to send email. An unknown error occurred."); 
    151               } 
    152             } 
    153           } 
    154         } 
    155  
     111        $msgs = messages_send_message($from,$recipients,$subject,$body); 
     112         
    156113        if ($msgs == count($recipients)) { 
    157114          $messages[] = __gettext("Your message was sent"); 
     
    176133        switch ($action_type) { 
    177134          case "read"; 
    178             if ($msg->status == "unread") { 
    179               $msg->status = "read"; 
    180               update_record('messages', $msg); 
    181            
    182             break; 
     135          if ($msg->status == "unread") { 
     136            $msg->status = "read"; 
     137            update_record('messages', $msg); 
     138         
     139          break; 
    183140          case "unread"; 
    184             if ($msg->status == "read") { 
    185               $msg->status = "unread"; 
    186               update_record('messages', $msg); 
    187            
    188             break; 
     141          if ($msg->status == "read") { 
     142            $msg->status = "unread"; 
     143            update_record('messages', $msg); 
     144         
     145          break; 
    189146          case "delete"; 
    190             deleteMessage($option, $USER->ident,$sent); 
    191             break; 
     147          deleteMessage($option, $USER->ident,$sent); 
     148          break; 
    192149        } 
    193150      } 
  • messages/trunk/plugin.info

    r223 r312  
    11Maintainer: Diego Andrés Ramírez Aragón <diego@somosmas.org> 
    22Title: Messages plugin 
    3 Version: 0.2.
     3Version: 0.
    44Package: messages 
    55Distribution-URL: http://elgg.org/mod/plugins/plugin.php?id=18 
  • messages/trunk/templates/messages_detailed_message.html

    r152 r312  
    22   <h2>{{title}}</h2> 
    33        <div class="user"><!-- Open class user --> 
    4         {{from_icon}}&nbsp;<small>{{from_name}}</small> 
     4                {{from_icon}}<br/>{{from_name}} 
    55        </div><!-- Close class user --> 
    66        <div class="post"><!-- Open class post --> 
     
    99    <div class="info"><!-- Open class info --> 
    1010            <p> 
    11                  {{links}} 
     11            <span style="float:right;padding-right:10px">{{msg_nav}}</span> 
     12            {{links}} 
    1213            </p> 
    1314        </div><!-- Close class info --> 
  • messages/trunk/templates/messages_message.html

    r152 r312  
    22      <td {{msg_style}} style="text-align:center;padding-left:2px;padding-right:2px">{{index}}</td> 
    33      <td {{msg_style}} style="text-align:center;padding-left:2px;padding-right:2px">{{mark}}</td> 
    4       <td {{msg_style}} valign="middle">{{from_icon}}&nbsp;{{from_name}}</td> 
    5       <td {{msg_style}}>{{title}}</td> 
    6       <td {{msg_style}}>{{date}}</td> 
     4      <td {{msg_style}} align="center" valign="middle">{{from_icon}}<br/><small>{{from_name}}</small></td> 
     5      <td {{msg_style}}><p>{{title}}</p></td> 
     6      <td {{msg_style}}><p>{{date}}</p></td> 
    77     </tr> 
  • messages/trunk/templates/messages_messages.html

    r152 r312  
    22<form method="post" name="message_form" action="{{action_form}}" onsubmit="return submitForm();"> 
    33   <input type="hidden" name="sent" value="{{sent}}"> 
    4    <h2>{{title}}</h2
     4   <h3>{{title}}</h3
    55    <table id="messages_table" cellspacing="0" width="100%"> 
    66     <tr> 
    77      <th colspan="4" style="text-align:left"> 
    8         {{action}}&nbsp; 
     8       <p>{{action}}&nbsp; 
    99        <select name="message_action_type" id="message_action_type" onchange="submitMessagesAction(this,message_form,'{{returnConfirm}}')"> 
    1010          <option value="-1">{{actionMsg}}</option> 
    1111          {{action_options}} 
    12         </select
     12       </select></p
    1313      </th> 
    1414      <th>&nbsp;</th> 
     
    1616     <tr> 
    1717      <th width="4%" colspan="2">&nbsp;</th> 
    18       <th width="23%">{{from_to}}</th> 
    19       <th width="50%">{{subject}}</th> 
    20       <th width="33%">{{date}}</th> 
     18      <th width="23%"><p>{{from_to}}</p></th> 
     19      <th width="50%"><p>{{subject}}</p></th> 
     20      <th width="33%"><p>{{date}}</p></th> 
    2121     </tr> 
    2222        {{messages}} 
    2323     <tr> 
    24       <th colspan="4" style="text-align:left">{{paging}}</th> 
     24      <th colspan="4" style="text-align:left"><p>{{paging}}</p></th> 
    2525      <th>&nbsp;</th> 
    2626     </tr>