Completed
Push — 1.10.x ( 7c88bc...8998f9 )
by
unknown
49:14
created
main/inc/lib/usermanager.lib.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
     const USER_FIELD_TYPE_TIMEZONE = 11;
35 35
     const USER_FIELD_TYPE_SOCIAL_PROFILE = 12;
36 36
     const USER_FIELD_TYPE_FILE = 13;
37
-    const USER_FIELD_TYPE_MOBILE_PHONE_NUMBER  = 14;
37
+    const USER_FIELD_TYPE_MOBILE_PHONE_NUMBER = 14;
38 38
 
39 39
     private static $encryptionMethod;
40 40
 
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
         }
281 281
 
282 282
         if (empty($password)) {
283
-            Display::addFlash(Display::return_message(get_lang('ThisFieldIsRequired').': '.get_lang('Password') , 'warning'));
283
+            Display::addFlash(Display::return_message(get_lang('ThisFieldIsRequired').': '.get_lang('Password'), 'warning'));
284 284
 
285 285
             return false;
286 286
         }
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
         $res = Database::query($sql);
495 495
         while ($course = Database::fetch_object($res)) {
496 496
             $sql = "SELECT id FROM $table_course_user
497
-                    WHERE status=1 AND c_id = " . intval($course->c_id);
497
+                    WHERE status=1 AND c_id = ".intval($course->c_id);
498 498
             $res2 = Database::query($sql);
499 499
             if (Database::num_rows($res2) == 1) {
500 500
 
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
         $sql = "UPDATE $table_user SET active = 1 WHERE id IN ($ids)";
759 759
         $r = Database::query($sql);
760 760
         if ($r !== false) {
761
-            Event::addEvent(LOG_USER_ENABLE,LOG_USER_ID,$ids);
761
+            Event::addEvent(LOG_USER_ENABLE, LOG_USER_ID, $ids);
762 762
         }
763 763
         return $r;
764 764
     }
@@ -1164,7 +1164,7 @@  discard block
 block discarded – undo
1164 1164
             // 1. Conversion of unacceptable letters (latinian letters with accents for example) into ASCII letters in order they not to be totally removed.
1165 1165
             // 2. Applying the strict purifier.
1166 1166
             // 3. Length limitation.
1167
-            $return  = api_get_setting('login_is_email') == 'true' ? substr(preg_replace(USERNAME_PURIFIER_MAIL, '', $username), 0, USERNAME_MAX_LENGTH) : substr(preg_replace(USERNAME_PURIFIER, '', $username), 0, USERNAME_MAX_LENGTH);
1167
+            $return = api_get_setting('login_is_email') == 'true' ? substr(preg_replace(USERNAME_PURIFIER_MAIL, '', $username), 0, USERNAME_MAX_LENGTH) : substr(preg_replace(USERNAME_PURIFIER, '', $username), 0, USERNAME_MAX_LENGTH);
1168 1168
             $return = URLify::transliterate($return);
1169 1169
             return $return;
1170 1170
         }
@@ -1256,12 +1256,12 @@  discard block
 block discarded – undo
1256 1256
 
1257 1257
         if (!is_null($order)) {
1258 1258
             $order = Database::escape_string($order);
1259
-            $sql .= ' ORDER BY ' . $order;
1259
+            $sql .= ' ORDER BY '.$order;
1260 1260
         }
1261 1261
 
1262 1262
         if (!is_null($limit)) {
1263 1263
             $limit = Database::escape_string($limit);
1264
-            $sql .= ' LIMIT ' . $limit;
1264
+            $sql .= ' LIMIT '.$limit;
1265 1265
         }
1266 1266
 
1267 1267
         $rs = Database::query($sql);
@@ -1443,7 +1443,7 @@  discard block
 block discarded – undo
1443 1443
             // In exceptional cases, on some portals, the intermediate base user
1444 1444
             // directory might not have been created. Make sure it is before
1445 1445
             // going further.
