@@ -30,21 +30,21 @@ discard block |
||
30 | 30 | */ |
31 | 31 | function SetXmlHeaders() |
32 | 32 | { |
33 | - ob_end_clean(); |
|
34 | - |
|
35 | - // Prevent the browser from caching the result. |
|
36 | - // Date in the past |
|
37 | - header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
|
38 | - // always modified |
|
39 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
|
40 | - // HTTP/1.1 |
|
41 | - header('Cache-Control: no-store, no-cache, must-revalidate'); |
|
42 | - header('Cache-Control: post-check=0, pre-check=0', false); |
|
43 | - // HTTP/1.0 |
|
44 | - header('Pragma: no-cache'); |
|
45 | - |
|
46 | - // Set the response format. |
|
47 | - header('Content-Type: text/xml; charset=utf-8'); |
|
33 | + ob_end_clean(); |
|
34 | + |
|
35 | + // Prevent the browser from caching the result. |
|
36 | + // Date in the past |
|
37 | + header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
|
38 | + // always modified |
|
39 | + header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
|
40 | + // HTTP/1.1 |
|
41 | + header('Cache-Control: no-store, no-cache, must-revalidate'); |
|
42 | + header('Cache-Control: post-check=0, pre-check=0', false); |
|
43 | + // HTTP/1.0 |
|
44 | + header('Pragma: no-cache'); |
|
45 | + |
|
46 | + // Set the response format. |
|
47 | + header('Content-Type: text/xml; charset=utf-8'); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -57,18 +57,18 @@ discard block |
||
57 | 57 | */ |
58 | 58 | function CreateXmlHeader( $command, $resourceType, $currentFolder ) |
59 | 59 | { |
60 | - SetXmlHeaders(); |
|
60 | + SetXmlHeaders(); |
|
61 | 61 | |
62 | - // Create the XML document header. |
|
63 | - echo '<?xml version="1.0" encoding="utf-8" ?>' ; |
|
62 | + // Create the XML document header. |
|
63 | + echo '<?xml version="1.0" encoding="utf-8" ?>' ; |
|
64 | 64 | |
65 | - // Create the main "Connector" node. |
|
66 | - echo '<Connector command="' . $command . '" resourceType="' . $resourceType . '">' ; |
|
65 | + // Create the main "Connector" node. |
|
66 | + echo '<Connector command="' . $command . '" resourceType="' . $resourceType . '">' ; |
|
67 | 67 | |
68 | - // Add the current folder node. |
|
69 | - echo '<CurrentFolder path="' . ConvertToXmlAttribute($currentFolder) . '" url="' . ConvertToXmlAttribute(GetUrlFromPath($resourceType, $currentFolder, $command)) . '" />' ; |
|
68 | + // Add the current folder node. |
|
69 | + echo '<CurrentFolder path="' . ConvertToXmlAttribute($currentFolder) . '" url="' . ConvertToXmlAttribute(GetUrlFromPath($resourceType, $currentFolder, $command)) . '" />' ; |
|
70 | 70 | |
71 | - $GLOBALS['HeaderSent'] = true ; |
|
71 | + $GLOBALS['HeaderSent'] = true ; |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | function CreateXmlFooter() |
80 | 80 | { |
81 | - echo '</Connector>' ; |
|
81 | + echo '</Connector>' ; |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -90,30 +90,30 @@ discard block |
||
90 | 90 | */ |
91 | 91 | function SendError($number, $text) |
92 | 92 | { |
93 | - if ( $_GET['Command'] == 'FileUpload' ) |
|
94 | - SendUploadResults($number, "", "", $text); |
|
95 | - |
|
96 | - if ( isset( $GLOBALS['HeaderSent'] ) && $GLOBALS['HeaderSent'] ) |
|
97 | - { |
|
98 | - SendErrorNode($number, $text); |
|
99 | - CreateXmlFooter(); |
|
100 | - } |
|
101 | - else |
|
102 | - { |
|
103 | - SetXmlHeaders(); |
|
104 | - |
|
105 | - dol_syslog('Error: '.$number.' '.$text, LOG_ERR); |
|
93 | + if ( $_GET['Command'] == 'FileUpload' ) |
|
94 | + SendUploadResults($number, "", "", $text); |
|
95 | + |
|
96 | + if ( isset( $GLOBALS['HeaderSent'] ) && $GLOBALS['HeaderSent'] ) |
|
97 | + { |
|
98 | + SendErrorNode($number, $text); |
|
99 | + CreateXmlFooter(); |
|
100 | + } |
|
101 | + else |
|
102 | + { |
|
103 | + SetXmlHeaders(); |
|
104 | + |
|
105 | + dol_syslog('Error: '.$number.' '.$text, LOG_ERR); |
|
106 | 106 | |
107 | - // Create the XML document header |
|
108 | - echo '<?xml version="1.0" encoding="utf-8" ?>' ; |
|
107 | + // Create the XML document header |
|
108 | + echo '<?xml version="1.0" encoding="utf-8" ?>' ; |
|
109 | 109 | |
110 | - echo '<Connector>' ; |
|
110 | + echo '<Connector>' ; |
|
111 | 111 | |
112 | - SendErrorNode($number, $text); |
|
112 | + SendErrorNode($number, $text); |
|
113 | 113 | |
114 | - echo '</Connector>' ; |
|
115 | - } |
|
116 | - exit ; |
|
114 | + echo '</Connector>' ; |
|
115 | + } |
|
116 | + exit ; |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | */ |
126 | 126 | function SendErrorNode($number, $text) |
127 | 127 | { |
128 | - if ($text) |
|
129 | - echo '<Error number="' . $number . '" text="' . htmlspecialchars($text) . '" />' ; |
|
130 | - else |
|
131 | - echo '<Error number="' . $number . '" />' ; |
|
128 | + if ($text) |
|
129 | + echo '<Error number="' . $number . '" text="' . htmlspecialchars($text) . '" />' ; |
|
130 | + else |
|
131 | + echo '<Error number="' . $number . '" />' ; |
|
132 | 132 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | require 'commands.php'; |
32 | 32 | |
33 | 33 | if ( !$Config['Enabled'] ) |
34 | - SendError(1, 'This connector is disabled. Please check the "editor/filemanager/connectors/php/config.php" file'); |
|
34 | + SendError(1, 'This connector is disabled. Please check the "editor/filemanager/connectors/php/config.php" file'); |
|
35 | 35 | |
36 | 36 | DoResponse(); |
37 | 37 | |
@@ -45,47 +45,47 @@ discard block |
||
45 | 45 | if (!isset($_GET)) { |
46 | 46 | global $_GET; |
47 | 47 | } |
48 | - if ( !isset( $_GET['Command'] ) || !isset( $_GET['Type'] ) || !isset( $_GET['CurrentFolder'] ) ) |
|
49 | - return; |
|
48 | + if ( !isset( $_GET['Command'] ) || !isset( $_GET['Type'] ) || !isset( $_GET['CurrentFolder'] ) ) |
|
49 | + return; |
|
50 | 50 | |
51 | - // Get the main request informaiton. |
|
52 | - $sCommand = $_GET['Command'] ; |
|
53 | - $sResourceType = $_GET['Type'] ; |
|
54 | - $sCurrentFolder = GetCurrentFolder(); |
|
51 | + // Get the main request informaiton. |
|
52 | + $sCommand = $_GET['Command'] ; |
|
53 | + $sResourceType = $_GET['Type'] ; |
|
54 | + $sCurrentFolder = GetCurrentFolder(); |
|
55 | 55 | |
56 | - // Check if it is an allowed command |
|
57 | - if (! IsAllowedCommand($sCommand)) |
|
58 | - { |
|
59 | - SendError(1, 'The "' . $sCommand . '" command isn\'t allowed'); |
|
60 | - } |
|
61 | - // Check if it is an allowed type. |
|
62 | - if (! IsAllowedType($sResourceType)) |
|
63 | - SendError(1, 'Invalid type specified'); |
|
56 | + // Check if it is an allowed command |
|
57 | + if (! IsAllowedCommand($sCommand)) |
|
58 | + { |
|
59 | + SendError(1, 'The "' . $sCommand . '" command isn\'t allowed'); |
|
60 | + } |
|
61 | + // Check if it is an allowed type. |
|
62 | + if (! IsAllowedType($sResourceType)) |
|
63 | + SendError(1, 'Invalid type specified'); |
|
64 | 64 | |
65 | - // File Upload doesn't have to Return XML, so it must be intercepted before anything. |
|
66 | - if ( $sCommand == 'FileUpload' ) |
|
67 | - { |
|
68 | - FileUpload($sResourceType, $sCurrentFolder, $sCommand); |
|
69 | - return; |
|
70 | - } |
|
65 | + // File Upload doesn't have to Return XML, so it must be intercepted before anything. |
|
66 | + if ( $sCommand == 'FileUpload' ) |
|
67 | + { |
|
68 | + FileUpload($sResourceType, $sCurrentFolder, $sCommand); |
|
69 | + return; |
|
70 | + } |
|
71 | 71 | |
72 | - CreateXmlHeader($sCommand, $sResourceType, $sCurrentFolder); |
|
72 | + CreateXmlHeader($sCommand, $sResourceType, $sCurrentFolder); |
|
73 | 73 | |
74 | - // Execute the required command. |
|
75 | - switch ( $sCommand ) |
|
76 | - { |
|
77 | - case 'GetFolders' : |
|
78 | - GetFolders($sResourceType, $sCurrentFolder); |
|
79 | - break; |
|
80 | - case 'GetFoldersAndFiles' : |
|
81 | - GetFoldersAndFiles($sResourceType, $sCurrentFolder); |
|
82 | - break; |
|
83 | - case 'CreateFolder' : |
|
84 | - CreateFolder($sResourceType, $sCurrentFolder); |
|
85 | - break; |
|
86 | - } |
|
74 | + // Execute the required command. |
|
75 | + switch ( $sCommand ) |
|
76 | + { |
|
77 | + case 'GetFolders' : |
|
78 | + GetFolders($sResourceType, $sCurrentFolder); |
|
79 | + break; |
|
80 | + case 'GetFoldersAndFiles' : |
|
81 | + GetFoldersAndFiles($sResourceType, $sCurrentFolder); |
|
82 | + break; |
|
83 | + case 'CreateFolder' : |
|
84 | + CreateFolder($sResourceType, $sCurrentFolder); |
|
85 | + break; |
|
86 | + } |
|
87 | 87 | |
88 | - CreateXmlFooter(); |
|
88 | + CreateXmlFooter(); |
|
89 | 89 | |
90 | - exit; |
|
90 | + exit; |
|
91 | 91 | } |
@@ -36,13 +36,13 @@ discard block |
||
36 | 36 | */ |
37 | 37 | function SendError($number, $text) |
38 | 38 | { |
39 | - SendUploadResults($number, '', '', $text); |
|
39 | + SendUploadResults($number, '', '', $text); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | |
43 | 43 | // Check if this uploader has been enabled. |
44 | 44 | if ( !$Config['Enabled'] ) |
45 | - SendUploadResults('1', '', '', 'This file uploader is disabled. Please check the "filemanagerdol/connectors/php/config.php" file'); |
|
45 | + SendUploadResults('1', '', '', 'This file uploader is disabled. Please check the "filemanagerdol/connectors/php/config.php" file'); |
|
46 | 46 | |
47 | 47 | $sCommand = 'QuickUpload' ; |
48 | 48 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | |
54 | 54 | // Is enabled the upload? |
55 | 55 | if (! IsAllowedCommand($sCommand)) |
56 | - SendUploadResults('1', '', '', 'The ""' . $sCommand . '"" command isn\'t allowed'); |
|
56 | + SendUploadResults('1', '', '', 'The ""' . $sCommand . '"" command isn\'t allowed'); |
|
57 | 57 | |
58 | 58 | // Check if it is an allowed type. |
59 | 59 | if (! IsAllowedType($sType)) |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | */ |
32 | 32 | function CombinePaths( $sBasePath, $sFolder ) |
33 | 33 | { |
34 | - return RemoveFromEnd($sBasePath, '/') . '/' . RemoveFromStart($sFolder, '/'); |
|
34 | + return RemoveFromEnd($sBasePath, '/') . '/' . RemoveFromStart($sFolder, '/'); |
|
35 | 35 | } |
36 | 36 | /** |
37 | 37 | * GetResourceTypePath |
@@ -42,12 +42,12 @@ discard block |
||
42 | 42 | */ |
43 | 43 | function GetResourceTypePath($resourceType, $sCommand) |
44 | 44 | { |
45 | - global $Config ; |
|
45 | + global $Config ; |
|
46 | 46 | |
47 | - if ($sCommand == "QuickUpload") |
|
48 | - return $Config['QuickUploadPath'][$resourceType] ; |
|
49 | - else |
|
50 | - return $Config['FileTypesPath'][$resourceType] ; |
|
47 | + if ($sCommand == "QuickUpload") |
|
48 | + return $Config['QuickUploadPath'][$resourceType] ; |
|
49 | + else |
|
50 | + return $Config['FileTypesPath'][$resourceType] ; |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -59,23 +59,23 @@ discard block |
||
59 | 59 | */ |
60 | 60 | function GetResourceTypeDirectory($resourceType, $sCommand) |
61 | 61 | { |
62 | - global $Config ; |
|
63 | - if ($sCommand == "QuickUpload") |
|
64 | - { |
|
65 | - if ( strlen($Config['QuickUploadAbsolutePath'][$resourceType]) > 0) |
|
66 | - return $Config['QuickUploadAbsolutePath'][$resourceType] ; |
|
67 | - |
|
68 | - // Map the "UserFiles" path to a local directory. |
|
69 | - return Server_MapPath($Config['QuickUploadPath'][$resourceType]); |
|
70 | - } |
|
71 | - else |
|
72 | - { |
|
73 | - if ( strlen($Config['FileTypesAbsolutePath'][$resourceType]) > 0) |
|
74 | - return $Config['FileTypesAbsolutePath'][$resourceType] ; |
|
75 | - |
|
76 | - // Map the "UserFiles" path to a local directory. |
|
77 | - return Server_MapPath($Config['FileTypesPath'][$resourceType]); |
|
78 | - } |
|
62 | + global $Config ; |
|
63 | + if ($sCommand == "QuickUpload") |
|
64 | + { |
|
65 | + if ( strlen($Config['QuickUploadAbsolutePath'][$resourceType]) > 0) |
|
66 | + return $Config['QuickUploadAbsolutePath'][$resourceType] ; |
|
67 | + |
|
68 | + // Map the "UserFiles" path to a local directory. |
|
69 | + return Server_MapPath($Config['QuickUploadPath'][$resourceType]); |
|
70 | + } |
|
71 | + else |
|
72 | + { |
|
73 | + if ( strlen($Config['FileTypesAbsolutePath'][$resourceType]) > 0) |
|
74 | + return $Config['FileTypesAbsolutePath'][$resourceType] ; |
|
75 | + |
|
76 | + // Map the "UserFiles" path to a local directory. |
|
77 | + return Server_MapPath($Config['FileTypesPath'][$resourceType]); |
|
78 | + } |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | */ |
89 | 89 | function GetUrlFromPath($resourceType, $folderPath, $sCommand) |
90 | 90 | { |
91 | - return CombinePaths(GetResourceTypePath($resourceType, $sCommand), $folderPath); |
|
91 | + return CombinePaths(GetResourceTypePath($resourceType, $sCommand), $folderPath); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | */ |
100 | 100 | function RemoveExtension($fileName) |
101 | 101 | { |
102 | - return substr($fileName, 0, strrpos($fileName, '.')); |
|
102 | + return substr($fileName, 0, strrpos($fileName, '.')); |
|
103 | 103 | } |
104 | 104 | /** |
105 | 105 | * ServerMapFolder |
@@ -111,16 +111,16 @@ discard block |
||
111 | 111 | */ |
112 | 112 | function ServerMapFolder($resourceType, $folderPath, $sCommand) |
113 | 113 | { |
114 | - // Get the resource type directory. |
|
115 | - $sResourceTypePath = GetResourceTypeDirectory($resourceType, $sCommand); |
|
114 | + // Get the resource type directory. |
|
115 | + $sResourceTypePath = GetResourceTypeDirectory($resourceType, $sCommand); |
|
116 | 116 | |
117 | - // Ensure that the directory exists. |
|
118 | - $sErrorMsg = CreateServerFolder($sResourceTypePath); |
|
119 | - if ( $sErrorMsg != '' ) |
|
120 | - SendError(1, "Error creating folder \"{$sResourceTypePath}\" ({$sErrorMsg})"); |
|
117 | + // Ensure that the directory exists. |
|
118 | + $sErrorMsg = CreateServerFolder($sResourceTypePath); |
|
119 | + if ( $sErrorMsg != '' ) |
|
120 | + SendError(1, "Error creating folder \"{$sResourceTypePath}\" ({$sErrorMsg})"); |
|
121 | 121 | |
122 | - // Return the resource type directory combined with the required path. |
|
123 | - return CombinePaths($sResourceTypePath, $folderPath); |
|
122 | + // Return the resource type directory combined with the required path. |
|
123 | + return CombinePaths($sResourceTypePath, $folderPath); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
@@ -144,67 +144,67 @@ discard block |
||
144 | 144 | */ |
145 | 145 | function CreateServerFolder($folderPath, $lastFolder = null) |
146 | 146 | { |
147 | - global $Config ; |
|
148 | - $sParent = GetParentFolder($folderPath); |
|
149 | - |
|
150 | - // Ensure the folder path has no double-slashes, or mkdir may fail on certain platforms |
|
151 | - while ( strpos($folderPath, '//') !== false ) |
|
152 | - { |
|
153 | - $folderPath = str_replace('//', '/', $folderPath); |
|
154 | - } |
|
155 | - |
|
156 | - // Check if the parent exists, or create it. |
|
157 | - if ( !empty($sParent) && !file_exists($sParent)) |
|
158 | - { |
|
159 | - //prevents agains infinite loop when we can't create root folder |
|
160 | - if ( !is_null($lastFolder) && $lastFolder === $sParent) { |
|
161 | - return "Can't create $folderPath directory" ; |
|
162 | - } |
|
163 | - |
|
164 | - $sErrorMsg = CreateServerFolder($sParent, $folderPath); |
|
165 | - if ( $sErrorMsg != '' ) |
|
166 | - return $sErrorMsg ; |
|
167 | - } |
|
168 | - |
|
169 | - if ( !file_exists($folderPath)) |
|
170 | - { |
|
171 | - // Turn off all error reporting. |
|
172 | - error_reporting(0); |
|
173 | - |
|
174 | - $php_errormsg = '' ; |
|
175 | - // Enable error tracking to catch the error. |
|
176 | - ini_set('track_errors', '1'); |
|
177 | - |
|
178 | - if ( isset( $Config['ChmodOnFolderCreate'] ) && !$Config['ChmodOnFolderCreate'] ) |
|
179 | - { |
|
180 | - mkdir($folderPath); |
|
181 | - } |
|
182 | - else |
|
183 | - { |
|
184 | - $permissions = '0777'; |
|
185 | - if ( isset( $Config['ChmodOnFolderCreate'] ) && $Config['ChmodOnFolderCreate']) |
|
186 | - { |
|
187 | - $permissions = (string) $Config['ChmodOnFolderCreate']; |
|
188 | - } |
|
189 | - $permissionsdec = octdec($permissions); |
|
190 | - $permissionsdec |= octdec('0111'); // Set x bit required for directories |
|
191 | - dol_syslog("io.php permission = ".$permissions." ".$permissionsdec." ".decoct($permissionsdec)); |
|
192 | - // To create the folder with 0777 permissions, we need to set umask to zero. |
|
193 | - $oldumask = umask(0); |
|
194 | - mkdir($folderPath, $permissionsdec); |
|
195 | - umask($oldumask); |
|
196 | - } |
|
197 | - |
|
198 | - $sErrorMsg = $php_errormsg ; |
|
199 | - |
|
200 | - // Restore the configurations. |
|
201 | - ini_restore('track_errors'); |
|
202 | - ini_restore('error_reporting'); |
|
203 | - |
|
204 | - return $sErrorMsg ; |
|
205 | - } |
|
206 | - else |
|
207 | - return '' ; |
|
147 | + global $Config ; |
|
148 | + $sParent = GetParentFolder($folderPath); |
|
149 | + |
|
150 | + // Ensure the folder path has no double-slashes, or mkdir may fail on certain platforms |
|
151 | + while ( strpos($folderPath, '//') !== false ) |
|
152 | + { |
|
153 | + $folderPath = str_replace('//', '/', $folderPath); |
|
154 | + } |
|
155 | + |
|
156 | + // Check if the parent exists, or create it. |
|
157 | + if ( !empty($sParent) && !file_exists($sParent)) |
|
158 | + { |
|
159 | + //prevents agains infinite loop when we can't create root folder |
|
160 | + if ( !is_null($lastFolder) && $lastFolder === $sParent) { |
|
161 | + return "Can't create $folderPath directory" ; |
|
162 | + } |
|
163 | + |
|
164 | + $sErrorMsg = CreateServerFolder($sParent, $folderPath); |
|
165 | + if ( $sErrorMsg != '' ) |
|
166 | + return $sErrorMsg ; |
|
167 | + } |
|
168 | + |
|
169 | + if ( !file_exists($folderPath)) |
|
170 | + { |
|
171 | + // Turn off all error reporting. |
|
172 | + error_reporting(0); |
|
173 | + |
|
174 | + $php_errormsg = '' ; |
|
175 | + // Enable error tracking to catch the error. |
|
176 | + ini_set('track_errors', '1'); |
|
177 | + |
|
178 | + if ( isset( $Config['ChmodOnFolderCreate'] ) && !$Config['ChmodOnFolderCreate'] ) |
|
179 | + { |
|
180 | + mkdir($folderPath); |
|
181 | + } |
|
182 | + else |
|
183 | + { |
|
184 | + $permissions = '0777'; |
|
185 | + if ( isset( $Config['ChmodOnFolderCreate'] ) && $Config['ChmodOnFolderCreate']) |
|
186 | + { |
|
187 | + $permissions = (string) $Config['ChmodOnFolderCreate']; |
|
188 | + } |
|
189 | + $permissionsdec = octdec($permissions); |
|
190 | + $permissionsdec |= octdec('0111'); // Set x bit required for directories |
|
191 | + dol_syslog("io.php permission = ".$permissions." ".$permissionsdec." ".decoct($permissionsdec)); |
|
192 | + // To create the folder with 0777 permissions, we need to set umask to zero. |
|
193 | + $oldumask = umask(0); |
|
194 | + mkdir($folderPath, $permissionsdec); |
|
195 | + umask($oldumask); |
|
196 | + } |
|
197 | + |
|
198 | + $sErrorMsg = $php_errormsg ; |
|
199 | + |
|
200 | + // Restore the configurations. |
|
201 | + ini_restore('track_errors'); |
|
202 | + ini_restore('error_reporting'); |
|
203 | + |
|
204 | + return $sErrorMsg ; |
|
205 | + } |
|
206 | + else |
|
207 | + return '' ; |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
@@ -260,18 +260,18 @@ discard block |
||
260 | 260 | */ |
261 | 261 | function IsAllowedExt($sExtension, $resourceType) |
262 | 262 | { |
263 | - global $Config ; |
|
264 | - // Get the allowed and denied extensions arrays. |
|
265 | - $arAllowed = $Config['AllowedExtensions'][$resourceType] ; |
|
266 | - $arDenied = $Config['DeniedExtensions'][$resourceType] ; |
|
263 | + global $Config ; |
|
264 | + // Get the allowed and denied extensions arrays. |
|
265 | + $arAllowed = $Config['AllowedExtensions'][$resourceType] ; |
|
266 | + $arDenied = $Config['DeniedExtensions'][$resourceType] ; |
|
267 | 267 | |
268 | - if ( count($arAllowed) > 0 && !in_array($sExtension, $arAllowed)) |
|
269 | - return false ; |
|
268 | + if ( count($arAllowed) > 0 && !in_array($sExtension, $arAllowed)) |
|
269 | + return false ; |
|
270 | 270 | |
271 | - if ( count($arDenied) > 0 && in_array($sExtension, $arDenied)) |
|
272 | - return false ; |
|
271 | + if ( count($arDenied) > 0 && in_array($sExtension, $arDenied)) |
|
272 | + return false ; |
|
273 | 273 | |
274 | - return true ; |
|
274 | + return true ; |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | /** |
@@ -282,11 +282,11 @@ discard block |
||
282 | 282 | */ |
283 | 283 | function IsAllowedType($resourceType) |
284 | 284 | { |
285 | - global $Config ; |
|
286 | - if ( !in_array($resourceType, $Config['ConfigAllowedTypes'])) |
|
287 | - return false ; |
|
285 | + global $Config ; |
|
286 | + if ( !in_array($resourceType, $Config['ConfigAllowedTypes'])) |
|
287 | + return false ; |
|
288 | 288 | |
289 | - return true ; |
|
289 | + return true ; |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |
@@ -297,12 +297,12 @@ discard block |
||
297 | 297 | */ |
298 | 298 | function IsAllowedCommand($sCommand) |
299 | 299 | { |
300 | - global $Config ; |
|
300 | + global $Config ; |
|
301 | 301 | |
302 | - if (! in_array($sCommand, $Config['ConfigAllowedCommands'])) |
|
303 | - return false ; |
|
302 | + if (! in_array($sCommand, $Config['ConfigAllowedCommands'])) |
|
303 | + return false ; |
|
304 | 304 | |
305 | - return true ; |
|
305 | + return true ; |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | /** |
@@ -312,79 +312,79 @@ discard block |
||
312 | 312 | */ |
313 | 313 | function GetCurrentFolder() |
314 | 314 | { |
315 | - if (!isset($_GET)) { |
|
316 | - global $_GET; |
|
317 | - } |
|
318 | - $sCurrentFolder = isset( $_GET['CurrentFolder'] ) ? GETPOST('CurrentFolder', '', 1) : '/' ; |
|
319 | - |
|
320 | - // Check the current folder syntax (must begin and start with a slash). |
|
321 | - if (!preg_match('|/$|', $sCurrentFolder)) |
|
322 | - $sCurrentFolder .= '/' ; |
|
323 | - if (strpos($sCurrentFolder, '/') !== 0) |
|
324 | - $sCurrentFolder = '/' . $sCurrentFolder ; |
|
325 | - |
|
326 | - // Ensure the folder path has no double-slashes |
|
327 | - while ( strpos($sCurrentFolder, '//') !== false ) { |
|
328 | - $sCurrentFolder = str_replace('//', '/', $sCurrentFolder); |
|
329 | - } |
|
330 | - |
|
331 | - // Check for invalid folder paths (..) |
|
332 | - if ( strpos($sCurrentFolder, '..') || strpos($sCurrentFolder, "\\")) |
|
333 | - SendError(102, ''); |
|
334 | - |
|
335 | - if ( preg_match(",(/\.)|[[:cntrl:]]|(//)|(\\\\)|([\:\*\?\"\<\>\|]),", $sCurrentFolder)) |
|
336 | - SendError(102, ''); |
|
337 | - |
|
338 | - return $sCurrentFolder ; |
|
315 | + if (!isset($_GET)) { |
|
316 | + global $_GET; |
|
317 | + } |
|
318 | + $sCurrentFolder = isset( $_GET['CurrentFolder'] ) ? GETPOST('CurrentFolder', '', 1) : '/' ; |
|
319 | + |
|
320 | + // Check the current folder syntax (must begin and start with a slash). |
|
321 | + if (!preg_match('|/$|', $sCurrentFolder)) |
|
322 | + $sCurrentFolder .= '/' ; |
|
323 | + if (strpos($sCurrentFolder, '/') !== 0) |
|
324 | + $sCurrentFolder = '/' . $sCurrentFolder ; |
|
325 | + |
|
326 | + // Ensure the folder path has no double-slashes |
|
327 | + while ( strpos($sCurrentFolder, '//') !== false ) { |
|
328 | + $sCurrentFolder = str_replace('//', '/', $sCurrentFolder); |
|
329 | + } |
|
330 | + |
|
331 | + // Check for invalid folder paths (..) |
|
332 | + if ( strpos($sCurrentFolder, '..') || strpos($sCurrentFolder, "\\")) |
|
333 | + SendError(102, ''); |
|
334 | + |
|
335 | + if ( preg_match(",(/\.)|[[:cntrl:]]|(//)|(\\\\)|([\:\*\?\"\<\>\|]),", $sCurrentFolder)) |
|
336 | + SendError(102, ''); |
|
337 | + |
|
338 | + return $sCurrentFolder ; |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | // Do a cleanup of the folder name to avoid possible problems |
342 | 342 | function SanitizeFolderName( $sNewFolderName ) |
343 | 343 | { |
344 | - $sNewFolderName = stripslashes($sNewFolderName); |
|
344 | + $sNewFolderName = stripslashes($sNewFolderName); |
|
345 | 345 | |
346 | - // Remove . \ / | : ? * " < > |
|
347 | - $sNewFolderName = preg_replace('/\\.|\\\\|\\/|\\||\\:|\\?|\\*|"|<|>|[[:cntrl:]]/', '_', $sNewFolderName); |
|
346 | + // Remove . \ / | : ? * " < > |
|
347 | + $sNewFolderName = preg_replace('/\\.|\\\\|\\/|\\||\\:|\\?|\\*|"|<|>|[[:cntrl:]]/', '_', $sNewFolderName); |
|
348 | 348 | |
349 | - return $sNewFolderName ; |
|
349 | + return $sNewFolderName ; |
|
350 | 350 | } |
351 | 351 | |
352 | 352 | // Do a cleanup of the file name to avoid possible problems |
353 | 353 | function SanitizeFileName( $sNewFileName ) |
354 | 354 | { |
355 | - global $Config ; |
|
355 | + global $Config ; |
|
356 | 356 | |
357 | - $sNewFileName = stripslashes($sNewFileName); |
|
357 | + $sNewFileName = stripslashes($sNewFileName); |
|
358 | 358 | |
359 | - // Replace dots in the name with underscores (only one dot can be there... security issue). |
|
360 | - if ( $Config['ForceSingleExtension'] ) |
|
361 | - $sNewFileName = preg_replace('/\\.(?![^.]*$)/', '_', $sNewFileName); |
|
359 | + // Replace dots in the name with underscores (only one dot can be there... security issue). |
|
360 | + if ( $Config['ForceSingleExtension'] ) |
|
361 | + $sNewFileName = preg_replace('/\\.(?![^.]*$)/', '_', $sNewFileName); |
|
362 | 362 | |
363 | - // Remove \ / | : ? * " < > |
|
364 | - $sNewFileName = preg_replace('/\\\\|\\/|\\||\\:|\\?|\\*|"|<|>|[[:cntrl:]]/', '_', $sNewFileName); |
|
363 | + // Remove \ / | : ? * " < > |
|
364 | + $sNewFileName = preg_replace('/\\\\|\\/|\\||\\:|\\?|\\*|"|<|>|[[:cntrl:]]/', '_', $sNewFileName); |
|
365 | 365 | |
366 | - return $sNewFileName ; |
|
366 | + return $sNewFileName ; |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | // This is the function that sends the results of the uploading process. |
370 | 370 | function SendUploadResults( $errorNumber, $fileUrl = '', $fileName = '', $customMsg = '' ) |
371 | 371 | { |
372 | - // Minified version of the document.domain automatic fix script (#1919). |
|
373 | - // The original script can be found at _dev/domain_fix_template.js |
|
374 | - echo <<<EOF |
|
372 | + // Minified version of the document.domain automatic fix script (#1919). |
|
373 | + // The original script can be found at _dev/domain_fix_template.js |
|
374 | + echo <<<EOF |
|
375 | 375 | <script type="text/javascript"> |
376 | 376 | (function(){var d=document.domain;while (true){try{var A=window.parent.document.domain;break;}catch(e) {};d=d.replace(/.*?(?:\.|$)/,'');if (d.length==0) break;try{document.domain=d;}catch (e){break;}}})(); |
377 | 377 | EOF; |
378 | 378 | |
379 | - if ($errorNumber && $errorNumber != 201) { |
|
380 | - $fileUrl = ""; |
|
381 | - $fileName = ""; |
|
382 | - } |
|
379 | + if ($errorNumber && $errorNumber != 201) { |
|
380 | + $fileUrl = ""; |
|
381 | + $fileName = ""; |
|
382 | + } |
|
383 | 383 | |
384 | - $rpl = array( '\\' => '\\\\', '"' => '\\"' ); |
|
385 | - echo 'window.parent.OnUploadCompleted(' . $errorNumber . ',"' . strtr($fileUrl, $rpl) . '","' . strtr($fileName, $rpl) . '", "' . strtr($customMsg, $rpl) . '");' ; |
|
386 | - echo '</script>' ; |
|
387 | - exit ; |
|
384 | + $rpl = array( '\\' => '\\\\', '"' => '\\"' ); |
|
385 | + echo 'window.parent.OnUploadCompleted(' . $errorNumber . ',"' . strtr($fileUrl, $rpl) . '","' . strtr($fileName, $rpl) . '", "' . strtr($customMsg, $rpl) . '");' ; |
|
386 | + echo '</script>' ; |
|
387 | + exit ; |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | |
@@ -401,11 +401,11 @@ discard block |
||
401 | 401 | */ |
402 | 402 | function SendCKEditorResults($callback, $sFileUrl, $customMsg = '') |
403 | 403 | { |
404 | - echo '<script type="text/javascript">'; |
|
404 | + echo '<script type="text/javascript">'; |
|
405 | 405 | |
406 | - $rpl = array( '\\' => '\\\\', '"' => '\\"' ); |
|
406 | + $rpl = array( '\\' => '\\\\', '"' => '\\"' ); |
|
407 | 407 | |
408 | - echo 'window.parent.CKEDITOR.tools.callFunction("'. $callback. '","'. strtr($sFileUrl, $rpl). '", "'. strtr($customMsg, $rpl). '");' ; |
|
408 | + echo 'window.parent.CKEDITOR.tools.callFunction("'. $callback. '","'. strtr($sFileUrl, $rpl). '", "'. strtr($customMsg, $rpl). '");' ; |
|
409 | 409 | |
410 | - echo '</script>'; |
|
410 | + echo '</script>'; |
|
411 | 411 | } |
@@ -31,33 +31,33 @@ discard block |
||
31 | 31 | */ |
32 | 32 | function GetFolders($resourceType, $currentFolder) |
33 | 33 | { |
34 | - // Map the virtual path to the local server path. |
|
35 | - $sServerDir = ServerMapFolder($resourceType, $currentFolder, 'GetFolders'); |
|
34 | + // Map the virtual path to the local server path. |
|
35 | + $sServerDir = ServerMapFolder($resourceType, $currentFolder, 'GetFolders'); |
|
36 | 36 | |
37 | - // Array that will hold the folders names. |
|
38 | - $aFolders = array(); |
|
37 | + // Array that will hold the folders names. |
|
38 | + $aFolders = array(); |
|
39 | 39 | |
40 | - $oCurrentFolder = @opendir($sServerDir); |
|
40 | + $oCurrentFolder = @opendir($sServerDir); |
|
41 | 41 | |
42 | - if ($oCurrentFolder !== false) |
|
43 | - { |
|
44 | - while ( $sFile = readdir($oCurrentFolder) ) |
|
45 | - { |
|
46 | - if ( $sFile != '.' && $sFile != '..' && is_dir($sServerDir . $sFile) ) |
|
47 | - $aFolders[] = '<Folder name="' . ConvertToXmlAttribute($sFile) . '" />' ; |
|
48 | - } |
|
49 | - closedir($oCurrentFolder); |
|
50 | - } |
|
42 | + if ($oCurrentFolder !== false) |
|
43 | + { |
|
44 | + while ( $sFile = readdir($oCurrentFolder) ) |
|
45 | + { |
|
46 | + if ( $sFile != '.' && $sFile != '..' && is_dir($sServerDir . $sFile) ) |
|
47 | + $aFolders[] = '<Folder name="' . ConvertToXmlAttribute($sFile) . '" />' ; |
|
48 | + } |
|
49 | + closedir($oCurrentFolder); |
|
50 | + } |
|
51 | 51 | |
52 | - // Open the "Folders" node. |
|
53 | - echo "<Folders>" ; |
|
52 | + // Open the "Folders" node. |
|
53 | + echo "<Folders>" ; |
|
54 | 54 | |
55 | - natcasesort($aFolders); |
|
56 | - foreach ( $aFolders as $sFolder ) |
|
57 | - echo $sFolder ; |
|
55 | + natcasesort($aFolders); |
|
56 | + foreach ( $aFolders as $sFolder ) |
|
57 | + echo $sFolder ; |
|
58 | 58 | |
59 | - // Close the "Folders" node. |
|
60 | - echo "</Folders>" ; |
|
59 | + // Close the "Folders" node. |
|
60 | + echo "</Folders>" ; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -69,60 +69,60 @@ discard block |
||
69 | 69 | */ |
70 | 70 | function GetFoldersAndFiles( $resourceType, $currentFolder ) |
71 | 71 | { |
72 | - // Map the virtual path to the local server path. |
|
73 | - $sServerDir = ServerMapFolder($resourceType, $currentFolder, 'GetFoldersAndFiles'); |
|
74 | - |
|
75 | - // Arrays that will hold the folders and files names. |
|
76 | - $aFolders = array(); |
|
77 | - $aFiles = array(); |
|
78 | - |
|
79 | - $oCurrentFolder = @opendir($sServerDir); |
|
80 | - |
|
81 | - if ($oCurrentFolder !== false) |
|
82 | - { |
|
83 | - while ( $sFile = readdir($oCurrentFolder) ) |
|
84 | - { |
|
85 | - if ( $sFile != '.' && $sFile != '..' ) |
|
86 | - { |
|
87 | - if ( is_dir($sServerDir . $sFile) ) |
|
88 | - $aFolders[] = '<Folder name="' . ConvertToXmlAttribute($sFile) . '" />' ; |
|
89 | - else |
|
90 | - { |
|
91 | - $iFileSize = @filesize($sServerDir . $sFile); |
|
92 | - if ( !$iFileSize ) { |
|
93 | - $iFileSize = 0 ; |
|
94 | - } |
|
95 | - if ( $iFileSize > 0 ) |
|
96 | - { |
|
97 | - $iFileSize = round($iFileSize / 1024); |
|
98 | - if ( $iFileSize < 1 ) |
|
99 | - $iFileSize = 1 ; |
|
100 | - } |
|
101 | - |
|
102 | - $aFiles[] = '<File name="' . ConvertToXmlAttribute($sFile) . '" size="' . $iFileSize . '" />' ; |
|
103 | - } |
|
104 | - } |
|
105 | - } |
|
106 | - closedir($oCurrentFolder); |
|
107 | - } |
|
108 | - |
|
109 | - // Send the folders |
|
110 | - natcasesort($aFolders); |
|
111 | - echo '<Folders>' ; |
|
112 | - |
|
113 | - foreach ( $aFolders as $sFolder ) |
|
114 | - echo $sFolder ; |
|
115 | - |
|
116 | - echo '</Folders>' ; |
|
117 | - |
|
118 | - // Send the files |
|
119 | - natcasesort($aFiles); |
|
120 | - echo '<Files>' ; |
|
121 | - |
|
122 | - foreach ( $aFiles as $sFiles ) |
|
123 | - echo $sFiles ; |
|
124 | - |
|
125 | - echo '</Files>' ; |
|
72 | + // Map the virtual path to the local server path. |
|
73 | + $sServerDir = ServerMapFolder($resourceType, $currentFolder, 'GetFoldersAndFiles'); |
|
74 | + |
|
75 | + // Arrays that will hold the folders and files names. |
|
76 | + $aFolders = array(); |
|
77 | + $aFiles = array(); |
|
78 | + |
|
79 | + $oCurrentFolder = @opendir($sServerDir); |
|
80 | + |
|
81 | + if ($oCurrentFolder !== false) |
|
82 | + { |
|
83 | + while ( $sFile = readdir($oCurrentFolder) ) |
|
84 | + { |
|
85 | + if ( $sFile != '.' && $sFile != '..' ) |
|
86 | + { |
|
87 | + if ( is_dir($sServerDir . $sFile) ) |
|
88 | + $aFolders[] = '<Folder name="' . ConvertToXmlAttribute($sFile) . '" />' ; |
|
89 | + else |
|
90 | + { |
|
91 | + $iFileSize = @filesize($sServerDir . $sFile); |
|
92 | + if ( !$iFileSize ) { |
|
93 | + $iFileSize = 0 ; |
|
94 | + } |
|
95 | + if ( $iFileSize > 0 ) |
|
96 | + { |
|
97 | + $iFileSize = round($iFileSize / 1024); |
|
98 | + if ( $iFileSize < 1 ) |
|
99 | + $iFileSize = 1 ; |
|
100 | + } |
|
101 | + |
|
102 | + $aFiles[] = '<File name="' . ConvertToXmlAttribute($sFile) . '" size="' . $iFileSize . '" />' ; |
|
103 | + } |
|
104 | + } |
|
105 | + } |
|
106 | + closedir($oCurrentFolder); |
|
107 | + } |
|
108 | + |
|
109 | + // Send the folders |
|
110 | + natcasesort($aFolders); |
|
111 | + echo '<Folders>' ; |
|
112 | + |
|
113 | + foreach ( $aFolders as $sFolder ) |
|
114 | + echo $sFolder ; |
|
115 | + |
|
116 | + echo '</Folders>' ; |
|
117 | + |
|
118 | + // Send the files |
|
119 | + natcasesort($aFiles); |
|
120 | + echo '<Files>' ; |
|
121 | + |
|
122 | + foreach ( $aFiles as $sFiles ) |
|
123 | + echo $sFiles ; |
|
124 | + |
|
125 | + echo '</Files>' ; |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -134,53 +134,53 @@ discard block |
||
134 | 134 | */ |
135 | 135 | function CreateFolder( $resourceType, $currentFolder ) |
136 | 136 | { |
137 | - if (!isset($_GET)) { |
|
138 | - global $_GET; |
|
139 | - } |
|
140 | - $sErrorNumber = '0' ; |
|
141 | - $sErrorMsg = '' ; |
|
142 | - |
|
143 | - if ( isset( $_GET['NewFolderName'] ) ) |
|
144 | - { |
|
145 | - $sNewFolderName = $_GET['NewFolderName'] ; |
|
146 | - $sNewFolderName = SanitizeFolderName($sNewFolderName); |
|
147 | - |
|
148 | - if (strpos($sNewFolderName, '..') !== false) |
|
149 | - $sErrorNumber = '102' ; // Invalid folder name. |
|
150 | - else |
|
151 | - { |
|
152 | - // Map the virtual path to the local server path of the current folder. |
|
153 | - $sServerDir = ServerMapFolder($resourceType, $currentFolder, 'CreateFolder'); |
|
154 | - |
|
155 | - if ( is_writable($sServerDir) ) |
|
156 | - { |
|
157 | - $sServerDir .= $sNewFolderName ; |
|
158 | - |
|
159 | - $sErrorMsg = CreateServerFolder($sServerDir); |
|
160 | - |
|
161 | - switch ( $sErrorMsg ) |
|
162 | - { |
|
163 | - case '': |
|
164 | - $sErrorNumber = '0' ; |
|
165 | - break; |
|
166 | - case 'Invalid argument' : |
|
167 | - case 'No such file or directory' : |
|
168 | - $sErrorNumber = '102' ; // Path too long. |
|
169 | - break ; |
|
170 | - default: |
|
171 | - $sErrorNumber = '110' ; |
|
172 | - break ; |
|
173 | - } |
|
174 | - } |
|
175 | - else |
|
176 | - $sErrorNumber = '103' ; |
|
177 | - } |
|
178 | - } |
|
179 | - else |
|
180 | - $sErrorNumber = '102' ; |
|
181 | - |
|
182 | - // Create the "Error" node. |
|
183 | - echo '<Error number="' . $sErrorNumber . '" />' ; |
|
137 | + if (!isset($_GET)) { |
|
138 | + global $_GET; |
|
139 | + } |
|
140 | + $sErrorNumber = '0' ; |
|
141 | + $sErrorMsg = '' ; |
|
142 | + |
|
143 | + if ( isset( $_GET['NewFolderName'] ) ) |
|
144 | + { |
|
145 | + $sNewFolderName = $_GET['NewFolderName'] ; |
|
146 | + $sNewFolderName = SanitizeFolderName($sNewFolderName); |
|
147 | + |
|
148 | + if (strpos($sNewFolderName, '..') !== false) |
|
149 | + $sErrorNumber = '102' ; // Invalid folder name. |
|
150 | + else |
|
151 | + { |
|
152 | + // Map the virtual path to the local server path of the current folder. |
|
153 | + $sServerDir = ServerMapFolder($resourceType, $currentFolder, 'CreateFolder'); |
|
154 | + |
|
155 | + if ( is_writable($sServerDir) ) |
|
156 | + { |
|
157 | + $sServerDir .= $sNewFolderName ; |
|
158 | + |
|
159 | + $sErrorMsg = CreateServerFolder($sServerDir); |
|
160 | + |
|
161 | + switch ( $sErrorMsg ) |
|
162 | + { |
|
163 | + case '': |
|
164 | + $sErrorNumber = '0' ; |
|
165 | + break; |
|
166 | + case 'Invalid argument' : |
|
167 | + case 'No such file or directory' : |
|
168 | + $sErrorNumber = '102' ; // Path too long. |
|
169 | + break ; |
|
170 | + default: |
|
171 | + $sErrorNumber = '110' ; |
|
172 | + break ; |
|
173 | + } |
|
174 | + } |
|
175 | + else |
|
176 | + $sErrorNumber = '103' ; |
|
177 | + } |
|
178 | + } |
|
179 | + else |
|
180 | + $sErrorNumber = '102' ; |
|
181 | + |
|
182 | + // Create the "Error" node. |
|
183 | + echo '<Error number="' . $sErrorNumber . '" />' ; |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | // @CHANGE |
@@ -196,134 +196,134 @@ discard block |
||
196 | 196 | */ |
197 | 197 | function FileUpload($resourceType, $currentFolder, $sCommand, $CKEcallback = '') |
198 | 198 | { |
199 | - if (!isset($_FILES)) { |
|
200 | - global $_FILES; |
|
201 | - } |
|
202 | - $sErrorNumber = '0' ; |
|
203 | - $sFileName = '' ; |
|
204 | - |
|
205 | - if ( isset( $_FILES['NewFile'] ) && !is_null($_FILES['NewFile']['tmp_name']) |
|
206 | - // This is for the QuickUpload tab box |
|
199 | + if (!isset($_FILES)) { |
|
200 | + global $_FILES; |
|
201 | + } |
|
202 | + $sErrorNumber = '0' ; |
|
203 | + $sFileName = '' ; |
|
204 | + |
|
205 | + if ( isset( $_FILES['NewFile'] ) && !is_null($_FILES['NewFile']['tmp_name']) |
|
206 | + // This is for the QuickUpload tab box |
|
207 | 207 | or (isset($_FILES['upload']) && !is_null($_FILES['upload']['tmp_name']))) |
208 | - { |
|
209 | - global $Config ; |
|
210 | - |
|
211 | - $oFile = isset($_FILES['NewFile']) ? $_FILES['NewFile'] : $_FILES['upload']; |
|
212 | - |
|
213 | - // Map the virtual path to the local server path. |
|
214 | - $sServerDir = ServerMapFolder($resourceType, $currentFolder, $sCommand); |
|
215 | - |
|
216 | - // Get the uploaded file name. |
|
217 | - $sFileName = $oFile['name'] ; |
|
218 | - $sFileName = SanitizeFileName($sFileName); |
|
219 | - |
|
220 | - $sOriginalFileName = $sFileName ; |
|
221 | - |
|
222 | - // Get the extension. |
|
223 | - $sExtension = substr($sFileName, (strrpos($sFileName, '.') + 1)); |
|
224 | - $sExtension = strtolower($sExtension); |
|
225 | - |
|
226 | - if ( isset( $Config['SecureImageUploads'] ) ) |
|
227 | - { |
|
228 | - if ( ( $isImageValid = IsImageValid($oFile['tmp_name'], $sExtension) ) === false ) |
|
229 | - { |
|
230 | - $sErrorNumber = '202' ; |
|
231 | - } |
|
232 | - } |
|
233 | - |
|
234 | - if ( isset( $Config['HtmlExtensions'] ) ) |
|
235 | - { |
|
236 | - if (!IsHtmlExtension($sExtension, $Config['HtmlExtensions']) && |
|
237 | - ($detectHtml = DetectHtml($oFile['tmp_name'])) === true) |
|
238 | - { |
|
239 | - $sErrorNumber = '202' ; |
|
240 | - } |
|
241 | - } |
|
242 | - |
|
243 | - // Check if it is an allowed extension. |
|
244 | - if ( !$sErrorNumber && IsAllowedExt($sExtension, $resourceType) ) |
|
245 | - { |
|
246 | - $iCounter = 0 ; |
|
247 | - |
|
248 | - while ( true ) |
|
249 | - { |
|
250 | - $sFilePath = $sServerDir . $sFileName ; |
|
251 | - |
|
252 | - if ( is_file($sFilePath) ) |
|
253 | - { |
|
254 | - $iCounter++ ; |
|
255 | - $sFileName = RemoveExtension($sOriginalFileName) . '(' . $iCounter . ').' . $sExtension ; |
|
256 | - $sErrorNumber = '201' ; |
|
257 | - } |
|
258 | - else |
|
259 | - { |
|
260 | - move_uploaded_file($oFile['tmp_name'], $sFilePath); |
|
261 | - |
|
262 | - if ( is_file($sFilePath) ) |
|
263 | - { |
|
264 | - if ( isset( $Config['ChmodOnUpload'] ) && !$Config['ChmodOnUpload'] ) |
|
265 | - { |
|
266 | - break ; |
|
267 | - } |
|
268 | - |
|
269 | - $permissions = '0777'; |
|
270 | - if ( isset( $Config['ChmodOnUpload'] ) && $Config['ChmodOnUpload'] ) |
|
271 | - { |
|
272 | - $permissions = (string) $Config['ChmodOnUpload'] ; |
|
273 | - } |
|
274 | - $permissionsdec = octdec($permissions); |
|
275 | - dol_syslog("commands.php permission = ".$permissions." ".$permissionsdec." ".decoct($permissionsdec)); |
|
276 | - $oldumask = umask(0); |
|
277 | - chmod($sFilePath, $permissionsdec); |
|
278 | - umask($oldumask); |
|
279 | - } |
|
280 | - |
|
281 | - break ; |
|
282 | - } |
|
283 | - } |
|
284 | - |
|
285 | - if ( file_exists($sFilePath) ) |
|
286 | - { |
|
287 | - //previous checks failed, try once again |
|
288 | - if ( isset( $isImageValid ) && $isImageValid === -1 && IsImageValid($sFilePath, $sExtension) === false ) |
|
289 | - { |
|
290 | - @unlink($sFilePath); |
|
291 | - $sErrorNumber = '202' ; |
|
292 | - } |
|
293 | - else if ( isset( $detectHtml ) && $detectHtml === -1 && DetectHtml($sFilePath) === true ) |
|
294 | - { |
|
295 | - @unlink($sFilePath); |
|
296 | - $sErrorNumber = '202' ; |
|
297 | - } |
|
298 | - } |
|
299 | - } |
|
300 | - else |
|
301 | - $sErrorNumber = '202' ; |
|
302 | - } |
|
303 | - else |
|
304 | - $sErrorNumber = '202' ; |
|
305 | - |
|
306 | - |
|
307 | - $sFileUrl = CombinePaths(GetResourceTypePath($resourceType, $sCommand), $currentFolder); |
|
308 | - $sFileUrl = CombinePaths($sFileUrl, $sFileName); |
|
309 | - |
|
310 | - |
|
311 | - // @CHANGE |
|
312 | - //SendUploadResults( $sErrorNumber, $sFileUrl, $sFileName ); |
|
313 | - if($CKEcallback == '') |
|
208 | + { |
|
209 | + global $Config ; |
|
210 | + |
|
211 | + $oFile = isset($_FILES['NewFile']) ? $_FILES['NewFile'] : $_FILES['upload']; |
|
212 | + |
|
213 | + // Map the virtual path to the local server path. |
|
214 | + $sServerDir = ServerMapFolder($resourceType, $currentFolder, $sCommand); |
|
215 | + |
|
216 | + // Get the uploaded file name. |
|
217 | + $sFileName = $oFile['name'] ; |
|
218 | + $sFileName = SanitizeFileName($sFileName); |
|
219 | + |
|
220 | + $sOriginalFileName = $sFileName ; |
|
221 | + |
|
222 | + // Get the extension. |
|
223 | + $sExtension = substr($sFileName, (strrpos($sFileName, '.') + 1)); |
|
224 | + $sExtension = strtolower($sExtension); |
|
225 | + |
|
226 | + if ( isset( $Config['SecureImageUploads'] ) ) |
|
227 | + { |
|
228 | + if ( ( $isImageValid = IsImageValid($oFile['tmp_name'], $sExtension) ) === false ) |
|
229 | + { |
|
230 | + $sErrorNumber = '202' ; |
|
231 | + } |
|
232 | + } |
|
233 | + |
|
234 | + if ( isset( $Config['HtmlExtensions'] ) ) |
|
235 | + { |
|
236 | + if (!IsHtmlExtension($sExtension, $Config['HtmlExtensions']) && |
|
237 | + ($detectHtml = DetectHtml($oFile['tmp_name'])) === true) |
|
238 | + { |
|
239 | + $sErrorNumber = '202' ; |
|
240 | + } |
|
241 | + } |
|
242 | + |
|
243 | + // Check if it is an allowed extension. |
|
244 | + if ( !$sErrorNumber && IsAllowedExt($sExtension, $resourceType) ) |
|
245 | + { |
|
246 | + $iCounter = 0 ; |
|
247 | + |
|
248 | + while ( true ) |
|
249 | + { |
|
250 | + $sFilePath = $sServerDir . $sFileName ; |
|
251 | + |
|
252 | + if ( is_file($sFilePath) ) |
|
253 | + { |
|
254 | + $iCounter++ ; |
|
255 | + $sFileName = RemoveExtension($sOriginalFileName) . '(' . $iCounter . ').' . $sExtension ; |
|
256 | + $sErrorNumber = '201' ; |
|
257 | + } |
|
258 | + else |
|
259 | + { |
|
260 | + move_uploaded_file($oFile['tmp_name'], $sFilePath); |
|
261 | + |
|
262 | + if ( is_file($sFilePath) ) |
|
263 | + { |
|
264 | + if ( isset( $Config['ChmodOnUpload'] ) && !$Config['ChmodOnUpload'] ) |
|
265 | + { |
|
266 | + break ; |
|
267 | + } |
|
268 | + |
|
269 | + $permissions = '0777'; |
|
270 | + if ( isset( $Config['ChmodOnUpload'] ) && $Config['ChmodOnUpload'] ) |
|
271 | + { |
|
272 | + $permissions = (string) $Config['ChmodOnUpload'] ; |
|
273 | + } |
|
274 | + $permissionsdec = octdec($permissions); |
|
275 | + dol_syslog("commands.php permission = ".$permissions." ".$permissionsdec." ".decoct($permissionsdec)); |
|
276 | + $oldumask = umask(0); |
|
277 | + chmod($sFilePath, $permissionsdec); |
|
278 | + umask($oldumask); |
|
279 | + } |
|
280 | + |
|
281 | + break ; |
|
282 | + } |
|
283 | + } |
|
284 | + |
|
285 | + if ( file_exists($sFilePath) ) |
|
286 | + { |
|
287 | + //previous checks failed, try once again |
|
288 | + if ( isset( $isImageValid ) && $isImageValid === -1 && IsImageValid($sFilePath, $sExtension) === false ) |
|
289 | + { |
|
290 | + @unlink($sFilePath); |
|
291 | + $sErrorNumber = '202' ; |
|
292 | + } |
|
293 | + else if ( isset( $detectHtml ) && $detectHtml === -1 && DetectHtml($sFilePath) === true ) |
|
294 | + { |
|
295 | + @unlink($sFilePath); |
|
296 | + $sErrorNumber = '202' ; |
|
297 | + } |
|
298 | + } |
|
299 | + } |
|
300 | + else |
|
301 | + $sErrorNumber = '202' ; |
|
302 | + } |
|
303 | + else |
|
304 | + $sErrorNumber = '202' ; |
|
305 | + |
|
306 | + |
|
307 | + $sFileUrl = CombinePaths(GetResourceTypePath($resourceType, $sCommand), $currentFolder); |
|
308 | + $sFileUrl = CombinePaths($sFileUrl, $sFileName); |
|
309 | + |
|
310 | + |
|
311 | + // @CHANGE |
|
312 | + //SendUploadResults( $sErrorNumber, $sFileUrl, $sFileName ); |
|
313 | + if($CKEcallback == '') |
|
314 | 314 | { |
315 | 315 | // this line already exists so wrap the if block around it |
316 | 316 | SendUploadResults($sErrorNumber, $sFileUrl, $sFileName); |
317 | 317 | } |
318 | 318 | else |
319 | - { |
|
320 | - //issue the CKEditor Callback |
|
321 | - SendCKEditorResults( |
|
322 | - $CKEcallback, |
|
323 | - $sFileUrl, |
|
324 | - ($sErrorNumber != 0 ? 'Error '. $sErrorNumber. ' upload failed.' : 'Upload Successful') |
|
325 | - ); |
|
326 | - } |
|
327 | - |
|
328 | - exit; |
|
319 | + { |
|
320 | + //issue the CKEditor Callback |
|
321 | + SendCKEditorResults( |
|
322 | + $CKEcallback, |
|
323 | + $sFileUrl, |
|
324 | + ($sErrorNumber != 0 ? 'Error '. $sErrorNumber. ' upload failed.' : 'Upload Successful') |
|
325 | + ); |
|
326 | + } |
|
327 | + |
|
328 | + exit; |
|
329 | 329 | } |
@@ -31,8 +31,8 @@ discard block |
||
31 | 31 | */ |
32 | 32 | function RemoveFromStart($sourceString, $charToRemove) |
33 | 33 | { |
34 | - $sPattern = '|^' . $charToRemove . '+|' ; |
|
35 | - return preg_replace($sPattern, '', $sourceString); |
|
34 | + $sPattern = '|^' . $charToRemove . '+|' ; |
|
35 | + return preg_replace($sPattern, '', $sourceString); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | */ |
45 | 45 | function RemoveFromEnd($sourceString, $charToRemove) |
46 | 46 | { |
47 | - $sPattern = '|' . $charToRemove . '+$|' ; |
|
48 | - return preg_replace($sPattern, '', $sourceString); |
|
47 | + $sPattern = '|' . $charToRemove . '+$|' ; |
|
48 | + return preg_replace($sPattern, '', $sourceString); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -56,24 +56,24 @@ discard block |
||
56 | 56 | */ |
57 | 57 | function FindBadUtf8($string) |
58 | 58 | { |
59 | - $regex = '([\x00-\x7F]'. |
|
60 | - '|[\xC2-\xDF][\x80-\xBF]'. |
|
61 | - '|\xE0[\xA0-\xBF][\x80-\xBF]'. |
|
62 | - '|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}'. |
|
63 | - '|\xED[\x80-\x9F][\x80-\xBF]'. |
|
64 | - '|\xF0[\x90-\xBF][\x80-\xBF]{2}'. |
|
65 | - '|[\xF1-\xF3][\x80-\xBF]{3}'. |
|
66 | - '|\xF4[\x80-\x8F][\x80-\xBF]{2}'. |
|
67 | - '|(.{1}))'; |
|
68 | - |
|
69 | - while (preg_match('/'.$regex.'/S', $string, $matches)) { |
|
70 | - if ( isset($matches[2])) { |
|
71 | - return true; |
|
72 | - } |
|
73 | - $string = substr($string, strlen($matches[0])); |
|
74 | - } |
|
75 | - |
|
76 | - return false; |
|
59 | + $regex = '([\x00-\x7F]'. |
|
60 | + '|[\xC2-\xDF][\x80-\xBF]'. |
|
61 | + '|\xE0[\xA0-\xBF][\x80-\xBF]'. |
|
62 | + '|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}'. |
|
63 | + '|\xED[\x80-\x9F][\x80-\xBF]'. |
|
64 | + '|\xF0[\x90-\xBF][\x80-\xBF]{2}'. |
|
65 | + '|[\xF1-\xF3][\x80-\xBF]{3}'. |
|
66 | + '|\xF4[\x80-\x8F][\x80-\xBF]{2}'. |
|
67 | + '|(.{1}))'; |
|
68 | + |
|
69 | + while (preg_match('/'.$regex.'/S', $string, $matches)) { |
|
70 | + if ( isset($matches[2])) { |
|
71 | + return true; |
|
72 | + } |
|
73 | + $string = substr($string, strlen($matches[0])); |
|
74 | + } |
|
75 | + |
|
76 | + return false; |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -84,23 +84,23 @@ discard block |
||
84 | 84 | */ |
85 | 85 | function ConvertToXmlAttribute( $value ) |
86 | 86 | { |
87 | - if ( defined('PHP_OS') ) |
|
88 | - { |
|
89 | - $os = PHP_OS ; |
|
90 | - } |
|
91 | - else |
|
92 | - { |
|
93 | - $os = php_uname(); |
|
94 | - } |
|
95 | - |
|
96 | - if (strtoupper(substr($os, 0, 3)) === 'WIN' || FindBadUtf8($value)) |
|
97 | - { |
|
98 | - return (utf8_encode(htmlspecialchars($value))); |
|
99 | - } |
|
100 | - else |
|
101 | - { |
|
102 | - return (htmlspecialchars($value)); |
|
103 | - } |
|
87 | + if ( defined('PHP_OS') ) |
|
88 | + { |
|
89 | + $os = PHP_OS ; |
|
90 | + } |
|
91 | + else |
|
92 | + { |
|
93 | + $os = php_uname(); |
|
94 | + } |
|
95 | + |
|
96 | + if (strtoupper(substr($os, 0, 3)) === 'WIN' || FindBadUtf8($value)) |
|
97 | + { |
|
98 | + return (utf8_encode(htmlspecialchars($value))); |
|
99 | + } |
|
100 | + else |
|
101 | + { |
|
102 | + return (htmlspecialchars($value)); |
|
103 | + } |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
@@ -112,16 +112,16 @@ discard block |
||
112 | 112 | */ |
113 | 113 | function IsHtmlExtension( $ext, $formExtensions ) |
114 | 114 | { |
115 | - if (!$formExtensions || !is_array($formExtensions) ) |
|
116 | - { |
|
117 | - return false ; |
|
118 | - } |
|
119 | - $lcaseHtmlExtensions = array(); |
|
120 | - foreach ( $formExtensions as $key => $val ) |
|
121 | - { |
|
122 | - $lcaseHtmlExtensions[$key] = strtolower($val); |
|
123 | - } |
|
124 | - return in_array($ext, $lcaseHtmlExtensions); |
|
115 | + if (!$formExtensions || !is_array($formExtensions) ) |
|
116 | + { |
|
117 | + return false ; |
|
118 | + } |
|
119 | + $lcaseHtmlExtensions = array(); |
|
120 | + foreach ( $formExtensions as $key => $val ) |
|
121 | + { |
|
122 | + $lcaseHtmlExtensions[$key] = strtolower($val); |
|
123 | + } |
|
124 | + return in_array($ext, $lcaseHtmlExtensions); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -134,63 +134,63 @@ discard block |
||
134 | 134 | */ |
135 | 135 | function DetectHtml( $filePath ) |
136 | 136 | { |
137 | - $fp = @fopen($filePath, 'rb'); |
|
138 | - |
|
139 | - //open_basedir restriction, see #1906 |
|
140 | - if ( $fp === false || !flock($fp, LOCK_SH) ) |
|
141 | - { |
|
142 | - return -1 ; |
|
143 | - } |
|
144 | - |
|
145 | - $chunk = fread($fp, 1024); |
|
146 | - flock($fp, LOCK_UN); |
|
147 | - fclose($fp); |
|
148 | - |
|
149 | - $chunk = strtolower($chunk); |
|
150 | - |
|
151 | - if (!$chunk) |
|
152 | - { |
|
153 | - return false ; |
|
154 | - } |
|
155 | - |
|
156 | - $chunk = trim($chunk); |
|
157 | - |
|
158 | - if ( preg_match("/<!DOCTYPE\W*X?HTML/sim", $chunk) ) |
|
159 | - { |
|
160 | - return true; |
|
161 | - } |
|
162 | - |
|
163 | - $tags = array( '<body', '<head', '<html', '<img', '<pre', '<script', '<table', '<title' ); |
|
164 | - |
|
165 | - foreach( $tags as $tag ) |
|
166 | - { |
|
167 | - if( false !== strpos($chunk, $tag) ) |
|
168 | - { |
|
169 | - return true ; |
|
170 | - } |
|
171 | - } |
|
172 | - |
|
173 | - //type = javascript |
|
174 | - if ( preg_match('!type\s*=\s*[\'"]?\s*(?:\w*/)?(?:ecma|java)!sim', $chunk) ) |
|
175 | - { |
|
176 | - return true ; |
|
177 | - } |
|
178 | - |
|
179 | - //href = javascript |
|
180 | - //src = javascript |
|
181 | - //data = javascript |
|
182 | - if ( preg_match('!(?:href|src|data)\s*=\s*[\'"]?\s*(?:ecma|java)script:!sim', $chunk) ) |
|
183 | - { |
|
184 | - return true ; |
|
185 | - } |
|
186 | - |
|
187 | - //url(javascript |
|
188 | - if ( preg_match('!url\s*\(\s*[\'"]?\s*(?:ecma|java)script:!sim', $chunk) ) |
|
189 | - { |
|
190 | - return true ; |
|
191 | - } |
|
192 | - |
|
193 | - return false ; |
|
137 | + $fp = @fopen($filePath, 'rb'); |
|
138 | + |
|
139 | + //open_basedir restriction, see #1906 |
|
140 | + if ( $fp === false || !flock($fp, LOCK_SH) ) |
|
141 | + { |
|
142 | + return -1 ; |
|
143 | + } |
|
144 | + |
|
145 | + $chunk = fread($fp, 1024); |
|
146 | + flock($fp, LOCK_UN); |
|
147 | + fclose($fp); |
|
148 | + |
|
149 | + $chunk = strtolower($chunk); |
|
150 | + |
|
151 | + if (!$chunk) |
|
152 | + { |
|
153 | + return false ; |
|
154 | + } |
|
155 | + |
|
156 | + $chunk = trim($chunk); |
|
157 | + |
|
158 | + if ( preg_match("/<!DOCTYPE\W*X?HTML/sim", $chunk) ) |
|
159 | + { |
|
160 | + return true; |
|
161 | + } |
|
162 | + |
|
163 | + $tags = array( '<body', '<head', '<html', '<img', '<pre', '<script', '<table', '<title' ); |
|
164 | + |
|
165 | + foreach( $tags as $tag ) |
|
166 | + { |
|
167 | + if( false !== strpos($chunk, $tag) ) |
|
168 | + { |
|
169 | + return true ; |
|
170 | + } |
|
171 | + } |
|
172 | + |
|
173 | + //type = javascript |
|
174 | + if ( preg_match('!type\s*=\s*[\'"]?\s*(?:\w*/)?(?:ecma|java)!sim', $chunk) ) |
|
175 | + { |
|
176 | + return true ; |
|
177 | + } |
|
178 | + |
|
179 | + //href = javascript |
|
180 | + //src = javascript |
|
181 | + //data = javascript |
|
182 | + if ( preg_match('!(?:href|src|data)\s*=\s*[\'"]?\s*(?:ecma|java)script:!sim', $chunk) ) |
|
183 | + { |
|
184 | + return true ; |
|
185 | + } |
|
186 | + |
|
187 | + //url(javascript |
|
188 | + if ( preg_match('!url\s*\(\s*[\'"]?\s*(?:ecma|java)script:!sim', $chunk) ) |
|
189 | + { |
|
190 | + return true ; |
|
191 | + } |
|
192 | + |
|
193 | + return false ; |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | /** |
@@ -204,11 +204,11 @@ discard block |
||
204 | 204 | */ |
205 | 205 | function IsImageValid( $filePath, $extension ) |
206 | 206 | { |
207 | - if (!@is_readable($filePath)) { |
|
208 | - return -1; |
|
209 | - } |
|
207 | + if (!@is_readable($filePath)) { |
|
208 | + return -1; |
|
209 | + } |
|
210 | 210 | |
211 | - $imageCheckExtensions = array( |
|
211 | + $imageCheckExtensions = array( |
|
212 | 212 | 'gif', |
213 | 213 | 'jpeg', |
214 | 214 | 'jpg', |
@@ -228,14 +228,14 @@ discard block |
||
228 | 228 | 'wbmp' |
229 | 229 | ); |
230 | 230 | |
231 | - if (!in_array($extension, $imageCheckExtensions) ) { |
|
232 | - return true; |
|
233 | - } |
|
231 | + if (!in_array($extension, $imageCheckExtensions) ) { |
|
232 | + return true; |
|
233 | + } |
|
234 | 234 | |
235 | - if (@getimagesize($filePath) === false) { |
|
236 | - return false ; |
|
237 | - } |
|
235 | + if (@getimagesize($filePath) === false) { |
|
236 | + return false ; |
|
237 | + } |
|
238 | 238 | |
239 | - return true; |
|
239 | + return true; |
|
240 | 240 | } |
241 | 241 |
@@ -34,22 +34,22 @@ |
||
34 | 34 | */ |
35 | 35 | function import_prepare_head($param, $maxstep=0) |
36 | 36 | { |
37 | - global $langs; |
|
37 | + global $langs; |
|
38 | 38 | |
39 | - if (empty($maxstep)) $maxstep=6; |
|
39 | + if (empty($maxstep)) $maxstep=6; |
|
40 | 40 | |
41 | - $h=0; |
|
42 | - $head = array(); |
|
43 | - $i=1; |
|
44 | - while($i <= $maxstep) |
|
45 | - { |
|
46 | - $head[$h][0] = DOL_URL_ROOT.'/imports/import.php?step='.$i.$param; |
|
47 | - $head[$h][1] = $langs->trans("Step")." ".$i; |
|
48 | - $head[$h][2] = 'step'.$i; |
|
49 | - $h++; |
|
50 | - $i++; |
|
51 | - } |
|
41 | + $h=0; |
|
42 | + $head = array(); |
|
43 | + $i=1; |
|
44 | + while($i <= $maxstep) |
|
45 | + { |
|
46 | + $head[$h][0] = DOL_URL_ROOT.'/imports/import.php?step='.$i.$param; |
|
47 | + $head[$h][1] = $langs->trans("Step")." ".$i; |
|
48 | + $head[$h][2] = 'step'.$i; |
|
49 | + $h++; |
|
50 | + $i++; |
|
51 | + } |
|
52 | 52 | |
53 | - return $head; |
|
53 | + return $head; |
|
54 | 54 | } |
55 | 55 |
@@ -49,157 +49,157 @@ discard block |
||
49 | 49 | */ |
50 | 50 | function print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, $filtera, $filtert, $filterd, $pid, $socid, $action, $showextcals=array(), $actioncode='', $usergroupid='', $excludetype='', $resourceid=0) |
51 | 51 | { |
52 | - global $conf, $user, $langs, $db, $hookmanager; |
|
53 | - global $begin_h, $end_h, $begin_d, $end_d; |
|
54 | - |
|
55 | - $langs->load("companies"); |
|
56 | - |
|
57 | - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; |
|
58 | - $formactions=new FormActions($db); |
|
59 | - |
|
60 | - // Filters |
|
61 | - //print '<form name="listactionsfilter" class="listactionsfilter" action="' . $_SERVER["PHP_SELF"] . '" method="get">'; |
|
62 | - print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">'; |
|
63 | - print '<input type="hidden" name="year" value="' . $year . '">'; |
|
64 | - print '<input type="hidden" name="month" value="' . $month . '">'; |
|
65 | - print '<input type="hidden" name="day" value="' . $day . '">'; |
|
66 | - print '<input type="hidden" name="action" value="' . $action . '">'; |
|
67 | - print '<input type="hidden" name="search_showbirthday" value="' . $showbirthday . '">'; |
|
68 | - |
|
69 | - print '<div class="fichecenter">'; |
|
70 | - |
|
71 | - if ($conf->browser->layout == 'phone') print '<div class="fichehalfleft">'; |
|
72 | - else print '<table class="nobordernopadding" width="100%"><tr><td class="borderright">'; |
|
73 | - |
|
74 | - print '<table class="nobordernopadding centpercent">'; |
|
75 | - |
|
76 | - if ($canedit) |
|
77 | - { |
|
78 | - print '<tr>'; |
|
79 | - print '<td class="nowrap" style="padding-bottom: 2px; padding-right: 4px;">'; |
|
80 | - print $langs->trans("ActionsToDoBy").' '; |
|
81 | - print '</td><td style="padding-bottom: 2px; padding-right: 4px;">'; |
|
82 | - print $form->select_dolusers($filtert, 'search_filtert', 1, '', ! $canedit, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); |
|
83 | - if (empty($conf->dol_optimize_smallscreen)) print ' '.$langs->trans("or") . ' '.$langs->trans("ToUserOfGroup").' '; |
|
84 | - print $form->select_dolgroups($usergroupid, 'usergroup', 1, '', ! $canedit); |
|
85 | - print '</td></tr>'; |
|
86 | - |
|
87 | - if ($conf->resource->enabled) |
|
88 | - { |
|
89 | - include_once DOL_DOCUMENT_ROOT . '/resource/class/html.formresource.class.php'; |
|
90 | - $formresource=new FormResource($db); |
|
91 | - |
|
92 | - // Resource |
|
93 | - print '<tr>'; |
|
94 | - print '<td class="nowrap" style="padding-bottom: 2px; padding-right: 4px;">'; |
|
95 | - print $langs->trans("Resource"); |
|
96 | - print ' </td><td class="nowrap maxwidthonsmartphone" style="padding-bottom: 2px; padding-right: 4px;">'; |
|
52 | + global $conf, $user, $langs, $db, $hookmanager; |
|
53 | + global $begin_h, $end_h, $begin_d, $end_d; |
|
54 | + |
|
55 | + $langs->load("companies"); |
|
56 | + |
|
57 | + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; |
|
58 | + $formactions=new FormActions($db); |
|
59 | + |
|
60 | + // Filters |
|
61 | + //print '<form name="listactionsfilter" class="listactionsfilter" action="' . $_SERVER["PHP_SELF"] . '" method="get">'; |
|
62 | + print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">'; |
|
63 | + print '<input type="hidden" name="year" value="' . $year . '">'; |
|
64 | + print '<input type="hidden" name="month" value="' . $month . '">'; |
|
65 | + print '<input type="hidden" name="day" value="' . $day . '">'; |
|
66 | + print '<input type="hidden" name="action" value="' . $action . '">'; |
|
67 | + print '<input type="hidden" name="search_showbirthday" value="' . $showbirthday . '">'; |
|
68 | + |
|
69 | + print '<div class="fichecenter">'; |
|
70 | + |
|
71 | + if ($conf->browser->layout == 'phone') print '<div class="fichehalfleft">'; |
|
72 | + else print '<table class="nobordernopadding" width="100%"><tr><td class="borderright">'; |
|
73 | + |
|
74 | + print '<table class="nobordernopadding centpercent">'; |
|
75 | + |
|
76 | + if ($canedit) |
|
77 | + { |
|
78 | + print '<tr>'; |
|
79 | + print '<td class="nowrap" style="padding-bottom: 2px; padding-right: 4px;">'; |
|
80 | + print $langs->trans("ActionsToDoBy").' '; |
|
81 | + print '</td><td style="padding-bottom: 2px; padding-right: 4px;">'; |
|
82 | + print $form->select_dolusers($filtert, 'search_filtert', 1, '', ! $canedit, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); |
|
83 | + if (empty($conf->dol_optimize_smallscreen)) print ' '.$langs->trans("or") . ' '.$langs->trans("ToUserOfGroup").' '; |
|
84 | + print $form->select_dolgroups($usergroupid, 'usergroup', 1, '', ! $canedit); |
|
85 | + print '</td></tr>'; |
|
86 | + |
|
87 | + if ($conf->resource->enabled) |
|
88 | + { |
|
89 | + include_once DOL_DOCUMENT_ROOT . '/resource/class/html.formresource.class.php'; |
|
90 | + $formresource=new FormResource($db); |
|
91 | + |
|
92 | + // Resource |
|
93 | + print '<tr>'; |
|
94 | + print '<td class="nowrap" style="padding-bottom: 2px; padding-right: 4px;">'; |
|
95 | + print $langs->trans("Resource"); |
|
96 | + print ' </td><td class="nowrap maxwidthonsmartphone" style="padding-bottom: 2px; padding-right: 4px;">'; |
|
97 | 97 | print $formresource->select_resource_list($resourceid, "search_resourceid", '', 1, 0, 0, null, '', 2); |
98 | - print '</td></tr>'; |
|
99 | - } |
|
100 | - |
|
101 | - // Type |
|
102 | - print '<tr>'; |
|
103 | - print '<td class="nowrap" style="padding-bottom: 2px; padding-right: 4px;">'; |
|
104 | - print $langs->trans("Type"); |
|
105 | - print ' </td><td class="nowrap" style="padding-bottom: 2px; padding-right: 4px;">'; |
|
106 | - $multiselect=0; |
|
107 | - if (! empty($conf->global->MAIN_ENABLE_MULTISELECT_TYPE)) // We use an option here because it adds bugs when used on agenda page "peruser" and "list" |
|
108 | - { |
|
98 | + print '</td></tr>'; |
|
99 | + } |
|
100 | + |
|
101 | + // Type |
|
102 | + print '<tr>'; |
|
103 | + print '<td class="nowrap" style="padding-bottom: 2px; padding-right: 4px;">'; |
|
104 | + print $langs->trans("Type"); |
|
105 | + print ' </td><td class="nowrap" style="padding-bottom: 2px; padding-right: 4px;">'; |
|
106 | + $multiselect=0; |
|
107 | + if (! empty($conf->global->MAIN_ENABLE_MULTISELECT_TYPE)) // We use an option here because it adds bugs when used on agenda page "peruser" and "list" |
|
108 | + { |
|
109 | 109 | $multiselect=(!empty($conf->global->AGENDA_USE_EVENT_TYPE)); |
110 | - } |
|
110 | + } |
|
111 | 111 | print $formactions->select_type_actions($actioncode, "search_actioncode", $excludetype, (empty($conf->global->AGENDA_USE_EVENT_TYPE)?1:-1), 0, $multiselect); |
112 | - print '</td></tr>'; |
|
113 | - } |
|
114 | - |
|
115 | - if (! empty($conf->societe->enabled) && $user->rights->societe->lire) |
|
116 | - { |
|
117 | - print '<tr>'; |
|
118 | - print '<td class="nowrap" style="padding-bottom: 2px; padding-right: 4px;">'; |
|
119 | - print $langs->trans("ThirdParty").' '; |
|
120 | - print '</td><td class="nowrap" style="padding-bottom: 2px;">'; |
|
121 | - print $form->select_company($socid, 'search_socid', '', 'SelectThirdParty', 0, 0, null, 0); |
|
122 | - print '</td></tr>'; |
|
123 | - } |
|
124 | - |
|
125 | - if (! empty($conf->projet->enabled) && $user->rights->projet->lire) |
|
126 | - { |
|
127 | - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; |
|
128 | - $formproject=new FormProjets($db); |
|
129 | - |
|
130 | - print '<tr>'; |
|
131 | - print '<td class="nowrap" style="padding-bottom: 2px;">'; |
|
132 | - print $langs->trans("Project").' '; |
|
133 | - print '</td><td class="nowrap" style="padding-bottom: 2px;">'; |
|
134 | - print $formproject->select_projects($socid?$socid:-1, $pid, 'search_projectid', 0, 0, 1, 0, 0, 0, 0, '', 1, 0, 'maxwidth500'); |
|
135 | - print '</td></tr>'; |
|
136 | - } |
|
137 | - |
|
138 | - if ($canedit && ! preg_match('/list/', $_SERVER["PHP_SELF"])) |
|
139 | - { |
|
140 | - // Status |
|
141 | - print '<tr>'; |
|
142 | - print '<td class="nowrap" style="padding-bottom: 2px; padding-right: 4px;">'; |
|
143 | - print $langs->trans("Status"); |
|
144 | - print ' </td><td class="nowrap" style="padding-bottom: 2px; padding-right: 4px;">'; |
|
145 | - $formactions->form_select_status_action('formaction', $status, 1, 'search_status', 1, 2, 'minwidth100'); |
|
146 | - print '</td></tr>'; |
|
147 | - } |
|
148 | - |
|
149 | - if ($canedit && $action == 'show_peruser') |
|
150 | - { |
|
151 | - // Filter on hours |
|
152 | - print '<tr>'; |
|
153 | - print '<td class="nowrap" style="padding-bottom: 2px; padding-right: 4px;">'.$langs->trans("VisibleTimeRange").'</td>'; |
|
154 | - print "<td class='nowrap'>"; |
|
155 | - print '<div class="ui-grid-a"><div class="ui-block-a">'; |
|
156 | - print '<input type="number" class="short" name="begin_h" value="'.$begin_h.'" min="0" max="23">'; |
|
157 | - if (empty($conf->dol_use_jmobile)) print ' - '; |
|
158 | - else print '</div><div class="ui-block-b">'; |
|
159 | - print '<input type="number" class="short" name="end_h" value="'.$end_h.'" min="1" max="24">'; |
|
160 | - if (empty($conf->dol_use_jmobile)) print ' '.$langs->trans("H"); |
|
161 | - print '</div></div>'; |
|
162 | - print '</td></tr>'; |
|
163 | - |
|
164 | - // Filter on days |
|
165 | - print '<tr>'; |
|
166 | - print '<td class="nowrap">'.$langs->trans("VisibleDaysRange").'</td>'; |
|
167 | - print "<td class='nowrap'>"; |
|
168 | - print '<div class="ui-grid-a"><div class="ui-block-a">'; |
|
169 | - print '<input type="number" class="short" name="begin_d" value="'.$begin_d.'" min="1" max="7">'; |
|
170 | - if (empty($conf->dol_use_jmobile)) print ' - '; |
|
171 | - else print '</div><div class="ui-block-b">'; |
|
172 | - print '<input type="number" class="short" name="end_d" value="'.$end_d.'" min="1" max="7">'; |
|
173 | - print '</div></div>'; |
|
174 | - print '</td></tr>'; |
|
175 | - } |
|
176 | - |
|
177 | - // Hooks |
|
178 | - $parameters = array('canedit'=>$canedit, 'pid'=>$pid, 'socid'=>$socid); |
|
179 | - $reshook = $hookmanager->executeHooks('searchAgendaFrom', $parameters, $object, $action); // Note that $action and $object may have been |
|
180 | - |
|
181 | - print '</table>'; |
|
182 | - |
|
183 | - if ($conf->browser->layout == 'phone') print '</div>'; |
|
184 | - else print '</td>'; |
|
185 | - |
|
186 | - if ($conf->browser->layout == 'phone') print '<div class="fichehalfright">'; |
|
187 | - else print '<td align="center" valign="middle" class="nowrap">'; |
|
188 | - |
|
189 | - print '<table class="centpercent"><tr><td align="center">'; |
|
190 | - print '<div class="formleftzone">'; |
|
191 | - print '<input type="submit" class="button" style="min-width:120px" name="refresh" value="' . $langs->trans("Refresh") . '">'; |
|
192 | - print '</div>'; |
|
193 | - print '</td></tr>'; |
|
194 | - print '</table>'; |
|
195 | - |
|
196 | - if ($conf->browser->layout == 'phone') print '</div>'; |
|
197 | - else print '</td></tr></table>'; |
|
198 | - |
|
199 | - print '</div>'; // Close fichecenter |
|
200 | - print '<div style="clear:both"></div>'; |
|
201 | - |
|
202 | - //print '</form>'; |
|
112 | + print '</td></tr>'; |
|
113 | + } |
|
114 | + |
|
115 | + if (! empty($conf->societe->enabled) && $user->rights->societe->lire) |
|
116 | + { |
|
117 | + print '<tr>'; |
|
118 | + print '<td class="nowrap" style="padding-bottom: 2px; padding-right: 4px;">'; |
|
119 | + print $langs->trans("ThirdParty").' '; |
|
120 | + print '</td><td class="nowrap" style="padding-bottom: 2px;">'; |
|
121 | + print $form->select_company($socid, 'search_socid', '', 'SelectThirdParty', 0, 0, null, 0); |
|
122 | + print '</td></tr>'; |
|
123 | + } |
|
124 | + |
|
125 | + if (! empty($conf->projet->enabled) && $user->rights->projet->lire) |
|
126 | + { |
|
127 | + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; |
|
128 | + $formproject=new FormProjets($db); |
|
129 | + |
|
130 | + print '<tr>'; |
|
131 | + print '<td class="nowrap" style="padding-bottom: 2px;">'; |
|
132 | + print $langs->trans("Project").' '; |
|
133 | + print '</td><td class="nowrap" style="padding-bottom: 2px;">'; |
|
134 | + print $formproject->select_projects($socid?$socid:-1, $pid, 'search_projectid', 0, 0, 1, 0, 0, 0, 0, '', 1, 0, 'maxwidth500'); |
|
135 | + print '</td></tr>'; |
|
136 | + } |
|
137 | + |
|
138 | + if ($canedit && ! preg_match('/list/', $_SERVER["PHP_SELF"])) |
|
139 | + { |
|
140 | + // Status |
|
141 | + print '<tr>'; |
|
142 | + print '<td class="nowrap" style="padding-bottom: 2px; padding-right: 4px;">'; |
|
143 | + print $langs->trans("Status"); |
|
144 | + print ' </td><td class="nowrap" style="padding-bottom: 2px; padding-right: 4px;">'; |
|
145 | + $formactions->form_select_status_action('formaction', $status, 1, 'search_status', 1, 2, 'minwidth100'); |
|
146 | + print '</td></tr>'; |
|
147 | + } |
|
148 | + |
|
149 | + if ($canedit && $action == 'show_peruser') |
|
150 | + { |
|
151 | + // Filter on hours |
|
152 | + print '<tr>'; |
|
153 | + print '<td class="nowrap" style="padding-bottom: 2px; padding-right: 4px;">'.$langs->trans("VisibleTimeRange").'</td>'; |
|
154 | + print "<td class='nowrap'>"; |
|
155 | + print '<div class="ui-grid-a"><div class="ui-block-a">'; |
|
156 | + print '<input type="number" class="short" name="begin_h" value="'.$begin_h.'" min="0" max="23">'; |
|
157 | + if (empty($conf->dol_use_jmobile)) print ' - '; |
|
158 | + else print '</div><div class="ui-block-b">'; |
|
159 | + print '<input type="number" class="short" name="end_h" value="'.$end_h.'" min="1" max="24">'; |
|
160 | + if (empty($conf->dol_use_jmobile)) print ' '.$langs->trans("H"); |
|
161 | + print '</div></div>'; |
|
162 | + print '</td></tr>'; |
|
163 | + |
|
164 | + // Filter on days |
|
165 | + print '<tr>'; |
|
166 | + print '<td class="nowrap">'.$langs->trans("VisibleDaysRange").'</td>'; |
|
167 | + print "<td class='nowrap'>"; |
|
168 | + print '<div class="ui-grid-a"><div class="ui-block-a">'; |
|
169 | + print '<input type="number" class="short" name="begin_d" value="'.$begin_d.'" min="1" max="7">'; |
|
170 | + if (empty($conf->dol_use_jmobile)) print ' - '; |
|
171 | + else print '</div><div class="ui-block-b">'; |
|
172 | + print '<input type="number" class="short" name="end_d" value="'.$end_d.'" min="1" max="7">'; |
|
173 | + print '</div></div>'; |
|
174 | + print '</td></tr>'; |
|
175 | + } |
|
176 | + |
|
177 | + // Hooks |
|
178 | + $parameters = array('canedit'=>$canedit, 'pid'=>$pid, 'socid'=>$socid); |
|
179 | + $reshook = $hookmanager->executeHooks('searchAgendaFrom', $parameters, $object, $action); // Note that $action and $object may have been |
|
180 | + |
|
181 | + print '</table>'; |
|
182 | + |
|
183 | + if ($conf->browser->layout == 'phone') print '</div>'; |
|
184 | + else print '</td>'; |
|
185 | + |
|
186 | + if ($conf->browser->layout == 'phone') print '<div class="fichehalfright">'; |
|
187 | + else print '<td align="center" valign="middle" class="nowrap">'; |
|
188 | + |
|
189 | + print '<table class="centpercent"><tr><td align="center">'; |
|
190 | + print '<div class="formleftzone">'; |
|
191 | + print '<input type="submit" class="button" style="min-width:120px" name="refresh" value="' . $langs->trans("Refresh") . '">'; |
|
192 | + print '</div>'; |
|
193 | + print '</td></tr>'; |
|
194 | + print '</table>'; |
|
195 | + |
|
196 | + if ($conf->browser->layout == 'phone') print '</div>'; |
|
197 | + else print '</td></tr></table>'; |
|
198 | + |
|
199 | + print '</div>'; // Close fichecenter |
|
200 | + print '<div style="clear:both"></div>'; |
|
201 | + |
|
202 | + //print '</form>'; |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | |
@@ -211,42 +211,42 @@ discard block |
||
211 | 211 | */ |
212 | 212 | function show_array_actions_to_do($max=5) |
213 | 213 | { |
214 | - global $langs, $conf, $user, $db, $bc, $socid; |
|
214 | + global $langs, $conf, $user, $db, $bc, $socid; |
|
215 | 215 | |
216 | - $now=dol_now(); |
|
216 | + $now=dol_now(); |
|
217 | 217 | |
218 | - include_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; |
|
219 | - include_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; |
|
218 | + include_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; |
|
219 | + include_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; |
|
220 | 220 | |
221 | - $sql = "SELECT a.id, a.label, a.datep as dp, a.datep2 as dp2, a.fk_user_author, a.percent,"; |
|
222 | - $sql.= " c.code, c.libelle as type_label,"; |
|
223 | - $sql.= " s.nom as sname, s.rowid, s.client"; |
|
224 | - $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a LEFT JOIN "; |
|
225 | - $sql.= " ".MAIN_DB_PREFIX."c_actioncomm as c ON c.id = a.fk_action"; |
|
221 | + $sql = "SELECT a.id, a.label, a.datep as dp, a.datep2 as dp2, a.fk_user_author, a.percent,"; |
|
222 | + $sql.= " c.code, c.libelle as type_label,"; |
|
223 | + $sql.= " s.nom as sname, s.rowid, s.client"; |
|
224 | + $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a LEFT JOIN "; |
|
225 | + $sql.= " ".MAIN_DB_PREFIX."c_actioncomm as c ON c.id = a.fk_action"; |
|
226 | 226 | $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; |
227 | - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
228 | - $sql.= " WHERE a.entity = ".$conf->entity; |
|
227 | + if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
228 | + $sql.= " WHERE a.entity = ".$conf->entity; |
|
229 | 229 | $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep2 > '".$db->idate($now)."'))"; |
230 | - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
231 | - if ($socid) $sql.= " AND s.rowid = ".$socid; |
|
232 | - $sql.= " ORDER BY a.datep DESC, a.id DESC"; |
|
233 | - $sql.= $db->plimit($max, 0); |
|
230 | + if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
231 | + if ($socid) $sql.= " AND s.rowid = ".$socid; |
|
232 | + $sql.= " ORDER BY a.datep DESC, a.id DESC"; |
|
233 | + $sql.= $db->plimit($max, 0); |
|
234 | 234 | |
235 | - $resql=$db->query($sql); |
|
236 | - if ($resql) |
|
237 | - { |
|
238 | - $num = $db->num_rows($resql); |
|
235 | + $resql=$db->query($sql); |
|
236 | + if ($resql) |
|
237 | + { |
|
238 | + $num = $db->num_rows($resql); |
|
239 | 239 | |
240 | - print '<table class="noborder" width="100%">'; |
|
241 | - print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("LastActionsToDo",$max).'</th>'; |
|
242 | - print '<th colspan="2" align="right"><a class="commonlink" href="'.DOL_URL_ROOT.'/comm/action/list.php?status=todo">'.$langs->trans("FullList").'</a></th>'; |
|
243 | - print '</tr>'; |
|
240 | + print '<table class="noborder" width="100%">'; |
|
241 | + print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("LastActionsToDo",$max).'</th>'; |
|
242 | + print '<th colspan="2" align="right"><a class="commonlink" href="'.DOL_URL_ROOT.'/comm/action/list.php?status=todo">'.$langs->trans("FullList").'</a></th>'; |
|
243 | + print '</tr>'; |
|
244 | 244 | |
245 | - $var = true; |
|
246 | - $i = 0; |
|
245 | + $var = true; |
|
246 | + $i = 0; |
|
247 | 247 | |
248 | - $staticaction=new ActionComm($db); |
|
249 | - $customerstatic=new Client($db); |
|
248 | + $staticaction=new ActionComm($db); |
|
249 | + $customerstatic=new Client($db); |
|
250 | 250 | |
251 | 251 | while ($i < $num) |
252 | 252 | { |
@@ -260,15 +260,15 @@ discard block |
||
260 | 260 | $staticaction->id=$obj->id; |
261 | 261 | print '<td>'.$staticaction->getNomUrl(1,34).'</td>'; |
262 | 262 | |
263 | - // print '<td>'.dol_trunc($obj->label,22).'</td>'; |
|
263 | + // print '<td>'.dol_trunc($obj->label,22).'</td>'; |
|
264 | 264 | |
265 | 265 | print '<td>'; |
266 | 266 | if ($obj->rowid > 0) |
267 | 267 | { |
268 | - $customerstatic->id=$obj->rowid; |
|
269 | - $customerstatic->name=$obj->sname; |
|
270 | - $customerstatic->client=$obj->client; |
|
271 | - print $customerstatic->getNomUrl(1,'',16); |
|
268 | + $customerstatic->id=$obj->rowid; |
|
269 | + $customerstatic->name=$obj->sname; |
|
270 | + $customerstatic->client=$obj->client; |
|
271 | + print $customerstatic->getNomUrl(1,'',16); |
|
272 | 272 | } |
273 | 273 | print '</td>'; |
274 | 274 | |
@@ -276,30 +276,30 @@ discard block |
||
276 | 276 | $datep2=$db->jdate($obj->dp2); |
277 | 277 | |
278 | 278 | // Date |
279 | - print '<td width="100" align="right">'.dol_print_date($datep,'day').' '; |
|
280 | - $late=0; |
|
281 | - if ($obj->percent == 0 && $datep && $datep < time()) $late=1; |
|
282 | - if ($obj->percent == 0 && ! $datep && $datep2 && $datep2 < time()) $late=1; |
|
283 | - if ($obj->percent > 0 && $obj->percent < 100 && $datep2 && $datep2 < time()) $late=1; |
|
284 | - if ($obj->percent > 0 && $obj->percent < 100 && ! $datep2 && $datep && $datep < time()) $late=1; |
|
285 | - if ($late) print img_warning($langs->trans("Late")); |
|
286 | - print "</td>"; |
|
279 | + print '<td width="100" align="right">'.dol_print_date($datep,'day').' '; |
|
280 | + $late=0; |
|
281 | + if ($obj->percent == 0 && $datep && $datep < time()) $late=1; |
|
282 | + if ($obj->percent == 0 && ! $datep && $datep2 && $datep2 < time()) $late=1; |
|
283 | + if ($obj->percent > 0 && $obj->percent < 100 && $datep2 && $datep2 < time()) $late=1; |
|
284 | + if ($obj->percent > 0 && $obj->percent < 100 && ! $datep2 && $datep && $datep < time()) $late=1; |
|
285 | + if ($late) print img_warning($langs->trans("Late")); |
|
286 | + print "</td>"; |
|
287 | 287 | |
288 | - // Statut |
|
289 | - print "<td align=\"right\" width=\"14\">".$staticaction->LibStatut($obj->percent,3)."</td>\n"; |
|
288 | + // Statut |
|
289 | + print "<td align=\"right\" width=\"14\">".$staticaction->LibStatut($obj->percent,3)."</td>\n"; |
|
290 | 290 | |
291 | - print "</tr>\n"; |
|
291 | + print "</tr>\n"; |
|
292 | 292 | |
293 | 293 | $i++; |
294 | 294 | } |
295 | - print "</table><br>"; |
|
296 | - |
|
297 | - $db->free($resql); |
|
298 | - } |
|
299 | - else |
|
300 | - { |
|
301 | - dol_print_error($db); |
|
302 | - } |
|
295 | + print "</table><br>"; |
|
296 | + |
|
297 | + $db->free($resql); |
|
298 | + } |
|
299 | + else |
|
300 | + { |
|
301 | + dol_print_error($db); |
|
302 | + } |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | |
@@ -311,83 +311,83 @@ discard block |
||
311 | 311 | */ |
312 | 312 | function show_array_last_actions_done($max=5) |
313 | 313 | { |
314 | - global $langs, $conf, $user, $db, $bc, $socid; |
|
314 | + global $langs, $conf, $user, $db, $bc, $socid; |
|
315 | 315 | |
316 | - $now=dol_now(); |
|
316 | + $now=dol_now(); |
|
317 | 317 | |
318 | - $sql = "SELECT a.id, a.percent, a.datep as da, a.datep2 as da2, a.fk_user_author, a.label,"; |
|
319 | - $sql.= " c.code, c.libelle,"; |
|
320 | - $sql.= " s.rowid, s.nom as sname, s.client"; |
|
321 | - $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a LEFT JOIN "; |
|
322 | - $sql.= " ".MAIN_DB_PREFIX."c_actioncomm as c ON c.id = a.fk_action "; |
|
318 | + $sql = "SELECT a.id, a.percent, a.datep as da, a.datep2 as da2, a.fk_user_author, a.label,"; |
|
319 | + $sql.= " c.code, c.libelle,"; |
|
320 | + $sql.= " s.rowid, s.nom as sname, s.client"; |
|
321 | + $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a LEFT JOIN "; |
|
322 | + $sql.= " ".MAIN_DB_PREFIX."c_actioncomm as c ON c.id = a.fk_action "; |
|
323 | 323 | $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; |
324 | - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
325 | - $sql.= " WHERE a.entity = ".$conf->entity; |
|
324 | + if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
325 | + $sql.= " WHERE a.entity = ".$conf->entity; |
|
326 | 326 | $sql.= " AND (a.percent >= 100 OR (a.percent = -1 AND a.datep2 <= '".$db->idate($now)."'))"; |
327 | - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
327 | + if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
328 | 328 | if ($socid) $sql.= " AND s.rowid = ".$socid; |
329 | - $sql .= " ORDER BY a.datep2 DESC"; |
|
330 | - $sql .= $db->plimit($max, 0); |
|
329 | + $sql .= " ORDER BY a.datep2 DESC"; |
|
330 | + $sql .= $db->plimit($max, 0); |
|
331 | 331 | |
332 | - $resql=$db->query($sql); |
|
333 | - if ($resql) |
|
334 | - { |
|
335 | - $num = $db->num_rows($resql); |
|
332 | + $resql=$db->query($sql); |
|
333 | + if ($resql) |
|
334 | + { |
|
335 | + $num = $db->num_rows($resql); |
|
336 | 336 | |
337 | - print '<table class="noborder" width="100%">'; |
|
338 | - print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("LastDoneTasks",$max).'</th>'; |
|
339 | - print '<th colspan="2" align="right"><a class="commonlink" href="'.DOL_URL_ROOT.'/comm/action/list.php?status=done">'.$langs->trans("FullList").'</a></th>'; |
|
340 | - print '</tr>'; |
|
341 | - $var = true; |
|
342 | - $i = 0; |
|
337 | + print '<table class="noborder" width="100%">'; |
|
338 | + print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("LastDoneTasks",$max).'</th>'; |
|
339 | + print '<th colspan="2" align="right"><a class="commonlink" href="'.DOL_URL_ROOT.'/comm/action/list.php?status=done">'.$langs->trans("FullList").'</a></th>'; |
|
340 | + print '</tr>'; |
|
341 | + $var = true; |
|
342 | + $i = 0; |
|
343 | 343 | |
344 | - $staticaction=new ActionComm($db); |
|
345 | - $customerstatic=new Societe($db); |
|
344 | + $staticaction=new ActionComm($db); |
|
345 | + $customerstatic=new Societe($db); |
|
346 | 346 | |
347 | - while ($i < $num) |
|
348 | - { |
|
349 | - $obj = $db->fetch_object($resql); |
|
347 | + while ($i < $num) |
|
348 | + { |
|
349 | + $obj = $db->fetch_object($resql); |
|
350 | 350 | |
351 | 351 | |
352 | - print '<tr class="oddeven">'; |
|
352 | + print '<tr class="oddeven">'; |
|
353 | 353 | |
354 | - $staticaction->type_code=$obj->code; |
|
355 | - $staticaction->libelle=$obj->label; |
|
356 | - $staticaction->id=$obj->id; |
|
357 | - print '<td>'.$staticaction->getNomUrl(1,34).'</td>'; |
|
354 | + $staticaction->type_code=$obj->code; |
|
355 | + $staticaction->libelle=$obj->label; |
|
356 | + $staticaction->id=$obj->id; |
|
357 | + print '<td>'.$staticaction->getNomUrl(1,34).'</td>'; |
|
358 | 358 | |
359 | 359 | //print '<td>'.dol_trunc($obj->label,24).'</td>'; |
360 | 360 | |
361 | - print '<td>'; |
|
362 | - if ($obj->rowid > 0) |
|
363 | - { |
|
361 | + print '<td>'; |
|
362 | + if ($obj->rowid > 0) |
|
363 | + { |
|
364 | 364 | $customerstatic->id=$obj->rowid; |
365 | 365 | $customerstatic->name=$obj->sname; |
366 | 366 | $customerstatic->client=$obj->client; |
367 | - print $customerstatic->getNomUrl(1,'',24); |
|
368 | - } |
|
369 | - print '</td>'; |
|
370 | - |
|
371 | - // Date |
|
372 | - print '<td width="100" align="right">'.dol_print_date($db->jdate($obj->da2),'day'); |
|
373 | - print "</td>"; |
|
374 | - |
|
375 | - // Statut |
|
376 | - print "<td align=\"right\" width=\"14\">".$staticaction->LibStatut($obj->percent,3)."</td>\n"; |
|
377 | - |
|
378 | - print "</tr>\n"; |
|
379 | - $i++; |
|
380 | - } |
|
381 | - // TODO Ajouter rappel pour "il y a des contrats a mettre en service" |
|
382 | - // TODO Ajouter rappel pour "il y a des contrats qui arrivent a expiration" |
|
383 | - print "</table><br>"; |
|
384 | - |
|
385 | - $db->free($resql); |
|
386 | - } |
|
387 | - else |
|
388 | - { |
|
389 | - dol_print_error($db); |
|
390 | - } |
|
367 | + print $customerstatic->getNomUrl(1,'',24); |
|
368 | + } |
|
369 | + print '</td>'; |
|
370 | + |
|
371 | + // Date |
|
372 | + print '<td width="100" align="right">'.dol_print_date($db->jdate($obj->da2),'day'); |
|
373 | + print "</td>"; |
|
374 | + |
|
375 | + // Statut |
|
376 | + print "<td align=\"right\" width=\"14\">".$staticaction->LibStatut($obj->percent,3)."</td>\n"; |
|
377 | + |
|
378 | + print "</tr>\n"; |
|
379 | + $i++; |
|
380 | + } |
|
381 | + // TODO Ajouter rappel pour "il y a des contrats a mettre en service" |
|
382 | + // TODO Ajouter rappel pour "il y a des contrats qui arrivent a expiration" |
|
383 | + print "</table><br>"; |
|
384 | + |
|
385 | + $db->free($resql); |
|
386 | + } |
|
387 | + else |
|
388 | + { |
|
389 | + dol_print_error($db); |
|
390 | + } |
|
391 | 391 | } |
392 | 392 | |
393 | 393 | |
@@ -398,49 +398,49 @@ discard block |
||
398 | 398 | */ |
399 | 399 | function agenda_prepare_head() |
400 | 400 | { |
401 | - global $langs, $conf, $user; |
|
402 | - $h = 0; |
|
403 | - $head = array(); |
|
401 | + global $langs, $conf, $user; |
|
402 | + $h = 0; |
|
403 | + $head = array(); |
|
404 | 404 | |
405 | - $head[$h][0] = DOL_URL_ROOT."/admin/agenda_other.php"; |
|
406 | - $head[$h][1] = $langs->trans("Miscellaneous"); |
|
407 | - $head[$h][2] = 'other'; |
|
408 | - $h++; |
|
405 | + $head[$h][0] = DOL_URL_ROOT."/admin/agenda_other.php"; |
|
406 | + $head[$h][1] = $langs->trans("Miscellaneous"); |
|
407 | + $head[$h][2] = 'other'; |
|
408 | + $h++; |
|
409 | 409 | |
410 | - $head[$h][0] = DOL_URL_ROOT."/admin/agenda.php"; |
|
411 | - $head[$h][1] = $langs->trans("AutoActions"); |
|
412 | - $head[$h][2] = 'autoactions'; |
|
413 | - $h++; |
|
410 | + $head[$h][0] = DOL_URL_ROOT."/admin/agenda.php"; |
|
411 | + $head[$h][1] = $langs->trans("AutoActions"); |
|
412 | + $head[$h][2] = 'autoactions'; |
|
413 | + $h++; |
|
414 | 414 | |
415 | - if ($conf->global->MAIN_FEATURES_LEVEL > 0) |
|
416 | - { |
|
417 | - $head[$h][0] = DOL_URL_ROOT."/admin/agenda_reminder.php"; |
|
418 | - $head[$h][1] = $langs->trans("Reminders"); |
|
419 | - $head[$h][2] = 'reminders'; |
|
420 | - $h++; |
|
421 | - } |
|
415 | + if ($conf->global->MAIN_FEATURES_LEVEL > 0) |
|
416 | + { |
|
417 | + $head[$h][0] = DOL_URL_ROOT."/admin/agenda_reminder.php"; |
|
418 | + $head[$h][1] = $langs->trans("Reminders"); |
|
419 | + $head[$h][2] = 'reminders'; |
|
420 | + $h++; |
|
421 | + } |
|
422 | 422 | |
423 | - $head[$h][0] = DOL_URL_ROOT."/admin/agenda_xcal.php"; |
|
424 | - $head[$h][1] = $langs->trans("ExportCal"); |
|
425 | - $head[$h][2] = 'xcal'; |
|
426 | - $h++; |
|
423 | + $head[$h][0] = DOL_URL_ROOT."/admin/agenda_xcal.php"; |
|
424 | + $head[$h][1] = $langs->trans("ExportCal"); |
|
425 | + $head[$h][2] = 'xcal'; |
|
426 | + $h++; |
|
427 | 427 | |
428 | - $head[$h][0] = DOL_URL_ROOT."/admin/agenda_extsites.php"; |
|
429 | - $head[$h][1] = $langs->trans("ExtSites"); |
|
430 | - $head[$h][2] = 'extsites'; |
|
431 | - $h++; |
|
428 | + $head[$h][0] = DOL_URL_ROOT."/admin/agenda_extsites.php"; |
|
429 | + $head[$h][1] = $langs->trans("ExtSites"); |
|
430 | + $head[$h][2] = 'extsites'; |
|
431 | + $h++; |
|
432 | 432 | |
433 | - complete_head_from_modules($conf,$langs,null,$head,$h,'agenda_admin'); |
|
433 | + complete_head_from_modules($conf,$langs,null,$head,$h,'agenda_admin'); |
|
434 | 434 | |
435 | - $head[$h][0] = DOL_URL_ROOT."/admin/agenda_extrafields.php"; |
|
436 | - $head[$h][1] = $langs->trans("ExtraFields"); |
|
437 | - $head[$h][2] = 'attributes'; |
|
438 | - $h++; |
|
435 | + $head[$h][0] = DOL_URL_ROOT."/admin/agenda_extrafields.php"; |
|
436 | + $head[$h][1] = $langs->trans("ExtraFields"); |
|
437 | + $head[$h][2] = 'attributes'; |
|
438 | + $h++; |
|
439 | 439 | |
440 | - complete_head_from_modules($conf,$langs,null,$head,$h,'agenda_admin','remove'); |
|
440 | + complete_head_from_modules($conf,$langs,null,$head,$h,'agenda_admin','remove'); |
|
441 | 441 | |
442 | 442 | |
443 | - return $head; |
|
443 | + return $head; |
|
444 | 444 | } |
445 | 445 | |
446 | 446 | /** |
@@ -451,30 +451,30 @@ discard block |
||
451 | 451 | */ |
452 | 452 | function actions_prepare_head($object) |
453 | 453 | { |
454 | - global $db, $langs, $conf, $user; |
|
454 | + global $db, $langs, $conf, $user; |
|
455 | 455 | |
456 | - $h = 0; |
|
457 | - $head = array(); |
|
456 | + $h = 0; |
|
457 | + $head = array(); |
|
458 | 458 | |
459 | - $head[$h][0] = DOL_URL_ROOT.'/comm/action/card.php?id='.$object->id; |
|
460 | - $head[$h][1] = $langs->trans("CardAction"); |
|
461 | - $head[$h][2] = 'card'; |
|
462 | - $h++; |
|
459 | + $head[$h][0] = DOL_URL_ROOT.'/comm/action/card.php?id='.$object->id; |
|
460 | + $head[$h][1] = $langs->trans("CardAction"); |
|
461 | + $head[$h][2] = 'card'; |
|
462 | + $h++; |
|
463 | 463 | |
464 | 464 | // Tab to link resources |
465 | - if ($conf->resource->enabled) |
|
466 | - { |
|
467 | - include_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php'; |
|
468 | - $resource=new DolResource($db); |
|
465 | + if ($conf->resource->enabled) |
|
466 | + { |
|
467 | + include_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php'; |
|
468 | + $resource=new DolResource($db); |
|
469 | 469 | |
470 | - $head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=action&element_id='.$object->id; |
|
470 | + $head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=action&element_id='.$object->id; |
|
471 | 471 | $listofresourcelinked = $resource->getElementResources($object->element, $object->id); |
472 | 472 | $nbResources=count($listofresourcelinked); |
473 | - $head[$h][1] = $langs->trans("Resources"); |
|
474 | - if ($nbResources > 0) $head[$h][1].= ' <span class="badge">'.($nbResources).'</span>'; |
|
475 | - $head[$h][2] = 'resources'; |
|
476 | - $h++; |
|
477 | - } |
|
473 | + $head[$h][1] = $langs->trans("Resources"); |
|
474 | + if ($nbResources > 0) $head[$h][1].= ' <span class="badge">'.($nbResources).'</span>'; |
|
475 | + $head[$h][2] = 'resources'; |
|
476 | + $h++; |
|
477 | + } |
|
478 | 478 | |
479 | 479 | // Attached files |
480 | 480 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
@@ -484,20 +484,20 @@ discard block |
||
484 | 484 | $nbLinks=Link::count($db, $object->element, $object->id); |
485 | 485 | $head[$h][0] = DOL_URL_ROOT.'/comm/action/document.php?id='.$object->id; |
486 | 486 | $head[$h][1] = $langs->trans("Documents"); |
487 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
487 | + if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
488 | 488 | $head[$h][2] = 'documents'; |
489 | 489 | $h++; |
490 | 490 | |
491 | - $head[$h][0] = DOL_URL_ROOT.'/comm/action/info.php?id='.$object->id; |
|
492 | - $head[$h][1] = $langs->trans('Info'); |
|
493 | - $head[$h][2] = 'info'; |
|
494 | - $h++; |
|
491 | + $head[$h][0] = DOL_URL_ROOT.'/comm/action/info.php?id='.$object->id; |
|
492 | + $head[$h][1] = $langs->trans('Info'); |
|
493 | + $head[$h][2] = 'info'; |
|
494 | + $h++; |
|
495 | 495 | |
496 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'action'); |
|
496 | + complete_head_from_modules($conf,$langs,$object,$head,$h,'action'); |
|
497 | 497 | |
498 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'action','remove'); |
|
498 | + complete_head_from_modules($conf,$langs,$object,$head,$h,'action','remove'); |
|
499 | 499 | |
500 | - return $head; |
|
500 | + return $head; |
|
501 | 501 | } |
502 | 502 | |
503 | 503 | |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | $h++; |
550 | 550 | |
551 | 551 | |
552 | - $object=new stdClass(); |
|
552 | + $object=new stdClass(); |
|
553 | 553 | |
554 | 554 | // Show more tabs from modules |
555 | 555 | // Entries must be declared in modules descriptor with line |
@@ -35,33 +35,33 @@ discard block |
||
35 | 35 | */ |
36 | 36 | function facture_prepare_head($object) |
37 | 37 | { |
38 | - global $db, $langs, $conf; |
|
39 | - |
|
40 | - $h = 0; |
|
41 | - $head = array(); |
|
42 | - |
|
43 | - $head[$h][0] = DOL_URL_ROOT.'/compta/facture/card.php?facid='.$object->id; |
|
44 | - $head[$h][1] = $langs->trans('Card'); |
|
45 | - $head[$h][2] = 'compta'; |
|
46 | - $h++; |
|
47 | - |
|
48 | - if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) |
|
49 | - { |
|
50 | - $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
|
51 | - $head[$h][0] = DOL_URL_ROOT.'/compta/facture/contact.php?facid='.$object->id; |
|
52 | - $head[$h][1] = $langs->trans('ContactsAddresses'); |
|
53 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
54 | - $head[$h][2] = 'contact'; |
|
55 | - $h++; |
|
56 | - } |
|
57 | - |
|
58 | - //if ($fac->mode_reglement_code == 'PRE') |
|
59 | - if (! empty($conf->prelevement->enabled)) |
|
60 | - { |
|
61 | - $nbStandingOrders=0; |
|
62 | - $sql = "SELECT COUNT(pfd.rowid) as nb"; |
|
63 | - $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; |
|
64 | - $sql .= " WHERE pfd.fk_facture = ".$object->id; |
|
38 | + global $db, $langs, $conf; |
|
39 | + |
|
40 | + $h = 0; |
|
41 | + $head = array(); |
|
42 | + |
|
43 | + $head[$h][0] = DOL_URL_ROOT.'/compta/facture/card.php?facid='.$object->id; |
|
44 | + $head[$h][1] = $langs->trans('Card'); |
|
45 | + $head[$h][2] = 'compta'; |
|
46 | + $h++; |
|
47 | + |
|
48 | + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) |
|
49 | + { |
|
50 | + $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
|
51 | + $head[$h][0] = DOL_URL_ROOT.'/compta/facture/contact.php?facid='.$object->id; |
|
52 | + $head[$h][1] = $langs->trans('ContactsAddresses'); |
|
53 | + if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
54 | + $head[$h][2] = 'contact'; |
|
55 | + $h++; |
|
56 | + } |
|
57 | + |
|
58 | + //if ($fac->mode_reglement_code == 'PRE') |
|
59 | + if (! empty($conf->prelevement->enabled)) |
|
60 | + { |
|
61 | + $nbStandingOrders=0; |
|
62 | + $sql = "SELECT COUNT(pfd.rowid) as nb"; |
|
63 | + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; |
|
64 | + $sql .= " WHERE pfd.fk_facture = ".$object->id; |
|
65 | 65 | $resql=$db->query($sql); |
66 | 66 | if ($resql) |
67 | 67 | { |
@@ -69,12 +69,12 @@ discard block |
||
69 | 69 | if ($obj) $nbStandingOrders = $obj->nb; |
70 | 70 | } |
71 | 71 | else dol_print_error($db); |
72 | - $head[$h][0] = DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$object->id; |
|
73 | - $head[$h][1] = $langs->trans('StandingOrders'); |
|
74 | - if ($nbStandingOrders > 0) $head[$h][1].= ' <span class="badge">'.$nbStandingOrders.'</span>'; |
|
75 | - $head[$h][2] = 'standingorders'; |
|
76 | - $h++; |
|
77 | - } |
|
72 | + $head[$h][0] = DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$object->id; |
|
73 | + $head[$h][1] = $langs->trans('StandingOrders'); |
|
74 | + if ($nbStandingOrders > 0) $head[$h][1].= ' <span class="badge">'.$nbStandingOrders.'</span>'; |
|
75 | + $head[$h][2] = 'standingorders'; |
|
76 | + $h++; |
|
77 | + } |
|
78 | 78 | |
79 | 79 | // Show more tabs from modules |
80 | 80 | // Entries must be declared in modules descriptor with line |
@@ -84,35 +84,35 @@ discard block |
||
84 | 84 | |
85 | 85 | if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
86 | 86 | { |
87 | - $nbNote = 0; |
|
87 | + $nbNote = 0; |
|
88 | 88 | if(!empty($object->note_private)) $nbNote++; |
89 | - if(!empty($object->note_public)) $nbNote++; |
|
90 | - $head[$h][0] = DOL_URL_ROOT.'/compta/facture/note.php?facid='.$object->id; |
|
91 | - $head[$h][1] = $langs->trans('Notes'); |
|
92 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
93 | - $head[$h][2] = 'note'; |
|
94 | - $h++; |
|
89 | + if(!empty($object->note_public)) $nbNote++; |
|
90 | + $head[$h][0] = DOL_URL_ROOT.'/compta/facture/note.php?facid='.$object->id; |
|
91 | + $head[$h][1] = $langs->trans('Notes'); |
|
92 | + if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
93 | + $head[$h][2] = 'note'; |
|
94 | + $h++; |
|
95 | 95 | } |
96 | 96 | |
97 | - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
97 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
98 | 98 | require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
99 | - $upload_dir = $conf->facture->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
100 | - $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
99 | + $upload_dir = $conf->facture->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
100 | + $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
101 | 101 | $nbLinks=Link::count($db, $object->element, $object->id); |
102 | - $head[$h][0] = DOL_URL_ROOT.'/compta/facture/document.php?facid='.$object->id; |
|
103 | - $head[$h][1] = $langs->trans('Documents'); |
|
104 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
105 | - $head[$h][2] = 'documents'; |
|
106 | - $h++; |
|
102 | + $head[$h][0] = DOL_URL_ROOT.'/compta/facture/document.php?facid='.$object->id; |
|
103 | + $head[$h][1] = $langs->trans('Documents'); |
|
104 | + if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
105 | + $head[$h][2] = 'documents'; |
|
106 | + $h++; |
|
107 | 107 | |
108 | - $head[$h][0] = DOL_URL_ROOT.'/compta/facture/info.php?facid='.$object->id; |
|
109 | - $head[$h][1] = $langs->trans('Info'); |
|
110 | - $head[$h][2] = 'info'; |
|
111 | - $h++; |
|
108 | + $head[$h][0] = DOL_URL_ROOT.'/compta/facture/info.php?facid='.$object->id; |
|
109 | + $head[$h][1] = $langs->trans('Info'); |
|
110 | + $head[$h][2] = 'info'; |
|
111 | + $h++; |
|
112 | 112 | |
113 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'invoice','remove'); |
|
113 | + complete_head_from_modules($conf,$langs,$object,$head,$h,'invoice','remove'); |
|
114 | 114 | |
115 | - return $head; |
|
115 | + return $head; |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -122,50 +122,50 @@ discard block |
||
122 | 122 | */ |
123 | 123 | function invoice_admin_prepare_head() |
124 | 124 | { |
125 | - global $langs, $conf, $user; |
|
126 | - |
|
127 | - $h = 0; |
|
128 | - $head = array(); |
|
129 | - |
|
130 | - $head[$h][0] = DOL_URL_ROOT.'/admin/facture.php'; |
|
131 | - $head[$h][1] = $langs->trans("Miscellaneous"); |
|
132 | - $head[$h][2] = 'general'; |
|
133 | - $h++; |
|
134 | - |
|
135 | - $head[$h][0] = DOL_URL_ROOT.'/admin/payment.php'; |
|
136 | - $head[$h][1] = $langs->trans("Payments"); |
|
137 | - $head[$h][2] = 'payment'; |
|
138 | - $h++; |
|
139 | - |
|
140 | - // Show more tabs from modules |
|
141 | - // Entries must be declared in modules descriptor with line |
|
142 | - // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
|
143 | - // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab |
|
144 | - complete_head_from_modules($conf,$langs,null,$head,$h,'invoice_admin'); |
|
145 | - |
|
146 | - $head[$h][0] = DOL_URL_ROOT.'/compta/facture/admin/facture_cust_extrafields.php'; |
|
147 | - $head[$h][1] = $langs->trans("ExtraFieldsCustomerInvoices"); |
|
148 | - $head[$h][2] = 'attributes'; |
|
149 | - $h++; |
|
150 | - |
|
151 | - $head[$h][0] = DOL_URL_ROOT.'/compta/facture/admin/facturedet_cust_extrafields.php'; |
|
152 | - $head[$h][1] = $langs->trans("ExtraFieldsLines"); |
|
153 | - $head[$h][2] = 'attributeslines'; |
|
154 | - $h++; |
|
155 | - |
|
156 | - $head[$h][0] = DOL_URL_ROOT.'/compta/facture/admin/facture_rec_cust_extrafields.php'; |
|
157 | - $head[$h][1] = $langs->trans("ExtraFieldsCustomerInvoicesRec"); |
|
158 | - $head[$h][2] = 'attributesrec'; |
|
159 | - $h++; |
|
160 | - |
|
161 | - $head[$h][0] = DOL_URL_ROOT.'/compta/facture/admin/facturedet_rec_cust_extrafields.php'; |
|
162 | - $head[$h][1] = $langs->trans("ExtraFieldsLinesRec"); |
|
163 | - $head[$h][2] = 'attributeslinesrec'; |
|
164 | - $h++; |
|
165 | - |
|
166 | - complete_head_from_modules($conf,$langs,null,$head,$h,'invoice_admin','remove'); |
|
167 | - |
|
168 | - return $head; |
|
125 | + global $langs, $conf, $user; |
|
126 | + |
|
127 | + $h = 0; |
|
128 | + $head = array(); |
|
129 | + |
|
130 | + $head[$h][0] = DOL_URL_ROOT.'/admin/facture.php'; |
|
131 | + $head[$h][1] = $langs->trans("Miscellaneous"); |
|
132 | + $head[$h][2] = 'general'; |
|
133 | + $h++; |
|
134 | + |
|
135 | + $head[$h][0] = DOL_URL_ROOT.'/admin/payment.php'; |
|
136 | + $head[$h][1] = $langs->trans("Payments"); |
|
137 | + $head[$h][2] = 'payment'; |
|
138 | + $h++; |
|
139 | + |
|
140 | + // Show more tabs from modules |
|
141 | + // Entries must be declared in modules descriptor with line |
|
142 | + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
|
143 | + // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab |
|
144 | + complete_head_from_modules($conf,$langs,null,$head,$h,'invoice_admin'); |
|
145 | + |
|
146 | + $head[$h][0] = DOL_URL_ROOT.'/compta/facture/admin/facture_cust_extrafields.php'; |
|
147 | + $head[$h][1] = $langs->trans("ExtraFieldsCustomerInvoices"); |
|
148 | + $head[$h][2] = 'attributes'; |
|
149 | + $h++; |
|
150 | + |
|
151 | + $head[$h][0] = DOL_URL_ROOT.'/compta/facture/admin/facturedet_cust_extrafields.php'; |
|
152 | + $head[$h][1] = $langs->trans("ExtraFieldsLines"); |
|
153 | + $head[$h][2] = 'attributeslines'; |
|
154 | + $h++; |
|
155 | + |
|
156 | + $head[$h][0] = DOL_URL_ROOT.'/compta/facture/admin/facture_rec_cust_extrafields.php'; |
|
157 | + $head[$h][1] = $langs->trans("ExtraFieldsCustomerInvoicesRec"); |
|
158 | + $head[$h][2] = 'attributesrec'; |
|
159 | + $h++; |
|
160 | + |
|
161 | + $head[$h][0] = DOL_URL_ROOT.'/compta/facture/admin/facturedet_rec_cust_extrafields.php'; |
|
162 | + $head[$h][1] = $langs->trans("ExtraFieldsLinesRec"); |
|
163 | + $head[$h][2] = 'attributeslinesrec'; |
|
164 | + $h++; |
|
165 | + |
|
166 | + complete_head_from_modules($conf,$langs,null,$head,$h,'invoice_admin','remove'); |
|
167 | + |
|
168 | + return $head; |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | |
@@ -177,15 +177,15 @@ discard block |
||
177 | 177 | */ |
178 | 178 | function invoice_rec_prepare_head($object) |
179 | 179 | { |
180 | - global $db, $langs, $conf; |
|
180 | + global $db, $langs, $conf; |
|
181 | 181 | |
182 | - $h = 0; |
|
183 | - $head = array(); |
|
182 | + $h = 0; |
|
183 | + $head = array(); |
|
184 | 184 | |
185 | - $head[$h][0] = DOL_URL_ROOT.'/compta/facture/fiche-rec.php?id='.$object->id; |
|
186 | - $head[$h][1] = $langs->trans("CardBill"); |
|
187 | - $head[$h][2] = 'card'; |
|
188 | - $h++; |
|
185 | + $head[$h][0] = DOL_URL_ROOT.'/compta/facture/fiche-rec.php?id='.$object->id; |
|
186 | + $head[$h][1] = $langs->trans("CardBill"); |
|
187 | + $head[$h][2] = 'card'; |
|
188 | + $h++; |
|
189 | 189 | |
190 | 190 | // Show more tabs from modules |
191 | 191 | // Entries must be declared in modules descriptor with line |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | // $this->tabs = array('entity:-tabname); to remove a tab |
194 | 194 | complete_head_from_modules($conf,$langs,$object,$head,$h,'invoice-rec'); |
195 | 195 | |
196 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'invoice-rec','remove'); |
|
196 | + complete_head_from_modules($conf,$langs,$object,$head,$h,'invoice-rec','remove'); |
|
197 | 197 | |
198 | - return $head; |
|
198 | + return $head; |
|
199 | 199 | } |