Merge branch '1.9.x' into C7347

1.9.x
aragonc 10 years ago
commit 4fe7ad6640
  1. 12
      documentation/changelog.html
  2. 124
      main/exercice/exercise.class.php
  3. 2
      main/exercice/question_list_admin.inc.php
  4. 73
      main/inc/lib/course.lib.php
  5. 3
      main/inc/lib/document.lib.php
  6. 6
      main/inc/lib/main_api.lib.php
  7. 18
      main/inc/lib/social.lib.php
  8. 17
      main/inc/lib/text.lib.php
  9. 6
      main/messages/new_message.php
  10. 9
      main/social/home.php
  11. 10
      main/social/profile.php
  12. 77
      tests/scripts/packaging/gitlog.php

@ -44,7 +44,7 @@
<p><i>Note: most #wxyz references are issue numbers you can find in <a href="http://support.chamilo.org/projects/chamilo-18/issues" target="_blank">our public bug tracking system</a>. Some references marked BT#xyz are developments made externally for BeezNest customers and integrated into Chamilo. The details of these tasks cannot be seen for confidentiality reasons, but the code change is public and can be reviewed by anyone.</i></p>
<p>&nbsp;</p>
<h1>Chamilo 1.9.10 - 10th of November, 2014</h1>
<h1>Chamilo 1.9.10 - Huánuco, 10th of November, 2014</h1>
<h3>Release notes - summary</h3>
<p>Chamilo 1.9.10 is a patch version with a few minor bugfixes and a new packaging. This will be packaged and promoted as 1.9.8, but the folder inside the 1.9.8 will be called 1.9.10, with a few changes to this changelog file and a few fixes throughout the code (as such, you can just overwrite previous files to upgrade from 1.9.8, 1.9.8.1 or 1.9.8.2 to 1.9.10).</p>
<h3>Release name</h3>
@ -272,9 +272,11 @@ All security issues are published and patches are attached on <a href="https://s
<li>(a55776c - BT#8189) Fix for users inscription with approval setting</li>
</ul>
<h3>Stylesheets and theming</h3>
Stylesheets have been considerably changed in version 1.9.8, which might require a little update on your side if you have a custom stylesheet. We're sorry about it, but it was really necessary to improve the adaptability of the interface for mobile devices (which we are sure you will appreciate). If you only changed the logo, we recommend you make a copy of an existing Chamilo style (main/css/chamilo*) again, rename it and simply replace the logo then upload the new style. If you have more complex styles, you might want to ask for the assistance of your web designer at the moment you update Chamilo to this version.
<ul>
<li>No major style changes in this version, but a lot of visual improvements</li>
<li>The possibility to select a template (from main/template/) through the configuration.php file has been added, although no new template is available yet</li>
<li>Old question types icons were replaced by new icons</li>
<li>Old session "window" icon was replaced by a new icon</li>
</ul>
<h3>Web services</h3>
<ul>
@ -283,8 +285,7 @@ Stylesheets have been considerably changed in version 1.9.8, which might require
</ul>
<h3>Removals</h3>
<ul>
<li>Old question types icons were replaced by new icons</li>
<li>Old session "window" icon was replaced by a new icon</li>
<li>No removal worth mentioning in this version</li>
</ul>
@ -2172,9 +2173,8 @@ This version of Chamilo only includes a few minor new features:
<li>Added support for .docx</li>
<li>Improve group homepage (#2077)</li>
<li>Added support for global announcement by URL (#1763)</li>
</li>
</ul>
<h3>Debugging</h3>
<ul>
<li>Fixed tools shortcuts crash bug (#3356)</li>

@ -3626,6 +3626,7 @@ class Exercise
'open_answer' => $arrans,
'answer_type' => $answerType
);
return $return_array;
}
@ -3633,15 +3634,21 @@ class Exercise
* Sends a notification when a user ends an examn
*
*/
function send_mail_notification_for_exam($question_list_answers, $origin, $exe_id) {
public function send_mail_notification_for_exam($question_list_answers, $origin, $exe_id)
{
if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) {
return null;
}
// Email configuration settings
$courseCode = api_get_course_id();
$courseInfo = api_get_course_info($courseCode);
$courseCode = api_get_course_id();
$courseInfo = api_get_course_info($courseCode);
$sessionId = api_get_session_id();
$url_email = api_get_path(WEB_CODE_PATH).'exercice/exercise_show.php?'.api_get_cidreq().'&id_session='.api_get_session_id().'&id='.$exe_id.'&action=qualify';
if (empty($courseInfo)) {
return false;
}
$url_email = api_get_path(WEB_CODE_PATH).'exercice/exercise_show.php?'.api_get_cidreq().'&id_session='.$sessionId.'&id='.$exe_id.'&action=qualify';
$user_info = UserManager::get_user_info_by_id(api_get_user_id());
$msg = '<p>'.get_lang('ExerciseAttempted').' :</p>
@ -3666,12 +3673,11 @@ class Exercise
</table>';
$open_question_list = null;
$msg = str_replace("#email#", $user_info['email'],$msg);
$msg1 = str_replace("#exercise#", $this->exercise, $msg);
$msg = str_replace("#firstName#", $user_info['firstname'],$msg1);
$msg1 = str_replace("#lastName#", $user_info['lastname'],$msg);
$msg = str_replace("#course#", $courseInfo['name'],$msg1);
$msg = str_replace("#email#", $user_info['email'], $msg);
$msg1 = str_replace("#exercise#", $this->exercise, $msg);
$msg = str_replace("#firstName#", $user_info['firstname'], $msg1);
$msg1 = str_replace("#lastName#", $user_info['lastname'], $msg);
$msg = str_replace("#course#", $courseInfo['name'], $msg1);
if ($origin != 'learnpath') {
$msg.= get_lang('ClickToCommentAndGiveFeedback').', <br />
@ -3681,32 +3687,35 @@ class Exercise
$mail_content = $msg1;
$subject = get_lang('ExerciseAttempted');
$teachers = array();
if (api_get_session_id()) {
$teachers = CourseManager::get_coach_list_from_course_code($coursecode, api_get_session_id());
if (!empty($sessionId)) {
$teachers = CourseManager::get_coach_list_from_course_code($courseCode, $sessionId);
} else {
$teachers = CourseManager::get_teacher_list_from_course_code($courseInfo['code']);
$teachers = CourseManager::get_teacher_list_from_course_code($courseCode);
}
if (!empty($teachers)) {
foreach ($teachers as $user_id => $teacher_data) {
MessageManager::send_message_simple($user_id, $subject, $mail_content);
MessageManager::send_message_simple(
$user_id,
$subject,
$mail_content
);
}
}
}
/**
* Sends a notification when a user ends an examn
*
*/
function send_notification_for_open_questions($question_list_answers, $origin, $exe_id) {
function send_notification_for_open_questions($question_list_answers, $origin, $exe_id)
{
if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) {
return null;
}
// Email configuration settings
$coursecode = api_get_course_id();
$course_info = api_get_course_info(api_get_course_id());
$courseCode = api_get_course_id();
$course_info = api_get_course_info($courseCode);
$url_email = api_get_path(WEB_CODE_PATH).'exercice/exercise_show.php?'.api_get_cidreq().'&id_session='.api_get_session_id().'&id='.$exe_id.'&action=qualify';
$user_info = UserManager::get_user_info_by_id(api_get_user_id());
@ -3770,33 +3779,36 @@ class Exercise
$mail_content = $msg1;
$subject = get_lang('OpenQuestionsAttempted');
$teachers = array();
if (api_get_session_id()) {
$teachers = CourseManager::get_coach_list_from_course_code($coursecode, api_get_session_id());
$teachers = CourseManager::get_coach_list_from_course_code($courseCode, api_get_session_id());
} else {
$teachers = CourseManager::get_teacher_list_from_course_code($coursecode);
$teachers = CourseManager::get_teacher_list_from_course_code($courseCode);
}
if (!empty($teachers)) {
foreach ($teachers as $user_id => $teacher_data) {
MessageManager::send_message_simple($user_id, $subject, $mail_content);
MessageManager::send_message_simple(
$user_id,
$subject,
$mail_content
);
}
}
}
}
function send_notification_for_oral_questions($question_list_answers, $origin, $exe_id) {
function send_notification_for_oral_questions($question_list_answers, $origin, $exe_id)
{
if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) {
return null;
}
// Email configuration settings
$coursecode = api_get_course_id();
$course_info = api_get_course_info(api_get_course_id());
$courseCode = api_get_course_id();
$course_info = api_get_course_info($courseCode);
$url_email = api_get_path(WEB_CODE_PATH).'exercice/exercise_show.php?'.api_get_cidreq().'&id_session='.api_get_session_id().'&id='.$exe_id.'&action=qualify';
$user_info = UserManager::get_user_info_by_id(api_get_user_id());
$oral_question_list = null;
foreach ($question_list_answers as $item) {
$question = $item['question'];
@ -3851,16 +3863,19 @@ class Exercise
$mail_content = $msg1;
$subject = get_lang('OralQuestionsAttempted');
$teachers = array();
if (api_get_session_id()) {
$teachers = CourseManager::get_coach_list_from_course_code($coursecode, api_get_session_id());
$teachers = CourseManager::get_coach_list_from_course_code($courseCode, api_get_session_id());
} else {
$teachers = CourseManager::get_teacher_list_from_course_code($coursecode);
$teachers = CourseManager::get_teacher_list_from_course_code($courseCode);
}
if (!empty($teachers)) {
foreach ($teachers as $user_id => $teacher_data) {
MessageManager::send_message_simple($user_id, $subject, $mail_content);
MessageManager::send_message_simple(
$user_id,
$subject,
$mail_content
);
}
}
}
@ -3954,7 +3969,8 @@ class Exercise
return $quiz_id;
}
function process_geometry() {
function process_geometry()
{
}
@ -3963,7 +3979,6 @@ class Exercise
* @param int attempt id
* @return float exercise result
*/
public function get_exercise_result($exe_id) {
$result = array();
$track_exercise_info = get_exercise_track_exercise_info($exe_id);
@ -4125,7 +4140,8 @@ class Exercise
public function added_in_lp()
{
$TBL_LP_ITEM = Database::get_course_table(TABLE_LP_ITEM);
$sql = "SELECT max_score FROM $TBL_LP_ITEM WHERE c_id = ".$this->course_id." AND item_type = '".TOOL_QUIZ."' AND path = '".$this->id."'";
$sql = "SELECT max_score FROM $TBL_LP_ITEM
WHERE c_id = ".$this->course_id." AND item_type = '".TOOL_QUIZ."' AND path = '".$this->id."'";
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
return true;
@ -4133,7 +4149,8 @@ class Exercise
return false;
}
function get_media_list() {
function get_media_list()
{
$media_questions = array();
$question_list = $this->get_validated_question_list();
if (!empty($question_list)) {
@ -4150,7 +4167,8 @@ class Exercise
return $media_questions;
}
function media_is_activated($media_list) {
function media_is_activated($media_list)
{
$active = false;
if (isset($media_list) && !empty($media_list)) {
$media_count = count($media_list);
@ -4167,7 +4185,8 @@ class Exercise
return $active;
}
function get_validated_question_list() {
function get_validated_question_list()
{
$tabres = array();
$isRandomByCategory = $this->isRandomByCat();
if ($isRandomByCategory == 0) {
@ -4221,13 +4240,15 @@ class Exercise
return $tabres;
}
function get_question_list($expand_media_questions = false) {
function get_question_list($expand_media_questions = false)
{
$question_list = $this->get_validated_question_list();
$question_list = $this->transform_question_list_with_medias($question_list, $expand_media_questions);
return $question_list;
}
function transform_question_list_with_medias($question_list, $expand_media_questions = false) {
function transform_question_list_with_medias($question_list, $expand_media_questions = false)
{
$new_question_list = array();
if (!empty($question_list)) {
$media_questions = $this->get_media_list();
@ -4268,7 +4289,8 @@ class Exercise
return $new_question_list;
}
public function get_stat_track_exercise_info_by_exe_id($exe_id) {
public function get_stat_track_exercise_info_by_exe_id($exe_id)
{
$track_exercises = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$exe_id = intval($exe_id);
$sql_track = "SELECT * FROM $track_exercises WHERE exe_id = $exe_id ";
@ -4298,7 +4320,8 @@ class Exercise
return $new_array;
}
public function edit_question_to_remind($exe_id, $question_id, $action = 'add') {
public function edit_question_to_remind($exe_id, $question_id, $action = 'add')
{
$exercise_info = self::get_stat_track_exercise_info_by_exe_id($exe_id);
$question_id = intval($question_id);
$exe_id = intval($exe_id);
@ -4340,18 +4363,20 @@ class Exercise
}
$remind_list_string = Database::escape_string($remind_list_string);
$sql = "UPDATE $track_exercises SET questions_to_check = '$remind_list_string' WHERE exe_id = $exe_id ";
$result = Database::query($sql);
Database::query($sql);
}
}
}
public function fill_in_blank_answer_to_array($answer) {
public function fill_in_blank_answer_to_array($answer)
{
api_preg_match_all('/\[[^]]+\]/', $answer, $teacher_answer_list);
$teacher_answer_list = $teacher_answer_list[0];
return $teacher_answer_list;
}
public function fill_in_blank_answer_to_string($answer) {
public function fill_in_blank_answer_to_string($answer)
{
$teacher_answer_list = $this->fill_in_blank_answer_to_array($answer);
$result = '';
if (!empty($teacher_answer_list)) {
@ -4372,13 +4397,15 @@ class Exercise
return $result;
}
function return_time_left_div() {
function return_time_left_div()
{
$html = '<div id="clock_warning" style="display:none">'.Display::return_message(get_lang('ReachedTimeLimit'), 'warning').' '.sprintf(get_lang('YouWillBeRedirectedInXSeconds'), '<span id="counter_to_redirect" class="red_alert"></span>').'</div>';
$html .= '<div id="exercise_clock_warning" class="well count_down"></div>';
return $html;
}
function get_count_question_list() {
function get_count_question_list()
{
//Real question count
$question_count = 0;
$question_list = $this->get_question_list();
@ -4388,7 +4415,8 @@ class Exercise
return $question_count;
}
function get_exercise_list_ordered() {
function get_exercise_list_ordered()
{
$table_exercise_order = Database::get_course_table(TABLE_QUIZ_ORDER);
$course_id = api_get_course_int_id();
$session_id = api_get_session_id();
@ -4403,7 +4431,6 @@ class Exercise
return $list;
}
/**
* Calculate the max_score of the quiz, depending of question inside, and quiz advanced option
*/
@ -4480,7 +4507,6 @@ class Exercise
return api_htmlentities($this->title);
}
/**
* @param $in_title
* @return string

@ -191,7 +191,7 @@ if (!$inATest) {
array(),
ICON_SIZE_SMALL
).'</a>';
$delete_link = null;
if ($objExercise->edit_exercise_in_lp == true) {
$delete_link = '<a id="delete_'.$id.'" class="opener" href="'.api_get_self().'?'.api_get_cidreq().'&exerciseId='.$exerciseId.'&deleteQuestion='.$id.'" >'.Display::return_icon('delete.png',get_lang('RemoveFromTest'), array(), ICON_SIZE_SMALL).'</a>';
}

@ -7,7 +7,7 @@ require_once api_get_path(LIBRARY_PATH).'add_course.lib.inc.php';
/**
* Class CourseManager
*
* This is the course library for Chamilo.
* This is the course library for Chamilo.
*
* All main course functions should be placed here.
*
@ -24,7 +24,8 @@ require_once api_get_path(LIBRARY_PATH).'add_course.lib.inc.php';
class CourseManager
{
const MAX_COURSE_LENGTH_CODE = 40;
/** This constant is used to show separate user names in the course list (userportal), footer, etc */
/** This constant is used to show separate user names in the course
* list (userportal), footer, etc */
const USER_SEPARATOR = ' |';
const COURSE_FIELD_TYPE_CHECKBOX = 10;
public $columns = array();
@ -136,6 +137,7 @@ class CourseManager
* Returns all the information of a given coursecode
* @param int the course id
* @return an array with all the fields of the course table
* @deprecated use api_get_course_info_by_id()
* @assert ('') === false
*/
public static function get_course_information_by_id($course_id)
@ -271,8 +273,9 @@ class CourseManager
/**
* Returns the status of a user in a course, which is COURSEMANAGER or STUDENT.
* @param int User ID
* @param string Course code
* @param int $user_id
* @param string $course_code
*
* @return int the status of the user in that course
*/
public static function get_user_in_course_status($user_id, $course_code)
@ -281,6 +284,7 @@ class CourseManager
"SELECT status FROM ".Database::get_main_table(TABLE_MAIN_COURSE_USER)."
WHERE course_code = '".Database::escape_string($course_code)."' AND user_id = ".Database::escape_string($user_id))
);
return $result['status'];
}
@ -295,6 +299,7 @@ class CourseManager
"SELECT tutor_id FROM ".Database::get_main_table(TABLE_MAIN_COURSE_USER)."
WHERE course_code = '".Database::escape_string($course_code)."' AND user_id = ".Database::escape_string($user_id))
);
return $result['tutor_id'];
}
@ -523,7 +528,8 @@ class CourseManager
}
// check if the user is registered in the session with other course
$sql = "SELECT id_user FROM ".Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER)." WHERE id_session='".$session_id."' AND id_user='$user_id'";
$sql = "SELECT id_user FROM ".Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER)."
WHERE id_session='".$session_id."' AND id_user='$user_id'";
$rs = Database::query($sql);
if (Database::num_rows($rs) == 0) {
// Check whether the user has not already been stored in the session_rel_user table
@ -588,13 +594,14 @@ class CourseManager
}
/**
* Get the course id based on the original id and field name in the extra fields. Returns 0 if course was not found
*
* @param string Original course id
* @param string Original field name
* @return int Course id
* @assert ('', '') === false
*/
* Get the course id based on the original id and field name in the
* extra fields. Returns 0 if course was not found
*
* @param string Original course id
* @param string Original field name
* @return int Course id
* @assert ('', '') === false
*/
public static function get_course_code_from_original_id($original_course_id_value, $original_course_id_name)
{
$t_cfv = Database::get_main_table(TABLE_MAIN_COURSE_FIELD_VALUES);
@ -719,8 +726,8 @@ class CourseManager
}
/**
* @return true if there already are one or more courses
* with the same code OR visual_code (visualcode), false otherwise
* @return true if there already are one or more courses
* with the same code OR visual_code (visualcode), false otherwise
*/
public static function course_code_exists($wanted_course_code)
{
@ -732,7 +739,7 @@ class CourseManager
}
/**
* @return an array with the course info of all real courses on the platform
* @return an array with the course info of all real courses on the platform
*/
public static function get_real_course_list() {
$sql_result = Database::query("SELECT * FROM ".Database::get_main_table(TABLE_MAIN_COURSE)."
@ -776,10 +783,13 @@ class CourseManager
WHERE course.target_course_code IS NULL
AND course_user.user_id = '$user_id'
AND course_user.status = '1'");
if ($sql_result === false) { return $result_array; }
if ($sql_result === false) {
return $result_array;
}
while ($result = Database::fetch_array($sql_result)) {
$result_array[] = $result;
}
return $result_array;
}
@ -818,6 +828,7 @@ class CourseManager
}
}
}
return $courseList;
}
@ -1635,17 +1646,18 @@ class CourseManager
*/
public static function get_coach_list_from_course_code($course_code, $session_id)
{
if ($session_id != strval(intval($session_id))) {
if (empty($course_code) OR empty($session_id)) {
return array();
}
$course_code = Database::escape_string($course_code);
$session_id = intval($session_id);
$users = array();
// We get the coach for the given course in a given session.
$rs = Database::query('SELECT id_user FROM '.Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER).
' WHERE id_session="'.$session_id.'" AND course_code="'.$course_code.'" AND status = 2');
$sql = 'SELECT id_user FROM '.Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER).
' WHERE id_session="'.$session_id.'" AND course_code="'.$course_code.'" AND status = 2';
$rs = Database::query($sql);
while ($user = Database::fetch_array($rs)) {
$user_info = api_get_user_info($user['id_user']);
$user_info['status'] = $user['status'];
@ -1655,8 +1667,10 @@ class CourseManager
$users[$user['id_user']] = $user_info;
}
$table = Database::get_main_table(TABLE_MAIN_SESSION);
// We get the session coach.
$rs = Database::query('SELECT id_coach FROM '.Database::get_main_table(TABLE_MAIN_SESSION).' WHERE id="'.$session_id.'"');
$sql = 'SELECT id_coach FROM '.$table.' WHERE id='.$session_id;
$rs = Database::query($sql);
$session_id_coach = Database::result($rs, 0, 'id_coach');
$user_info = api_get_user_info($session_id_coach);
$user_info['status'] = $user['status'];
@ -1669,15 +1683,15 @@ class CourseManager
}
/**
* Return user info array of all users registered in the specified real or virtual course
* This only returns the users that are registered in this actual course, not linked courses.
* Return user info array of all users registered in the specified real or virtual course
* This only returns the users that are registered in this actual course, not linked courses.
*
* @param string $course_code
* @param boolean $with_session
* @param integer $session_id
* @param date $date_from
* @param date $date_to
* @return array with user id
* @param string $course_code
* @param boolean $with_session
* @param integer $session_id
* @param date $date_from
* @param date $date_to
* @return array with user id
*/
public static function get_student_list_from_course_code(
$course_code,
@ -1730,6 +1744,7 @@ class CourseManager
$students[$student['id_user']] = $student;
}
}
return $students;
}

@ -4273,6 +4273,7 @@ class DocumentManager
try {
$ffmpeg = \FFMpeg\FFMpeg::create();
$video = $ffmpeg->open($wavFile);
$mp3File = str_replace('wav', 'mp3', $wavFile);
$result = $video->save(new FFMpeg\Format\Audio\Mp3(), $mp3File);
if ($result && $removeWavFileIfSuccess) {
@ -4283,6 +4284,8 @@ class DocumentManager
return $mp3File;
}
} catch (Exception $e) {
error_log($e->getMessage());
error_log($e->getPrevious()->getMessage());
}
}
return false;

@ -7553,10 +7553,10 @@ function api_get_configuration_value($variable)
}
/**
* Returns supported image extensions
* @return array Supported image extensions
* Returns supported image extensions in the portal
* @return array Supported image extensions in the portal
*/
function getSupportedImageExtensions()
function api_get_supported_image_extensions()
{
$supportedImageExtensions = array('jpg', 'jpeg', 'png', 'gif', 'svg');
if (version_compare(PHP_VERSION, '5.5.0', '>=')) {

@ -735,7 +735,7 @@ class SocialManager extends UserManager
$total_invitations = (!empty($total_invitations) ? Display::badge($total_invitations) : '');
$html = '';
$active = null;
if (!in_array($show, array('shared_profile', 'groups', 'group_edit', 'member_list', 'waiting_list', 'invite_friends'))) {
$html .= '<div class="well sidebar-nav"><ul class="nav nav-list">';
@ -1204,7 +1204,7 @@ class SocialManager extends UserManager
$safeFileName = Database::escape_string($fileAttach['name']);
$extension = strtolower(substr(strrchr($safeFileName, '.'), 1));
$allowedTypes = getSupportedImageExtensions();
$allowedTypes = api_get_supported_image_extensions();
if (!in_array($extension, $allowedTypes)) {
$flag = false;
} else {
@ -1413,7 +1413,15 @@ class SocialManager extends UserManager
return $data;
}
/**
* 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']);
@ -1493,7 +1501,7 @@ class SocialManager extends UserManager
* @param string $text Content text
* @return string $newText Content text with OpenGraph
*/
public function readContentWithOpenGraph($text)
public static function readContentWithOpenGraph($text)
{
// search link in first line
$regExUrl = "/(http|https)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/";
@ -1519,7 +1527,7 @@ class SocialManager extends UserManager
* @param $link url
* @return string data html
*/
public function getHtmlByLink($link)
public static function getHtmlByLink($link)
{
$graph = OpenGraph::fetch($link);
$title = $graph->title;

@ -8,7 +8,7 @@
* @package chamilo.library
*/
define ('EXERCISE_NUMBER_OF_DECIMALS', 2);
define('EXERCISE_NUMBER_OF_DECIMALS', 2);
/**
* This function strips all html-tags found in the input string and outputs a pure text.
@ -16,7 +16,8 @@ define ('EXERCISE_NUMBER_OF_DECIMALS', 2);
* @param string $string The input string with html-tags to be converted to plain text.
* @return string The returned plain text as a result.
*/
function api_html_to_text($string) {
function api_html_to_text($string)
{
// These purifications have been found experimentally, for nice looking output.
$string = preg_replace('/<br[^>]*>/i', "\n", $string);
$string = preg_replace('/<\/?(div|p|h[1-6]|table|ol|ul|blockquote)[^>]*>/i', "\n", $string);
@ -729,12 +730,13 @@ function implode_with_key($glue, $array) {
/**
* Transform the file size in a human readable format.
*
* @param int Size of the file in bytes
* @param int $file_size Size of the file in bytes
* @return string A human readable representation of the file size
*/
function format_file_size($file_size) {
function format_file_size($file_size)
{
$file_size = intval($file_size);
if($file_size >= 1073741824) {
if ($file_size >= 1073741824) {
$file_size = round($file_size / 1073741824 * 100) / 100 . 'G';
} elseif($file_size >= 1048576) {
$file_size = round($file_size / 1048576 * 100) / 100 . 'M';
@ -746,7 +748,8 @@ function format_file_size($file_size) {
return $file_size;
}
function return_datetime_from_array($array) {
function return_datetime_from_array($array)
{
$year = '0000';
$month = $day = $hours = $minutes = $seconds = '00';
if (isset($array['Y']) && (isset($array['F']) || isset($array['M'])) && isset($array['d']) && isset($array['H']) && isset($array['i'])) {
@ -782,4 +785,4 @@ function return_datetime_from_array($array) {
function bracketsToArray($array)
{
return preg_split('/[\[\]]+/', $array, -1, PREG_SPLIT_NO_EMPTY);
}
}

@ -13,7 +13,7 @@
* - send to specific user (when pressing send message in the who is online list)
*/
// name of the language file that needs to be included
$language_file= array('messages', 'userInfo', 'admin');
$language_file = array('messages', 'userInfo', 'admin');
$cidReset = true;
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php';
@ -242,8 +242,8 @@ function manage_form($default, $select_from_user_list = null, $sent_to = null) {
$file_comments = $_POST['legend'];
$title = $default['title'];
$content = $default['content'];
$group_id = $default['group_id'];
$parent_id = $default['parent_id'];
$group_id = isset($default['group_id']) ? $default['group_id'] : null;
$parent_id = isset($default['parent_id']) ? $default['parent_id'] : null;
if (is_array($user_list) && count($user_list)> 0) {
//all is well, send the message
foreach ($user_list as $user) {

@ -44,7 +44,7 @@ if (api_get_setting('profile', 'picture') == 'true') {
get_lang('DelImage')
);
}
$allowed_picture_types = getSupportedImageExtensions();
$allowed_picture_types = api_get_supported_image_extensions();
$form->addRule(
'picture',
get_lang('OnlyImagesAllowed') . ' (' . implode(
@ -109,9 +109,9 @@ $socialRightContent .= '
' . get_lang('EditProfile') . '
</a>
</div></div></div>';
$socialRightInformation = '<div class="span4">';
if (api_get_setting('allow_skills_tool') == 'true') {
$socialRightInformation .= '<div><div class="well_border">';
$socialRightInformation .= '<div class="well_border">';
$skill = new Skill();
$ranking = $skill->get_user_skill_ranking(api_get_user_id());
$url = api_get_path(WEB_CODE_PATH) . 'social/skills_ranking.php';
@ -147,12 +147,11 @@ if (api_get_setting('allow_skills_tool') == 'true') {
$socialRightInformation .= '</div>';
}
$socialRightInformation .= '</div>';
//Search box
$socialRightInformation .= '<div>';
$socialRightInformation .= UserManager::get_search_form('');
$socialRightInformation .= '<br />';
$socialRightInformation .= '<br /></div>';
//Group box by age
$results = GroupPortalManager::get_groups_by_age(1, false);

@ -384,7 +384,7 @@ foreach ($sessionList as $session) {
// My friends
$friend_html = listMyFriends($user_id, $link_shared ,$show_full_profile);
$social_left_content.= '<div class="well sidebar-nav">' .$friend_html . '</div>';
$social_left_content = '<div class="well sidebar-nav">' .$friend_html . '</div>';
$personal_info = null;
if (!empty($user_info['firstname']) || !empty($user_info['lastname'])) {
@ -425,8 +425,8 @@ if ($show_full_profile) {
$personal_info .= '</dl>';
}
$wallSocialAddPost .= wallSocialAddPost();
$social_right_content .= SocialManager::social_wrapper_div($wallSocialAddPost, 5);
$wallSocialAddPost = wallSocialAddPost();
$social_right_content = SocialManager::social_wrapper_div($wallSocialAddPost, 5);
$social_right_content .= wallSocialPost($my_user_id, $friendId);
$socialAutoExtendLink = Display::url(
@ -437,7 +437,7 @@ $socialAutoExtendLink = Display::url(
)
);
$socialRightInformation .= SocialManager::social_wrapper_div($personal_info, 4);
$socialRightInformation = SocialManager::social_wrapper_div($personal_info, 4);
//$social_right_content .= SocialManager::social_wrapper_div($wallSocial, 5);
@ -654,7 +654,7 @@ if ($show_full_profile) {
}
$sessions .= '<div><h3>'.api_ucfirst(get_lang('MySessions')).'</h3></div>';
$sessions = '<div><h3>'.api_ucfirst(get_lang('MySessions')).'</h3></div>';
$sessions .= "<div class='social-content-training'>$htmlSessionList</div>";
$socialRightInformation .= SocialManager::social_wrapper_div($sessions, 4);

@ -0,0 +1,77 @@
<?php
/**
* This script pre-generates a list of commits to generate a changelog in the
* form (branch, then commits in HTML form, then a final feedback):
*
* @example
* 1.9.x
* <li>(<a href="https://github.com/chamilo/chamilo-lms/commit/7333997ce358870bac139d15816dcaa7dd7794fa">7333997c</a> - <a href="https://task.beeznest.com/issues/8680">BT#8680</a>) Fixing custom lost password to work as classic Chamilo</li>
* ...
* <li>(<a href="https://github.com/chamilo/chamilo-lms/commit/acdc14c47997315b151efda9a530c47a53100d68">acdc14c4</a> - <a href="https://task.beeznest.com/issues/8676">BT#8676</a>) Adding unique email validation option</li>
* Printed 367 commits of 500 requested (others were minor)
*
* @author Yannick Warnier <yannick.warnier@beeznest.com>
*/
/**
* Includes a modified version of Git lib by Sebastian Bergmann of PHPUnit
* @see https://github.com/ywarnier/git
*/
require 'php-git/src/Git.php';
$repository = __DIR__.'/../..';
$number = 500; //the number of commits to check (including minor)
$formatHTML = true;
$git = new \SebastianBergmann\Git\Git($repository);
echo $git->getCurrentBranch().PHP_EOL;
$logs = $git->getRevisions('DESC', $number);
$i = 0;
foreach ($logs as $log) {
//echo $log['date']->format('Y-m-d H:i:s').' '.substr($log['sha1'],0,8).PHP_EOL;
if (strncasecmp($log['message'], 'Minor', 5) === 0) {
//Skip minor messages
continue;
}
$issueLink = '';
$matches = array();
if (preg_match_all('/((BT)?#(\d){2,5})/', $log['message'], $matches)) {
$issue = $matches[0][0];
if (substr($issue, 0, 1) == '#') {
// not a BeezNest task
$num = substr($issue, 1);
if ($formatHTML) {
$issueLink = ' - <a href="https://support.chamilo.org/issues/' . $num . '">#' . $num . '</a>';
} else {
$issueLink = ' - ' . $num;
}
} else {
$num = substr($issue, 3);
if ($formatHTML) {
$issueLink = ' - <a href="https://task.beeznest.com/issues/' . $num . '">BT#' . $num . '</a>';
} else {
$issueLink = ' - ' . $num;
}
}
if ($hasRefs = stripos($log['message'], ' see '.$issue)) {
$log['message'] = substr($log['message'], 0, $hasRefs);
}
if ($hasRefs = stripos($log['message'], ' - ref')) {
$log['message'] = substr($log['message'], 0, $hasRefs);
}
if ($hasRefs = stripos($log['message'], ' -refs ')) {
$log['message'] = substr($log['message'], 0, $hasRefs);
}
}
$commitLink = '';
if ($formatHTML) {
$commitLink = '<a href="https://github.com/chamilo/chamilo-lms/commit/' . $log['sha1'] . '">' .
substr($log['sha1'], 0, 8) . '</a>';
echo '<li>('.$commitLink.$issueLink.') '.$log['message'].'</li>'.PHP_EOL;
} else {
$commitLink = substr($log['sha1'], 0, 8);
echo '('.$commitLink.$issueLink.') '.$log['message'].''.PHP_EOL;
}
$i++;
}
echo "Printed $i commits of $number requested (others were minor)".PHP_EOL;
Loading…
Cancel
Save