/**
  * Returns an HTML block with the user picture (as a link in a <div>)
  * @param int User ID (if not provided, will use the user ID from session)
  * @return string HTML div with a link to the user's profile
  * @uses UserManager::get_user_pictur_path_by_id() to get the image path
  * @uses UserManager::get_picture_user() to get the details of the image in a specific format
  * @uses PageController::show_right_block() to include the image in a larger user block
  * @assert (-1) === false
  */
 public function setUserImageBlock($user_id = null)
 {
     if (empty($user_id)) {
         $user_id = api_get_user_id();
     }
     //Always show the user image
     $img_array = UserManager::get_user_picture_path_by_id($user_id, 'web', true, true);
     $no_image = false;
     if ($img_array['file'] == 'unknown.jpg') {
         $no_image = true;
     }
     $img_array = UserManager::get_picture_user($user_id, $img_array['file'], 100, USER_IMAGE_SIZE_ORIGINAL);
     $profile_content = null;
     if (api_get_setting('allow_social_tool') == 'true') {
         if (!$no_image) {
             $profile_content .= '<a style="text-align:center" href="' . api_get_path(WEB_CODE_PATH) . 'social/home.php">
                                 <img src="' . $img_array['file'] . '"></a>';
         } else {
             $profile_content .= '<a style="text-align:center"  href="' . api_get_path(WEB_CODE_PATH) . 'auth/profile.php">
                                 <img title="' . get_lang('EditProfile') . '" src="' . $img_array['file'] . '"></a>';
         }
     }
     if (!empty($profile_content)) {
         $this->show_right_block(null, null, 'user_image_block', array('content' => $profile_content));
     }
 }
Exemple #2
0
 $groups = $usergroup->get_all_group_tags($_GET['q']);
 if (empty($users) && empty($groups)) {
     $social_right_content .= get_lang('SorryNoResults');
 }
 $results = '<div id="online_grid_container"><div class="col-md-12">';
 if (is_array($users) && count($users) > 0) {
     $results .= Display::page_subheader(get_lang('Users'));
     $results .= '<ul class="thumbnails">';
     foreach ($users as $user) {
         $user_info = api_get_user_info($user['user_id'], true);
         $url = $user_info['profile_url'];
         if (empty($user['picture_uri'])) {
             $picture['file'] = api_get_path(WEB_IMG_PATH) . 'unknown_180_100.jpg';
             $img = '<img src="' . $picture['file'] . '">';
         } else {
             $picture = UserManager::get_picture_user($user['user_id'], $user['picture_uri'], 80, USER_IMAGE_SIZE_ORIGINAL);
             $img = '<img src="' . $picture['file'] . '">';
         }
         if ($user_info['user_is_online']) {
             $status_icon = Display::span('', array('class' => 'online_user_in_text'));
         } else {
             $status_icon = Display::span('', array('class' => 'offline_user_in_text'));
         }
         $user['tag'] = isset($user['tag']) ? $user['tag'] : null;
         $user_info['complete_name'] = Display::url($status_icon . $user_info['complete_name'], $url) . '<br />' . $user['tag'];
         $results .= '<li class="col-md-3"><div class="thumbnail">' . $img . '<div class="caption">' . $user_info['complete_name'] . $user['tag'] . '</div</div></li>';
     }
     $results .= '</ul></div></div>';
     $social_right_content .= $results;
 }
 $grid_groups = array();
Exemple #3
0
/**
 * Get the users to display on the current page (fill the sortable-table)
 * @param   int     offset of first user to recover
 * @param   int     Number of users to get
 * @param   int     Column to sort on
 * @param   string  Order (ASC,DESC)
 * @see SortableTable#get_table_data($from)
 */
