@@ -1727,7 +1727,7 @@ discard block |
||
1727 | 1727 | $isSelected = false; |
1728 | 1728 | |
1729 | 1729 | if(empty($option_key)) { |
1730 | - continue; |
|
1730 | + continue; |
|
1731 | 1731 | } |
1732 | 1732 | |
1733 | 1733 | if(empty($option_value)) { |
@@ -3128,8 +3128,8 @@ discard block |
||
3128 | 3128 | } |
3129 | 3129 | |
3130 | 3130 | // If there are some bug ridden versions, we should include them here |
3131 | - // and check immediately for one of this versions |
|
3132 | - $bug_php_versions = array(); |
|
3131 | + // and check immediately for one of this versions |
|
3132 | + $bug_php_versions = array(); |
|
3133 | 3133 | foreach ($bug_php_versions as $v) { |
3134 | 3134 | if ( version_compare($sys_php_version, $v, '=') === true) { |
3135 | 3135 | return -1; |
@@ -100,368 +100,368 @@ discard block |
||
100 | 100 | */ |
101 | 101 | class MysqlManager extends DBManager |
102 | 102 | { |
103 | - /** |
|
104 | - * @see DBManager::$dbType |
|
105 | - */ |
|
106 | - public $dbType = 'mysql'; |
|
107 | - public $variant = 'mysql'; |
|
108 | - public $dbName = 'MySQL'; |
|
109 | - public $label = 'LBL_MYSQL'; |
|
110 | - |
|
111 | - protected $maxNameLengths = array( |
|
112 | - 'table' => 64, |
|
113 | - 'column' => 64, |
|
114 | - 'index' => 64, |
|
115 | - 'alias' => 256 |
|
116 | - ); |
|
117 | - |
|
118 | - protected $type_map = array( |
|
119 | - 'int' => 'int', |
|
120 | - 'double' => 'double', |
|
121 | - 'float' => 'float', |
|
122 | - 'uint' => 'int unsigned', |
|
123 | - 'ulong' => 'bigint unsigned', |
|
124 | - 'long' => 'bigint', |
|
125 | - 'short' => 'smallint', |
|
126 | - 'varchar' => 'varchar', |
|
127 | - 'text' => 'text', |
|
128 | - 'longtext' => 'longtext', |
|
129 | - 'date' => 'date', |
|
130 | - 'enum' => 'varchar', |
|
131 | - 'relate' => 'varchar', |
|
132 | - 'multienum'=> 'text', |
|
133 | - 'html' => 'text', |
|
134 | - 'longhtml' => 'longtext', |
|
135 | - 'datetime' => 'datetime', |
|
136 | - 'datetimecombo' => 'datetime', |
|
137 | - 'time' => 'time', |
|
138 | - 'bool' => 'bool', |
|
139 | - 'tinyint' => 'tinyint', |
|
140 | - 'char' => 'char', |
|
141 | - 'blob' => 'blob', |
|
142 | - 'longblob' => 'longblob', |
|
143 | - 'currency' => 'decimal(26,6)', |
|
144 | - 'decimal' => 'decimal', |
|
145 | - 'decimal2' => 'decimal', |
|
146 | - 'id' => 'char(36)', |
|
147 | - 'url' => 'varchar', |
|
148 | - 'encrypt' => 'varchar', |
|
149 | - 'file' => 'varchar', |
|
150 | - 'decimal_tpl' => 'decimal(%d, %d)', |
|
151 | - |
|
152 | - ); |
|
153 | - |
|
154 | - protected $capabilities = array( |
|
155 | - "affected_rows" => true, |
|
156 | - "select_rows" => true, |
|
157 | - "inline_keys" => true, |
|
158 | - "create_user" => true, |
|
159 | - "fulltext" => true, |
|
160 | - "collation" => true, |
|
161 | - "create_db" => true, |
|
162 | - "disable_keys" => true, |
|
163 | - ); |
|
164 | - |
|
165 | - /** |
|
166 | - * Parses and runs queries |
|
167 | - * |
|
168 | - * @param string $sql SQL Statement to execute |
|
169 | - * @param bool $dieOnError True if we want to call die if the query returns errors |
|
170 | - * @param string $msg Message to log if error occurs |
|
171 | - * @param bool $suppress Flag to suppress all error output unless in debug logging mode. |
|
172 | - * @param bool $keepResult True if we want to push this result into the $lastResult array. |
|
173 | - * @return resource result set |
|
174 | - */ |
|
175 | - public function query($sql, $dieOnError = false, $msg = '', $suppress = false, $keepResult = false) |
|
176 | - { |
|
177 | - if(is_array($sql)) { |
|
178 | - return $this->queryArray($sql, $dieOnError, $msg, $suppress); |
|
179 | - } |
|
180 | - |
|
181 | - parent::countQuery($sql); |
|
182 | - $GLOBALS['log']->info('Query:' . $sql); |
|
183 | - $this->checkConnection(); |
|
184 | - $this->query_time = microtime(true); |
|
185 | - $this->lastsql = $sql; |
|
186 | - $result = $suppress?@mysql_query($sql, $this->database):mysql_query($sql, $this->database); |
|
187 | - |
|
188 | - $this->query_time = microtime(true) - $this->query_time; |
|
189 | - $GLOBALS['log']->info('Query Execution Time:'.$this->query_time); |
|
190 | - |
|
191 | - |
|
192 | - if($keepResult) |
|
193 | - $this->lastResult = $result; |
|
194 | - |
|
195 | - $this->checkError($msg.' Query Failed:' . $sql . '::', $dieOnError); |
|
196 | - return $result; |
|
197 | - } |
|
103 | + /** |
|
104 | + * @see DBManager::$dbType |
|
105 | + */ |
|
106 | + public $dbType = 'mysql'; |
|
107 | + public $variant = 'mysql'; |
|
108 | + public $dbName = 'MySQL'; |
|
109 | + public $label = 'LBL_MYSQL'; |
|
110 | + |
|
111 | + protected $maxNameLengths = array( |
|
112 | + 'table' => 64, |
|
113 | + 'column' => 64, |
|
114 | + 'index' => 64, |
|
115 | + 'alias' => 256 |
|
116 | + ); |
|
117 | + |
|
118 | + protected $type_map = array( |
|
119 | + 'int' => 'int', |
|
120 | + 'double' => 'double', |
|
121 | + 'float' => 'float', |
|
122 | + 'uint' => 'int unsigned', |
|
123 | + 'ulong' => 'bigint unsigned', |
|
124 | + 'long' => 'bigint', |
|
125 | + 'short' => 'smallint', |
|
126 | + 'varchar' => 'varchar', |
|
127 | + 'text' => 'text', |
|
128 | + 'longtext' => 'longtext', |
|
129 | + 'date' => 'date', |
|
130 | + 'enum' => 'varchar', |
|
131 | + 'relate' => 'varchar', |
|
132 | + 'multienum'=> 'text', |
|
133 | + 'html' => 'text', |
|
134 | + 'longhtml' => 'longtext', |
|
135 | + 'datetime' => 'datetime', |
|
136 | + 'datetimecombo' => 'datetime', |
|
137 | + 'time' => 'time', |
|
138 | + 'bool' => 'bool', |
|
139 | + 'tinyint' => 'tinyint', |
|
140 | + 'char' => 'char', |
|
141 | + 'blob' => 'blob', |
|
142 | + 'longblob' => 'longblob', |
|
143 | + 'currency' => 'decimal(26,6)', |
|
144 | + 'decimal' => 'decimal', |
|
145 | + 'decimal2' => 'decimal', |
|
146 | + 'id' => 'char(36)', |
|
147 | + 'url' => 'varchar', |
|
148 | + 'encrypt' => 'varchar', |
|
149 | + 'file' => 'varchar', |
|
150 | + 'decimal_tpl' => 'decimal(%d, %d)', |
|
151 | + |
|
152 | + ); |
|
153 | + |
|
154 | + protected $capabilities = array( |
|
155 | + "affected_rows" => true, |
|
156 | + "select_rows" => true, |
|
157 | + "inline_keys" => true, |
|
158 | + "create_user" => true, |
|
159 | + "fulltext" => true, |
|
160 | + "collation" => true, |
|
161 | + "create_db" => true, |
|
162 | + "disable_keys" => true, |
|
163 | + ); |
|
164 | + |
|
165 | + /** |
|
166 | + * Parses and runs queries |
|
167 | + * |
|
168 | + * @param string $sql SQL Statement to execute |
|
169 | + * @param bool $dieOnError True if we want to call die if the query returns errors |
|
170 | + * @param string $msg Message to log if error occurs |
|
171 | + * @param bool $suppress Flag to suppress all error output unless in debug logging mode. |
|
172 | + * @param bool $keepResult True if we want to push this result into the $lastResult array. |
|
173 | + * @return resource result set |
|
174 | + */ |
|
175 | + public function query($sql, $dieOnError = false, $msg = '', $suppress = false, $keepResult = false) |
|
176 | + { |
|
177 | + if(is_array($sql)) { |
|
178 | + return $this->queryArray($sql, $dieOnError, $msg, $suppress); |
|
179 | + } |
|
180 | + |
|
181 | + parent::countQuery($sql); |
|
182 | + $GLOBALS['log']->info('Query:' . $sql); |
|
183 | + $this->checkConnection(); |
|
184 | + $this->query_time = microtime(true); |
|
185 | + $this->lastsql = $sql; |
|
186 | + $result = $suppress?@mysql_query($sql, $this->database):mysql_query($sql, $this->database); |
|
187 | + |
|
188 | + $this->query_time = microtime(true) - $this->query_time; |
|
189 | + $GLOBALS['log']->info('Query Execution Time:'.$this->query_time); |
|
190 | + |
|
191 | + |
|
192 | + if($keepResult) |
|
193 | + $this->lastResult = $result; |
|
194 | + |
|
195 | + $this->checkError($msg.' Query Failed:' . $sql . '::', $dieOnError); |
|
196 | + return $result; |
|
197 | + } |
|
198 | 198 | |
199 | 199 | /** |
200 | 200 | * Returns the number of rows affected by the last query |
201 | 201 | * @param $result |
202 | 202 | * @return int |
203 | 203 | */ |
204 | - public function getAffectedRowCount($result) |
|
205 | - { |
|
206 | - return mysql_affected_rows($this->getDatabase()); |
|
207 | - } |
|
208 | - |
|
209 | - /** |
|
210 | - * Returns the number of rows returned by the result |
|
211 | - * |
|
212 | - * This function can't be reliably implemented on most DB, do not use it. |
|
213 | - * @abstract |
|
214 | - * @deprecated |
|
215 | - * @param resource $result |
|
216 | - * @return int |
|
217 | - */ |
|
218 | - public function getRowCount($result) |
|
219 | - { |
|
220 | - return mysql_num_rows($result); |
|
221 | - } |
|
222 | - |
|
223 | - /** |
|
224 | - * Disconnects from the database |
|
225 | - * |
|
226 | - * Also handles any cleanup needed |
|
227 | - */ |
|
228 | - public function disconnect() |
|
229 | - { |
|
230 | - $GLOBALS['log']->debug('Calling MySQL::disconnect()'); |
|
231 | - if(!empty($this->database)){ |
|
232 | - $this->freeResult(); |
|
233 | - mysql_close($this->database); |
|
234 | - $this->database = null; |
|
235 | - } |
|
236 | - } |
|
237 | - |
|
238 | - /** |
|
239 | - * @see DBManager::freeDbResult() |
|
240 | - */ |
|
241 | - protected function freeDbResult($dbResult) |
|
242 | - { |
|
243 | - if(!empty($dbResult)) |
|
244 | - mysql_free_result($dbResult); |
|
245 | - } |
|
246 | - |
|
247 | - |
|
248 | - /** |
|
249 | - * @abstract |
|
250 | - * Check if query has LIMIT clause |
|
251 | - * Relevant for now only for Mysql |
|
252 | - * @param string $sql |
|
253 | - * @return bool |
|
254 | - */ |
|
255 | - protected function hasLimit($sql) |
|
256 | - { |
|
257 | - return stripos($sql, " limit ") !== false; |
|
258 | - } |
|
259 | - |
|
260 | - /** |
|
261 | - * @see DBManager::limitQuery() |
|
262 | - */ |
|
263 | - public function limitQuery($sql, $start, $count, $dieOnError = false, $msg = '', $execute = true) |
|
264 | - { |
|
204 | + public function getAffectedRowCount($result) |
|
205 | + { |
|
206 | + return mysql_affected_rows($this->getDatabase()); |
|
207 | + } |
|
208 | + |
|
209 | + /** |
|
210 | + * Returns the number of rows returned by the result |
|
211 | + * |
|
212 | + * This function can't be reliably implemented on most DB, do not use it. |
|
213 | + * @abstract |
|
214 | + * @deprecated |
|
215 | + * @param resource $result |
|
216 | + * @return int |
|
217 | + */ |
|
218 | + public function getRowCount($result) |
|
219 | + { |
|
220 | + return mysql_num_rows($result); |
|
221 | + } |
|
222 | + |
|
223 | + /** |
|
224 | + * Disconnects from the database |
|
225 | + * |
|
226 | + * Also handles any cleanup needed |
|
227 | + */ |
|
228 | + public function disconnect() |
|
229 | + { |
|
230 | + $GLOBALS['log']->debug('Calling MySQL::disconnect()'); |
|
231 | + if(!empty($this->database)){ |
|
232 | + $this->freeResult(); |
|
233 | + mysql_close($this->database); |
|
234 | + $this->database = null; |
|
235 | + } |
|
236 | + } |
|
237 | + |
|
238 | + /** |
|
239 | + * @see DBManager::freeDbResult() |
|
240 | + */ |
|
241 | + protected function freeDbResult($dbResult) |
|
242 | + { |
|
243 | + if(!empty($dbResult)) |
|
244 | + mysql_free_result($dbResult); |
|
245 | + } |
|
246 | + |
|
247 | + |
|
248 | + /** |
|
249 | + * @abstract |
|
250 | + * Check if query has LIMIT clause |
|
251 | + * Relevant for now only for Mysql |
|
252 | + * @param string $sql |
|
253 | + * @return bool |
|
254 | + */ |
|
255 | + protected function hasLimit($sql) |
|
256 | + { |
|
257 | + return stripos($sql, " limit ") !== false; |
|
258 | + } |
|
259 | + |
|
260 | + /** |
|
261 | + * @see DBManager::limitQuery() |
|
262 | + */ |
|
263 | + public function limitQuery($sql, $start, $count, $dieOnError = false, $msg = '', $execute = true) |
|
264 | + { |
|
265 | 265 | $start = (int)$start; |
266 | 266 | $count = (int)$count; |
267 | - if ($start < 0) |
|
268 | - $start = 0; |
|
269 | - $GLOBALS['log']->debug('Limit Query:' . $sql. ' Start: ' .$start . ' count: ' . $count); |
|
270 | - |
|
271 | - $sql = "$sql LIMIT $start,$count"; |
|
272 | - $this->lastsql = $sql; |
|
273 | - |
|
274 | - if(!empty($GLOBALS['sugar_config']['check_query'])){ |
|
275 | - $this->checkQuery($sql); |
|
276 | - } |
|
277 | - if(!$execute) { |
|
278 | - return $sql; |
|
279 | - } |
|
280 | - |
|
281 | - return $this->query($sql, $dieOnError, $msg); |
|
282 | - } |
|
283 | - |
|
284 | - |
|
285 | - /** |
|
286 | - * @see DBManager::checkQuery() |
|
287 | - */ |
|
288 | - protected function checkQuery($sql, $object_name = false) |
|
289 | - { |
|
290 | - $result = $this->query('EXPLAIN ' . $sql); |
|
291 | - $badQuery = array(); |
|
292 | - while ($row = $this->fetchByAssoc($result)) { |
|
293 | - if (empty($row['table'])) |
|
294 | - continue; |
|
295 | - $badQuery[$row['table']] = ''; |
|
296 | - if (strtoupper($row['type']) == 'ALL') |
|
297 | - $badQuery[$row['table']] .= ' Full Table Scan;'; |
|
298 | - if (empty($row['key'])) |
|
299 | - $badQuery[$row['table']] .= ' No Index Key Used;'; |
|
300 | - if (!empty($row['Extra']) && substr_count($row['Extra'], 'Using filesort') > 0) |
|
301 | - $badQuery[$row['table']] .= ' Using FileSort;'; |
|
302 | - if (!empty($row['Extra']) && substr_count($row['Extra'], 'Using temporary') > 0) |
|
303 | - $badQuery[$row['table']] .= ' Using Temporary Table;'; |
|
304 | - } |
|
305 | - |
|
306 | - if ( empty($badQuery) ) |
|
307 | - return true; |
|
308 | - |
|
309 | - foreach($badQuery as $table=>$data ){ |
|
310 | - if(!empty($data)){ |
|
311 | - $warning = ' Table:' . $table . ' Data:' . $data; |
|
312 | - if(!empty($GLOBALS['sugar_config']['check_query_log'])){ |
|
313 | - $GLOBALS['log']->fatal($sql); |
|
314 | - $GLOBALS['log']->fatal('CHECK QUERY:' .$warning); |
|
315 | - } |
|
316 | - else{ |
|
317 | - $GLOBALS['log']->warn('CHECK QUERY:' .$warning); |
|
318 | - } |
|
319 | - } |
|
320 | - } |
|
321 | - |
|
322 | - return false; |
|
323 | - } |
|
324 | - |
|
325 | - /** |
|
326 | - * @see DBManager::get_columns() |
|
327 | - */ |
|
328 | - public function get_columns($tablename) |
|
329 | - { |
|
330 | - //find all unique indexes and primary keys. |
|
331 | - $result = $this->query("DESCRIBE $tablename"); |
|
332 | - |
|
333 | - $columns = array(); |
|
334 | - while (($row=$this->fetchByAssoc($result)) !=null) { |
|
335 | - $name = strtolower($row['Field']); |
|
336 | - $columns[$name]['name']=$name; |
|
337 | - $matches = array(); |
|
338 | - preg_match_all('/(\w+)(?:\(([0-9]+,?[0-9]*)\)|)( unsigned)?/i', $row['Type'], $matches); |
|
339 | - $columns[$name]['type']=strtolower($matches[1][0]); |
|
340 | - if ( isset($matches[2][0]) && in_array(strtolower($matches[1][0]),array('varchar','char','varchar2','int','decimal','float')) ) |
|
341 | - $columns[$name]['len']=strtolower($matches[2][0]); |
|
342 | - if ( stristr($row['Extra'],'auto_increment') ) |
|
343 | - $columns[$name]['auto_increment'] = '1'; |
|
344 | - if ($row['Null'] == 'NO' && !stristr($row['Key'],'PRI')) |
|
345 | - $columns[$name]['required'] = 'true'; |
|
346 | - if (!empty($row['Default']) ) |
|
347 | - $columns[$name]['default'] = $row['Default']; |
|
348 | - } |
|
349 | - return $columns; |
|
350 | - } |
|
351 | - |
|
352 | - /** |
|
353 | - * @see DBManager::getFieldsArray() |
|
354 | - */ |
|
355 | - public function getFieldsArray($result, $make_lower_case=false) |
|
356 | - { |
|
357 | - $field_array = array(); |
|
358 | - |
|
359 | - if(empty($result)) |
|
360 | - return 0; |
|
361 | - |
|
362 | - $fields = mysql_num_fields($result); |
|
363 | - for ($i=0; $i < $fields; $i++) { |
|
364 | - $meta = mysql_fetch_field($result, $i); |
|
365 | - if (!$meta) |
|
366 | - return array(); |
|
367 | - |
|
368 | - if($make_lower_case == true) |
|
369 | - $meta->name = strtolower($meta->name); |
|
370 | - |
|
371 | - $field_array[] = $meta->name; |
|
372 | - } |
|
373 | - |
|
374 | - return $field_array; |
|
375 | - } |
|
376 | - |
|
377 | - /** |
|
378 | - * @see DBManager::fetchRow() |
|
379 | - */ |
|
380 | - public function fetchRow($result) |
|
381 | - { |
|
382 | - if (empty($result)) return false; |
|
383 | - |
|
384 | - return mysql_fetch_assoc($result); |
|
385 | - } |
|
386 | - |
|
387 | - /** |
|
388 | - * @see DBManager::getTablesArray() |
|
389 | - */ |
|
390 | - public function getTablesArray() |
|
391 | - { |
|
392 | - $this->log->debug('Fetching table list'); |
|
393 | - |
|
394 | - if ($this->getDatabase()) { |
|
395 | - $tables = array(); |
|
396 | - $r = $this->query('SHOW TABLES'); |
|
397 | - if (!empty($r)) { |
|
398 | - while ($a = $this->fetchByAssoc($r)) { |
|
399 | - $row = array_values($a); |
|
400 | - $tables[]=$row[0]; |
|
401 | - } |
|
402 | - return $tables; |
|
403 | - } |
|
404 | - } |
|
405 | - |
|
406 | - return false; // no database available |
|
407 | - } |
|
408 | - |
|
409 | - /** |
|
410 | - * @see DBManager::version() |
|
411 | - */ |
|
412 | - public function version() |
|
413 | - { |
|
414 | - return $this->getOne("SELECT version() version"); |
|
415 | - } |
|
416 | - |
|
417 | - /** |
|
418 | - * @see DBManager::tableExists() |
|
419 | - */ |
|
420 | - public function tableExists($tableName) |
|
421 | - { |
|
422 | - $this->log->info("tableExists: $tableName"); |
|
423 | - |
|
424 | - if ($this->getDatabase()) { |
|
425 | - $result = $this->query("SHOW TABLES LIKE ".$this->quoted($tableName)); |
|
426 | - if(empty($result)) return false; |
|
427 | - $row = $this->fetchByAssoc($result); |
|
428 | - return !empty($row); |
|
429 | - } |
|
430 | - |
|
431 | - return false; |
|
432 | - } |
|
433 | - |
|
434 | - /** |
|
435 | - * Get tables like expression |
|
436 | - * @param $like string |
|
437 | - * @return array |
|
438 | - */ |
|
439 | - public function tablesLike($like) |
|
440 | - { |
|
441 | - if ($this->getDatabase()) { |
|
442 | - $tables = array(); |
|
443 | - $r = $this->query('SHOW TABLES LIKE '.$this->quoted($like)); |
|
444 | - if (!empty($r)) { |
|
445 | - while ($a = $this->fetchByAssoc($r)) { |
|
446 | - $row = array_values($a); |
|
447 | - $tables[]=$row[0]; |
|
448 | - } |
|
449 | - return $tables; |
|
450 | - } |
|
451 | - } |
|
452 | - return false; |
|
453 | - } |
|
454 | - |
|
455 | - /** |
|
456 | - * @see DBManager::quote() |
|
457 | - */ |
|
458 | - public function quote($string) |
|
459 | - { |
|
460 | - if(is_array($string)) { |
|
461 | - return $this->arrayQuote($string); |
|
462 | - } |
|
463 | - return mysqli_real_escape_string($this->quoteInternal($string), $this->getDatabase()); |
|
464 | - } |
|
267 | + if ($start < 0) |
|
268 | + $start = 0; |
|
269 | + $GLOBALS['log']->debug('Limit Query:' . $sql. ' Start: ' .$start . ' count: ' . $count); |
|
270 | + |
|
271 | + $sql = "$sql LIMIT $start,$count"; |
|
272 | + $this->lastsql = $sql; |
|
273 | + |
|
274 | + if(!empty($GLOBALS['sugar_config']['check_query'])){ |
|
275 | + $this->checkQuery($sql); |
|
276 | + } |
|
277 | + if(!$execute) { |
|
278 | + return $sql; |
|
279 | + } |
|
280 | + |
|
281 | + return $this->query($sql, $dieOnError, $msg); |
|
282 | + } |
|
283 | + |
|
284 | + |
|
285 | + /** |
|
286 | + * @see DBManager::checkQuery() |
|
287 | + */ |
|
288 | + protected function checkQuery($sql, $object_name = false) |
|
289 | + { |
|
290 | + $result = $this->query('EXPLAIN ' . $sql); |
|
291 | + $badQuery = array(); |
|
292 | + while ($row = $this->fetchByAssoc($result)) { |
|
293 | + if (empty($row['table'])) |
|
294 | + continue; |
|
295 | + $badQuery[$row['table']] = ''; |
|
296 | + if (strtoupper($row['type']) == 'ALL') |
|
297 | + $badQuery[$row['table']] .= ' Full Table Scan;'; |
|
298 | + if (empty($row['key'])) |
|
299 | + $badQuery[$row['table']] .= ' No Index Key Used;'; |
|
300 | + if (!empty($row['Extra']) && substr_count($row['Extra'], 'Using filesort') > 0) |
|
301 | + $badQuery[$row['table']] .= ' Using FileSort;'; |
|
302 | + if (!empty($row['Extra']) && substr_count($row['Extra'], 'Using temporary') > 0) |
|
303 | + $badQuery[$row['table']] .= ' Using Temporary Table;'; |
|
304 | + } |
|
305 | + |
|
306 | + if ( empty($badQuery) ) |
|
307 | + return true; |
|
308 | + |
|
309 | + foreach($badQuery as $table=>$data ){ |
|
310 | + if(!empty($data)){ |
|
311 | + $warning = ' Table:' . $table . ' Data:' . $data; |
|
312 | + if(!empty($GLOBALS['sugar_config']['check_query_log'])){ |
|
313 | + $GLOBALS['log']->fatal($sql); |
|
314 | + $GLOBALS['log']->fatal('CHECK QUERY:' .$warning); |
|
315 | + } |
|
316 | + else{ |
|
317 | + $GLOBALS['log']->warn('CHECK QUERY:' .$warning); |
|
318 | + } |
|
319 | + } |
|
320 | + } |
|
321 | + |
|
322 | + return false; |
|
323 | + } |
|
324 | + |
|
325 | + /** |
|
326 | + * @see DBManager::get_columns() |
|
327 | + */ |
|
328 | + public function get_columns($tablename) |
|
329 | + { |
|
330 | + //find all unique indexes and primary keys. |
|
331 | + $result = $this->query("DESCRIBE $tablename"); |
|
332 | + |
|
333 | + $columns = array(); |
|
334 | + while (($row=$this->fetchByAssoc($result)) !=null) { |
|
335 | + $name = strtolower($row['Field']); |
|
336 | + $columns[$name]['name']=$name; |
|
337 | + $matches = array(); |
|
338 | + preg_match_all('/(\w+)(?:\(([0-9]+,?[0-9]*)\)|)( unsigned)?/i', $row['Type'], $matches); |
|
339 | + $columns[$name]['type']=strtolower($matches[1][0]); |
|
340 | + if ( isset($matches[2][0]) && in_array(strtolower($matches[1][0]),array('varchar','char','varchar2','int','decimal','float')) ) |
|
341 | + $columns[$name]['len']=strtolower($matches[2][0]); |
|
342 | + if ( stristr($row['Extra'],'auto_increment') ) |
|
343 | + $columns[$name]['auto_increment'] = '1'; |
|
344 | + if ($row['Null'] == 'NO' && !stristr($row['Key'],'PRI')) |
|
345 | + $columns[$name]['required'] = 'true'; |
|
346 | + if (!empty($row['Default']) ) |
|
347 | + $columns[$name]['default'] = $row['Default']; |
|
348 | + } |
|
349 | + return $columns; |
|
350 | + } |
|
351 | + |
|
352 | + /** |
|
353 | + * @see DBManager::getFieldsArray() |
|
354 | + */ |
|
355 | + public function getFieldsArray($result, $make_lower_case=false) |
|
356 | + { |
|
357 | + $field_array = array(); |
|
358 | + |
|
359 | + if(empty($result)) |
|
360 | + return 0; |
|
361 | + |
|
362 | + $fields = mysql_num_fields($result); |
|
363 | + for ($i=0; $i < $fields; $i++) { |
|
364 | + $meta = mysql_fetch_field($result, $i); |
|
365 | + if (!$meta) |
|
366 | + return array(); |
|
367 | + |
|
368 | + if($make_lower_case == true) |
|
369 | + $meta->name = strtolower($meta->name); |
|
370 | + |
|
371 | + $field_array[] = $meta->name; |
|
372 | + } |
|
373 | + |
|
374 | + return $field_array; |
|
375 | + } |
|
376 | + |
|
377 | + /** |
|
378 | + * @see DBManager::fetchRow() |
|
379 | + */ |
|
380 | + public function fetchRow($result) |
|
381 | + { |
|
382 | + if (empty($result)) return false; |
|
383 | + |
|
384 | + return mysql_fetch_assoc($result); |
|
385 | + } |
|
386 | + |
|
387 | + /** |
|
388 | + * @see DBManager::getTablesArray() |
|
389 | + */ |
|
390 | + public function getTablesArray() |
|
391 | + { |
|
392 | + $this->log->debug('Fetching table list'); |
|
393 | + |
|
394 | + if ($this->getDatabase()) { |
|
395 | + $tables = array(); |
|
396 | + $r = $this->query('SHOW TABLES'); |
|
397 | + if (!empty($r)) { |
|
398 | + while ($a = $this->fetchByAssoc($r)) { |
|
399 | + $row = array_values($a); |
|
400 | + $tables[]=$row[0]; |
|
401 | + } |
|
402 | + return $tables; |
|
403 | + } |
|
404 | + } |
|
405 | + |
|
406 | + return false; // no database available |
|
407 | + } |
|
408 | + |
|
409 | + /** |
|
410 | + * @see DBManager::version() |
|
411 | + */ |
|
412 | + public function version() |
|
413 | + { |
|
414 | + return $this->getOne("SELECT version() version"); |
|
415 | + } |
|
416 | + |
|
417 | + /** |
|
418 | + * @see DBManager::tableExists() |
|
419 | + */ |
|
420 | + public function tableExists($tableName) |
|
421 | + { |
|
422 | + $this->log->info("tableExists: $tableName"); |
|
423 | + |
|
424 | + if ($this->getDatabase()) { |
|
425 | + $result = $this->query("SHOW TABLES LIKE ".$this->quoted($tableName)); |
|
426 | + if(empty($result)) return false; |
|
427 | + $row = $this->fetchByAssoc($result); |
|
428 | + return !empty($row); |
|
429 | + } |
|
430 | + |
|
431 | + return false; |
|
432 | + } |
|
433 | + |
|
434 | + /** |
|
435 | + * Get tables like expression |
|
436 | + * @param $like string |
|
437 | + * @return array |
|
438 | + */ |
|
439 | + public function tablesLike($like) |
|
440 | + { |
|
441 | + if ($this->getDatabase()) { |
|
442 | + $tables = array(); |
|
443 | + $r = $this->query('SHOW TABLES LIKE '.$this->quoted($like)); |
|
444 | + if (!empty($r)) { |
|
445 | + while ($a = $this->fetchByAssoc($r)) { |
|
446 | + $row = array_values($a); |
|
447 | + $tables[]=$row[0]; |
|
448 | + } |
|
449 | + return $tables; |
|
450 | + } |
|
451 | + } |
|
452 | + return false; |
|
453 | + } |
|
454 | + |
|
455 | + /** |
|
456 | + * @see DBManager::quote() |
|
457 | + */ |
|
458 | + public function quote($string) |
|
459 | + { |
|
460 | + if(is_array($string)) { |
|
461 | + return $this->arrayQuote($string); |
|
462 | + } |
|
463 | + return mysqli_real_escape_string($this->quoteInternal($string), $this->getDatabase()); |
|
464 | + } |
|
465 | 465 | |
466 | 466 | /** |
467 | 467 | * @see DBManager::quoteIdentifier() |
@@ -471,272 +471,272 @@ discard block |
||
471 | 471 | return '`'.$string.'`'; |
472 | 472 | } |
473 | 473 | |
474 | - /** |
|
475 | - * @see DBManager::connect() |
|
476 | - */ |
|
477 | - public function connect(array $configOptions = null, $dieOnError = false) |
|
478 | - { |
|
479 | - global $sugar_config; |
|
480 | - |
|
481 | - if(is_null($configOptions)) |
|
482 | - $configOptions = $sugar_config['dbconfig']; |
|
483 | - |
|
484 | - if ($this->getOption('persistent')) { |
|
485 | - $this->database = @mysql_pconnect( |
|
486 | - $configOptions['db_host_name'], |
|
487 | - $configOptions['db_user_name'], |
|
488 | - $configOptions['db_password'] |
|
489 | - ); |
|
490 | - } |
|
491 | - |
|
492 | - if (!$this->database) { |
|
493 | - $this->database = mysql_connect( |
|
494 | - $configOptions['db_host_name'], |
|
495 | - $configOptions['db_user_name'], |
|
496 | - $configOptions['db_password'] |
|
497 | - ); |
|
498 | - if(empty($this->database)) { |
|
499 | - $GLOBALS['log']->fatal("Could not connect to server ".$configOptions['db_host_name']." as ".$configOptions['db_user_name'].":".mysql_error()); |
|
500 | - if($dieOnError) { |
|
501 | - if(isset($GLOBALS['app_strings']['ERR_NO_DB'])) { |
|
502 | - sugar_die($GLOBALS['app_strings']['ERR_NO_DB']); |
|
503 | - } else { |
|
504 | - sugar_die("Could not connect to the database. Please refer to suitecrm.log for details."); |
|
505 | - } |
|
506 | - } else { |
|
507 | - return false; |
|
508 | - } |
|
509 | - } |
|
510 | - // Do not pass connection information because we have not connected yet |
|
511 | - if($this->database && $this->getOption('persistent')){ |
|
512 | - $_SESSION['administrator_error'] = "<b>Severe Performance Degradation: Persistent Database Connections " |
|
513 | - . "not working. Please set \$sugar_config['dbconfigoption']['persistent'] to false " |
|
514 | - . "in your config.php file</b>"; |
|
515 | - } |
|
516 | - } |
|
517 | - if(!empty($configOptions['db_name']) && !@mysql_select_db($configOptions['db_name'])) { |
|
518 | - $GLOBALS['log']->fatal( "Unable to select database {$configOptions['db_name']}: " . mysql_error($this->database)); |
|
519 | - if($dieOnError) { |
|
520 | - sugar_die($GLOBALS['app_strings']['ERR_NO_DB']); |
|
521 | - } else { |
|
522 | - return false; |
|
523 | - } |
|
524 | - } |
|
525 | - |
|
526 | - // cn: using direct calls to prevent this from spamming the Logs |
|
527 | - mysql_query("SET CHARACTER SET utf8", $this->database); |
|
528 | - $names = "SET NAMES 'utf8'"; |
|
529 | - $collation = $this->getOption('collation'); |
|
530 | - if(!empty($collation)) { |
|
531 | - $names .= " COLLATE '$collation'"; |
|
532 | - } |
|
533 | - mysql_query($names, $this->database); |
|
534 | - |
|
535 | - if(!$this->checkError('Could Not Connect:', $dieOnError)) |
|
536 | - $GLOBALS['log']->info("connected to db"); |
|
537 | - $this->connectOptions = $configOptions; |
|
538 | - |
|
539 | - $GLOBALS['log']->info("Connect:".$this->database); |
|
540 | - return true; |
|
541 | - } |
|
542 | - |
|
543 | - /** |
|
544 | - * @see DBManager::repairTableParams() |
|
545 | - * |
|
546 | - * For MySQL, we can write the ALTER TABLE statement all in one line, which speeds things |
|
547 | - * up quite a bit. So here, we'll parse the returned SQL into a single ALTER TABLE command. |
|
548 | - */ |
|
549 | - public function repairTableParams($tablename, $fielddefs, $indices, $execute = true, $engine = null) |
|
550 | - { |
|
551 | - $sql = parent::repairTableParams($tablename,$fielddefs,$indices,false,$engine); |
|
552 | - |
|
553 | - if ( $sql == '' ) |
|
554 | - return ''; |
|
555 | - |
|
556 | - if ( stristr($sql,'create table') ) |
|
557 | - { |
|
558 | - if ($execute) { |
|
559 | - $msg = "Error creating table: ".$tablename. ":"; |
|
560 | - $this->query($sql,true,$msg); |
|
561 | - } |
|
562 | - return $sql; |
|
563 | - } |
|
564 | - |
|
565 | - // first, parse out all the comments |
|
566 | - $match = array(); |
|
567 | - preg_match_all('!/\*.*?\*/!is', $sql, $match); |
|
568 | - $commentBlocks = $match[0]; |
|
569 | - $sql = preg_replace('!/\*.*?\*/!is','', $sql); |
|
570 | - |
|
571 | - // now, we should only have alter table statements |
|
572 | - // let's replace the 'alter table name' part with a comma |
|
573 | - $sql = preg_replace("!alter table $tablename!is",', ', $sql); |
|
574 | - |
|
575 | - // re-add it at the beginning |
|
576 | - $sql = substr_replace($sql,'',strpos($sql,','),1); |
|
577 | - $sql = str_replace(";","",$sql); |
|
578 | - $sql = str_replace("\n","",$sql); |
|
579 | - $sql = "ALTER TABLE $tablename $sql"; |
|
580 | - |
|
581 | - if ( $execute ) |
|
582 | - $this->query($sql,'Error with MySQL repair table'); |
|
583 | - |
|
584 | - // and re-add the comments at the beginning |
|
585 | - $sql = implode("\n",$commentBlocks) . "\n". $sql . "\n"; |
|
586 | - |
|
587 | - return $sql; |
|
588 | - } |
|
589 | - |
|
590 | - /** |
|
591 | - * @see DBManager::convert() |
|
592 | - */ |
|
593 | - public function convert($string, $type, array $additional_parameters = array()) |
|
594 | - { |
|
595 | - $all_parameters = $additional_parameters; |
|
596 | - if(is_array($string)) { |
|
597 | - $all_parameters = array_merge($string, $all_parameters); |
|
598 | - } elseif (!is_null($string)) { |
|
599 | - array_unshift($all_parameters, $string); |
|
600 | - } |
|
601 | - $all_strings = implode(',', $all_parameters); |
|
602 | - |
|
603 | - switch (strtolower($type)) { |
|
604 | - case 'today': |
|
605 | - return "CURDATE()"; |
|
606 | - case 'left': |
|
607 | - return "LEFT($all_strings)"; |
|
608 | - case 'date_format': |
|
609 | - if(empty($additional_parameters)) { |
|
610 | - return "DATE_FORMAT($string,'%Y-%m-%d')"; |
|
611 | - } else { |
|
612 | - $format = $additional_parameters[0]; |
|
613 | - if($format[0] != "'") { |
|
614 | - $format = $this->quoted($format); |
|
615 | - } |
|
616 | - return "DATE_FORMAT($string,$format)"; |
|
617 | - } |
|
618 | - case 'ifnull': |
|
619 | - if(empty($additional_parameters) && !strstr($all_strings, ",")) { |
|
620 | - $all_strings .= ",''"; |
|
621 | - } |
|
622 | - return "IFNULL($all_strings)"; |
|
623 | - case 'concat': |
|
624 | - return "CONCAT($all_strings)"; |
|
625 | - case 'quarter': |
|
626 | - return "QUARTER($string)"; |
|
627 | - case "length": |
|
628 | - return "LENGTH($string)"; |
|
629 | - case 'month': |
|
630 | - return "MONTH($string)"; |
|
631 | - case 'add_date': |
|
632 | - return "DATE_ADD($string, INTERVAL {$additional_parameters[0]} {$additional_parameters[1]})"; |
|
633 | - case 'add_time': |
|
634 | - return "DATE_ADD($string, INTERVAL + CONCAT({$additional_parameters[0]}, ':', {$additional_parameters[1]}) HOUR_MINUTE)"; |
|
474 | + /** |
|
475 | + * @see DBManager::connect() |
|
476 | + */ |
|
477 | + public function connect(array $configOptions = null, $dieOnError = false) |
|
478 | + { |
|
479 | + global $sugar_config; |
|
480 | + |
|
481 | + if(is_null($configOptions)) |
|
482 | + $configOptions = $sugar_config['dbconfig']; |
|
483 | + |
|
484 | + if ($this->getOption('persistent')) { |
|
485 | + $this->database = @mysql_pconnect( |
|
486 | + $configOptions['db_host_name'], |
|
487 | + $configOptions['db_user_name'], |
|
488 | + $configOptions['db_password'] |
|
489 | + ); |
|
490 | + } |
|
491 | + |
|
492 | + if (!$this->database) { |
|
493 | + $this->database = mysql_connect( |
|
494 | + $configOptions['db_host_name'], |
|
495 | + $configOptions['db_user_name'], |
|
496 | + $configOptions['db_password'] |
|
497 | + ); |
|
498 | + if(empty($this->database)) { |
|
499 | + $GLOBALS['log']->fatal("Could not connect to server ".$configOptions['db_host_name']." as ".$configOptions['db_user_name'].":".mysql_error()); |
|
500 | + if($dieOnError) { |
|
501 | + if(isset($GLOBALS['app_strings']['ERR_NO_DB'])) { |
|
502 | + sugar_die($GLOBALS['app_strings']['ERR_NO_DB']); |
|
503 | + } else { |
|
504 | + sugar_die("Could not connect to the database. Please refer to suitecrm.log for details."); |
|
505 | + } |
|
506 | + } else { |
|
507 | + return false; |
|
508 | + } |
|
509 | + } |
|
510 | + // Do not pass connection information because we have not connected yet |
|
511 | + if($this->database && $this->getOption('persistent')){ |
|
512 | + $_SESSION['administrator_error'] = "<b>Severe Performance Degradation: Persistent Database Connections " |
|
513 | + . "not working. Please set \$sugar_config['dbconfigoption']['persistent'] to false " |
|
514 | + . "in your config.php file</b>"; |
|
515 | + } |
|
516 | + } |
|
517 | + if(!empty($configOptions['db_name']) && !@mysql_select_db($configOptions['db_name'])) { |
|
518 | + $GLOBALS['log']->fatal( "Unable to select database {$configOptions['db_name']}: " . mysql_error($this->database)); |
|
519 | + if($dieOnError) { |
|
520 | + sugar_die($GLOBALS['app_strings']['ERR_NO_DB']); |
|
521 | + } else { |
|
522 | + return false; |
|
523 | + } |
|
524 | + } |
|
525 | + |
|
526 | + // cn: using direct calls to prevent this from spamming the Logs |
|
527 | + mysql_query("SET CHARACTER SET utf8", $this->database); |
|
528 | + $names = "SET NAMES 'utf8'"; |
|
529 | + $collation = $this->getOption('collation'); |
|
530 | + if(!empty($collation)) { |
|
531 | + $names .= " COLLATE '$collation'"; |
|
532 | + } |
|
533 | + mysql_query($names, $this->database); |
|
534 | + |
|
535 | + if(!$this->checkError('Could Not Connect:', $dieOnError)) |
|
536 | + $GLOBALS['log']->info("connected to db"); |
|
537 | + $this->connectOptions = $configOptions; |
|
538 | + |
|
539 | + $GLOBALS['log']->info("Connect:".$this->database); |
|
540 | + return true; |
|
541 | + } |
|
542 | + |
|
543 | + /** |
|
544 | + * @see DBManager::repairTableParams() |
|
545 | + * |
|
546 | + * For MySQL, we can write the ALTER TABLE statement all in one line, which speeds things |
|
547 | + * up quite a bit. So here, we'll parse the returned SQL into a single ALTER TABLE command. |
|
548 | + */ |
|
549 | + public function repairTableParams($tablename, $fielddefs, $indices, $execute = true, $engine = null) |
|
550 | + { |
|
551 | + $sql = parent::repairTableParams($tablename,$fielddefs,$indices,false,$engine); |
|
552 | + |
|
553 | + if ( $sql == '' ) |
|
554 | + return ''; |
|
555 | + |
|
556 | + if ( stristr($sql,'create table') ) |
|
557 | + { |
|
558 | + if ($execute) { |
|
559 | + $msg = "Error creating table: ".$tablename. ":"; |
|
560 | + $this->query($sql,true,$msg); |
|
561 | + } |
|
562 | + return $sql; |
|
563 | + } |
|
564 | + |
|
565 | + // first, parse out all the comments |
|
566 | + $match = array(); |
|
567 | + preg_match_all('!/\*.*?\*/!is', $sql, $match); |
|
568 | + $commentBlocks = $match[0]; |
|
569 | + $sql = preg_replace('!/\*.*?\*/!is','', $sql); |
|
570 | + |
|
571 | + // now, we should only have alter table statements |
|
572 | + // let's replace the 'alter table name' part with a comma |
|
573 | + $sql = preg_replace("!alter table $tablename!is",', ', $sql); |
|
574 | + |
|
575 | + // re-add it at the beginning |
|
576 | + $sql = substr_replace($sql,'',strpos($sql,','),1); |
|
577 | + $sql = str_replace(";","",$sql); |
|
578 | + $sql = str_replace("\n","",$sql); |
|
579 | + $sql = "ALTER TABLE $tablename $sql"; |
|
580 | + |
|
581 | + if ( $execute ) |
|
582 | + $this->query($sql,'Error with MySQL repair table'); |
|
583 | + |
|
584 | + // and re-add the comments at the beginning |
|
585 | + $sql = implode("\n",$commentBlocks) . "\n". $sql . "\n"; |
|
586 | + |
|
587 | + return $sql; |
|
588 | + } |
|
589 | + |
|
590 | + /** |
|
591 | + * @see DBManager::convert() |
|
592 | + */ |
|
593 | + public function convert($string, $type, array $additional_parameters = array()) |
|
594 | + { |
|
595 | + $all_parameters = $additional_parameters; |
|
596 | + if(is_array($string)) { |
|
597 | + $all_parameters = array_merge($string, $all_parameters); |
|
598 | + } elseif (!is_null($string)) { |
|
599 | + array_unshift($all_parameters, $string); |
|
600 | + } |
|
601 | + $all_strings = implode(',', $all_parameters); |
|
602 | + |
|
603 | + switch (strtolower($type)) { |
|
604 | + case 'today': |
|
605 | + return "CURDATE()"; |
|
606 | + case 'left': |
|
607 | + return "LEFT($all_strings)"; |
|
608 | + case 'date_format': |
|
609 | + if(empty($additional_parameters)) { |
|
610 | + return "DATE_FORMAT($string,'%Y-%m-%d')"; |
|
611 | + } else { |
|
612 | + $format = $additional_parameters[0]; |
|
613 | + if($format[0] != "'") { |
|
614 | + $format = $this->quoted($format); |
|
615 | + } |
|
616 | + return "DATE_FORMAT($string,$format)"; |
|
617 | + } |
|
618 | + case 'ifnull': |
|
619 | + if(empty($additional_parameters) && !strstr($all_strings, ",")) { |
|
620 | + $all_strings .= ",''"; |
|
621 | + } |
|
622 | + return "IFNULL($all_strings)"; |
|
623 | + case 'concat': |
|
624 | + return "CONCAT($all_strings)"; |
|
625 | + case 'quarter': |
|
626 | + return "QUARTER($string)"; |
|
627 | + case "length": |
|
628 | + return "LENGTH($string)"; |
|
629 | + case 'month': |
|
630 | + return "MONTH($string)"; |
|
631 | + case 'add_date': |
|
632 | + return "DATE_ADD($string, INTERVAL {$additional_parameters[0]} {$additional_parameters[1]})"; |
|
633 | + case 'add_time': |
|
634 | + return "DATE_ADD($string, INTERVAL + CONCAT({$additional_parameters[0]}, ':', {$additional_parameters[1]}) HOUR_MINUTE)"; |
|
635 | 635 | case 'add_tz_offset' : |
636 | 636 | $getUserUTCOffset = $GLOBALS['timedate']->getUserUTCOffset(); |
637 | 637 | $operation = $getUserUTCOffset < 0 ? '-' : '+'; |
638 | 638 | return $string . ' ' . $operation . ' INTERVAL ' . abs($getUserUTCOffset) . ' MINUTE'; |
639 | 639 | case 'avg': |
640 | 640 | return "avg($string)"; |
641 | - } |
|
642 | - |
|
643 | - return $string; |
|
644 | - } |
|
645 | - |
|
646 | - /** |
|
647 | - * (non-PHPdoc) |
|
648 | - * @see DBManager::fromConvert() |
|
649 | - */ |
|
650 | - public function fromConvert($string, $type) |
|
651 | - { |
|
652 | - return $string; |
|
653 | - } |
|
654 | - |
|
655 | - /** |
|
656 | - * Returns the name of the engine to use or null if we are to use the default |
|
657 | - * |
|
658 | - * @param object $bean SugarBean instance |
|
659 | - * @return string |
|
660 | - */ |
|
661 | - protected function getEngine($bean) |
|
662 | - { |
|
663 | - global $dictionary; |
|
664 | - $engine = null; |
|
665 | - if (isset($dictionary[$bean->getObjectName()]['engine'])) { |
|
666 | - $engine = $dictionary[$bean->getObjectName()]['engine']; |
|
667 | - } |
|
668 | - return $engine; |
|
669 | - } |
|
670 | - |
|
671 | - /** |
|
672 | - * Returns true if the engine given is enabled in the backend |
|
673 | - * |
|
674 | - * @param string $engine |
|
675 | - * @return bool |
|
676 | - */ |
|
677 | - protected function isEngineEnabled($engine) |
|
678 | - { |
|
679 | - if(!is_string($engine)) return false; |
|
680 | - |
|
681 | - $engine = strtoupper($engine); |
|
682 | - |
|
683 | - $r = $this->query("SHOW ENGINES"); |
|
684 | - |
|
685 | - while ( $row = $this->fetchByAssoc($r) ) |
|
686 | - if ( strtoupper($row['Engine']) == $engine ) |
|
687 | - return ($row['Support']=='YES' || $row['Support']=='DEFAULT'); |
|
688 | - |
|
689 | - return false; |
|
690 | - } |
|
691 | - |
|
692 | - /** |
|
693 | - * @see DBManager::createTableSQL() |
|
694 | - */ |
|
695 | - public function createTableSQL(SugarBean $bean) |
|
696 | - { |
|
697 | - $tablename = $bean->getTableName(); |
|
698 | - $fieldDefs = $bean->getFieldDefinitions(); |
|
699 | - $indices = $bean->getIndices(); |
|
700 | - $engine = $this->getEngine($bean); |
|
701 | - return $this->createTableSQLParams($tablename, $fieldDefs, $indices, $engine); |
|
702 | - } |
|
703 | - |
|
704 | - /** |
|
705 | - * Generates sql for create table statement for a bean. |
|
706 | - * |
|
707 | - * @param string $tablename |
|
708 | - * @param array $fieldDefs |
|
709 | - * @param array $indices |
|
710 | - * @param string $engine optional, MySQL engine to use |
|
711 | - * @return string SQL Create Table statement |
|
712 | - */ |
|
713 | - public function createTableSQLParams($tablename, $fieldDefs, $indices, $engine = null) |
|
714 | - { |
|
715 | - if ( empty($engine) && isset($fieldDefs['engine'])) |
|
716 | - $engine = $fieldDefs['engine']; |
|
717 | - if ( !$this->isEngineEnabled($engine) ) |
|
718 | - $engine = ''; |
|
719 | - |
|
720 | - $columns = $this->columnSQLRep($fieldDefs, false, $tablename); |
|
721 | - if (empty($columns)) |
|
722 | - return false; |
|
723 | - |
|
724 | - $keys = $this->keysSQL($indices); |
|
725 | - if (!empty($keys)) |
|
726 | - $keys = ",$keys"; |
|
727 | - |
|
728 | - // cn: bug 9873 - module tables do not get created in utf8 with assoc collation |
|
729 | - $collation = $this->getOption('collation'); |
|
730 | - if(empty($collation)) { |
|
731 | - $collation = 'utf8_general_ci'; |
|
732 | - } |
|
733 | - $sql = "CREATE TABLE $tablename ($columns $keys) CHARACTER SET utf8 COLLATE $collation"; |
|
734 | - |
|
735 | - if (!empty($engine)) |
|
736 | - $sql.= " ENGINE=$engine"; |
|
737 | - |
|
738 | - return $sql; |
|
739 | - } |
|
641 | + } |
|
642 | + |
|
643 | + return $string; |
|
644 | + } |
|
645 | + |
|
646 | + /** |
|
647 | + * (non-PHPdoc) |
|
648 | + * @see DBManager::fromConvert() |
|
649 | + */ |
|
650 | + public function fromConvert($string, $type) |
|
651 | + { |
|
652 | + return $string; |
|
653 | + } |
|
654 | + |
|
655 | + /** |
|
656 | + * Returns the name of the engine to use or null if we are to use the default |
|
657 | + * |
|
658 | + * @param object $bean SugarBean instance |
|
659 | + * @return string |
|
660 | + */ |
|
661 | + protected function getEngine($bean) |
|
662 | + { |
|
663 | + global $dictionary; |
|
664 | + $engine = null; |
|
665 | + if (isset($dictionary[$bean->getObjectName()]['engine'])) { |
|
666 | + $engine = $dictionary[$bean->getObjectName()]['engine']; |
|
667 | + } |
|
668 | + return $engine; |
|
669 | + } |
|
670 | + |
|
671 | + /** |
|
672 | + * Returns true if the engine given is enabled in the backend |
|
673 | + * |
|
674 | + * @param string $engine |
|
675 | + * @return bool |
|
676 | + */ |
|
677 | + protected function isEngineEnabled($engine) |
|
678 | + { |
|
679 | + if(!is_string($engine)) return false; |
|
680 | + |
|
681 | + $engine = strtoupper($engine); |
|
682 | + |
|
683 | + $r = $this->query("SHOW ENGINES"); |
|
684 | + |
|
685 | + while ( $row = $this->fetchByAssoc($r) ) |
|
686 | + if ( strtoupper($row['Engine']) == $engine ) |
|
687 | + return ($row['Support']=='YES' || $row['Support']=='DEFAULT'); |
|
688 | + |
|
689 | + return false; |
|
690 | + } |
|
691 | + |
|
692 | + /** |
|
693 | + * @see DBManager::createTableSQL() |
|
694 | + */ |
|
695 | + public function createTableSQL(SugarBean $bean) |
|
696 | + { |
|
697 | + $tablename = $bean->getTableName(); |
|
698 | + $fieldDefs = $bean->getFieldDefinitions(); |
|
699 | + $indices = $bean->getIndices(); |
|
700 | + $engine = $this->getEngine($bean); |
|
701 | + return $this->createTableSQLParams($tablename, $fieldDefs, $indices, $engine); |
|
702 | + } |
|
703 | + |
|
704 | + /** |
|
705 | + * Generates sql for create table statement for a bean. |
|
706 | + * |
|
707 | + * @param string $tablename |
|
708 | + * @param array $fieldDefs |
|
709 | + * @param array $indices |
|
710 | + * @param string $engine optional, MySQL engine to use |
|
711 | + * @return string SQL Create Table statement |
|
712 | + */ |
|
713 | + public function createTableSQLParams($tablename, $fieldDefs, $indices, $engine = null) |
|
714 | + { |
|
715 | + if ( empty($engine) && isset($fieldDefs['engine'])) |
|
716 | + $engine = $fieldDefs['engine']; |
|
717 | + if ( !$this->isEngineEnabled($engine) ) |
|
718 | + $engine = ''; |
|
719 | + |
|
720 | + $columns = $this->columnSQLRep($fieldDefs, false, $tablename); |
|
721 | + if (empty($columns)) |
|
722 | + return false; |
|
723 | + |
|
724 | + $keys = $this->keysSQL($indices); |
|
725 | + if (!empty($keys)) |
|
726 | + $keys = ",$keys"; |
|
727 | + |
|
728 | + // cn: bug 9873 - module tables do not get created in utf8 with assoc collation |
|
729 | + $collation = $this->getOption('collation'); |
|
730 | + if(empty($collation)) { |
|
731 | + $collation = 'utf8_general_ci'; |
|
732 | + } |
|
733 | + $sql = "CREATE TABLE $tablename ($columns $keys) CHARACTER SET utf8 COLLATE $collation"; |
|
734 | + |
|
735 | + if (!empty($engine)) |
|
736 | + $sql.= " ENGINE=$engine"; |
|
737 | + |
|
738 | + return $sql; |
|
739 | + } |
|
740 | 740 | |
741 | 741 | /** |
742 | 742 | * Does this type represent text (i.e., non-varchar) value? |
@@ -748,745 +748,745 @@ discard block |
||
748 | 748 | return in_array($type, array('blob','text','longblob', 'longtext')); |
749 | 749 | } |
750 | 750 | |
751 | - /** |
|
752 | - * @see DBManager::oneColumnSQLRep() |
|
753 | - */ |
|
754 | - protected function oneColumnSQLRep($fieldDef, $ignoreRequired = false, $table = '', $return_as_array = false) |
|
755 | - { |
|
756 | - // always return as array for post-processing |
|
757 | - $ref = parent::oneColumnSQLRep($fieldDef, $ignoreRequired, $table, true); |
|
751 | + /** |
|
752 | + * @see DBManager::oneColumnSQLRep() |
|
753 | + */ |
|
754 | + protected function oneColumnSQLRep($fieldDef, $ignoreRequired = false, $table = '', $return_as_array = false) |
|
755 | + { |
|
756 | + // always return as array for post-processing |
|
757 | + $ref = parent::oneColumnSQLRep($fieldDef, $ignoreRequired, $table, true); |
|
758 | 758 | |
759 | - if ( $ref['colType'] == 'int' && !empty($fieldDef['len']) ) { |
|
760 | - $ref['colType'] .= "(".$fieldDef['len'].")"; |
|
761 | - } |
|
759 | + if ( $ref['colType'] == 'int' && !empty($fieldDef['len']) ) { |
|
760 | + $ref['colType'] .= "(".$fieldDef['len'].")"; |
|
761 | + } |
|
762 | 762 | |
763 | - // bug 22338 - don't set a default value on text or blob fields |
|
764 | - if ( isset($ref['default']) && |
|
763 | + // bug 22338 - don't set a default value on text or blob fields |
|
764 | + if ( isset($ref['default']) && |
|
765 | 765 | in_array($ref['colBaseType'], array('text', 'blob', 'longtext', 'longblob'))) |
766 | - $ref['default'] = ''; |
|
767 | - |
|
768 | - if ( $return_as_array ) |
|
769 | - return $ref; |
|
770 | - else |
|
771 | - return "{$ref['name']} {$ref['colType']} {$ref['default']} {$ref['required']} {$ref['auto_increment']}"; |
|
772 | - } |
|
773 | - |
|
774 | - /** |
|
775 | - * @see DBManager::changeColumnSQL() |
|
776 | - */ |
|
777 | - protected function changeColumnSQL($tablename, $fieldDefs, $action, $ignoreRequired = false) |
|
778 | - { |
|
779 | - $columns = array(); |
|
780 | - if ($this->isFieldArray($fieldDefs)){ |
|
781 | - foreach ($fieldDefs as $def){ |
|
782 | - if ($action == 'drop') |
|
783 | - $columns[] = $def['name']; |
|
784 | - else |
|
785 | - $columns[] = $this->oneColumnSQLRep($def, $ignoreRequired); |
|
786 | - } |
|
787 | - } else { |
|
788 | - if ($action == 'drop') |
|
789 | - $columns[] = $fieldDefs['name']; |
|
790 | - else |
|
791 | - $columns[] = $this->oneColumnSQLRep($fieldDefs); |
|
792 | - } |
|
793 | - |
|
794 | - return "ALTER TABLE $tablename $action COLUMN ".implode(",$action column ", $columns); |
|
795 | - } |
|
796 | - |
|
797 | - /** |
|
798 | - * Generates SQL for key specification inside CREATE TABLE statement |
|
799 | - * |
|
800 | - * The passes array is an array of field definitions or a field definition |
|
801 | - * itself. The keys generated will be either primary, foreign, unique, index |
|
802 | - * or none at all depending on the setting of the "key" parameter of a field definition |
|
803 | - * |
|
804 | - * @param array $indices |
|
805 | - * @param bool $alter_table |
|
806 | - * @param string $alter_action |
|
807 | - * @return string SQL Statement |
|
808 | - */ |
|
809 | - protected function keysSQL($indices, $alter_table = false, $alter_action = '') |
|
810 | - { |
|
811 | - // check if the passed value is an array of fields. |
|
812 | - // if not, convert it into an array |
|
813 | - if (!$this->isFieldArray($indices)) |
|
814 | - $indices[] = $indices; |
|
815 | - |
|
816 | - $columns = array(); |
|
817 | - foreach ($indices as $index) { |
|
818 | - if(!empty($index['db']) && $index['db'] != $this->dbType) |
|
819 | - continue; |
|
820 | - if (isset($index['source']) && $index['source'] != 'db') |
|
821 | - continue; |
|
822 | - |
|
823 | - $type = $index['type']; |
|
824 | - $name = $index['name']; |
|
825 | - |
|
826 | - if (is_array($index['fields'])) |
|
827 | - $fields = implode(", ", $index['fields']); |
|
828 | - else |
|
829 | - $fields = $index['fields']; |
|
830 | - |
|
831 | - switch ($type) { |
|
832 | - case 'unique': |
|
833 | - $columns[] = " UNIQUE $name ($fields)"; |
|
834 | - break; |
|
835 | - case 'primary': |
|
836 | - $columns[] = " PRIMARY KEY ($fields)"; |
|
837 | - break; |
|
838 | - case 'index': |
|
839 | - case 'foreign': |
|
840 | - case 'clustered': |
|
841 | - case 'alternate_key': |
|
842 | - /** |
|
843 | - * @todo here it is assumed that the primary key of the foreign |
|
844 | - * table will always be named 'id'. It must be noted though |
|
845 | - * that this can easily be fixed by referring to db dictionary |
|
846 | - * to find the correct primary field name |
|
847 | - */ |
|
848 | - if ( $alter_table ) |
|
849 | - $columns[] = " INDEX $name ($fields)"; |
|
850 | - else |
|
851 | - $columns[] = " KEY $name ($fields)"; |
|
852 | - break; |
|
853 | - case 'fulltext': |
|
854 | - if ($this->full_text_indexing_installed()) |
|
855 | - $columns[] = " FULLTEXT ($fields)"; |
|
856 | - else |
|
857 | - $GLOBALS['log']->debug('MYISAM engine is not available/enabled, full-text indexes will be skipped. Skipping:',$name); |
|
858 | - break; |
|
859 | - } |
|
860 | - } |
|
861 | - $columns = implode(", $alter_action ", $columns); |
|
862 | - if(!empty($alter_action)){ |
|
863 | - $columns = $alter_action . ' '. $columns; |
|
864 | - } |
|
865 | - return $columns; |
|
866 | - } |
|
867 | - |
|
868 | - /** |
|
869 | - * @see DBManager::setAutoIncrement() |
|
870 | - */ |
|
871 | - protected function setAutoIncrement($table, $field_name) |
|
872 | - { |
|
873 | - return "auto_increment"; |
|
874 | - } |
|
875 | - |
|
876 | - /** |
|
877 | - * Sets the next auto-increment value of a column to a specific value. |
|
878 | - * |
|
879 | - * @param string $table tablename |
|
880 | - * @param string $field_name |
|
881 | - */ |
|
882 | - public function setAutoIncrementStart($table, $field_name, $start_value) |
|
883 | - { |
|
884 | - $start_value = (int)$start_value; |
|
885 | - return $this->query( "ALTER TABLE $table AUTO_INCREMENT = $start_value;"); |
|
886 | - } |
|
887 | - |
|
888 | - /** |
|
889 | - * Returns the next value for an auto increment |
|
890 | - * |
|
891 | - * @param string $table tablename |
|
892 | - * @param string $field_name |
|
893 | - * @return string |
|
894 | - */ |
|
895 | - public function getAutoIncrement($table, $field_name) |
|
896 | - { |
|
897 | - $result = $this->query("SHOW TABLE STATUS LIKE '$table'"); |
|
898 | - $row = $this->fetchByAssoc($result); |
|
899 | - if (!empty($row['Auto_increment'])) |
|
900 | - return $row['Auto_increment']; |
|
901 | - |
|
902 | - return ""; |
|
903 | - } |
|
904 | - |
|
905 | - /** |
|
906 | - * @see DBManager::get_indices() |
|
907 | - */ |
|
908 | - public function get_indices($tablename) |
|
909 | - { |
|
910 | - //find all unique indexes and primary keys. |
|
911 | - $result = $this->query("SHOW INDEX FROM $tablename"); |
|
912 | - |
|
913 | - $indices = array(); |
|
914 | - while (($row=$this->fetchByAssoc($result)) !=null) { |
|
915 | - $index_type='index'; |
|
916 | - if ($row['Key_name'] =='PRIMARY') { |
|
917 | - $index_type='primary'; |
|
918 | - } |
|
919 | - elseif ( $row['Non_unique'] == '0' ) { |
|
920 | - $index_type='unique'; |
|
921 | - } |
|
922 | - $name = strtolower($row['Key_name']); |
|
923 | - $indices[$name]['name']=$name; |
|
924 | - $indices[$name]['type']=$index_type; |
|
925 | - $indices[$name]['fields'][]=strtolower($row['Column_name']); |
|
926 | - } |
|
927 | - return $indices; |
|
928 | - } |
|
929 | - |
|
930 | - /** |
|
931 | - * @see DBManager::add_drop_constraint() |
|
932 | - */ |
|
933 | - public function add_drop_constraint($table, $definition, $drop = false) |
|
934 | - { |
|
935 | - $type = $definition['type']; |
|
936 | - $fields = implode(',',$definition['fields']); |
|
937 | - $name = $definition['name']; |
|
938 | - $sql = ''; |
|
939 | - |
|
940 | - switch ($type){ |
|
941 | - // generic indices |
|
942 | - case 'index': |
|
943 | - case 'alternate_key': |
|
944 | - case 'clustered': |
|
945 | - if ($drop) |
|
946 | - $sql = "ALTER TABLE {$table} DROP INDEX {$name} "; |
|
947 | - else |
|
948 | - $sql = "ALTER TABLE {$table} ADD INDEX {$name} ({$fields})"; |
|
949 | - break; |
|
950 | - // constraints as indices |
|
951 | - case 'unique': |
|
952 | - if ($drop) |
|
953 | - $sql = "ALTER TABLE {$table} DROP INDEX $name"; |
|
954 | - else |
|
955 | - $sql = "ALTER TABLE {$table} ADD CONSTRAINT UNIQUE {$name} ({$fields})"; |
|
956 | - break; |
|
957 | - case 'primary': |
|
958 | - if ($drop) |
|
959 | - $sql = "ALTER TABLE {$table} DROP PRIMARY KEY"; |
|
960 | - else |
|
961 | - $sql = "ALTER TABLE {$table} ADD CONSTRAINT PRIMARY KEY ({$fields})"; |
|
962 | - break; |
|
963 | - case 'foreign': |
|
964 | - if ($drop) |
|
965 | - $sql = "ALTER TABLE {$table} DROP FOREIGN KEY ({$fields})"; |
|
966 | - else |
|
967 | - $sql = "ALTER TABLE {$table} ADD CONSTRAINT FOREIGN KEY {$name} ({$fields}) REFERENCES {$definition['foreignTable']}({$definition['foreignField']})"; |
|
968 | - break; |
|
969 | - } |
|
970 | - return $sql; |
|
971 | - } |
|
972 | - |
|
973 | - /** |
|
974 | - * Runs a query and returns a single row |
|
975 | - * |
|
976 | - * @param string $sql SQL Statement to execute |
|
977 | - * @param bool $dieOnError True if we want to call die if the query returns errors |
|
978 | - * @param string $msg Message to log if error occurs |
|
979 | - * @param bool $suppress Message to log if error occurs |
|
980 | - * @return array single row from the query |
|
981 | - */ |
|
982 | - public function fetchOne($sql, $dieOnError = false, $msg = '', $suppress = false) |
|
983 | - { |
|
984 | - if(stripos($sql, ' LIMIT ') === false) { |
|
985 | - // little optimization to just fetch one row |
|
986 | - $sql .= " LIMIT 0,1"; |
|
987 | - } |
|
988 | - return parent::fetchOne($sql, $dieOnError, $msg, $suppress); |
|
989 | - } |
|
990 | - |
|
991 | - /** |
|
992 | - * @see DBManager::full_text_indexing_installed() |
|
993 | - */ |
|
994 | - public function full_text_indexing_installed($dbname = null) |
|
995 | - { |
|
996 | - return $this->isEngineEnabled('MyISAM'); |
|
997 | - } |
|
998 | - |
|
999 | - /** |
|
1000 | - * @see DBManager::massageFieldDef() |
|
1001 | - */ |
|
1002 | - public function massageFieldDef(&$fieldDef, $tablename) |
|
1003 | - { |
|
1004 | - parent::massageFieldDef($fieldDef,$tablename); |
|
1005 | - |
|
1006 | - if ( isset($fieldDef['default']) && |
|
1007 | - ($fieldDef['dbType'] == 'text' |
|
1008 | - || $fieldDef['dbType'] == 'blob' |
|
1009 | - || $fieldDef['dbType'] == 'longtext' |
|
1010 | - || $fieldDef['dbType'] == 'longblob' )) |
|
1011 | - unset($fieldDef['default']); |
|
1012 | - if ($fieldDef['dbType'] == 'uint') |
|
1013 | - $fieldDef['len'] = '10'; |
|
1014 | - if ($fieldDef['dbType'] == 'ulong') |
|
1015 | - $fieldDef['len'] = '20'; |
|
1016 | - if ($fieldDef['dbType'] == 'bool') |
|
1017 | - $fieldDef['type'] = 'tinyint'; |
|
1018 | - if ($fieldDef['dbType'] == 'bool' && empty($fieldDef['default']) ) |
|
1019 | - $fieldDef['default'] = '0'; |
|
1020 | - if (($fieldDef['dbType'] == 'varchar' || $fieldDef['dbType'] == 'enum') && empty($fieldDef['len']) ) |
|
1021 | - $fieldDef['len'] = '255'; |
|
1022 | - if ($fieldDef['dbType'] == 'uint') |
|
1023 | - $fieldDef['len'] = '10'; |
|
1024 | - if ($fieldDef['dbType'] == 'int' && empty($fieldDef['len']) ) |
|
1025 | - $fieldDef['len'] = '11'; |
|
1026 | - |
|
1027 | - if($fieldDef['dbType'] == 'decimal') { |
|
1028 | - if(isset($fieldDef['len'])) { |
|
1029 | - if(strstr($fieldDef['len'], ",") === false) { |
|
1030 | - $fieldDef['len'] .= ",0"; |
|
1031 | - } |
|
1032 | - } else { |
|
1033 | - $fieldDef['len'] = '10,0'; |
|
1034 | - } |
|
1035 | - } |
|
1036 | - } |
|
1037 | - |
|
1038 | - /** |
|
1039 | - * Generates SQL for dropping a table. |
|
1040 | - * |
|
1041 | - * @param string $name table name |
|
1042 | - * @return string SQL statement |
|
1043 | - */ |
|
1044 | - public function dropTableNameSQL($name) |
|
1045 | - { |
|
1046 | - return "DROP TABLE IF EXISTS ".$name; |
|
1047 | - } |
|
1048 | - |
|
1049 | - public function dropIndexes($tablename, $indexes, $execute = true) |
|
1050 | - { |
|
1051 | - $sql = array(); |
|
1052 | - foreach ($indexes as $index) { |
|
1053 | - $name =$index['name']; |
|
1054 | - if($execute) { |
|
1055 | - unset(self::$index_descriptions[$tablename][$name]); |
|
1056 | - } |
|
1057 | - if ($index['type'] == 'primary') { |
|
1058 | - $sql[] = 'DROP PRIMARY KEY'; |
|
1059 | - } else { |
|
1060 | - $sql[] = "DROP INDEX $name"; |
|
1061 | - } |
|
1062 | - } |
|
1063 | - if (!empty($sql)) { |
|
766 | + $ref['default'] = ''; |
|
767 | + |
|
768 | + if ( $return_as_array ) |
|
769 | + return $ref; |
|
770 | + else |
|
771 | + return "{$ref['name']} {$ref['colType']} {$ref['default']} {$ref['required']} {$ref['auto_increment']}"; |
|
772 | + } |
|
773 | + |
|
774 | + /** |
|
775 | + * @see DBManager::changeColumnSQL() |
|
776 | + */ |
|
777 | + protected function changeColumnSQL($tablename, $fieldDefs, $action, $ignoreRequired = false) |
|
778 | + { |
|
779 | + $columns = array(); |
|
780 | + if ($this->isFieldArray($fieldDefs)){ |
|
781 | + foreach ($fieldDefs as $def){ |
|
782 | + if ($action == 'drop') |
|
783 | + $columns[] = $def['name']; |
|
784 | + else |
|
785 | + $columns[] = $this->oneColumnSQLRep($def, $ignoreRequired); |
|
786 | + } |
|
787 | + } else { |
|
788 | + if ($action == 'drop') |
|
789 | + $columns[] = $fieldDefs['name']; |
|
790 | + else |
|
791 | + $columns[] = $this->oneColumnSQLRep($fieldDefs); |
|
792 | + } |
|
793 | + |
|
794 | + return "ALTER TABLE $tablename $action COLUMN ".implode(",$action column ", $columns); |
|
795 | + } |
|
796 | + |
|
797 | + /** |
|
798 | + * Generates SQL for key specification inside CREATE TABLE statement |
|
799 | + * |
|
800 | + * The passes array is an array of field definitions or a field definition |
|
801 | + * itself. The keys generated will be either primary, foreign, unique, index |
|
802 | + * or none at all depending on the setting of the "key" parameter of a field definition |
|
803 | + * |
|
804 | + * @param array $indices |
|
805 | + * @param bool $alter_table |
|
806 | + * @param string $alter_action |
|
807 | + * @return string SQL Statement |
|
808 | + */ |
|
809 | + protected function keysSQL($indices, $alter_table = false, $alter_action = '') |
|
810 | + { |
|
811 | + // check if the passed value is an array of fields. |
|
812 | + // if not, convert it into an array |
|
813 | + if (!$this->isFieldArray($indices)) |
|
814 | + $indices[] = $indices; |
|
815 | + |
|
816 | + $columns = array(); |
|
817 | + foreach ($indices as $index) { |
|
818 | + if(!empty($index['db']) && $index['db'] != $this->dbType) |
|
819 | + continue; |
|
820 | + if (isset($index['source']) && $index['source'] != 'db') |
|
821 | + continue; |
|
822 | + |
|
823 | + $type = $index['type']; |
|
824 | + $name = $index['name']; |
|
825 | + |
|
826 | + if (is_array($index['fields'])) |
|
827 | + $fields = implode(", ", $index['fields']); |
|
828 | + else |
|
829 | + $fields = $index['fields']; |
|
830 | + |
|
831 | + switch ($type) { |
|
832 | + case 'unique': |
|
833 | + $columns[] = " UNIQUE $name ($fields)"; |
|
834 | + break; |
|
835 | + case 'primary': |
|
836 | + $columns[] = " PRIMARY KEY ($fields)"; |
|
837 | + break; |
|
838 | + case 'index': |
|
839 | + case 'foreign': |
|
840 | + case 'clustered': |
|
841 | + case 'alternate_key': |
|
842 | + /** |
|
843 | + * @todo here it is assumed that the primary key of the foreign |
|
844 | + * table will always be named 'id'. It must be noted though |
|
845 | + * that this can easily be fixed by referring to db dictionary |
|
846 | + * to find the correct primary field name |
|
847 | + */ |
|
848 | + if ( $alter_table ) |
|
849 | + $columns[] = " INDEX $name ($fields)"; |
|
850 | + else |
|
851 | + $columns[] = " KEY $name ($fields)"; |
|
852 | + break; |
|
853 | + case 'fulltext': |
|
854 | + if ($this->full_text_indexing_installed()) |
|
855 | + $columns[] = " FULLTEXT ($fields)"; |
|
856 | + else |
|
857 | + $GLOBALS['log']->debug('MYISAM engine is not available/enabled, full-text indexes will be skipped. Skipping:',$name); |
|
858 | + break; |
|
859 | + } |
|
860 | + } |
|
861 | + $columns = implode(", $alter_action ", $columns); |
|
862 | + if(!empty($alter_action)){ |
|
863 | + $columns = $alter_action . ' '. $columns; |
|
864 | + } |
|
865 | + return $columns; |
|
866 | + } |
|
867 | + |
|
868 | + /** |
|
869 | + * @see DBManager::setAutoIncrement() |
|
870 | + */ |
|
871 | + protected function setAutoIncrement($table, $field_name) |
|
872 | + { |
|
873 | + return "auto_increment"; |
|
874 | + } |
|
875 | + |
|
876 | + /** |
|
877 | + * Sets the next auto-increment value of a column to a specific value. |
|
878 | + * |
|
879 | + * @param string $table tablename |
|
880 | + * @param string $field_name |
|
881 | + */ |
|
882 | + public function setAutoIncrementStart($table, $field_name, $start_value) |
|
883 | + { |
|
884 | + $start_value = (int)$start_value; |
|
885 | + return $this->query( "ALTER TABLE $table AUTO_INCREMENT = $start_value;"); |
|
886 | + } |
|
887 | + |
|
888 | + /** |
|
889 | + * Returns the next value for an auto increment |
|
890 | + * |
|
891 | + * @param string $table tablename |
|
892 | + * @param string $field_name |
|
893 | + * @return string |
|
894 | + */ |
|
895 | + public function getAutoIncrement($table, $field_name) |
|
896 | + { |
|
897 | + $result = $this->query("SHOW TABLE STATUS LIKE '$table'"); |
|
898 | + $row = $this->fetchByAssoc($result); |
|
899 | + if (!empty($row['Auto_increment'])) |
|
900 | + return $row['Auto_increment']; |
|
901 | + |
|
902 | + return ""; |
|
903 | + } |
|
904 | + |
|
905 | + /** |
|
906 | + * @see DBManager::get_indices() |
|
907 | + */ |
|
908 | + public function get_indices($tablename) |
|
909 | + { |
|
910 | + //find all unique indexes and primary keys. |
|
911 | + $result = $this->query("SHOW INDEX FROM $tablename"); |
|
912 | + |
|
913 | + $indices = array(); |
|
914 | + while (($row=$this->fetchByAssoc($result)) !=null) { |
|
915 | + $index_type='index'; |
|
916 | + if ($row['Key_name'] =='PRIMARY') { |
|
917 | + $index_type='primary'; |
|
918 | + } |
|
919 | + elseif ( $row['Non_unique'] == '0' ) { |
|
920 | + $index_type='unique'; |
|
921 | + } |
|
922 | + $name = strtolower($row['Key_name']); |
|
923 | + $indices[$name]['name']=$name; |
|
924 | + $indices[$name]['type']=$index_type; |
|
925 | + $indices[$name]['fields'][]=strtolower($row['Column_name']); |
|
926 | + } |
|
927 | + return $indices; |
|
928 | + } |
|
929 | + |
|
930 | + /** |
|
931 | + * @see DBManager::add_drop_constraint() |
|
932 | + */ |
|
933 | + public function add_drop_constraint($table, $definition, $drop = false) |
|
934 | + { |
|
935 | + $type = $definition['type']; |
|
936 | + $fields = implode(',',$definition['fields']); |
|
937 | + $name = $definition['name']; |
|
938 | + $sql = ''; |
|
939 | + |
|
940 | + switch ($type){ |
|
941 | + // generic indices |
|
942 | + case 'index': |
|
943 | + case 'alternate_key': |
|
944 | + case 'clustered': |
|
945 | + if ($drop) |
|
946 | + $sql = "ALTER TABLE {$table} DROP INDEX {$name} "; |
|
947 | + else |
|
948 | + $sql = "ALTER TABLE {$table} ADD INDEX {$name} ({$fields})"; |
|
949 | + break; |
|
950 | + // constraints as indices |
|
951 | + case 'unique': |
|
952 | + if ($drop) |
|
953 | + $sql = "ALTER TABLE {$table} DROP INDEX $name"; |
|
954 | + else |
|
955 | + $sql = "ALTER TABLE {$table} ADD CONSTRAINT UNIQUE {$name} ({$fields})"; |
|
956 | + break; |
|
957 | + case 'primary': |
|
958 | + if ($drop) |
|
959 | + $sql = "ALTER TABLE {$table} DROP PRIMARY KEY"; |
|
960 | + else |
|
961 | + $sql = "ALTER TABLE {$table} ADD CONSTRAINT PRIMARY KEY ({$fields})"; |
|
962 | + break; |
|
963 | + case 'foreign': |
|
964 | + if ($drop) |
|
965 | + $sql = "ALTER TABLE {$table} DROP FOREIGN KEY ({$fields})"; |
|
966 | + else |
|
967 | + $sql = "ALTER TABLE {$table} ADD CONSTRAINT FOREIGN KEY {$name} ({$fields}) REFERENCES {$definition['foreignTable']}({$definition['foreignField']})"; |
|
968 | + break; |
|
969 | + } |
|
970 | + return $sql; |
|
971 | + } |
|
972 | + |
|
973 | + /** |
|
974 | + * Runs a query and returns a single row |
|
975 | + * |
|
976 | + * @param string $sql SQL Statement to execute |
|
977 | + * @param bool $dieOnError True if we want to call die if the query returns errors |
|
978 | + * @param string $msg Message to log if error occurs |
|
979 | + * @param bool $suppress Message to log if error occurs |
|
980 | + * @return array single row from the query |
|
981 | + */ |
|
982 | + public function fetchOne($sql, $dieOnError = false, $msg = '', $suppress = false) |
|
983 | + { |
|
984 | + if(stripos($sql, ' LIMIT ') === false) { |
|
985 | + // little optimization to just fetch one row |
|
986 | + $sql .= " LIMIT 0,1"; |
|
987 | + } |
|
988 | + return parent::fetchOne($sql, $dieOnError, $msg, $suppress); |
|
989 | + } |
|
990 | + |
|
991 | + /** |
|
992 | + * @see DBManager::full_text_indexing_installed() |
|
993 | + */ |
|
994 | + public function full_text_indexing_installed($dbname = null) |
|
995 | + { |
|
996 | + return $this->isEngineEnabled('MyISAM'); |
|
997 | + } |
|
998 | + |
|
999 | + /** |
|
1000 | + * @see DBManager::massageFieldDef() |
|
1001 | + */ |
|
1002 | + public function massageFieldDef(&$fieldDef, $tablename) |
|
1003 | + { |
|
1004 | + parent::massageFieldDef($fieldDef,$tablename); |
|
1005 | + |
|
1006 | + if ( isset($fieldDef['default']) && |
|
1007 | + ($fieldDef['dbType'] == 'text' |
|
1008 | + || $fieldDef['dbType'] == 'blob' |
|
1009 | + || $fieldDef['dbType'] == 'longtext' |
|
1010 | + || $fieldDef['dbType'] == 'longblob' )) |
|
1011 | + unset($fieldDef['default']); |
|
1012 | + if ($fieldDef['dbType'] == 'uint') |
|
1013 | + $fieldDef['len'] = '10'; |
|
1014 | + if ($fieldDef['dbType'] == 'ulong') |
|
1015 | + $fieldDef['len'] = '20'; |
|
1016 | + if ($fieldDef['dbType'] == 'bool') |
|
1017 | + $fieldDef['type'] = 'tinyint'; |
|
1018 | + if ($fieldDef['dbType'] == 'bool' && empty($fieldDef['default']) ) |
|
1019 | + $fieldDef['default'] = '0'; |
|
1020 | + if (($fieldDef['dbType'] == 'varchar' || $fieldDef['dbType'] == 'enum') && empty($fieldDef['len']) ) |
|
1021 | + $fieldDef['len'] = '255'; |
|
1022 | + if ($fieldDef['dbType'] == 'uint') |
|
1023 | + $fieldDef['len'] = '10'; |
|
1024 | + if ($fieldDef['dbType'] == 'int' && empty($fieldDef['len']) ) |
|
1025 | + $fieldDef['len'] = '11'; |
|
1026 | + |
|
1027 | + if($fieldDef['dbType'] == 'decimal') { |
|
1028 | + if(isset($fieldDef['len'])) { |
|
1029 | + if(strstr($fieldDef['len'], ",") === false) { |
|
1030 | + $fieldDef['len'] .= ",0"; |
|
1031 | + } |
|
1032 | + } else { |
|
1033 | + $fieldDef['len'] = '10,0'; |
|
1034 | + } |
|
1035 | + } |
|
1036 | + } |
|
1037 | + |
|
1038 | + /** |
|
1039 | + * Generates SQL for dropping a table. |
|
1040 | + * |
|
1041 | + * @param string $name table name |
|
1042 | + * @return string SQL statement |
|
1043 | + */ |
|
1044 | + public function dropTableNameSQL($name) |
|
1045 | + { |
|
1046 | + return "DROP TABLE IF EXISTS ".$name; |
|
1047 | + } |
|
1048 | + |
|
1049 | + public function dropIndexes($tablename, $indexes, $execute = true) |
|
1050 | + { |
|
1051 | + $sql = array(); |
|
1052 | + foreach ($indexes as $index) { |
|
1053 | + $name =$index['name']; |
|
1054 | + if($execute) { |
|
1055 | + unset(self::$index_descriptions[$tablename][$name]); |
|
1056 | + } |
|
1057 | + if ($index['type'] == 'primary') { |
|
1058 | + $sql[] = 'DROP PRIMARY KEY'; |
|
1059 | + } else { |
|
1060 | + $sql[] = "DROP INDEX $name"; |
|
1061 | + } |
|
1062 | + } |
|
1063 | + if (!empty($sql)) { |
|
1064 | 1064 | $sql = "ALTER TABLE $tablename " . join(",", $sql) . ";"; |
1065 | - if($execute) |
|
1066 | - $this->query($sql); |
|
1067 | - } else { |
|
1068 | - $sql = ''; |
|
1069 | - } |
|
1070 | - return $sql; |
|
1071 | - } |
|
1072 | - |
|
1073 | - /** |
|
1074 | - * List of available collation settings |
|
1075 | - * @return string |
|
1076 | - */ |
|
1077 | - public function getDefaultCollation() |
|
1078 | - { |
|
1079 | - return "utf8_general_ci"; |
|
1080 | - } |
|
1081 | - |
|
1082 | - /** |
|
1083 | - * List of available collation settings |
|
1084 | - * @return array |
|
1085 | - */ |
|
1086 | - public function getCollationList() |
|
1087 | - { |
|
1088 | - $q = "SHOW COLLATION LIKE 'utf8%'"; |
|
1089 | - $r = $this->query($q); |
|
1090 | - $res = array(); |
|
1091 | - while($a = $this->fetchByAssoc($r)) { |
|
1092 | - $res[] = $a['Collation']; |
|
1093 | - } |
|
1094 | - return $res; |
|
1095 | - } |
|
1096 | - |
|
1097 | - /** |
|
1098 | - * (non-PHPdoc) |
|
1099 | - * @see DBManager::renameColumnSQL() |
|
1100 | - */ |
|
1101 | - public function renameColumnSQL($tablename, $column, $newname) |
|
1102 | - { |
|
1103 | - $field = $this->describeField($column, $tablename); |
|
1104 | - $field['name'] = $newname; |
|
1105 | - return "ALTER TABLE $tablename CHANGE COLUMN $column ".$this->oneColumnSQLRep($field); |
|
1106 | - } |
|
1107 | - |
|
1108 | - public function emptyValue($type) |
|
1109 | - { |
|
1110 | - $ctype = $this->getColumnType($type); |
|
1111 | - if($ctype == "datetime") { |
|
1112 | - return 'NULL'; |
|
1113 | - } |
|
1114 | - if($ctype == "date") { |
|
1115 | - return 'NULL'; |
|
1116 | - } |
|
1117 | - if($ctype == "time") { |
|
1118 | - return 'NULL'; |
|
1119 | - } |
|
1120 | - return parent::emptyValue($type); |
|
1121 | - } |
|
1122 | - |
|
1123 | - /** |
|
1124 | - * (non-PHPdoc) |
|
1125 | - * @see DBManager::lastDbError() |
|
1126 | - */ |
|
1127 | - public function lastDbError() |
|
1128 | - { |
|
1129 | - if($this->database) { |
|
1130 | - if(mysql_errno($this->database)) { |
|
1131 | - return "MySQL error ".mysql_errno($this->database).": ".mysql_error($this->database); |
|
1132 | - } |
|
1133 | - } else { |
|
1134 | - $err = mysql_error(); |
|
1135 | - if($err) { |
|
1136 | - return $err; |
|
1137 | - } |
|
1138 | - } |
|
1065 | + if($execute) |
|
1066 | + $this->query($sql); |
|
1067 | + } else { |
|
1068 | + $sql = ''; |
|
1069 | + } |
|
1070 | + return $sql; |
|
1071 | + } |
|
1072 | + |
|
1073 | + /** |
|
1074 | + * List of available collation settings |
|
1075 | + * @return string |
|
1076 | + */ |
|
1077 | + public function getDefaultCollation() |
|
1078 | + { |
|
1079 | + return "utf8_general_ci"; |
|
1080 | + } |
|
1081 | + |
|
1082 | + /** |
|
1083 | + * List of available collation settings |
|
1084 | + * @return array |
|
1085 | + */ |
|
1086 | + public function getCollationList() |
|
1087 | + { |
|
1088 | + $q = "SHOW COLLATION LIKE 'utf8%'"; |
|
1089 | + $r = $this->query($q); |
|
1090 | + $res = array(); |
|
1091 | + while($a = $this->fetchByAssoc($r)) { |
|
1092 | + $res[] = $a['Collation']; |
|
1093 | + } |
|
1094 | + return $res; |
|
1095 | + } |
|
1096 | + |
|
1097 | + /** |
|
1098 | + * (non-PHPdoc) |
|
1099 | + * @see DBManager::renameColumnSQL() |
|
1100 | + */ |
|
1101 | + public function renameColumnSQL($tablename, $column, $newname) |
|
1102 | + { |
|
1103 | + $field = $this->describeField($column, $tablename); |
|
1104 | + $field['name'] = $newname; |
|
1105 | + return "ALTER TABLE $tablename CHANGE COLUMN $column ".$this->oneColumnSQLRep($field); |
|
1106 | + } |
|
1107 | + |
|
1108 | + public function emptyValue($type) |
|
1109 | + { |
|
1110 | + $ctype = $this->getColumnType($type); |
|
1111 | + if($ctype == "datetime") { |
|
1112 | + return 'NULL'; |
|
1113 | + } |
|
1114 | + if($ctype == "date") { |
|
1115 | + return 'NULL'; |
|
1116 | + } |
|
1117 | + if($ctype == "time") { |
|
1118 | + return 'NULL'; |
|
1119 | + } |
|
1120 | + return parent::emptyValue($type); |
|
1121 | + } |
|
1122 | + |
|
1123 | + /** |
|
1124 | + * (non-PHPdoc) |
|
1125 | + * @see DBManager::lastDbError() |
|
1126 | + */ |
|
1127 | + public function lastDbError() |
|
1128 | + { |
|
1129 | + if($this->database) { |
|
1130 | + if(mysql_errno($this->database)) { |
|
1131 | + return "MySQL error ".mysql_errno($this->database).": ".mysql_error($this->database); |
|
1132 | + } |
|
1133 | + } else { |
|
1134 | + $err = mysql_error(); |
|
1135 | + if($err) { |
|
1136 | + return $err; |
|
1137 | + } |
|
1138 | + } |
|
1139 | 1139 | return false; |
1140 | 1140 | } |
1141 | 1141 | |
1142 | - /** |
|
1143 | - * Quote MySQL search term |
|
1144 | - * @param unknown_type $term |
|
1145 | - */ |
|
1146 | - protected function quoteTerm($term) |
|
1147 | - { |
|
1148 | - if(strpos($term, ' ') !== false) { |
|
1149 | - return '"'.$term.'"'; |
|
1150 | - } |
|
1151 | - return $term; |
|
1152 | - } |
|
1153 | - |
|
1154 | - /** |
|
1155 | - * Generate fulltext query from set of terms |
|
1156 | - * @param string $fields Field to search against |
|
1157 | - * @param array $terms Search terms that may be or not be in the result |
|
1158 | - * @param array $must_terms Search terms that have to be in the result |
|
1159 | - * @param array $exclude_terms Search terms that have to be not in the result |
|
1160 | - */ |
|
1161 | - public function getFulltextQuery($field, $terms, $must_terms = array(), $exclude_terms = array()) |
|
1162 | - { |
|
1163 | - $condition = array(); |
|
1164 | - foreach($terms as $term) { |
|
1165 | - $condition[] = $this->quoteTerm($term); |
|
1166 | - } |
|
1167 | - foreach($must_terms as $term) { |
|
1168 | - $condition[] = "+".$this->quoteTerm($term); |
|
1169 | - } |
|
1170 | - foreach($exclude_terms as $term) { |
|
1171 | - $condition[] = "-".$this->quoteTerm($term); |
|
1172 | - } |
|
1173 | - $condition = $this->quoted(join(" ",$condition)); |
|
1174 | - return "MATCH($field) AGAINST($condition IN BOOLEAN MODE)"; |
|
1175 | - } |
|
1176 | - |
|
1177 | - /** |
|
1178 | - * Get list of all defined charsets |
|
1179 | - * @return array |
|
1180 | - */ |
|
1181 | - protected function getCharsetInfo() |
|
1182 | - { |
|
1183 | - $charsets = array(); |
|
1184 | - $res = $this->query("show variables like 'character\\_set\\_%'"); |
|
1185 | - while($row = $this->fetchByAssoc($res)) { |
|
1186 | - $charsets[$row['Variable_name']] = $row['Value']; |
|
1187 | - } |
|
1188 | - return $charsets; |
|
1189 | - } |
|
1190 | - |
|
1191 | - public function getDbInfo() |
|
1192 | - { |
|
1193 | - $charsets = $this->getCharsetInfo(); |
|
1194 | - $charset_str = array(); |
|
1195 | - foreach($charsets as $name => $value) { |
|
1196 | - $charset_str[] = "$name = $value"; |
|
1197 | - } |
|
1198 | - return array( |
|
1199 | - "MySQL Version" => @mysql_get_client_info(), |
|
1200 | - "MySQL Host Info" => @mysql_get_host_info($this->database), |
|
1201 | - "MySQL Server Info" => @mysql_get_server_info($this->database), |
|
1202 | - "MySQL Client Encoding" => @mysql_client_encoding($this->database), |
|
1203 | - "MySQL Character Set Settings" => join(", ", $charset_str), |
|
1204 | - ); |
|
1205 | - } |
|
1206 | - |
|
1207 | - public function validateQuery($query) |
|
1208 | - { |
|
1209 | - $res = $this->query("EXPLAIN $query"); |
|
1210 | - return !empty($res); |
|
1211 | - } |
|
1212 | - |
|
1213 | - protected function makeTempTableCopy($table) |
|
1214 | - { |
|
1215 | - $this->log->debug("creating temp table for [$table]..."); |
|
1216 | - $result = $this->query("SHOW CREATE TABLE {$table}"); |
|
1217 | - if(empty($result)) { |
|
1218 | - return false; |
|
1219 | - } |
|
1220 | - $row = $this->fetchByAssoc($result); |
|
1221 | - if(empty($row) || empty($row['Create Table'])) { |
|
1222 | - return false; |
|
1223 | - } |
|
1224 | - $create = $row['Create Table']; |
|
1225 | - // rewrite DDL with _temp name |
|
1226 | - $tempTableQuery = str_replace("CREATE TABLE `{$table}`", "CREATE TABLE `{$table}__uw_temp`", $create); |
|
1227 | - $r2 = $this->query($tempTableQuery); |
|
1228 | - if(empty($r2)) { |
|
1229 | - return false; |
|
1230 | - } |
|
1231 | - |
|
1232 | - // get sample data into the temp table to test for data/constraint conflicts |
|
1233 | - $this->log->debug('inserting temp dataset...'); |
|
1234 | - $q3 = "INSERT INTO `{$table}__uw_temp` SELECT * FROM `{$table}` LIMIT 10"; |
|
1235 | - $this->query($q3, false, "Preflight Failed for: {$q3}"); |
|
1236 | - return true; |
|
1237 | - } |
|
1238 | - |
|
1239 | - /** |
|
1240 | - * Tests an ALTER TABLE query |
|
1241 | - * @param string table The table name to get DDL |
|
1242 | - * @param string query The query to test. |
|
1243 | - * @return string Non-empty if error found |
|
1244 | - */ |
|
1245 | - protected function verifyAlterTable($table, $query) |
|
1246 | - { |
|
1247 | - $this->log->debug("verifying ALTER TABLE"); |
|
1248 | - // Skipping ALTER TABLE [table] DROP PRIMARY KEY because primary keys are not being copied |
|
1249 | - // over to the temp tables |
|
1250 | - if(strpos(strtoupper($query), 'DROP PRIMARY KEY') !== false) { |
|
1251 | - $this->log->debug("Skipping DROP PRIMARY KEY"); |
|
1252 | - return ''; |
|
1253 | - } |
|
1254 | - if(!$this->makeTempTableCopy($table)) { |
|
1255 | - return 'Could not create temp table copy'; |
|
1256 | - } |
|
1257 | - |
|
1258 | - // test the query on the test table |
|
1259 | - $this->log->debug('testing query: ['.$query.']'); |
|
1260 | - $tempTableTestQuery = str_replace("ALTER TABLE `{$table}`", "ALTER TABLE `{$table}__uw_temp`", $query); |
|
1261 | - if (strpos($tempTableTestQuery, 'idx') === false) { |
|
1262 | - if(strpos($tempTableTestQuery, '__uw_temp') === false) { |
|
1263 | - return 'Could not use a temp table to test query!'; |
|
1264 | - } |
|
1265 | - |
|
1266 | - $this->log->debug('testing query on temp table: ['.$tempTableTestQuery.']'); |
|
1267 | - $this->query($tempTableTestQuery, false, "Preflight Failed for: {$query}"); |
|
1268 | - } else { |
|
1269 | - // test insertion of an index on a table |
|
1270 | - $tempTableTestQuery_idx = str_replace("ADD INDEX `idx_", "ADD INDEX `temp_idx_", $tempTableTestQuery); |
|
1271 | - $this->log->debug('testing query on temp table: ['.$tempTableTestQuery_idx.']'); |
|
1272 | - $this->query($tempTableTestQuery_idx, false, "Preflight Failed for: {$query}"); |
|
1273 | - } |
|
1274 | - $mysqlError = $this->getL(); |
|
1275 | - if(!empty($mysqlError)) { |
|
1276 | - return $mysqlError; |
|
1277 | - } |
|
1278 | - $this->dropTableName("{$table}__uw_temp"); |
|
1279 | - |
|
1280 | - return ''; |
|
1281 | - } |
|
1282 | - |
|
1283 | - protected function verifyGenericReplaceQuery($querytype, $table, $query) |
|
1284 | - { |
|
1285 | - $this->log->debug("verifying $querytype statement"); |
|
1286 | - |
|
1287 | - if(!$this->makeTempTableCopy($table)) { |
|
1288 | - return 'Could not create temp table copy'; |
|
1289 | - } |
|
1290 | - // test the query on the test table |
|
1291 | - $this->log->debug('testing query: ['.$query.']'); |
|
1292 | - $tempTableTestQuery = str_replace("$querytype `{$table}`", "$querytype `{$table}__uw_temp`", $query); |
|
1293 | - if(strpos($tempTableTestQuery, '__uw_temp') === false) { |
|
1294 | - return 'Could not use a temp table to test query!'; |
|
1295 | - } |
|
1296 | - |
|
1297 | - $this->query($tempTableTestQuery, false, "Preflight Failed for: {$query}"); |
|
1298 | - $error = $this->lastError(); // empty on no-errors |
|
1299 | - $this->dropTableName("{$table}__uw_temp"); // just in case |
|
1300 | - return $error; |
|
1301 | - } |
|
1302 | - |
|
1303 | - /** |
|
1304 | - * Tests a DROP TABLE query |
|
1305 | - * @param string table The table name to get DDL |
|
1306 | - * @param string query The query to test. |
|
1307 | - * @return string Non-empty if error found |
|
1308 | - */ |
|
1309 | - public function verifyDropTable($table, $query) |
|
1310 | - { |
|
1311 | - return $this->verifyGenericReplaceQuery("DROP TABLE", $table, $query); |
|
1312 | - } |
|
1313 | - |
|
1314 | - /** |
|
1315 | - * Tests an INSERT INTO query |
|
1316 | - * @param string table The table name to get DDL |
|
1317 | - * @param string query The query to test. |
|
1318 | - * @return string Non-empty if error found |
|
1319 | - */ |
|
1320 | - public function verifyInsertInto($table, $query) |
|
1321 | - { |
|
1322 | - return $this->verifyGenericReplaceQuery("INSERT INTO", $table, $query); |
|
1323 | - } |
|
1324 | - |
|
1325 | - /** |
|
1326 | - * Tests an UPDATE query |
|
1327 | - * @param string table The table name to get DDL |
|
1328 | - * @param string query The query to test. |
|
1329 | - * @return string Non-empty if error found |
|
1330 | - */ |
|
1331 | - public function verifyUpdate($table, $query) |
|
1332 | - { |
|
1333 | - return $this->verifyGenericReplaceQuery("UPDATE", $table, $query); |
|
1334 | - } |
|
1335 | - |
|
1336 | - /** |
|
1337 | - * Tests an DELETE FROM query |
|
1338 | - * @param string table The table name to get DDL |
|
1339 | - * @param string query The query to test. |
|
1340 | - * @return string Non-empty if error found |
|
1341 | - */ |
|
1342 | - public function verifyDeleteFrom($table, $query) |
|
1343 | - { |
|
1344 | - return $this->verifyGenericReplaceQuery("DELETE FROM", $table, $query); |
|
1345 | - } |
|
1346 | - |
|
1347 | - /** |
|
1348 | - * Check if certain database exists |
|
1349 | - * @param string $dbname |
|
1350 | - */ |
|
1351 | - public function dbExists($dbname) |
|
1352 | - { |
|
1353 | - $db = $this->getOne("SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = ".$this->quoted($dbname)); |
|
1354 | - return !empty($db); |
|
1355 | - } |
|
1356 | - |
|
1357 | - /** |
|
1358 | - * Select database |
|
1359 | - * @param string $dbname |
|
1360 | - */ |
|
1361 | - protected function selectDb($dbname) |
|
1362 | - { |
|
1363 | - return mysql_select_db($dbname); |
|
1364 | - } |
|
1365 | - |
|
1366 | - /** |
|
1367 | - * Check if certain DB user exists |
|
1368 | - * @param string $username |
|
1369 | - */ |
|
1370 | - public function userExists($username) |
|
1371 | - { |
|
1372 | - $db = $this->getOne("SELECT DATABASE()"); |
|
1373 | - if(!$this->selectDb("mysql")) { |
|
1374 | - return false; |
|
1375 | - } |
|
1376 | - $user = $this->getOne("select count(*) from user where user = ".$this->quoted($username)); |
|
1377 | - if(!$this->selectDb($db)) { |
|
1378 | - $this->checkError("Cannot select database $db", true); |
|
1379 | - } |
|
1380 | - return !empty($user); |
|
1381 | - } |
|
1382 | - |
|
1383 | - /** |
|
1384 | - * Create DB user |
|
1385 | - * @param string $database_name |
|
1386 | - * @param string $host_name |
|
1387 | - * @param string $user |
|
1388 | - * @param string $password |
|
1389 | - */ |
|
1390 | - public function createDbUser($database_name, $host_name, $user, $password) |
|
1391 | - { |
|
1392 | - $qpassword = $this->quote($password); |
|
1393 | - $this->query("GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, INDEX |
|
1142 | + /** |
|
1143 | + * Quote MySQL search term |
|
1144 | + * @param unknown_type $term |
|
1145 | + */ |
|
1146 | + protected function quoteTerm($term) |
|
1147 | + { |
|
1148 | + if(strpos($term, ' ') !== false) { |
|
1149 | + return '"'.$term.'"'; |
|
1150 | + } |
|
1151 | + return $term; |
|
1152 | + } |
|
1153 | + |
|
1154 | + /** |
|
1155 | + * Generate fulltext query from set of terms |
|
1156 | + * @param string $fields Field to search against |
|
1157 | + * @param array $terms Search terms that may be or not be in the result |
|
1158 | + * @param array $must_terms Search terms that have to be in the result |
|
1159 | + * @param array $exclude_terms Search terms that have to be not in the result |
|
1160 | + */ |
|
1161 | + public function getFulltextQuery($field, $terms, $must_terms = array(), $exclude_terms = array()) |
|
1162 | + { |
|
1163 | + $condition = array(); |
|
1164 | + foreach($terms as $term) { |
|
1165 | + $condition[] = $this->quoteTerm($term); |
|
1166 | + } |
|
1167 | + foreach($must_terms as $term) { |
|
1168 | + $condition[] = "+".$this->quoteTerm($term); |
|
1169 | + } |
|
1170 | + foreach($exclude_terms as $term) { |
|
1171 | + $condition[] = "-".$this->quoteTerm($term); |
|
1172 | + } |
|
1173 | + $condition = $this->quoted(join(" ",$condition)); |
|
1174 | + return "MATCH($field) AGAINST($condition IN BOOLEAN MODE)"; |
|
1175 | + } |
|
1176 | + |
|
1177 | + /** |
|
1178 | + * Get list of all defined charsets |
|
1179 | + * @return array |
|
1180 | + */ |
|
1181 | + protected function getCharsetInfo() |
|
1182 | + { |
|
1183 | + $charsets = array(); |
|
1184 | + $res = $this->query("show variables like 'character\\_set\\_%'"); |
|
1185 | + while($row = $this->fetchByAssoc($res)) { |
|
1186 | + $charsets[$row['Variable_name']] = $row['Value']; |
|
1187 | + } |
|
1188 | + return $charsets; |
|
1189 | + } |
|
1190 | + |
|
1191 | + public function getDbInfo() |
|
1192 | + { |
|
1193 | + $charsets = $this->getCharsetInfo(); |
|
1194 | + $charset_str = array(); |
|
1195 | + foreach($charsets as $name => $value) { |
|
1196 | + $charset_str[] = "$name = $value"; |
|
1197 | + } |
|
1198 | + return array( |
|
1199 | + "MySQL Version" => @mysql_get_client_info(), |
|
1200 | + "MySQL Host Info" => @mysql_get_host_info($this->database), |
|
1201 | + "MySQL Server Info" => @mysql_get_server_info($this->database), |
|
1202 | + "MySQL Client Encoding" => @mysql_client_encoding($this->database), |
|
1203 | + "MySQL Character Set Settings" => join(", ", $charset_str), |
|
1204 | + ); |
|
1205 | + } |
|
1206 | + |
|
1207 | + public function validateQuery($query) |
|
1208 | + { |
|
1209 | + $res = $this->query("EXPLAIN $query"); |
|
1210 | + return !empty($res); |
|
1211 | + } |
|
1212 | + |
|
1213 | + protected function makeTempTableCopy($table) |
|
1214 | + { |
|
1215 | + $this->log->debug("creating temp table for [$table]..."); |
|
1216 | + $result = $this->query("SHOW CREATE TABLE {$table}"); |
|
1217 | + if(empty($result)) { |
|
1218 | + return false; |
|
1219 | + } |
|
1220 | + $row = $this->fetchByAssoc($result); |
|
1221 | + if(empty($row) || empty($row['Create Table'])) { |
|
1222 | + return false; |
|
1223 | + } |
|
1224 | + $create = $row['Create Table']; |
|
1225 | + // rewrite DDL with _temp name |
|
1226 | + $tempTableQuery = str_replace("CREATE TABLE `{$table}`", "CREATE TABLE `{$table}__uw_temp`", $create); |
|
1227 | + $r2 = $this->query($tempTableQuery); |
|
1228 | + if(empty($r2)) { |
|
1229 | + return false; |
|
1230 | + } |
|
1231 | + |
|
1232 | + // get sample data into the temp table to test for data/constraint conflicts |
|
1233 | + $this->log->debug('inserting temp dataset...'); |
|
1234 | + $q3 = "INSERT INTO `{$table}__uw_temp` SELECT * FROM `{$table}` LIMIT 10"; |
|
1235 | + $this->query($q3, false, "Preflight Failed for: {$q3}"); |
|
1236 | + return true; |
|
1237 | + } |
|
1238 | + |
|
1239 | + /** |
|
1240 | + * Tests an ALTER TABLE query |
|
1241 | + * @param string table The table name to get DDL |
|
1242 | + * @param string query The query to test. |
|
1243 | + * @return string Non-empty if error found |
|
1244 | + */ |
|
1245 | + protected function verifyAlterTable($table, $query) |
|
1246 | + { |
|
1247 | + $this->log->debug("verifying ALTER TABLE"); |
|
1248 | + // Skipping ALTER TABLE [table] DROP PRIMARY KEY because primary keys are not being copied |
|
1249 | + // over to the temp tables |
|
1250 | + if(strpos(strtoupper($query), 'DROP PRIMARY KEY') !== false) { |
|
1251 | + $this->log->debug("Skipping DROP PRIMARY KEY"); |
|
1252 | + return ''; |
|
1253 | + } |
|
1254 | + if(!$this->makeTempTableCopy($table)) { |
|
1255 | + return 'Could not create temp table copy'; |
|
1256 | + } |
|
1257 | + |
|
1258 | + // test the query on the test table |
|
1259 | + $this->log->debug('testing query: ['.$query.']'); |
|
1260 | + $tempTableTestQuery = str_replace("ALTER TABLE `{$table}`", "ALTER TABLE `{$table}__uw_temp`", $query); |
|
1261 | + if (strpos($tempTableTestQuery, 'idx') === false) { |
|
1262 | + if(strpos($tempTableTestQuery, '__uw_temp') === false) { |
|
1263 | + return 'Could not use a temp table to test query!'; |
|
1264 | + } |
|
1265 | + |
|
1266 | + $this->log->debug('testing query on temp table: ['.$tempTableTestQuery.']'); |
|
1267 | + $this->query($tempTableTestQuery, false, "Preflight Failed for: {$query}"); |
|
1268 | + } else { |
|
1269 | + // test insertion of an index on a table |
|
1270 | + $tempTableTestQuery_idx = str_replace("ADD INDEX `idx_", "ADD INDEX `temp_idx_", $tempTableTestQuery); |
|
1271 | + $this->log->debug('testing query on temp table: ['.$tempTableTestQuery_idx.']'); |
|
1272 | + $this->query($tempTableTestQuery_idx, false, "Preflight Failed for: {$query}"); |
|
1273 | + } |
|
1274 | + $mysqlError = $this->getL(); |
|
1275 | + if(!empty($mysqlError)) { |
|
1276 | + return $mysqlError; |
|
1277 | + } |
|
1278 | + $this->dropTableName("{$table}__uw_temp"); |
|
1279 | + |
|
1280 | + return ''; |
|
1281 | + } |
|
1282 | + |
|
1283 | + protected function verifyGenericReplaceQuery($querytype, $table, $query) |
|
1284 | + { |
|
1285 | + $this->log->debug("verifying $querytype statement"); |
|
1286 | + |
|
1287 | + if(!$this->makeTempTableCopy($table)) { |
|
1288 | + return 'Could not create temp table copy'; |
|
1289 | + } |
|
1290 | + // test the query on the test table |
|
1291 | + $this->log->debug('testing query: ['.$query.']'); |
|
1292 | + $tempTableTestQuery = str_replace("$querytype `{$table}`", "$querytype `{$table}__uw_temp`", $query); |
|
1293 | + if(strpos($tempTableTestQuery, '__uw_temp') === false) { |
|
1294 | + return 'Could not use a temp table to test query!'; |
|
1295 | + } |
|
1296 | + |
|
1297 | + $this->query($tempTableTestQuery, false, "Preflight Failed for: {$query}"); |
|
1298 | + $error = $this->lastError(); // empty on no-errors |
|
1299 | + $this->dropTableName("{$table}__uw_temp"); // just in case |
|
1300 | + return $error; |
|
1301 | + } |
|
1302 | + |
|
1303 | + /** |
|
1304 | + * Tests a DROP TABLE query |
|
1305 | + * @param string table The table name to get DDL |
|
1306 | + * @param string query The query to test. |
|
1307 | + * @return string Non-empty if error found |
|
1308 | + */ |
|
1309 | + public function verifyDropTable($table, $query) |
|
1310 | + { |
|
1311 | + return $this->verifyGenericReplaceQuery("DROP TABLE", $table, $query); |
|
1312 | + } |
|
1313 | + |
|
1314 | + /** |
|
1315 | + * Tests an INSERT INTO query |
|
1316 | + * @param string table The table name to get DDL |
|
1317 | + * @param string query The query to test. |
|
1318 | + * @return string Non-empty if error found |
|
1319 | + */ |
|
1320 | + public function verifyInsertInto($table, $query) |
|
1321 | + { |
|
1322 | + return $this->verifyGenericReplaceQuery("INSERT INTO", $table, $query); |
|
1323 | + } |
|
1324 | + |
|
1325 | + /** |
|
1326 | + * Tests an UPDATE query |
|
1327 | + * @param string table The table name to get DDL |
|
1328 | + * @param string query The query to test. |
|
1329 | + * @return string Non-empty if error found |
|
1330 | + */ |
|
1331 | + public function verifyUpdate($table, $query) |
|
1332 | + { |
|
1333 | + return $this->verifyGenericReplaceQuery("UPDATE", $table, $query); |
|
1334 | + } |
|
1335 | + |
|
1336 | + /** |
|
1337 | + * Tests an DELETE FROM query |
|
1338 | + * @param string table The table name to get DDL |
|
1339 | + * @param string query The query to test. |
|
1340 | + * @return string Non-empty if error found |
|
1341 | + */ |
|
1342 | + public function verifyDeleteFrom($table, $query) |
|
1343 | + { |
|
1344 | + return $this->verifyGenericReplaceQuery("DELETE FROM", $table, $query); |
|
1345 | + } |
|
1346 | + |
|
1347 | + /** |
|
1348 | + * Check if certain database exists |
|
1349 | + * @param string $dbname |
|
1350 | + */ |
|
1351 | + public function dbExists($dbname) |
|
1352 | + { |
|
1353 | + $db = $this->getOne("SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = ".$this->quoted($dbname)); |
|
1354 | + return !empty($db); |
|
1355 | + } |
|
1356 | + |
|
1357 | + /** |
|
1358 | + * Select database |
|
1359 | + * @param string $dbname |
|
1360 | + */ |
|
1361 | + protected function selectDb($dbname) |
|
1362 | + { |
|
1363 | + return mysql_select_db($dbname); |
|
1364 | + } |
|
1365 | + |
|
1366 | + /** |
|
1367 | + * Check if certain DB user exists |
|
1368 | + * @param string $username |
|
1369 | + */ |
|
1370 | + public function userExists($username) |
|
1371 | + { |
|
1372 | + $db = $this->getOne("SELECT DATABASE()"); |
|
1373 | + if(!$this->selectDb("mysql")) { |
|
1374 | + return false; |
|
1375 | + } |
|
1376 | + $user = $this->getOne("select count(*) from user where user = ".$this->quoted($username)); |
|
1377 | + if(!$this->selectDb($db)) { |
|
1378 | + $this->checkError("Cannot select database $db", true); |
|
1379 | + } |
|
1380 | + return !empty($user); |
|
1381 | + } |
|
1382 | + |
|
1383 | + /** |
|
1384 | + * Create DB user |
|
1385 | + * @param string $database_name |
|
1386 | + * @param string $host_name |
|
1387 | + * @param string $user |
|
1388 | + * @param string $password |
|
1389 | + */ |
|
1390 | + public function createDbUser($database_name, $host_name, $user, $password) |
|
1391 | + { |
|
1392 | + $qpassword = $this->quote($password); |
|
1393 | + $this->query("GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, INDEX |
|
1394 | 1394 | ON `$database_name`.* |
1395 | 1395 | TO \"$user\"@\"$host_name\" |
1396 | 1396 | IDENTIFIED BY '{$qpassword}';", true); |
1397 | 1397 | |
1398 | - $this->query("SET PASSWORD FOR \"{$user}\"@\"{$host_name}\" = password('{$qpassword}');", true); |
|
1399 | - if($host_name != 'localhost') { |
|
1400 | - $this->createDbUser($database_name, "localhost", $user, $password); |
|
1401 | - } |
|
1402 | - } |
|
1403 | - |
|
1404 | - /** |
|
1405 | - * Create a database |
|
1406 | - * @param string $dbname |
|
1407 | - */ |
|
1408 | - public function createDatabase($dbname) |
|
1409 | - { |
|
1410 | - $this->query("CREATE DATABASE `$dbname` CHARACTER SET utf8 COLLATE utf8_general_ci", true); |
|
1411 | - } |
|
1412 | - |
|
1413 | - public function preInstall() |
|
1414 | - { |
|
1415 | - $db->query("ALTER DATABASE `{$setup_db_database_name}` DEFAULT CHARACTER SET utf8", true); |
|
1416 | - $db->query("ALTER DATABASE `{$setup_db_database_name}` DEFAULT COLLATE utf8_general_ci", true); |
|
1417 | - |
|
1418 | - } |
|
1419 | - |
|
1420 | - /** |
|
1421 | - * Drop a database |
|
1422 | - * @param string $dbname |
|
1423 | - */ |
|
1424 | - public function dropDatabase($dbname) |
|
1425 | - { |
|
1426 | - return $this->query("DROP DATABASE IF EXISTS `$dbname`", true); |
|
1427 | - } |
|
1428 | - |
|
1429 | - /** |
|
1430 | - * Check if this driver can be used |
|
1431 | - * @return bool |
|
1432 | - */ |
|
1433 | - public function valid() |
|
1434 | - { |
|
1435 | - return function_exists("mysql_connect"); |
|
1436 | - } |
|
1437 | - |
|
1438 | - /** |
|
1439 | - * Check DB version |
|
1440 | - * @see DBManager::canInstall() |
|
1441 | - */ |
|
1442 | - public function canInstall() |
|
1443 | - { |
|
1444 | - $db_version = $this->version(); |
|
1445 | - if(empty($db_version)) { |
|
1446 | - return array('ERR_DB_VERSION_FAILURE'); |
|
1447 | - } |
|
1448 | - if(version_compare($db_version, '4.1.2') < 0) { |
|
1449 | - return array('ERR_DB_MYSQL_VERSION', $db_version); |
|
1450 | - } |
|
1451 | - return true; |
|
1452 | - } |
|
1453 | - |
|
1454 | - public function installConfig() |
|
1455 | - { |
|
1456 | - return array( |
|
1457 | - 'LBL_DBCONFIG_MSG3' => array( |
|
1458 | - "setup_db_database_name" => array("label" => 'LBL_DBCONF_DB_NAME', "required" => true), |
|
1459 | - ), |
|
1460 | - 'LBL_DBCONFIG_MSG2' => array( |
|
1461 | - "setup_db_host_name" => array("label" => 'LBL_DBCONF_HOST_NAME', "required" => true), |
|
1462 | - ), |
|
1463 | - 'LBL_DBCONF_TITLE_USER_INFO' => array(), |
|
1464 | - 'LBL_DBCONFIG_B_MSG1' => array( |
|
1465 | - "setup_db_admin_user_name" => array("label" => 'LBL_DBCONF_DB_ADMIN_USER', "required" => true), |
|
1466 | - "setup_db_admin_password" => array("label" => 'LBL_DBCONF_DB_ADMIN_PASSWORD', "type" => "password"), |
|
1467 | - ) |
|
1468 | - ); |
|
1469 | - } |
|
1470 | - |
|
1471 | - /** |
|
1472 | - * Disable keys on the table |
|
1473 | - * @abstract |
|
1474 | - * @param string $tableName |
|
1475 | - */ |
|
1476 | - public function disableKeys($tableName) |
|
1477 | - { |
|
1478 | - return $this->query('ALTER TABLE '.$tableName.' DISABLE KEYS'); |
|
1479 | - } |
|
1480 | - |
|
1481 | - /** |
|
1482 | - * Re-enable keys on the table |
|
1483 | - * @abstract |
|
1484 | - * @param string $tableName |
|
1485 | - */ |
|
1486 | - public function enableKeys($tableName) |
|
1487 | - { |
|
1488 | - return $this->query('ALTER TABLE '.$tableName.' ENABLE KEYS'); |
|
1489 | - } |
|
1398 | + $this->query("SET PASSWORD FOR \"{$user}\"@\"{$host_name}\" = password('{$qpassword}');", true); |
|
1399 | + if($host_name != 'localhost') { |
|
1400 | + $this->createDbUser($database_name, "localhost", $user, $password); |
|
1401 | + } |
|
1402 | + } |
|
1403 | + |
|
1404 | + /** |
|
1405 | + * Create a database |
|
1406 | + * @param string $dbname |
|
1407 | + */ |
|
1408 | + public function createDatabase($dbname) |
|
1409 | + { |
|
1410 | + $this->query("CREATE DATABASE `$dbname` CHARACTER SET utf8 COLLATE utf8_general_ci", true); |
|
1411 | + } |
|
1412 | + |
|
1413 | + public function preInstall() |
|
1414 | + { |
|
1415 | + $db->query("ALTER DATABASE `{$setup_db_database_name}` DEFAULT CHARACTER SET utf8", true); |
|
1416 | + $db->query("ALTER DATABASE `{$setup_db_database_name}` DEFAULT COLLATE utf8_general_ci", true); |
|
1417 | + |
|
1418 | + } |
|
1419 | + |
|
1420 | + /** |
|
1421 | + * Drop a database |
|
1422 | + * @param string $dbname |
|
1423 | + */ |
|
1424 | + public function dropDatabase($dbname) |
|
1425 | + { |
|
1426 | + return $this->query("DROP DATABASE IF EXISTS `$dbname`", true); |
|
1427 | + } |
|
1428 | + |
|
1429 | + /** |
|
1430 | + * Check if this driver can be used |
|
1431 | + * @return bool |
|
1432 | + */ |
|
1433 | + public function valid() |
|
1434 | + { |
|
1435 | + return function_exists("mysql_connect"); |
|
1436 | + } |
|
1437 | + |
|
1438 | + /** |
|
1439 | + * Check DB version |
|
1440 | + * @see DBManager::canInstall() |
|
1441 | + */ |
|
1442 | + public function canInstall() |
|
1443 | + { |
|
1444 | + $db_version = $this->version(); |
|
1445 | + if(empty($db_version)) { |
|
1446 | + return array('ERR_DB_VERSION_FAILURE'); |
|
1447 | + } |
|
1448 | + if(version_compare($db_version, '4.1.2') < 0) { |
|
1449 | + return array('ERR_DB_MYSQL_VERSION', $db_version); |
|
1450 | + } |
|
1451 | + return true; |
|
1452 | + } |
|
1453 | + |
|
1454 | + public function installConfig() |
|
1455 | + { |
|
1456 | + return array( |
|
1457 | + 'LBL_DBCONFIG_MSG3' => array( |
|
1458 | + "setup_db_database_name" => array("label" => 'LBL_DBCONF_DB_NAME', "required" => true), |
|
1459 | + ), |
|
1460 | + 'LBL_DBCONFIG_MSG2' => array( |
|
1461 | + "setup_db_host_name" => array("label" => 'LBL_DBCONF_HOST_NAME', "required" => true), |
|
1462 | + ), |
|
1463 | + 'LBL_DBCONF_TITLE_USER_INFO' => array(), |
|
1464 | + 'LBL_DBCONFIG_B_MSG1' => array( |
|
1465 | + "setup_db_admin_user_name" => array("label" => 'LBL_DBCONF_DB_ADMIN_USER', "required" => true), |
|
1466 | + "setup_db_admin_password" => array("label" => 'LBL_DBCONF_DB_ADMIN_PASSWORD', "type" => "password"), |
|
1467 | + ) |
|
1468 | + ); |
|
1469 | + } |
|
1470 | + |
|
1471 | + /** |
|
1472 | + * Disable keys on the table |
|
1473 | + * @abstract |
|
1474 | + * @param string $tableName |
|
1475 | + */ |
|
1476 | + public function disableKeys($tableName) |
|
1477 | + { |
|
1478 | + return $this->query('ALTER TABLE '.$tableName.' DISABLE KEYS'); |
|
1479 | + } |
|
1480 | + |
|
1481 | + /** |
|
1482 | + * Re-enable keys on the table |
|
1483 | + * @abstract |
|
1484 | + * @param string $tableName |
|
1485 | + */ |
|
1486 | + public function enableKeys($tableName) |
|
1487 | + { |
|
1488 | + return $this->query('ALTER TABLE '.$tableName.' ENABLE KEYS'); |
|
1489 | + } |
|
1490 | 1490 | |
1491 | 1491 | /** |
1492 | 1492 | * Returns a DB specific FROM clause which can be used to select against functions. |
@@ -1505,8 +1505,8 @@ discard block |
||
1505 | 1505 | * @return string |
1506 | 1506 | */ |
1507 | 1507 | |
1508 | - public function getGuidSQL() |
|
1508 | + public function getGuidSQL() |
|
1509 | 1509 | { |
1510 | - return 'UUID()'; |
|
1510 | + return 'UUID()'; |
|
1511 | 1511 | } |
1512 | 1512 | } |
@@ -3,8 +3,7 @@ discard block |
||
3 | 3 | * |
4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
6 | - |
|
7 | -* * SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd. |
|
6 | + * * SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd. |
|
8 | 7 | * Copyright (C) 2011 - 2017 SalesAgility Ltd. |
9 | 8 | * |
10 | 9 | * This program is free software; you can redistribute it and/or modify it under |
@@ -174,12 +173,12 @@ discard block |
||
174 | 173 | */ |
175 | 174 | protected $action_view_map = array(); |
176 | 175 | |
177 | - /** |
|
178 | - * This can be set from the application to tell us whether we have authorization to |
|
179 | - * process the action. If this is set we will default to the noaccess view. |
|
180 | - *@var bool |
|
176 | + /** |
|
177 | + * This can be set from the application to tell us whether we have authorization to |
|
178 | + * process the action. If this is set we will default to the noaccess view. |
|
179 | + *@var bool |
|
181 | 180 | */ |
182 | - public $hasAccess ; |
|
181 | + public $hasAccess ; |
|
183 | 182 | |
184 | 183 | /** |
185 | 184 | * Map case sensitive filenames to action. This is used for linux/unix systems |
@@ -191,12 +190,12 @@ discard block |
||
191 | 190 | 'listview' => 'ListView' |
192 | 191 | ); |
193 | 192 | |
194 | - /** |
|
195 | - * Constructor. This ie meant to load up the module, action, record as well |
|
196 | - * as the mapping arrays. |
|
197 | - */ |
|
198 | - public function __construct() |
|
199 | - { |
|
193 | + /** |
|
194 | + * Constructor. This ie meant to load up the module, action, record as well |
|
195 | + * as the mapping arrays. |
|
196 | + */ |
|
197 | + public function __construct() |
|
198 | + { |
|
200 | 199 | $this->hasAccess = true;} |
201 | 200 | |
202 | 201 | /** |
@@ -62,42 +62,42 @@ |
||
62 | 62 | |
63 | 63 | require_once('include/formbase.php'); |
64 | 64 | |
65 | - global $beanFiles,$beanList; |
|
66 | - $bean_name = $beanList[$_REQUEST['module']]; |
|
67 | - require_once($beanFiles[$bean_name]); |
|
68 | - $focus = new $bean_name(); |
|
69 | - if ( empty($_REQUEST['linked_id']) || empty($_REQUEST['linked_field']) || empty($_REQUEST['record'])){ |
|
70 | - |
|
71 | - die("need linked_field, linked_id and record fields"); |
|
72 | - } |
|
73 | - $linked_field = $_REQUEST['linked_field']; |
|
74 | - $record = $_REQUEST['record']; |
|
75 | - $linked_id = $_REQUEST['linked_id']; |
|
76 | - if ($linked_field === 'aclroles') { |
|
65 | + global $beanFiles,$beanList; |
|
66 | + $bean_name = $beanList[$_REQUEST['module']]; |
|
67 | + require_once($beanFiles[$bean_name]); |
|
68 | + $focus = new $bean_name(); |
|
69 | + if ( empty($_REQUEST['linked_id']) || empty($_REQUEST['linked_field']) || empty($_REQUEST['record'])){ |
|
70 | + |
|
71 | + die("need linked_field, linked_id and record fields"); |
|
72 | + } |
|
73 | + $linked_field = $_REQUEST['linked_field']; |
|
74 | + $record = $_REQUEST['record']; |
|
75 | + $linked_id = $_REQUEST['linked_id']; |
|
76 | + if ($linked_field === 'aclroles') { |
|
77 | 77 | if (!ACLController::checkAccess($bean_name, 'edit', true)) { |
78 | 78 | ACLController::displayNoAccess(); |
79 | 79 | sugar_cleanup(true); |
80 | 80 | } |
81 | 81 | }if($linked_field === 'aclroles') { |
82 | 82 | if (!ACLController::checkAccess($bean_name , 'edit', true)) { |
83 | - ACLController::displayNoAccess(); |
|
83 | + ACLController::displayNoAccess(); |
|
84 | 84 | sugar_cleanup(true); |
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
88 | 88 | if ($bean_name === 'Team'){ |
89 | - $focus->retrieve($record); |
|
90 | - $focus->remove_user_from_team($linked_id); |
|
91 | - } |
|
92 | - else{ |
|
93 | - |
|
94 | - // cut it off: |
|
95 | - $focus->load_relationship($linked_field); |
|
96 | - if($focus->$linked_field->_relationship->relationship_name === 'quotes_contacts_shipto'){ |
|
97 | - unset($focus->$linked_field->_relationship->relationship_role_column);} |
|
98 | - $focus->$linked_field->delete($record,$linked_id); |
|
99 | - } |
|
100 | - if ($bean_name === 'Campaign' and $linked_field==='prospectlists' ) { |
|
89 | + $focus->retrieve($record); |
|
90 | + $focus->remove_user_from_team($linked_id); |
|
91 | + } |
|
92 | + else{ |
|
93 | + |
|
94 | + // cut it off: |
|
95 | + $focus->load_relationship($linked_field); |
|
96 | + if($focus->$linked_field->_relationship->relationship_name === 'quotes_contacts_shipto'){ |
|
97 | + unset($focus->$linked_field->_relationship->relationship_role_column);} |
|
98 | + $focus->$linked_field->delete($record,$linked_id); |
|
99 | + } |
|
100 | + if ($bean_name === 'Campaign' and $linked_field==='prospectlists' ) { |
|
101 | 101 | |
102 | 102 | $query = "SELECT email_marketing_prospect_lists.id from email_marketing_prospect_lists "; |
103 | 103 | $query .= " left join email_marketing on email_marketing.id=email_marketing_prospect_lists.email_marketing_id"; |
@@ -60,50 +60,50 @@ |
||
60 | 60 | $parent_record_id = $_REQUEST['record']; |
61 | 61 | $parent_module = $_REQUEST['module']; |
62 | 62 | |
63 | - $action = 'DeleteRelationship'; |
|
64 | - $record = $layout_def['fields']['ID']; |
|
65 | - $current_module=$layout_def['module']; |
|
66 | - //in document revisions subpanel ,users are now allowed to |
|
67 | - //delete the latest revsion of a document. this will be tested here |
|
68 | - //and if the condition is met delete button will be removed. |
|
69 | - $hideremove=false; |
|
70 | - if ($current_module==='DocumentRevisions') { |
|
71 | - if ($layout_def['fields']['ID']===$layout_def['fields']['LATEST_REVISION_ID']) { |
|
72 | - $hideremove=true; |
|
73 | - } |
|
74 | - }elseif ($_REQUEST['module'] === 'Teams' && $current_module === 'Users') { |
|
75 | - // Implicit Team-memberships are not "removeable" |
|
76 | - |
|
77 | - if($layout_def['fields']['UPLINE'] !== translate('LBL_TEAM_UPLINE_EXPLICIT', 'Users')) { |
|
78 | - $hideremove = true; |
|
79 | - } |
|
80 | - |
|
81 | - //We also cannot remove the user whose private team is set to the parent_record_id value |
|
82 | - $user = new User(); |
|
83 | - $user->retrieve($layout_def['fields']['ID']); |
|
84 | - if($parent_record_id === $user->getPrivateTeamID()){ |
|
85 | - |
|
86 | - $hideremove = true; |
|
87 | - }} elseif ($current_module === 'ACLRoles' && (!ACLController::checkAccess($current_module, 'edit', true))) { |
|
63 | + $action = 'DeleteRelationship'; |
|
64 | + $record = $layout_def['fields']['ID']; |
|
65 | + $current_module=$layout_def['module']; |
|
66 | + //in document revisions subpanel ,users are now allowed to |
|
67 | + //delete the latest revsion of a document. this will be tested here |
|
68 | + //and if the condition is met delete button will be removed. |
|
69 | + $hideremove=false; |
|
70 | + if ($current_module==='DocumentRevisions') { |
|
71 | + if ($layout_def['fields']['ID']===$layout_def['fields']['LATEST_REVISION_ID']) { |
|
72 | + $hideremove=true; |
|
73 | + } |
|
74 | + }elseif ($_REQUEST['module'] === 'Teams' && $current_module === 'Users') { |
|
75 | + // Implicit Team-memberships are not "removeable" |
|
76 | + |
|
77 | + if($layout_def['fields']['UPLINE'] !== translate('LBL_TEAM_UPLINE_EXPLICIT', 'Users')) { |
|
78 | + $hideremove = true; |
|
79 | + } |
|
80 | + |
|
81 | + //We also cannot remove the user whose private team is set to the parent_record_id value |
|
82 | + $user = new User(); |
|
83 | + $user->retrieve($layout_def['fields']['ID']); |
|
84 | + if($parent_record_id === $user->getPrivateTeamID()){ |
|
85 | + |
|
86 | + $hideremove = true; |
|
87 | + }} elseif ($current_module === 'ACLRoles' && (!ACLController::checkAccess($current_module, 'edit', true))) { |
|
88 | 88 | $hideremove = true; |
89 | - }elseif ($current_module === 'ACLRoles' && (!ACLController::checkAccess($current_module, 'edit', true))) { |
|
89 | + }elseif ($current_module === 'ACLRoles' && (!ACLController::checkAccess($current_module, 'edit', true))) { |
|
90 | 90 | $hideremove = true; |
91 | - } |
|
91 | + } |
|
92 | 92 | |
93 | - $return_module = $_REQUEST['module']; |
|
94 | - $return_action = 'SubPanelViewer'; |
|
95 | - $subpanel = $layout_def['subpanel_id']; |
|
96 | - $return_id = $_REQUEST['record']; |
|
97 | - if (isset($layout_def['linked_field_set']) && !empty($layout_def['linked_field_set'])) { |
|
98 | - $linked_field= $layout_def['linked_field_set'] ; |
|
99 | - } else { |
|
100 | - $linked_field = $layout_def['linked_field']; |
|
101 | - } |
|
102 | - $refresh_page = 0; |
|
103 | - if(!empty($layout_def['refresh_page'])){ |
|
104 | - $refresh_page = 1; |
|
105 | - } |
|
106 | - $return_url = "index.php?module=$return_module&action=$return_action&subpanel=$subpanel&record=$return_id&sugar_body_only=1&inline=1"; |
|
93 | + $return_module = $_REQUEST['module']; |
|
94 | + $return_action = 'SubPanelViewer'; |
|
95 | + $subpanel = $layout_def['subpanel_id']; |
|
96 | + $return_id = $_REQUEST['record']; |
|
97 | + if (isset($layout_def['linked_field_set']) && !empty($layout_def['linked_field_set'])) { |
|
98 | + $linked_field= $layout_def['linked_field_set'] ; |
|
99 | + } else { |
|
100 | + $linked_field = $layout_def['linked_field']; |
|
101 | + } |
|
102 | + $refresh_page = 0; |
|
103 | + if(!empty($layout_def['refresh_page'])){ |
|
104 | + $refresh_page = 1; |
|
105 | + } |
|
106 | + $return_url = "index.php?module=$return_module&action=$return_action&subpanel=$subpanel&record=$return_id&sugar_body_only=1&inline=1"; |
|
107 | 107 | |
108 | 108 | $icon_remove_text = $app_strings['LBL_ID_FF_REMOVE']; |
109 | 109 |
@@ -60,21 +60,21 @@ discard block |
||
60 | 60 | function __construct ($definition) |
61 | 61 | { |
62 | 62 | |
63 | - parent::__construct ( $definition ) ; |
|
64 | - $onetomanyDef = array_merge($definition, array( |
|
65 | - 'rhs_label' => isset($definition['lhs_label']) ? $definition['lhs_label'] : null, |
|
66 | - 'lhs_label' => isset($definition['rhs_label']) ? $definition['rhs_label'] : null, |
|
67 | - 'lhs_subpanel' => isset($definition['rhs_subpanel']) ? $definition['rhs_subpanel'] : null, |
|
68 | - 'rhs_subpanel' => isset($definition['lhs_subpanel']) ? $definition['lhs_subpanel'] : null, |
|
69 | - 'lhs_module' => isset($definition['rhs_module']) ? $definition['rhs_module'] : null, |
|
70 | - 'lhs_table' => isset($definition['rhs_table']) ? $definition['rhs_table'] : null, |
|
71 | - 'lhs_key' => isset($definition['rhs_key']) ? $definition['rhs_key'] : null, |
|
72 | - 'rhs_module' => isset($definition['lhs_module']) ? $definition['lhs_module'] : null, |
|
73 | - 'rhs_table' => isset($definition['lhs_table']) ? $definition['lhs_table'] : null, |
|
74 | - 'rhs_key' => isset($definition['lhs_key']) ? $definition['lhs_key'] : null, |
|
75 | - 'join_key_lhs' => isset($definition['join_key_rhs']) ? $definition['join_key_rhs'] : null, |
|
76 | - 'join_key_rhs' => isset($definition['join_key_lhs']) ? $definition['join_key_lhs'] : null, |
|
77 | - 'relationship_type' => MB_ONETOMANY, |
|
63 | + parent::__construct ( $definition ) ; |
|
64 | + $onetomanyDef = array_merge($definition, array( |
|
65 | + 'rhs_label' => isset($definition['lhs_label']) ? $definition['lhs_label'] : null, |
|
66 | + 'lhs_label' => isset($definition['rhs_label']) ? $definition['rhs_label'] : null, |
|
67 | + 'lhs_subpanel' => isset($definition['rhs_subpanel']) ? $definition['rhs_subpanel'] : null, |
|
68 | + 'rhs_subpanel' => isset($definition['lhs_subpanel']) ? $definition['lhs_subpanel'] : null, |
|
69 | + 'lhs_module' => isset($definition['rhs_module']) ? $definition['rhs_module'] : null, |
|
70 | + 'lhs_table' => isset($definition['rhs_table']) ? $definition['rhs_table'] : null, |
|
71 | + 'lhs_key' => isset($definition['rhs_key']) ? $definition['rhs_key'] : null, |
|
72 | + 'rhs_module' => isset($definition['lhs_module']) ? $definition['lhs_module'] : null, |
|
73 | + 'rhs_table' => isset($definition['lhs_table']) ? $definition['lhs_table'] : null, |
|
74 | + 'rhs_key' => isset($definition['lhs_key']) ? $definition['lhs_key'] : null, |
|
75 | + 'join_key_lhs' => isset($definition['join_key_rhs']) ? $definition['join_key_rhs'] : null, |
|
76 | + 'join_key_rhs' => isset($definition['join_key_lhs']) ? $definition['join_key_lhs'] : null, |
|
77 | + 'relationship_type' => MB_ONETOMANY, |
|
78 | 78 | )); |
79 | 79 | $this->one_to_many = new OneToManyRelationship($onetomanyDef); |
80 | 80 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * BUILD methods called during the build |
84 | 84 | */ |
85 | 85 | |
86 | - function buildLabels($update = false) |
|
86 | + function buildLabels($update = false) |
|
87 | 87 | { |
88 | 88 | return $this->one_to_many->buildLabels(); |
89 | 89 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | */ |
105 | 105 | function buildVardefs ( ) |
106 | 106 | { |
107 | - return $this->one_to_many->buildVardefs(); |
|
107 | + return $this->one_to_many->buildVardefs(); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /* |
@@ -130,19 +130,19 @@ discard block |
||
130 | 130 | public function setName ($relationshipName) |
131 | 131 | { |
132 | 132 | parent::setName($relationshipName); |
133 | - $this->one_to_many->setname($relationshipName); |
|
133 | + $this->one_to_many->setname($relationshipName); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | public function setReadonly ($set = true) |
137 | 137 | { |
138 | 138 | parent::setReadonly($set); |
139 | - $this->one_to_many->setReadonly(); |
|
139 | + $this->one_to_many->setReadonly(); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | public function delete () |
143 | 143 | { |
144 | 144 | parent::delete(); |
145 | - $this->one_to_many->delete(); |
|
145 | + $this->one_to_many->delete(); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | public function setRelationship_only () |
@@ -43,66 +43,66 @@ discard block |
||
43 | 43 | } |
44 | 44 | |
45 | 45 | $mod_strings = array ( |
46 | - 'LBL_ACCEPT_THIS'=>'Accept?', |
|
47 | - 'LBL_ADD_BUTTON'=> 'Add', |
|
48 | - 'LBL_ADD_INVITEE' => 'Add Invitees', |
|
49 | - 'LBL_CONTACT_NAME' => 'Contact:', |
|
50 | - 'LBL_CONTACTS_SUBPANEL_TITLE' => 'Contacts', |
|
51 | - 'LBL_CREATED_BY'=>'Created by', |
|
52 | - 'LBL_DATE_END'=>'End Date', |
|
53 | - 'LBL_DATE_TIME' => 'Start Date & Time:', |
|
54 | - 'LBL_DATE' => 'Start Date:', |
|
55 | - 'LBL_DEFAULT_SUBPANEL_TITLE' => 'Meetings', |
|
56 | - 'LBL_DESCRIPTION' => 'Description:', |
|
46 | + 'LBL_ACCEPT_THIS'=>'Accept?', |
|
47 | + 'LBL_ADD_BUTTON'=> 'Add', |
|
48 | + 'LBL_ADD_INVITEE' => 'Add Invitees', |
|
49 | + 'LBL_CONTACT_NAME' => 'Contact:', |
|
50 | + 'LBL_CONTACTS_SUBPANEL_TITLE' => 'Contacts', |
|
51 | + 'LBL_CREATED_BY'=>'Created by', |
|
52 | + 'LBL_DATE_END'=>'End Date', |
|
53 | + 'LBL_DATE_TIME' => 'Start Date & Time:', |
|
54 | + 'LBL_DATE' => 'Start Date:', |
|
55 | + 'LBL_DEFAULT_SUBPANEL_TITLE' => 'Meetings', |
|
56 | + 'LBL_DESCRIPTION' => 'Description:', |
|
57 | 57 | 'LBL_DIRECTION' => 'Direction:', |
58 | - 'LBL_DURATION_HOURS' => 'Duration Hours:', |
|
59 | - 'LBL_DURATION_MINUTES' => 'Duration Minutes:', |
|
60 | - 'LBL_DURATION' => 'Duration:', |
|
61 | - 'LBL_EMAIL' => 'Email', |
|
62 | - 'LBL_FIRST_NAME' => 'First Name', |
|
63 | - 'LBL_HISTORY_SUBPANEL_TITLE' => 'Notes', |
|
64 | - 'LBL_HOURS_ABBREV' => 'h', |
|
65 | - 'LBL_HOURS_MINS' => '(hours/minutes)', |
|
66 | - 'LBL_INVITEE' => 'Invitees', |
|
67 | - 'LBL_LAST_NAME' => 'Last Name', |
|
68 | - 'LBL_ASSIGNED_TO_NAME'=>'Assigned to:', |
|
69 | - 'LBL_LIST_ASSIGNED_TO_NAME' => 'Assigned User', |
|
70 | - 'LBL_LIST_CLOSE' => 'Close', |
|
71 | - 'LBL_LIST_CONTACT' => 'Contact', |
|
72 | - 'LBL_LIST_DATE_MODIFIED'=>'Date Modified', |
|
73 | - 'LBL_LIST_DATE' => 'Start Date', |
|
74 | - 'LBL_LIST_DIRECTION' => 'Direction', |
|
75 | - 'LBL_LIST_DUE_DATE'=>'Due Date', |
|
76 | - 'LBL_LIST_FORM_TITLE' => 'Meeting List', |
|
77 | - 'LBL_LIST_MY_MEETINGS' => 'My Meetings', |
|
78 | - 'LBL_LIST_RELATED_TO' => 'Related to', |
|
79 | - 'LBL_LIST_STATUS'=>'Status', |
|
80 | - 'LBL_LIST_SUBJECT' => 'Subject', |
|
81 | - 'LBL_LEADS_SUBPANEL_TITLE' => 'Leads', |
|
82 | - 'LBL_LOCATION' => 'Location:', |
|
83 | - 'LBL_MINSS_ABBREV' => 'm', |
|
84 | - 'LBL_MODIFIED_BY'=>'Modified by', |
|
85 | - 'LBL_MODULE_NAME' => 'Meetings', |
|
86 | - 'LBL_MODULE_TITLE' => 'Meetings: Home', |
|
87 | - 'LBL_NAME' => 'Name', |
|
88 | - 'LBL_NEW_FORM_TITLE' => 'Create Appointment', |
|
89 | - 'LBL_OUTLOOK_ID' => 'Outlook ID', |
|
90 | - 'LBL_SEQUENCE' => 'Meeting update sequence', |
|
91 | - 'LBL_PHONE' => 'Phone Office:', |
|
92 | - 'LBL_REMINDER_TIME'=>'Reminder Time', |
|
58 | + 'LBL_DURATION_HOURS' => 'Duration Hours:', |
|
59 | + 'LBL_DURATION_MINUTES' => 'Duration Minutes:', |
|
60 | + 'LBL_DURATION' => 'Duration:', |
|
61 | + 'LBL_EMAIL' => 'Email', |
|
62 | + 'LBL_FIRST_NAME' => 'First Name', |
|
63 | + 'LBL_HISTORY_SUBPANEL_TITLE' => 'Notes', |
|
64 | + 'LBL_HOURS_ABBREV' => 'h', |
|
65 | + 'LBL_HOURS_MINS' => '(hours/minutes)', |
|
66 | + 'LBL_INVITEE' => 'Invitees', |
|
67 | + 'LBL_LAST_NAME' => 'Last Name', |
|
68 | + 'LBL_ASSIGNED_TO_NAME'=>'Assigned to:', |
|
69 | + 'LBL_LIST_ASSIGNED_TO_NAME' => 'Assigned User', |
|
70 | + 'LBL_LIST_CLOSE' => 'Close', |
|
71 | + 'LBL_LIST_CONTACT' => 'Contact', |
|
72 | + 'LBL_LIST_DATE_MODIFIED'=>'Date Modified', |
|
73 | + 'LBL_LIST_DATE' => 'Start Date', |
|
74 | + 'LBL_LIST_DIRECTION' => 'Direction', |
|
75 | + 'LBL_LIST_DUE_DATE'=>'Due Date', |
|
76 | + 'LBL_LIST_FORM_TITLE' => 'Meeting List', |
|
77 | + 'LBL_LIST_MY_MEETINGS' => 'My Meetings', |
|
78 | + 'LBL_LIST_RELATED_TO' => 'Related to', |
|
79 | + 'LBL_LIST_STATUS'=>'Status', |
|
80 | + 'LBL_LIST_SUBJECT' => 'Subject', |
|
81 | + 'LBL_LEADS_SUBPANEL_TITLE' => 'Leads', |
|
82 | + 'LBL_LOCATION' => 'Location:', |
|
83 | + 'LBL_MINSS_ABBREV' => 'm', |
|
84 | + 'LBL_MODIFIED_BY'=>'Modified by', |
|
85 | + 'LBL_MODULE_NAME' => 'Meetings', |
|
86 | + 'LBL_MODULE_TITLE' => 'Meetings: Home', |
|
87 | + 'LBL_NAME' => 'Name', |
|
88 | + 'LBL_NEW_FORM_TITLE' => 'Create Appointment', |
|
89 | + 'LBL_OUTLOOK_ID' => 'Outlook ID', |
|
90 | + 'LBL_SEQUENCE' => 'Meeting update sequence', |
|
91 | + 'LBL_PHONE' => 'Phone Office:', |
|
92 | + 'LBL_REMINDER_TIME'=>'Reminder Time', |
|
93 | 93 | 'LBL_EMAIL_REMINDER_SENT' => 'Email reminder sent', |
94 | - 'LBL_REMINDER' => 'Reminders:', |
|
95 | - 'LBL_REMINDER_POPUP' => 'Popup', |
|
94 | + 'LBL_REMINDER' => 'Reminders:', |
|
95 | + 'LBL_REMINDER_POPUP' => 'Popup', |
|
96 | 96 | 'LBL_REMINDER_EMAIL_ALL_INVITEES' => 'Email all invitees', |
97 | 97 | 'LBL_EMAIL_REMINDER' => 'Email Reminder', |
98 | 98 | 'LBL_EMAIL_REMINDER_TIME' => 'Email Reminder Time', |
99 | 99 | 'LBL_REMOVE' => 'rem', |
100 | - 'LBL_SCHEDULING_FORM_TITLE' => 'Scheduling', |
|
101 | - 'LBL_SEARCH_BUTTON'=> 'Search', |
|
102 | - 'LBL_SEARCH_FORM_TITLE' => 'Meeting Search', |
|
103 | - 'LBL_SEND_BUTTON_LABEL'=>'Save & Send Invites', |
|
104 | - 'LBL_SEND_BUTTON_TITLE'=>'Save & Send Invites', |
|
105 | - 'LBL_STATUS' => 'Status:', |
|
100 | + 'LBL_SCHEDULING_FORM_TITLE' => 'Scheduling', |
|
101 | + 'LBL_SEARCH_BUTTON'=> 'Search', |
|
102 | + 'LBL_SEARCH_FORM_TITLE' => 'Meeting Search', |
|
103 | + 'LBL_SEND_BUTTON_LABEL'=>'Save & Send Invites', |
|
104 | + 'LBL_SEND_BUTTON_TITLE'=>'Save & Send Invites', |
|
105 | + 'LBL_STATUS' => 'Status:', |
|
106 | 106 | 'LBL_TYPE' => 'Meeting Type', |
107 | 107 | 'LBL_PASSWORD' => 'Meeting Password', |
108 | 108 | 'LBL_URL' => 'Start/Join Meeting', |
@@ -110,21 +110,21 @@ discard block |
||
110 | 110 | 'LBL_DISPLAYED_URL' => 'Display URL', |
111 | 111 | 'LBL_CREATOR' => 'Meeting Creator', |
112 | 112 | 'LBL_EXTERNALID' => 'External App ID', |
113 | - 'LBL_SUBJECT' => 'Subject:', |
|
114 | - 'LBL_TIME' => 'Start Time:', |
|
115 | - 'LBL_USERS_SUBPANEL_TITLE' => 'Users', |
|
113 | + 'LBL_SUBJECT' => 'Subject:', |
|
114 | + 'LBL_TIME' => 'Start Time:', |
|
115 | + 'LBL_USERS_SUBPANEL_TITLE' => 'Users', |
|
116 | 116 | 'LBL_PARENT_TYPE' => 'Parent Type', |
117 | 117 | 'LBL_PARENT_ID' => 'Parent ID', |
118 | - 'LNK_MEETING_LIST'=>'View Meetings', |
|
119 | - 'LNK_NEW_APPOINTMENT' => 'Create Appointment', |
|
120 | - 'LNK_NEW_MEETING'=>'Schedule Meeting', |
|
121 | - 'LNK_IMPORT_MEETINGS' => 'Import Meetings', |
|
118 | + 'LNK_MEETING_LIST'=>'View Meetings', |
|
119 | + 'LNK_NEW_APPOINTMENT' => 'Create Appointment', |
|
120 | + 'LNK_NEW_MEETING'=>'Schedule Meeting', |
|
121 | + 'LNK_IMPORT_MEETINGS' => 'Import Meetings', |
|
122 | 122 | |
123 | 123 | 'LBL_CREATED_USER' => 'Created User', |
124 | 124 | 'LBL_MODIFIED_USER' => 'Modified User', |
125 | 125 | 'NOTICE_DURATION_TIME' => 'Duration time must be greater than 0', |
126 | 126 | 'LBL_MEETING_INFORMATION' => 'OVERVIEW', |
127 | - 'LBL_LIST_JOIN_MEETING' => 'Join Meeting', |
|
127 | + 'LBL_LIST_JOIN_MEETING' => 'Join Meeting', |
|
128 | 128 | 'LBL_ACCEPT_STATUS' => 'Accept Status', |
129 | 129 | 'LBL_ACCEPT_LINK' => 'Accept Link', |
130 | 130 | // You are not invited to the meeting messages |
@@ -154,14 +154,14 @@ discard block |
||
154 | 154 | 'LBL_SYNCED_RECURRING_MSG' => 'This meeting originated in another system and was synced to SuiteCRM. To make changes, go to the original meeting within the other system. Changes made in the other system can be synced to this record.', |
155 | 155 | 'LBL_RELATED_TO' => 'Related to:', |
156 | 156 | |
157 | - // for reminders |
|
158 | - 'LBL_REMINDERS' => 'Reminders', |
|
159 | - 'LBL_REMINDERS_ACTIONS' => 'Actions:', |
|
160 | - 'LBL_REMINDERS_POPUP' => 'Popup', |
|
161 | - 'LBL_REMINDERS_EMAIL' => 'Email invitees', |
|
162 | - 'LBL_REMINDERS_WHEN' => 'When:', |
|
163 | - 'LBL_REMINDERS_REMOVE_REMINDER' => 'Remove reminder', |
|
164 | - 'LBL_REMINDERS_ADD_ALL_INVITEES' => 'Add All Invitees', |
|
165 | - 'LBL_REMINDERS_ADD_REMINDER' => 'Add reminder', |
|
157 | + // for reminders |
|
158 | + 'LBL_REMINDERS' => 'Reminders', |
|
159 | + 'LBL_REMINDERS_ACTIONS' => 'Actions:', |
|
160 | + 'LBL_REMINDERS_POPUP' => 'Popup', |
|
161 | + 'LBL_REMINDERS_EMAIL' => 'Email invitees', |
|
162 | + 'LBL_REMINDERS_WHEN' => 'When:', |
|
163 | + 'LBL_REMINDERS_REMOVE_REMINDER' => 'Remove reminder', |
|
164 | + 'LBL_REMINDERS_ADD_ALL_INVITEES' => 'Add All Invitees', |
|
165 | + 'LBL_REMINDERS_ADD_REMINDER' => 'Add reminder', |
|
166 | 166 | ); |
167 | 167 | ?> |
@@ -112,17 +112,17 @@ |
||
112 | 112 | 'LBL_FP_EVENTS_LEADS_1_FROM_LEADS_TITLE' => 'Leads', |
113 | 113 | 'LBL_FP_EVENTS_PROSPECTS_1_FROM_PROSPECTS_TITLE' => 'Targets', |
114 | 114 | 'LBL_FP_EVENTS_FP_EVENT_DELEGATES_1_FROM_FP_EVENT_DELEGATES_TITLE' => 'Delegates', |
115 | - 'LBL_HOURS_ABBREV' => 'h', |
|
116 | - 'LBL_MINSS_ABBREV' => 'm', |
|
115 | + 'LBL_HOURS_ABBREV' => 'h', |
|
116 | + 'LBL_MINSS_ABBREV' => 'm', |
|
117 | 117 | |
118 | - // Attendance report |
|
119 | - 'LBL_CONTACT_NAME' => 'Name', |
|
120 | - 'LBL_ACCOUNT_NAME' => 'Company', |
|
121 | - 'LBL_SIGNATURE' => 'Signature', |
|
122 | - // contacts/leads/targets subpanels |
|
123 | - 'LBL_LIST_INVITE_STATUS_EVENT' => 'Invited', |
|
124 | - 'LBL_LIST_ACCEPT_STATUS_EVENT' => 'Status', |
|
118 | + // Attendance report |
|
119 | + 'LBL_CONTACT_NAME' => 'Name', |
|
120 | + 'LBL_ACCOUNT_NAME' => 'Company', |
|
121 | + 'LBL_SIGNATURE' => 'Signature', |
|
122 | + // contacts/leads/targets subpanels |
|
123 | + 'LBL_LIST_INVITE_STATUS_EVENT' => 'Invited', |
|
124 | + 'LBL_LIST_ACCEPT_STATUS_EVENT' => 'Status', |
|
125 | 125 | |
126 | - 'LBL_ACTIVITY_STATUS' => 'Activity Status', |
|
127 | - 'LBL_FP_EVENT_LOCATIONS_FP_EVENTS_1_FROM_FP_EVENTS_TITLE' => 'Event Locations from Events Title', |
|
126 | + 'LBL_ACTIVITY_STATUS' => 'Activity Status', |
|
127 | + 'LBL_FP_EVENT_LOCATIONS_FP_EVENTS_1_FROM_FP_EVENTS_TITLE' => 'Event Locations from Events Title', |
|
128 | 128 | ); |
@@ -137,15 +137,15 @@ |
||
137 | 137 | |
138 | 138 | 'LBL_SOURCE_SUGAR' => 'SugarCRM Inc - providers of CE framework', |
139 | 139 | |
140 | - 'LBL_DASHLET_TITLE' => 'My Sites', |
|
141 | - 'LBL_DASHLET_OPT_TITLE' => 'Title', |
|
142 | - 'LBL_DASHLET_INCORRECT_URL' => 'Incorrect website location is specified', |
|
143 | - 'LBL_DASHLET_OPT_URL' => 'Website Location', |
|
144 | - 'LBL_DASHLET_OPT_HEIGHT' => 'Dashlet Height (in pixels)', |
|
145 | - 'LBL_DASHLET_SUGAR_NEWS' => 'SuiteCRM News', |
|
146 | - 'LBL_DASHLET_DISCOVER_SUGAR_PRO' => 'Discover SuiteCRM', |
|
147 | - 'LBL_BASIC_SEARCH' => 'Quick Filter' /*for 508 compliance fix*/, |
|
148 | - 'LBL_ADVANCED_SEARCH' => 'Advanced Filter' /*for 508 compliance fix*/, |
|
140 | + 'LBL_DASHLET_TITLE' => 'My Sites', |
|
141 | + 'LBL_DASHLET_OPT_TITLE' => 'Title', |
|
142 | + 'LBL_DASHLET_INCORRECT_URL' => 'Incorrect website location is specified', |
|
143 | + 'LBL_DASHLET_OPT_URL' => 'Website Location', |
|
144 | + 'LBL_DASHLET_OPT_HEIGHT' => 'Dashlet Height (in pixels)', |
|
145 | + 'LBL_DASHLET_SUGAR_NEWS' => 'SuiteCRM News', |
|
146 | + 'LBL_DASHLET_DISCOVER_SUGAR_PRO' => 'Discover SuiteCRM', |
|
147 | + 'LBL_BASIC_SEARCH' => 'Quick Filter' /*for 508 compliance fix*/, |
|
148 | + 'LBL_ADVANCED_SEARCH' => 'Advanced Filter' /*for 508 compliance fix*/, |
|
149 | 149 | 'LBL_TOUR_HOME' => 'Home Icon', |
150 | 150 | 'LBL_TOUR_HOME_DESCRIPTION' => 'Quickly get back to your Home Page dashboard in one click.', |
151 | 151 | 'LBL_TOUR_MODULES' => 'Modules', |