Minor - format code.

pull/2487/head
jmontoyaa 7 years ago
parent 7f127cf6a6
commit 1759ea517f
  1. 4
      main/attendance/attendance_controller.php
  2. 24
      main/exercise/export/scorm/scorm_classes.php
  3. 11
      main/gradebook/lib/be/category.class.php
  4. 22
      main/gradebook/lib/be/evaluation.class.php
  5. 6
      main/gradebook/lib/be/exerciselink.class.php
  6. 3
      main/gradebook/lib/be/learnpathlink.class.php
  7. 3
      main/gradebook/lib/be/studentpublicationlink.class.php
  8. 34
      main/gradebook/lib/fe/dataform.class.php
  9. 6
      main/gradebook/lib/fe/displaygradebook.php
  10. 72
      main/gradebook/lib/scoredisplay.class.php
  11. 82
      main/inc/lib/attendance.lib.php
  12. 8
      main/inc/lib/course_category.lib.php
  13. 1
      main/inc/lib/course_description.lib.php
  14. 32
      main/inc/lib/course_home.lib.php
  15. 59
      main/inc/lib/groupmanager.lib.php
  16. 7
      main/inc/lib/image.lib.php
  17. 5
      main/inc/lib/skill.lib.php
  18. 97
      main/inc/lib/social.lib.php
  19. 42
      main/lp/aicc.class.php
  20. 46
      main/lp/aicc_api.php
  21. 13
      main/lp/openoffice_text.class.php
  22. 1
      main/lp/openoffice_text_document.class.php
  23. 5
      src/Chamilo/CourseBundle/Component/CourseCopy/CourseBuilder.php
  24. 14
      src/Chamilo/CourseBundle/Component/CourseCopy/Resources/Thematic.php

@ -323,7 +323,7 @@ class AttendanceController
$data['next_attendance_calendar_id'] = $attendance->get_next_attendance_calendar_id(
$attendance_id
);
$data['next_attendance_calendar_datetime'] = $attendance->get_next_attendance_calendar_datetime(
$data['next_attendance_calendar_datetime'] = $attendance->getNextAttendanceCalendarDatetime(
$attendance_id
);
@ -357,7 +357,7 @@ class AttendanceController
$data['attendant_calendar_all'] = $attendance->get_attendance_calendar($attendance_id, 'all', null, $groupId);
$data['users_presence'] = $attendance->get_users_attendance_sheet($attendance_id, 0, $groupId);
$data['next_attendance_calendar_id'] = $attendance->get_next_attendance_calendar_id($attendance_id);
$data['next_attendance_calendar_datetime'] = $attendance->get_next_attendance_calendar_datetime($attendance_id);
$data['next_attendance_calendar_datetime'] = $attendance->getNextAttendanceCalendarDatetime($attendance_id);
} else {
$data['attendant_calendar_all'] = $attendance->get_attendance_calendar($attendance_id, 'all', null, $groupId);
$data['attendant_calendar'] = $attendance->get_attendance_calendar($attendance_id, $filter_type, null, $groupId);

@ -1127,18 +1127,18 @@ class ScormSection
list($js, $html) = $this->export_questions();
$res = $this->start_page()
. $this->start_header()
. $this->css()
. $this->globalAssets()
. $this->start_js()
. $this->common_js()
. $js
. $this->end_js()
. $this->end_header()
. $this->start_body()
. $html
. $this->end_body()
. $this->end_page();
.$this->start_header()
.$this->css()
.$this->globalAssets()
.$this->start_js()
.$this->common_js()
.$js
.$this->end_js()
.$this->end_header()
.$this->start_body()
.$html
.$this->end_body()
.$this->end_page();
return $res;
}

