From f16711c9fa84bbf655146d7b7e9353b4ab7bd502 Mon Sep 17 00:00:00 2001 From: Quitta Date: Thu, 5 Sep 2013 21:33:11 +0200 Subject: [PATCH] added support group functionality to the drupal module --HG-- branch : quitta-gsoc-2013 --- .../ryzommanage/func/add_sgroup.php | 40 ++++++ .../ryzommanage/func/add_user_to_sgroup.php | 43 +++++++ .../func/modify_email_of_sgroup.php | 54 ++++++++ .../ryzommanage/inc/sgroup_list.php | 31 +++++ .../ryzommanage/inc/show_sgroup.php | 58 +++++++++ .../ryzommanage/templates/sgroup_list.tpl | 105 ++++++++++++++++ .../ryzommanage/templates/show_sgroup.tpl | 118 ++++++++++++++++++ .../drupal_module/ryzommanage/todo.txt | 4 +- 8 files changed, 452 insertions(+), 1 deletion(-) create mode 100644 code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/func/add_sgroup.php create mode 100644 code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/func/add_user_to_sgroup.php create mode 100644 code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/func/modify_email_of_sgroup.php create mode 100644 code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/inc/sgroup_list.php create mode 100644 code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/inc/show_sgroup.php create mode 100644 code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/sgroup_list.tpl create mode 100644 code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/show_sgroup.tpl diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/func/add_sgroup.php b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/func/add_sgroup.php new file mode 100644 index 000000000..e2ef663f1 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/func/add_sgroup.php @@ -0,0 +1,40 @@ +getPermission(); + $result['no_visible_elements'] = 'FALSE'; + $result['username'] = $_SESSION['user']; + //global $SITEBASE; + //require($SITEBASE . '/inc/sgroup_list.php'); + //$result= array_merge($result, sgroup_list()); + //return helpers :: loadtemplate( 'sgroup_list', $result, true); + header("Location: ams?page=sgroup_list"); + 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/func/add_user_to_sgroup.php b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/func/add_user_to_sgroup.php new file mode 100644 index 000000000..924014f79 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/func/add_user_to_sgroup.php @@ -0,0 +1,43 @@ +getPermission()>1){ + $result['RESULT_OF_ADDING'] = Support_Group::addUserToSupportGroup($user_id, $id); + }else{ + $result['RESULT_OF_ADDING'] = "NOT_MOD_OR_ADMIN"; + } + + }else{ + $result['RESULT_OF_ADDING'] = "USER_NOT_EXISTING"; + } + $result['permission'] = unserialize($_SESSION['ticket_user'])->getPermission(); + $result['no_visible_elements'] = 'FALSE'; + $result['username'] = $_SESSION['user']; + //global $SITEBASE; + //require_once($SITEBASE . 'inc/show_sgroup.php'); + //$result= array_merge($result, show_sgroup()); + //helpers :: loadtemplate( 'show_sgroup', $result); + header("Location: ams?page=show_sgroup&id=".$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/func/modify_email_of_sgroup.php b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/func/modify_email_of_sgroup.php new file mode 100644 index 000000000..ade3c3af2 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/func/modify_email_of_sgroup.php @@ -0,0 +1,54 @@ +setGroupEmail($groupemail); + $group->setIMAP_MailServer(filter_var($_POST['IMAP_MailServer'],FILTER_SANITIZE_STRING)); + $group->setIMAP_Username(filter_var($_POST['IMAP_Username'],FILTER_SANITIZE_STRING)); + + //encrypt password! + global $cfg; + $crypter = new MyCrypt($cfg['crypt']); + $enc_password = $crypter->encrypt($password); + $group->setIMAP_Password($enc_password); + $group->update(); + $result['RESULT_OF_MODIFYING'] = "SUCCESS"; + if($password == ""){ + $result['RESULT_OF_MODIFYING'] = "NO_PASSWORD"; + } + }else{ + $result['RESULT_OF_MODIFYING'] = "EMAIL_NOT_VALID"; + } + + $result['permission'] = unserialize($_SESSION['ticket_user'])->getPermission(); + $result['no_visible_elements'] = 'FALSE'; + $result['username'] = $_SESSION['user']; + //global $SITEBASE; + //require_once($SITEBASE . 'inc/show_sgroup.php'); + //$result= array_merge($result, show_sgroup()); + //helpers :: loadtemplate( 'show_sgroup', $result); + header("Location: ams?page=show_sgroup&id=".$sgroupid); + 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/sgroup_list.php b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/inc/sgroup_list.php new file mode 100644 index 000000000..546395ed8 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/inc/sgroup_list.php @@ -0,0 +1,31 @@ +getName(); + $result['groupemail'] = $group->getGroupEmail(); + $result['imap_mailserver'] = $group->getIMAP_MailServer(); + $result['imap_username'] = $group->getIMAP_Username(); + $result['userlist'] = Gui_Elements::make_table(Support_Group::getAllUsersOfSupportGroup($result['target_id']), Array("getTUserId","getPermission","getExternId"), Array("tUserId","permission","externId")); + $i = 0; + foreach( $result['userlist'] as $user){ + $webuser = new Webusers($user['externId']); + $result['userlist'][$i]['name'] = $webuser->getUsername(); + $i++; + } + return $result; + + + }else{ + + //ERROR: No page specified! + $_SESSION['error_code'] = "404"; + header("Location: ams?page=error"); + 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/templates/sgroup_list.tpl b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/sgroup_list.tpl new file mode 100644 index 000000000..231250fda --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/sgroup_list.tpl @@ -0,0 +1,105 @@ +{block name=content} + +