function get_user_data($from, $number_of_items, $column, $direction)
{
    $user_table = Database :: get_main_table(TABLE_MAIN_USER);

    if (api_is_western_name_order()) {
        $col34 = "u.firstname AS col3,
                  u.lastname AS col4,";
    } else {
        $col34 = "u.lastname AS col3,
                  u.firstname AS col4,";
    }

    $sql = "SELECT
                 u.user_id AS col0,
                 u.official_code AS col2,
		 $col34
                 u.username AS col5,
                 u.email AS col6,
                 u.status AS col7,
                 u.active AS col8,
                 u.user_id AS col9,
              u.expiration_date AS exp
           FROM $user_table u ";

    if (isset($_GET['keyword'])) {
        $keyword = Database::escape_string(trim($_GET['keyword']));
        $sql .= " WHERE (u.firstname LIKE '%$keyword%' OR
                  u.lastname LIKE '%$keyword%' OR
                  concat(u.firstname,' ',u.lastname) LIKE '%$keyword%' OR
                  concat(u.lastname,' ',u.firstname) LIKE '%$keyword%' OR
                  u.username LIKE '%$keyword%'  OR
                  u.official_code LIKE '%$keyword%'
                  OR u.email LIKE '%$keyword%' )";
    }
    if (!in_array($direction, array('ASC', 'DESC'))) {
        $direction = 'ASC';
    }
    $column = intval($column);
    $from = intval($from);
    $number_of_items = intval($number_of_items);

    $sql .= " ORDER BY col$column $direction ";
    $sql .= " LIMIT $from,$number_of_items";

    $res = Database::query($sql);

    $users = array();
    $webPath = api_get_path(WEB_PATH);
    $selfPath = api_get_self();
    while ($user = Database::fetch_row($res)) {
        $image_path = UserManager::get_user_picture_path_by_id($user[0], 'web', false, true);
        $user_profile = UserManager::get_picture_user($user[0], $image_path['file'], 22, USER_IMAGE_SIZE_SMALL, ' width="22" height="22" ');
        if (!api_is_anonymous()) {
            $photo = '<center><a href="' . $webPath . 'whoisonline.php?origin=user_list&id=' . $user[0] . '" title="' . get_lang('Info') . '"><img src="' . $user_profile['file'] . '" ' . $user_profile['style'] . ' alt="' . api_get_person_name($user[2], $user[3]) . '"  title="' . api_get_person_name($user[2], $user[3]) . '" /></a></center>';
        } else {
            $photo = '<center><img src="' . $user_profile['file'] . '" ' . $user_profile['style'] . ' alt="' . api_get_person_name($user[2], $user[3]) . '" title="' . api_get_person_name($user[2], $user[3]) . '" /></center>';
        }
        $user_id = $user[0];
        $button = '<a href="' . $selfPath . '?user_request=' . $user[0] . '">' . Display::return_icon('view_more_stats.gif', get_lang('Info')) . '</a>';
        $button = '<a  href="javascript:void(0)" onclick="load_course_list(\'div_' . $user_id . '\',' . $user_id . ')">
					<img onclick="load_course_list(\'div_' . $user_id . '\',' . $user_id . ')"  src="' . $webPath . 'img/view_more_stats.gif" title="' . get_lang('Courses') . '" alt="' . get_lang('Courses') . '"/>
					</a>&nbsp;&nbsp;';
        $users[] = array($photo, $user[1], $user[2], $user[3], $user[4], $user[5], $button);
    }
    return $users;
}
Exemple #4
0
                        $icon = Display::return_icon(
                            'social_group_moderator.png',
                            get_lang('Moderator')
                        );
                    } else {
                        $icon = '';
                    }
                    $image_path = UserManager::get_user_picture_path_by_id(
                        $member['user_id'],
                        'web',
                        false,
                        true
                    );
                    $picture = UserManager::get_picture_user(
                        $member['user_id'],
                        $image_path['file'],
                        60,
                        USER_IMAGE_SIZE_MEDIUM
                    );

                    $member_content .= '<div class="">';
                    $member_name = Display::url(
                        api_get_person_name(
                            cut($member['firstname'], 15),
                            cut($member['lastname'], 15)
                        ) . '&nbsp;' . $icon,
                        'profile.php?u=' . $member['user_id']
                    );
                    $member_content .= Display::div(
                        '<img height="44" border="2" align="middle" vspace="10" class="social-groups-image" src="' . $picture['file'] . '"/>&nbsp' . $member_name
                    );
                    $member_content .= '</div>';
 function return_user_image_block() {
     $img_array = UserManager::get_user_picture_path_by_id(api_get_user_id(), 'web', true, true);
     $img_array = UserManager::get_picture_user(api_get_user_id(), $img_array['file'], 50, USER_IMAGE_SIZE_MEDIUM, ' width="90" height="90" ');
     $profile_content = null;
     if (api_get_setting('allow_social_tool') == 'true') {
         $profile_content .='<a style="text-align:center" href="'.api_get_path(WEB_PATH).'main/social/home.php"><img src="'.$img_array['file'].'"  '.$img_array['style'].' ></a>';
     } else {
         $profile_content .='<a style="text-align:center"  href="'.api_get_path(WEB_PATH).'main/auth/profile.php"><img title="'.get_lang('EditProfile').'" src="'.$img_array['file'].'" '.$img_array['style'].'></a>';
     }
     $html = self::show_right_block(null, $profile_content, 'user_image_block', array('style' => 'text-align:center;'));
     return $html;
 }
 /**
  * Get registered users inside current course
  * @param 	int	   attendance id for showing attendance result field (optional)
  * @return 	array  users data
  */
 public function get_users_rel_course($attendance_id = 0)
 {
     $current_course_id = $this->get_course_id();
     $courseInfo = api_get_course_info($current_course_id);
     $courseId = $courseInfo['real_id'];
     $current_session_id = $this->get_session_id();
     if (!empty($current_session_id)) {
         $a_course_users = CourseManager::get_user_list_from_course_code($current_course_id, $current_session_id, '', 'lastname');
     } else {
         $a_course_users = CourseManager::get_user_list_from_course_code($current_course_id, 0, '', 'lastname');
     }
     // get registered users inside current course
     $a_users = array();
     foreach ($a_course_users as $key => $user_data) {
         $value = array();
         $uid = $user_data['user_id'];
         $status = $user_data['status'];
         $user_status_in_session = null;
         $user_status_in_course = null;
         if ($current_session_id) {
             $user_status_in_session = SessionManager::get_user_status_in_course_session($uid, $courseId, $current_session_id);
         } else {
             $user_status_in_course = CourseManager::get_user_in_course_status($uid, $courseId);
         }
         //Not taking into account DRH or COURSEMANAGER
         if ($uid <= 1 || $status == DRH || $user_status_in_course == COURSEMANAGER || $user_status_in_session == 2) {
             continue;
         }
         if (!empty($attendance_id)) {
             $user_faults = $this->get_faults_of_user($uid, $attendance_id);
             $value['attendance_result'] = $user_faults['faults'] . '/' . $user_faults['total'] . ' (' . $user_faults['faults_porcent'] . '%)';
             $value['result_color_bar'] = $user_faults['color_bar'];
         }
         // user's picture
         $image_path = UserManager::get_user_picture_path_by_id($uid, 'web', false);
         $user_profile = UserManager::get_picture_user($uid, $image_path['file'], 22, USER_IMAGE_SIZE_SMALL, ' width="22" height="22" ');
         if (!empty($image_path['file'])) {
             $photo = '<center><a class="thickbox" href="' . $image_path['dir'] . $image_path['file'] . '"  ><img src="' . $user_profile['file'] . '" ' . $user_profile['style'] . ' alt="' . api_get_person_name($user_data['firstname'], $user_data['lastname']) . '"  title="' . api_get_person_name($user_data['firstname'], $user_data['lastname']) . '" /></a></center>';
         } else {
             $photo = '<center><img src="' . $user_profile['file'] . '" ' . $user_profile['style'] . ' alt="' . api_get_person_name($user_data['firstname'], $user_data['lastname']) . '"  title="' . api_get_person_name($user_data['firstname'], $user_data['lastname']) . '" /></center>';
         }
         $value['photo'] = $photo;
         $value['firstname'] = $user_data['firstname'];
         $value['lastname'] = $user_data['lastname'];
         $value['username'] = $user_data['username'];
         $value['user_id'] = $uid;
         //Sending only 5 items in the array instead of 60
         $a_users[$key] = $value;
     }
     return $a_users;
 }
    /**
     * 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...
     * @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);
        $message_id = intval($message_id);
        if ($source == 'outbox') {
            if (isset($message_id) && is_numeric($message_id)) {
                $query = "SELECT * FROM {$table_message}\n                          WHERE user_sender_id=" . api_get_user_id() . " AND id=" . $message_id . " AND msg_status=4;";
                $result = Database::query($query);
                $path = 'outbox.php';
            }
        } else {
            if (is_numeric($message_id) && !empty($message_id)) {
                $query = "UPDATE {$table_message} SET msg_status = '" . MESSAGE_STATUS_NEW . "'\n                          WHERE user_receiver_id=" . api_get_user_id() . " AND id='" . $message_id . "';";
                Database::query($query);
                $query = "SELECT * FROM {$table_message}\n                          WHERE msg_status<>4 AND user_receiver_id=" . api_get_user_id() . " AND id='" . $message_id . "';";
                $result = Database::query($query);
            }
            $path = 'inbox.php';
        }
        $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;
        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));
        $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 ($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>';
            } else {
                $message_content .= get_lang('From') . ':&nbsp;' . $name . '</b> ' . api_strtolower(get_lang('To')) . ' <b>' . get_lang('Me') . '</b>';
            }
        }
        $message_content .= ' ' . get_lang('Date') . ':  ' . api_get_local_time($row['send_date']) . '
		        <br />
		        <hr style="color:#ddd" />
		        <table height="209px" width="100%">
		            <tr>
		              <td valign=top class="view-message-content">' . str_replace("\\", "", $content) . '</td>
		            </tr>
		        </table>
		        <div id="message-attach">' . (!empty($files_attachments) ? implode('<br />', $files_attachments) : '') . '</div>
		        <div style="padding: 15px 0px 5px 0px">';
        $social_link = '';
        if (isset($_GET['f']) && $_GET['f'] == 'social') {
            $social_link = 'f=social';
        }
        if ($source == 'outbox') {
            $message_content .= '<a href="outbox.php?' . $social_link . '">' . Display::return_icon('back.png', get_lang('ReturnToOutbox')) . '</a> &nbsp';
        } else {
            $message_content .= '<a href="inbox.php?' . $social_link . '">' . Display::return_icon('back.png', get_lang('ReturnToInbox')) . '</a> &nbsp';
            $message_content .= '<a href="new_message.php?re_id=' . $message_id . '&' . $social_link . '">' . Display::return_icon('message_reply.png', get_lang('ReplyToMessage')) . '</a> &nbsp';
        }
        $message_content .= '<a href="inbox.php?action=deleteone&id=' . $message_id . '&' . $social_link . '" >' . Display::return_icon('delete.png', get_lang('DeleteMessage')) . '</a>&nbsp';
        $message_content .= '</div></td>
		      <td width=10></td>
		    </tr>
		</table>';
        return $message_content;
    }
/**
 * This function displays the user image from the profile, with a link to the user's details.
 * @param   int     User's database ID
 * @param   str     User's name
 * @return  string  An HTML with the anchor and the image of the user
 * @author Julio Montoya <*****@*****.**>
 */
