From 2237e9ac6ecfff2053b31d5adc8a7c6f5ab009a1 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 9 Aug 2018 10:30:07 +0200 Subject: [PATCH] Minor - format code --- main/auth/inscription.php | 2 +- main/inc/lib/course.lib.php | 88 +++++++++---------- main/inc/lib/document.lib.php | 86 +++++++++--------- main/inc/lib/extra_field.lib.php | 4 +- main/inc/lib/usermanager.lib.php | 26 +++--- src/Chamilo/CoreBundle/Entity/ExtraField.php | 2 +- .../UserBundle/Repository/UserRepository.php | 2 +- 7 files changed, 105 insertions(+), 105 deletions(-) diff --git a/main/auth/inscription.php b/main/auth/inscription.php index 5ef0c794ec..dc7b435bbc 100755 --- a/main/auth/inscription.php +++ b/main/auth/inscription.php @@ -540,7 +540,7 @@ if (api_get_setting('allow_terms_conditions') === 'true' && $user_already_regist $values = $termExtraFields->getAllValuesByItem($term_preview['id']); foreach ($values as $value) { //if ($value['variable'] === 'category') { - $form->addLabel($value['display_text'], $value['value']); + $form->addLabel($value['display_text'], $value['value']); //} } diff --git a/main/inc/lib/course.lib.php b/main/inc/lib/course.lib.php index e8a0053313..36e66dc9bf 100755 --- a/main/inc/lib/course.lib.php +++ b/main/inc/lib/course.lib.php @@ -6675,6 +6675,50 @@ class CourseManager return api_get_path(WEB_COURSE_PATH).$course->getDirectory().'/course-pic85x85.png'; } + /** + * @return int + */ + public static function getCountOpenCourses() + { + $visibility = [ + COURSE_VISIBILITY_REGISTERED, + COURSE_VISIBILITY_OPEN_PLATFORM, + COURSE_VISIBILITY_OPEN_WORLD, + ]; + + $table = Database::get_main_table(TABLE_MAIN_COURSE); + $sql = "SELECT count(id) count + FROM $table + WHERE visibility IN (".implode(',', $visibility).")"; + $result = Database::query($sql); + $row = Database::fetch_array($result); + + return (int) $row['count']; + } + + /** + * @return int + */ + public static function getCountExercisesFromOpenCourse() + { + $visibility = [ + COURSE_VISIBILITY_REGISTERED, + COURSE_VISIBILITY_OPEN_PLATFORM, + COURSE_VISIBILITY_OPEN_WORLD, + ]; + + $table = Database::get_main_table(TABLE_MAIN_COURSE); + $tableExercise = Database::get_course_table(TABLE_QUIZ_TEST); + $sql = "SELECT count(e.iid) count + FROM $table c INNER JOIN $tableExercise e + ON (c.id = e.c_id) + WHERE e.active <> -1 AND visibility IN (".implode(',', $visibility).")"; + $result = Database::query($sql); + $row = Database::fetch_array($result); + + return (int) $row['count']; + } + /** * Check if a specific access-url-related setting is a problem or not. * @@ -6742,48 +6786,4 @@ class CourseManager $courseFieldValue = new ExtraFieldValue('course'); $courseFieldValue->saveFieldValues($params); } - - /** - * @return int - */ - public static function getCountOpenCourses() - { - $visibility = [ - COURSE_VISIBILITY_REGISTERED, - COURSE_VISIBILITY_OPEN_PLATFORM, - COURSE_VISIBILITY_OPEN_WORLD, - ]; - - $table = Database::get_main_table(TABLE_MAIN_COURSE); - $sql = "SELECT count(id) count - FROM $table - WHERE visibility IN (".implode(',', $visibility).")"; - $result = Database::query($sql); - $row = Database::fetch_array($result); - - return (int) $row['count']; - } - - /** - * @return int - */ - public static function getCountExercisesFromOpenCourse() - { - $visibility = [ - COURSE_VISIBILITY_REGISTERED, - COURSE_VISIBILITY_OPEN_PLATFORM, - COURSE_VISIBILITY_OPEN_WORLD, - ]; - - $table = Database::get_main_table(TABLE_MAIN_COURSE); - $tableExercise = Database::get_course_table(TABLE_QUIZ_TEST); - $sql = "SELECT count(e.iid) count - FROM $table c INNER JOIN $tableExercise e - ON (c.id = e.c_id) - WHERE e.active <> -1 AND visibility IN (".implode(',', $visibility).")"; - $result = Database::query($sql); - $row = Database::fetch_array($result); - - return (int) $row['count']; - } } diff --git a/main/inc/lib/document.lib.php b/main/inc/lib/document.lib.php index e8a1b5cb8e..66498ff559 100644 --- a/main/inc/lib/document.lib.php +++ b/main/inc/lib/document.lib.php @@ -6400,6 +6400,49 @@ class DocumentManager ]; } + /** + * @param int $userId + * + * @return array Example [ 0 => ['code' => 'ABC', 'directory' => 'ABC0', 'path' => '/images/gallery/test.png', 'code_path' => 'ABC:/images/gallery/test.png'], 1 => ...] + */ + public static function getAllDocumentsCreatedByUser($userId) + { + $tblItemProperty = Database::get_course_table(TABLE_ITEM_PROPERTY); + $tblDocument = Database::get_course_table(TABLE_DOCUMENT); + $tblCourse = Database::get_main_table(TABLE_MAIN_COURSE); + $userId = (int) $userId; + + $sql = "SELECT DISTINCT c.code, c.directory, docs.path + FROM $tblItemProperty AS last + INNER JOIN $tblDocument AS docs + ON ( + docs.id = last.ref AND + docs.c_id = last.c_id AND + docs.filetype <> 'folder' + ) + INNER JOIN $tblCourse as c + ON ( + docs.c_id = c.id + ) + WHERE + last.tool = '".TOOL_DOCUMENT."' AND + last.insert_user_id = $userId AND + docs.path NOT LIKE '%_DELETED_%' + ORDER BY c.directory, docs.path + "; + $result = Database::query($sql); + + $list = []; + if (Database::num_rows($result) != 0) { + while ($row = Database::fetch_array($result, 'ASSOC')) { + $row['code_path'] = $row['code'].':'.$row['path']; + $list[] = $row; + } + } + + return $list; + } + /** * Parse file information into a link. * @@ -6826,47 +6869,4 @@ class DocumentManager return $btn; } - - /** - * @param int $userId - * - * @return array Example [ 0 => ['code' => 'ABC', 'directory' => 'ABC0', 'path' => '/images/gallery/test.png', 'code_path' => 'ABC:/images/gallery/test.png'], 1 => ...] - */ - public static function getAllDocumentsCreatedByUser($userId) - { - $tblItemProperty = Database::get_course_table(TABLE_ITEM_PROPERTY); - $tblDocument = Database::get_course_table(TABLE_DOCUMENT); - $tblCourse = Database::get_main_table(TABLE_MAIN_COURSE); - $userId = (int) $userId; - - $sql = "SELECT DISTINCT c.code, c.directory, docs.path - FROM $tblItemProperty AS last - INNER JOIN $tblDocument AS docs - ON ( - docs.id = last.ref AND - docs.c_id = last.c_id AND - docs.filetype <> 'folder' - ) - INNER JOIN $tblCourse as c - ON ( - docs.c_id = c.id - ) - WHERE - last.tool = '".TOOL_DOCUMENT."' AND - last.insert_user_id = $userId AND - docs.path NOT LIKE '%_DELETED_%' - ORDER BY c.directory, docs.path - "; - $result = Database::query($sql); - - $list = []; - if (Database::num_rows($result) != 0) { - while ($row = Database::fetch_array($result, 'ASSOC')) { - $row['code_path'] = $row['code'].':'.$row['path']; - $list[] = $row; - } - } - - return $list; - } } diff --git a/main/inc/lib/extra_field.lib.php b/main/inc/lib/extra_field.lib.php index 8250c36ab9..857626156e 100755 --- a/main/inc/lib/extra_field.lib.php +++ b/main/inc/lib/extra_field.lib.php @@ -179,7 +179,7 @@ class ExtraField extends Model 'career', 'user_certificate', 'survey', - 'terms_and_condition' + 'terms_and_condition', ]; if (api_get_configuration_value('allow_scheduled_announcements')) { @@ -480,7 +480,7 @@ class ExtraField extends Model * @throws Exception * * @return array|bool If relevant, returns a one-element array with JS code to be added to the page HTML headers. - * Returns false if the form object was not given + * Returns false if the form object was not given */ public function addElements( $form, diff --git a/main/inc/lib/usermanager.lib.php b/main/inc/lib/usermanager.lib.php index 6021a75d64..f32827ff53 100755 --- a/main/inc/lib/usermanager.lib.php +++ b/main/inc/lib/usermanager.lib.php @@ -6311,6 +6311,19 @@ SQL; } } + /** + * @return int + */ + public static function getCountActiveUsers() + { + $table = Database::get_main_table(TABLE_MAIN_USER); + $sql = "SELECT count(id) count FROM $table WHERE active = 1 AND status <> ".ANONYMOUS; + $result = Database::query($sql); + $row = Database::fetch_array($result); + + return (int) $row['count']; + } + /** * @return EncoderFactory */ @@ -6408,17 +6421,4 @@ SQL; return $url; } - - /** - * @return int - */ - public static function getCountActiveUsers() - { - $table = Database::get_main_table(TABLE_MAIN_USER); - $sql = "SELECT count(id) count FROM $table WHERE active = 1 AND status <> ".ANONYMOUS; - $result = Database::query($sql); - $row = Database::fetch_array($result); - - return (int)$row['count']; - } } diff --git a/src/Chamilo/CoreBundle/Entity/ExtraField.php b/src/Chamilo/CoreBundle/Entity/ExtraField.php index eb01e48bbe..33c7d0b00e 100644 --- a/src/Chamilo/CoreBundle/Entity/ExtraField.php +++ b/src/Chamilo/CoreBundle/Entity/ExtraField.php @@ -30,7 +30,7 @@ class ExtraField extends BaseAttribute const USER_CERTIFICATE = 11; const SURVEY_FIELD_TYPE = 12; const SCHEDULED_ANNOUNCEMENT = 13; - const TERMS_AND_CONDITION_TYPE= 14; + const TERMS_AND_CONDITION_TYPE = 14; /** * @var int diff --git a/src/Chamilo/UserBundle/Repository/UserRepository.php b/src/Chamilo/UserBundle/Repository/UserRepository.php index 5f183e0bef..7b7267ff65 100644 --- a/src/Chamilo/UserBundle/Repository/UserRepository.php +++ b/src/Chamilo/UserBundle/Repository/UserRepository.php @@ -512,7 +512,7 @@ class UserRepository extends EntityRepository } $agenda = new \Agenda('personal'); - $events = $agenda->getEvents('', '', null, null, $userId, 'array'); + $events = $agenda->getEvents('', '', null, null, $userId, 'array'); $eventList = []; if (!empty($events)) { foreach ($events as $event) {