/**
  * 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));
     }
 }
 public function get_link_user_picture($username, $password, $id)
 {
     if ($this->verifyUserPass($username, $password) == "valid") {
         $userPic = UserManager::get_user_picture_path_by_id($id, "web");
         if (empty($userPic['file'])) {
             return "0";
         }
         return $userPic['dir'] . $userPic['file'];
     }
     return "0";
 }
 /**
  * {@inheritdoc}
  */
 public function getConfiguration()
 {
     if ($this->connector->security->isGranted('IS_AUTHENTICATED_FULLY')) {
         $userId = $this->connector->user->getUserId();
         if (!empty($userId)) {
             // Adding user personal files
             $dir = \UserManager::get_user_picture_path_by_id($userId, 'system');
             $dirWeb = \UserManager::get_user_picture_path_by_id($userId, 'web');
             $driver = array('driver' => 'PersonalDriver', 'alias' => $this->connector->translator->trans('MyFiles'), 'path' => $dir['dir'] . 'my_files', 'URL' => $dirWeb['dir'] . 'my_files', 'accessControl' => array($this, 'access'));
             return $driver;
         }
     }
 }
 /**
  * Checks if the certificate user path directory is created
  */
 public function check_certificate_path()
 {
     $this->certification_user_path = null;
     //Setting certification path
     $path_info = UserManager::get_user_picture_path_by_id($this->user_id, 'system');
     $web_path_info = UserManager::get_user_picture_path_by_id($this->user_id, 'web');
     if (!empty($path_info) && isset($path_info['dir'])) {
         $this->certification_user_path = $path_info['dir'] . 'certificate/';
         $this->certification_web_user_path = $web_path_info['dir'] . 'certificate/';
         if (!is_dir($path_info['dir'])) {
             mkdir($path_info['dir'], 0777, true);
         }
         if (!is_dir($this->certification_user_path)) {
             mkdir($this->certification_user_path, 0777);
         }
     }
 }
 /**
  * Displays messages of a group with nested view
  * @param $group_id
  * @param $topic_id
  * @param $is_member
  * @param $message_id
  * @return string
  */
 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);
     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);
     $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
     $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) {
         $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_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') {
             $date = '<div class="message-group-date"> ' . get_lang('LastUpdate') . ' ' . date_to_str_ago($main_message['update_date']) . '</div>';
         }
     } 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>';
     $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;
         $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;
             $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">';
             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_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') {
                     $date = '<div class="message-group-date"> ' . get_lang('LastUpdate') . ' ' . date_to_str_ago($topic['update_date']) . '</div>';
                 }
             } 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>';
             $base_padding = 20;
             if ($topic['indent_cnt'] == 0) {
                 $indent = $base_padding;
             } else {
                 $indent = intval($topic['indent_cnt']) * $base_padding + $base_padding;
             }
             $class = 'group_social_sub_item';
             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'));
             $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;
 }