function display_user_image($user_id, $name, $origin = '')
{
    $link = '<a href="../user/userInfo.php?uInfo=' . $user_id . '" ' . (!empty($origin) ? 'target="_self"' : '') . '>';
    if ($user_id != 0) {
        $image_path = UserManager::get_user_picture_path_by_id($user_id, 'web', false, true);
        $friends_profile = UserManager::get_picture_user($user_id, $image_path['file'], 0, USER_IMAGE_SIZE_MEDIUM, 'width="96" height="96" ');
        return $link . '<img src="' . $friends_profile['file'] . '" ' . $friends_profile['style'] . ' alt="' . $name . '"  title="' . $name . '" /></a>';
    } else {
        return $link . '<img src="' . api_get_path(WEB_CODE_PATH) . "img/unknown.jpg" . '" alt="' . $name . '"  title="' . $name . '" /></a>';
    }
}
Exemple #9
0
 /**
  * Displays a sortable table with the list of online users.
  * @param array $user_list
  */
 public static function display_user_list($user_list)
 {
     if (!isset($_GET['id'])) {
         $html = null;
         $column_size = '9';
         $add_row = false;
         if (api_is_anonymous()) {
             $column_size = '12';
             $add_row = true;
         }
         $extra_params = array();
         $course_url = '';
         if (isset($_GET['cidReq']) && !empty($_GET['cidReq'])) {
             $extra_params['cidReq'] = Security::remove_XSS($_GET['cidReq']);
             $course_url = '&amp;cidReq=' . Security::remove_XSS($_GET['cidReq']);
         }
         if ($add_row) {
             $html .= '<div class="row">';
         }
         $html .= '<div class="span' . $column_size . '">';
         $html .= '<ul id="online_grid_container" class="thumbnails">';
         foreach ($user_list as $uid) {
             $user_info = api_get_user_info($uid);
             //Anonymous users can't have access to the profile
             if (!api_is_anonymous()) {
                 if (api_get_setting('allow_social_tool') == 'true') {
                     $url = $user_info['profile_url'] . $course_url;
                 } else {
                     $url = '?id=' . $uid . $course_url;
                 }
             } else {
                 $url = '#';
             }
             $image_array = UserManager::get_user_picture_path_by_id($uid, 'system', false, true);
             // reduce image
             $name = $user_info['complete_name'];
             $status_icon = Display::span('', array('class' => 'online_user_in_text'));
             $user_status = $user_info['status'] == 1 ? Display::span('', array('class' => 'teacher_online')) : Display::span('', array('class' => 'student_online'));
             if ($image_array['file'] == 'unknown.jpg' || !file_exists($image_array['dir'] . $image_array['file'])) {
                 $friends_profile['file'] = api_get_path(WEB_IMG_PATH) . 'unknown_180_100.jpg';
                 $img = '<img title = "' . $name . '" alt="' . $name . '" src="' . $friends_profile['file'] . '">';
             } else {
                 $friends_profile = UserManager::get_picture_user($uid, $image_array['file'], 80, USER_IMAGE_SIZE_ORIGINAL);
                 $img = '<img title = "' . $name . '" alt="' . $name . '" src="' . $friends_profile['file'] . '">';
             }
             $name = '<a href="' . $url . '">' . $status_icon . $user_status . $name . '</a><br>';
             $html .= '<li class="span' . $column_size / 3 . '"><div class="thumbnail">' . $img . '<div class="caption">' . $name . '</div</div></li>';
         }
         $counter = $_SESSION['who_is_online_counter'];
         $html .= '</ul></div>';
         if (count($user_list) >= 9) {
             $html .= '<div class="span' . $column_size . '"><a class="btn btn-large" id="link_load_more_items" data_link="' . $counter . '" >' . get_lang('More') . '</a></div>';
         }
         if ($add_row) {
             $html .= '</div>';
         }
     }
     return $html;
 }
