dokeos-survey
[ class tree: dokeos-survey ] [ index: dokeos-survey ] [ all elements ]

Source for file functions.inc.php

Documentation is available at functions.inc.php

  1. <?php
  2. /*
  3.     DOKEOS - elearning and course management software
  4.  
  5.     For a full list of contributors, see documentation/credits.html
  6.  
  7.     This program is free software; you can redistribute it and/or
  8.     modify it under the terms of the GNU General Public License
  9.     as published by the Free Software Foundation; either version 2
  10.     of the License, or (at your option) any later version.
  11.     See "documentation/licence.html" more details.
  12.  
  13.     Contact:
  14.         Dokeos
  15.         Rue des Palais 44 Paleizenstraat
  16.         B-1030 Brussels - Belgium
  17.         Tel. +32 (2) 211 34 56
  18. */
  19.  
  20. /**
  21. *    @package dokeos.survey
  22. *     @author
  23. *     @version $Id: functions.inc.php 12281 2007-05-03 16:25:12Z yannoo $
  24. *     @todo use database library
  25. */
  26. if(!function_exists('api_get_path')){header('location: view_message.php');die;}
  27. include_once(api_get_path(LIBRARY_PATH).'/online.inc.php');
  28.  
  29. define ("MESSAGES_DATABASE""messages");
  30.  
  31.  
  32.  
  33. function get_online_user_list($current_user_id)
  34. {
  35.     $MINUTE=30;
  36.     global $_configuration;
  37.     $userlist WhoIsOnline($current_user_id,$_configuration['statistics_database'],$MINUTE);
  38.     foreach($userlist as $row)
  39.     {
  40.         $receiver_id $row[0];
  41.         $online_user_list[$receiver_idGetFullUserName($receiver_id).($current_user_id==$receiver_id?("&nbsp;(".get_lang('Myself').")"):(""));
  42.     }
  43.  
  44.     return $online_user_list;
  45. }
  46.  
  47. /**
  48. * Displays info stating that the message is sent successfully.
  49. */
  50. function display_success_message($uid)
  51. {
  52.     $success"<p style=\"text-align: center\">".
  53.             get_lang('MessageSentTo').
  54.             "&nbsp;<b>".
  55.             GetFullUserName($uid).
  56.             "</b>".
  57.             "<br><a href=\"".
  58.             "inbox.php\">".
  59.             get_lang('BackToInbox').
  60.             "</a>";
  61.     Display::display_confirmation_message($successfalse);
  62. }
  63.  
  64. /**
  65. @todo this function seems no longer user
  66. *  but is still mentioned in comments, what can be the use?
  67. */
  68. function validate_text($texto)
  69. {
  70.     $MAX_SIZE 60/*Tama� m�imo de caracteres por l�ea*/
  71.     $i=0;
  72.     $lines array()/*Arreglo que contendr�las l�eas del texto*/
  73.     $token strtok($texto"\n");
  74.     while($token)
  75.     {
  76.         $lines[$i]$token;
  77.         $token strtok("\n");
  78.         $i++;
  79.     }
  80.     $modificado"";
  81.     for($i=0$i<count($lines)$i++ )
  82.     {
  83.         if(strlen($lines[$i])>$MAX_SIZE 1)
  84.         {
  85.             $modificado2substr($lines[$i]0$MAX_SIZE);
  86.             for($j=$MAX_SIZE$j<strlen($lines[$i])$j+=$MAX_SIZE)
  87.             {
  88.                 $modificado2 $modificado2."\n".substr($lines[$i]$j$MAX_SIZE);
  89.             }
  90.         }
  91.         else
  92.         {
  93.             $modificado2$lines[$i];
  94.         }
  95.         $modificado $modificado.$modificado2."\n";
  96.     }
  97.     $modificado substr($modificado,strlen($modificado)-1);
  98.     $modificado str_replace("&""&#038"$modificado)// �em
  99.     $modificado str_replace("<""&#60"$modificado)// para evitar que lo convierta en html
  100.     $modificado str_replace(">""&#62"$modificado)// �em
  101.  
  102.  
  103.     return $modificado;
  104. }
  105.  
  106. /**
  107. * Displays the wysiwyg html editor.
  108. */
  109. function display_html_editor_area($name,$resp)
  110. {
  111.     api_disp_html_area($name'Type your message here.''''100%');
  112. }
  113.  
  114. /**
  115. * Get the new messages for the current user from the database.
  116. */
  117. function get_new_messages()
  118. {
  119.     if (!api_get_user_id())
  120.     {
  121.         return false;
  122.     }
  123.     $i=0;
  124.     $query "SELECT * FROM `".MESSAGES_DATABASE."` WHERE id_receiver=".api_get_user_id()." AND status=1;";
  125.     $result api_sql_query($query,__FILE__,__LINE__);
  126.     $i mysql_num_rows($result);
  127.     return $i;
  128. }
  129.  
  130. /**
  131. * Get the list of user_ids of users who are online.
  132. */
  133. {
  134.     global $_configuration$_user;
  135.     $MINUTE=30;
  136.     $user_connect WhoIsOnline($_user['user_id'],$_configuration['statistics_database'],$MINUTE);
  137.     for ($i=0$i<count($user_connect)$i++)
  138.     {
  139.         $user_id_list[$i]=$user_connect[$i][0];
  140.     }
  141.     return $user_id_list;
  142. }
  143.  
  144. /**
  145.  * Gets the total number of messages, used for the inbox sortable table
  146.  */
  147. {
  148.     $sql_query "SELECT COUNT(*) as number_messages FROM `".MESSAGES_DATABASE."` WHERE id_receiver=".$_SESSION['_user']['user_id'];
  149.     $sql_result api_sql_query($sql_query,__FILE__,__LINE__);
  150.     $result mysql_fetch_array($sql_result);
  151.     return $result['number_messages'];
  152. }
  153.  
  154. /**
  155.  * Gets information about some messages, used for the inbox sortable table
  156.  * @param int $from 
  157.  * @param int $number_of_items 
  158.  * @param string $direction 
  159.  */
  160. function get_message_data($from$number_of_items$column$direction)
  161. {
  162.     $sql_query "SELECT id as col0, id_sender as col1, title as col2, date as col3 FROM `".MESSAGES_DATABASE."` WHERE id_receiver=".$_SESSION['_user']['user_id']." ORDER BY col$column $direction LIMIT $from,$number_of_items";
  163.     $sql_result api_sql_query($sql_query,__FILE__,__LINE__);
  164.     $i 0;
  165.     $message_list array ();
  166.     while ($result mysql_fetch_row($sql_result))
  167.     {
  168.         $message[0$result[0];
  169.         $message[1GetFullUserName($result[1]);
  170.         //$message[1] = "<a href=\"view_message.php?id=".$result[0]."\" title=\"$texto\">".GetFullUserName($result[1])."</a>";
  171.         $message[2'<a href="view_message.php?id='.$result[0].'">'.$result[2].'</a>';
  172.         $message[3$result[3]//date stays the same
  173.         $message[4'<a href="new_message.php?re_id='.$result[0].'"><img src="'.api_get_path(WEB_IMG_PATH).'forum.gif" alt="'.get_lang("ReplyToMessage").'" align="middle"></img></a>';
  174.         $message_list[$message;
  175.         $i++;
  176.     }
  177.     return $message_list;
  178. }
  179.  
  180. /**
  181. * Displays the inbox of a user, listing all messages.
  182. * In the process of moving towards sortable table.
  183. */
  184. function inbox_display()
  185. {
  186.     //delete messages if delete action was chosen
  187.     if (isset ($_POST['action']))
  188.     {
  189.         switch ($_POST['action'])
  190.         {
  191.             case 'delete' :
  192.                 $number_of_selected_messages count($_POST['id']);
  193.                 foreach ($_POST['id'as $index => $message_id)
  194.                 {
  195.                     $query "DELETE FROM ".MESSAGES_DATABASE." WHERE id_receiver=".api_get_user_id()." AND id='".mysql_real_escape_string($message_id)."'";
  196.                     api_sql_query($query,__FILE__,__LINE__);
  197.                 }
  198.                 Display :: display_normal_message(get_lang('SelectedMessagesDeleted'));
  199.                 break;
  200.         }
  201.     }
  202.  
  203.     // display sortable table with messages of the current user
  204.     $table new SortableTable('messages''get_number_of_messages''get_message_data'1);
  205.     $table->set_header(0''false);
  206.     $table->set_header(1get_lang('From'));
  207.     $table->set_header(2get_lang('Title'));
  208.     $table->set_header(3get_lang('Date'));
  209.     $table->set_header(4get_lang("ReplyToMessage")false);
  210.     $table->set_form_actions(array ('delete' => get_lang('DeleteSelectedMessages')));
  211.     $table->display();
  212. }
  213. ?>

Documentation generated on Thu, 12 Jun 2008 13:32:22 -0500 by phpDocumentor 1.4.1