From ca8270bf65f0958fe0d45161ee69dfe1077e8ac8 Mon Sep 17 00:00:00 2001 From: botanic Date: Sun, 7 Sep 2014 05:39:48 -0700 Subject: [PATCH] Initial Domain Management Plugin --- .../ams/plugins/Achievements/Achievements.php | 30 +-- .../plugins/Achievements/templates/index.tpl | 1 - .../Domain_Management/Domain_Management.php | 68 ++--- .../Domain_Management/templates/index.tpl | 251 ++++++++++++++---- .../public_php/ams/templates/layout_admin.tpl | 4 +- .../public_php/ams/templates/layout_mod.tpl | 2 +- .../public_php/ams/templates/layout_user.tpl | 2 +- 7 files changed, 258 insertions(+), 100 deletions(-) diff --git a/code/web/private_php/ams/plugins/Achievements/Achievements.php b/code/web/private_php/ams/plugins/Achievements/Achievements.php index 47f39b9d8..13404598b 100644 --- a/code/web/private_php/ams/plugins/Achievements/Achievements.php +++ b/code/web/private_php/ams/plugins/Achievements/Achievements.php @@ -17,7 +17,7 @@ // Global variable to store the data which is // returned to the templates -$return_set = array(); +$achievements_return_set = array(); // Local variable to store data during // functionalities of the hooks @@ -28,10 +28,10 @@ $var_set = array(); */ function achievements_hook_display() { - global $return_set; + global $achievements_return_set; // to display plugin name in menu bar - $return_set['menu_display'] = 'Achievements'; - $return_set['icon'] = 'icon-certificate'; + $achievements_return_set['menu_display'] = 'Achievements'; + $achievements_return_set['icon'] = 'icon-certificate'; } /** @@ -98,7 +98,7 @@ function hook_get_player_stat( $data ) */ function hook_variable_set() { - global $return_set; + global $achievements_return_set; global $var_set; if ( isset( $_POST['Character'] ) && !empty( $_POST['Character'] ) ) { @@ -133,7 +133,7 @@ function hook_variable_set() } else { - $return_set['no_char'] = "Please Generate key for a character before requesting for achievements"; + $achievements_return_set['no_char'] = "Please Generate key for a character before requesting for achievements"; } } @@ -147,13 +147,13 @@ function hook_variable_set() * appkey --> app key for authentication * host --> host from which request have been sent * - * @return $return_set global array returns the template data + * @return $achievements_return_set global array returns the template data */ function achievements_hook_call_rest() { // defined the variables global $var_set; - global $return_set; + global $achievements_return_set; if ( isset( $_POST['get_data'] ) ) { @@ -162,7 +162,7 @@ function achievements_hook_call_rest() $rest_api = new Rest_Api(); $ach_data = $rest_api -> request( $var_set['url'], $var_set['app_key'], $var_set['host'], $var_set['items'] ); // here we store the response we get from the server - $return_set['char_achievements'] = $ach_data ; + $achievements_return_set['char_achievements'] = $ach_data ; } } @@ -171,11 +171,11 @@ function achievements_hook_call_rest() * the content to use in the smarty templates extracted from * the database * - * @return $return_set global array returns the template data + * @return $achievements_return_set global array returns the template data */ function achievements_hook_get_db() { - global $return_set; + global $achievements_return_set; if ( isset( $_SESSION['user'] ) ) { @@ -184,7 +184,7 @@ function achievements_hook_get_db() // getting content for selecting characters $sth = $db -> selectWithParameter( 'UserCharacter', 'ams_api_keys', array( 'User' => $_SESSION['user'] ) , 'User = :User' ); $row = $sth -> fetch(); - $return_set['Character'] = $row; + $achievements_return_set['Character'] = $row; } } @@ -192,10 +192,10 @@ function achievements_hook_get_db() * Global Hook to return global variables which contains * the content to use in the smarty templates * - * @return $return_set global array returns the template data + * @return $achievements_return_set global array returns the template data */ function achievements_hook_return_global() { - global $return_set; - return $return_set; + global $achievements_return_set; + return $achievements_return_set; } diff --git a/code/web/private_php/ams/plugins/Achievements/templates/index.tpl b/code/web/private_php/ams/plugins/Achievements/templates/index.tpl index b88b5730a..be0306fe1 100644 --- a/code/web/private_php/ams/plugins/Achievements/templates/index.tpl +++ b/code/web/private_php/ams/plugins/Achievements/templates/index.tpl @@ -1,5 +1,4 @@ {block name=content} - {if isset($smarty.get.plugin_action) and $smarty.get.plugin_action eq 'get_achievements'}
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 4c8f44f54..359c9289e 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 @@ -17,7 +17,7 @@ // Global variable to store the data which is // returned to the templates -$return_set = array(); +$domain_management_return_set = array(); // Local variable to store data during // functionalities of the hooks @@ -28,10 +28,10 @@ $var_set = array(); */ function domain_management_hook_display() { - global $return_set; + global $domain_management_return_set; // to display plugin name in menu bar - $return_set['admin_menu_display'] = 'Domain Management'; - $return_set['icon'] = 'icon-edit'; + $domain_management_return_set['admin_menu_display'] = 'Domain Management'; + $domain_management_return_set['icon'] = 'icon-edit'; } /** @@ -98,7 +98,7 @@ function domain_management_get_player_stat( $data ) */ function domain_management_variable_set() { - global $return_set; + global $domain_management_return_set; global $var_set; if ( isset( $_POST['Character'] ) && !empty( $_POST['Character'] ) ) { @@ -133,7 +133,7 @@ function domain_management_variable_set() } else { - $return_set['no_char'] = "Please Generate key for a character before requesting for domain_management"; + $domain_management_return_set['no_char'] = "Please Generate key for a character before requesting for domain_management"; } } @@ -147,23 +147,16 @@ function domain_management_variable_set() * appkey --> app key for authentication * host --> host from which request have been sent * - * @return $return_set global array returns the template data + * @return $domain_management_return_set global array returns the template data */ function domain_management_hook_call_rest() { - // defined the variables - global $var_set; - global $return_set; + + global $domain_management_return_set; + global $WEBPATH; - if ( isset( $_POST['get_data'] ) ) - { - domain_management_variable_set(); - // here we make the REST connection - $rest_api = new Rest_Api(); - $ach_data = $rest_api -> request( $var_set['url'], $var_set['app_key'], $var_set['host'], $var_set['items'] ); - // here we store the response we get from the server - $return_set['char_domain_management'] = $ach_data ; - } + $domain_management_return_set['path'] = $WEBPATH; + } /** @@ -171,31 +164,42 @@ function domain_management_hook_call_rest() * the content to use in the smarty templates extracted from * the database * - * @return $return_set global array returns the template data + * @return $domain_management_return_set global array returns the template data */ function domain_management_hook_get_db() { - global $return_set; + global $domain_management_return_set; - if ( isset( $_SESSION['user'] ) ) - { - $db = new DBLayer( 'lib' ); + $db = new DBLayer( 'shard' ); - // getting content for selecting characters - $sth = $db -> selectWithParameter( 'UserCharacter', 'ams_api_keys', array( 'User' => $_SESSION['user'] ) , 'User = :User' ); - $row = $sth -> fetch(); - $return_set['Character'] = $row; - } + //get all domains + $statement = $db->executeWithoutParams("SELECT * FROM domain"); + $rows = $statement->fetchAll(); + $domain_management_return_set['domains'] = $rows; + + if (isset($_GET['edit_domain'])){ + //get permissions + $statement = $db->executeWithoutParams("SELECT * FROM `permission` WHERE `ClientApplication` = '".$rows[$_GET['edit_domain']-1]['domain_name']."'"); + $rows = $statement->fetchAll(); + $domain_management_return_set['permissions'] = $rows; + + //get all users + $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")); + + } + + return $rows; } /** * Global Hook to return global variables which contains * the content to use in the smarty templates * - * @return $return_set global array returns the template data + * @return $domain_management_return_set global array returns the template data */ function domain_management_hook_return_global() { - global $return_set; - return $return_set; + global $domain_management_return_set; + return $domain_management_return_set; } 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 eb0c770da..d49edc89e 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 @@ -1,54 +1,209 @@ {block name=content} -{if isset($smarty.get.plugin_action) and $smarty.get.plugin_action eq 'get_domain_management'} -
-
-
-
-

