From 89604dbba48d927e8b0a147f6ee6b44b77ecd9da Mon Sep 17 00:00:00 2001 From: botanic Date: Sun, 14 Sep 2014 15:52:40 -0700 Subject: [PATCH] Fix #194 --HG-- branch : develop --- code/web/private_php/ams/autoload/helpers.php | 4 +- code/web/private_php/ams/autoload/users.php | 30 ++++++-- .../Domain_Management/Domain_Management.php | 31 +++++++++ .../Domain_Management/templates/index.tpl | 69 ++++++++++++------- 4 files changed, 104 insertions(+), 30 deletions(-) diff --git a/code/web/private_php/ams/autoload/helpers.php b/code/web/private_php/ams/autoload/helpers.php index b8118db37..28e4ce036 100644 --- a/code/web/private_php/ams/autoload/helpers.php +++ b/code/web/private_php/ams/autoload/helpers.php @@ -18,8 +18,8 @@ class Helpers { */ public static function loadTemplate( $template, $vars = array (), $returnHTML = false ) { - error_log(print_r($_GET,true)); - error_log(print_r($_POST,true)); + //error_log(print_r($_GET,true)); + //error_log(print_r($_POST,true)); global $AMS_LIB; global $SITEBASE; global $AMS_TRANS; diff --git a/code/web/private_php/ams/autoload/users.php b/code/web/private_php/ams/autoload/users.php index cde30cf63..ffc04ace2 100644 --- a/code/web/private_php/ams/autoload/users.php +++ b/code/web/private_php/ams/autoload/users.php @@ -336,12 +336,32 @@ class Users{ $dbs = new DBLayer("shard"); $sth = $dbs->selectWithParameter("UId", "user", $values, "Login= :username"); $result = $sth->fetchAll(); - /*foreach ($result as $UId) { - $ins_values = array('UId' => $UId['UId'], 'clientApplication' => 'r2', 'AccessPrivilege' => 'OPEN'); + $dbl = new DBLayer("lib"); + + $UId = $result['0']['UId']; + + $statement = $dbl->execute("SELECT * FROM `settings` WHERE `Setting` = :setting", Array('setting' => 'Domain_Auto_Add')); + $json = $statement->fetch(); + $json = json_decode($json['Value'],true); + + $db = new DBLayer( 'shard' ); + + // get all domains + $statement = $db -> executeWithoutParams( "SELECT * FROM domain" ); + $rows = $statement -> fetchAll(); + + //error_log(print_r($rows,true)); + //error_log(print_r($result,true)); + //error_log(print_r($json,true)); + foreach ($json as $key => $value) { + //error_log(print_r($key,true)); + //error_log(print_r($value,true)); + + $ins_values = array('UId' => $UId, 'DomainId' => $key, 'AccessPrivilege' => $value['1']); + error_log(print_r($ins_values,true)); + $dbs = new DBLayer("shard"); $dbs->insert("permission", $ins_values); - $ins_values['clientApplication'] = 'ryzom_open'; - $dbs->insert("permission", $ins_values); - }*/ // FIXME: GARBAGE + } } catch (PDOException $e) { //oh noooz, the shard is offline! Put it in query queue at ams_lib db! diff --git a/code/web/private_php/ams/plugins/Domain_Management/Domain_Management.php b/code/web/private_php/ams/plugins/Domain_Management/Domain_Management.php index cd748167d..a99ac5551 100644 --- a/code/web/private_php/ams/plugins/Domain_Management/Domain_Management.php +++ b/code/web/private_php/ams/plugins/Domain_Management/Domain_Management.php @@ -73,6 +73,29 @@ function domain_management_hook_get_db() $dbs = new DBLayer( 'shard' ); $dbs->update("domain", Array( 'domain_name' => $_POST['domain_name'], 'status' => $_POST['status'], 'patch_version' => $_POST['patch_version'],'backup_patch_url' => $_POST['backup_patch_url'],'patch_urls' => $_POST['patch_urls'],'login_address' => $_POST['login_address'],'session_manager_address' => $_POST['session_manager_address'],'ring_db_name' => $_POST['ring_db_name'],'web_host' => $_POST['web_host'],'web_host_php' => $_POST['web_host_php'],'description' => $_POST['description'],),'`domain_id` = '.$_GET['edit_domain']); + } + catch ( Exception $e ) { + return null; + } + } + + if ( isset( $_GET['ModifyPermission'] ) && $_GET['ModifyPermission'] = '1' && isset($_POST['user'])) { + try { + + $dbl = new DBLayer("lib"); + + $statement = $dbl->execute("SELECT * FROM `settings` WHERE `Setting` = :setting", Array('setting' => 'Domain_Auto_Add')); + $json = $statement->fetch(); + $json = json_decode($json['Value'],true); + + $json[$_GET['edit_domain']]['1'] = $_POST['user']; + $json[$_GET['edit_domain']]['2'] = $_POST['moderator']; + $json[$_GET['edit_domain']]['3'] = $_POST['admin']; + + $update = json_encode($json); + + $dbl->update("settings", Array( 'Value' => $update),"`Setting` = 'Domain_Auto_Add'"); + } catch ( Exception $e ) { return null; @@ -102,6 +125,14 @@ function domain_management_hook_get_db() $pagination = new Pagination( WebUsers :: getAllUsersQuery(), "web", 10, "WebUsers" ); $domain_management_return_set['userlist'] = Gui_Elements :: make_table( $pagination -> getElements() , Array( "getUId", "getUsername", "getEmail" ), Array( "id", "username", "email" ) ); + $dbl = new DBLayer("lib"); + + $statement = $dbl->execute("SELECT * FROM `settings` WHERE `Setting` = :setting", Array('setting' => 'Domain_Auto_Add')); + $json = $statement->fetch(); + $json = json_decode($json['Value'],true); + + $domain_management_return_set['Domain_Auto_Add'] = $json[$_GET['edit_domain']]; + } return $rows; diff --git a/code/web/private_php/ams/plugins/Domain_Management/templates/index.tpl b/code/web/private_php/ams/plugins/Domain_Management/templates/index.tpl index 6c6a55b45..803d1133e 100644 --- a/code/web/private_php/ams/plugins/Domain_Management/templates/index.tpl +++ b/code/web/private_php/ams/plugins/Domain_Management/templates/index.tpl @@ -205,35 +205,58 @@
-
-
- -
- + + + + + +
- -
- -
- + + + + +
+
- -
-
- +
+
+
+
+
+ +
+
+
+
+
+ +
+