| @@ 6-55 (lines=50) @@ | ||
| 3 | /** |
|
| 4 | * Class upgrade_2016 |
|
| 5 | */ |
|
| 6 | 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; |
|
| @@ 6-55 (lines=50) @@ | ||
| 3 | /** |
|
| 4 | * Class upgrade_2017 |
|
| 5 | */ |
|
| 6 | class Upgrade_2017 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_2017(); |
|
| 58 | return $upg; |
|