@@ -74,8 +74,8 @@ |
||
74 | 74 | function reloadCacheTable(): void |
75 | 75 | { |
76 | 76 | // Load expected files |
77 | - require_once __DIR__. '/../sources/main.functions.php'; |
|
78 | - include __DIR__. '/../includes/config/tp.config.php'; |
|
77 | + require_once __DIR__.'/../sources/main.functions.php'; |
|
78 | + include __DIR__.'/../includes/config/tp.config.php'; |
|
79 | 79 | |
80 | 80 | updateCacheTable('reload', NULL); |
81 | 81 | } |
82 | 82 | \ No newline at end of file |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | use TeampassClasses\NestedTree\NestedTree; |
26 | 26 | |
27 | -require_once API_ROOT_PATH . "/Model/Database.php"; |
|
27 | +require_once API_ROOT_PATH."/Model/Database.php"; |
|
28 | 28 | |
29 | 29 | class ItemModel extends Database |
30 | 30 | { |
@@ -46,16 +46,16 @@ discard block |
||
46 | 46 | "SELECT i.id, label, description, i.pw, i.url, i.id_tree, i.login, i.email, i.viewed_no, i.fa_icon, i.inactif, i.perso, t.title as folder_label |
47 | 47 | FROM ".prefixTable('items')." as i |
48 | 48 | LEFT JOIN ".prefixTable('nested_tree')." as t ON (t.id = i.id_tree) ". |
49 | - $sqlExtra . |
|
50 | - " ORDER BY i.id ASC" . |
|
49 | + $sqlExtra. |
|
50 | + " ORDER BY i.id ASC". |
|
51 | 51 | //($limit > 0 ? " LIMIT ?". ["i", $limit] : '') |
52 | - ($limit > 0 ? " LIMIT ". $limit : '') |
|
52 | + ($limit > 0 ? " LIMIT ".$limit : '') |
|
53 | 53 | ); |
54 | 54 | $ret = []; |
55 | 55 | foreach ($rows as $row) { |
56 | 56 | $userKey = $this->select( |
57 | 57 | 'SELECT share_key |
58 | - FROM ' . prefixTable('sharekeys_items') . ' |
|
58 | + FROM ' . prefixTable('sharekeys_items').' |
|
59 | 59 | WHERE user_id = '.$userId.' AND object_id = '.$row['id'] |
60 | 60 | ); |
61 | 61 | if (count($userKey) === 0 || empty($row['pw']) === true) { |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | if (empty($path) === true) { |
90 | 90 | $path = htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES); |
91 | 91 | } else { |
92 | - $path .= '/' . htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES); |
|
92 | + $path .= '/'.htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES); |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 |
@@ -30,13 +30,13 @@ discard block |
||
30 | 30 | header("Access-Control-Allow-Methods: POST"); |
31 | 31 | header("Access-Control-Max-Age: 3600"); |
32 | 32 | header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With"); |
33 | -require __DIR__ . "/inc/bootstrap.php"; |
|
33 | +require __DIR__."/inc/bootstrap.php"; |
|
34 | 34 | |
35 | 35 | // sanitize url segments |
36 | 36 | $base = new BaseController(); |
37 | 37 | $uri = $base->getUriSegments(); |
38 | 38 | if (is_array($uri) === false || is_string($uri) === true) { |
39 | - $uri = [$uri]; // ensure $uril is table |
|
39 | + $uri = [$uri]; // ensure $uril is table |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | // Prepare DB password |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | if ($uri[0] === 'authorize') { |
53 | 53 | // Is API enabled in Teampass settings |
54 | 54 | if ($apiStatus['error'] === false) { |
55 | - require API_ROOT_PATH . "/Controller/Api/AuthController.php"; |
|
55 | + require API_ROOT_PATH."/Controller/Api/AuthController.php"; |
|
56 | 56 | $objFeedController = new AuthController(); |
57 | - $strMethodName = $uri[0] . 'Action'; |
|
57 | + $strMethodName = $uri[0].'Action'; |
|
58 | 58 | $objFeedController->{$strMethodName}(); |
59 | 59 | } else { |
60 | 60 | // Error management |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | |
81 | 81 | // action related to USER |
82 | 82 | } elseif ($controller === 'user') { |
83 | - require API_ROOT_PATH . "/Controller/Api/UserController.php"; |
|
83 | + require API_ROOT_PATH."/Controller/Api/UserController.php"; |
|
84 | 84 | $objFeedController = new UserController(); |
85 | - $strMethodName = (string) $action . 'Action'; |
|
85 | + $strMethodName = (string) $action.'Action'; |
|
86 | 86 | $objFeedController->{$strMethodName}(); |
87 | 87 | |
88 | 88 | // action related to ITEM |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | try { |
32 | 32 | $this->connection = new \mysqli(DB_HOST, DB_USER, DB_PASSWD_CLEAR, DB_NAME); |
33 | 33 | |
34 | - if ( mysqli_connect_errno()) { |
|
34 | + if (mysqli_connect_errno()) { |
|
35 | 35 | throw new Exception("Could not connect to database."); |
36 | 36 | } |
37 | 37 | } catch (Exception $e) { |
@@ -39,37 +39,37 @@ discard block |
||
39 | 39 | } |
40 | 40 | } |
41 | 41 | |
42 | - public function select($query = "" , $params = []) |
|
42 | + public function select($query = "", $params = []) |
|
43 | 43 | { |
44 | 44 | try { |
45 | - $stmt = $this->executeStatement( $query , $params ); |
|
45 | + $stmt = $this->executeStatement($query, $params); |
|
46 | 46 | $result = $stmt->get_result()->fetch_all(MYSQLI_ASSOC); |
47 | 47 | $stmt->close(); |
48 | 48 | |
49 | 49 | return $result; |
50 | - } catch(Exception $e) { |
|
51 | - throw New Exception( $e->getMessage() ); |
|
50 | + } catch (Exception $e) { |
|
51 | + throw New Exception($e->getMessage()); |
|
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
55 | - private function executeStatement($query = "" , $params = []) |
|
55 | + private function executeStatement($query = "", $params = []) |
|
56 | 56 | { |
57 | 57 | try { |
58 | - $stmt = $this->connection->prepare( $query ); |
|
58 | + $stmt = $this->connection->prepare($query); |
|
59 | 59 | |
60 | - if($stmt === false) { |
|
61 | - throw New Exception("Unable to do prepared statement: " . $query); |
|
60 | + if ($stmt === false) { |
|
61 | + throw New Exception("Unable to do prepared statement: ".$query); |
|
62 | 62 | } |
63 | 63 | |
64 | - if( $params ) { |
|
64 | + if ($params) { |
|
65 | 65 | $stmt->bind_param($params[0], $params[1]); |
66 | 66 | } |
67 | 67 | |
68 | 68 | $stmt->execute(); |
69 | 69 | |
70 | 70 | return $stmt; |
71 | - } catch(Exception $e) { |
|
72 | - throw New Exception( $e->getMessage() ); |
|
71 | + } catch (Exception $e) { |
|
72 | + throw New Exception($e->getMessage()); |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | } |
76 | 76 | \ No newline at end of file |
@@ -26,22 +26,22 @@ discard block |
||
26 | 26 | |
27 | 27 | use TeampassClasses\SuperGlobal\SuperGlobal; |
28 | 28 | |
29 | -define("API_ROOT_PATH", __DIR__ . "/.."); |
|
29 | +define("API_ROOT_PATH", __DIR__."/.."); |
|
30 | 30 | |
31 | 31 | // include main configuration file |
32 | -require API_ROOT_PATH . '/../sources/main.functions.php'; |
|
32 | +require API_ROOT_PATH.'/../sources/main.functions.php'; |
|
33 | 33 | |
34 | 34 | // init |
35 | 35 | loadClasses('DB'); |
36 | 36 | $superGlobal = new SuperGlobal(); |
37 | 37 | |
38 | 38 | // include the base controller file |
39 | -require API_ROOT_PATH . "/Controller/Api/BaseController.php"; |
|
39 | +require API_ROOT_PATH."/Controller/Api/BaseController.php"; |
|
40 | 40 | |
41 | 41 | // include the use model file |
42 | -require API_ROOT_PATH . "/Model/UserModel.php"; |
|
43 | -require API_ROOT_PATH . "/Model/ItemModel.php"; |
|
44 | -require API_ROOT_PATH . "/Model/FolderModel.php"; |
|
42 | +require API_ROOT_PATH."/Model/UserModel.php"; |
|
43 | +require API_ROOT_PATH."/Model/ItemModel.php"; |
|
44 | +require API_ROOT_PATH."/Model/FolderModel.php"; |
|
45 | 45 | |
46 | 46 | /** |
47 | 47 | * Launch expected action for ITEM |
@@ -52,10 +52,10 @@ discard block |
||
52 | 52 | */ |
53 | 53 | function itemAction(array $actions, array $userData) |
54 | 54 | { |
55 | - require API_ROOT_PATH . "/Controller/Api/ItemController.php"; |
|
55 | + require API_ROOT_PATH."/Controller/Api/ItemController.php"; |
|
56 | 56 | |
57 | 57 | $objFeedController = new ItemController(); |
58 | - $strMethodName = $actions[0] . 'Action'; |
|
58 | + $strMethodName = $actions[0].'Action'; |
|
59 | 59 | $objFeedController->{$strMethodName}($userData); |
60 | 60 | } |
61 | 61 | |
@@ -68,10 +68,10 @@ discard block |
||
68 | 68 | */ |
69 | 69 | function folderAction(array $actions, array $userData) |
70 | 70 | { |
71 | - require API_ROOT_PATH . "/Controller/Api/FolderController.php"; |
|
71 | + require API_ROOT_PATH."/Controller/Api/FolderController.php"; |
|
72 | 72 | |
73 | 73 | $objFeedController = new FolderController(); |
74 | - $strMethodName = $actions[0] . 'Action'; |
|
74 | + $strMethodName = $actions[0].'Action'; |
|
75 | 75 | $objFeedController->{$strMethodName}($userData); |
76 | 76 | } |
77 | 77 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | function apiIsEnabled(): string |
84 | 84 | { |
85 | - include API_ROOT_PATH . '/../includes/config/tp.config.php'; |
|
85 | + include API_ROOT_PATH.'/../includes/config/tp.config.php'; |
|
86 | 86 | |
87 | 87 | if (isset($SETTINGS) === true && isset($SETTINGS['api']) === true && (int) $SETTINGS['api'] === 1) { |
88 | 88 | return json_encode( |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | */ |
112 | 112 | function verifyAuth(): string |
113 | 113 | { |
114 | - include_once API_ROOT_PATH . '/inc/jwt_utils.php'; |
|
114 | + include_once API_ROOT_PATH.'/inc/jwt_utils.php'; |
|
115 | 115 | $bearer_token = get_bearer_token(); |
116 | 116 | |
117 | 117 | if (empty($bearer_token) === false && is_jwt_valid($bearer_token) === true) { |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | */ |
142 | 142 | function getDataFromToken(): string |
143 | 143 | { |
144 | - include_once API_ROOT_PATH . '/inc/jwt_utils.php'; |
|
144 | + include_once API_ROOT_PATH.'/inc/jwt_utils.php'; |
|
145 | 145 | $bearer_token = get_bearer_token(); |
146 | 146 | |
147 | 147 | if (empty($bearer_token) === false) { |
@@ -37,45 +37,45 @@ discard block |
||
37 | 37 | * @return boolean |
38 | 38 | */ |
39 | 39 | function is_jwt_valid($jwt) { |
40 | - try { |
|
41 | - $decoded = (array) JWT::decode($jwt, new Key(DB_PASSWD, 'HS256')); |
|
40 | + try { |
|
41 | + $decoded = (array) JWT::decode($jwt, new Key(DB_PASSWD, 'HS256')); |
|
42 | 42 | |
43 | - // Check if expiration is reached |
|
44 | - if ($decoded['exp'] - time() < 0) { |
|
45 | - return false; |
|
46 | - } |
|
43 | + // Check if expiration is reached |
|
44 | + if ($decoded['exp'] - time() < 0) { |
|
45 | + return false; |
|
46 | + } |
|
47 | 47 | /* |
48 | 48 | $decoded1 = JWT::decode($jwt, new Key(DB_PASSWD, 'HS256'), $headers = new stdClass()); |
49 | 49 | print_r($headers); |
50 | 50 | */ |
51 | 51 | |
52 | - return true; |
|
53 | - } catch (InvalidArgumentException $e) { |
|
54 | - // provided key/key-array is empty or malformed. |
|
55 | - return false; |
|
56 | - } catch (DomainException $e) { |
|
57 | - // provided algorithm is unsupported OR |
|
58 | - // provided key is invalid OR |
|
59 | - // unknown error thrown in openSSL or libsodium OR |
|
60 | - // libsodium is required but not available. |
|
61 | - return false; |
|
62 | - } catch (SignatureInvalidException $e) { |
|
63 | - // provided JWT signature verification failed. |
|
64 | - return false; |
|
65 | - } catch (BeforeValidException $e) { |
|
66 | - // provided JWT is trying to be used before "nbf" claim OR |
|
67 | - // provided JWT is trying to be used before "iat" claim. |
|
68 | - return false; |
|
69 | - } catch (ExpiredException $e) { |
|
70 | - // provided JWT is trying to be used after "exp" claim. |
|
71 | - return false; |
|
72 | - } catch (UnexpectedValueException $e) { |
|
73 | - // provided JWT is malformed OR |
|
74 | - // provided JWT is missing an algorithm / using an unsupported algorithm OR |
|
75 | - // provided JWT algorithm does not match provided key OR |
|
76 | - // provided key ID in key/key-array is empty or invalid. |
|
77 | - return false; |
|
78 | - } |
|
52 | + return true; |
|
53 | + } catch (InvalidArgumentException $e) { |
|
54 | + // provided key/key-array is empty or malformed. |
|
55 | + return false; |
|
56 | + } catch (DomainException $e) { |
|
57 | + // provided algorithm is unsupported OR |
|
58 | + // provided key is invalid OR |
|
59 | + // unknown error thrown in openSSL or libsodium OR |
|
60 | + // libsodium is required but not available. |
|
61 | + return false; |
|
62 | + } catch (SignatureInvalidException $e) { |
|
63 | + // provided JWT signature verification failed. |
|
64 | + return false; |
|
65 | + } catch (BeforeValidException $e) { |
|
66 | + // provided JWT is trying to be used before "nbf" claim OR |
|
67 | + // provided JWT is trying to be used before "iat" claim. |
|
68 | + return false; |
|
69 | + } catch (ExpiredException $e) { |
|
70 | + // provided JWT is trying to be used after "exp" claim. |
|
71 | + return false; |
|
72 | + } catch (UnexpectedValueException $e) { |
|
73 | + // provided JWT is malformed OR |
|
74 | + // provided JWT is missing an algorithm / using an unsupported algorithm OR |
|
75 | + // provided JWT algorithm does not match provided key OR |
|
76 | + // provided key ID in key/key-array is empty or invalid. |
|
77 | + return false; |
|
78 | + } |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | function base64url_encode($data) { |
@@ -83,24 +83,24 @@ discard block |
||
83 | 83 | } |
84 | 84 | |
85 | 85 | function get_authorization_header(){ |
86 | - $superGlobal = new SuperGlobal(); |
|
87 | - $headers = null; |
|
86 | + $superGlobal = new SuperGlobal(); |
|
87 | + $headers = null; |
|
88 | 88 | |
89 | - if (null !== $superGlobal->get('Authorization', 'SERVER')) { |
|
90 | - $headers = trim($superGlobal->get('Authorization', 'SERVER')); |
|
91 | - } else if (null !== $superGlobal->get('HTTP_AUTHORIZATION', 'SERVER')) { //Nginx or fast CGI |
|
92 | - $headers = trim($superGlobal->get('HTTP_AUTHORIZATION', 'SERVER')); |
|
93 | - } else if (function_exists('apache_request_headers') === true) { |
|
94 | - $requestHeaders = (array) apache_request_headers(); |
|
95 | - // Server-side fix for bug in old Android versions (a nice side-effect of this fix means we don't care about capitalization for Authorization) |
|
96 | - $requestHeaders = array_combine(array_map('ucwords', array_keys($requestHeaders)), array_values($requestHeaders)); |
|
97 | - //print_r($requestHeaders); |
|
98 | - if (isset($requestHeaders['Authorization']) === true) { |
|
99 | - $headers = trim($requestHeaders['Authorization']); |
|
100 | - } |
|
101 | - } |
|
89 | + if (null !== $superGlobal->get('Authorization', 'SERVER')) { |
|
90 | + $headers = trim($superGlobal->get('Authorization', 'SERVER')); |
|
91 | + } else if (null !== $superGlobal->get('HTTP_AUTHORIZATION', 'SERVER')) { //Nginx or fast CGI |
|
92 | + $headers = trim($superGlobal->get('HTTP_AUTHORIZATION', 'SERVER')); |
|
93 | + } else if (function_exists('apache_request_headers') === true) { |
|
94 | + $requestHeaders = (array) apache_request_headers(); |
|
95 | + // Server-side fix for bug in old Android versions (a nice side-effect of this fix means we don't care about capitalization for Authorization) |
|
96 | + $requestHeaders = array_combine(array_map('ucwords', array_keys($requestHeaders)), array_values($requestHeaders)); |
|
97 | + //print_r($requestHeaders); |
|
98 | + if (isset($requestHeaders['Authorization']) === true) { |
|
99 | + $headers = trim($requestHeaders['Authorization']); |
|
100 | + } |
|
101 | + } |
|
102 | 102 | |
103 | - return $headers; |
|
103 | + return $headers; |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | function get_bearer_token() { |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | |
118 | 118 | function get_bearer_data($jwt) { |
119 | 119 | // split the jwt |
120 | - $tokenParts = explode('.', $jwt); |
|
121 | - $payload = base64_decode($tokenParts[1]); |
|
120 | + $tokenParts = explode('.', $jwt); |
|
121 | + $payload = base64_decode($tokenParts[1]); |
|
122 | 122 | |
123 | 123 | // HEADER: Get the access token from the header |
124 | 124 | if (empty($payload) === false) { |
@@ -82,7 +82,7 @@ |
||
82 | 82 | return rtrim(strtr(base64_encode($data), '+/', '-_'), '='); |
83 | 83 | } |
84 | 84 | |
85 | -function get_authorization_header(){ |
|
85 | +function get_authorization_header() { |
|
86 | 86 | $superGlobal = new SuperGlobal(); |
87 | 87 | $headers = null; |
88 | 88 |
@@ -133,7 +133,7 @@ |
||
133 | 133 | { |
134 | 134 | include API_ROOT_PATH . '/../includes/config/tp.config.php'; |
135 | 135 | |
136 | - $payload = [ |
|
136 | + $payload = [ |
|
137 | 137 | 'username' => $login, |
138 | 138 | 'id' => $id, |
139 | 139 | 'exp' => (time() + $SETTINGS['api_token_duration'] + 600), |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | use Firebase\JWT\JWT; |
28 | 28 | use Firebase\JWT\Key; |
29 | 29 | |
30 | -require_once API_ROOT_PATH . "/Model/Database.php"; |
|
30 | +require_once API_ROOT_PATH."/Model/Database.php"; |
|
31 | 31 | |
32 | 32 | |
33 | 33 | class AuthModel extends Database |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | public function getUserAuth(string $login, string $password, string $apikey): array |
46 | 46 | { |
47 | 47 | // Sanitize |
48 | - include_once API_ROOT_PATH . '/../sources/main.functions.php'; |
|
48 | + include_once API_ROOT_PATH.'/../sources/main.functions.php'; |
|
49 | 49 | $inputData = dataSanitizer( |
50 | 50 | [ |
51 | 51 | 'login' => isset($login) === true ? $login : '', |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | 'password' => 'trim|escape', |
58 | 58 | 'apikey' => 'trim|escape', |
59 | 59 | ], |
60 | - API_ROOT_PATH . '/..' |
|
60 | + API_ROOT_PATH.'/..' |
|
61 | 61 | ); |
62 | 62 | if (empty($inputData['login']) === true || empty($inputData['apikey']) === true) { |
63 | 63 | return ["error" => "Login failed0.", "info" => "Empty entry"]; |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | // Check apikey |
67 | 67 | if (empty($inputData['password']) === true) { |
68 | 68 | // case where it is a generic key |
69 | - $apiInfo = $this->select("SELECT count(*) FROM " . prefixTable('api') . " WHERE value='".$inputData['apikey']."' AND label='".$inputData['login']."'"); |
|
69 | + $apiInfo = $this->select("SELECT count(*) FROM ".prefixTable('api')." WHERE value='".$inputData['apikey']."' AND label='".$inputData['login']."'"); |
|
70 | 70 | if ((int) $apiInfo[0]['count(*)'] === 0) { |
71 | 71 | return ["error" => "Login failed1.", "info" => "apikey : Not valid"]; |
72 | 72 | } |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | // Check if user exists |
78 | 78 | $userInfoRes = $this->select( |
79 | 79 | "SELECT u.id, u.pw, u.public_key, u.private_key, u.personal_folder, u.fonction_id, u.groupes_visibles, u.groupes_interdits, a.value AS user_api_key |
80 | - FROM " . prefixTable('users') . " AS u |
|
81 | - INNER JOIN " . prefixTable('api') . " AS a ON (a.user_id=u.id) |
|
80 | + FROM " . prefixTable('users')." AS u |
|
81 | + INNER JOIN " . prefixTable('api')." AS a ON (a.user_id=u.id) |
|
82 | 82 | WHERE login='".$inputData['login']."'"); |
83 | 83 | if (count($userInfoRes) === 0) { |
84 | 84 | return ["error" => "Login failed3.", "info" => "apikey : Not valid"]; |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | */ |
132 | 132 | private function createUserJWT(int $id, string $login, int $pf_enabled, string $pubkey, string $privkey, string $folders, string $items): array |
133 | 133 | { |
134 | - include API_ROOT_PATH . '/../includes/config/tp.config.php'; |
|
134 | + include API_ROOT_PATH.'/../includes/config/tp.config.php'; |
|
135 | 135 | |
136 | 136 | $payload = [ |
137 | 137 | 'username' => $login, |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | |
176 | 176 | // Get folders from the roles |
177 | 177 | if (empty($userFunctionId) === false) { |
178 | - $rows = $this->select("SELECT * FROM " . prefixTable('roles_values') . " WHERE role_id IN (".$userFunctionId.") AND type IN ('W', 'ND', 'NE', 'NDNE', 'R')"); |
|
178 | + $rows = $this->select("SELECT * FROM ".prefixTable('roles_values')." WHERE role_id IN (".$userFunctionId.") AND type IN ('W', 'ND', 'NE', 'NDNE', 'R')"); |
|
179 | 179 | foreach ($rows as $record) { |
180 | 180 | if ($record['type'] === 'R') { |
181 | 181 | array_push($readOnlyFolders, $record['folder_id']); |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | |
197 | 197 | // Does this user is allowed to see other items |
198 | 198 | $inc = 0; |
199 | - $rows = $this->select("SELECT id, id_tree FROM " . prefixTable('items') . " WHERE restricted_to LIKE '".$userInfo['id']."'". |
|
199 | + $rows = $this->select("SELECT id, id_tree FROM ".prefixTable('items')." WHERE restricted_to LIKE '".$userInfo['id']."'". |
|
200 | 200 | (empty($userFunctionId) === false ? ' AND id_tree NOT IN ('.$userFunctionId.')' : '')); |
201 | 201 | foreach ($rows as $record) { |
202 | 202 | // Exclude restriction on item if folder is fully accessible |
@@ -206,8 +206,8 @@ discard block |
||
206 | 206 | |
207 | 207 | // Check for the users roles if some specific rights exist on items |
208 | 208 | $rows = $this->select("SELECT i.id_tree, r.item_id |
209 | - FROM " . prefixTable('items') . " as i |
|
210 | - INNER JOIN " . prefixTable('restriction_to_roles') . " as r ON (r.item_id=i.id) |
|
209 | + FROM " . prefixTable('items')." as i |
|
210 | + INNER JOIN " . prefixTable('restriction_to_roles')." as r ON (r.item_id=i.id) |
|
211 | 211 | WHERE ".(empty($userFunctionId) === false ? ' id_tree NOT IN ('.$userFunctionId.') AND ' : '')." i.id_tree != '' |
212 | 212 | ORDER BY i.id_tree ASC"); |
213 | 213 | foreach ($rows as $record) { |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | // Add all personal folders |
222 | 222 | $rows = $this->select( |
223 | 223 | 'SELECT id |
224 | - FROM ' . prefixTable('nested_tree') . ' |
|
224 | + FROM ' . prefixTable('nested_tree').' |
|
225 | 225 | WHERE title = '.$userInfo['id'].' AND personal_folder = 1'. |
226 | 226 | (empty($userFunctionId) === false ? ' AND id NOT IN ('.$userFunctionId.')' : ''). |
227 | 227 | ' LIMIT 0,1' |
@@ -68,7 +68,7 @@ |
||
68 | 68 | DB::debugmode(false); |
69 | 69 | $rows = DB::query( |
70 | 70 | 'SELECT * |
71 | - FROM ' . prefixTable('processes') . ' |
|
71 | + FROM ' . prefixTable('processes').' |
|
72 | 72 | WHERE is_in_progress = %i AND process_type = %s |
73 | 73 | ORDER BY increment_id ASC LIMIT 0,10', |
74 | 74 | 0, |
@@ -90,10 +90,10 @@ discard block |
||
90 | 90 | */ |
91 | 91 | function provideLog(string $message, array $SETTINGS) |
92 | 92 | { |
93 | - echo '\n' . (string) date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], time()) . ' - '.$message . '\n'; |
|
93 | + echo '\n'.(string) date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], time()).' - '.$message.'\n'; |
|
94 | 94 | } |
95 | 95 | |
96 | -function performVisibleFoldersHtmlUpdate (int $user_id) |
|
96 | +function performVisibleFoldersHtmlUpdate(int $user_id) |
|
97 | 97 | { |
98 | 98 | $html = []; |
99 | 99 | |
@@ -103,10 +103,10 @@ discard block |
||
103 | 103 | |
104 | 104 | // get current folders visible for user |
105 | 105 | $cache_tree = DB::queryFirstRow( |
106 | - 'SELECT increment_id, data FROM ' . prefixTable('cache_tree') . ' WHERE user_id = %i', |
|
106 | + 'SELECT increment_id, data FROM '.prefixTable('cache_tree').' WHERE user_id = %i', |
|
107 | 107 | $user_id |
108 | 108 | ); |
109 | - $folders = json_decode($cache_tree['data'], true);//print_r($folders); |
|
109 | + $folders = json_decode($cache_tree['data'], true); //print_r($folders); |
|
110 | 110 | foreach ($folders as $folder) { |
111 | 111 | $idFolder = (int) explode("li_", $folder['id'])[1]; |
112 | 112 | |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | |
120 | 120 | // get folder info |
121 | 121 | $folder = DB::queryFirstRow( |
122 | - 'SELECT title, parent_id, personal_folder FROM ' . prefixTable('nested_tree') . ' WHERE id = %i', |
|
122 | + 'SELECT title, parent_id, personal_folder FROM '.prefixTable('nested_tree').' WHERE id = %i', |
|
123 | 123 | $idFolder |
124 | 124 | ); |
125 | 125 |