/*	DISPLAY */
if ($to_group_id != 0) {
    // Add group name after for group documents
    $add_group_to_title = ' (' . $group_properties['name'] . ')';
}
/* Introduction section (editable by course admins) */
if (!empty($_SESSION['_gid'])) {
    Display::display_introduction_section(TOOL_DOCUMENT . $_SESSION['_gid']);
} else {
    Display::display_introduction_section(TOOL_DOCUMENT);
}
// ACTION MENU
// Copy a file to general my files user's
if (isset($_GET['action']) && $_GET['action'] == 'copytomyfiles' && api_get_setting('users_copy_files') == 'true' && api_get_user_id() != 0) {
    $clean_get_id = Security::remove_XSS($_GET['id']);
    $my_path = UserManager::get_user_picture_path_by_id(api_get_user_id(), 'system');
    $user_folder = $my_path['dir'] . 'my_files/';
    $my_path = null;
    if (!file_exists($user_folder)) {
        $perm = api_get_permissions_for_new_directories();
        @mkdir($user_folder, $perm, true);
    }
    $file = $sys_course_path . $_course['path'] . '/document' . $clean_get_id;
    $copyfile = $user_folder . basename($clean_get_id);
    if (file_exists($copyfile)) {
        $message = get_lang('CopyAlreadyDone') . '</p><p>' . '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;curdirpath=' . $curdirpath . '">' . get_lang("No") . '</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;curdirpath=' . $curdirpath . '&amp;action=copytomyfiles&amp;id=' . $clean_get_id . '&amp;copy=yes">' . get_lang('Yes') . '</a></p>';
        if (!isset($_GET['copy'])) {
            Display::display_warning_message($message, false);
        }
        if (Security::remove_XSS($_GET['copy']) == 'yes') {
            if (!copy($file, $copyfile)) {
    // cvs informations
    $csv_content[] = array(get_lang('Informations'));
    $csv_content[] = array(get_lang('Name'), get_lang('Email'), get_lang('Tel'));
    $csv_content[] = array($a_infosUser['name'], $a_infosUser['email'], $a_infosUser['phone']);
    $csv_content[] = array();
    // csv tracking
    $csv_content[] = array(get_lang('Tracking'));
    $csv_content[] = array(get_lang('FirstLogin'), get_lang('LatestLogin'), get_lang('TimeSpentInTheCourse'), get_lang('Progress'), get_lang('Score'));
    $csv_content[] = array(strip_tags($first_connection_date), strip_tags($last_connection_date), $time_spent_on_the_course, $avg_student_progress . ' %', $avg_student_score . ' %');
    ?>
	<a name="infosStudent"></a>
				<table width="100%" border="0" >
					<tr>
						
							<?php 
    $image_array = UserManager::get_user_picture_path_by_id($a_infosUser['user_id'], 'web', false, true);
    echo '<td class="borderRight" width="10%" valign="top">';
    // get the path,width and height from original picture
    $image_file = $image_array['dir'] . $image_array['file'];
    $big_image = $image_array['dir'] . 'big_' . $image_array['file'];
    $big_image_size = @getimagesize(api_url_to_local_path($big_image));
    $big_image_width = $big_image_size[0];
    $big_image_height = $big_image_size[1];
    $url_big_image = $big_image . '?rnd=' . time();
    $img_attributes = 'src="' . $image_file . '?rand=' . time() . '" ' . 'alt="' . $a_infosUser['lastname'] . ' ' . $a_infosUser['firstname'] . '" ' . 'style="float:' . ($text_dir == 'rtl' ? 'left' : 'right') . '; padding:5px;" ';
    if ($image_array['file'] == 'unknown.jpg') {
        echo '<img ' . $img_attributes . ' />';
    } else {
        echo '<input type="image" ' . $img_attributes . ' onclick="return show_image(\'' . $url_big_image . '\',\'' . $big_image_width . '\',\'' . $big_image_height . '\');"/>';
    }
    echo '</td>';
                'social_group_moderator.png',
                get_lang('Moderator')
            );
            //only group admin can manage moderators
            if ($user_role == GROUP_USER_PERMISSION_ADMIN) {
                $user['link'] .= '<a href="group_members.php?id=' . $group_id . '&u=' . $user['user_id'] . '&action=delete_moderator">' . Display::return_icon(
                        '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(),
    /**
     * Returns the formatted header message post
     * @param   int     $authorId   Author's id
     * @param   int     $receiverId Receiver's id
     * @param   array   $users      Author's and receiver's data
     * @param   array   $message    Message data
     * @param   boolean $isOwnWall  Determines if the author is in its own social wall or not
     * @return  string  $html       The formatted header message post
     */
    private  static function headerMessagePost($authorId, $receiverId, $users, $message, $isOwnWall = false)
    {
        $date = api_get_local_time($message['send_date']);
        $avatarAuthor = $users[$authorId]['avatar'];
        $urlAuthor = api_get_path(WEB_CODE_PATH).'social/profile.php?u='.$authorId;
        $nameCompleteAuthor = api_get_person_name(
            $users[$authorId]['firstname'],
            $users[$authorId]['lastname']
        );
        // Deprecated since 2014-10-29
        //$avatarReceiver = $users[$receiverId]['avatar'];
        $urlReceiver = api_get_path(WEB_CODE_PATH).'social/profile.php?u='.$receiverId;
        $nameCompleteReceiver = api_get_person_name(
            $users[$receiverId]['firstname'],
            $users[$receiverId]['lastname']
        );

        $htmlReceiver = '';
        if ($authorId != $receiverId) {
            $htmlReceiver = ' > <a href="'.$urlReceiver.'">' . $nameCompleteReceiver . '</a> ';
        }

        $wallImage = '';
        if (!empty($message['path'])) {
            $pathUserInfo = UserManager::get_user_picture_path_by_id($authorId, 'web', true);
            $pathImg = $pathUserInfo['dir'] . 'message_attachments';
            $imageBig = $pathImg .self::getImagePath($message['path'], IMAGE_WALL_BIG);
            $imageSmall =  $pathImg. self::getImagePath($message['path'], IMAGE_WALL_SMALL);
            $wallImage = '<a class="thumbnail thickbox" href="'.$imageBig.'"><img src="'.$imageSmall.'"></a>';
        }


        $htmlDelete = '';
        if ($isOwnWall) {
            $htmlDelete .= '<a href="'.api_get_path(WEB_CODE_PATH).'social/profile.php?messageId='.
            $message['id'].'">'.get_lang('SocialMessageDelete').'</a>';
        }

        $html = '';
        $html .= '<div class="mediaPost" style="width: 100%; display:inline-block; margin-bottom:5px;">';
        $html .= '<div class="media-body" style="width: 100%; height: 40px; margin-bottom:5px;">';
        $html .= '<div class="pull-left" style="width: 40px; height: 100%;">';
        $html .= '<a href="'.$urlAuthor.'">'.'<img class="" src="'.$avatarAuthor.
        '" alt="'.$nameCompleteAuthor.'" style="width: 40px; height: 40px;"></a>';
        $html .= '</div>';
        $html .= '<div class="pull-left" style="padding-left:4px; width: calc(100% - 44px);height: 100%;">';
        $html .= '<div style="width: 100%; height: 50%;">';
        $html .= '<h4 class="media-heading" style="width: inherit;">';
        $html .= '<a href="'.$urlAuthor.'">'.$nameCompleteAuthor.'</a>'.$htmlReceiver.'</h4>';
        $html .= '</div>';
        $html .= '<div style="width: 100%; height: 50%;">';
        $html .= '<div class="pull-left" style="height: 100%;">';
        $html .= '<small><span class="time timeago" title="'.$date.'">'.$date.'</span></small>';
        $html .= '</div>';
        $html .= '</div>';
        $html .= '</div>';
        $html .= '</div>';
        if ($isOwnWall) {
            $html .= '<div style="width: 100%;height:20px">';
            $html .= $htmlDelete;
            $html .= '</div>';
        }
        $html .= '<div style="width: 100%;">';
        $html .= $wallImage;
        $html .= '</div>';
        $html .= '<div style="width:100%;text-align:justify;">';
        $html .= '<span class="content">'.
            Security::remove_XSS(self::readContentWithOpenGraph($message['content'])).'</span>';
        $html .= '</div>';
        $html .= '</div>'; // end mediaPost

        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;
 }
 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;
 }
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;
}
Exemple #13
0
/**
 * Builds an img html tag for the filetype
 *
 * @param string $type (file/folder)
 * @param string $path
 * @return string img html tag
 */
function build_document_icon_tag($type, $path)
{
    $basename = basename($path);
    $current_session_id = api_get_session_id();
    $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
    if ($type == 'file') {
        $icon = FileManager::choose_image($basename);
        if (preg_match('/_chnano_.wav$/i', $basename)) {
            $icon = "jplayer_play.png";
            $basename = 'wav' . ' ' . '(Nanogong)';
        } else {
            $basename = substr(strrchr($basename, '.'), 1);
        }
    } else {
        if ($path == '/shared_folder') {
            $icon = 'folder_users.gif';
            if ($is_allowed_to_edit) {
                $basename = get_lang('HelpUsersFolder');
            } else {
                $basename = get_lang('UserFolders');
            }
        } elseif (strstr($basename, 'sf_user_')) {
            $userinfo = api_get_user_info(substr($basename, 8));
            $image_path = UserManager::get_user_picture_path_by_id(substr($basename, 8), 'web', false, true);
            if ($image_path['file'] == 'unknown.jpg') {
                $icon = $image_path['file'];
            } else {
                $icon = '../upload/users/' . substr($basename, 8) . '/' . $image_path['file'];
            }
            $basename = get_lang('UserFolder') . ' ' . $userinfo['complete_name'];
        } elseif (strstr($path, 'shared_folder_session_')) {
            if ($is_allowed_to_edit) {
                $basename = '***(' . api_get_session_name($current_session_id) . ')*** ' . get_lang('HelpUsersFolder');
            } else {
                $basename = get_lang('UserFolders') . ' (' . api_get_session_name($current_session_id) . ')';
            }
            $icon = 'folder_users.gif';
        } else {
            $icon = 'folder_document.gif';
            if ($path == '/audio') {
                $icon = 'folder_audio.gif';
                if (api_is_allowed_to_edit()) {
                    $basename = get_lang('HelpDefaultDirDocuments');
                } else {
                    $basename = get_lang('Audio');
                }
            } elseif ($path == '/flash') {
                $icon = 'folder_flash.gif';
                if (api_is_allowed_to_edit()) {
                    $basename = get_lang('HelpDefaultDirDocuments');
                } else {
                    $basename = get_lang('Flash');
                }
            } elseif ($path == '/images') {
                $icon = 'folder_images.gif';
                if (api_is_allowed_to_edit()) {
                    $basename = get_lang('HelpDefaultDirDocuments');
                } else {
                    $basename = get_lang('Images');
                }
            } elseif ($path == '/video') {
                $icon = 'folder_video.gif';
                if (api_is_allowed_to_edit()) {
                    $basename = get_lang('HelpDefaultDirDocuments');
                } else {
                    $basename = get_lang('Video');
                }
            } elseif ($path == '/images/gallery') {
                $icon = 'folder_gallery.gif';
                if (api_is_allowed_to_edit()) {
                    $basename = get_lang('HelpDefaultDirDocuments');
                } else {
                    $basename = get_lang('Gallery');
                }
            } elseif ($path == '/chat_files') {
                $icon = 'folder_chat.gif';
                if (api_is_allowed_to_edit()) {
                    $basename = get_lang('HelpFolderChat');
                } else {
                    $basename = get_lang('ChatFiles');
                }
            } elseif ($path == '/learning_path') {
                $icon = 'folder_learningpath.gif';
                if (api_is_allowed_to_edit()) {
                    $basename = get_lang('HelpFolderLearningPaths');
                } else {
                    $basename = get_lang('LearningPaths');
                }
            }
        }
    }
    return Display::return_icon($icon, $basename, array());
}
Exemple #14
0
/**
 * Upload a submitted user production.
 *
 * @param    $user_id    User id
 * @return    The filename of the new production or FALSE if the upload has failed
 */
function upload_user_production($user_id)
{
    $image_path = UserManager::get_user_picture_path_by_id($user_id, 'system');
    $production_repository = $image_path['dir'];
    if (!file_exists($production_repository)) {
        @mkdir($production_repository, api_get_permissions_for_new_directories(), true);
    }
    $filename = replace_dangerous_char($_FILES['production']['name']);
    $filename = disable_dangerous_file($filename);
    if (filter_extension($filename)) {
        if (@move_uploaded_file($_FILES['production']['tmp_name'], $production_repository . $filename)) {
            return $filename;
        }
    }
    return false;
    // this should be returned if anything went wrong with the upload
}
 /**
  * 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;
 }
}
//only allow platform admins to login_as, or session admins only for students
// (not teachers nor other admins), and only if all options confirm it
// $_configuration['login_as_forbidden_globally'], defined in configuration.php,
// is the master key to these conditions
$statusname = api_get_status_langvars();
$login_as_icon = '';
if (empty($_configuration['login_as_forbidden_globally']) && (api_is_global_platform_admin() || api_get_setting('login_as_allowed') === 'true' && (api_is_platform_admin() || api_is_session_admin() && (api_is_session_admin() && $row['6'] == $statusname[STUDENT])))) {
    $login_as_icon = '<a href="' . api_get_path(WEB_CODE_PATH) . 'admin/user_list.php?action=login_as&amp;user_id=' . $user['user_id'] . '&amp;sec_token=' . $_SESSION['sec_token'] . '">' . Display::return_icon('login_as.gif', get_lang('LoginAs')) . '</a>';
}
echo '<div class="actions"><a href="' . api_get_path(WEB_CODE_PATH) . 'mySpace/myStudents.php?student=' . intval($_GET['user_id']) . '" title="' . get_lang('Reporting') . '">' . Display::return_icon('statistics.png', get_lang('Reporting'), '', ICON_SIZE_MEDIUM) . '</a>' . $login_as_icon . '</div>';
echo Display::page_header($tool_name);
//getting the user image
$sysdir_array = UserManager::get_user_picture_path_by_id($user['user_id'], 'system', false, true);
$sysdir = $sysdir_array['dir'];
$webdir_array = UserManager::get_user_picture_path_by_id($user['user_id'], 'web', false, true);
$webdir = $webdir_array['dir'];
$fullurl = $webdir . $webdir_array['file'];
$system_image_path = $sysdir . $webdir_array['file'];
list($width, $height, $type, $attr) = @getimagesize($system_image_path);
$resizing = $height > 200 ? 'height="200"' : '';
$height += 30;
$width += 30;
$window_name = 'window' . uniqid('');
$onclick = $window_name . "=window.open('" . $fullurl . "','" . $window_name . "','alwaysRaised=yes, alwaysLowered=no,alwaysOnTop=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=" . $width . ",height=" . $height . ",left=200,top=20'); return false;";
echo '<a href="javascript: void(0);" onclick="' . $onclick . '" ><img src="' . $fullurl . '" ' . $resizing . ' /></a><br />';
echo '<p>' . ($user['status'] == 1 ? get_lang('Teacher') : get_lang('Student')) . '</p>';
echo '<p>' . Display::encrypted_mailto_link($user['mail'], $user['mail']) . '</p>';
/**
 * Show the sessions and the courses in wich this user is subscribed
 */
Exemple #17
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;
}
Exemple #18
0
/**
 * Display a user icon that links to the user page
 *
 * @param integer $user_id the id of the user
 * @return html code
 *
 * @author Patrick Cool <*****@*****.**>, Ghent University, Belgium
 * @version April 2008
 */
function user_icon_filter($user_id)
{
    global $origin;
    $userinfo = api_get_user_info($user_id);
    $image_path = UserManager::get_user_picture_path_by_id($user_id, 'web', false, true);
    $image_repository = $image_path['dir'];
    $existing_image = $image_path['file'];
    $photo = '<center><img src="' . $image_repository . $existing_image . '" alt="' . $userinfo['complete_name'] . '"  width="22" height="22" title="' . $userinfo['complete_name'] . '" /></center>';
    return '<a href="../user/userInfo.php?origin=' . $origin . '&amp;uInfo=' . $user_id . '">' . $photo;
}
require_once '../inc/global.inc.php';
$app['template.show_footer'] = false;
$app['template.show_header'] = false;
$app['default_layout'] = 'default/layout/blank.tpl';
api_block_anonymous_users();
if (api_get_setting('allow_social_tool') != 'true') {
    api_not_allowed();
}
$tok = Security::get_token();
if (isset($_REQUEST['user_friend'])) {
    $info_user_friend = array();
    $info_path_friend = array();
    $userfriend_id = intval($_REQUEST['user_friend']);
    $panel = Security::remove_XSS($_REQUEST['view_panel']);
    $info_user_friend = api_get_user_info($userfriend_id);
    $info_path_friend = UserManager::get_user_picture_path_by_id($userfriend_id, 'web', false, true);
}
$group_id = isset($_GET['group_id']) ? intval($_GET['group_id']) : null;
$message_id = isset($_GET['message_id']) ? intval($_GET['message_id']) : null;
$actions = array('add_message_group', 'edit_message_group', 'reply_message_group');
$allowed_action = isset($_GET['action']) && in_array($_GET['action'], $actions) ? Security::remove_XSS($_GET['action']) : '';
$to_group = '';
$subject = '';
$message = '';
$usergroup = new UserGroup();
if (!empty($group_id) && $allowed_action) {
    $group_info = $usergroup->get($group_id);
    $is_member = $usergroup->is_group_member($group_id);
    if ($group_info['visibility'] == GROUP_PERMISSION_CLOSED && !$is_member) {
        api_not_allowed(true);
    }
 /**
  * @param int $userid
  */
 public static function display_header_user($userid)
 {
     $select_cat = intval($_GET['selectcat']);
     $user_id = $userid;
     $user = api_get_user_info($user_id);
     $catcourse = Category::load($select_cat);
     $scoredisplay = ScoreDisplay::instance();
     $scorecourse = $catcourse[0]->calc_score($user_id);
     // generating the total score for a course
     $allevals = $catcourse[0]->get_evaluations($user_id, true);
     $alllinks = $catcourse[0]->get_links($user_id, true);
     $evals_links = array_merge($allevals, $alllinks);
     $item_value = 0;
     $item_total = 0;
     for ($count = 0; $count < count($evals_links); $count++) {
         $item = $evals_links[$count];
         $score = $item->calc_score($user_id);
         $my_score_denom = $score[1] == 0 ? 1 : $score[1];
         $item_value += $score[0] / $my_score_denom * $item->get_weight();
         $item_total += $item->get_weight();
         //$row[] = $scoredisplay->display_score($score,SCORE_DIV_PERCENT);
     }
     $item_value = number_format($item_value, 2, '.', ' ');
     $total_score = array($item_value, $item_total);
     $scorecourse_display = $scoredisplay->display_score($total_score, SCORE_DIV_PERCENT);
     //$scorecourse_display = (isset($scorecourse) ? $scoredisplay->display_score($scorecourse,SCORE_AVERAGE) : get_lang('NoResultsAvailable'));
     $cattotal = Category::load(0);
     $scoretotal = $cattotal[0]->calc_score($user_id);
     $scoretotal_display = isset($scoretotal) ? $scoredisplay->display_score($scoretotal, SCORE_PERCENT) : get_lang('NoResultsAvailable');
     $image_syspath = UserManager::get_user_picture_path_by_id($userid, 'system', false, true);
     $image_size = getimagesize($image_syspath['dir'] . $image_syspath['file']);
     //Web path
     $image_path = UserManager::get_user_picture_path_by_id($userid, 'web', false, true);
     $image_file = $image_path['dir'] . $image_path['file'];
     $img_attributes = 'src="' . $image_file . '?rand=' . time() . '" ' . 'alt="' . $user['complete_name'] . '" ';
     if ($image_size[0] > 200) {
         //limit display width to 200px
         $img_attributes .= 'width="200" ';
     }
     $info = '<div class="row"><div class="span3">';
     $info .= '<div class="thumbnail"><img ' . $img_attributes . '/></div>';
     $info .= '</div>';
     $info .= '<div class="span6">';
     $info .= get_lang('Name') . ' :  <a target="_blank" href="' . api_get_path(WEB_CODE_PATH) . 'social/profile.php?u=' . $userid . '"> ' . $user['complete_name'] . '</a><br />';
     if (api_get_setting('show_email_addresses') == 'true') {
         $info .= get_lang('Email') . ' : <a href="mailto:' . $user['email'] . '">' . $user['email'] . '</a><br />';
     }
     $info .= get_lang('TotalUser') . ' : <b>' . $scorecourse_display . '</b>';
     $info .= '</div>';
     $info .= '</div>';
     echo $info;
 }
                    <div class="buttons">
                        <button class="btn btn-primary" name="btn_accepted" type="submit" id="btn_accepted_' . $sender_user_id . '" value="' . get_lang('Accept') . ' "onclick="javascript:register_friend(this)">
                        ' . get_lang('Accept') . '</button>
                        <button class="btn btn-danger" name="btn_denied" type="submit" id="btn_deniedst_' . $sender_user_id . ' " value="' . get_lang('Deny') . ' " onclick="javascript:denied_friend(this)" >
                        ' . get_lang('Deny') . '</button>
                    </div>
                </div>
        </div>';
    }
}
if (count($list_get_invitation_sent) > 0) {
    $social_right_content .= '<div class="span8">' . Display::page_subheader(get_lang('InvitationSent')) . '</div>';
    foreach ($list_get_invitation_sent as $invitation) {
        $sender_user_id = $invitation['user_receiver_id'];
        $social_right_content .= '<div id="id_' . $sender_user_id . '" class="invitation_confirm span8">';
        $picture = UserManager::get_user_picture_path_by_id($sender_user_id, 'web', false, true);
        $friends_profile = SocialManager::get_picture_user($sender_user_id, $picture['file'], 92);
        $userInfo = api_get_user_info($sender_user_id);
        $title = Security::remove_XSS($invitation['title'], STUDENT, true);
        $content = Security::remove_XSS($invitation['content'], STUDENT, true);
        $date = api_convert_and_format_date($invitation['send_date'], DATE_TIME_FORMAT_LONG);
        $social_right_content .= '
        <div class="span2">
            <a class="thumbnail" href="' . $userInfo['profile_url'] . '">
            <img src="' . $friends_profile['file'] . '"  /></a>
        </div>
        <div class="span3">
            <a class="profile_link" href="' . $userInfo['profile_url'] . '">' . $userInfo['complete_name'] . '</a>
            <div>' . $title . ' : ' . $content . '</div>
            <div>' . get_lang('DateSend') . ' : ' . $date . '</div>
            </div>
Exemple #22
0
                // To remove from user_field_value and folder
                UserManager::update_extra_field_value($user_id, substr($key, 13), $extra_value);
            }
        }
        $tok = Security::get_token();
        header('Location: user_list.php?action=show_message&message=' . urlencode(get_lang('UserUpdated')) . '&sec_token=' . $tok);
        exit;
    }
}
$message = null;
if ($error_drh) {
    $err_msg = get_lang('StatusCanNotBeChangedToHumanResourcesManager');
    $message = Display::return_message($err_msg, 'error');
}
// USER PICTURE
$image_path = UserManager::get_user_picture_path_by_id($user_id, 'web');
$image_dir = $image_path['dir'];
$image = $image_path['file'];
$image_file = $image != '' ? $image_dir . $image : api_get_path(WEB_CODE_PATH) . 'img/unknown.jpg';
$image_size = api_getimagesize($image_file);
$img_attributes = 'src="' . $image_file . '?rand=' . time() . '" ' . 'alt="' . api_get_person_name($user_data['firstname'], $user_data['lastname']) . '" ' . 'style="float:' . ($text_dir == 'rtl' ? 'left' : 'right') . '; padding:5px;" ';
if ($image_size['width'] > 300) {
    //limit display width to 300px
    $img_attributes .= 'width="300" ';
}
// get the path,width and height from original picture
$big_image = $image_dir . 'big_' . $image;
$big_image_size = api_getimagesize($big_image);
$big_image_width = $big_image_size['width'];
$big_image_height = $big_image_size['height'];
$url_big_image = $big_image . '?rnd=' . time();
Exemple #23
0
 /**
  * Display productions in whoisonline
  * @param int $user_id User id
  */
 public static function display_productions($user_id, $returnContent = false)
 {
     $sysdir_array = UserManager::get_user_picture_path_by_id($user_id, 'system', true);
     $sysdir = $sysdir_array['dir'] . $user_id . '/';
     $webdir_array = UserManager::get_user_picture_path_by_id($user_id, 'web', true);
     $webdir = $webdir_array['dir'] . $user_id . '/';
     if (!is_dir($sysdir)) {
         mkdir($sysdir, api_get_permissions_for_new_directories(), true);
     }
     /*
     $handle = opendir($sysdir);
     $productions = array();
     while ($file = readdir($handle)) {
         if ($file == '.' || $file == '..' || $file == '.htaccess') {
             continue;                        // Skip current and parent directories
         }
         if (preg_match('/('.$user_id.'|[0-9a-f]{13}|saved)_.+\.(png|jpg|jpeg|gif)$/i', $file)) {
             // User's photos should not be listed as productions.
             continue;
         }
         $productions[] = $file;
     }
     */
     $content = null;
     $productions = UserManager::get_user_productions($user_id);
     if (count($productions) > 0) {
         $content .= '<dt><strong>' . get_lang('Productions') . '</strong></dt>';
         $content .= '<dd><ul>';
         foreach ($productions as $file) {
             // Only display direct file links to avoid browsing an empty directory
             if (is_file($sysdir . $file) && $file != $webdir_array['file']) {
                 $content .= '<li><a href="' . $webdir . urlencode($file) . '" target=_blank>' . $file . '</a></li>';
             }
             // Real productions are under a subdirectory by the User's id
             if (is_dir($sysdir . $file)) {
                 $subs = scandir($sysdir . $file);
                 foreach ($subs as $my => $sub) {
                     if (substr($sub, 0, 1) != '.' && is_file($sysdir . $file . '/' . $sub)) {
                         $content .= '<li><a href="' . $webdir . urlencode($file) . '/' . urlencode($sub) . '" target=_blank>' . $sub . '</a></li>';
                     }
                 }
             }
         }
         $content .= '</ul></dd>';
     }
     if ($returnContent) {
         return $content;
     } else {
         echo $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 #25
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;
}
/**
 * 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 #27
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 #28
0
 /**
  * Display productions in who is online
  * @param int $user_id User id
  */
 public static function display_productions($user_id)
 {
     $webdir_array = UserManager::get_user_picture_path_by_id($user_id, 'web');
     $sysdir = UserManager::getUserPathById($user_id, 'system');
     $webdir = UserManager::getUserPathById($user_id, 'web');
     if (!is_dir($sysdir)) {
         mkdir($sysdir, api_get_permissions_for_new_directories(), true);
     }
     $productions = UserManager::get_user_productions($user_id);
     if (count($productions) > 0) {
         echo '<dt><strong>' . get_lang('Productions') . '</strong></dt>';
         echo '<dd><ul>';
         foreach ($productions as $file) {
             // Only display direct file links to avoid browsing an empty directory
             if (is_file($sysdir . $file) && $file != $webdir_array['file']) {
                 echo '<li><a href="' . $webdir . urlencode($file) . '" target=_blank>' . $file . '</a></li>';
             }
             // Real productions are under a subdirectory by the User's id
             if (is_dir($sysdir . $file)) {
                 $subs = scandir($sysdir . $file);
                 foreach ($subs as $my => $sub) {
                     if (substr($sub, 0, 1) != '.' && is_file($sysdir . $file . '/' . $sub)) {
                         echo '<li><a href="' . $webdir . urlencode($file) . '/' . urlencode($sub) . '" target=_blank>' . $sub . '</a></li>';
                     }
                 }
             }
         }
         echo '</ul></dd>';
     }
 }
 /**
  * Creates the users/upload/X/my_files folder
  * @param User $user
  */
 public function createMyFilesFolder(User $user)
 {
     $userId = $user->getUserId();
     $path = \UserManager::get_user_picture_path_by_id($userId, 'system');
     if (!$this->fs->exists($path['dir'] . 'my_files')) {
         $this->createFolders(array($path['dir'] . 'my_files'));
     }
 }
Exemple #30
0
 /**
  * This method returns default configuration for document repository that is to be used by the editor.
  * @return array
  */
 private function &get_repository_configuration()
 {
     // Disabling access for anonymous users.
     $isAnonymous = api_is_anonymous();
     if ($isAnonymous) {
         return array();
     }
     // Preliminary calculations for assembling required paths.
     $base_path = $this->BasePath;
     $script_name = substr($_SERVER['PHP_SELF'], strlen(api_get_path(REL_PATH)));
     $script_path = explode('/', $script_name);
     $script_path[count($script_path) - 1] = '';
     if (api_is_in_course()) {
         $relative_path_prefix = str_repeat('../', count($script_path) - 1);
     } else {
         $relative_path_prefix = str_repeat('../', count($script_path) - 2);
     }
     $script_path = implode('/', $script_path);
     $script_path = api_get_path(WEB_PATH) . $script_path;
     $use_advanced_filemanager = api_get_setting('advanced_filemanager') == 'true';
     // Let javascripts "know" which file manager has been chosen.
     $config['AdvancedFileManager'] = $use_advanced_filemanager;
     if (api_is_in_course()) {
         if (!api_is_in_group()) {
             // 1. We are inside a course and not in a group.
             if (api_is_allowed_to_edit()) {
                 // 1.1. Teacher (tutor and coach are not authorized to change anything in the "content creation" tools)
                 $config['CreateDocumentWebDir'] = api_get_path(WEB_COURSE_PATH) . api_get_course_path() . '/document/';
                 $config['CreateDocumentDir'] = $relative_path_prefix . 'courses/' . api_get_course_path() . '/document/';
                 $config['BaseHref'] = $script_path;
             } else {
                 // 1.2. Student
                 $current_session_id = api_get_session_id();
                 if ($current_session_id == 0) {
                     $config['CreateDocumentWebDir'] = api_get_path(WEB_COURSE_PATH) . api_get_course_path() . '/document/shared_folder/sf_user_' . api_get_user_id() . '/';
                     $config['CreateDocumentDir'] = $relative_path_prefix . 'courses/' . api_get_course_path() . '/document/shared_folder/sf_user_' . api_get_user_id() . '/';
                     $config['BaseHref'] = $script_path;
                 } else {
                     $config['CreateDocumentWebDir'] = api_get_path(WEB_COURSE_PATH) . api_get_course_path() . '/document/shared_folder_session_' . $current_session_id . '/sf_user_' . api_get_user_id() . '/';
                     $config['CreateDocumentDir'] = $relative_path_prefix . 'courses/' . api_get_course_path() . '/document/shared_folder_session_' . $current_session_id . '/sf_user_' . api_get_user_id() . '/';
                     $config['BaseHref'] = $script_path;
                 }
             }
         } else {
             // 2. Inside a course and inside a group.
             global $group_properties;
             $config['CreateDocumentWebDir'] = api_get_path(WEB_COURSE_PATH) . api_get_course_path() . '/document' . $group_properties['directory'] . '/';
             $config['CreateDocumentDir'] = $relative_path_prefix . 'courses/' . api_get_course_path() . '/document' . $group_properties['directory'] . '/';
             $config['BaseHref'] = $script_path;
         }
     } else {
         if (api_is_platform_admin() && isset($_SESSION['this_section']) && $_SESSION['this_section'] == 'platform_admin') {
             // 3. Platform administration activities.
             $config['CreateDocumentWebDir'] = api_get_path(WEB_PATH) . 'home/default_platform_document/';
             $config['CreateDocumentDir'] = api_get_path(WEB_PATH) . 'home/default_platform_document/';
             // A side-effect is in use here.
             $config['BaseHref'] = api_get_path(WEB_PATH) . 'home/default_platform_document/';
         } else {
             // 4. The user is outside courses.
             $my_path = UserManager::get_user_picture_path_by_id(api_get_user_id(), 'system');
             $config['CreateDocumentWebDir'] = $my_path['dir'] . 'my_files/';
             $my_path = UserManager::get_user_picture_path_by_id(api_get_user_id(), 'rel');
             $config['CreateDocumentDir'] = $my_path['dir'] . 'my_files/';
             $config['BaseHref'] = $script_path;
         }
     }
     // URLs for opening the file browser for different resource types (file types):
     if ($use_advanced_filemanager) {
         // Double slashes within the following URLs for the advanced file manager are put intentionally. Please, keep them.
         // for images
         $config['ImageBrowserURL'] = $base_path . '/editor/plugins/ajaxfilemanager/ajaxfilemanager.php';
         // for flash
         $config['FlashBrowserURL'] = $base_path . '/editor/plugins/ajaxfilemanager/ajaxfilemanager.php';
         // for audio files (mp3)
         $config['MP3BrowserURL'] = $base_path . '/editor/plugins/ajaxfilemanager/ajaxfilemanager.php';
         // for video
         $config['VideoBrowserURL'] = $base_path . '/editor/plugins/ajaxfilemanager/ajaxfilemanager.php';
         // for video (flv)
         $config['MediaBrowserURL'] = $base_path . '/editor/plugins/ajaxfilemanager/ajaxfilemanager.php';
         // for links (any resource type)
         $config['LinkBrowserURL'] = $base_path . '/editor/plugins/ajaxfilemanager/ajaxfilemanager.php';
     } else {
         // for images
         $config['ImageBrowserURL'] = $base_path . 'editor/filemanager/browser/default/browser.html?Type=Images&Connector=' . $base_path . 'editor/filemanager/connectors/php/connector.php';
         // for flash
         $config['FlashBrowserURL'] = $base_path . 'editor/filemanager/browser/default/browser.html?Type=Flash&Connector=' . $base_path . 'editor/filemanager/connectors/php/connector.php';
         // for audio files (mp3)
         $config['MP3BrowserURL'] = $base_path . 'editor/filemanager/browser/default/browser.html?Type=MP3&Connector=' . $base_path . 'editor/filemanager/connectors/php/connector.php';
         // for video
         $config['VideoBrowserURL'] = $base_path . 'editor/filemanager/browser/default/browser.html?Type=Video&Connector=' . $base_path . 'editor/filemanager/connectors/php/connector.php';
         // for video (flv)
         $config['MediaBrowserURL'] = $base_path . 'editor/filemanager/browser/default/browser.html?Type=Video/flv&Connector=' . $base_path . 'editor/filemanager/connectors/php/connector.php';
         // for links (any resource type)
         $config['LinkBrowserURL'] = $base_path . 'editor/filemanager/browser/default/browser.html?Type=File&Connector=' . $base_path . 'editor/filemanager/connectors/php/connector.php';
     }
     // URLs for making quick uplods for different resource types (file types).
     // These URLs are used by the dialogs' quick upload tabs:
     // for images
     $config['ImageUploadURL'] = $base_path . 'editor/filemanager/connectors/php/upload.php?Type=Images';
     // for flash
     $config['FlashUploadURL'] = $base_path . 'editor/filemanager/connectors/php/upload.php?Type=Flash';
     // for audio files (mp3)
     $config['MP3UploadURL'] = $base_path . 'editor/filemanager/connectors/php/upload.php?Type=MP3';
     // for video
     $config['VideoUploadURL'] = $base_path . 'editor/filemanager/connectors/php/upload.php?Type=Video';
     // for video (flv)
     $config['MediaUploadURL'] = $base_path . 'editor/filemanager/connectors/php/upload.php?Type=Video/flv';
     // for links (any resource type)
     $config['LinkUploadURL'] = $base_path . 'editor/filemanager/connectors/php/upload.php?Type=File';
     return $config;
 }