@ -1814,7 +1814,6 @@ class Category implements GradebookItem
// All students
// Course admin
if (api_is_allowed_to_edit() && !api_is_platform_admin()) {
// root
if ($this->id == 0) {
return $this->get_root_categories_for_teacher(
@ -1857,7 +1856,15 @@ class Category implements GradebookItem
} elseif (api_is_platform_admin()) {
// platform admin
// we explicitly avoid listing subcats from another session
return self::load(null, null, $course_code, $this->id, null, $session_id, $order);
return self::load(
null,
null,
$course_code,
$this->id,
null,
$session_id,
$order
);
}
}

@ -212,6 +212,8 @@ class Evaluation implements GradebookItem
* @param string $course_code course code
* @param int $category_id parent category
* @param integer $visible visible
*
* @return array
*/
public static function load(
$id = null,
@ -446,8 +448,8 @@ class Evaluation implements GradebookItem
*/
public function delete()
{
$tbl_grade_evaluations = Database::get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
$sql = 'DELETE FROM '.$tbl_grade_evaluations.'
$table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
$sql = 'DELETE FROM '.$table.'
WHERE id = '.intval($this->id);
Database::query($sql);
}
@ -759,14 +761,14 @@ class Evaluation implements GradebookItem
$table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
$sql = "SELECT user_id,lastname,firstname,username
FROM $tbl_user
WHERE
lastname LIKE '".Database::escape_string($first_letter_user)."%' AND
status = ".STUDENT." AND user_id NOT IN (
SELECT user_id FROM $table
WHERE evaluation_id = ".intval($this->id)."
)
ORDER BY lastname";
FROM $tbl_user
WHERE
lastname LIKE '".Database::escape_string($first_letter_user)."%' AND
status = ".STUDENT." AND user_id NOT IN (
SELECT user_id FROM $table
WHERE evaluation_id = ".intval($this->id)."
)
ORDER BY lastname";
$result = Database::query($sql);
$users = Database::store_result($result);

@ -193,9 +193,9 @@ class ExerciseLink extends AbstractLink
* Get the score of this exercise. Only the first attempts are taken into account.
* @param int $stud_id student id (default: all students who have results -
* then the average is returned)
* @return array (score, max) if student is given
* array (sum of scores, number of scores) otherwise
* or null if no scores available
* @return array (score, max) if student is given
* array (sum of scores, number of scores) otherwise
* or null if no scores available
*/
public function calc_score($stud_id = null, $type = null)
{

@ -156,7 +156,6 @@ class LearnpathLink extends AbstractLink
if ($rescount == 0) {
return null;
} else {
switch ($type) {
case 'best':
return array($bestResult, 100);
@ -247,8 +246,6 @@ class LearnpathLink extends AbstractLink
return false;
}
// INTERNAL FUNCTIONS
/**
* Lazy load function to get the database table of the learnpath
*/

@ -195,7 +195,7 @@ class StudentPublicationLink extends AbstractLink
$parentId = !$assignment ? 0 : $assignment->getId();
if (empty($session)) {
$dql = 'SELECT a FROM ChamiloCourseBundle:CStudentPublication a
$dql = 'SELECT a FROM ChamiloCourseBundle:CStudentPublication a
WHERE
a.cId = :course AND
a.active = :active AND
@ -209,7 +209,6 @@ class StudentPublicationLink extends AbstractLink
'parent' => $parentId,
'active' => true
];
} else {
$dql = 'SELECT a FROM ChamiloCourseBundle:CStudentPublication a
WHERE

@ -8,21 +8,27 @@
*/
class DataForm extends FormValidator
{
const TYPE_IMPORT = 1;
const TYPE_EXPORT = 2;
const TYPE_EXPORT_PDF = 3;
const TYPE_IMPORT = 1;
const TYPE_EXPORT = 2;
const TYPE_EXPORT_PDF = 3;
/**
* Builds a form containing form items based on a given parameter
* @param int form_type 1=import, 2=export
* @param obj cat_obj the category object
* @param obj res_obj the result object
* @param string form name
* @param method
* @param action
*/
public function __construct($form_type, $form_name, $method = 'post', $action = null, $target = '', $locked_status)
{
/**
* Builds a form containing form items based on a given parameter
* @param int form_type 1=import, 2=export
* @param obj cat_obj the category object
* @param obj res_obj the result object
* @param string form name
* @param method
* @param action
*/
public function __construct(
$form_type,
$form_name,
$method = 'post',
$action = null,
$target = '',
$locked_status
) {
parent:: __construct($form_name, $method, $action, $target);
$this->form_type = $form_type;
if ($this->form_type == self::TYPE_IMPORT) {

@ -335,8 +335,9 @@ class DisplayGradebook
}
if (!($is_course_admin &&
$message_resource === false &&
isset($_GET['selectcat']) && $_GET['selectcat'] != 0
) && isset($_GET['studentoverview'])) {
isset($_GET['selectcat']) && $_GET['selectcat'] != 0) &&
isset($_GET['studentoverview'])
) {
$header .= '<td style="vertical-align: top;"><a href="'.api_get_self().'?'.api_get_cidreq().'&studentoverview=&exportpdf=&selectcat='.$catobj->get_id().'" target="_blank">
'.Display::return_icon('pdf.png', get_lang('ExportPDF'), [], ICON_SIZE_MEDIUM).'
' . get_lang('ExportPDF').'</a>';
@ -349,7 +350,6 @@ class DisplayGradebook
$actionsLeft = '';
$my_api_cidreq = api_get_cidreq();
if (api_is_allowed_to_edit(null, true)) {
if (empty($grade_model_id) || $grade_model_id == -1) {
$actionsLeft .= '<a href="gradebook_add_cat.php?'.api_get_cidreq().'&selectcat='.$catobj->get_id().'">'.

@ -17,42 +17,6 @@ class ScoreDisplay
private $custom_display;
private $custom_display_conv;
/**
* Get the instance of this class
* @param int $category_id
* @return ScoreDisplay
*/
public static function instance($category_id = 0)
{
static $instance;
if (!isset($instance)) {
$instance = new ScoreDisplay($category_id);
}
return $instance;
}
/**
* Compare the custom display of 2 scores, can be useful in sorting
*/
public static function compare_scores_by_custom_display($score1, $score2)
{
if (!isset($score1)) {
return (isset($score2) ? 1 : 0);
} elseif (!isset($score2)) {
return -1;
} else {
$scoreDisplay = self::instance();
$custom1 = $scoreDisplay->display_custom($score1);
$custom2 = $scoreDisplay->display_custom($score2);
if ($custom1 == $custom2) {
return 0;
} else {
return (($score1[0] / $score1[1]) < ($score2[0] / $score2[1]) ? -1 : 1);
}
}
}
/**
* Protected constructor - call instance() to instantiate
*/
@ -121,6 +85,42 @@ class ScoreDisplay
}
}
/**
* Get the instance of this class
* @param int $category_id
* @return ScoreDisplay
*/
public static function instance($category_id = 0)
{
static $instance;
if (!isset($instance)) {
$instance = new ScoreDisplay($category_id);
}
return $instance;
}
/**
* Compare the custom display of 2 scores, can be useful in sorting
*/
public static function compare_scores_by_custom_display($score1, $score2)
{
if (!isset($score1)) {
return (isset($score2) ? 1 : 0);
} elseif (!isset($score2)) {
return -1;
} else {
$scoreDisplay = self::instance();
$custom1 = $scoreDisplay->display_custom($score1);
$custom2 = $scoreDisplay->display_custom($score2);
if ($custom1 == $custom2) {
return 0;
} else {
return (($score1[0] / $score1[1]) < ($score2[0] / $score2[1]) ? -1 : 1);
}
}
}
/**
* Is coloring enabled ?
*/

@ -246,10 +246,21 @@ class Attendance
}
$actions .= '</center>';
$attendances[] = array($attendance[0], $attendance[1], $attendance[2], $attendance[3], $actions);
$attendances[] = array(
$attendance[0],
$attendance[1],
$attendance[2],
$attendance[3],
$actions
);
} else {
$attendance[0] = '&nbsp;';
$attendances[] = array($attendance[0], $attendance[1], $attendance[2], $attendance[3]);
$attendances[] = array(
$attendance[0],
$attendance[1],
$attendance[2],
$attendance[3]
);
}
}
@ -609,14 +620,11 @@ class Attendance
$affected_rows = Database::affected_rows($result);
if ($affected_rows && $lock) {
// Save attendance sheet log
$lastedit_date = api_get_utc_datetime();
$lastedit_type = self::LOCKED_ATTENDANCE_LOG_TYPE;
$lastedit_user_id = api_get_user_id();
$this->save_attendance_sheet_log(
$this->saveAttendanceSheetLog(
$attendance_id,
$lastedit_date,
$lastedit_type,
$lastedit_user_id
api_get_utc_datetime(),
self::LOCKED_ATTENDANCE_LOG_TYPE,
api_get_user_id()
);
}
return $affected_rows;
@ -821,19 +829,16 @@ class Attendance
Database::query($sql);
// save users' results
$this->update_users_results($user_ids, $attendance_id);
$this->updateUsersResults($user_ids, $attendance_id);
if ($affected_rows) {
//save attendance sheet log
$lastedit_date = api_get_utc_datetime();
$lastedit_user_id = api_get_user_id();
$calendar_date_value = $calendar_data['date_time'];
$this->save_attendance_sheet_log(
$this->saveAttendanceSheetLog(
$attendance_id,
$lastedit_date,
api_get_utc_datetime(),
$lastedit_type,
$lastedit_user_id,
$calendar_date_value
api_get_user_id(),
$calendar_data['date_time']
);
}
@ -845,7 +850,7 @@ class Attendance
* @param array $user_ids registered users inside current course
* @param int $attendance_id
*/
public function update_users_results($user_ids, $attendance_id)
public function updateUsersResults($user_ids, $attendance_id)
{
$tbl_attendance_sheet = Database::get_course_table(TABLE_ATTENDANCE_SHEET);
$tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT);
@ -935,7 +940,7 @@ class Attendance
* @param string Calendar datetime value (optional, when event type is 'done_attendance_sheet')
* @return int Affected rows
*/
public function save_attendance_sheet_log(
public function saveAttendanceSheetLog(
$attendance_id,
$lastedit_date,
$lastedit_type,
@ -982,11 +987,11 @@ class Attendance
*/
public static function get_done_attendance_calendar($attendance_id)
{
$tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR);
$table = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR);
$attendance_id = intval($attendance_id);
$course_id = api_get_course_int_id();
$sql = "SELECT count(done_attendance) as count
FROM $tbl_attendance_calendar
FROM $table
WHERE
c_id = $course_id AND
attendance_id = '$attendance_id' AND
@ -1069,7 +1074,6 @@ class Attendance
{
// get all courses of current user
$courses = CourseManager::get_courses_list_by_user_id($user_id, true);
$user_id = intval($user_id);
$results = array();
$total_faults = $total_weight = $porcent = 0;
@ -1271,7 +1275,7 @@ class Attendance
* @param int attendance id
* @return int UNIX time format datetime
*/
public function get_next_attendance_calendar_datetime($attendance_id)
public function getNextAttendanceCalendarDatetime($attendance_id)
{
$table = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR);
$course_id = api_get_course_int_id();
@ -1631,20 +1635,20 @@ class Attendance
attendance_id = '$attendance_id'";
$rs = Database::query($sql);
if (Database::num_rows($rs) == 0) {*/
$params = array(
'c_id' => $course_id,
'date_time' => $this->date_time,
'attendance_id' => $attendance_id,
'done_attendance' => 0
);
$id = Database::insert($tbl_attendance_calendar, $params);
$params = array(
'c_id' => $course_id,
'date_time' => $this->date_time,
'attendance_id' => $attendance_id,
'done_attendance' => 0
);
$id = Database::insert($tbl_attendance_calendar, $params);
if ($id) {
$sql = "UPDATE $tbl_attendance_calendar SET id = iid WHERE iid = $id";
Database::query($sql);
$affected_rows++;
}
$this->addAttendanceCalendarToGroup($id, $course_id, $groupList);
if ($id) {
$sql = "UPDATE $tbl_attendance_calendar SET id = iid WHERE iid = $id";
Database::query($sql);
$affected_rows++;
}
$this->addAttendanceCalendarToGroup($id, $course_id, $groupList);
//}
// update locked attendance
@ -1661,6 +1665,8 @@ class Attendance
* @param int $calendarId
* @param int $courseId
* @param array $groupList
*
* @return bool
*/
public function addAttendanceCalendarToGroup($calendarId, $courseId, $groupList)
{
@ -1690,6 +1696,8 @@ class Attendance
Database::insert($table, $params);
}
}
return true;
}
/**
@ -1897,7 +1905,7 @@ class Attendance
}
// update users' results
$this->update_users_results($user_ids, $attendance_id);
$this->updateUsersResults($user_ids, $attendance_id);
return $affected_rows;
}

@ -813,8 +813,12 @@ class CourseCategory
* @param string $parentCode the parent category of the categories added (default=null for root category)
* @param string $padding the indent param (you shouldn't indicate something here)
*/
public static function setCategoriesInForm($element, $defaultCode = null, $parentCode = null, $padding = null)
{
public static function setCategoriesInForm(
$element,
$defaultCode = null,
$parentCode = null,
$padding = null
) {
$tbl_category = Database::get_main_table(TABLE_MAIN_CATEGORY);
$table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY);

@ -171,7 +171,6 @@ class CourseDescription
return $data;
}
/**
* Get maximum description type by session id,
* first you must set session_id properties with the object CourseDescription

@ -367,12 +367,13 @@ class CourseHome
$tool_name = self::translate_tool_name($tool);
$html .= Display::return_icon(
$tool['image'],
$tool_name,
array(),
null,
ICON_SIZE_MEDIUM
).'&nbsp;'.$tool_name.'</a>';
$tool['image'],
$tool_name,
array(),
null,
ICON_SIZE_MEDIUM
).'&nbsp;'.$tool_name.
'</a>';
// This part displays the links to hide or remove a tool.
// These links are only visible by the course manager.
@ -463,8 +464,11 @@ class CourseHome
* @param int $sessionId Optional
* @return array
*/
public static function get_tools_category($course_tool_category, $courseId = 0, $sessionId = 0)
{
public static function get_tools_category(
$course_tool_category,
$courseId = 0,
$sessionId = 0
) {
$course_tool_table = Database::get_course_table(TABLE_TOOL_LIST);
$is_platform_admin = api_is_platform_admin();
$all_tools_list = array();
@ -990,7 +994,10 @@ class CourseHome
}*/
// Validation when belongs to a session
$session_img = api_get_session_image($tool['session_id'], (!empty($_user['status']) ? $_user['status'] : ''));
$session_img = api_get_session_image(
$tool['session_id'],
!empty($_user['status']) ? $_user['status'] : ''
);
if ($studentview) {
$tool_link_params['href'] .= '&isStudentView=true';
}
@ -1004,9 +1011,7 @@ class CourseHome
$tool_link_params['href'],
$tool_link_params
);
$items[] = $item;
$i++;
} // end of foreach
}
@ -1071,7 +1076,7 @@ class CourseHome
/**
* Shows the general data for a particular meeting
*
* @param id session id
* @param int $id_session
* @return string session data
*/
public static function show_session_data($id_session)
@ -1180,9 +1185,7 @@ class CourseHome
{
$query = parse_url($link, PHP_URL_QUERY);
parse_str($query, $params);
$id = isset($params['id']) ? (int) $params['id'] : 0;
$em = Database::getManager();
/** @var CLpCategory $category */
$category = $em->find('ChamiloCourseBundle:CLpCategory', $id);
@ -1202,7 +1205,6 @@ class CourseHome
$sessionId = api_get_session_id();
if (!empty($course_id)) {
$course_tools_table = Database::get_course_table(TABLE_TOOL_LIST);
/* Link to the Course homepage */

@ -54,7 +54,7 @@ class GroupManager
const GROUP_TOOL_CHAT = 6;
/**
*
* GroupManager constructor.
*/
public function __construct()
{
@ -964,8 +964,10 @@ class GroupManager
* Returns the number of groups of the user with the greatest number of
* subscriptions in the given category
*/
public static function get_current_max_groups_per_user($category_id = null, $course_code = null)
{
public static function get_current_max_groups_per_user(
$category_id = null,
$course_code = null
) {
$course_info = api_get_course_info($course_code);
$group_table = Database::get_course_table(TABLE_GROUP);
$group_user_table = Database::get_course_table(TABLE_GROUP_USER);
@ -1295,7 +1297,11 @@ class GroupManager
//now sort by # of group left
$complete_user_list = TableSort::sort_table($complete_user_list, 'number_groups_left', SORT_DESC);
$complete_user_list = TableSort::sort_table(
$complete_user_list,
'number_groups_left',
SORT_DESC
);
$userToken = array();
foreach ($complete_user_list as $this_user) {
if ($this_user['number_groups_left'] > 0) {
@ -2238,32 +2244,45 @@ class GroupManager
if (count($tutorsids_of_group) > 0) {
foreach ($tutorsids_of_group as $tutor_id) {
$tutor = api_get_user_info($tutor_id);
$username = api_htmlentities(sprintf(get_lang('LoginX'), $tutor['username']), ENT_QUOTES);
$username = api_htmlentities(
sprintf(get_lang('LoginX'), $tutor['username']),
ENT_QUOTES
);
if (api_get_setting('show_email_addresses') === 'true') {
$tutor_info .= Display::tag(
'span',
Display::encrypted_mailto_link($tutor['mail'], api_get_person_name($tutor['firstName'], $tutor['lastName'])),
Display::encrypted_mailto_link(
$tutor['mail'],
$tutor['complete_name']
),
array('title'=>$username)
).', ';
} else {
if (api_is_allowed_to_edit()) {
$tutor_info .= Display::tag(
'span',
Display::encrypted_mailto_link($tutor['mail'], api_get_person_name($tutor['firstName'], $tutor['lastName'])),
Display::encrypted_mailto_link(
$tutor['mail'],
$tutor['complete_name']
),
array('title'=>$username)
).', ';
} else {
$tutor_info .= Display::tag(
'span',
api_get_person_name($tutor['firstName'], $tutor['lastName']),
array('title'=>$username)
$tutor['complete_name'],
array('title' => $username)
).', ';
}
}
}
}
$tutor_info = api_substr($tutor_info, 0, api_strlen($tutor_info) - 2);
$tutor_info = api_substr(
$tutor_info,
0,
api_strlen($tutor_info) - 2
);
$row[] = $tutor_info;
// Max number of members in group
@ -2366,8 +2385,10 @@ class GroupManager
* @param bool $deleteNotInArray
* @return array
*/
public static function importCategoriesAndGroupsFromArray($groupData, $deleteNotInArray = false)
{
public static function importCategoriesAndGroupsFromArray(
$groupData,
$deleteNotInArray = false
) {
$result = array();
$elementsFound = array(
'categories' => array(),
@ -2548,8 +2569,7 @@ class GroupManager
continue;
}
if (
!CourseManager::is_user_subscribed_in_course(
if (!CourseManager::is_user_subscribed_in_course(
$userInfo['user_id'],
$courseCode,
!empty($sessionId),
@ -2783,7 +2803,11 @@ class GroupManager
$content .= '<h2>'.$category['title'].'</h2>';
}
if (!empty($keyword)) {
$groups = self::getGroupListFilterByName($keyword, $category['id'], $courseId);
$groups = self::getGroupListFilterByName(
$keyword,
$category['id'],
$courseId
);
} else {
$groups = self::get_group_list($category['id']);
}
@ -2796,7 +2820,10 @@ class GroupManager
if (!empty($groups)) {
foreach ($groups as $group) {
$content .= '<li>';
$content .= Display::tag('h3', Security::remove_XSS($group['name']));
$content .= Display::tag(
'h3',
Security::remove_XSS($group['name'])
);
$users = self::getTutors($group);
if (!empty($users)) {
$content .= '<ul>';

@ -326,6 +326,11 @@ class ImagickWrapper extends ImageWrapper
class GDWrapper extends ImageWrapper
{
public $bg;
/**
* GDWrapper constructor.
* @param $path
*/
public function __construct($path)
{
parent::__construct($path);
@ -547,7 +552,7 @@ class GDWrapper extends ImageWrapper
/**
* Convert image to black & white
*/
function convert2bw()
public function convert2bw()
{
if (!$this->image_validated) {
return false;

@ -55,8 +55,9 @@ class SkillProfile extends Model
/**
* Call the save method of the parent class and the SkillRelProfile object
* @param array Params
* @param bool Whether to show the query in parent save() method
* @param array $params
* @param bool $show_query Whether to show the query in parent save() method
*
* @return mixed Profile ID or false if incomplete params
*/
public function save($params, $show_query = false)

@ -214,8 +214,12 @@ class SocialManager extends UserManager
* @author isaac flores paz
* @author Julio Montoya <gugli100@gmail.com> Cleaning code
*/
public static function send_invitation_friend($user_id, $friend_id, $message_title, $message_content)
{
public static function send_invitation_friend(
$user_id,
$friend_id,
$message_title,
$message_content
) {
$tbl_message = Database::get_main_table(TABLE_MESSAGE);
$user_id = intval($user_id);
$friend_id = intval($friend_id);
@ -701,12 +705,14 @@ class SocialManager extends UserManager
if ($my_course['access_start_date'] == '0000-00-00') {
$session['dates'] = get_lang('WithoutTimeLimits');
if (api_get_setting('show_session_coach') === 'true') {
$session['coach'] = get_lang('GeneralCoach').': '.api_get_person_name($sessioncoach['firstname'], $sessioncoach['lastname']);
$session['coach'] = get_lang('GeneralCoach').': '.
api_get_person_name($sessioncoach['firstname'], $sessioncoach['lastname']);
}
} else {
$session ['dates'] = ' - '.get_lang('From').' '.$my_course['access_start_date'].' '.get_lang('To').' '.$my_course['access_end_date'];
if (api_get_setting('show_session_coach') === 'true') {
$session['coach'] = get_lang('GeneralCoach').': '.api_get_person_name($sessioncoach['firstname'], $sessioncoach['lastname']);
$session['coach'] = get_lang('GeneralCoach').': '.
api_get_person_name($sessioncoach['firstname'], $sessioncoach['lastname']);
}
}
}
@ -1376,8 +1382,13 @@ class SocialManager extends UserManager
* @return boolean
* @author Yannick Warnier
*/
public static function sendWallMessage($userId, $friendId, $messageContent, $messageId = 0, $messageStatus = '')
{
public static function sendWallMessage(
$userId,
$friendId,
$messageContent,
$messageId = 0,
$messageStatus = ''
) {
$tblMessage = Database::get_main_table(TABLE_MESSAGE);
$userId = intval($userId);
$friendId = intval($friendId);
@ -1411,8 +1422,12 @@ class SocialManager extends UserManager
* @param string $fileComment description attachment file
* @return bool
*/
public static function sendWallMessageAttachmentFile($userId, $fileAttach, $messageId, $fileComment = '')
{
public static function sendWallMessageAttachmentFile(
$userId,
$fileAttach,
$messageId,
$fileComment = ''
) {
$tbl_message_attach = Database::get_main_table(TABLE_MESSAGE_ATTACHMENT);
// create directory
@ -1472,8 +1487,14 @@ class SocialManager extends UserManager
* @return array
* @author Yannick Warnier
*/
public static function getWallMessages($userId, $messageStatus, $parentId = '', $start = null, $limit = 10, $offset = 0)
{
public static function getWallMessages(
$userId,
$messageStatus,
$parentId = '',
$start = null,
$limit = 10,
$offset = 0
) {
if (empty($start)) {
$start = '0000-00-00';
}
@ -1530,14 +1551,27 @@ class SocialManager extends UserManager
* @param int $offset Wall messages offset
* @return string HTML formatted string to show messages
*/
public static function getWallMessagesHTML($userId, $friendId, $idMessage, $start = null, $limit = 10, $offset = 0)
{
public static function getWallMessagesHTML(
$userId,
$friendId,
$idMessage,
$start = null,
$limit = 10,
$offset = 0
) {
if (empty($start)) {
$start = '0000-00-00';
}
$isOwnWall = (api_get_user_id() == $userId && $userId == $friendId);
$messages = self::getWallMessages($userId, MESSAGE_STATUS_WALL, $idMessage, $start, $limit, $offset);
$messages = self::getWallMessages(
$userId,
MESSAGE_STATUS_WALL,
$idMessage,
$start,
$limit,
$offset
);
$formattedList = '<div class="sub-mediapost">';
$users = array();
@ -1607,13 +1641,25 @@ class SocialManager extends UserManager
* @param int $offset Wall messages offset
* @return array $data return user's starting wall messages along with message extra data
*/
public static function getWallMessagesPostHTML($userId, $friendId = 0, $start = null, $limit = 10, $offset = 0)
{
public static function getWallMessagesPostHTML(
$userId,
$friendId = 0,
$start = null,
$limit = 10,
$offset = 0
) {
if (empty($start)) {
$start = '0000-00-00';
}
$isOwnWall = (api_get_user_id() == $userId && $userId == $friendId);
$messages = self::getWallMessages($userId, MESSAGE_STATUS_WALL_POST, null, $start, $limit, $offset);
$isOwnWall = api_get_user_id() == $userId && $userId == $friendId;
$messages = self::getWallMessages(
$userId,
MESSAGE_STATUS_WALL_POST,
null,
$start,
$limit,
$offset
);
$users = array();
$data = array();
foreach ($messages as $key => $message) {
@ -1893,8 +1939,9 @@ class SocialManager extends UserManager
$friendHtml .= '<ul class="nav nav-list">';
$j = 1;
for ($k = 0; $k < $number_friends; $k++) {
if ($j > $number_of_images) break;
if ($j > $number_of_images) {
break;
}
if (isset($friends[$k])) {
$friend = $friends[$k];
$name_user = api_get_person_name($friend['firstName'], $friend['lastName']);
@ -1910,7 +1957,10 @@ class SocialManager extends UserManager
$friendHtml .= '<div>';
// the height = 92 must be the same in the image_friend_network span style in default.css
$friends_profile = UserManager::getUserPicture($friend['friend_user_id'], USER_IMAGE_SIZE_SMALL);
$friends_profile = UserManager::getUserPicture(
$friend['friend_user_id'],
USER_IMAGE_SIZE_SMALL
);
$friendHtml .= '<img src="'.$friends_profile.'" id="imgfriend_'.$friend['friend_user_id'].'" title="'.$name_user.'"/>';
$link_shared = (empty($link_shared)) ? '' : '&'.$link_shared;
$friendHtml .= $statusIcon.'<a href="profile.php?'.'u='.$friend['friend_user_id'].$link_shared.'">'.$name_user.'</a>';
@ -2031,7 +2081,12 @@ class SocialManager extends UserManager
]
);
$form->addHidden('url_content', '');
$form->addButtonSend(get_lang('Post'), 'wall_post_button', false, ['cols-size' => [1, 10, 1]]);
$form->addButtonSend(
get_lang('Post'),
'wall_post_button',
false,
['cols-size' => [1, 10, 1]]
);
$html = Display::panel($form->returnForm(), get_lang('SocialWall'));
return $html;

@ -77,7 +77,7 @@ class aicc extends learnpath
* If not defined, uses the base path of the course's scorm dir
* @return array Structured array representing the config files' contents
*/
function parse_config_files($dir = '')
public function parse_config_files($dir = '')
{
if ($this->debug > 0) {error_log('New LP - In aicc::parse_config_files('.$dir.')', 0); }
if (empty($dir)) {
@ -472,8 +472,7 @@ class aicc extends learnpath
}
}
if ($package_type == '' || !$mandatory)
{
if ($package_type == '' || !$mandatory) {
Display::addFlash(
Display::return_message(get_lang('FileError'))
);
@ -506,7 +505,9 @@ class aicc extends learnpath
- parse & change relative html links
- make sure the filenames are secure (filter funny characters or php extensions)
*/
if (is_dir($course_sys_dir.$new_dir) OR @mkdir($course_sys_dir.$new_dir, api_get_permissions_for_new_directories())) {
if (is_dir($course_sys_dir.$new_dir) ||
@mkdir($course_sys_dir.$new_dir, api_get_permissions_for_new_directories())
) {
// PHP method - slower...
if ($this->debug >= 1) { error_log('New LP - Changing dir to '.$course_sys_dir.$new_dir, 0); }
$saved_dir = getcwd();
@ -581,7 +582,7 @@ class aicc extends learnpath
* @param string $proxy Proximity setting
* @return bool
*/
function set_proximity($proxy = '')
public function set_proximity($proxy = '')
{
$course_id = api_get_course_int_id();
if ($this->debug > 0) { error_log('In aicc::set_proximity('.$proxy.') method', 0); }
@ -601,7 +602,7 @@ class aicc extends learnpath
* @param string Theme setting
* @return bool
*/
function set_theme($theme = '')
public function set_theme($theme = '')
{
$course_id = api_get_course_int_id();
if ($this->debug > 0) { error_log('In aicc::set_theme('.$theme.') method', 0); }
@ -621,14 +622,15 @@ class aicc extends learnpath
* @param string $preview_image Theme setting
* @return bool
*/
function set_preview_image($preview_image = '')
public function set_preview_image($preview_image = '')
{
$course_id = api_get_course_int_id();
if ($this->debug > 0) {error_log('In aicc::set_preview_image('.$preview_image.') method', 0); }
$lp = $this->get_id();
if ($lp != 0) {
$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
$sql = "UPDATE $tbl_lp SET preview_image = '$preview_image' WHERE c_id = ".$course_id." id = ".$lp;
$sql = "UPDATE $tbl_lp SET preview_image = '$preview_image'
WHERE c_id = ".$course_id." id = ".$lp;
Database::query($sql);
return true;
} else {
@ -641,7 +643,7 @@ class aicc extends learnpath
* @param string $author
* @return true
*/
function set_author($author = '')
public function set_author($author = '')
{
$course_id = api_get_course_int_id();
if ($this->debug > 0) { error_log('In aicc::set_author('.$author.') method', 0); }
@ -662,7 +664,7 @@ class aicc extends learnpath
* @param string $maker
* @return bool
*/
function set_maker($maker = '')
public function set_maker($maker = '')
{
$course_id = api_get_course_int_id();
if ($this->debug > 0) { error_log('In aicc::set_maker method('.$maker.')', 0); }
@ -683,7 +685,7 @@ class aicc extends learnpath
* @param integer Learnpath ID (optional, taken from object context if not defined)
* @return bool
*/
function export_zip($lp_id = null)
public function export_zip($lp_id = null)
{
if ($this->debug > 0) { error_log('In aicc::export_zip method('.$lp_id.')', 0); }
if (empty($lp_id)) {
@ -717,18 +719,14 @@ class aicc extends learnpath
$zipfilename = $zipfoldername.'/'.$LPnamesafe.'.zip';
// Get a temporary dir for creating the zip file.
//error_log('New LP - cleaning dir '.$zipfoldername, 0);
removeDir($zipfoldername); //make sure the temp dir is cleared
mkdir($zipfoldername, api_get_permissions_for_new_directories());
//error_log('New LP - made dir '.$zipfoldername, 0);
// Create zipfile of given directory.
$zip_folder = new PclZip($zipfilename);
$zip_folder->create($scormfoldername.'/', PCLZIP_OPT_REMOVE_PATH, $scormfoldername.'/');
//this file sending implies removing the default mime-type from php.ini
//DocumentManager::file_send_for_download($zipfilename, true, $LPnamesafe.".zip");
DocumentManager::file_send_for_download($zipfilename, true);
// Delete the temporary zip file and directory in fileManage.lib.php
@ -743,7 +741,7 @@ class aicc extends learnpath
* @param string Resource ID as used in resource array
* @return string The resource's path as declared in config file course.crs
*/
function get_res_path($id)
public function get_res_path($id)
{
if ($this->debug > 0) { error_log('In aicc::get_res_path('.$id.') method', 0); }
$path = '';
@ -759,7 +757,7 @@ class aicc extends learnpath
* @param string Resource ID as used in resource array
* @return string The resource's type as declared in the assignable unit (.au) file
*/
function get_res_type($id)
public function get_res_type($id)
{
if ($this->debug > 0) { error_log('In aicc::get_res_type('.$id.') method', 0); }
$type = '';
@ -777,7 +775,7 @@ class aicc extends learnpath
* Gets the default organisation's title
* @return string The organization's title
*/
function get_title()
public function get_title()
{
if ($this->debug > 0) { error_log('In aicc::get_title() method', 0); }
$title = '';
@ -798,7 +796,7 @@ class aicc extends learnpath
* updating the existing table... This will prove very useful in case initial data
* from config files were not imported well enough.
*/
function reimport_aicc()
public function reimport_aicc()
{
if ($this->debug > 0) { error_log('In aicc::reimport_aicc() method', 0); }
//query current items list
@ -815,7 +813,7 @@ class aicc extends learnpath
* @param string File path
* @return array Structured array
*/
function parse_ini_file_quotes_safe($f)
public function parse_ini_file_quotes_safe($f)
{
$null = '';
$r = $null;
@ -868,7 +866,7 @@ class aicc extends learnpath
* as containing only hard string data (no variables), provided in lower case
* @return array Structured array
*/
function parse_ini_string_quotes_safe($s, $pure_strings = array())
public function parse_ini_string_quotes_safe($s, $pure_strings = array())
{
$null = '';
$r = $null;
@ -932,7 +930,7 @@ class aicc extends learnpath
* @param boolean Might one field name happen more than once on the same line? (then split by comma in the values)
* @return array Simple structured array
*/
function parse_csv_file($f, $delim = ',', $enclosure = '"', $multiples = false)
public function parse_csv_file($f, $delim = ',', $enclosure = '"', $multiples = false)
{
$data = @file_get_contents($f);
$data = api_convert_encoding($data, api_get_system_encoding(), $this->config_encoding);

@ -141,10 +141,10 @@ function LMSGetValue(param) {
}else if(param == 'cmi.core.student_id'){
result='<?php echo $_user['user_id']; ?>';
}else if(param == 'cmi.core.student_name'){
<?php
$who = addslashes(api_get_person_name($_user['firstName'], $_user['lastName']));
echo "result='$who';";
?>
<?php
$who = addslashes(api_get_person_name($_user['firstName'], $_user['lastName']));
echo "result='$who';";
?>
}else if(param == 'cmi.core.lesson_location'){
result=lesson_location;
}else if(param == 'cmi.core.total_time'){
@ -173,19 +173,19 @@ function LMSGetValue(param) {
/*
// Switch not working??? WTF???
switch(param) {
case 'cmi.core._children' :
case 'cmi.core._children':
result='entry, exit, lesson_status, student_id, student_name, lesson_location, total_time, credit, lesson_mode, score, session_time';
break;
case 'cmi.core_children' :
case 'cmi.core_children':
result='entry, exit, lesson_status, student_id, student_name, lesson_location, total_time, credit, lesson_mode, score, session_time';
break;
case 'cmi.core.entry' :
case 'cmi.core.entry':
result='';
break;
case 'cmi.core.exit' :
case 'cmi.core.exit':
result='';
break;
case 'cmi.core.lesson_status' :
case 'cmi.core.lesson_status':
if(lesson_status != '') {
result=lesson_status;
}
@ -193,51 +193,51 @@ function LMSGetValue(param) {
result='not attempted';
}
break;
case 'cmi.core.student_id' :
case 'cmi.core.student_id':
result='<?php echo $_user['user_id']; ?>';
break;
case 'cmi.core.student_name' :
case 'cmi.core.student_name':
<?php
$who = addslashes(api_get_person_name($_user['firstName'], $_user['lastName']));
echo "result='$who';";
?> break;
case 'cmi.core.lesson_location' :
case 'cmi.core.lesson_location':
result='';
break;
case 'cmi.core.total_time' :
case 'cmi.core.total_time':
result=total_time;
break;
case 'cmi.core.score._children' :
case 'cmi.core.score._children':
result='raw,min,max';
break;
case 'cmi.core.score.raw' :
case 'cmi.core.score.raw':
result=score;
break;
case 'cmi.core.score.max' :
case 'cmi.core.score.max':
result=max;
break;
case 'cmi.core.score.min' :
case 'cmi.core.score.min':
result=min;
break;
case 'cmi.core.score' :
case 'cmi.core.score':
result=score;
break;
case 'cmi.core.credit' :
case 'cmi.core.credit':
result='no-credit';
break;
case 'cmi.core.lesson_mode' :
case 'cmi.core.lesson_mode':
result='normal';
break;
case 'cmi.suspend_data' :
case 'cmi.suspend_data':
result='<?php echo $oItem->get_suspend_data(); ?>';
break;
case 'cmi.launch_data' :
case 'cmi.launch_data':
result='';
break;
case 'cmi.objectives._count':
result='<?php echo $oItem->get_view_count(); ?>';
break;
default :
default:
result='';
break;
}

@ -78,7 +78,9 @@ class OpenofficeText extends OpenofficeDocument
// Chamilo styles.
$my_style = api_get_setting('stylesheets');
if (empty($my_style)) { $my_style = 'chamilo'; }
if (empty($my_style)) {
$my_style = 'chamilo';
}
$style_to_import = "<style type=\"text/css\">\r\n";
$style_to_import .= '@import "'.api_get_path(WEB_CODE_PATH).'css/'.$my_style.'/default.css";'."\n";
$style_to_import .= "</style>\r\n";
@ -128,9 +130,9 @@ class OpenofficeText extends OpenofficeDocument
$items_to_create[get_lang('Introduction')] = $intro_content;
for ($i = 0; $i < count($matches[0]); $i++) {
if (empty($matches[1][$i]))
if (empty($matches[1][$i])) {
continue;
}
$content = strstr($content, $matches[0][$i]);
if ($i + 1 !== count($matches[0])) {
@ -254,7 +256,7 @@ class OpenofficeText extends OpenofficeDocument
//echo Display::return_message(print_r($_POST));
$di = new ChamiloIndexer();
isset($_POST['language']) ? $lang = Database::escape_string($_POST['language']) : $lang = 'english';
$di->connectDb(NULL, NULL, $lang);
$di->connectDb(null, null, $lang);
$ic_slide = new IndexableChunk();
$ic_slide->addValue('title', $slide_name);
$specific_fields = get_specific_field_list();
@ -317,7 +319,8 @@ class OpenofficeText extends OpenofficeDocument
* @param string Page content
* @return string Formatted page content
*/
public function format_page_content($header, $content) {
public function format_page_content($header, $content)
{
// Limit the width of the doc.
list($max_width, $max_height) = explode('x', api_get_setting('service_ppt2lp', 'size'));

@ -363,6 +363,5 @@ class OpenOfficeTextDocument extends OpenofficeDocument
*/
public function add_docs_to_visio()
{
}
}

@ -1461,7 +1461,7 @@ class CourseBuilder
$result = Database::query($sql);
while ($sub_row = Database::fetch_array($result, 'ASSOC')) {
$thematic->add_thematic_advance($sub_row);
$thematic->addThematicAdvance($sub_row);
}
$items = api_get_item_property_by_tool(
@ -1474,7 +1474,6 @@ class CourseBuilder
if (!empty($items)) {
foreach ($items as $item) {
$thematic_plan_id_list[] = $item['ref'];
//$thematic_plan_complete_list[$item['ref']] = $item;
}
}
if (count($thematic_plan_id_list) > 0) {
@ -1489,7 +1488,7 @@ class CourseBuilder
$result = Database::query($sql);
while ($sub_row = Database::fetch_array($result, 'ASSOC')) {
$thematic->add_thematic_plan($sub_row);
$thematic->addThematicPlan($sub_row);
}
}
$this->course->add_resource($thematic);

@ -12,8 +12,8 @@ class Thematic extends Resource
{
public $params = array();
public $thematic_advance_list = array();
public $thematic_plan_list = array();
public $thematic_plan_list = array();
/**
* Create a new Thematic
*
@ -31,12 +31,18 @@ class Thematic extends Resource
echo $this->params['title'];
}
public function add_thematic_advance($data)
/**
* @param array $data
*/
public function addThematicAdvance($data)
{
$this->thematic_advance_list[] = $data;
}
public function add_thematic_plan($data)
/**
* @param array $data
*/
public function addThematicPlan($data)
{
$this->thematic_plan_list[] = $data;
}

Loading…
Cancel
Save