Feature #576 - The function mkpath() has been declared as deprecated. Elimination of this function form the actual code.

skala
Ivan Tcholakov 15 years ago
parent 179aac58d6
commit d37ef44978
  1. 48
      main/admin/course_export.php
  2. 66
      main/admin/session_export.php
  3. 84
      main/admin/session_import.php
  4. 4
      main/course_info/download.php
  5. 6
      main/inc/lib/add_course.lib.inc.php
  6. 4
      main/inc/lib/export.lib.inc.php
  7. 146
      main/inc/lib/fileManage.lib.php
  8. 248
      main/inc/lib/social.lib.php

@ -23,55 +23,55 @@ $interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAd
set_time_limit(0);
Display :: display_header($tool_name);
$archivePath=api_get_path(SYS_PATH).$archiveDirName.'/';
$archiveURL=api_get_path(WEB_CODE_PATH).'course_info/download.php?archive=';
$archivePath = api_get_path(SYS_ARCHIVE_PATH);
$archiveURL = api_get_path(WEB_CODE_PATH).'course_info/download.php?archive=';
$course_list = CourseManager::get_courses_list();
if($_POST['formSent'])
{
{
$formSent =$_POST['formSent'];
$select_type=intval($_POST['select_type']);
$file_type = 'csv';
$file_type = 'csv';
$courses = $selected_courses = array();
if ($select_type == 2) {
// Get selected courses from courses list in form sent
// Get selected courses from courses list in form sent
$selected_courses = $_POST['course_code'];
if (is_array($selected_courses)) {
foreach ($course_list as $course) {
if (is_array($selected_courses)) {
foreach ($course_list as $course) {
if (!in_array($course['code'],$selected_courses)) continue;
$courses[] = $course;
}
}
}
} else {
// Get all courses
$courses = $course_list;
}
if (!empty($courses)) {
if(!file_exists($archivePath)) {
mkpath($archivePath);
}
$archiveFile='export_courses_list_'.date('Y-m-d_H-i-s').'.'.$file_type;
$fp=fopen($archivePath.$archiveFile,'w');
if ($file_type == 'csv') {
$add = "Code;Title;CourseCategory;Teacher;Language;".PHP_EOL;
if (!empty($courses)) {
if (!file_exists($archivePath)) {
mkdir($archivePath, api_get_permissions_for_new_directories(), true);
}
$archiveFile = 'export_courses_list_'.date('Y-m-d_H-i-s').'.'.$file_type;
$fp = fopen($archivePath.$archiveFile,'w');
if ($file_type == 'csv') {
$add = "Code;Title;CourseCategory;Teacher;Language;".PHP_EOL;
foreach($courses as $course) {
$course['code'] = str_replace(';',',',$course['code']);
$course['title'] = str_replace(';',',',$course['title']);
$course['category_code'] = str_replace(';',',',$course['category_code']);
$course['tutor_name'] = str_replace(';',',',$course['tutor_name']);
$course['tutor_name'] = str_replace(';',',',$course['tutor_name']);
$course['course_language'] = str_replace(';',',',$course['course_language']);
$add.= $course['code'].';'.$course['title'].';'.$course['category_code'].';'.$course['tutor_name'].';'.$course['course_language'].';'.PHP_EOL;
}
$add.= $course['code'].';'.$course['title'].';'.$course['category_code'].';'.$course['tutor_name'].';'.$course['course_language'].';'.PHP_EOL;
}
fputs($fp, $add);
}
}
fclose($fp);
$msg=get_lang('CoursesListHasBeenExported').'<br/><a href="'.$archiveURL.$archiveFile.'">'.get_lang('ClickHereToDownloadTheFile').'</a>';
$msg = get_lang('CoursesListHasBeenExported').'<br/><a href="'.$archiveURL.$archiveFile.'">'.get_lang('ClickHereToDownloadTheFile').'</a>';
} else {
$msg=get_lang('ThereAreNotSelectedCoursesOrCoursesListIsEmpty');
$msg = get_lang('ThereAreNotSelectedCoursesOrCoursesListIsEmpty');
}
}

@ -27,21 +27,21 @@
==============================================================================
*/
// name of the language file that needs to be included
$language_file='admin';
$language_file = 'admin';
$cidReset=true;
$cidReset = true;
include('../inc/global.inc.php');
include '../inc/global.inc.php';
// setting the section (for the tabs)
$this_section=SECTION_PLATFORM_ADMIN;
$this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script(true);
include(api_get_path(LIBRARY_PATH).'/fileManage.lib.php');
include api_get_path(LIBRARY_PATH).'/fileManage.lib.php';
$session_id=$_GET['session_id'];
$formSent=0;
$errorMsg='';
$session_id = $_GET['session_id'];
$formSent = 0;
$errorMsg = '';
// Database Table Definitions
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
@ -53,21 +53,21 @@ $tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
$tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$archivePath=api_get_path(SYS_PATH).$archiveDirName.'/';
$archiveURL=api_get_path(WEB_CODE_PATH).'course_info/download.php?archive=';
$archivePath = api_get_path(SYS_ARCHIVE_PATH);
$archiveURL = api_get_path(WEB_CODE_PATH).'course_info/download.php?archive=';
$tool_name=get_lang('ExportSessionListXMLCSV');
$tool_name = get_lang('ExportSessionListXMLCSV');
$interbreadcrumb[]=array('url' => 'index.php',"name" => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array('url' => 'index.php',"name" => get_lang('PlatformAdmin'));
set_time_limit(0);
if($_POST['formSent'] )
if ($_POST['formSent'] )
{
$formSent=$_POST['formSent'];
$file_type=($_POST['file_type'] == 'csv')?'csv':'xml';
$session_id=$_POST['session_id'];
if(empty($session_id))
$formSent = $_POST['formSent'];
$file_type = ($_POST['file_type'] == 'csv')?'csv':'xml';
$session_id = $_POST['session_id'];
if (empty($session_id))
{
$sql = "SELECT id,name,id_coach,username,date_start,date_end,visibility,session_category_id FROM $tbl_session INNER JOIN $tbl_user
ON $tbl_user.user_id = $tbl_session.id_coach ORDER BY id";
@ -102,7 +102,7 @@ if($_POST['formSent'] )
{
if(!file_exists($archivePath))
{
mkpath($archivePath);
mkdir($archivePath, api_get_permissions_for_new_directories(), true);
}
if(!file_exists($archivePath.'index.html'))
@ -130,7 +130,7 @@ if($_POST['formSent'] )
else
{
$cvs = false;
fputs($fp,"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<Sessions>\n");
fputs($fp, "<?xml version=\"1.0\" encoding=\"".api_get_system_encoding()."\"?>\n<Sessions>\n");
}
while($row=Database::fetch_array($result))
@ -180,33 +180,33 @@ if($_POST['formSent'] )
$add .= $users;
//courses
$sql = "SELECT DISTINCT $tbl_course.code
$sql = "SELECT DISTINCT $tbl_course.code
FROM $tbl_course
INNER JOIN $tbl_session_course_user
ON $tbl_course.code = $tbl_session_course_user.course_code
ON $tbl_course.code = $tbl_session_course_user.course_code
AND $tbl_session_course_user.id_session = '".$row['id']."'";
$rsCourses = Database::query($sql,__FILE__,__LINE__);
$courses = '';
while($rowCourses = Database::fetch_array($rsCourses)){
// get coachs from a course
$sql = "SELECT u.username
$sql = "SELECT u.username
FROM $tbl_session_course_user scu
INNER JOIN $tbl_user u ON u.user_id = scu.id_user
INNER JOIN $tbl_user u ON u.user_id = scu.id_user
WHERE scu.course_code = '{$rowCourses['code']}'
AND scu.id_session = '".$row['id']."' AND scu.status = 2 ";
AND scu.id_session = '".$row['id']."' AND scu.status = 2 ";
$rs_coachs = Database::query($sql,__FILE__,__LINE__);
$coachs = array();
while ($row_coachs = Database::fetch_array($rs_coachs)) {
$coachs[] = $row_coachs['username'];
$coachs[] = $row_coachs['username'];
}
$coachs = implode(",",$coachs);
if($cvs){
$coachs = implode(",",$coachs);
if($cvs){
$courses .= str_replace(';',',',$rowCourses['code']);
$courses .= '['.str_replace(';',',',$coachs).'][';
}
@ -219,16 +219,16 @@ if($_POST['formSent'] )
// rel user courses
$sql = "SELECT DISTINCT u.username
FROM $tbl_session_course_user scu
INNER JOIN $tbl_session_user su ON scu.id_user = su.id_user AND scu.id_session = su.id_session
INNER JOIN $tbl_session_user su ON scu.id_user = su.id_user AND scu.id_session = su.id_session
INNER JOIN $tbl_user u
ON scu.id_user = u.user_id
AND scu.course_code='".$rowCourses['code']."'
AND scu.id_session='".$row['id']."'";
AND scu.id_session='".$row['id']."'";
$rsUsersCourse = Database::query($sql,__FILE__,__LINE__);
$userscourse = '';
while($rowUsersCourse = Database::fetch_array($rsUsersCourse)){
if($cvs){
$userscourse .= str_replace(';',',',$rowUsersCourse['username']).',';
}

@ -69,7 +69,7 @@ if ($_POST['formSent']) {
// $root = @simplexml_load_string(api_utf8_encode_xml(file_get_contents($_FILES['import_file']['tmp_name'])));
// To ease debugging let us use:
$content = file_get_contents($_FILES['import_file']['tmp_name']);
$content = api_utf8_encode_xml($content);
$root = @simplexml_load_string($content);
unset($content);
@ -242,7 +242,7 @@ if ($_POST['formSent']) {
// Creating sessions from <Sessions> base node.
if (count($root->Session) > 0) {
foreach ($root->Session as $node_session) {
$course_counter = 0;
@ -317,7 +317,7 @@ if ($_POST['formSent']) {
date_start = '$date_start',
date_end = '$date_end',
visibility = '$visibility',
session_category_id = '$session_category_id',
session_category_id = '$session_category_id',
session_admin_id=".intval($_user['user_id']);
$rs_session = Database::query($sql_session, __FILE__, __LINE__);
$session_id = Database::insert_id();
@ -334,7 +334,7 @@ if ($_POST['formSent']) {
date_start = '$date_start',
date_end = '$date_end',
visibility = '$visibility',
session_category_id = '$session_category_id',
session_category_id = '$session_category_id',
session_admin_id=".intval($_user['user_id']);
$rs_session = Database::query($sql_session, __FILE__, __LINE__);
$session_id = Database::insert_id();
@ -346,7 +346,7 @@ if ($_POST['formSent']) {
date_start = '$date_start',
date_end = '$date_end',
visibility = '$visibility',
session_category_id = '$session_category_id'
session_category_id = '$session_category_id'
WHERE name = '$session_name'";
$rs_session = Database::query($sql_session, __FILE__, __LINE__);
$session_id = Database::query("SELECT id FROM $tbl_session WHERE name='$session_name'", __FILE__, __LINE__);
@ -385,27 +385,27 @@ if ($_POST['formSent']) {
// Adding courses to a session.
foreach ($node_session->Course as $node_course) {
$course_code = Database::escape_string(trim(api_utf8_decode($node_course->CourseCode)));
// Verify that the course pointed by the course code node exists.
if (CourseManager::course_exists($course_code)) {
// If the course exists we continue.
$course_info = CourseManager::get_course_information($course_code);
$session_course_relation = SessionManager::relation_session_course_exist($session_id, $course_code);
if (!$session_course_relation) {
$sql_course = "INSERT INTO $tbl_session_course SET
course_code = '$course_code',
course_code = '$course_code',
id_session='$session_id'";
$rs_course = Database::query($sql_course, __FILE__, __LINE__);
}
$course_coachs = explode(",",$node_course->Coach);
// adding coachs to session course user
// adding coachs to session course user
foreach ($course_coachs as $course_coach) {
$coach_id = UserManager::purify_username(api_utf8_decode($course_coach), $purification_option_for_usernames);
$coach_id = UserManager::get_user_id_from_username($course_coach);
@ -420,10 +420,10 @@ if ($_POST['formSent']) {
$error_message .= get_lang('UserDoesNotExist').' : '.$user.'<br />';
}
}
// adding users
$course_counter++;
$users_in_course_counter = 0;
$users_in_course_counter = 0;
foreach ($node_course->User as $node_user) {
$username = UserManager::purify_username(api_utf8_decode($node_user), $purification_option_for_usernames);
$user_id = UserManager::get_user_id_from_username($username);
@ -459,15 +459,15 @@ if ($_POST['formSent']) {
if ($vcourse['code'] == $course_code) {
// Ignore, this has already been inserted.
} else {
$sql_course = "INSERT INTO $tbl_session_course SET
course_code = '".$vcourse['code']."',
id_session='$session_id'";
$rs_course = Database::query($sql_course, __FILE__, __LINE__);
$course_coachs = explode(",",$node_course->Coach);
// adding coachs to session course user
// adding coachs to session course user
foreach ($course_coachs as $course_coach) {
$coach_id = UserManager::purify_username(api_utf8_decode($course_coach), $purification_option_for_usernames);
$coach_id = UserManager::get_user_id_from_username($course_coach);
@ -482,10 +482,10 @@ if ($_POST['formSent']) {
$error_message .= get_lang('UserDoesNotExist').' : '.$user.'<br />';
}
}
// adding users
$course_counter++;
$users_in_course_counter = 0;
$users_in_course_counter = 0;
foreach ($node_course->User as $node_user) {
$username = UserManager::purify_username(api_utf8_decode($node_user), $purification_option_for_usernames);
$user_id = UserManager::get_user_id_from_username($username);
@ -559,7 +559,7 @@ if ($_POST['formSent']) {
}
}
}
// looping the sessions
foreach ($sessions as $enreg) {
$user_counter = 0;
@ -609,7 +609,7 @@ if ($_POST['formSent']) {
date_start = '$date_start',
date_end = '$date_end',
visibility = '$visibility',
session_category_id = '$session_category_id',
session_category_id = '$session_category_id',
session_admin_id=".intval($_user['user_id']);
$rs_session = Database::query($sql_session, __FILE__, __LINE__);
$session_id = Database::insert_id();
@ -626,7 +626,7 @@ if ($_POST['formSent']) {
date_end = '$date_end',
visibility = '$visibility',
session_category_id = '$session_category_id'";
$rs_session = Database::query($sql_session, __FILE__, __LINE__);
// We get the last insert id.
$my_session_result = SessionManager::get_session_by_name($session_name);
@ -639,7 +639,7 @@ if ($_POST['formSent']) {
date_start = '$date_start',
date_end = '$date_end',
visibility = '$visibility',
session_category_id = '$session_category_id'
session_category_id = '$session_category_id'
WHERE name = '$session_name'";
$rs_session = Database::query($sql_session, __FILE__, __LINE__);
$session_id = Database::query("SELECT id FROM $tbl_session WHERE name='$session_name'", __FILE__, __LINE__);
@ -691,22 +691,22 @@ if ($_POST['formSent']) {
}
// Adding the course to a session
$sql_course = "INSERT IGNORE INTO $tbl_session_course SET
course_code = '$course_code',
course_code = '$course_code',
id_session='$session_id'";
$rs_course = Database::query($sql_course, __FILE__, __LINE__);
$course_counter++;
$course_split = array();
$tok = strtok($course, "[]");
$course_split = array();
$tok = strtok($course, "[]");
while ($tok !== false) {
$course_split[] = $tok;
$tok = strtok("[]");
}
$course_coachs = explode(",",$course_split[1]);
$course_users = explode(",",$course_split[2]);
// adding coachs to session course user
// adding coachs to session course user
foreach ($course_coachs as $course_coach) {
$coach_id = UserManager::get_user_id_from_username($course_coach);
if ($coach_id !== false) {
@ -720,7 +720,7 @@ if ($_POST['formSent']) {
$error_message .= get_lang('UserDoesNotExist').' : '.$user.'<br />';
}
}
$users_in_course_counter = 0;
// Adding the relationship "Session - Course - User".
foreach ($course_users as $user) {
@ -748,23 +748,23 @@ if ($_POST['formSent']) {
if (CourseManager::course_exists($course_code, true)) {
$list = CourseManager :: get_courses_info_from_visual_code($course_code);
foreach ($list as $vcourse) {
if ($vcourse['code'] == $course_code) {
if ($vcourse['code'] == $course_code) {
// Ignore, this has already been inserted.
} else {
$coach = api_strstr($course, '[');
$coach = api_substr($coach, 1, api_strpos($coach,']') - 1);
// Adding the relationship "Session - Course".
$sql_course = "INSERT IGNORE INTO $tbl_session_course SET
course_code = '".$vcourse['code']."',
id_session='$session_id'";
$rs_course = Database::query($sql_course, __FILE__, __LINE__);
// adding coachs to session course user
// adding coachs to session course user
foreach ($course_coachs as $course_coach) {
$coach_id = UserManager::get_user_id_from_username($course_coach);
if ($coach_id !== false) {
@ -778,7 +778,7 @@ if ($_POST['formSent']) {
$error_message .= get_lang('UserDoesNotExist').' : '.$user.'<br />';
}
}
$users_in_course_counter = 0;
// Adding the relationship "Session - Course - User".
foreach ($course_users as $user) {
@ -794,13 +794,13 @@ if ($_POST['formSent']) {
$error_message .= get_lang('UserDoesNotExist').' : '.$user.'<br />';
}
}
Database::query("UPDATE $tbl_session_course SET nbr_users='$users_in_course_counter' WHERE course_code='".$vcourse['code']."'", __FILE__, __LINE__);
Database::query("UPDATE $tbl_session_course SET nbr_users='$users_in_course_counter' WHERE course_code='".$vcourse['code']."'", __FILE__, __LINE__);
}
}
$inserted_in_course[$vcourse['code']] = $vcourse['title'];
}
}
$sql_update_users = "UPDATE $tbl_session SET nbr_users='$user_counter', nbr_courses='$course_counter' WHERE id='$session_id'";
Database::query($sql_update_users, __FILE__, __LINE__);
}

@ -32,9 +32,9 @@ require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
if(isset($_GET['session']) && $_GET['session'] == true ){
$archive_path = api_get_path(SYS_ARCHIVE_PATH).'temp/';
$_cid = true;
$is_courseAdmin = true;
$is_courseAdmin = true;
} else {
$archive_path = api_get_path(SYS_PATH).$archiveDirName.'/';
$archive_path = api_get_path(SYS_ARCHIVE_PATH);
}
$archive_file = $_GET['archive'];

@ -2555,7 +2555,7 @@ function checkArchive($pathToArchive) {
* @return array List of files properties from the ZIP package
*/
function readPropertiesInArchive($archive, $isCompressed = TRUE) {
include (api_get_path(LIBRARY_PATH) . "pclzip/pclzip.lib.php");
include api_get_path(LIBRARY_PATH) . "pclzip/pclzip.lib.php";
printVar(dirname($archive), "Zip : ");
$uid = api_get_user_id();
/*
@ -2573,10 +2573,10 @@ function readPropertiesInArchive($archive, $isCompressed = TRUE) {
*/
$zipFile = new pclZip($archive);
$tmpDirName = dirname($archive) . "/tmp".$uid.uniqid($uid);
if (mkpath($tmpDirName)) {
if (mkdir($tmpDirName, api_get_permissions_for_new_directories(), true)) {
$unzippingSate = $zipFile->extract($tmpDirName);
} else {
die("mkpath failed");
die("mkdir failed");
}
$pathToArchiveIni = dirname($tmpDirName) . "/archive.ini";
// echo $pathToArchiveIni;

@ -169,7 +169,7 @@ class Export {
/*
==============================================================================
FUNCTIONS
DEPRECATED FUNCTIONS
==============================================================================
*/
@ -300,7 +300,7 @@ function copydir($origine, $destination, $verbose = false) {
return 0;
}
*/
mkpath($destination, 0770);
mkdir($destination, api_get_permissions_for_new_directories(), true);
if ($verbose) {
echo "
<strong>

@ -521,74 +521,6 @@ function form_dir_list($sourceType, $sourceComponent, $command, $baseWorkDir)
//------------------------------------------------------------------------------
/**
* to create missing directory in a gived path
*
* @returns a resource identifier or FALSE if the query was not executed correctly.
* @author KilerCris@Mail.com original function from php manual
* @author Christophe Gesch<EFBFBD> gesche@ipm.ucl.ac.be Claroline Team
* @since 28-Aug-2001 09:12
* @param sting $path wanted path
* @param boolean $verbose fix if comments must be printed
* @param string $mode fix if chmod is same of parent or default
* @global string $langCreatedIn string to say "create in"
*/
function mkpath($path, $verbose = false, $mode = "herit")
{
global $langCreatedIn, $_configuration;
$path = str_replace("/", "\\", $path);
$dirs = explode("\\", $path);
$path = $dirs[0];
if ($verbose)
{
echo "<ul>";
}
for ($i = 1; $i < sizeof($dirs); $i++)
{
$path .= '/'.$dirs[$i];
if (ereg('^'.$path,$_configuration['root_sys']) && strlen($path) < strlen($_configuration['root_sys']))
{
continue;
}
if (!is_dir($path))
{
$ret = mkdir($path, api_get_permissions_for_new_directories());
if ($ret)
{
if($verbose)
{
echo '<li><strong>'.basename($path).'</strong><br />'.$langCreatedIn.'<br /><strong>'.realpath($path.'/..').'</strong></li>';
}
}
else
{
if ($verbose)
{
echo '</ul>error : '.$path.' not created';
}
$ret = false;
break;
}
}
}
if ($verbose)
{
echo '</ul>';
}
return $ret;
}
/**
* to extract the extention of the filename
*
@ -840,4 +772,80 @@ class FileManager
} //end class FileManager
?>
/*
===============================================================
DEPRECATED FUNCTIONS
===============================================================
*/
/**
* @deprecated 06-FEB-2010. The function mkdir() is able to create directories recursively.
* @link http://php.net/manual/en/function.mkdir.php
*
* to create missing directory in a gived path
*
* @returns a resource identifier or FALSE if the query was not executed correctly.
* @author KilerCris@Mail.com original function from php manual
* @author Christophe Gesch<EFBFBD> gesche@ipm.ucl.ac.be Claroline Team
* @since 28-Aug-2001 09:12
* @param sting $path wanted path
* @param boolean $verbose fix if comments must be printed
* @param string $mode fix if chmod is same of parent or default (Note: This misterious parameter is not used).
* @global string $langCreatedIn string to say "create in"
*/
function mkpath($path, $verbose = false, $mode = "herit")
{
global $langCreatedIn, $_configuration;
$path = str_replace("/", "\\", $path);
$dirs = explode("\\", $path);
$path = $dirs[0];
if ($verbose)
{
echo "<ul>";
}
for ($i = 1; $i < sizeof($dirs); $i++)
{
$path .= '/'.$dirs[$i];
if (ereg('^'.$path,$_configuration['root_sys']) && strlen($path) < strlen($_configuration['root_sys']))
{
continue;
}
if (!is_dir($path))
{
$ret = mkdir($path, api_get_permissions_for_new_directories());
if ($ret)
{
if($verbose)
{
echo '<li><strong>'.basename($path).'</strong><br />'.$langCreatedIn.'<br /><strong>'.realpath($path.'/..').'</strong></li>';
}
}
else
{
if ($verbose)
{
echo '</ul>error : '.$path.' not created';
}
$ret = false;
break;
}
}
}
if ($verbose)
{
echo '</ul>';
}
return $ret;
}

@ -22,7 +22,7 @@ class SocialManager extends UserManager {
private function __construct() {
}
/**
* Allow to see contacts list
* @author isaac flores paz <florespaz@bidsoftperu.com>
@ -49,7 +49,7 @@ class SocialManager extends UserManager {
* Get relation type contact by name
* @param string names of the kind of relation
* @return int
* @author isaac flores paz <florespaz@bidsoftperu.com>
* @author isaac flores paz <florespaz@bidsoftperu.com>
*/
public static function get_relation_type_by_name ($relation_type_name) {
$list_type_friend=array();
@ -65,7 +65,7 @@ class SocialManager extends UserManager {
* @param int user id
* @param int user friend id
* @param string
* @author isaac flores paz <florespaz@bidsoftperu.com>
* @author isaac flores paz <florespaz@bidsoftperu.com>
*/
public static function get_relation_between_contacts ($user_id,$user_friend) {
$tbl_my_friend_relation_type = Database :: get_main_table(TABLE_MAIN_USER_FRIEND_RELATION_TYPE);
@ -80,7 +80,7 @@ class SocialManager extends UserManager {
return USER_UNKNOW;
}
}
/**
* Gets friends id list
* @param int user id
@ -89,7 +89,7 @@ class SocialManager extends UserManager {
* @param bool true will load firstname, lastname, and image name
* @return array
* @author Julio Montoya <gugli100@gmail.com> Cleaning code, function renamed, $load_extra_info option added
* @author isaac flores paz <florespaz@bidsoftperu.com>
* @author isaac flores paz <florespaz@bidsoftperu.com>
*/
public static function get_friends($user_id, $id_group=null, $search_name=null, $load_extra_info = true) {
$list_ids_friends=array();
@ -104,8 +104,8 @@ class SocialManager extends UserManager {
$search_name = str_replace(' ', '', $search_name);
//$sql.=' AND friend_user_id IN (SELECT user_id FROM '.$tbl_my_user.' WHERE '.(api_is_western_name_order() ? 'concat(firstName, lastName)' : 'concat(lastName, firstName)').' like concat("%","'.Database::escape_string($search_name).'","%"));';
$sql.=' AND friend_user_id IN (SELECT user_id FROM '.$tbl_my_user.' WHERE firstName LIKE "%'.Database::escape_string($search_name).'%" OR lastName LIKE "%'.Database::escape_string($search_name).'%" OR '.(api_is_western_name_order() ? 'concat(firstName, lastName)' : 'concat(lastName, firstName)').' like concat("%","'.Database::escape_string($search_name).'","%") ) ';
}
}
$res=Database::query($sql,__FILE__,__LINE__);
while ($row=Database::fetch_array($res,'ASSOC')) {
if ($load_extra_info == true) {
@ -113,13 +113,13 @@ class SocialManager extends UserManager {
$my_user_info=api_get_user_info($row['friend_user_id']);
$list_ids_friends[]=array('friend_user_id'=>$row['friend_user_id'],'firstName'=>$my_user_info['firstName'] , 'lastName'=>$my_user_info['lastName'], 'username'=>$my_user_info['username'], 'image'=>$path['file']);
} else {
$list_ids_friends[]=$row;
}
$list_ids_friends[]=$row;
}
}
return $list_ids_friends;
}
/**
* get list web path of contacts by user id
* @param int user id
@ -142,7 +142,7 @@ class SocialManager extends UserManager {
}
return $combine_friend;
}
/**
* get web path of user invitate
* @author isaac flores paz <florespaz@bidsoftperu.com>
@ -158,7 +158,7 @@ class SocialManager extends UserManager {
}
return $list_path_image_friend;
}
/**
* Sends an invitation to contacts
* @param int user id
@ -172,17 +172,17 @@ class SocialManager extends UserManager {
public static function send_invitation_friend ($user_id,$friend_id,$message_title,$message_content) {
$tbl_message = Database::get_main_table(TABLE_MAIN_MESSAGE);
$user_id = intval($user_id);
$friend_id = intval($friend_id);
$friend_id = intval($friend_id);
$message_title = Database::escape_string($message_title);
$message_content = Database::escape_string($message_content);
$current_date = date('Y-m-d H:i:s',time());
$current_date = date('Y-m-d H:i:s',time());
$sql_exist='SELECT COUNT(*) AS count FROM '.$tbl_message.' WHERE user_sender_id='.($user_id).' AND user_receiver_id='.($friend_id).' AND msg_status IN(5,6,7);';
$res_exist=Database::query($sql_exist,__FILE__,__LINE__);
$row_exist=Database::fetch_array($res_exist,'ASSOC');
if ($row_exist['count']==0) {
if ($row_exist['count']==0) {
$sql='INSERT INTO '.$tbl_message.'(user_sender_id,user_receiver_id,msg_status,send_date,title,content) VALUES('.$user_id.','.$friend_id.','.MESSAGE_STATUS_INVITATION_PENDING.',"'.$current_date.'","'.$message_title.'","'.$message_content.'")';
Database::query($sql,__FILE__,__LINE__);
return true;
@ -214,7 +214,7 @@ class SocialManager extends UserManager {
$row=Database::fetch_array($res,'ASSOC');
return $row['count_message_in_box'];
}
/**
* Get invitation list received by user
* @author isaac flores paz <florespaz@bidsoftperu.com>
@ -231,17 +231,17 @@ class SocialManager extends UserManager {
}
return $list_friend_invitation;
}
/**
* Get invitation list sent by user
* @author Julio Montoya <gugli100@gmail.com>
* @param int user id
* @return array()
*/
public static function get_list_invitation_sent_by_user_id ($user_id) {
$list_friend_invitation=array();
$tbl_message=Database::get_main_table(TABLE_MAIN_MESSAGE);
$tbl_message=Database::get_main_table(TABLE_MAIN_MESSAGE);
$sql='SELECT user_receiver_id, send_date,title,content FROM '.$tbl_message.' WHERE user_sender_id = '.intval($user_id).' AND msg_status = '.MESSAGE_STATUS_INVITATION_PENDING;
$res=Database::query($sql,__FILE__,__LINE__);
while ($row=Database::fetch_array($res,'ASSOC')) {
@ -249,7 +249,7 @@ class SocialManager extends UserManager {
}
return $list_friend_invitation;
}
/**
* Accepts invitation
* @param int user sender id
@ -263,7 +263,7 @@ class SocialManager extends UserManager {
Database::query($sql,__FILE__,__LINE__);
}
/**
* Denies invitation
* Denies invitation
* @param int user sender id
* @param int user receiver id
* @author isaac flores paz <florespaz@bidsoftperu.com>
@ -311,13 +311,13 @@ class SocialManager extends UserManager {
echo Display::display_error_message($succes,true);
}
return false;
} elseif (isset($userfriend_id) && !isset($subject_message)) {
} elseif (isset($userfriend_id) && !isset($subject_message)) {
$count_is_true=false;
$count_number_is_true=0;
if (isset($userfriend_id) && $userfriend_id>0) {
$message_title = get_lang('Invitation');
$message_title = get_lang('Invitation');
$count_is_true = self::send_invitation_friend(api_get_user_id(),$userfriend_id, $message_title, $content_message);
if ($count_is_true) {
echo Display::display_normal_message(api_htmlentities(get_lang('InvitationHasBeenSent'), ENT_QUOTES,$charset),false);
}else {
@ -327,7 +327,7 @@ class SocialManager extends UserManager {
}
}
}
/**
* Get user's feeds
* @param int User ID
@ -347,11 +347,11 @@ class SocialManager extends UserManager {
if (count($feeds)==0) { return ''; }
foreach ($feeds as $url) {
if (empty($url)) { continue; }
$rss = @fetch_rss($url);
$i = 1;
$rss = @fetch_rss($url);
$i = 1;
if (!empty($rss->items)) {
$res .= '<h2>'.$rss->channel['title'].'</h2>';
$res .= '<div class="social-rss-channel-items">';
$res .= '<div class="social-rss-channel-items">';
foreach ($rss->items as $item) {
if ($limit>=0 and $i>$limit) {break;}
$res .= '<h3><a href="'.$item['link'].'">'.$item['title'].'</a></h3>';
@ -360,11 +360,11 @@ class SocialManager extends UserManager {
$i++;
}
$res .= '</div>';
}
}
}
return $res;
}
/**
* Helper functions definition
*/
@ -382,7 +382,7 @@ class SocialManager extends UserManager {
$course_tool_table = Database :: get_course_table(TABLE_TOOL_LIST, $course_database);
$tool_edit_table = Database :: get_course_table(TABLE_ITEM_PROPERTY, $course_database);
$course_group_user_table = Database :: get_course_table(TOOL_USER, $course_database);
$user_id = api_get_user_id();
$course_system_code = $my_course['k'];
$course_visual_code = $my_course['c'];
@ -393,9 +393,9 @@ class SocialManager extends UserManager {
$course_info = Database :: get_course_info($course_system_code);
$course_access_settings = CourseManager :: get_access_settings($course_system_code);
$course_visibility = $course_access_settings['visibility'];
$user_in_course_status = CourseManager :: get_user_in_course_status(api_get_user_id(), $course_system_code);
//function logic - act on the data
$is_virtual_course = CourseManager :: is_virtual_course_from_system_code($my_course['k']);
@ -420,7 +420,7 @@ class SocialManager extends UserManager {
}
$s_course_status=$my_course['s'];
$s_htlm_status_icon="";
if ($s_course_status==1) {
$s_htlm_status_icon=Display::return_icon('course.gif', get_lang('Course')).' '.Display::return_icon('teachers.gif', get_lang('Status').': '.get_lang('Teacher'),array('style'=>'width:11px; height:11px'));
}
@ -430,13 +430,13 @@ class SocialManager extends UserManager {
if ($s_course_status==5) {
$s_htlm_status_icon=Display::return_icon('course.gif', get_lang('Course')).' '.Display::return_icon('students.gif', get_lang('Status').': '.get_lang('Student'),array('style'=>'width:11px; height:11px'));
}
//display course entry
$result .= '<div id="div_'.$count.'">';
//$result .= '<a id="btn_'.$count.'" href="#" onclick="toogle_course(this,\''.$course_database.'\')">';
$result .= '<h2><img src="../img/nolines_plus.gif" id="btn_'.$count.'" onclick="toogle_course(this,\''.$course_database.'\' )">';
$result .= $s_htlm_status_icon;
//show a hyperlink to the course, unless the course is closed and user is not course admin
if ($course_visibility != COURSE_VISIBILITY_CLOSED || $user_in_course_status == COURSEMANAGER) {
$result .= '<a href="javascript:void(0)" id="ln_'.$count.'" onclick=toogle_course(this,\''.$course_database.'\');>&nbsp;'.$course_title.'</a></h2>';
@ -517,12 +517,12 @@ class SocialManager extends UserManager {
}
$result .= '</li>';
$result .= '</div>';
if (api_get_setting('use_session_mode')=='true' && !$nosession) {
$session = '';
$active = false;
if (!empty($my_course['session_name'])) {
// Request for the name of the general coach
$sql = 'SELECT lastname, firstname
FROM '.$tbl_session.' ts LEFT JOIN '.$main_user_table .' tu
@ -531,7 +531,7 @@ class SocialManager extends UserManager {
$rs = Database::query($sql, __FILE__, __LINE__);
$sessioncoach = Database::store_result($rs);
$sessioncoach = $sessioncoach[0];
$session = array();
$session['title'] = $my_course['session_name'];
if ( $my_course['date_start']=='0000-00-00' ) {
@ -555,159 +555,159 @@ class SocialManager extends UserManager {
//$my_course['creation_date'];
return $output;
}
/**
* Shows the right menu of the Social Network tool
*
*
* @param string highlight link possible values: group_add, home, messages, messages_inbox, messages_compose ,messages_outbox ,invitations, shared_profile, friends, groups search
* @param int group id
* @param int user id
* @param bool show profile or not (show or hide the user image/information)
*
*
*/
public static function show_social_menu($show = '', $group_id = 0, $user_id = 0, $show_full_profile = false) {
if (empty($user_id)) {
$user_id = api_get_user_id();
}
$show_groups = array('groups', 'group_messages', 'messages_list', 'group_add', 'mygroups', 'group_edit', 'member_list', 'invite_friends', 'waiting_list');
$show_messages = array('messages', 'messages_inbox', 'messages_outbox', 'messages_compose');
// get count unread message and total invitations
$count_unread_message = MessageManager::get_number_of_messages(true);
$count_unread_message = MessageManager::get_number_of_messages(true);
$count_unread_message = (!empty($count_unread_message)?' ('.$count_unread_message.')':'');
$number_of_new_messages_of_friend = SocialManager::get_message_number_invitation_by_user_id(api_get_user_id());
$group_pending_invitations = GroupPortalManager::get_groups_by_user(api_get_user_id(), GROUP_USER_PERMISSION_PENDING_INVITATION,false);
$group_pending_invitations = count($group_pending_invitations);
$group_pending_invitations = count($group_pending_invitations);
$total_invitations = $number_of_new_messages_of_friend + $group_pending_invitations;
$total_invitations = (!empty($total_invitations)?' ('.$total_invitations.')':'');
// Everybody can create groups
if (api_get_setting('allow_students_to_create_groups_in_social') == 'true') {
$create_group_item = '<li class="social-menu-sub-level"><a href="'.api_get_path(WEB_PATH).'main/social/group_add.php">'.Display::return_icon('group_add.png',get_lang('CreateAgroup'),array('hspace'=>'6','style'=>'float:left')).'<span class="'.($show=='group_add'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('CreateAgroup').'</span></a></li>';
$create_group_item = '<li class="social-menu-sub-level"><a href="'.api_get_path(WEB_PATH).'main/social/group_add.php">'.Display::return_icon('group_add.png',get_lang('CreateAgroup'),array('hspace'=>'6','style'=>'float:left')).'<span class="'.($show=='group_add'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('CreateAgroup').'</span></a></li>';
} else {
// Only admins and teachers can create groups
// Only admins and teachers can create groups
if (api_is_allowed_to_edit(null,true)) {
$create_group_item = '<li class="social-menu-sub-level"><a href="'.api_get_path(WEB_PATH).'main/social/group_add.php">'.Display::return_icon('group_add.png',get_lang('CreateAgroup'),array('hspace'=>'6','style'=>'float:left')).'<span class="'.($show=='group_add'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('CreateAgroup').'</span></a></li>';
}
}
echo '<div class="social-menu">';
echo '<div class="social-menu">';
if (in_array($show, $show_groups) && !empty($group_id)) {
//--- Group image
//--- Group image
$group_info = GroupPortalManager::get_group_data($group_id);
$big = GroupPortalManager::get_picture_group($group_id, $group_info['picture_uri'],160,GROUP_IMAGE_SIZE_BIG);
$original = GroupPortalManager::get_picture_group($group_id, $group_info['picture_uri'],'',GROUP_IMAGE_SIZE_ORIGINAL);
$original = GroupPortalManager::get_picture_group($group_id, $group_info['picture_uri'],'',GROUP_IMAGE_SIZE_ORIGINAL);
echo '<div class="social-content-image">';
echo '<div class="social-background-content" onmouseout="hide_icon_edit()" onmouseover="show_icon_edit()"><center>';
if (basename($big['file']) != 'unknown_group.png') {
echo '<a class="thickbox" href="'.$original['file'].'"><img src='.$big['file'].' class="social-groups-image" /> </a><br /><br />';
} else {
echo '<img src='.$big['file'].' class="social-groups-image" /><br /><br />';
}
if (GroupPortalManager::is_group_admin($group_id, api_get_user_id())) {
if (GroupPortalManager::is_group_admin($group_id, api_get_user_id())) {
echo '<div id="edit_image" class="hidden_message" style="display:none"><a href="'.api_get_path(WEB_PATH).'main/social/group_edit.php?id='.$group_id.'">'.get_lang('EditGroup').'</a></div>';
}
echo '</center></div>';
echo '</div>';
} else {
$img_array = UserManager::get_user_picture_path_by_id($user_id,'web',true,true);
$big_image = UserManager::get_picture_user($user_id, $img_array['file'],'', USER_IMAGE_SIZE_BIG);
$big_image = UserManager::get_picture_user($user_id, $img_array['file'],'', USER_IMAGE_SIZE_BIG);
$big_image = $big_image['file'].$big_image['dir'];
//--- User image
//--- User image
echo '<div class="social-content-image">';
echo '<div class="social-background-content" onmouseout="hide_icon_edit()" onmouseover="show_icon_edit()"><center>';
if ($img_array['file'] != 'unknown.jpg') {
echo '<a class="thickbox" href="'.$big_image.'"><img src='.$img_array['dir'].$img_array['file'].' /> </a>';
} else {
echo '<img src='.$img_array['dir'].$img_array['file'].' width="110px" />';
}
if (api_get_user_id() == $user_id) {
if (api_get_user_id() == $user_id) {
echo '<div id="edit_image" class="hidden_message" style="display:none"><a href="'.api_get_path(WEB_PATH).'main/auth/profile.php">'.get_lang('EditProfile').'</a></div>';
}
echo '</center></div>';
echo '</div>';
}
if ($show != 'shared_profile') {
}
if ($show != 'shared_profile') {
echo '<div align="center" class="social-menu-title" ><span class="social-menu-text1">'.get_lang('Menu').'</span></div>';
echo '<div>
<ul>
<li><a href="'.api_get_path(WEB_PATH).'main/social/home.php">'.Display::return_icon('home.png',get_lang('Home'),array('hspace'=>'6')).'<span class="'.($show=='home'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('Home').'</span></a></li>
<li><a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php?f=social">'.Display::return_icon('instant_message.png',get_lang('Messages'),array('hspace'=>'6')).'<span class="'.($show=='messages'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('Messages').$count_unread_message.'</span></a></li>';
if (in_array($show, $show_messages)) {
echo '<li><ul>';
echo '<li class="social-menu-sub-level"><a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php?f=social">'.Display::return_icon('inbox_message.png', get_lang('Inbox'), array('hspace'=>'6')).'<span class="'.($show=='messages_inbox'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('Inbox').'</span></a></li>';
echo '<li class="social-menu-sub-level"><a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php?f=social">'.Display::return_icon('compose_message.png', get_lang('ComposeMessage'), array('hspace'=>'6','style'=>'float:left')).'<span class="'.($show=='messages_compose'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('ComposeMessage').'</span></a></li>';
echo '<li class="social-menu-sub-level" style="background:none;padding:0px"><a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php?f=social">'.Display::return_icon('outbox_message.png', get_lang('Outbox'), array('hspace'=>'6')).'<span class="'.($show=='messages_outbox'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('Outbox').'</span></a></li>';
echo '</ul></li>';
echo '</ul></li>';
}
//Invitations
echo '<li><a href="'.api_get_path(WEB_PATH).'main/social/invitations.php">'.Display::return_icon('invitation.png',get_lang('Invitations'),array('hspace'=>'6')).'<span class="'.($show=='invitations'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('Invitations').$total_invitations.'</span></a></li>';
echo '<li><a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.Display::return_icon('my_shared_profile.png',get_lang('ViewMySharedProfile'),array('hspace'=>'6')).'<span class="'.($show=='shared_profile'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('ViewMySharedProfile').'</span></a></li>
<li><a href="'.api_get_path(WEB_PATH).'main/social/friends.php">'.Display::return_icon('friend.png',get_lang('Friends'),array('hspace'=>'6')).'<span class="'.($show=='friends'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('Friends').'</span></a></li>
<li><a href="'.api_get_path(WEB_PATH).'main/social/groups.php">'.Display::return_icon('group.png',get_lang('Groups'),array('hspace'=>'6')).'<span class="'.($show=='groups'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('Groups').'</span></a></li>';
if (in_array($show,$show_groups)) {
echo '<li><ul>';
echo $create_group_item;
echo '<li class="social-menu-sub-level" style="background:none;padding:0px"><a href="'.api_get_path(WEB_PATH).'main/social/groups.php?view=mygroups">'.Display::return_icon('group.png',get_lang('MyGroups'),array('hspace'=>'6')).'<span class="'.($show=='mygroups'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('MyGroups').'</span></a></li>';
echo '<li class="social-menu-sub-level" style="background:none;padding:0px"><a href="'.api_get_path(WEB_PATH).'main/social/groups.php?view=mygroups">'.Display::return_icon('group.png',get_lang('MyGroups'),array('hspace'=>'6')).'<span class="'.($show=='mygroups'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('MyGroups').'</span></a></li>';
echo '</ul></li>';
}
}
echo '<li><a href="'.api_get_path(WEB_PATH).'main/social/search.php">'.Display::return_icon('zoom.png',get_lang('Search'),array('hspace'=>'6')).'<span class="'.($show=='search'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('Search').'</span></a></li>
</ul>
</div>';
</div>';
if (in_array($show, $show_groups) && !empty($group_id)) {
echo GroupPortalManager::show_group_column_information($group_id, api_get_user_id(), $show);
}
}
if ($show == 'shared_profile') {
echo '<div align="center" class="social-menu-title" ><span class="social-menu-text1">'.get_lang('Menu').'</span></div>';
echo '<div align="center" class="social-menu-title" ><span class="social-menu-text1">'.get_lang('Menu').'</span></div>';
echo '<div>
<ul>';
// My own profile
if ($show_full_profile && $user_id == intval(api_get_user_id())) {
if ($show_full_profile && $user_id == intval(api_get_user_id())) {
echo '
<li><a href="'.api_get_path(WEB_PATH).'main/social/home.php">'.Display::return_icon('home.png',get_lang('Home'),array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('Home').'</span></a></li>
<li><a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php?f=social">'.Display::return_icon('instant_message.png',get_lang('Messages'),array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('Messages').$count_unread_message.'</span></a></li>';
echo ' <li><a href="'.api_get_path(WEB_PATH).'main/social/invitations.php">'.Display::return_icon('invitation.png',get_lang('Invitations'),array('hspace'=>'6')).'<span class="'.($show=='invitations'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('Invitations').$total_invitations.'</span></a></li>';
echo ' <li><a href="'.api_get_path(WEB_PATH).'main/social/invitations.php">'.Display::return_icon('invitation.png',get_lang('Invitations'),array('hspace'=>'6')).'<span class="'.($show=='invitations'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('Invitations').$total_invitations.'</span></a></li>';
echo '<li><a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.Display::return_icon('my_shared_profile.png',get_lang('ViewMySharedProfile'),array('hspace'=>'6','style'=>'float:left')).'<span class="social-menu-text-active" >'.get_lang('ViewMySharedProfile').'</span></a></li>
<li><a href="'.api_get_path(WEB_PATH).'main/social/friends.php">'.Display::return_icon('friend.png',get_lang('Friends'),array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('Friends').'</span></a></li>
<li><a href="'.api_get_path(WEB_PATH).'main/social/groups.php">'.Display::return_icon('group.png',get_lang('Groups'),array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('Groups').'</span></a></li>';
}
// My friend profile
$html_actions = '';
if ($user_id != api_get_user_id()) {
if ($user_id != api_get_user_id()) {
echo '<li><a href="'.api_get_path(WEB_PATH).'main/messages/send_message_to_userfriend.inc.php?height=300&width=610&user_friend='.$user_id.'&view=profile&view_panel=1" class="thickbox" title="'.get_lang('SendMessage').'">';
echo Display::return_icon('compose_message.png',get_lang('SendMessage')).'&nbsp;&nbsp;'.get_lang('SendMessage').'</a></li>';
}
echo Display::return_icon('compose_message.png',get_lang('SendMessage')).'&nbsp;&nbsp;'.get_lang('SendMessage').'</a></li>';
}
//check if I already sent an invitation message
$invitation_sent_list = SocialManager::get_list_invitation_sent_by_user_id(api_get_user_id());
if (is_array($invitation_sent_list) && is_array($invitation_sent_list[$user_id]) && count($invitation_sent_list[$user_id]) >0 ) {
if (is_array($invitation_sent_list) && is_array($invitation_sent_list[$user_id]) && count($invitation_sent_list[$user_id]) >0 ) {
echo '<li><a href="'.api_get_path(WEB_PATH).'main/social/invitations.php">'.Display::return_icon('invitation.png',get_lang('YouAlreadySentAnInvitation')).'&nbsp;&nbsp;'.get_lang('YouAlreadySentAnInvitation').'</a></li>';
} else {
if (!$show_full_profile) {
@ -715,7 +715,7 @@ class SocialManager extends UserManager {
}
}
echo '</ul></div>';
/*
// ---- My Agenda Items
@ -736,12 +736,12 @@ class SocialManager extends UserManager {
if ($show_full_profile && $user_id == intval(api_get_user_id())) {
$personal_course_list = UserManager::get_personal_session_course_list($user_id);
$course_list_code = array();
$i=1;
$i=1;
if (is_array($personal_course_list)) {
foreach ($personal_course_list as $my_course) {
if ($i<=10) {
$list[] = SocialManager::get_logged_user_course_html($my_course,$i);
$course_list_code[] = array('code'=>$my_course['c'],'dbName'=>$my_course['db']);
$course_list_code[] = array('code'=>$my_course['c'],'dbName'=>$my_course['db']);
} else {
break;
}
@ -758,27 +758,27 @@ class SocialManager extends UserManager {
$content = get_all_annoucement_by_user_course($course['dbName'],$my_announcement_by_user_id);
$course_info=api_get_course_info($course['code']);
if (!empty($content)) {
$announcements[] = '<li><a href="'.api_get_path(WEB_CODE_PATH).'announcements/announcements.php?cidReq='.$course['code'].'"'.Display::return_icon('announcement.png',get_lang('Announcements'),array('hspace'=>'6')).'<span class="social-menu-text4">'.$course_info['name'].' ('.$content['count'].')</span></a></li>';
$announcements[] = '<li><a href="'.api_get_path(WEB_CODE_PATH).'announcements/announcements.php?cidReq='.$course['code'].'"'.Display::return_icon('announcement.png',get_lang('Announcements'),array('hspace'=>'6')).'<span class="social-menu-text4">'.$course_info['name'].' ('.$content['count'].')</span></a></li>';
}
}
if (!empty($announcements)) {
echo '<div align="center" class="social-menu-title" ><span class="social-menu-text1">'.get_lang('Announcement').'</span></div>';
echo '<div>';
echo '<ul>';
echo '<ul>';
foreach ($announcements as $announcement) {
echo $announcement;
}
}
echo '</ul>';
echo '</div>';
}
}
}
}
echo '</div>';
}
/**
* Displays a sortable table with the list of online users.
* @param array $user_list
@ -792,7 +792,7 @@ class SocialManager extends UserManager {
$extra_params['cidReq'] = Security::remove_XSS($_GET['cidReq']);
$course_url = '&amp;cidReq='.Security::remove_XSS($_GET['cidReq']);
}
foreach ($user_list as $user) {
$uid = $user[0];
$user_info = api_get_user_info($uid);
@ -808,7 +808,7 @@ class SocialManager extends UserManager {
$url = '#';
}
$image_array = UserManager::get_user_picture_path_by_id($uid, 'system', false, true);
$friends_profile = SocialManager::get_picture_user($uid, $image_array['file'], 80, USER_IMAGE_SIZE_ORIGINAL );
// reduce image
$name = api_get_person_name($user_info['firstName'], $user_info['lastName']);
@ -825,10 +825,10 @@ class SocialManager extends UserManager {
$table_header[] = array(get_lang('UserPicture'), false, 'width="90"');
///$table_header[] = array(get_lang('Name'), true);
//$table_header[] = array(get_lang('LastName'), true);
if (api_get_setting('show_email_addresses') == 'true') {
$table_header[] = array(get_lang('Email'), true);
}
}
Display::display_sortable_table($table_header, $table_data, array(), array('per_page' => 20), $extra_params, array(),'grid');
}
}
@ -839,7 +839,7 @@ class SocialManager extends UserManager {
public static function display_individual_user($user_id) {
global $interbreadcrumb;
$safe_user_id = Database::escape_string($user_id);
// to prevent a hacking attempt: http://www.dokeos.com/forum/viewtopic.php?t=5363
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$sql = "SELECT * FROM $user_table WHERE user_id='".$safe_user_id."'";
@ -878,17 +878,17 @@ class SocialManager extends UserManager {
echo Display::return_icon('unknown.jpg', get_lang('Unknown'));
echo '<br />';
}
echo '<br />'.$status.'<br />';
global $user_anonymous;
if (api_get_setting('allow_social_tool') == 'true' && api_get_user_id() <> $user_anonymous && api_get_user_id() <> 0) {
echo '<br />';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'social/profile.php?u='.$safe_user_id.'">'.get_lang('ViewSharedProfile').'</a>';
echo '<br />';
$user_anonymous = api_get_anonymous_id();
if ($safe_user_id != api_get_user_id() && !api_is_anonymous($safe_user_id)) {
$user_relation = SocialManager::get_relation_between_contacts(api_get_user_id(), $safe_user_id);
if ($user_relation == 0 || $user_relation == 6) {
@ -899,11 +899,11 @@ class SocialManager extends UserManager {
}
}
}
if (api_get_setting('show_email_addresses') == 'true') {
echo Display::encrypted_mailto_link($user_object->email,$user_object->email).'<br />';
}
echo '</div>';
if ($user_object->competences) {
echo '<dt><div class="actions-message"><strong>'.get_lang('MyCompetences').'</strong></div></dt>';
@ -942,7 +942,7 @@ class SocialManager extends UserManager {
$webdir_array = UserManager::get_user_picture_path_by_id($user_id, 'web', true);
$webdir = $webdir_array['dir'].$user_id.'/';
if (!is_dir($sysdir)) {
mkpath($sysdir);
mkdir($sysdir, api_get_permissions_for_new_directories(), true);
}
/*
$handle = opendir($sysdir);
@ -959,7 +959,7 @@ class SocialManager extends UserManager {
}
*/
$productions = UserManager::get_user_productions($user_id);
if (count($productions) > 0) {
echo '<dt><strong>'.get_lang('Productions').'</strong></dt>';
echo '<dd><ul>';
@ -982,8 +982,8 @@ class SocialManager extends UserManager {
}
}
/**
* Dummy function
*
* Dummy function
*
*/
public static function get_plugins($place = SOCIAL_CENTER_PLUGIN) {
$content = '';
@ -995,7 +995,7 @@ class SocialManager extends UserManager {
foreach($social_plugins as $plugin ) {
$content.= '<div class="social-plugin-item">';
$content.= $plugin;
$content.= '</div>';
$content.= '</div>';
}
$content.= '</div>';
}
@ -1004,7 +1004,7 @@ class SocialManager extends UserManager {
break;
case SOCIAL_RIGHT_PLUGIN:
break;
}
}
return $content;
}
}

Loading…
Cancel
Save