|
1
|
|
|
<?php |
|
|
|
|
|
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Class upgrade_2016 |
|
5
|
|
|
*/ |
|
6
|
|
View Code Duplication |
class Upgrade_2016 extends XoopsUpgrade |
|
|
|
|
|
|
7
|
|
|
{ |
|
8
|
|
|
/** |
|
9
|
|
|
* @return bool |
|
10
|
|
|
*/ |
|
11
|
|
|
public function check_auth_db() |
|
12
|
|
|
{ |
|
13
|
|
|
$db = $GLOBALS['xoopsDB']; |
|
14
|
|
|
$value = $this->getDbValue($db, 'config', 'conf_id', "`conf_name` = 'ldap_use_TLS' AND `conf_catid` = " . XOOPS_CONF_AUTH); |
|
15
|
|
|
|
|
16
|
|
|
return (bool)$value; |
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @param $sql |
|
21
|
|
|
*/ |
|
22
|
|
|
protected function query($sql) |
|
23
|
|
|
{ |
|
24
|
|
|
$db = $GLOBALS['xoopsDB']; |
|
25
|
|
|
if (!($ret = $db->queryF($sql))) { |
|
26
|
|
|
echo $db->error(); |
|
27
|
|
|
} |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @return bool |
|
32
|
|
|
*/ |
|
33
|
|
|
public function apply_auth_db() |
|
34
|
|
|
{ |
|
35
|
|
|
$db = $GLOBALS['xoopsDB']; |
|
36
|
|
|
|
|
37
|
|
|
// Insert config values |
|
38
|
|
|
$table = $db->prefix('config'); |
|
39
|
|
|
$data = array( |
|
40
|
|
|
'ldap_use_TLS' => "'_MD_AM_LDAP_USETLS', '0', '_MD_AM_LDAP_USETLS_DESC', 'yesno', 'int', 21"); |
|
41
|
|
|
foreach ($data as $name => $values) { |
|
42
|
|
|
if (!$this->getDbValue($db, 'config', 'conf_id', "`conf_modid`=0 AND `conf_catid`=7 AND `conf_name`='$name'")) { |
|
43
|
|
|
$this->query("INSERT INTO `$table` (conf_modid,conf_catid,conf_name,conf_title,conf_value,conf_desc,conf_formtype,conf_valuetype,conf_order) " . "VALUES ( 0,7,'$name',$values)"); |
|
44
|
|
|
} |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
return true; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function __construct() |
|
51
|
|
|
{ |
|
52
|
|
|
parent::__construct(basename(__DIR__)); |
|
53
|
|
|
$this->tasks = array('auth_db'); |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
$upg = new Upgrade_2016(); |
|
58
|
|
|
return $upg; |
|
59
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.