From ade0a81e02dc237beac8b3699077c12139af7dfc Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Wed, 1 Jun 2016 14:04:58 +0200 Subject: [PATCH 01/12] Fix PHP warning (from chamilo-awx) --- main/inc/lib/usermanager.lib.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/main/inc/lib/usermanager.lib.php b/main/inc/lib/usermanager.lib.php index c4feeece00..cee9e630f7 100755 --- a/main/inc/lib/usermanager.lib.php +++ b/main/inc/lib/usermanager.lib.php @@ -3586,7 +3586,7 @@ class UserManager if (is_array($extraFields) && count($extraFields)>0 ) { foreach ($extraFields as $extraField) { $varName = 'field_'.$extraField['variable']; - if (UserManager::is_extra_field_available($extraField['variable'])) { + //if (UserManager::is_extra_field_available($extraField['variable'])) { if (isset($_GET[$varName]) && $_GET[$varName]!='0') { $useExtraFields = true; $extraFieldResult[]= UserManager::get_extra_user_data_by_value( @@ -3594,7 +3594,7 @@ class UserManager $_GET[$varName] ); } - } + //} } } @@ -3602,7 +3602,7 @@ class UserManager $finalResult = array(); if (count($extraFieldResult)>1) { for ($i=0; $i < count($extraFieldResult) -1; $i++) { - if (is_array($extraFieldResult[$i+1])) { + if (is_array($extraFieldResult[$i]) && is_array($extraFieldResult[$i+1])) { $finalResult = array_intersect($extraFieldResult[$i], $extraFieldResult[$i+1]); } } @@ -3626,7 +3626,7 @@ class UserManager * @param string $query the value of the search box * @return string HTML form */ - public static function get_search_form($query) + public static function get_search_form($query, $defaultParams = []) { $searchType = isset($_GET['search_type']) ? $_GET['search_type'] : null; $form = new FormValidator( @@ -3678,6 +3678,10 @@ class UserManager $defaults['search_type'] = intval($searchType); $defaults['q'] = api_htmlentities(Security::remove_XSS($query)); + + if (!empty($defaultParams)) { + $defaults = array_merge($defaults, $defaultParams); + } $form->setDefaults($defaults); $form->addButtonSearch(get_lang('Search')); @@ -4815,7 +4819,7 @@ EOF; /** * Subscribe boss to students - * + * * @param int $bossId The boss id * @param array $usersId The users array * @return int Affected rows From c0da860b7f59d5d89e0144d27ddfded2049e88d9 Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Thu, 2 Jun 2016 12:22:35 +0200 Subject: [PATCH 02/12] Fix PHP warning (from chamilo-awx) --- main/admin/add_users_to_usergroup.php | 2 +- main/inc/lib/usermanager.lib.php | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/main/admin/add_users_to_usergroup.php b/main/admin/add_users_to_usergroup.php index 22367ed007..4998fe451c 100755 --- a/main/admin/add_users_to_usergroup.php +++ b/main/admin/add_users_to_usergroup.php @@ -177,7 +177,7 @@ if ($use_extra_fields) { if (count($extra_field_result)>1) { for ($i=0; $i'value'); */ - public static function get_extra_user_data_by_value($field_variable, $field_value) + public static function get_extra_user_data_by_value($field_variable, $field_value, $all_visibility = true) { $extraField = new ExtraFieldValue('user'); - $data = $extraField->get_item_id_from_field_variable_and_field_value( + $data = $extraField->get_values_by_handler_and_field_variable( $field_variable, $field_value, - true + null, + true, + intval($all_visibility) ); $result = []; if (!empty($data)) { foreach ($data as $data) { - $result[] = $data; + $result[] = $data['item_id']; } } @@ -3586,7 +3590,7 @@ class UserManager if (is_array($extraFields) && count($extraFields)>0 ) { foreach ($extraFields as $extraField) { $varName = 'field_'.$extraField['variable']; - //if (UserManager::is_extra_field_available($extraField['variable'])) { + if (UserManager::is_extra_field_available($extraField['variable'])) { if (isset($_GET[$varName]) && $_GET[$varName]!='0') { $useExtraFields = true; $extraFieldResult[]= UserManager::get_extra_user_data_by_value( @@ -3594,7 +3598,7 @@ class UserManager $_GET[$varName] ); } - //} + } } } From 3a9dfa6cf4b949fb33f5216abe97c21c259da348 Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Thu, 2 Jun 2016 12:45:43 +0200 Subject: [PATCH 03/12] Fix fatal error #8274 --- main/coursecopy/classes/Resource.class.php | 53 +++++++++++++++------- 1 file changed, 37 insertions(+), 16 deletions(-) diff --git a/main/coursecopy/classes/Resource.class.php b/main/coursecopy/classes/Resource.class.php index d421d4e2d5..f91fc2f00f 100755 --- a/main/coursecopy/classes/Resource.class.php +++ b/main/coursecopy/classes/Resource.class.php @@ -233,28 +233,49 @@ class Resource } /** - * Fix objects coming from 1.9.x to 1.10.x + * Fix objects coming from 1.9.x to 1.10.x * Example class Event to CalendarEvent * * @param Resource $resource */ public static function setClassType(&$resource) { - if (get_class($resource) == 'Event') { - /** @var $resource CalendarEvent */ - $newResource = new CalendarEvent( - $resource->source_id, - $resource->title, - $resource->content, - $resource->start_date, - $resource->end_date, - $resource->attachment_path, - $resource->attachment_filename, - $resource->attachment_size, - $resource->attachment_comment, - $resource->all_day - ); - $resource = $newResource; + $class = get_class($resource); + switch ($class) { + case 'Event': + /** @var $resource \CalendarEvent */ + $newResource = new \CalendarEvent( + $resource->source_id, + $resource->title, + $resource->content, + $resource->start_date, + $resource->end_date, + $resource->attachment_path, + $resource->attachment_filename, + $resource->attachment_size, + $resource->attachment_comment, + $resource->all_day + ); + $resource = $newResource; + break; + case 'CourseDescription': + if (!method_exists($resource, 'show')) { + $resource = (array) $resource; + $newResource = new CourseDescription( + isset($resource['id']) ? $resource['id'] : '', + $resource['title'], + $resource['content'], + $resource['description_type'] + ); + $newResource->source_id = $resource['source_id']; + $newResource->destination_id = $resource['source_id']; + $newResource->linked_resources = $resource['source_id']; + $newResource->item_properties = $resource['source_id']; + $newResource->obj = $resource['obj']; + $resource = $newResource; + } + + break; } } } From 0328a9890d3fbff01b01c9abc6df97af30eec9bf Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Thu, 2 Jun 2016 12:47:15 +0200 Subject: [PATCH 04/12] Format code --- .../coursecopy/classes/Announcement.class.php | 98 +-- main/coursecopy/classes/Attendance.class.php | 26 +- .../classes/CourseDescription.class.php | 69 ++- .../classes/CourseSelectForm.class.php | 3 +- .../classes/CourseSession.class.php | 37 +- .../classes/DummyCourseCreator.class.php | 567 +++++++++--------- main/coursecopy/classes/Event.class.php | 2 +- main/coursecopy/classes/Forum.class.php | 5 +- .../classes/ForumCategory.class.php | 2 +- main/coursecopy/classes/ForumTopic.class.php | 4 +- main/coursecopy/classes/Glossary.class.php | 50 +- main/coursecopy/classes/Link.class.php | 73 ++- .../coursecopy/classes/LinkCategory.class.php | 66 +- main/coursecopy/classes/Quiz.class.php | 4 + .../classes/ScormDocument.class.php | 22 +- main/coursecopy/classes/Survey.class.php | 206 +++---- .../classes/SurveyInvitation.class.php | 92 +-- .../classes/SurveyQuestion.class.php | 175 +++--- main/coursecopy/classes/Thematic.class.php | 2 +- main/coursecopy/classes/ToolIntro.class.php | 150 ++--- main/coursecopy/classes/Work.class.php | 2 +- main/coursecopy/classes/wiki.class.php | 84 +-- 22 files changed, 879 insertions(+), 860 deletions(-) diff --git a/main/coursecopy/classes/Announcement.class.php b/main/coursecopy/classes/Announcement.class.php index aff329f442..67fab68a38 100755 --- a/main/coursecopy/classes/Announcement.class.php +++ b/main/coursecopy/classes/Announcement.class.php @@ -10,25 +10,25 @@ require_once 'Resource.class.php'; */ class Announcement extends Coursecopy\Resource { - /** - * The title of the announcement - */ + /** + * The title of the announcement + */ public $title; - /** - * The content of the announcement - */ + /** + * The content of the announcement + */ public $content; - /** - * The date on which this announcement was made - */ + /** + * The date on which this announcement was made + */ public $date; - /** - * The display order of this announcement - */ + /** + * The display order of this announcement + */ public $display_order; - /** - * Has the e-mail been sent? - */ + /** + * Has the e-mail been sent? + */ public $email_sent; public $attachment_path; @@ -39,36 +39,46 @@ class Announcement extends Coursecopy\Resource public $attachment_comment; - /** - * Create a new announcement - * @param int $id - * @param string $title - * @param string $content - * @param string $date - * @param int display_order - */ - function __construct($id, $title, $content, $date, $display_order, $email_sent, $path, $filename, $size, $comment) - { - parent::__construct($id,RESOURCE_ANNOUNCEMENT); + /** + * Create a new announcement + * @param int $id + * @param string $title + * @param string $content + * @param string $date + * @param int display_order + */ + public function __construct( + $id, + $title, + $content, + $date, + $display_order, + $email_sent, + $path, + $filename, + $size, + $comment + ) { + parent::__construct($id,RESOURCE_ANNOUNCEMENT); - $this->content = $content; - $this->title = $title; - $this->date = $date; - $this->display_order = $display_order; - $this->email_sent = $email_sent; + $this->content = $content; + $this->title = $title; + $this->date = $date; + $this->display_order = $display_order; + $this->email_sent = $email_sent; - $this->attachment_path = $path; - $this->attachment_filename = $filename; - $this->attachment_size = $size; - $this->attachment_comment = $comment; - } + $this->attachment_path = $path; + $this->attachment_filename = $filename; + $this->attachment_size = $size; + $this->attachment_comment = $comment; + } - /** - * Show this announcement - */ - function show() - { - parent::show(); - echo $this->date.': '.$this->title; - } + /** + * Show this announcement + */ + function show() + { + parent::show(); + echo $this->date.': '.$this->title; + } } diff --git a/main/coursecopy/classes/Attendance.class.php b/main/coursecopy/classes/Attendance.class.php index c4ee9584c5..51d33badc4 100755 --- a/main/coursecopy/classes/Attendance.class.php +++ b/main/coursecopy/classes/Attendance.class.php @@ -13,28 +13,28 @@ class Attendance extends Coursecopy\Resource public $params = array(); public $attendance_calendar = array(); - /** - * Create a new Thematic - * - * @param array parameters - */ + /** + * Create a new Thematic + * + * @param array parameters + */ public function __construct($params) { - parent::__construct($params['id'], RESOURCE_ATTENDANCE); - $this->params = $params; - } + parent::__construct($params['id'], RESOURCE_ATTENDANCE); + $this->params = $params; + } /** * @inheritdoc */ public function show() { - parent::show(); - echo $this->params['name']; - } + parent::show(); + echo $this->params['name']; + } public function add_attendance_calendar($data) { - $this->attendance_calendar[] = $data; - } + $this->attendance_calendar[] = $data; + } } diff --git a/main/coursecopy/classes/CourseDescription.class.php b/main/coursecopy/classes/CourseDescription.class.php index ca5e93d4aa..3d5a207192 100755 --- a/main/coursecopy/classes/CourseDescription.class.php +++ b/main/coursecopy/classes/CourseDescription.class.php @@ -1,6 +1,7 @@ title = $title; - $this->content = $content; - $this->description_type = $description_type; - } + /** + * Create a new course description + * @param int $id + * @param string $title + * @param string $content + */ + public function __construct($id, $title, $content, $description_type) + { + parent::__construct($id, RESOURCE_COURSEDESCRIPTION); + $this->title = $title; + $this->content = $content; + $this->description_type = $description_type; + } - /** - * Show this Event - */ - function show() - { - parent::show(); - echo $this->title; - } + /** + * Show this Event + */ + public function show() + { + parent::show(); + echo $this->title; + } } diff --git a/main/coursecopy/classes/CourseSelectForm.class.php b/main/coursecopy/classes/CourseSelectForm.class.php index f83d2a1795..a0827ff4bb 100755 --- a/main/coursecopy/classes/CourseSelectForm.class.php +++ b/main/coursecopy/classes/CourseSelectForm.class.php @@ -16,7 +16,7 @@ class CourseSelectForm * @param array $hidden_fields Hidden fields to add to the form. * @param boolean the document array will be serialize. This is used in the course_copy.php file */ - static function display_form($course, $hidden_fields = null, $avoid_serialize = false) + public static function display_form($course, $hidden_fields = null, $avoid_serialize = false) { global $charset; $resource_titles[RESOURCE_GRADEBOOK] = get_lang('Gradebook'); @@ -224,7 +224,6 @@ class CourseSelectForm foreach ($resources as $id => $resource) { if ($resource) { - // Event obj in 1.9.x in 1.10.x the class is CalendarEvent Coursecopy\Resource::setClassType($resource); echo '