Changeset 103

Show
Ignore:
Timestamp:
05/04/07 20:28:57 (2 years ago)
Author:
diego
Message:

Added the sidebar button

Files:

Legend:

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

    r102 r103  
     1Version 0.2 
     2  Bug fixes 
     3  Added the sidebar link to allow send messages to every user (Thanks to Renato [http://elgg.org/renato/]) 
     4  Added the {{contact}} keyword to be used in templates 
    15Version 0.1.4 
    26  Added the messages counter in the toolbar string 
    37  Code refactor 
    4   Spanish translation 
     8  Spanish translations 
    59Version 0.1.3 
    610  Fix a problem with the css 
  • messages/languages/es_CO/LC_MESSAGES/es_CO.po

    r102 r103  
    228228msgstr "Siguiente" 
    229229 
     230#: messages_sidebar_link.php:71 
     231msgid "Send Message" 
     232msgstr "Enviar mensaje" 
  • messages/lib.php

    r102 r103  
    7575  $function['messages:detailedview'][] = $CFG->dirroot . "mod/messages/lib/messages_message_detailedview.php"; 
    7676 
     77  // Sidebar display function 
     78  $function['messages:contact:link'][] = $CFG->dirroot ."/mod/messages/lib/messages_sidebar_link.php"; 
     79  $function['users:infobox:menu:text'][] = $CFG->dirroot ."/mod/messages/lib/messages_sidebar_link.php"; 
     80 
     81 
    7782  // Inits the display field module param for the 'select' input field 
    7883  // I know, I know this is a big cannon to kill a fly, but I want to use the display_input_field function :P 
     
    8388    $CFG->display_field_module["as_select"]= "messages"; 
    8489  } 
     90 
     91  $CFG->templates->variables_substitute['contact'] = 'messages_contact_user'; 
    8592 
    8693} 
     
    106113    case "asoc_select": 
    107114    case "as_select" : 
    108       $run_result .= "<select name=\"" . $parameter[0] . "\" id=\"" . $cleanid . "\" />"; 
     115      $run_result = "<select name=\"" . $parameter[0] . "\" id=\"" . $cleanid . "\" />"; 
    109116      foreach ($parameter[6] as $option_value => $option) { 
    110117        $run_result .= "<option value=\"" . htmlspecialchars(stripslashes($option_value), ENT_COMPAT, 'utf-8') . "\" "; 
     
    120127  return $run_result; 
    121128} 
     129 
     130/** 
     131 * Function that replaces the '{{contact}}' keyword by the 'Send Message' link 
     132 */ 
     133function messages_contact_user(){ 
     134  return run("messages:contact:link"); 
     135} 
     136 
    122137?> 
  • messages/lib/messages_message_detailedview.php

    r102 r103  
    11<?php 
     2 
    23/* 
    34 * This script loads and append to $run_result the data for the specified message 
     
    1415if (isset ($parameter)) { 
    1516  global $CFG, $profile_id; 
    16   $msg = $parameter; 
     17  $msg= $parameter; 
    1718 
    18   $sent = optional_param('sent'); 
    19   $author = new StdClass; 
     19  $sent= optional_param('sent'); 
     20  $author= new StdClass; 
    2021 
    21   $authorid = ($sent == 1) ? $msg->to_id : $msg->from_id; 
    22   $authorInfo = get_record('users', 'ident', $authorid); 
    23   $author->username = $authorInfo->username; 
    24   $author->fullname = htmlspecialchars($authorInfo->name, ENT_COMPAT, 'utf-8'); 
    25   if ($authorInfo->icon == -1 || $post->owner == -1) { 
    26     $author->icon = 0; 
     22  $authorid= ($sent == 1) ? $msg->to_id : $msg->from_id; 
     23  if ($authorInfo= get_record('users', 'ident', $authorid)) { 
     24    $author->username= $authorInfo->username; 
     25    $author->fullname= htmlspecialchars($authorInfo->name, ENT_COMPAT, 'utf-8'); 
     26    $author->ident  = $authorInfo->ident; 
    2727  } else { 
    28     if ($icon = get_record('icons', 'ident', $authorInfo->icon)) { 
    29       $author->icon = $icon->ident; 
    30     } else { 
    31       $author->icon = 0; 
    32     } 
     28    $author->username= ""; 
     29    $author->fullname= ""; 
     30    $author->ident= -1; 
    3331  } 
    34   $author->icon = '<a href="' . url . $author->username . '/">' . "<img src=\"" . $CFG->wwwroot . "_icon/user/" . $author->icon . "\" border=\"0\" align=\"left\" alt=\"\" /></a>"; 
     32  $author->icon= '<a href="' . url . $author->username . '/">' .user_icon_html($author->ident)."</a>"; 
    3533 
    36   $date = strftime("%d %b %Y, %H:%M", $msg->posted); 
    37   $title = run("weblogs:text:process", $msg->title); 
    38   $body = run("weblogs:text:process", $msg->body); 
     34  $date= strftime("%d %b %Y, %H:%M", $msg->posted); 
     35  $title= run("weblogs:text:process", $msg->title); 
     36  $body= run("weblogs:text:process", $msg->body); 
    3937 
    40   $reply = __gettext("Reply"); 
    41   $returnConfirm = __gettext("Are you sure you want to permanently delete this message?"); 
    42   $Delete = __gettext("Delete"); 
    43   $from_msg = __gettext("To:"); 
     38  $reply= __gettext("Reply"); 
     39  $returnConfirm= __gettext("Are you sure you want to permanently delete this message?"); 
     40  $Delete= __gettext("Delete"); 
     41  $from_msg= __gettext("To:"); 
    4442  if (!$sent) { 
    45     $from_msg = __gettext("From:"); 
    46     $links = '<a href="' . $CFG->wwwroot . 'mod/messages/compose.php?action=reply&amp;msg_id=' . $msg->ident . '&amp;to=' . $msg->from_id . '">' . $reply . '</a> |'; 
     43    $from_msg= __gettext("From:"); 
     44    $links= '<a href="' . $CFG->wwwroot . 'mod/messages/compose.php?action=reply&amp;msg_id=' . $msg->ident . '&amp;to=' . $msg->from_id . '">' . $reply . '</a> |'; 
    4745  } 
    48   $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> |'; 
     46  $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> |'; 
    4947 
    5048  // Updated the message to the read status 
    5149  if ($msg->status == "unread" && $msg->to_id == $profile_id) { 
    52     $msg->status = "read"; 
     50    $msg->status= "read"; 
    5351    update_record('messages', $msg); 
    5452  } 
     
    5957    'title' => $title, 
    6058    'from_username' => $author->username, 
    61     'from_name' => $from_msg.' <a href="' . url . $author->username . '/">' . $author->fullname . "</a>", 
     59    'from_name' => $from_msg . ' <a href="' . url . $author->username . '/">' . $author->fullname . "</a>", 
    6260    'from_icon' => $author->icon, 
    6361    'body' => $body, 
  • messages/lib/messages_message_view.php

    r102 r103  
    11<?php 
     2 
    23/* 
    34 * This script loads and append to $run_result the basic data for the specified message 
     
    1516if (isset ($parameter)) { 
    1617  global $CFG, $profile_id; 
    17   $msg = $parameter[0]; 
    18   $sent = $parameter[1]; 
    19   $index = $parameter[2]; 
     18  $msg= $parameter[0]; 
     19  $sent= $parameter[1]; 
     20  $index= $parameter[2]; 
    2021 
    21   $sent = optional_param('sent', 0, PARAM_INT); 
    22   $author = new StdClass; 
     22  $sent= optional_param('sent', 0, PARAM_INT); 
     23  $author= new StdClass; 
    2324 
    24   $authorid = ($sent === 1) ? $msg->to_id : $msg->from_id; 
    25   $authorInfo = get_record('users', 'ident', $authorid); 
    26   $author->username = $authorInfo->username; 
    27   $author->fullname = htmlspecialchars($authorInfo->name, ENT_COMPAT, 'utf-8'); 
    28   if ($authorInfo->icon == -1 || $post->owner == -1) { 
    29     $author->icon = 0; 
     25  $authorid= ($sent === 1) ? $msg->to_id : $msg->from_id; 
     26  if ($authorInfo= get_record('users', 'ident', $authorid)) { 
     27    $author->username= $authorInfo->username; 
     28    $author->fullname= htmlspecialchars($authorInfo->name, ENT_COMPAT, 'utf-8'); 
     29    $author->ident = $authorInfo->ident; 
    3030  } else { 
    31     if ($icon = get_record('icons', 'ident', $authorInfo->icon)) { 
    32       $author->icon = $icon->ident; 
    33     } else { 
    34       $author->icon = 0; 
    35     } 
     31    $author->username= ""; 
     32    $author->fullname= ""; 
     33    $author->ident= -1; 
    3634  } 
    37   $author->icon = '<a href="' . url . $author->username . '/">' . "<img src=\"" . $CFG->wwwroot . "_icon/user/" . $author->icon . "/w/50/h/50\" border=\"0\" align=\"left\" alt=\"\" /></a>"; 
    3835 
    39   $mark = "<input type=\"checkbox\" name=\"selected[]\" value=\"".$msg->ident."\" onclick=\"mark(this)\">"; 
     36  $author->icon= '<a href="' . url . $author->username . '/">' .user_icon_html($author->ident,50). "</a>"; 
    4037 
    41   $date = strftime("%d/%m/%Y, %H:%M", $msg->posted); 
    42   $username = user_info('username', $msg->from_id); 
    43   $title = run("weblogs:text:process", $msg->title); 
    44   $msg_style = ""; 
     38  $mark= "<input type=\"checkbox\" name=\"selected[]\" value=\"" . $msg->ident . "\" onclick=\"mark(this)\">"; 
     39 
     40  $date= strftime("%d/%m/%Y, %H:%M", $msg->posted); 
     41  $username= user_info('username', $msg->from_id); 
     42  $title= run("weblogs:text:process", $msg->title); 
     43  $msg_style= ""; 
    4544  if ($msg->status == "read" || $sent === 1) { 
    46     $msg_style = "class='message_read'"; 
     45    $msg_style= "class='message_read'"; 
    4746  } 
    4847 
  • messages/lib/messages_new.php

    r102 r103  
    22/* 
    33 * This script loads and append to $run_result the data for the specified message 
    4  *  
     4 * 
    55 * @param int $from The sender Id 
    66 * @param int $to The recipient Id 
    77 * @param int $msg_id The messge id (optional, used if the new message its a reply) 
    88 * @param int $action If the message is a reply (optional) 
    9  *  
     9 * 
    1010 * @uses $profile_id 
    1111 * @uses $CFG 
    12  *  
     12 * 
    1313 * @author Diego Andrés Ramírez Aragón <diego@somosmas.org> 
    1414 * @copyright Corporación Somos Más - 2007 
     
    5656} 
    5757 
    58 $reply = optional_param('action'); 
     58$action = optional_param('action'); 
    5959 
    6060$redirect = url . "mod/messages/messages_actions.php?action=compose"; 
     
    130130</form> 
    131131END; 
     132 
    132133?> 
  • messages/lib/messages_view.php

    r102 r103  
    4141$action_options .= "<option value=\"delete\">$delete</option>"; 
    4242 
     43$filterlink = ""; 
    4344$where_sent = "to_id=$profile_id AND hidden_to='0'"; 
    4445if ($sent === 1) { 
  • messages/messages_actions.php

    r102 r103  
    8686 
    8787  case "compose" : 
    88     $redirect_url = url . user_info('username', $USER->ident) . "/messages/compose"; 
     88    $redirect_url = url . user_info('username', $_SESSION['userid']) . "/messages/compose"; 
    8989 
    9090    $from = optional_param('new_msg_from', -1, PARAM_INT); 
     
    118118        } 
    119119 
     120        $msgs = 0; 
    120121        foreach ($recipients as $rcpt) { 
    121122          $msg->to_id = trim($rcpt); 
     
    124125            $msg->title = "[" . $recipient->name . "] " . $subject; 
    125126          } 
    126  
    127127          $insert_id = insert_record('messages', $msg); 
    128128          if ($insert_id != -1) { 
    129129            $msgs++; 
    130130          } 
    131  
    132131          // Send the email confirmation if configured 
    133132          // Don't use the weblog plug-in hook because it inserts data in the messages table too 
     
    153152        if ($msgs == count($recipients)) { 
    154153          $messages[] = __gettext("Your message was sent"); 
    155           $redirect_url = url . user_info('username', $msg->from_id) . "/messages/sent"; 
     154          $redirect_url = url . user_info('username', $USER->ident) . "/messages/sent"; 
    156155        } 
    157156