/**
 * Get the users to display on the current page (fill the sortable-table)
 * @param   int     offset of first user to recover
 * @param   int     Number of users to get
 * @param   int     Column to sort on
 * @param   string  Order (ASC,DESC)
 * @param   bool
 * @see SortableTable#get_table_data($from)
 */
function get_user_data($from, $number_of_items, $column, $direction, $get_count = false)
{
    $user_table = Database::get_main_table(TABLE_MAIN_USER);
    $admin_table = Database::get_main_table(TABLE_MAIN_ADMIN);
    $select = "SELECT\n                 u.user_id\t\t\t\tAS col0,\n                 u.official_code\t\tAS col2,\n\t\t\t\t " . (api_is_western_name_order() ? "u.firstname \t\t\tAS col3,\n                 u.lastname \t\t\tAS col4," : "u.lastname \t\t\tAS col3,\n                 u.firstname \t\t\tAS col4,") . "\n                 u.username\t\t\t\tAS col5,\n                 u.email\t\t\t\tAS col6,\n                 u.status\t\t\t\tAS col7,\n                 u.active\t\t\t\tAS col8,\n                 u.user_id\t\t\t\tAS col9,\n                 u.registration_date    AS col10,\n                 u.expiration_date      AS exp,\n                 u.password\n    ";
    if ($get_count) {
        $select = "SELECT count(u.user_id) as total_rows";
    }
    $sql = "{$select} FROM {$user_table} u ";
    // adding the filter to see the user's only of the current access_url
    if ((api_is_platform_admin() || api_is_session_admin()) && api_get_multiple_access_url()) {
        $access_url_rel_user_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
        $sql .= " INNER JOIN {$access_url_rel_user_table} url_rel_user ON (u.user_id=url_rel_user.user_id)";
    }
    if (isset($_GET['keyword_extra_data'])) {
        $keyword_extra_data = Database::escape_string($_GET['keyword_extra_data']);
        if (!empty($keyword_extra_data)) {
            $extra_info = UserManager::get_extra_field_information_by_name($keyword_extra_data);
            $field_id = $extra_info['id'];
            $sql .= " INNER JOIN user_field_values ufv ON u.user_id=ufv.user_id AND ufv.field_id={$field_id} ";
        }
    }
    if (isset($_GET['keyword'])) {
        $keyword = Database::escape_string(trim($_GET['keyword']));
        $sql .= " WHERE (u.firstname LIKE '%" . $keyword . "%' OR u.lastname LIKE '%" . $keyword . "%' OR concat(u.firstname,' ',u.lastname) LIKE '%" . $keyword . "%' OR concat(u.lastname,' ',u.firstname) LIKE '%" . $keyword . "%' OR u.username LIKE '%" . $keyword . "%'  OR u.official_code LIKE '%" . $keyword . "%' OR u.email LIKE '%" . $keyword . "%' )";
    } elseif (isset($_GET['keyword_firstname'])) {
        $keyword_firstname = Database::escape_string($_GET['keyword_firstname']);
        $keyword_lastname = Database::escape_string($_GET['keyword_lastname']);
        $keyword_email = Database::escape_string($_GET['keyword_email']);
        $keyword_officialcode = Database::escape_string($_GET['keyword_officialcode']);
        $keyword_username = Database::escape_string($_GET['keyword_username']);
        $keyword_status = Database::escape_string($_GET['keyword_status']);
        $query_admin_table = '';
        $and_conditions = array();
        if ($keyword_status == SESSIONADMIN) {
            $keyword_status = '%';
            $query_admin_table = " , {$admin_table} a ";
            $and_conditions[] = ' a.user_id = u.user_id ';
        }
        if (isset($_GET['keyword_extra_data'])) {
            if (!empty($_GET['keyword_extra_data']) && !empty($_GET['keyword_extra_data_text'])) {
                $keyword_extra_data_text = Database::escape_string($_GET['keyword_extra_data_text']);
                $and_conditions[] = " ufv.field_value LIKE '%" . trim($keyword_extra_data_text) . "%' ";
            }
        }
        $keyword_active = isset($_GET['keyword_active']);
        $keyword_inactive = isset($_GET['keyword_inactive']);
        $sql .= $query_admin_table . " WHERE ( ";
        if (!empty($keyword_firstname)) {
            $and_conditions[] = "u.firstname LIKE '%" . $keyword_firstname . "%' ";
        }
        if (!empty($keyword_lastname)) {
            $and_conditions[] = "u.lastname LIKE '%" . $keyword_lastname . "%' ";
        }
        if (!empty($keyword_username)) {
            $and_conditions[] = "u.username LIKE '%" . $keyword_username . "%'  ";
        }
        if (!empty($keyword_email)) {
            $and_conditions[] = "u.email LIKE '%" . $keyword_email . "%' ";
        }
        if (!empty($keyword_officialcode)) {
            $and_conditions[] = "u.official_code LIKE '%" . $keyword_officialcode . "%' ";
        }
        if (!empty($keyword_status)) {
            $and_conditions[] = "u.status LIKE '" . $keyword_status . "' ";
        }
        if ($keyword_active && !$keyword_inactive) {
            $and_conditions[] = "  u.active='1' ";
        } elseif ($keyword_inactive && !$keyword_active) {
            $and_conditions[] = "  u.active='0' ";
        }
        if (!empty($and_conditions)) {
            $sql .= implode(' AND ', $and_conditions);
        }
        $sql .= " ) ";
    }
    // adding the filter to see the user's only of the current access_url
    if ((api_is_platform_admin() || api_is_session_admin()) && api_get_multiple_access_url()) {
        $sql .= " AND url_rel_user.access_url_id=" . api_get_current_access_url_id();
    }
    $checkPassStrength = isset($_GET['check_easy_passwords']) && $_GET['check_easy_passwords'] == 1 ? true : false;
    if ($checkPassStrength) {
        $easyPasswordList = api_get_easy_password_list();
        $easyPasswordList = array_map('api_get_encrypted_password', $easyPasswordList);
        $easyPasswordList = array_map(array('Database', 'escape_string'), $easyPasswordList);
        $easyPassword = implode("' OR password LIKE '", $easyPasswordList);
        $sql .= "AND password LIKE '{$easyPassword}' ";
    }
    if (!in_array($direction, array('ASC', 'DESC'))) {
        $direction = 'ASC';
    }
    $column = intval($column);
    $from = intval($from);
    $number_of_items = intval($number_of_items);
    // Returns counts and exits function.
    if ($get_count) {
        $res = Database::query($sql);
        $user = Database::fetch_array($res);
        return $user['total_rows'];
    }
    $sql .= " ORDER BY col{$column} {$direction} ";
    $sql .= " LIMIT {$from},{$number_of_items}";
    $res = Database::query($sql);
    $users = array();
    $t = time();
    while ($user = Database::fetch_row($res)) {
        $userInfo = api_get_user_info($user[0]);
        $image_path = UserManager::get_user_picture_path_by_id($user[0], 'web', false, true);
        $user_profile = UserManager::get_picture_user($user[0], $image_path['file'], 22, USER_IMAGE_SIZE_SMALL, ' width="22" height="22" ');
        if (!api_is_anonymous()) {
            $photo = '<center><a href="' . $userInfo['profile_url'] . '" title="' . get_lang('Info') . '">
                            <img src="' . $user_profile['file'] . '" ' . $user_profile['style'] . ' alt="' . $userInfo['complete_name'] . '" title="' . $userInfo['complete_name'] . '" /></a></center>';
        } else {
            $photo = '<center><img src="' . $user_profile['file'] . '" ' . $user_profile['style'] . ' alt="' . $userInfo['complete_name'] . '" title="' . $userInfo['complete_name'] . '" /></center>';
        }
        if ($user[7] == 1 && $user[10] != '0000-00-00 00:00:00') {
            // check expiration date
            $expiration_time = api_convert_sql_date($user[10]);
            // if expiration date is passed, store a special value for active field
            if ($expiration_time < $t) {
                $user[7] = '-1';
            }
        }
        // forget about the expiration date field
        $users[] = array($user[0], $photo, $user[1], Display::url($user[2], $userInfo['profile_url']), Display::url($user[3], $userInfo['profile_url']), $user[4], $user[5], $user[6], $user[7], api_get_local_time($user[9]), $user[0]);
    }
    return $users;
}
Exemple #11
0
/**
 * @param array $work
 * @return array
 */
