From 5eb052da4b97079291a7766be6510373f74d8a0e Mon Sep 17 00:00:00 2001 From: Quitta Date: Thu, 5 Sep 2013 04:16:28 +0200 Subject: [PATCH] userlist works, show reply works, also possible to change the permissions of the users (though relying on the libs permission system atm..) --- .../ryzommanage/autoload/webusers.php | 2 +- .../drupal_module/ryzommanage/config.php | 6 +- .../ryzommanage/inc/change_permission.php | 40 ++++++++++++ .../ryzommanage/inc/show_reply.php | 46 ++++++++++++++ .../ryzommanage/inc/userlist.php | 28 +++++++++ .../ryzommanage/ryzommanage.module | 2 +- .../ryzommanage/templates/show_reply.tpl | 24 +++++++ .../ryzommanage/templates/show_ticket.tpl | 8 +-- .../ryzommanage/templates/show_user.tpl | 2 - .../ryzommanage/templates/userlist.tpl | 62 +++++++++++++++++++ 10 files changed, 209 insertions(+), 11 deletions(-) create mode 100644 code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/inc/change_permission.php create mode 100644 code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/inc/show_reply.php create mode 100644 code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/inc/userlist.php create mode 100644 code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/show_reply.tpl create mode 100644 code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/userlist.tpl diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/autoload/webusers.php b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/autoload/webusers.php index 2beb75c1b..73d0b79a0 100644 --- a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/autoload/webusers.php +++ b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/autoload/webusers.php @@ -207,7 +207,7 @@ class WebUsers extends Users{ } public static function getAllUsersQuery(){ - return "SELECT * FROM ams_user"; + return "SELECT * FROM users WHERE `uid` > 0"; } public static function createWebuser($name, $pass, $mail){ diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/config.php b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/config.php index 74651b7fc..739ed8d02 100644 --- a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/config.php +++ b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/config.php @@ -8,9 +8,9 @@ $cfg['db']['web']['host'] = variable_get('ryzommanage_webserverurl', 'localhost'); $cfg['db']['web']['port'] = variable_get('ryzommanage_webmysqlport', '3306'); -$cfg['db']['web']['name'] = variable_get('ryzommanage_webdbname', 'ryzom_ams'); -$cfg['db']['web']['user'] = variable_get('ryzommanage_webusername', 'shard'); -$cfg['db']['web']['pass'] = variable_get('ryzommanage_webpassword', ''); +$cfg['db']['web']['name'] = variable_get('ryzommanage_webdbname', 'drupal'); +$cfg['db']['web']['user'] = variable_get('ryzommanage_webusername', 'root'); +$cfg['db']['web']['pass'] = variable_get('ryzommanage_webpassword', 'lol123'); $cfg['db']['lib']['host'] = variable_get('ryzommanage_libserverurl', 'localhost'); $cfg['db']['lib']['port'] = variable_get('ryzommanage_libmysqlport', '3306'); diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/inc/change_permission.php b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/inc/change_permission.php new file mode 100644 index 000000000..3830b718e --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/inc/change_permission.php @@ -0,0 +1,40 @@ +getTUserId(), $value); + header("Location: ams?page=show_user&id=".$user_id); + exit; + + + }else{ + //ERROR: GET PARAMS not given or trying to change admin + header("Location: ams?page=show_user&id=".$user_id); + exit; + } + + }else{ + //ERROR: No access! + $_SESSION['error_code'] = "403"; + header("Location: index.php?page=error"); + exit; + + } + + }else{ + //ERROR: not logged in! + header("Location: index.php"); + exit; + } + + +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/inc/show_reply.php b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/inc/show_reply.php new file mode 100644 index 000000000..94090fa88 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/inc/show_reply.php @@ -0,0 +1,46 @@ +load_With_TReplyId($result['reply_id']); + + + $ticket = new Ticket(); + $ticket->load_With_TId($reply->getTicket()); + + if(( $ticket->getAuthor() == unserialize($_SESSION['ticket_user'])->getTUserId() && ! $reply->getHidden()) || Ticket_User::isMod(unserialize($_SESSION['ticket_user']) )){ + $content = new Ticket_Content(); + $content->load_With_TContentId($reply->getContent()); + + $author = new Ticket_User(); + $author->load_With_TUserId($reply->getAuthor()); + + $result['hidden'] = $reply->getHidden(); + $result['ticket_id'] = $reply->getTicket(); + $result['reply_timestamp'] = $reply->getTimestamp(); + $result['author_permission'] = $author->getPermission(); + $result['reply_content'] = $content->getContent(); + $result['author'] = $author->getExternId(); + $webUser = new WebUsers($author->getExternId()); + $result['authorName'] = $webUser->getUsername(); + if(Ticket_User::isMod(unserialize($_SESSION['ticket_user']))){ + $result['isMod'] = "TRUE"; + } + return $result; + + }else{ + //ERROR: No access! + $_SESSION['error_code'] = "403"; + header("Location: index.php?page=error"); + exit; + } + }else{ + //ERROR: not logged in! + header("Location: index.php"); + exit; + } +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/inc/userlist.php b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/inc/userlist.php new file mode 100644 index 000000000..d8783ce32 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/inc/userlist.php @@ -0,0 +1,28 @@ +getElements() , Array("getUId","getUsername","getEmail"), Array("id","username","email")); + $pageResult['links'] = $pagination->getLinks(5); + $pageResult['lastPage'] = $pagination->getLast(); + $pageResult['currentPage'] = $pagination->getCurrent(); + + $i = 0; + foreach( $pageResult['userlist'] as $user ){ + $pageResult['userlist'][$i]['permission'] = Ticket_User::constr_ExternId($pageResult['userlist'][$i]['id'])->getPermission(); + $i++; + } + + if (Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))){ + $pageResult['isAdmin'] = "TRUE"; + } + return $pageResult; + }else{ + //ERROR: No access! + $_SESSION['error_code'] = "403"; + header("Location: index.php?page=error"); + exit; + } +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ryzommanage.module b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ryzommanage.module index be5bcbe8c..20d3e1569 100644 --- a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ryzommanage.module +++ b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ryzommanage.module @@ -556,7 +556,7 @@ function top_bar() if(ticket_user::isMod(unserialize($_SESSION['ticket_user']))){ return "
Profile | Create Ticket | - Settings | Users | + Settings | Users | Queues | Support Groups | Logout
"; diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/show_reply.tpl b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/show_reply.tpl new file mode 100644 index 000000000..287d59f8b --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/show_reply.tpl @@ -0,0 +1,24 @@ +{block name=content} +

Show Reply

+ +

Reply ID#{$reply_id} of Ticket #{$ticket_id}

+ + + + +
+

{$reply_timestamp} + {if $author_permission eq '1'} + {if isset($isMod) and $isMod eq "TRUE"} {$authorName}{else} {$authorName} {/if}

+ {else if $author_permission gt '1'} + {if isset($isMod) and $isMod eq "TRUE"} {$authorName}{else} {$authorName} {/if}

+ {/if} +

{if $hidden eq 1}{/if}{$reply_content}{if $hidden eq 1}{/if}

+ +
+ + + + +{/block} + diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/show_ticket.tpl b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/show_ticket.tpl index 9b83aab09..c9d8c854b 100644 --- a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/show_ticket.tpl +++ b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/show_ticket.tpl @@ -96,13 +96,13 @@ {if $ticket_forwardedGroupName eq "0"} {$public_sgroup} {else} - {$ticket_forwardedGroupName} + {$ticket_forwardedGroupName} {/if} - Assigned To: {if $ticket_assignedTo neq ""} {$ticket_assignedToText} {else} {$not_assigned} {/if} + Assigned To: {if $ticket_assignedTo neq ""} {$ticket_assignedToText} {else} {$not_assigned} {/if} @@ -117,9 +117,9 @@

{$reply.timestamp} {if $reply.permission eq '1'} - {if isset($isMod) and $isMod eq "TRUE"} {$reply.author}{else} {$reply.author} {/if} + {if isset($isMod) and $isMod eq "TRUE"} {$reply.author}{else} {$reply.author} {/if} {else if $reply.permission gt '1'} - {if isset($isMod) and $isMod eq "TRUE"} {$reply.author}{else} {$reply.author} {/if} + {if isset($isMod) and $isMod eq "TRUE"} {$reply.author}{else} {$reply.author} {/if} {/if}

{if $reply.hidden eq 1}{/if}{$reply.replyContent}{if $reply.hidden eq 1}{/if}

diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/show_user.tpl b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/show_user.tpl index 0344c11b5..a7b5a95b1 100644 --- a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/show_user.tpl +++ b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/show_user.tpl @@ -63,8 +63,6 @@

Tickets of {$target_name}

- - Tickets diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/userlist.tpl b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/userlist.tpl new file mode 100644 index 000000000..bf39cc6ae --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/userlist.tpl @@ -0,0 +1,62 @@ +{block name=content} + +
+ + + + + + + + + + + {foreach from=$userlist item=element} + + + + + {if $element.permission eq 1}{/if} + {if $element.permission eq 2}{/if} + {if $element.permission eq 3}{/if} + + + {/foreach} + + +
IdUsernameEmailPermissionAction
{$element.id}{$element.username}{$element.email}UserModeratorAdmin + + + + {if isset($isAdmin) and $isAdmin eq 'TRUE' and $element.id neq 1} + + {if $element.permission eq 1} + + + {else if $element.permission eq 2 } + + + {else if $element.permission eq 3 } + + + {/if} + {/if} + +
+ Show User + + Edit User + Make ModeratorMake AdminDemote to UserMake AdminDemote to UserDemote to Moderator
+
+
+ + « | + {foreach from=$links item=link} + {if $link == $currentPage}{/if}{$link}{if $link == $currentPage}{/if} | + {/foreach} + » + +
+ +{/block} +