Removing PHP notices/warnings

skala
Julio Montoya 13 years ago
parent 8a2e11c3a3
commit f278113d88
  1. 68
      main/admin/course_list.php
  2. 62
      main/admin/statistics/statistics.lib.php
  3. 319
      main/inc/lib/message.lib.php
  4. 4
      main/messages/inbox.php
  5. 4
      main/social/profile.php
  6. 65
      whoisonline.php

@ -27,7 +27,7 @@ function get_number_of_courses() {
$sql = "SELECT COUNT(code) AS total_number_of_items FROM $course_table";
global $_configuration;
if ((api_is_platform_admin() || api_is_session_admin()) && $_configuration['multiple_access_urls'] && api_get_current_access_url_id() != -1) {
if ((api_is_platform_admin() || api_is_session_admin()) && api_is_multiple_url_enabled() && api_get_current_access_url_id() != -1) {
$access_url_rel_course_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$sql.= " INNER JOIN $access_url_rel_course_table url_rel_course ON (code=url_rel_course.course_code)";
}
@ -48,7 +48,7 @@ function get_number_of_courses() {
}
// adding the filter to see the user's only of the current access_url
if ((api_is_platform_admin() || api_is_session_admin()) && $_configuration['multiple_access_urls'] && api_get_current_access_url_id() != -1) {
if ((api_is_platform_admin() || api_is_session_admin()) && api_is_multiple_url_enabled() && api_get_current_access_url_id() != -1) {
$sql.= " AND url_rel_course.access_url_id=".api_get_current_access_url_id();
}
@ -61,23 +61,23 @@ function get_number_of_courses() {
* Get course data to display
*/
function get_course_data($from, $number_of_items, $column, $direction) {
$course_table = Database::get_main_table(TABLE_MAIN_COURSE);
$sql = "SELECT code AS col0,
title AS col1,
code AS col2,
course_language AS col3,
category_code AS col4,
subscribe AS col5,
unsubscribe AS col6,
code AS col7,
visibility AS col8,
$course_table = Database::get_main_table(TABLE_MAIN_COURSE);
$sql = "SELECT code AS col0,
title AS col1,
code AS col2,
course_language AS col3,
category_code AS col4,
subscribe AS col5,
unsubscribe AS col6,
code AS col7,
visibility AS col8,
directory as col9,
visual_code
visual_code
FROM $course_table";
global $_configuration;
if ((api_is_platform_admin() || api_is_session_admin()) && $_configuration['multiple_access_urls'] && api_get_current_access_url_id() != -1) {
if ((api_is_platform_admin() || api_is_session_admin()) && api_is_multiple_url_enabled() && api_get_current_access_url_id() != -1) {
$access_url_rel_course_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$sql.= " INNER JOIN $access_url_rel_course_table url_rel_course ON (code=url_rel_course.course_code)";
}
@ -97,7 +97,7 @@ function get_course_data($from, $number_of_items, $column, $direction) {
}
// Adding the filter to see the user's only of the current access_url.
if ((api_is_platform_admin() || api_is_session_admin()) && $_configuration['multiple_access_urls'] && api_get_current_access_url_id() != -1) {
if ((api_is_platform_admin() || api_is_session_admin()) && api_is_multiple_url_enabled() && api_get_current_access_url_id() != -1) {
$sql.= " AND url_rel_course.access_url_id=".api_get_current_access_url_id();
}
@ -106,12 +106,12 @@ function get_course_data($from, $number_of_items, $column, $direction) {
$res = Database::query($sql);
$courses = array ();
while ($course = Database::fetch_array($res)) {
// Place colour icons in front of courses.
while ($course = Database::fetch_array($res)) {
// Place colour icons in front of courses.
$course[1] = get_course_visibility_icon($course[8]).'<a href="'.api_get_path(WEB_COURSE_PATH).$course[9].'/index.php">'.$course[1].'</a> '.Display::label($course['visual_code'], 'info');
$course[5] = $course[5] == SUBSCRIBE_ALLOWED ? get_lang('Yes') : get_lang('No');
$course[6] = $course[6] == UNSUBSCRIBE_ALLOWED ? get_lang('Yes') : get_lang('No');
$course_rem = array($course[0], $course[1], $course[2], $course[3], $course[4], $course[5], $course[6], $course[7]);
$course_rem = array($course[0], $course[1], $course[2], $course[3], $course[4], $course[5], $course[6], $course[7]);
$courses[] = $course_rem;
}
return $courses;
@ -127,7 +127,7 @@ function modify_filter($code) {
//'<a href="../course_home/course_home.php?cidReq='.$code.'">'.Display::return_icon('course_home.gif', get_lang('CourseHomepage')).'</a>&nbsp;'. // This is not the preferable way to go to the homepage.
'<a href="'.api_get_path(WEB_COURSE_PATH).$icourse['path'].'/index.php">'.Display::return_icon('course_home.gif', get_lang('CourseHomepage')).'</a>&nbsp;'.
'<a href="../tracking/courseLog.php?cidReq='.$code.'">'.Display::return_icon('statistics.gif', get_lang('Tracking')).'</a>&nbsp;'.
'<a href="course_edit.php?course_code='.$code.'">'.Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>&nbsp;'.
'<a href="course_edit.php?course_code='.$code.'">'.Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>&nbsp;'.
'<a href="../coursecopy/backup.php?cidReq='.$code.'">'.Display::return_icon('backup.gif', get_lang('CreateBackup')).'</a>&nbsp;'.
'<a href="course_list.php?delete_course='.$code.'" onclick="javascript: if (!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;">'.Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL).'</a>';
}
@ -156,13 +156,13 @@ function get_course_visibility_icon($v) {
}
}
if (isset ($_POST['action'])) {
switch ($_POST['action']) {
if (isset ($_POST['action'])) {
switch ($_POST['action']) {
// Delete selected courses
case 'delete_courses' :
$course_codes = $_POST['course'];
$course_codes = $_POST['course'];
if (count($course_codes) > 0) {
foreach ($course_codes as $index => $course_code) {
foreach ($course_codes as $index => $course_code) {
CourseManager :: delete_course($course_code);
$obj_cat = new Category();
$obj_cat->update_category_delete($course_code);
@ -181,7 +181,7 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array('url' => 'course_list.php', 'name' => get_lang('CourseList'));
$tool_name = get_lang('SearchACourse');
//api_display_tool_title($tool_name);
$form = new FormValidator('advanced_course_search', 'get');
$form->addElement('header', $tool_name);
@ -213,7 +213,7 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
} else {
$interbreadcrumb[] = array ('url' => 'index.php', "name" => get_lang('PlatformAdmin'));
$tool_name = get_lang('CourseList');
if (isset($_GET['action'])) {
switch ($_GET['action']) {
case 'show_msg':
@ -235,20 +235,20 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
}
// Create a search-box
$form = new FormValidator('search_simple', 'get', '', '', array('class'=>'form-search'), false);
$form = new FormValidator('search_simple', 'get', '', '', array('class'=>'form-search'), false);
$form->addElement('text', 'keyword', null);
$form->addElement('style_submit_button', 'submit', get_lang('SearchCourse'), 'class="btn"');
$form->addElement('static', 'search_advanced_link', null, '<a href="course_list.php?search=advanced">'.get_lang('AdvancedSearch').'</a>');
$actions .= '<div style="float: right; ">';
$actions .= '<div style="float: right; ">';
$actions .= '<a href="course_add.php">'.Display::return_icon('new_course.png', get_lang('AddCourse'),'',ICON_SIZE_MEDIUM).'</a> ';
if (api_get_setting('course_validation') == 'true') {
if (api_get_setting('course_validation') == 'true') {
$actions .= '<a href="course_request_review.php">'.Display::return_icon('course_request_pending.png', get_lang('ReviewCourseRequests'),'',ICON_SIZE_MEDIUM).'</a>';
}
$actions .= '</div>';
$actions .= '</div>';
$actions .= $form->return_form();
// Create a sortable table with the course data
$table = new SortableTable('courses', 'get_number_of_courses', 'get_course_data', 2);
$parameters=array();

@ -6,7 +6,7 @@
* @package chamilo.statistics
*/
class Statistics {
/**
* Converts a number of bytes in a formatted string
* @param int $size
@ -18,7 +18,7 @@ class Statistics {
if ($size >= pow(2,20) && $size < pow(2,30)) return round($size / pow(2,20), 1)." MB";
if ($size > pow(2,30)) return round($size / pow(2,30), 2)." GB";
}
/**
* Count courses
* @param string $category_code Code of a course category. Default: count
@ -30,7 +30,7 @@ class Statistics {
$course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
$access_url_rel_course_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$current_url_id = api_get_current_access_url_id();
if ($_configuration['multiple_access_urls']) {
if (api_is_multiple_url_enabled()) {
$sql = "SELECT COUNT(*) AS number FROM ".$course_table." as c, ".$access_url_rel_course_table." as u WHERE u.course_code=c.code AND access_url_id='".$current_url_id."'";
if (isset ($category_code)) {
$sql .= " AND category_code = '".Database::escape_string($category_code)."'";
@ -82,8 +82,6 @@ class Statistics {
* @return int Number of users counted
*/
static function count_users($status = null, $category_code = null, $count_invisible_courses = true, $only_active = false) {
global $_configuration;
// Database table definitions
$course_user_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
$course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
@ -93,7 +91,7 @@ class Statistics {
$active_filter = $only_active?' AND active=1':'';
$status_filter = isset($status)?' AND status = '.intval($status):'';
if ($_configuration['multiple_access_urls']) {
if (api_is_multiple_url_enabled()) {
$sql = "SELECT COUNT(DISTINCT(u.user_id)) AS number FROM $user_table as u, $access_url_rel_user_table as url WHERE u.user_id=url.user_id AND access_url_id='".$current_url_id."' $status_filter $active_filter";
if (isset ($category_code)) {
$sql = "SELECT COUNT(DISTINCT(cu.user_id)) AS number FROM $course_user_table cu, $course_table c, $access_url_rel_user_table as url WHERE c.code = cu.course_code AND c.category_code = '".Database::escape_string($category_code)."' AND cu.user_id=url.user_id AND access_url_id='".$current_url_id."' $status_filter $active_filter";
@ -137,14 +135,14 @@ class Statistics {
$obj = Database::fetch_object($res);
return $obj->total_number_of_items;
}
/**
* Get activities data to display
*/
static function get_activities_data($from, $number_of_items, $column, $direction) {
global $dateTimeFormatLong, $_configuration;
$track_e_default = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_DEFAULT);
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$access_url_rel_user_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$current_url_id = api_get_current_access_url_id();
@ -189,7 +187,7 @@ class Statistics {
$res = Database::query($sql);
$activities = array ();
while ($row = Database::fetch_row($res)) {
while ($row = Database::fetch_row($res)) {
if (strpos($row[1], '_object') === false) {
$row[2] = $row[2];
} else {
@ -200,7 +198,7 @@ class Statistics {
}
}
}
if (!empty($row['default_date']) && $row['default_date'] != '0000-00-00 00:00:00') {
if (!empty($row['default_date']) && $row['default_date'] != '0000-00-00 00:00:00') {
$row['default_date'] = api_get_local_time($row['default_date']);
} else {
$row['default_date'] = '-';
@ -224,7 +222,7 @@ class Statistics {
}
return $categories;
}
/**
* Rescale data
* @param array $data The data that should be rescaled
@ -244,7 +242,7 @@ class Statistics {
}
return $result;
}
/**
* Show statistics
* @param string $title The title
@ -262,13 +260,13 @@ class Statistics {
foreach ($stats as $subtitle => $number) {
$total += $number;
}
foreach ($stats as $subtitle => $number) {
foreach ($stats as $subtitle => $number) {
if (!$is_file_size) {
$number_label = number_format($number, 0, ',', '.');
} else {
$number_label = Statistics::make_size_string($number);
}
}
$percentage = ($total>0?number_format(100*$number/$total, 1, ',', '.'):'0');
echo '<tr class="row_'.($i%2 == 0 ? 'odd' : 'even').'">
@ -291,7 +289,7 @@ class Statistics {
}
echo '</table>';
}
/**
* Show some stats about the number of logins
* @param string $type month, hour or day
@ -366,7 +364,7 @@ class Statistics {
}
Statistics::print_stats(get_lang('AllLogins').' ('.$period.')', $result, true);
}
/**
* Print the number of recent logins
*/
@ -429,7 +427,7 @@ class Statistics {
}
Statistics::print_stats(get_lang('PlatformToolAccess'),$result,true);
}
/**
* Show some stats about the number of courses per language
*/
@ -440,8 +438,8 @@ class Statistics {
$current_url_id = api_get_current_access_url_id();
if ($_configuration['multiple_access_urls']) {
$sql = "SELECT course_language, count( c.code ) AS number_of_courses ".
"FROM $table as c, $access_url_rel_course_table as u
WHERE u.course_code=c.code AND access_url_id='".$current_url_id."'
"FROM $table as c, $access_url_rel_course_table as u
WHERE u.course_code=c.code AND access_url_id='".$current_url_id."'
GROUP BY course_language ORDER BY number_of_courses DESC";
} else {
$sql = "SELECT course_language, count( code ) AS number_of_courses ".
@ -454,7 +452,7 @@ class Statistics {
}
Statistics::print_stats(get_lang('CountCourseByLanguage'),$result,true);
}
/**
* Shows the number of users having their picture uploaded in Dokeos.
*/
@ -497,7 +495,7 @@ class Statistics {
echo '<div class="actions">';
$form->display();
echo '</div>';
$table = new SortableTable('activities', array('Statistics','get_number_of_activities'), array('Statistics','get_activities_data'),4,50,'DESC');
$parameters = array();
@ -599,9 +597,9 @@ class Statistics {
$message_table = Database::get_main_table(TABLE_MAIN_MESSAGE);
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$current_url_id = api_get_current_access_url_id();
switch ($message_type) {
case 'sent':
$field = 'user_sender_id';
@ -611,7 +609,7 @@ class Statistics {
break;
}
if ($_configuration['multiple_access_urls']) {
$sql = "SELECT lastname, firstname, username, COUNT($field) AS count_message ".
"FROM ".$access_url_rel_user_table." as url, ".$message_table." m ".
"LEFT JOIN ".$user_table." u ON m.$field = u.user_id ".
@ -644,7 +642,7 @@ class Statistics {
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$current_url_id = api_get_current_access_url_id();
if ($_configuration['multiple_access_urls']) {
$sql = "SELECT lastname, firstname, username, COUNT(friend_user_id) AS count_friend ".
"FROM ".$access_url_rel_user_table." as url, ".$user_friend_table." uf ".
@ -666,7 +664,7 @@ class Statistics {
}
return $list_friends;
}
/**
* Print the number of users that didn't login for a certain period of time
*/
@ -684,23 +682,23 @@ class Statistics {
$table_url = '';
$where_url='';
}
$sql[get_lang('Thisday')] =
$sql[get_lang('Thisday')] =
"SELECT count(distinct(login_user_id)) AS number ".
" FROM $table $table_url ".
" WHERE DATE_ADD(login_date, INTERVAL 1 DAY) >= NOW() $where_url";
$sql[get_lang('Last7days')] =
$sql[get_lang('Last7days')] =
"SELECT count(distinct(login_user_id)) AS number ".
" FROM $table $table_url ".
" WHERE DATE_ADD(login_date, INTERVAL 7 DAY) >= NOW() $where_url";
$sql[get_lang('Last31days')] =
$sql[get_lang('Last31days')] =
"SELECT count(distinct(login_user_id)) AS number ".
" FROM $table $table_url ".
" WHERE DATE_ADD(login_date, INTERVAL 31 DAY) >= NOW() $where_url";
$sql[sprintf(get_lang('LastXMonths'),6)] =
$sql[sprintf(get_lang('LastXMonths'),6)] =
"SELECT count(distinct(login_user_id)) AS number ".
" FROM $table $table_url ".
" WHERE DATE_ADD(login_date, INTERVAL 6 MONTH) >= NOW() $where_url";
$sql[get_lang('NeverConnected')] =
$sql[get_lang('NeverConnected')] =
"SELECT count(distinct(login_user_id)) AS number ".
" FROM $table $table_url WHERE 1=1 $where_url";
foreach ($sql as $index => $query) {

@ -32,13 +32,13 @@ define('MESSAGE_STATUS_INVITATION_DENIED', '7');
*/
class MessageManager
{
public static function get_online_user_list($current_user_id) {
public static function get_online_user_list($current_user_id) {
global $_configuration;
//@todo this is a bad idea to parse all users online
$count = who_is_online_count();
$userlist = who_is_online(0, $count, null, null, 30, true);
$online_user_list = array();
foreach ($userlist as $user_id) {
foreach ($userlist as $user_id) {
$online_user_list[$user_id] = GetFullUserName($user_id).($current_user_id==$user_id?("&nbsp;(".get_lang('Myself').")"):(""));
}
return $online_user_list;
@ -96,10 +96,10 @@ class MessageManager
/**
* Get the list of user_ids of users who are online.
*/
public static function users_connected_by_id() {
public static function users_connected_by_id() {
$count = who_is_online_count();
$user_connect = who_is_online(0, $count, null, null, 30, true);
$user_id_list = array();
$user_id_list = array();
for ($i=0; $i<count($user_connect); $i++) {
$user_id_list[$i]=$user_connect[$i][0];
}
@ -146,7 +146,7 @@ class MessageManager
$direction = 'ASC';
}
$table_message = Database::get_main_table(TABLE_MESSAGE);
$sql_query = "SELECT id as col0, user_sender_id as col1, title as col2, send_date as col3, msg_status as col4 FROM $table_message " .
" WHERE user_receiver_id=".api_get_user_id()." AND msg_status IN (0,1)" .
" ORDER BY col$column $direction LIMIT $from,$number_of_items";
@ -154,34 +154,25 @@ class MessageManager
$sql_result = Database::query($sql_query);
$i = 0;
$message_list = array ();
while ($result = Database::fetch_row($sql_result)) {
if ($request===true) {
$message[0] = '<input type="checkbox" value='.$result[0].' name="id[]">';
} else {
$message[0] = ($result[0]);
}
while ($result = Database::fetch_row($sql_result)) {
$message[0] = $result[0];
$result[2] = Security::remove_XSS($result[2], STUDENT, true);
$result[2] = cut($result[2], 80,true);
if ($request===true) {
$message[1] = '<a onclick="get_action_url_and_show_messages(1,'.$result[0].')" href="javascript:void(0)">'.GetFullUserName($result[1]).'</a>';
$message[2] = '<a onclick="get_action_url_and_show_messages(1,'.$result[0].')" href="javascript:void(0)">'.str_replace("\\","",$result[3]).'</a>';
$message[3] = '<a onclick="reply_to_messages(\'show\','.$result[0].',\'\')" href="javascript:void(0)">'.Display::return_icon('message_reply.png',get_lang('ReplyToMessage')).'</a>'.
'&nbsp;&nbsp;<a onclick="delete_one_message('.$result[0].')" href="javascript:void(0)" >'.Display::return_icon('delete.png',get_lang('DeleteMessage')).'</a>';
} else {
if($result[4]==1) {
$class = 'class = "unread"';
} else {
$class = 'class = "read"';
}
$link = '';
if ($_GET['f']=='social') {
$link = '&f=social';
}
$message[1] = '<a '.$class.' href="view_message.php?id='.$result[0].$link.'">'.$result[2].'</a><br />'.GetFullUserName(($result[1]));
$message[3] = '<a href="new_message.php?re_id='.$result[0].'&f='.Security::remove_XSS($_GET['f']).'">'.Display::return_icon('message_reply.png',get_lang('ReplyToMessage')).'</a>'.
'&nbsp;&nbsp;<a onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmDeleteMessage')))."'".')) return false;" href="inbox.php?action=deleteone&id='.$result[0].'&f='.Security::remove_XSS($_GET['f']).'">'.Display::return_icon('delete.png',get_lang('DeleteMessage')).'</a>';
}
if ($result[4]==1) {
$class = 'class = "unread"';
} else {
$class = 'class = "read"';
}
$link = '';
if ($_GET['f']=='social') {
$link = '&f=social';
}
$message[1] = '<a '.$class.' href="view_message.php?id='.$result[0].$link.'">'.$result[2].'</a><br />'.GetFullUserName(($result[1]));
$message[3] = '<a href="new_message.php?re_id='.$result[0].'&f='.Security::remove_XSS($_GET['f']).'">'.Display::return_icon('message_reply.png',get_lang('ReplyToMessage')).'</a>'.
'&nbsp;&nbsp;<a onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmDeleteMessage')))."'".')) return false;" href="inbox.php?action=deleteone&id='.$result[0].'&f='.Security::remove_XSS($_GET['f']).'">'.Display::return_icon('delete.png',get_lang('DeleteMessage')).'</a>';
$message[2] = api_convert_and_format_date($result[3], DATE_TIME_FORMAT_LONG); //date stays the same
foreach($message as $key => $value) {
$message[$key] = api_xml_http_response_encode($value);
@ -191,11 +182,11 @@ class MessageManager
}
return $message_list;
}
/**
* Sends a message to a user/group
*
*
* @param int receiver user id
* @param string subject
* @param string content
@ -207,15 +198,15 @@ class MessageManager
* @param int sender id (optional) the default value is the current user_id
* @return bool
*/
public static function send_message($receiver_user_id, $subject, $content, $file_attachments = array(), $file_comments = array(), $group_id = 0, $parent_id = 0, $edit_message_id = 0, $topic_id = 0, $sender_id = null) {
public static function send_message($receiver_user_id, $subject, $content, $file_attachments = array(), $file_comments = array(), $group_id = 0, $parent_id = 0, $edit_message_id = 0, $topic_id = 0, $sender_id = null) {
$table_message = Database::get_main_table(TABLE_MESSAGE);
$group_id = intval($group_id);
$receiver_user_id = intval($receiver_user_id);
$parent_id = intval($parent_id);
$edit_message_id = intval($edit_message_id);
$topic_id = intval($topic_id);
if (empty($sender_id)) {
if (empty($sender_id)) {
$user_sender_id = api_get_user_id();
} else {
$user_sender_id = intval($sender_id);
@ -234,23 +225,23 @@ class MessageManager
} else if ($total_filesize > intval(api_get_setting('message_max_upload_filesize'))) {
return sprintf(get_lang("FilesSizeExceedsX"),format_file_size(api_get_setting('message_max_upload_filesize')));
}
$inbox_last_id = null;
//Just in case we replace the and \n and \n\r while saving in the DB
$content = str_replace(array("\n", "\n\r"), '<br />', $content);
$content = str_replace(array("\n", "\n\r"), '<br />', $content);
$now = api_get_utc_datetime();
$now = api_get_utc_datetime();
if (!empty($receiver_user_id) || !empty($group_id)) {
// message for user friend
// message for user friend
$clean_subject = Database::escape_string($subject);
$clean_content = Database::escape_string($content);
//message in inbox for user friend
//@todo it's possible to edit a message? yes, only for groups
if ($edit_message_id) {
$query = " UPDATE $table_message SET update_date = '".$now."', content = '$clean_content' WHERE id = '$edit_message_id' ";
//@todo it's possible to edit a message? yes, only for groups
if ($edit_message_id) {
$query = " UPDATE $table_message SET update_date = '".$now."', content = '$clean_content' WHERE id = '$edit_message_id' ";
$result = Database::query($query);
$inbox_last_id = $edit_message_id;
} else {
@ -289,29 +280,29 @@ class MessageManager
}
}
}
//Load user settings
//Load user settings
$notification = new Notification();
$sender_info = api_get_user_info($user_sender_id);
if (empty($group_id)) {
$notification->save_notification(NOTIFICATION_TYPE_MESSAGE, array($receiver_user_id), $subject, $content, $sender_info);
if (empty($group_id)) {
$notification->save_notification(NOTIFICATION_TYPE_MESSAGE, array($receiver_user_id), $subject, $content, $sender_info);
} else {
$group_info = GroupPortalManager::get_group_data($group_id);
$group_info['topic_id'] = $topic_id;
$group_info['msg_id'] = $inbox_last_id;
$user_list = GroupPortalManager::get_users_by_group($group_id, false, array(),0, 1000);
//Adding more sens to the message group
$subject = sprintf(get_lang('ThereIsANewMessageInTheGroupX'), $group_info['name']);
$new_user_list = array();
$subject = sprintf(get_lang('ThereIsANewMessageInTheGroupX'), $group_info['name']);
$new_user_list = array();
foreach($user_list as $user_data) {
$new_user_list[] = $user_data['user_id'];
}
$group_info = array('group_info'=>$group_info, 'user_info' => $sender_info);
$notification->save_notification(NOTIFICATION_TYPE_GROUP, $new_user_list, $subject, $content, $group_info);
$notification->save_notification(NOTIFICATION_TYPE_GROUP, $new_user_list, $subject, $content, $group_info);
}
return $inbox_last_id;
}
@ -324,7 +315,7 @@ class MessageManager
public static function send_message_simple($receiver_user_id, $subject, $message, $sender_id = null) {
return MessageManager::send_message($receiver_user_id, $subject, $message, null, null, null, null, null, null, $sender_id);
}
/**
* Update parent ids for other receiver user from current message in groups
* @author Christian Fasanando Flores
@ -536,7 +527,7 @@ class MessageManager
*/
public static function get_messages_by_group($group_id) {
if ($group_id != strval(intval($group_id))) return false;
$table_message = Database::get_main_table(TABLE_MESSAGE);
$table_message = Database::get_main_table(TABLE_MESSAGE);
$group_id = intval($group_id);
$query = "SELECT * FROM $table_message WHERE group_id= $group_id AND msg_status NOT IN ('".MESSAGE_STATUS_OUTBOX."', '".MESSAGE_STATUS_DELETED."') ORDER BY id";
$rs = Database::query($query);
@ -548,8 +539,8 @@ class MessageManager
}
return $data;
}
/**
* get messages by group id
* @param int group id
@ -557,15 +548,15 @@ class MessageManager
*/
public static function get_messages_by_group_by_message($group_id, $message_id) {
if ($group_id != strval(intval($group_id))) return false;
$table_message = Database::get_main_table(TABLE_MESSAGE);
$table_message = Database::get_main_table(TABLE_MESSAGE);
$group_id = intval($group_id);
$query = "SELECT * FROM $table_message WHERE group_id = $group_id AND msg_status NOT IN ('".MESSAGE_STATUS_OUTBOX."', '".MESSAGE_STATUS_DELETED."') ORDER BY id ";
$rs = Database::query($query);
$data = array();
$parents = array();
if (Database::num_rows($rs) > 0) {
while ($row = Database::fetch_array($rs, 'ASSOC')) {
if (Database::num_rows($rs) > 0) {
while ($row = Database::fetch_array($rs, 'ASSOC')) {
if ($message_id == $row['parent_id'] || in_array($row['parent_id'], $parents)) {
$parents[]= $row['id'];
$data[] = $row;
@ -573,7 +564,7 @@ class MessageManager
}
}
return $data;
}
}
/**
* get messages by parent id optionally with limit
@ -670,7 +661,7 @@ class MessageManager
$message[1] = '<a onclick="show_sent_message('.$result[0].')" href="javascript:void(0)">'.GetFullUserName($result[4]).'</a>';
$message[2] = '<a onclick="show_sent_message('.$result[0].')" href="javascript:void(0)">'.str_replace("\\","",$result[2]).'</a>';
$message[3] = api_convert_and_format_date($result[3], DATE_TIME_FORMAT_LONG); //date stays the same
$message[4] = '&nbsp;&nbsp;<a onclick="delete_one_message_outbox('.$result[0].')" href="javascript:void(0)" >'.Display::return_icon('delete.png',get_lang('DeleteMessage')).'</a>';
} else {
$link = '';
@ -710,11 +701,11 @@ class MessageManager
* display message box in the inbox
* @param int the message id
* @param string inbox or outbox strings are available
* @todo replace numbers with letters in the $row array pff...
* @todo replace numbers with letters in the $row array pff...
* @return string html with the message content
*/
public static function show_message_box($message_id, $source = 'inbox') {
$table_message = Database::get_main_table(TABLE_MESSAGE);
$table_message = Database::get_main_table(TABLE_MESSAGE);
$message_id = intval($message_id);
if ($source == 'outbox') {
@ -733,39 +724,39 @@ class MessageManager
}
$path='inbox.php';
}
$row = Database::fetch_array($result, 'ASSOC');
$row = Database::fetch_array($result, 'ASSOC');
$user_sender_id = $row['user_sender_id'];
// get file attachments by message id
$files_attachments = self::get_links_message_attachment_files($message_id,$source);
$user_con = self::users_connected_by_id();
$band= 0;
$band= 0;
for ($i=0;$i<count($user_con);$i++)
if ($user_sender_id == $user_con[$i])
$band=1;
$title = Security::remove_XSS($row['title'], STUDENT, true);
$content = Security::remove_XSS($row['content'], STUDENT, true);
$from_user = UserManager::get_user_info_by_id($user_sender_id);
$name = api_get_person_name($from_user['firstname'], $from_user['lastname']);
$user_image = UserManager::get_picture_user($row['user_sender_id'], $from_user['picture_uri'],80);
$user_image = Display::img($user_image['file'], $name, array('title'=>$name));
$user_image = Display::img($user_image['file'], $name, array('title'=>$name));
$message_content = Display::page_subheader(str_replace("\\","",$title));
if (api_get_setting('allow_social_tool') == 'true') {
$message_content .= $user_image.' ';
}
$message_content .='<tr>';
if (api_get_setting('allow_social_tool') == 'true') {
if (api_get_setting('allow_social_tool') == 'true') {
if ($source == 'outbox') {
$message_content .= get_lang('From').': <a href="'.api_get_path(WEB_PATH).'main/social/profile.php?u='.$user_sender_id.'">'.$name.'</a> '.api_strtolower(get_lang('To')).'&nbsp;<b>'.GetFullUserName($row[2]).'</b>';
} else {
$message_content .= get_lang('From').' <a href="'.api_get_path(WEB_PATH).'main/social/profile.php?u='.$user_sender_id.'">'.$name.'</a> '.api_strtolower(get_lang('To')).'&nbsp;<b>'.get_lang('Me').'</b>';
}
}
} else {
if ($source == 'outbox') {
$message_content .= get_lang('From').':&nbsp;'.$name.'</b> '.api_strtolower(get_lang('To')).' <b>'.GetFullUserName($row['user_receiver_id']).'</b>';
@ -890,37 +881,37 @@ class MessageManager
* @param int group id
*/
public static function display_messages_for_group($group_id) {
global $my_group_role;
$rows = self::get_messages_by_group($group_id);
global $my_group_role;
$rows = self::get_messages_by_group($group_id);
$topics_per_page = 10;
$html_messages = '';
$query_vars = array('id'=>$group_id, 'topics_page_nr'=>0);
if (is_array($rows) && count($rows) > 0) {
// prepare array for topics with its items
$topics = array();
$x = 0;
foreach($rows as $index => $value) {
$x = 0;
foreach($rows as $index => $value) {
if (empty($value['parent_id'])) {
$topics[$value['id']] = $value;
}
}
$new_topics = array();
foreach ($topics as $id => $value) {
$rows = null;
$rows = self::get_messages_by_group_by_message($group_id, $value['id']);
if (!empty($rows)) {
if (!empty($rows)) {
$count = count(self::calculate_children($rows, $value['id']));
} else {
$count = 0;
}
$value['count'] = $count;
$new_topics[$id] = $value;
}
$new_topics[$id] = $value;
}
//$new_topics = sort_column($new_topics,'count');
$param_names = array_keys($_GET);
$array_html = array();
@ -934,8 +925,8 @@ class MessageManager
$name = api_get_person_name($user_sender_info['firstname'], $user_sender_info['lastname']);
$html .= '<div class="row">';
$items = $topic['count'];
$items = $topic['count'];
$reply_label = ($items == 1) ? get_lang('GroupReply'): get_lang('GroupReplies');
$html .= '<div class="span1">';
@ -950,23 +941,23 @@ class MessageManager
$html .= '<div class="span4">';
$html .= Display::tag('h4', Display::url(Security::remove_XSS($topic['title'], STUDENT, true), 'group_topics.php?id='.$group_id.'&topic_id='.$topic['id']));
if ($my_group_role == GROUP_USER_PERMISSION_ADMIN || $my_group_role == GROUP_USER_PERMISSION_MODERATOR) {
$actions = '<br />'.Display::url(get_lang('Delete'), api_get_path(WEB_CODE_PATH).'social/group_topics.php?action=delete&id='.$group_id.'&topic_id='.$topic['id'], array('class' => 'btn'));
}
$date = '';
$date = '';
if ($topic['send_date']!=$topic['update_date']) {
if (!empty($topic['update_date']) && $topic['update_date'] != '0000-00-00 00:00:00' ) {
$date .= '<div class="message-group-date" > <i>'.get_lang('LastUpdate').' '.date_to_str_ago($topic['update_date']).'</i></div>';
}
} else {
$date .= '<div class="message-group-date"> <i>'.get_lang('Created').' '.date_to_str_ago($topic['send_date']).'</i></div>';
}
}
$html .= $date.$actions;
$html .= '</div>';
$image_path = UserManager::get_user_picture_path_by_id($topic['user_sender_id'], 'web', false, true);
$image_path = UserManager::get_user_picture_path_by_id($topic['user_sender_id'], 'web', false, true);
$image_repository = $image_path['dir'];
$existing_image = $image_path['file'];
@ -978,12 +969,12 @@ class MessageManager
$html .= $user_info;
$html .= '</div>';
//group_topics.php?action=delete&id=3&topic_id=6
//$date.
//$date.
//$html .= Display::div($title.Security::remove_XSS(cut($topic['content'], 150), STUDENT, true).$user_info, array('class'=>'group_discussions_info')).' </tr> '.$actions.'</table>';
//$html .= Display::div($title.Security::remove_XSS(cut($topic['content'], 150), STUDENT, true).$user_info, array('class'=>'group_discussions_info')).' </tr> '.$actions.'</table>';
$html .= '</div>'; //rounded_div
$array_html[] = array($html);
}
// grids for items and topics with paginations
@ -991,62 +982,62 @@ class MessageManager
}
return $html_messages;
}
/**
* Displays messages of a group with nested view
* @param int group id
*/
public static function display_message_for_group($group_id, $topic_id, $is_member, $message_id ) {
global $my_group_role;
$main_message = self::get_message_by_id($topic_id);
global $my_group_role;
$main_message = self::get_message_by_id($topic_id);
if (empty($main_message)) {
return false;
}
$rows = self::get_messages_by_group_by_message($group_id, $topic_id);
$rows = self::calculate_children($rows, $topic_id);
$rows = self::get_messages_by_group_by_message($group_id, $topic_id);
$rows = self::calculate_children($rows, $topic_id);
$current_user_id = api_get_user_id();
$items_per_page = 50;
$query_vars = array('id' => $group_id, 'topic_id' => $topic_id , 'topics_page_nr' => 0);
// Main message
$query_vars = array('id' => $group_id, 'topic_id' => $topic_id , 'topics_page_nr' => 0);
// Main message
$user_link = '';
$links = '';
$main_content = '';
$items_page_nr = null;
$html = '';
$delete_button = '';
if (api_is_platform_admin()) {
$delete_button = Display::url(Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL), 'group_topics.php?action=delete&id='.$group_id.'&topic_id='.$topic_id);
}
$html .= Display::page_subheader(Security::remove_XSS($main_message['title'].$delete_button, STUDENT, true));
$user_sender_info = UserManager::get_user_info_by_id($main_message['user_sender_id']);
$files_attachments = self::get_links_message_attachment_files($main_message['id']);
$name = api_get_person_name($user_sender_info['firstname'], $user_sender_info['lastname']);
$topic_page_nr = isset($_GET['topics_page_nr']) ? intval($_GET['topics_page_nr']) : null;
$links.= '<div id="message-reply-link">';
if (($my_group_role == GROUP_USER_PERMISSION_ADMIN || $my_group_role == GROUP_USER_PERMISSION_MODERATOR) || $main_message['user_sender_id'] == $current_user_id) {
if (($my_group_role == GROUP_USER_PERMISSION_ADMIN || $my_group_role == GROUP_USER_PERMISSION_MODERATOR) || $main_message['user_sender_id'] == $current_user_id) {
$links.= '<a href="'.api_get_path(WEB_CODE_PATH).'social/message_for_group_form.inc.php?view_panel=1&height=390&width=610&&user_friend='.$current_user_id.'&group_id='.$group_id.'&message_id='.$main_message['id'].'&action=edit_message_group&anchor_topic=topic_'.$main_message['id'].'&topics_page_nr='.$topic_page_nr.'&items_page_nr='.$items_page_nr.'&topic_id='.$main_message['id'].'" class="group_message_popup" title="'.get_lang('Edit').'">';
$links.= Display :: return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>';
}
$links.= '&nbsp;&nbsp;<a href="'.api_get_path(WEB_CODE_PATH).'social/message_for_group_form.inc.php?view_panel=1&height=390&width=610&&user_friend='.api_get_user_id().'&group_id='.$group_id.'&message_id='.$main_message['id'].'&action=reply_message_group&anchor_topic=topic_'.$main_message['id'].'&topics_page_nr='.$topic_page_nr.'&items_page_nr='.$items_page_nr.'&topic_id='.$main_message['id'].'" class="group_message_popup" title="'.get_lang('Reply').'">';
$links.= Display :: return_icon('talk.png', get_lang('Reply')).'</a>';
$links.= '</div>';
$image_path = UserManager::get_user_picture_path_by_id($main_message['user_sender_id'], 'web', false, true);
$image_path = UserManager::get_user_picture_path_by_id($main_message['user_sender_id'], 'web', false, true);
$image_repository = $image_path['dir'];
$existing_image = $image_path['file'];
$main_content.= '<div class="message-group-author"><img src="'.$image_repository.$existing_image.'" alt="'.$name.'" width="32" height="32" title="'.$name.'" /></div>';
$user_link = '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php?u='.$main_message['user_sender_id'].'">'.$name.'&nbsp;</a>';
$date = '';
if ($main_message['send_date'] != $main_message['update_date']) {
if (!empty($main_message['update_date']) && $main_message['update_date'] != '0000-00-00 00:00:00' ) {
@ -1055,44 +1046,44 @@ class MessageManager
} else {
$date = '<div class="message-group-date"> '.get_lang('Created').' '.date_to_str_ago($main_message['send_date']).'</div>';
}
$attachment = '<div class="message-attach">'.(!empty($files_attachments)?implode('<br />',$files_attachments):'').'</div>';
$attachment = '<div class="message-attach">'.(!empty($files_attachments)?implode('<br />',$files_attachments):'').'</div>';
$main_content.= '<div class="message-group-content">'.$links.$user_link.' '.$date.$main_message['content'].$attachment.'</div>';
$main_content = Security::remove_XSS($main_content, STUDENT, true);
$html .= Display::div(Display::div(Display::div($main_content, array('class'=>'group_social_sub_item', 'style'=>'background-color:#fff;')), array('class' => 'group_social_item')), array('class' => 'group_social_grid'));
$topic_id = $main_message['id'];
if (is_array($rows) && count($rows)> 0) {
$topics = $rows;
$topics = $rows;
$array_html_items = array();
foreach ($topics as $index => $topic) {
if (empty($topic['id'])) {
continue;
}
$items_page_nr = isset($_GET['items_'.$topic['id'].'_page_nr']) ? intval($_GET['items_'.$topic['id'].'_page_nr']) : null;
$items_page_nr = isset($_GET['items_'.$topic['id'].'_page_nr']) ? intval($_GET['items_'.$topic['id'].'_page_nr']) : null;
$user_link = '';
$links = '';
$html_items = '';
$user_sender_info = UserManager::get_user_info_by_id($topic['user_sender_id']);
$files_attachments = self::get_links_message_attachment_files($topic['id']);
$name = api_get_person_name($user_sender_info['firstname'], $user_sender_info['lastname']);
$links.= '<div id="message-reply-link">';
$links.= '<div id="message-reply-link">';
if (($my_group_role == GROUP_USER_PERMISSION_ADMIN || $my_group_role == GROUP_USER_PERMISSION_MODERATOR) || $topic['user_sender_id'] == $current_user_id) {
$links.= '<a href="'.api_get_path(WEB_CODE_PATH).'social/message_for_group_form.inc.php?view_panel=1&height=390&width=610&&user_friend='.$current_user_id.'&group_id='.$group_id.'&message_id='.$topic['id'].'&action=edit_message_group&anchor_topic=topic_'.$topic_id.'&topics_page_nr='.$topic_page_nr.'&items_page_nr='.$items_page_nr.'&topic_id='.$topic_id.'" class="group_message_popup" title="'.get_lang('Edit').'">'.Display :: return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>';
}
}
$links.= '&nbsp;&nbsp;<a href="'.api_get_path(WEB_CODE_PATH).'social/message_for_group_form.inc.php?view_panel=1&height=390&width=610&&user_friend='.api_get_user_id().'&group_id='.$group_id.'&message_id='.$topic['id'].'&action=reply_message_group&anchor_topic=topic_'.$topic_id.'&topics_page_nr='.$topic_page_nr.'&items_page_nr='.$items_page_nr.'&topic_id='.$topic_id.'" class="group_message_popup" title="'.get_lang('Reply').'">';
$links.= Display :: return_icon('talk.png', get_lang('Reply')).'</a>';
$links.= '</div>';
$image_path = UserManager::get_user_picture_path_by_id($topic['user_sender_id'], 'web', false, true);
$image_path = UserManager::get_user_picture_path_by_id($topic['user_sender_id'], 'web', false, true);
$image_repository = $image_path['dir'];
$existing_image = $image_path['file'];
$html_items.= '<div class="message-group-author"><img src="'.$image_repository.$existing_image.'" alt="'.$name.'" width="32" height="32" title="'.$name.'" /></div>';
$user_link = '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php?u='.$topic['user_sender_id'].'">'.$name.'&nbsp;</a>';
$date = '';
if ($topic['send_date'] != $topic['update_date']) {
if (!empty($topic['update_date']) && $topic['update_date'] != '0000-00-00 00:00:00' ) {
@ -1101,13 +1092,13 @@ class MessageManager
} else {
$date = '<div class="message-group-date"> '.get_lang('Created').' '.date_to_str_ago($topic['send_date']).'</div>';
}
$attachment = '<div class="message-attach">'.(!empty($files_attachments)?implode('<br />',$files_attachments):'').'</div>';
$html_items.= '<div class="message-group-content">'.$links.$user_link.' '.$date.Security::remove_XSS($topic['content'], STUDENT, true).$attachment.'</div>';
$attachment = '<div class="message-attach">'.(!empty($files_attachments)?implode('<br />',$files_attachments):'').'</div>';
$html_items.= '<div class="message-group-content">'.$links.$user_link.' '.$date.Security::remove_XSS($topic['content'], STUDENT, true).$attachment.'</div>';
$base_padding = 20;
if ($topic['indent_cnt'] == 0) {
$indent = $base_padding;
$indent = $base_padding;
} else {
$indent = intval($topic['indent_cnt'])*$base_padding + $base_padding;
}
@ -1115,23 +1106,23 @@ class MessageManager
if (isset($message_id) && $message_id == $topic['id']) {
$class .= ' group_social_sub_item_highlight';
}
$html_items = Display::div($html_items, array('class' => $class, 'id'=>'msg_'.$topic['id']));
$html_items = Display::div($html_items, array('class' => '', 'style'=>'margin-left:'.$indent.'px'));
$html_items = Display::div($html_items, array('class' => '', 'style'=>'margin-left:'.$indent.'px'));
$array_html_items[] = array($html_items);
}
}
// grids for items with paginations
$options = array('hide_navigation' => false, 'per_page' => $items_per_page);
$visibility = array(true, true, true, false);
$style_class = array('item' => array('class'=>'group_social_item'), 'main' => array('class'=>'group_social_grid'));
if (!empty($array_html_items)) {
$html .= Display::return_sortable_grid('items_'.$topic['id'], array(), $array_html_items, $options, $query_vars, null, $visibility, false, $style_class);
}
}
}
return $html;
}
}
/**
* Add children to messages by id is used for nested view messages
* @param array rows of messages
@ -1142,10 +1133,10 @@ class MessageManager
foreach($rows as $row) {
$rows_with_children[$row["id"]]=$row;
$rows_with_children[$row["parent_id"]]["children"][]=$row["id"];
}
$rows = $rows_with_children;
$sorted_rows = array(0=>array());
self::message_recursive_sort($rows, $sorted_rows, $first_seed);
}
$rows = $rows_with_children;
$sorted_rows = array(0=>array());
self::message_recursive_sort($rows, $sorted_rows, $first_seed);
unset($sorted_rows[0]);
return $sorted_rows;
}
@ -1159,14 +1150,14 @@ class MessageManager
* @return void
*/
public static function message_recursive_sort($rows, &$messages, $seed=0, $indent=0) {
if ($seed > 0 && isset($rows[$seed]["id"])) {
if ($seed > 0 && isset($rows[$seed]["id"])) {
$messages[$rows[$seed]["id"]]=$rows[$seed];
$messages[$rows[$seed]["id"]]["indent_cnt"]=$indent;
$indent++;
}
if (isset($rows[$seed]["children"])) {
foreach($rows[$seed]["children"] as $child) {
if (isset($rows[$seed]["children"])) {
foreach($rows[$seed]["children"] as $child) {
self::message_recursive_sort($rows, $messages, $child, $indent);
}
}
@ -1231,27 +1222,27 @@ class MessageManager
}
return $item;
}
static function generate_message_form($id, $params = array()) {
$form = new FormValidator('send_message', null, 'post', null, array('id'=>$id.'_form', 'class' =>'form-vertical'));
$form->addElement('text', 'subject', get_lang('Subject'), array('id' => 'subject_id', 'class' => 'span5'));
$form->addElement('textarea', 'content', get_lang('Message'), array('id' => 'content_id', 'rows' => '5', 'class' => 'span5'));
$div = Display::div($form->return_form(), array('id' => $id.'_div', 'style' => 'display:none'));
$div = Display::div($form->return_form(), array('id' => $id.'_div', 'style' => 'display:none'));
return $div;
}
static function generate_invitation_form($id , $params = array()) {
$form = new FormValidator('send_invitation', null, 'post', null, array('id'=>$id.'_form','class' =>'form-vertical'));
//$form->addElement('text', 'subject', get_lang('Subject'), array('id' => 'subject_id'));
$form->addElement('textarea', 'content', get_lang('AddPersonalMessage'), array('id' => 'content_invitation_id', 'rows' => '5', 'class' => 'span5'));
$div = Display::div($form->return_form(), array('id' => $id.'_div', 'style' => 'display:none'));
$div = Display::div($form->return_form(), array('id' => $id.'_div', 'style' => 'display:none'));
return $div;
}
//@todo this functions should be in the message class
static function inbox_display() {
global $charset;
global $charset;
$success = get_lang('SelectedMessagesDeleted');
$html = '';
@ -1266,31 +1257,31 @@ class MessageManager
break;
case 'deleteone' :
MessageManager::delete_message_by_user_receiver(api_get_user_id(), $_GET['id']);
$html .= Display::return_message(api_xml_http_response_encode($success),'confirmation', false);
$html .= Display::return_message(api_xml_http_response_encode($success),'confirmation', false);
break;
}
}
// display sortable table with messages of the current user
// display sortable table with messages of the current user
$table = new SortableTable('message_inbox', array('MessageManager','get_number_of_messages'), array('MessageManager','get_message_data'),3,20,'DESC');
$table->set_header(0, '', false,array ('style' => 'width:15px;'));
$title=api_xml_http_response_encode(get_lang('Title'));
$action=api_xml_http_response_encode(get_lang('Modify'));
$table->set_header(1,api_xml_http_response_encode(get_lang('Messages')),false);
$table->set_header(1,api_xml_http_response_encode(get_lang('Messages')),false);
$table->set_header(2,api_xml_http_response_encode(get_lang('Date')),true, array('style' => 'width:180px;'));
$table->set_header(3,$action,false,array ('style' => 'width:70px;'));
if ($_REQUEST['f']=='social') {
$parameters['f'] = 'social';
$table->set_additional_parameters($parameters);
}
}
$table->set_form_actions(array ('delete' => get_lang('DeleteSelectedMessages')));
$html .= $table->return_table();
return $html;
return $html;
}
static function outbox_display() {
static function outbox_display() {
$request=api_is_xml_http_request();
global $charset;
@ -1319,7 +1310,7 @@ class MessageManager
}
}
// display sortable table with messages of the current user
// display sortable table with messages of the current user
$table = new SortableTable('message_outbox', array('MessageManager','get_number_of_messages_sent'), array('MessageManager','get_message_data_sent'),3,20,'DESC');
$parameters['f'] = Security::remove_XSS($_GET['f']);
@ -1348,7 +1339,7 @@ class MessageManager
$table->set_form_actions(array ('delete' => get_lang('DeleteSelectedMessages')));
$html .= $table->return_table();
}
return $html;
return $html;
}
}

@ -134,6 +134,7 @@ if (api_get_setting('allow_social_tool') == 'true') {
}
//Right content
$social_right_content = null;
if (api_get_setting('allow_social_tool') == 'true') {
$social_right_content .= '<div class="span9">';
@ -163,10 +164,9 @@ if (api_get_setting('allow_social_tool') == 'true') {
$social_right_content .= '</div>';
}
$tpl = new Template($tool_name);
$tpl = new Template(null);
if (api_get_setting('allow_social_tool') == 'true') {
$tpl->assign('social_left_content', $social_left_content);
$tpl->assign('social_left_menu', $social_left_menu);
$tpl->assign('social_right_content', $social_right_content);
$social_layout = $tpl->get_template('layout/social_layout.tpl');
$tpl->display($social_layout);

@ -679,11 +679,7 @@ $social_right_content .= MessageManager::generate_invitation_form('send_invitati
$tpl = new Template(get_lang('Social'));
$tpl->assign('social_left_content', $social_left_content);
$tpl->assign('social_left_menu', $social_left_menu);
$tpl->assign('social_right_content', $social_right_content);
$tpl->assign('actions', $actions);
$tpl->assign('message', $message);
$tpl->assign('content', $content);
$social_layout = $tpl->get_template('layout/social_layout.tpl');
$tpl->display($social_layout);

@ -29,7 +29,7 @@ $this_section = SECTION_SOCIAL;
// table definitions
$track_user_table = Database::get_main_table(TABLE_MAIN_USER);
$htmlHeadXtra[] = '<script>
function show_image(image,width,height) {
width = parseInt(width) + 20;
height = parseInt(height) + 20;
@ -56,16 +56,16 @@ function hide_display_message () {
$("#txt_area_invite").val("");
}
}
function show_icon_edit(element_html) {
function show_icon_edit(element_html) {
ident="#edit_image";
$(ident).show();
}
}
function hide_icon_edit(element_html) {
ident="#edit_image";
$(ident).hide();
}
}
$(document).ready(function() {
@ -73,12 +73,12 @@ $(document).ready(function() {
page = $("#link_load_more_items").attr("data_link");
$.ajax({
beforeSend: function(objeto) {
$("#display_response_id").html("'.addslashes(get_lang('Loading')).'");
$("#display_response_id").html("'.addslashes(get_lang('Loading')).'");
},
type: "GET",
url: "main/inc/ajax/online.ajax.php?a=load_online_user",
data: "online_page_nr="+page,
success: function(data) {
success: function(data) {
$("#display_response_id").html("");
if (data != "end") {
$("#link_load_more_items").remove();
@ -88,9 +88,9 @@ $(document).ready(function() {
$("#link_load_more_items").remove();
}
}
});
});
});
});
});
</script>';
@ -102,7 +102,7 @@ if ($_GET['chatid'] != '') {
if ($_GET['chatid'] == strval(intval($_GET['chatid']))) {
$sql = "update $track_user_table set chatcall_user_id = '".Database::escape_string($_user['user_id'])."', chatcall_date = '".Database::escape_string($time)."', chatcall_text = '' where (user_id = ".(int)Database::escape_string($chatid).")";
$result = Database::query($sql);
//redirect caller to chat
//redirect caller to chat
header("Location: ".api_get_path(WEB_CODE_PATH)."chat/chat.php?".api_get_cidreq()."&origin=whoisonline&target=".Security::remove_XSS($chatid));
exit;
}
@ -114,39 +114,39 @@ if ((api_get_setting('showonline', 'world') == 'true' && !$_user['user_id']) ||
if(isset($_GET['cidReq']) && strlen($_GET['cidReq']) > 0 ) {
$user_list = who_is_online_in_this_course(0, 9, api_get_user_id(), api_get_setting('time_limit_whosonline'), $_GET['cidReq']);
} else {
$user_list = who_is_online(0, 9);
$user_list = who_is_online(0, 9);
}
if (!isset($_GET['id'])) {
if (!isset($_GET['id'])) {
if (api_get_setting('allow_social_tool') == 'true') {
if (!api_is_anonymous()) {
if (!api_is_anonymous()) {
//this include the social menu div
$social_left_content = SocialManager::show_social_menu('whoisonline');
}
$social_left_content = SocialManager::show_social_menu('whoisonline');
}
}
}
if ($user_list) {
if (!isset($_GET['id'])) {
if (api_get_setting('allow_social_tool') == 'true') {
if (api_get_setting('allow_social_tool') == 'true') {
if (!api_is_anonymous()) {
$query = isset($_GET['q']) ? $_GET['q']: null;
$query = isset($_GET['q']) ? $_GET['q']: null;
$social_right_content .= '<div class="span9">'.UserManager::get_search_form($query).'</div>';
}
}
$social_right_content .= SocialManager::display_user_list($user_list);
}
$social_right_content .= SocialManager::display_user_list($user_list);
}
}
if (isset($_GET['id'])) {
if (api_get_setting('allow_social_tool') == 'true') {
if (isset($_GET['id'])) {
if (api_get_setting('allow_social_tool') == 'true') {
header("Location: ".api_get_path(WEB_CODE_PATH)."social/profile.php?u=".intval($_GET['id']));
exit;
} else {
SocialManager::display_individual_user($_GET['id']);
SocialManager::display_individual_user($_GET['id']);
}
}
} else {
} else {
api_not_allowed();
exit;
}
@ -158,13 +158,12 @@ if (api_get_setting('allow_social_tool') == 'true' && !api_is_anonymous()) {
//$tpl->assign('social_left_menu', $social_left_menu);
$tpl->assign('social_right_content', $social_right_content);
$social_layout = $tpl->get_template('layout/social_layout.tpl');
$content = $tpl->fetch($social_layout);
$tpl->display($social_layout);
} else {
$content = $social_right_content;
}
$tpl->assign('actions', $actions);
$tpl->assign('message', $show_message);
$tpl->assign('header', get_lang('UsersOnLineList'));
$tpl->assign('content', $content);
$tpl->display_one_col_template();
$tpl->assign('actions', $actions);
$tpl->assign('message', $show_message);
$tpl->assign('header', get_lang('UsersOnLineList'));
$tpl->assign('content', $content);
$tpl->display_one_col_template();
}
Loading…
Cancel
Save