Domain_Management

-
-
- {if isset($hook_info.Domain_Management.no_char)}

{$hook_info.Domain_Management.no_char}

{/if} -
- {$hook_info.Domain_Management.char_domain_management} +{if isset($smarty.get.edit_domain)} +
+
+
+
+

{$hook_info['Domain_Management']['domains'][$smarty.get.edit_domain-1]['domain_name']}

+
+
+
+ Users with permissions in domain + + + + + + + + + + + {foreach from=$hook_info['Domain_Management']['userlist'] item=element} + + + + + + + {/foreach} + +
User IDUsernamePermissions
{$element.id}{$element.username}{$hook_info['Domain_Management']['permissions'][{$element.id}-1]['AccessPrivilege']} + +
+
+
+
+
+ +
+
+
+

Modify Domain Settings

+
+
+
+ +
+ + Domain Settings of '{$hook_info['Domain_Management']['domains'][$smarty.get.edit_domain-1]['domain_name']}' + +
+ +
+
+
-
-
-
+
+
+ +
+ +
+
+ +
+
+
+ +
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ +
+ +
+
+ +
+
+
+ +
+ +
+
+ +
+
+
+ +
+ +
+
+ +
+
+
+ +
+ +
+
+ +
+
+
+ +
+ +
+
+ +
+
+
+ +
+ +
+
+ +
+
+
+ +
+ +
+
+ +
+
+
+ +
+ +
+
+ +
+
+
+ +
+ +
+ +
+
+ + {if isset($RESULT_OF_MODIFYING) and $RESULT_OF_MODIFYING eq "SUCCESS"} +
+ {$modify_mail_of_group_success} +
+ {/if} + + +
+
+
+
+
{else} -
-
-
-
-