1446
-            $rootPath = api_get_path(SYS_UPLOAD_PATH) . 'users/' . substr((string) $id, 0, 1);
1446
+            $rootPath = api_get_path(SYS_UPLOAD_PATH).'users/'.substr((string) $id, 0, 1);
1447 1447
             if (!is_dir($rootPath)) {
1448 1448
                 $perm = api_get_permissions_for_new_directories();
1449 1449
                 try {
@@ -1695,7 +1695,7 @@  discard block
 block discarded – undo
1695 1695
         $path_info = self::get_user_picture_path_by_id($user_id, 'system');
1696 1696
         $path = $path_info['dir'];
1697 1697
         if (!empty($extra_field)) {
1698
-            $path .= $extra_field . '/';
1698
+            $path .= $extra_field.'/';
1699 1699
         }
1700 1700
         // If this directory does not exist - we create it.
1701 1701
         if (!file_exists($path)) {
@@ -1703,7 +1703,7 @@  discard block
 block discarded – undo
1703 1703
         }
1704 1704
 
1705 1705
         if (filter_extension($file)) {
1706
-            if (@move_uploaded_file($source_file,$path.$file)) {
1706
+            if (@move_uploaded_file($source_file, $path.$file)) {
1707 1707
                 if ($extra_field) {
1708 1708
                     return $extra_field.'/'.$file;
1709 1709
                 } else {
@@ -1956,10 +1956,10 @@  discard block
 block discarded – undo
1956 1956
         if (count($extra_files) > 0) {
1957 1957
             $extra_file_list = '<div class="files-production"><ul id="productions">';
1958 1958
             foreach ($extra_files as $file) {
1959
-                $filename = substr($file,strlen($extra_field)+1);
1959
+                $filename = substr($file, strlen($extra_field) + 1);
1960 1960
                 $extra_file_list .= '<li>'.Display::return_icon('archive.png').'<a href="'.$path.$extra_field.'/'.urlencode($filename).'" target="_blank">'.htmlentities($filename).'</a> ';
1961 1961
                 if ($showdelete) {
1962
-                    $extra_file_list .= '<input style="width:16px;" type="image" name="remove_extra_' . $extra_field . '['.urlencode($file).']" src="'.$del_image.'" alt="'.$del_text.'" title="'.$del_text.' '.htmlentities($filename).'" onclick="javascript: return confirmation(\''.htmlentities($filename).'\');" /></li>';
1962
+                    $extra_file_list .= '<input style="width:16px;" type="image" name="remove_extra_'.$extra_field.'['.urlencode($file).']" src="'.$del_image.'" alt="'.$del_text.'" title="'.$del_text.' '.htmlentities($filename).'" onclick="javascript: return confirmation(\''.htmlentities($filename).'\');" /></li>';
1963 1963
                 }
1964 1964
             }
1965 1965
             $extra_file_list .= '</ul></div>';
@@ -2544,7 +2544,7 @@  discard block
 block discarded – undo
2544 2544
 
2545 2545
         if (api_is_allowed_to_create_course()) {
2546 2546
             $sessionListFromCourseCoach = array();
2547
-            $sql =" SELECT DISTINCT session_id
2547
+            $sql = " SELECT DISTINCT session_id
2548 2548
                     FROM $tbl_session_course_user
2549 2549
                     WHERE user_id = $user_id AND status = 2 ";
2550 2550
 
@@ -2552,7 +2552,7 @@  discard block
 block discarded – undo
2552 2552
             if (Database::num_rows($result)) {
2553 2553
                 $result = Database::store_result($result);
2554 2554
                 foreach ($result as $session) {
2555
-                    $sessionListFromCourseCoach[]= $session['session_id'];
2555
+                    $sessionListFromCourseCoach[] = $session['session_id'];
2556 2556
                 }
2557 2557
             }
2558 2558
             if (!empty($sessionListFromCourseCoach)) {
@@ -2575,7 +2575,7 @@  discard block
 block discarded – undo
2575 2575
                 ORDER BY access_start_date, access_end_date, name";
2576 2576
 
2577 2577
         $result = Database::query($sql);
2578
-        if (Database::num_rows($result)>0) {
2578
+        if (Database::num_rows($result) > 0) {
2579 2579
             while ($row = Database::fetch_assoc($result)) {
2580 2580
                 $sessions[$row['id']] = $row;
2581 2581
             }
@@ -2591,7 +2591,7 @@  discard block
 block discarded – undo
2591 2591
                 ORDER BY access_start_date, access_end_date, name";
2592 2592
 
2593 2593
         $result = Database::query($sql);
2594
-        if (Database::num_rows($result)>0) {
2594
+        if (Database::num_rows($result) > 0) {
2595 2595
             while ($row = Database::fetch_assoc($result)) {
2596 2596
                 if (empty($sessions[$row['id']])) {
2597 2597
                     $sessions[$row['id']] = $row;
@@ -3583,13 +3583,13 @@  discard block
 block discarded – undo
3583 3583
         $useExtraFields = false;
3584 3584
         $extraFields = UserManager::get_extra_filtrable_fields();
3585 3585
         $extraFieldResult = array();
3586
-        if (is_array($extraFields) && count($extraFields)>0 ) {
3586
+        if (is_array($extraFields) && count($extraFields) > 0) {
3587 3587
             foreach ($extraFields as $extraField) {
3588 3588
                 $varName = 'field_'.$extraField['variable'];
3589 3589
                 //if (UserManager::is_extra_field_available($extraField['variable'])) {
3590
-                    if (isset($_GET[$varName]) && $_GET[$varName]!='0') {
3590
+                    if (isset($_GET[$varName]) && $_GET[$varName] != '0') {
3591 3591
                         $useExtraFields = true;
3592
-                        $extraFieldResult[]= UserManager::get_extra_user_data_by_value(
3592
+                        $extraFieldResult[] = UserManager::get_extra_user_data_by_value(
3593 3593
                             $extraField['variable'],
3594 3594
                             $_GET[$varName]
3595 3595
                         );
@@ -3600,17 +3600,17 @@  discard block
 block discarded – undo
3600 3600
 
3601 3601
         if ($useExtraFields) {
3602 3602
             $finalResult = array();
3603
-            if (count($extraFieldResult)>1) {
3604
-                for ($i=0; $i < count($extraFieldResult) -1; $i++) {
3605
-                if (is_array($extraFieldResult[$i]) && is_array($extraFieldResult[$i+1])) {
3606
-                        $finalResult  = array_intersect($extraFieldResult[$i], $extraFieldResult[$i+1]);
3603
+            if (count($extraFieldResult) > 1) {
3604
+                for ($i = 0; $i < count($extraFieldResult) - 1; $i++) {
3605
+                if (is_array($extraFieldResult[$i]) && is_array($extraFieldResult[$i + 1])) {
3606
+                        $finalResult = array_intersect($extraFieldResult[$i], $extraFieldResult[$i + 1]);
3607 3607
                     }
3608 3608
                 }
3609 3609
             } else {
3610 3610
                 $finalResult = $extraFieldResult[0];
3611 3611
             }
3612 3612
 
3613
-            if (is_array($finalResult) && count($finalResult)>0) {
3613
+            if (is_array($finalResult) && count($finalResult) > 0) {
3614 3614
                 $whereFilter = " AND u.id IN  ('".implode("','", $finalResult)."') ";
3615 3615
             } else {
3616 3616
                 //no results
@@ -3787,7 +3787,7 @@  discard block
 block discarded – undo
3787 3787
             $sql = 'DELETE FROM '.$tbl_my_friend.'
3788 3788
                     WHERE relation_type <> '.USER_RELATION_TYPE_RRHH.' AND friend_user_id='.$friend_id.' '.$extra_condition;
3789 3789
             Database::query($sql);
3790
-            $sql= 'DELETE FROM '.$tbl_my_friend.'
3790
+            $sql = 'DELETE FROM '.$tbl_my_friend.'
3791 3791
                    WHERE relation_type <> '.USER_RELATION_TYPE_RRHH.' AND user_id='.$friend_id.' '.$extra_condition;
3792 3792
             Database::query($sql);
3793 3793
         } else {
@@ -3988,7 +3988,7 @@  discard block
 block discarded – undo
3988 3988
 
3989 3989
         if (!empty($lastConnectionDate)) {
3990 3990
             $lastConnectionDate = Database::escape_string($lastConnectionDate);
3991
-            $userConditions .=  " AND u.last_login <= '$lastConnectionDate' ";
3991
+            $userConditions .= " AND u.last_login <= '$lastConnectionDate' ";
3992 3992
         }
3993 3993
 
3994 3994
         $courseConditions = null;
@@ -4055,7 +4055,7 @@  discard block
 block discarded – undo
4055 4055
                 break;
4056 4056
             case STUDENT_BOSS :
4057 4057
                 $drhConditions = " AND friend_user_id = $userId AND "
4058
-                . "relation_type = " . USER_RELATION_TYPE_BOSS;
4058
+                . "relation_type = ".USER_RELATION_TYPE_BOSS;
4059 4059
                 break;
4060 4060
         }
4061 4061
 
@@ -4146,7 +4146,7 @@  discard block
 block discarded – undo
4146 4146
                     WHERE 
4147 4147
                         friend_user_id = $userId AND 
4148 4148
                         relation_type = $relationType AND 
4149
-                        access_url_id = " . api_get_current_access_url_id();
4149
+                        access_url_id = ".api_get_current_access_url_id();
4150 4150
         } else {
4151 4151
             $sql = "SELECT user_id FROM $userRelUserTable 
4152 4152
                     WHERE friend_user_id = $userId 
@@ -4428,7 +4428,7 @@  discard block
 block discarded – undo
4428 4428
         if (empty($years)) {
4429 4429
             $years = 1;
4430 4430
         }
4431
-        $inactive_time = $years * 31536000;  //1 year
4431
+        $inactive_time = $years * 31536000; //1 year
4432 4432
         $rs = Database::query($sql);
4433 4433
         if (Database::num_rows($rs) > 0) {
4434 4434
             if ($last_login_date = Database::result($rs, 0, 0)) {
@@ -4561,7 +4561,7 @@  discard block
 block discarded – undo
4561 4561
                         'extra_'.$field_details[1],
4562 4562
                         $field_details[3],
4563 4563
                         $options,
4564
-                        array('id' => 'extra_' . $field_details[1])
4564
+                        array('id' => 'extra_'.$field_details[1])
4565 4565
                     );
4566 4566
 
4567 4567
                     if (!$admin_permissions) {
@@ -4715,7 +4715,7 @@  discard block
 block discarded – undo
4715 4715
                     $extra_field = 'extra_'.$field_details[1];
4716 4716
                     $form->addElement('file', $extra_field, $field_details[3], null, '');
4717 4717
                     if ($extra_file_list = UserManager::build_user_extra_file_list($user_id, $field_details[1], '', true)) {
4718
-                        $form->addElement('static', $extra_field . '_list', null, $extra_file_list);
4718
+                        $form->addElement('static', $extra_field.'_list', null, $extra_file_list);
4719 4719
                     }
4720 4720
                     if ($field_details[7] == 0) {
4721 4721
                         $form->freeze($extra_field);
@@ -4883,7 +4883,7 @@  discard block
 block discarded – undo
4883 4883
         $direction = null,
4884 4884
         $active = null,
4885 4885
         $lastConnectionDate = null
4886
-    ){
4886
+    ) {
4887 4887
         return self::getUsersFollowedByUser(
4888 4888
             $userId,
4889 4889
             $userStatus,
@@ -5090,12 +5090,12 @@  discard block
 block discarded – undo
5090 5090
         if (!empty($_SERVER['HTTPS'])) {
5091 5091
             $url = 'https://secure.gravatar.com/avatar/';
5092 5092
         }
5093
-        $url .= md5( strtolower( trim( $email ) ) );
5093
+        $url .= md5(strtolower(trim($email)));
5094 5094
         $url .= "?s=$s&d=$d&r=$r";
5095
-        if ( $img ) {
5096
-            $url = '<img src="' . $url . '"';
5097
-            foreach ( $atts as $key => $val )
5098
-                $url .= ' ' . $key . '="' . $val . '"';
5095
+        if ($img) {
5096
+            $url = '<img src="'.$url.'"';
5097
+            foreach ($atts as $key => $val)
5098
+                $url .= ' '.$key.'="'.$val.'"';
5099 5099
             $url .= ' />';
5100 5100
         }
5101 5101
         return $url;
Please login to merge, or discard this patch.