function getWorkComments($work)
{
    if (ADD_DOCUMENT_TO_WORK == false) {
        return array();
    }

    $commentTable = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT_COMMENT);
    $userTable= Database::get_main_table(TABLE_MAIN_USER);

    $courseId = intval($work['c_id']);
    $workId = intval($work['id']);

    if (empty($courseId) || empty($workId)) {
        return array();
    }

    $sql = "SELECT
            c.id, c.user_id, u.firstname, u.lastname, u.username, u.picture_uri
            FROM $commentTable c
            INNER JOIN $userTable u ON (u.user_id = c.user_id)
            WHERE c_id = $courseId AND work_id = $workId
            ORDER BY sent_at
            ";
    $result = Database::query($sql);
    $comments = Database::store_result($result, 'ASSOC');
    if (!empty($comments)) {
        foreach ($comments as &$comment) {
            $pictureInfo = UserManager::get_picture_user(
                $comment['user_id'],
                $comment['picture_uri'],
                24,
                USER_IMAGE_SIZE_SMALL
            );
            $comment['picture'] = $pictureInfo['file'];
            $commentInfo = getWorkComment($comment['id']);

            if (!empty($commentInfo)) {
                $comment = array_merge($comment, $commentInfo);
            }
        }
    }
    return $comments;
}
Exemple #12
0
/**
 * Get the users to display on the current page.
 */