List of all Support Groups

+ + + + + + + + + {if isset($isAdmin) && $isAdmin eq 'TRUE'}{/if} + + + + {foreach from=$grouplist item=group} + + + + + + {if isset($isAdmin) && $isAdmin eq 'TRUE'}{/if} + + {/foreach} + + +
IDNameTagEmailAction
{$group.sGroupId}{$group.name}{$group.tag}{$group.groupemail}Delete
+ + {if isset($isAdmin) && $isAdmin eq 'TRUE'} + +

Add a support group

+ +
+ + + + + + + + + + +
+ + + + + + +
+ + + + + + + + +
+
+ + + + + + +
+ + + + + + + + +
+
+ + +
+ + +
+ {if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "SUCCESS"} + +

{$group_success}

+
+ {else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "NAME_TAKEN"} + +

{$group_name_taken}

+
+ {else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "TAG_TAKEN"} + +

{$group_tag_taken}

+
+ {else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "SIZE_ERROR"} + +

{$group_size_error}

+
+ {/if} + + {/if} +{/block} + diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/show_sgroup.tpl b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/show_sgroup.tpl new file mode 100644 index 000000000..0f1d55d17 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/show_sgroup.tpl @@ -0,0 +1,118 @@ +{block name=content} + +

{$groupsname} Members List

+ + + + + + {if isset($isAdmin) && $isAdmin eq 'TRUE'}{/if} + + + + + {foreach from=$userlist item=user} + + + + {if isset($isAdmin) && $isAdmin eq 'TRUE'}{/if} + + {/foreach} + + +
IDNameAction
{$user.tUserId}{$user.name} Delete
+ + {if isset($isAdmin) && $isAdmin eq 'TRUE'} +

Add user to '{$groupsname}'

+ + + + +
+
+ + + + + +
+
+ + + + {if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "SUCCESS"} + +

{$add_to_group_success}

+
+ {else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "ALREADY_ADDED"} + +

{$user_already_added}

+
+ {else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "GROUP_NOT_EXISTING"} + +

{$group_not_existing}

+
+ {else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "USER_NOT_EXISTING"} + +

{$user_not_existing}

+
+ {else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "NOT_MOD_OR_ADMIN"} + +

{$not_mod_or_admin}

+
+ {/if} + + +

Modify Email Settings

+
+ + + + + + + + + + + + + +
+ + + + + +
+ + + + + +
+ + + +
+
+ + {if isset($RESULT_OF_MODIFYING) and $RESULT_OF_MODIFYING eq "SUCCESS"} + + {$modify_mail_of_group_success} + + {else if isset($RESULT_OF_MODIFYING) and $RESULT_OF_MODIFYING eq "EMAIL_NOT_VALID"} + + {$email_not_valid} + + {else if isset($RESULT_OF_MODIFYING) and $RESULT_OF_MODIFYING eq "NO_PASSWORD"} + + {$no_password_given} + + {/if} + + + {/if} + +{/block} + diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/todo.txt b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/todo.txt index 241f7c3f2..20bb8235b 100644 --- a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/todo.txt +++ b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/todo.txt @@ -1,3 +1,5 @@ -Remove full path in autoload functions -Make Permission www dependend, so it can be implemented in drupal with hook_permission(); --in helpers make_folders mkdir($value); should be drupal_mkdir(); \ No newline at end of file +-in helpers make_folders mkdir($value); should be drupal_mkdir(); +-write backwards compatible script for existing nel db! +-fix the callback in add_user_to_sgroup.php and show_sgroup.php in the func dir \ No newline at end of file