Select your Character

-
-
-
-
-
-
- -
- -
-
-
- -
- -
-
- -
-
-
-
-
-
-{/if} + + + + + + + + + + + + {foreach from=$hook_info['Domain_Management']['domains'] item=array} + + + + + + + + {/foreach} + +
Domain IDDomain NameStatusPatch VersionDescription
{$array['domain_id']}{$array['domain_name']}{$array['status']}{$array['patch_version']}{$array['description']|truncate}
+{/if} {/block} diff --git a/code/web/public_php/ams/templates/layout_admin.tpl b/code/web/public_php/ams/templates/layout_admin.tpl index 12ff65c40..be6bd0765 100644 --- a/code/web/public_php/ams/templates/layout_admin.tpl +++ b/code/web/public_php/ams/templates/layout_admin.tpl @@ -4,12 +4,12 @@
  • Dashboard
  • Profile
  • Settings
  • - {if isset($hook_info)} {foreach from=$hook_info key=arrkey item=element}{if isset($element.menu_display)}
  • {$element.menu_display}
  • {/if}{/foreach}{/if} + {if isset($hook_info)} {foreach from=$hook_info key=arrkey item=element}{if isset($element['menu_display'])}
  • {$element['menu_display']}
  • {/if}{/foreach}{/if}
  • Users
  • Queues
  • Support Groups
  • - {if isset($hook_info)} {foreach from=$hook_info key=arrkey item=element}{if isset($element.admin_menu_display)}
  • {$element.admin_menu_display}
  • {/if}{/foreach}{/if} + {if isset($hook_info)} {foreach from=$hook_info key=arrkey item=element}{if isset($element.admin_menu_display)}
  • {$element.admin_menu_display}
  • {/if}{/foreach}{/if}
  • Plugins
  • Syncing
  • diff --git a/code/web/public_php/ams/templates/layout_mod.tpl b/code/web/public_php/ams/templates/layout_mod.tpl index e4fbdcc69..63b992d3f 100644 --- a/code/web/public_php/ams/templates/layout_mod.tpl +++ b/code/web/public_php/ams/templates/layout_mod.tpl @@ -4,7 +4,7 @@
  • Dashboard
  • Profile
  • Settings
  • - {if isset($hook_info)} {foreach from=$hook_info key=arrkey item=element}
  • {$element.menu_display}
  • {/foreach}{/if} + {if isset($hook_info)} {foreach from=$hook_info key=arrkey item=element}{if isset($element.menu_display)}
  • {$element.menu_display}
  • {/if]{/foreach}{/if}
  • Users
  • Queues
  • diff --git a/code/web/public_php/ams/templates/layout_user.tpl b/code/web/public_php/ams/templates/layout_user.tpl index e70b7c164..800058bfa 100644 --- a/code/web/public_php/ams/templates/layout_user.tpl +++ b/code/web/public_php/ams/templates/layout_user.tpl @@ -3,7 +3,7 @@
  • Profile
  • Settings
  • - {if isset($hook_info)} {foreach from=$hook_info key=arrkey item=element}
  • {$element.menu_display}
  • {/foreach}{/if} + {if isset($hook_info)} {foreach from=$hook_info key=arrkey item=element}
  • {$element.menu_display}
  • {/foreach}{/if}
  • Create New Ticket
  • Logout