function get_user_data($from, $number_of_items, $column, $direction)
{
    global $origin;
    global $course_info;
    global $is_western_name_order;
    global $session_id;
    global $extraFields;

    $a_users = array();

    // limit
    if (!isset($_GET['keyword']) || empty($_GET['keyword'])) {
        $limit = 'LIMIT '.intval($from).','.intval($number_of_items);
    }

    if (!in_array($direction, array('ASC', 'DESC'))) {
        $direction = 'ASC';
    }

    switch ($column) {
        case 2: //official code
            $order_by = 'ORDER BY user.official_code '.$direction;
            break;
        case 3:
            if ($is_western_name_order) {
                $order_by = 'ORDER BY user.firstname '.$direction.', user.lastname '.$direction;
            } else {
                $order_by = 'ORDER BY user.lastname '.$direction.', user.firstname '.$direction;
            }
            break;
        case 4:
            if ($is_western_name_order) {
                $order_by = 'ORDER BY user.lastname '.$direction.', user.firstname '.$direction;
            } else {
                $order_by = 'ORDER BY user.firstname '.$direction.', user.lastname '.$direction;
            }
            break;
        case 5: //username
            $order_by = 'ORDER BY user.username '.$direction;
            break;
        default:
            if ($is_western_name_order) {
                $order_by = 'ORDER BY user.lastname '.$direction.', user.firstname '.$direction;
            } else {
                $order_by = 'ORDER BY user.firstname '.$direction.', user.lastname '.$direction;
            }
            break;
    }

    $session_id = api_get_session_id();
    $course_code = api_get_course_id();
    $active = isset($_GET['active']) ? $_GET['active'] : null;
    $a_course_users = CourseManager :: get_user_list_from_course_code(
        $course_code,
        $session_id,
        $limit,
        $order_by,
        null,
        null,
        false,
        false,
        null,
        array(),
        array(),
        $active
    );

    foreach ($a_course_users as $user_id => $o_course_user) {
        if ((
                isset($_GET['keyword']) &&
                searchUserKeyword(
                    $o_course_user['firstname'],
                    $o_course_user['lastname'],
                    $o_course_user['username'],
                    $o_course_user['official_code'],
                    $_GET['keyword'])
            ) || !isset($_GET['keyword']) || empty($_GET['keyword'])
        ) {

            $groupsNameList = GroupManager::getAllGroupPerUserSubscription($user_id);
            $temp = array();
            if (api_is_allowed_to_edit(null, true)) {
                $temp[] = $user_id;
                $image_path = UserManager::get_user_picture_path_by_id(
                    $user_id,
                    'web',
                    false,
                    true
                );
                $user_profile = UserManager::get_picture_user(
                    $user_id,
                    $image_path['file'],
                    22,
                    USER_IMAGE_SIZE_SMALL,
                    ' width="22" height="22" '
                );
                if (!api_is_anonymous()) {
                    $photo = '<a href="userInfo.php?'.api_get_cidreq().'&origin='.$origin.'&amp;uInfo='.$user_id.'" title="'.get_lang('Info').'"  ><img src="'.$user_profile['file'].'" '.$user_profile['style'].' alt="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'"  title="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" /></a>';
                } else {
                    $photo = '<img src="'.$user_profile['file'].'" '.$user_profile['style'].' alt="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" title="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" />';
                }

                $temp[] = $photo;
                $temp[] = $o_course_user['official_code'];

                if ($is_western_name_order) {
                    $temp[] = $o_course_user['firstname'];
                    $temp[] = $o_course_user['lastname'];
                } else {
                    $temp[] = $o_course_user['lastname'];
                    $temp[] = $o_course_user['firstname'];
                }

                $temp[] = $o_course_user['username'];
                // Description.
                $temp[] = isset($o_course_user['role']) ? $o_course_user['role'] : null;
                // Groups.
                $temp[] = implode(', ', $groupsNameList);
                // Status
                $default_status = '-';
                if ((isset($o_course_user['status_rel']) && $o_course_user['status_rel'] == 1) ||
                    (isset($o_course_user['status_session']) && $o_course_user['status_session'] == 2)
                ) {
                    $default_status = get_lang('CourseManager');
                } elseif (isset($o_course_user['tutor_id']) && $o_course_user['tutor_id'] == 1) {
                    $default_status = get_lang('Tutor');
                }
                $temp[] = $default_status;

                // Active
                $temp[] = $o_course_user['active'];

                if (!empty($extraFields)) {
                    foreach ($extraFields as $extraField) {
                        $extraFieldValue = new ExtraFieldValue('user');
                        $data = $extraFieldValue->get_values_by_handler_and_field_id(
                            $user_id,
                            $extraField['id']
                        );
                        $temp[] = $data['field_value'];
                    }
                }

                // User id for actions
                $temp[] = $user_id;
            } else {
                $image_path = UserManager::get_user_picture_path_by_id($user_id, 'web', false, true);
                $image_repository = $image_path['dir'];
                $existing_image = $image_path['file'];
                if (!api_is_anonymous()) {
                    $photo= '<a href="userInfo.php?'.api_get_cidreq().'&origin='.$origin.'&amp;uInfo='.$user_id.'" title="'.get_lang('Info').'"  ><img src="'.$image_repository.$existing_image.'" alt="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'"  width="22" height="22" title="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" /></a>';
                } else {
                    $photo= '<img src="'.$image_repository.$existing_image.'" alt="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'"  width="22" height="22" title="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" />';
                }
                $temp[] = $user_id;
                $temp[] = $photo;
                $temp[] = $o_course_user['official_code'];

                if ($is_western_name_order) {
                    $temp[] = $o_course_user['firstname'];
                    $temp[] = $o_course_user['lastname'];
                } else {
                    $temp[] = $o_course_user['lastname'];
                    $temp[] = $o_course_user['firstname'];
                }
                $temp[] = $o_course_user['username'];
                $temp[] = $o_course_user['role'];
                // Group.
                $temp[] = implode(', ', $groupsNameList);

                if ($course_info['unsubscribe'] == 1) {
                    //User id for actions
                    $temp[] = $user_id;
                }
            }
            $a_users[$user_id] = $temp;
        }
    }

    return $a_users;
}
 /**
  * Gets the group's members
  * @param int group id
  * @param bool show image or not of the group
  * @param array list of relation type use constants
  * @param int from value
  * @param int limit
  * @param array image configuration, i.e array('height'=>'20px', 'size'=> '20px')
  * @return array list of users in a group
  */
 public static function get_users_by_group($group_id, $with_image = false, $relation_type = array(), $from = null, $limit = null, $image_conf = array('size' => USER_IMAGE_SIZE_MEDIUM, 'height' => 80))
 {
     $where = '';
     $table_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP);
     $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
     $group_id = intval($group_id);
     if (empty($group_id)) {
         return array();
     }
     $limit_text = '';
     if (isset($from) && isset($limit)) {
         $from = intval($from);
         $limit = intval($limit);
         $limit_text = "LIMIT {$from}, {$limit}";
     }
     if (count($relation_type) == 0) {
         $where_relation_condition = '';
     } else {
         $new_relation_type = array();
         foreach ($relation_type as $rel) {
             $rel = intval($rel);
             $new_relation_type[] = "'{$rel}'";
         }
         $relation_type = implode(',', $new_relation_type);
         if (!empty($relation_type)) {
             $where_relation_condition = "AND gu.relation_type IN ({$relation_type}) ";
         }
     }
     $sql = "SELECT picture_uri as image, u.user_id, u.firstname, u.lastname, relation_type\n    \t\t    FROM {$tbl_user} u INNER JOIN {$table_group_rel_user} gu\n    \t\t\tON (gu.user_id = u.user_id)\n    \t\t\tWHERE gu.group_id= {$group_id} {$where_relation_condition}\n    \t\t\tORDER BY relation_type, firstname {$limit_text}";
     $result = Database::query($sql);
     $array = array();
     while ($row = Database::fetch_array($result, 'ASSOC')) {
         if ($with_image) {
             $image_path = UserManager::get_user_picture_path_by_id($row['user_id'], 'web', false, true);
             $picture = UserManager::get_picture_user($row['user_id'], $image_path['file'], $image_conf['height'], $image_conf['size']);
             $row['image'] = '<img src="' . $picture['file'] . '"  ' . $picture['style'] . '  />';
         }
         $array[$row['user_id']] = $row;
     }
     return $array;
 }
Exemple #14
0
/**
 * Get the users to display on the current page.
 */
