@@ -41,11 +41,9 @@ class Rest extends WebService
4141 const GET_MESSAGE_USERS = 'message_users ' ;
4242 const SAVE_COURSE_NOTEBOOK = 'save_course_notebook ' ;
4343 const SAVE_FORUM_THREAD = 'save_forum_thread ' ;
44-
4544 const SAVE_COURSE = 'save_course ' ;
4645 const SAVE_USER = 'save_user ' ;
4746 const SUBSCRIBE_USER_TO_COURSE = 'subscribe_user_to_course ' ;
48-
4947 const EXTRAFIELD_GCM_ID = 'gcm_registration_id ' ;
5048
5149 /**
@@ -84,8 +82,7 @@ public function setCourse($id)
8482 /** @var Course $course */
8583 $ course = $ em ->find ('ChamiloCoreBundle:Course ' , $ id );
8684
87- if (!$ course )
88- {
85+ if (!$ course ) {
8986 throw new Exception (get_lang ('NoCourse ' ));
9087 }
9188
@@ -283,7 +280,6 @@ public function getCourseDocuments($directoryId = 0)
283280 {
284281 /** @var string $path */
285282 $ path = '/ ' ;
286-
287283 $ sessionId = $ this ->session ? $ this ->session ->getId () : 0 ;
288284
289285 if ($ directoryId ) {
@@ -353,7 +349,6 @@ public function getCourseDocuments($directoryId = 0)
353349 }
354350
355351 /**
356- * @param int $courseId
357352 * @return array
358353 * @throws Exception
359354 */
@@ -376,14 +371,17 @@ public function getCourseAnnouncements()
376371 $ sessionId
377372 );
378373
379- $ announcements = array_map (function ($ announcement ) {
380- return [
381- 'id ' => intval ($ announcement ['id ' ]),
382- 'title ' => strip_tags ($ announcement ['title ' ]),
383- 'creatorName ' => strip_tags ($ announcement ['username ' ]),
384- 'date ' => strip_tags ($ announcement ['insert_date ' ])
385- ];
386- }, $ announcements );
374+ $ announcements = array_map (
375+ function ($ announcement ) {
376+ return [
377+ 'id ' => intval ($ announcement ['id ' ]),
378+ 'title ' => strip_tags ($ announcement ['title ' ]),
379+ 'creatorName ' => strip_tags ($ announcement ['username ' ]),
380+ 'date ' => strip_tags ($ announcement ['insert_date ' ]),
381+ ];
382+ },
383+ $ announcements
384+ );
387385
388386 return $ announcements ;
389387 }
@@ -410,7 +408,10 @@ public function getCourseAnnouncement($announcementId)
410408 'id ' => intval ($ announcement ['announcement ' ]->getIid ()),
411409 'title ' => $ announcement ['announcement ' ]->getTitle (),
412410 'creatorName ' => $ announcement ['item_property ' ]->getInsertUser ()->getCompleteName (),
413- 'date ' => api_convert_and_format_date ($ announcement ['item_property ' ]->getInsertDate (), DATE_TIME_FORMAT_LONG_24H ),
411+ 'date ' => api_convert_and_format_date (
412+ $ announcement ['item_property ' ]->getInsertDate (),
413+ DATE_TIME_FORMAT_LONG_24H
414+ ),
414415 'content ' => AnnouncementManager::parse_content (
415416 $ this ->user ->getId (),
416417 $ announcement ['announcement ' ]->getContent (),
@@ -462,7 +463,7 @@ public function getCourseAgenda()
462463 $ webPath = api_get_path (WEB_PATH );
463464
464465 return array_map (
465- function ($ event ) use ($ webPath ) {
466+ function ($ event ) use ($ webPath ) {
466467 return [
467468 'id ' => intval ($ event ['unique_id ' ]),
468469 'title ' => $ event ['title ' ],
@@ -551,7 +552,7 @@ public function getCourseForumCategories()
551552 foreach ($ categoriesFullData as $ category ) {
552553 $ categoryForums = array_filter (
553554 $ forums ,
554- function (array $ forum ) use ($ category ) {
555+ function (array $ forum ) use ($ category ) {
555556 if ($ forum ['catId ' ] != $ category ['cat_id ' ]) {
556557 return false ;
557558 }
@@ -635,7 +636,6 @@ public function getCourseForumThread($forumId, $threadId)
635636 ];
636637
637638 $ forumInfo = get_forums ($ threadInfo ['forum_id ' ], $ this ->course ->getCode (), true , $ sessionId );
638-
639639 $ postsInfo = getPosts ($ forumInfo , $ threadInfo ['iid ' ], 'ASC ' );
640640
641641 foreach ($ postsInfo as $ postInfo ) {
@@ -736,12 +736,12 @@ public function getCourseLearnPaths()
736736
737737 $ timeLimits = false ;
738738
739- //This is an old LP (from a migration 1.8.7) so we do nothing
739+ // This is an old LP (from a migration 1.8.7) so we do nothing
740740 if (empty ($ lpDetails ['created_on ' ]) && empty ($ lpDetails ['modified_on ' ])) {
741741 $ timeLimits = false ;
742742 }
743743
744- //Checking if expired_on is ON
744+ // Checking if expired_on is ON
745745 if (!empty ($ lpDetails ['expired_on ' ])) {
746746 $ timeLimits = true ;
747747 }
@@ -806,7 +806,6 @@ private function encodeParams(array $additionalParams = [])
806806 ]);
807807
808808 $ strParams = serialize ($ params );
809-
810809 $ b64Encoded = base64_encode ($ strParams );
811810
812811 return str_replace (['+ ' , '/ ' , '= ' ], ['- ' , '_ ' , '. ' ], $ b64Encoded );
@@ -816,7 +815,8 @@ private function encodeParams(array $additionalParams = [])
816815 * @param string $encoded
817816 * @return array
818817 */
819- public static function decodeParams ($ encoded ) {
818+ public static function decodeParams ($ encoded )
819+ {
820820 $ decoded = str_replace (['- ' , '_ ' , '. ' ], ['+ ' , '/ ' , '= ' ], $ encoded );
821821 $ mod4 = strlen ($ decoded ) % 4 ;
822822
@@ -838,7 +838,6 @@ public function showLearningPath($lpId)
838838 $ loggedUser ['user_id ' ] = $ this ->user ->getId ();
839839 $ loggedUser ['status ' ] = $ this ->user ->getStatus ();
840840 $ loggedUser ['uidReset ' ] = true ;
841-
842841 $ sessionId = $ this ->session ? $ this ->session ->getId () : 0 ;
843842
844843 ChamiloSession::write ('_user ' , $ loggedUser );
@@ -869,7 +868,6 @@ public function saveForumPost(array $postValues, $forumId)
869868 require_once api_get_path (SYS_CODE_PATH ).'forum/forumfunction.inc.php ' ;
870869
871870 $ forum = get_forums ($ forumId , $ this ->course ->getCode ());
872-
873871 store_reply ($ forum , $ postValues , $ this ->course ->getId (), $ this ->user ->getId ());
874872
875873 return [
@@ -954,8 +952,7 @@ public function saveUserMessage($subject, $text, array $receivers)
954952 public function getMessageUsers ($ search )
955953 {
956954 /** @var UserRepository $repo */
957- $ repo = Database::getManager ()
958- ->getRepository ('ChamiloUserBundle:User ' );
955+ $ repo = Database::getManager ()->getRepository ('ChamiloUserBundle:User ' );
959956
960957 $ users = $ repo ->findUsersToSendMessage ($ this ->user ->getId (), $ search );
961958
@@ -982,7 +979,7 @@ public function getMessageUsers($search)
982979 /**
983980 * @param string $title
984981 * @param string $text
985- * @return bool
982+ * @return array
986983 */
987984 public function saveCourseNotebook ($ title , $ text )
988985 {
@@ -1013,7 +1010,6 @@ public function saveForumThread(array $values, $forumId)
10131010 $ sessionId = $ this ->session ? $ this ->session ->getId () : 0 ;
10141011 $ forum = get_forums ($ forumId , $ this ->course ->getCode (), true , $ sessionId );
10151012 $ courseInfo = api_get_course_info ($ this ->course ->getCode ());
1016-
10171013 $ id = store_thread ($ forum , $ values , $ courseInfo , false , $ this ->user ->getId (), $ sessionId );
10181014
10191015 return [
@@ -1027,7 +1023,6 @@ public function saveForumThread(array $values, $forumId)
10271023 */
10281024 public function saveNewCourse ($ course_param )
10291025 {
1030-
10311026 $ table_course = Database::get_main_table (TABLE_MAIN_COURSE );
10321027 $ extra_list = array ();
10331028
@@ -1039,7 +1034,7 @@ public function saveNewCourse($course_param)
10391034 $ language = isset ($ course_param ['language ' ]) ? $ course_param ['language ' ] : null ;
10401035 $ original_course_id = isset ($ course_param ['original_course_id ' ]) ? $ course_param ['original_course_id ' ] : null ;
10411036 $ diskQuota = isset ($ course_param ['disk_quota ' ]) ? $ course_param ['disk_quota ' ] : '100 ' ;
1042- $ visibility = isset ($ course_param ['visibility ' ]) ? $ course_param ['visibility ' ] : null ;;
1037+ $ visibility = isset ($ course_param ['visibility ' ]) ? $ course_param ['visibility ' ] : null ;
10431038
10441039 if (isset ($ course_param ['visibility ' ])) {
10451040 if ($ course_param ['visibility ' ] &&
@@ -1157,13 +1152,13 @@ public function saveNewCourse($course_param)
11571152 }
11581153
11591154 /**
1155+ * @param $user_param
1156+ * @return array
11601157 */
11611158 public function saveNewUser ($ user_param )
11621159 {
1163- global $ _user ;
11641160 $ results = array ();
11651161 $ orig_user_id_value = array ();
1166-
11671162 $ userManager = UserManager::getManager ();
11681163 $ userRepository = UserManager::getRepository ();
11691164
@@ -1201,12 +1196,6 @@ public function saveNewUser($user_param)
12011196 $ language = api_get_setting ('platformLanguage ' );
12021197 }
12031198
1204- if (!empty ($ _user ['user_id ' ])) {
1205- $ creator_id = $ _user ['user_id ' ];
1206- } else {
1207- $ creator_id = '' ;
1208- }
1209-
12101199 // First check wether the login already exists.
12111200 if (!UserManager::is_username_available ($ loginName )) {
12121201 $ results [] = 0 ;
@@ -1282,28 +1271,26 @@ public function saveNewUser($user_param)
12821271 $ results [] = 0 ;
12831272 }
12841273
1285- // $results[] = $userId;
12861274 return $ results ;
12871275 }
12881276
12891277 /**
12901278 * Subscribe User to Course
1279+ * @param array $params
1280+ * @return array
12911281 */
12921282 public function subscribeUserToCourse ($ params )
12931283 {
12941284 $ course_id = $ params ['course_id ' ];
12951285 $ course_code = $ params ['course_code ' ];
12961286 $ user_id = $ params ['user_id ' ];
1297- if (!$ course_id && !$ course_code )
1298- {
1287+ if (!$ course_id && !$ course_code ) {
12991288 return [false ];
13001289 }
1301- if (!$ course_code )
1302- {
1290+ if (!$ course_code ) {
13031291 $ course_code = CourseManager::get_course_code_from_course_id ($ course_id );
13041292 }
1305- if (CourseManager::subscribe_user ($ user_id , $ course_code ))
1306- {
1293+ if (CourseManager::subscribe_user ($ user_id , $ course_code )) {
13071294 return [true ];
13081295 } else {
13091296 return [false ];
0 commit comments