function get_user_data($from, $number_of_items, $column, $direction)
{
    global $origin;
    global $course_info;
    global $is_western_name_order;
    global $session_id;
    $a_users = array();
    // limit
    $limit = 'LIMIT ' . intval($from) . ',' . intval($number_of_items);
    if (!in_array($direction, array('ASC', 'DESC'))) {
        $direction = 'ASC';
    }
    switch ($column) {
        case 2:
            //official code
            $order_by = 'ORDER BY user.official_code ' . $direction;
            break;
        case 3:
            if ($is_western_name_order) {
                $order_by = 'ORDER BY user.firstname ' . $direction . ', user.lastname ' . $direction;
            } else {
                $order_by = 'ORDER BY user.lastname ' . $direction . ', user.firstname ' . $direction;
            }
            break;
        case 4:
            if ($is_western_name_order) {
                $order_by = 'ORDER BY user.lastname ' . $direction . ', user.firstname ' . $direction;
            } else {
                $order_by = 'ORDER BY user.firstname ' . $direction . ', user.lastname ' . $direction;
            }
            break;
        case 5:
            //username
            $order_by = 'ORDER BY user.username ' . $direction;
            break;
        default:
            if ($is_western_name_order) {
                $order_by = 'ORDER BY user.lastname ' . $direction . ', user.firstname ' . $direction;
            } else {
                $order_by = 'ORDER BY user.firstname ' . $direction . ', user.lastname ' . $direction;
            }
            break;
    }
    $session_id = api_get_session_id();
    $course_code = api_get_course_id();
    $keyword = isset($_REQUEST['keyword']) ? $_REQUEST['keyword'] : null;
    $a_course_users = CourseManager::get_user_list_from_course_code($course_code, $session_id, $limit, $order_by, null, $keyword);
    foreach ($a_course_users as $user_id => $o_course_user) {
        $groups_name = GroupManager::get_user_group_name($user_id);
        $temp = array();
        if (api_is_allowed_to_edit(null, true)) {
            //if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true') {
            $temp[] = $user_id;
            //}
            $image_path = UserManager::get_user_picture_path_by_id($user_id, 'web', false, true);
            $user_profile = UserManager::get_picture_user($user_id, $image_path['file'], 22, USER_IMAGE_SIZE_SMALL, ' width="22" height="22" ');
            if (!api_is_anonymous()) {
                $photo = '<a href="userInfo.php?' . api_get_cidreq() . '&origin=' . $origin . '&amp;uInfo=' . $user_id . '" title="' . get_lang('Info') . '"  ><img src="' . $user_profile['file'] . '" ' . $user_profile['style'] . ' alt="' . api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']) . '"  title="' . api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']) . '" /></a>';
            } else {
                $photo = '<img src="' . $user_profile['file'] . '" ' . $user_profile['style'] . ' alt="' . api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']) . '" title="' . api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']) . '" />';
            }
            $temp[] = $photo;
            $temp[] = $o_course_user['official_code'];
            if ($is_western_name_order) {
                $temp[] = $o_course_user['firstname'];
                $temp[] = $o_course_user['lastname'];
            } else {
                $temp[] = $o_course_user['lastname'];
                $temp[] = $o_course_user['firstname'];
            }
            $temp[] = $o_course_user['username'];
            $temp[] = isset($o_course_user['role']) ? $o_course_user['role'] : null;
            //Description
            $temp[] = implode(', ', $groups_name);
            //Group
            // Status
            $default_status = '-';
            if (isset($o_course_user['status_rel']) && $o_course_user['status_rel'] == 1 || isset($o_course_user['status_session']) && $o_course_user['status_session'] == 2) {
                $default_status = get_lang('CourseManager');
            } elseif (isset($o_course_user['tutor_id']) && $o_course_user['tutor_id'] == 1) {
                $default_status = get_lang('Tutor');
            }
            $temp[] = $default_status;
            //Active
            $temp[] = $o_course_user['active'];
            //User id for actions
            $temp[] = $user_id;
        } else {
            $image_path = UserManager::get_user_picture_path_by_id($user_id, 'web', false, true);
            $image_repository = $image_path['dir'];
            $existing_image = $image_path['file'];
            if (!api_is_anonymous()) {
                $photo = '<a href="userInfo.php?' . api_get_cidreq() . '&origin=' . $origin . '&amp;uInfo=' . $user_id . '" title="' . get_lang('Info') . '"  ><img src="' . $image_repository . $existing_image . '" alt="' . api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']) . '"  width="22" height="22" title="' . api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']) . '" /></a>';
            } else {
                $photo = '<img src="' . $image_repository . $existing_image . '" alt="' . api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']) . '"  width="22" height="22" title="' . api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']) . '" />';
            }
            $temp[] = $user_id;
            $temp[] = $photo;
            $temp[] = $o_course_user['official_code'];
            if ($is_western_name_order) {
                $temp[] = $o_course_user['firstname'];
                $temp[] = $o_course_user['lastname'];
            } else {
                $temp[] = $o_course_user['lastname'];
                $temp[] = $o_course_user['firstname'];
            }
            $temp[] = $o_course_user['username'];
            $temp[] = $o_course_user['role'];
            $temp[] = implode(', ', $groups_name);
            //Group
            if ($course_info['unsubscribe'] == 1) {
                //User id for actions
                $temp[] = $user_id;
            }
            //$temp[] = $o_course_user['official_code'];
        }
        $a_users[$user_id] = $temp;
    }
    return $a_users;
}
Exemple #15
0
/**
 * Get the users to display on the current page (fill the sortable-table)
 * @param   int     offset of first user to recover
 * @param   int     Number of users to get
 * @param   int     Column to sort on
 * @param   string  Order (ASC,DESC)
 * @see SortableTable#get_table_data($from)
 */
function get_user_data($from, $number_of_items, $column, $direction)
{
    $sql = prepare_user_sql_query(false);
    $checkPassStrength = isset($_GET['check_easy_passwords']) && $_GET['check_easy_passwords'] == 1 ? true : false;
    if ($checkPassStrength) {
        $easyPasswordList = api_get_easy_password_list();
        $easyPasswordList = array_map('api_get_encrypted_password', $easyPasswordList);
        $easyPasswordList = array_map(array('Database', 'escape_string'), $easyPasswordList);
        $easyPassword = implode("' OR password LIKE '", $easyPasswordList);
        $sql .= "AND password LIKE '{$easyPassword}' ";
    }
    if (!in_array($direction, array('ASC', 'DESC'))) {
        $direction = 'ASC';
    }
    $column = intval($column);
    $from = intval($from);
    $number_of_items = intval($number_of_items);
    global $_configuration;
    if (api_is_session_admin() && isset($_configuration['prevent_session_admins_to_manage_all_users']) && $_configuration['prevent_session_admins_to_manage_all_users'] == 'true') {
        $sql .= " WHERE u.creator_id = " . api_get_user_id();
    }
    $sql .= " ORDER BY col{$column} {$direction} ";
    $sql .= " LIMIT {$from},{$number_of_items}";
    $res = Database::query($sql);
    $users = array();
    $t = time();
    while ($user = Database::fetch_row($res)) {
        $image_path = UserManager::get_user_picture_path_by_id($user[0], 'web', false, true);
        $user_profile = UserManager::get_picture_user($user[0], $image_path['file'], 22, USER_IMAGE_SIZE_SMALL, ' width="22" height="22" ');
        if (!api_is_anonymous()) {
            $photo = '<center><a href="' . api_get_path(WEB_PATH) . 'whoisonline.php?origin=user_list&id=' . $user[0] . '" title="' . get_lang('Info') . '">
                            <img src="' . $user_profile['file'] . '" ' . $user_profile['style'] . ' alt="' . api_get_person_name($user[2], $user[3]) . '"  title="' . api_get_person_name($user[2], $user[3]) . '" /></a></center>';
        } else {
            $photo = '<center><img src="' . $user_profile['file'] . '" ' . $user_profile['style'] . ' alt="' . api_get_person_name($user[2], $user[3]) . '" title="' . api_get_person_name($user[2], $user[3]) . '" /></center>';
        }
        if ($user[7] == 1 && $user[10] != '0000-00-00 00:00:00') {
            // check expiration date
            $expiration_time = convert_sql_date($user[10]);
            // if expiration date is passed, store a special value for active field
            if ($expiration_time < $t) {
                $user[7] = '-1';
            }
        }
        // forget about the expiration date field
        $users[] = array($user[0], $photo, $user[1], $user[2], $user[3], $user[4], $user[5], $user[6], $user[7], api_get_local_time($user[9]), $user[0]);
    }
    return $users;
}
                        'social_moderator_delete.png',
                        get_lang('DeleteModerator')
                    ) . '</a>';
            }
            break;
    }

    $image_path = UserManager::get_user_picture_path_by_id(
        $user['user_id'],
        'web',
        false,
        true
    );
    $picture = UserManager::get_picture_user(
        $user['user_id'],
        $image_path['file'],
        80
    );
    $user['image'] = '<img src="' . $picture['file'] . '"  width="50px" height="50px"  />';

    $new_member_list[] = $user;
}
if (count($new_member_list) > 0) {
    $social_right_content .= Display::return_sortable_grid(
        'list_members',
        array(),
        $new_member_list,
        array('hide_navigation' => true, 'per_page' => 100),
        array(),
        false,
        array(true, false, true, true, false, true, true)
    /**
     * 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...
     * @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);
        $message_id = intval($message_id);
        if ($source == 'outbox') {
            if (isset($message_id) && is_numeric($message_id)) {
                $query = "SELECT * FROM {$table_message} WHERE user_sender_id=" . api_get_user_id() . " AND id=" . $message_id . " AND msg_status=4;";
                $result = Database::query($query);
                $path = 'outbox.php';
            }
        } else {
            if (is_numeric($message_id) && !empty($message_id)) {
                $query = "UPDATE {$table_message} SET msg_status = '" . MESSAGE_STATUS_NEW . "' WHERE user_receiver_id=" . api_get_user_id() . " AND id='" . $message_id . "';";
                $result = Database::query($query);
                $query = "SELECT * FROM {$table_message} WHERE msg_status<>4 AND user_receiver_id=" . api_get_user_id() . " AND id='" . $message_id . "';";
                $result = Database::query($query);
            }
            $path = 'inbox.php';
        }
        $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();
        $title = Security::remove_XSS($row['title'], STUDENT, true);
        $content = Security::remove_XSS($row['content'], STUDENT, true);
        $userInfoSender = api_get_user_info($user_sender_id);
        $name = $userInfoSender['complete_name'];
        $user_image = UserManager::get_picture_user($row['user_sender_id'], $userInfoSender['picture_uri'], 80);
        $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 . ' ';
        }
        if (api_get_setting('allow_social_tool') == 'true') {
            $userInfo = api_get_user_info($row['user_sender_id']);
            if ($source == 'outbox') {
                $message_content .= get_lang('From') . ': <a href="' . $userInfoSender['profile_url'] . '">' . $name . '</a> ' . api_strtolower(get_lang('To')) . '&nbsp;<b>' . $userInfo['complete_name'] . '</b>';
            } else {
                $message_content .= get_lang('From') . ' <a href="' . $userInfoSender['profile_url'] . '">' . $name . '</a> ' . api_strtolower(get_lang('To')) . '&nbsp;<b>' . get_lang('Me') . '</b>';
            }
        } else {
            $userInfo = api_get_user_info($row['user_receiver_id']);
            if ($source == 'outbox') {
                $message_content .= get_lang('From') . ':&nbsp;' . $name . '</b> ' . api_strtolower(get_lang('To')) . ' <b>' . $userInfo['complete_name'] . '</b>';
            } else {
                $message_content .= get_lang('From') . ':&nbsp;' . $name . '</b> ' . api_strtolower(get_lang('To')) . ' <b>' . get_lang('Me') . '</b>';
            }
        }
        $message_content .= ' ' . get_lang('Date') . ':  ' . api_get_local_time($row['send_date']);
        $message_content .= '<br />';
        $message_content .= '<br />';
        $message_content .= str_replace("\\", "", $content);
        $message_content .= '<br />';
        $message_content .= '<div id="message-attach">' . (!empty($files_attachments) ? implode('<br />', $files_attachments) : '') . '</div>
		        ';
        $social_link = '';
        if (isset($_GET['f']) && $_GET['f'] == 'social') {
            $social_link = 'f=social';
        }
        if ($source == 'outbox') {
            $message_content .= '<a href="outbox.php?' . $social_link . '">' . Display::return_icon('back.png', get_lang('ReturnToOutbox')) . '</a> &nbsp';
        } else {
            $message_content .= '<a href="inbox.php?' . $social_link . '">' . Display::return_icon('back.png', get_lang('ReturnToInbox')) . '</a> &nbsp';
            $message_content .= '<a href="new_message.php?re_id=' . $message_id . '&' . $social_link . '">' . Display::return_icon('message_reply.png', get_lang('ReplyToMessage')) . '</a> &nbsp';
        }
        $message_content .= '<a href="inbox.php?action=deleteone&id=' . $message_id . '&' . $social_link . '" >' . Display::return_icon('delete.png', get_lang('DeleteMessage')) . '</a>&nbsp';
        return $message_content;
    }