mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-23 07:36:16 +00:00
added support group functionality to the drupal module
--HG-- branch : quitta-gsoc-2013
This commit is contained in:
parent
46114b65b3
commit
f16711c9fa
8 changed files with 452 additions and 1 deletions
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
function add_sgroup(){
|
||||
|
||||
if(WebUsers::isLoggedIn()){
|
||||
|
||||
if( Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))){
|
||||
$name = filter_var($_POST['Name'],FILTER_SANITIZE_STRING);
|
||||
$inner_tag = filter_var($_POST['Tag'], FILTER_SANITIZE_STRING);
|
||||
$tag = "[" . $inner_tag . "]";
|
||||
$inner_tag = filter_var($_POST['Tag'], FILTER_SANITIZE_STRING);
|
||||
$groupemail = filter_var($_POST['GroupEmail'], FILTER_SANITIZE_STRING);
|
||||
$imap_mailserver = filter_var($_POST['IMAP_MailServer'], FILTER_SANITIZE_STRING);
|
||||
$imap_username = filter_var($_POST['IMAP_Username'], FILTER_SANITIZE_STRING);
|
||||
$imap_password = filter_var($_POST['IMAP_Password'], FILTER_SANITIZE_STRING);
|
||||
|
||||
$result['RESULT_OF_ADDING'] = Support_Group::createSupportGroup($name, $tag, $groupemail, $imap_mailserver, $imap_username, $imap_password);
|
||||
$result['permission'] = unserialize($_SESSION['ticket_user'])->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;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
function add_user_to_sgroup(){
|
||||
|
||||
if(WebUsers::isLoggedIn()){
|
||||
|
||||
if( Ticket_User::isAdmin(unserialize($_SESSION['ticket_user'])) && isset($_POST['target_id'])){
|
||||
$name = filter_var($_POST['Name'],FILTER_SANITIZE_STRING);
|
||||
$id = filter_var($_POST['target_id'],FILTER_SANITIZE_NUMBER_INT);
|
||||
$user_id = WebUsers::getId($name);
|
||||
if ($user_id != ""){
|
||||
if (Ticket_User::constr_ExternId($user_id)->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;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
function modify_email_of_sgroup(){
|
||||
|
||||
if(WebUsers::isLoggedIn()){
|
||||
|
||||
if( Ticket_User::isAdmin(unserialize($_SESSION['ticket_user'])) && isset($_POST['target_id'])){
|
||||
|
||||
$sgroupid = filter_var($_POST['target_id'],FILTER_SANITIZE_NUMBER_INT);
|
||||
$group = Support_Group::getGroup($sgroupid);
|
||||
$groupemail = filter_var($_POST['GroupEmail'],FILTER_SANITIZE_STRING);
|
||||
if(Users::validEmail($groupemail) || $groupemail == ""){
|
||||
$password = filter_var($_POST['IMAP_Password'],FILTER_SANITIZE_STRING);
|
||||
$group->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;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
function sgroup_list(){
|
||||
//if logged in
|
||||
if(WebUsers::isLoggedIn()){
|
||||
if(Ticket_User::isMod(unserialize($_SESSION['ticket_user']))){
|
||||
|
||||
if(isset($_GET['delete']) && Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))){
|
||||
$delete_id = filter_var($_GET['delete'], FILTER_SANITIZE_NUMBER_INT);
|
||||
$result['delete'] = Support_Group::deleteSupportGroup( $delete_id);
|
||||
header("Location: ams?page=sgroup_list");
|
||||
exit;
|
||||
}
|
||||
if(Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))){
|
||||
$result['isAdmin'] = "TRUE";
|
||||
}
|
||||
$result['grouplist'] = Gui_Elements::make_table(Support_Group::getGroups(), Array("getSGroupId","getName","getTag","getGroupEmail"), Array("sGroupId","name","tag","groupemail"));
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
function show_sgroup(){
|
||||
//if logged in
|
||||
if(WebUsers::isLoggedIn()){
|
||||
if(Ticket_User::isMod(unserialize($_SESSION['ticket_user']))){
|
||||
if( isset($_GET['id'])){
|
||||
//['target_id'] holds the id of the group!
|
||||
$result['target_id'] = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT);
|
||||
|
||||
if(isset($_GET['delete']) && Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))){
|
||||
$delete_id = filter_var($_GET['delete'], FILTER_SANITIZE_NUMBER_INT);
|
||||
$result['delete'] = Support_Group::deleteUserOfSupportGroup( $delete_id, $result['target_id'] );
|
||||
header("Location: ams?page=show_sgroup&id=" . $result['target_id']);
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
if(Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))){
|
||||
$result['isAdmin'] = "TRUE";
|
||||
}
|
||||
|
||||
$group = Support_Group::getGroup($result['target_id']);
|
||||
$result['groupsname'] = $group->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;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,105 @@
|
|||
{block name=content}
|
||||
|
||||
<h2>List of all Support Groups</h2>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Name</th>
|
||||
<th>Tag</th>
|
||||
<th>Email</th>
|
||||
{if isset($isAdmin) && $isAdmin eq 'TRUE'}<th>Action</th>{/if}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{foreach from=$grouplist item=group}
|
||||
<tr>
|
||||
<td>{$group.sGroupId}</td>
|
||||
<td><a href ="ams?page=show_sgroup&id={$group.sGroupId}">{$group.name}</a></td>
|
||||
<td class="center">{$group.tag}</td>
|
||||
<td class="center">{$group.groupemail}</td>
|
||||
{if isset($isAdmin) && $isAdmin eq 'TRUE'}<td class="center"><a href="ams?page=sgroup_list&delete={$group.sGroupId}"><font color="red">Delete</font></a></td>{/if}
|
||||
</tr>
|
||||
{/foreach}
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{if isset($isAdmin) && $isAdmin eq 'TRUE'}
|
||||
|
||||
<h2>Add a support group</h2>
|
||||
|
||||
<form id="addSGroup" class="form-vertical" method="post" action="ams?page=sgroup_list">
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<label>Group name</label>
|
||||
<input type="text" maxlength="20" id="Name" name="Name">
|
||||
</td>
|
||||
<td>
|
||||
<label>Group Tag</label>
|
||||
<input type="text" maxlength="4" id="Tag" name="Tag">
|
||||
</td>
|
||||
<td>
|
||||
<label>Group EmailAddress</label>
|
||||
<input type="text" id="GroupEmail" name="GroupEmail">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<label>IMAP MailServer IP</label>
|
||||
<input type="text" id="IMAP_MailServer" name="IMAP_MailServer">
|
||||
</td>
|
||||
<td>
|
||||
<label class="control-label">IMAP Username</label>
|
||||
<input type="text" id="IMAP_Username" name="IMAP_Username">
|
||||
</td>
|
||||
<td>
|
||||
<label class="control-label">IMAP Password</label>
|
||||
<input type="password" id="IMAP_Password" name="IMAP_Password">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="hidden" name="function" value="add_sgroup">
|
||||
<button type="submit" class="btn btn-primary" >Add</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
</form>
|
||||
{if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "SUCCESS"}
|
||||
<font color="green">
|
||||
<p>{$group_success}</p>
|
||||
</font>
|
||||
{else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "NAME_TAKEN"}
|
||||
<font color="red">
|
||||
<p>{$group_name_taken}</p>
|
||||
</font>
|
||||
{else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "TAG_TAKEN"}
|
||||
<font color="red">
|
||||
<p>{$group_tag_taken}</p>
|
||||
</font>
|
||||
{else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "SIZE_ERROR"}
|
||||
<font color="red">
|
||||
<p>{$group_size_error}</p>
|
||||
</font>
|
||||
{/if}
|
||||
|
||||
{/if}
|
||||
{/block}
|
||||
|
|
@ -0,0 +1,118 @@
|
|||
{block name=content}
|
||||
|
||||
<h2>{$groupsname} Members List</h2>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Name</th>
|
||||
{if isset($isAdmin) && $isAdmin eq 'TRUE'}<th>Action</th>{/if}
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{foreach from=$userlist item=user}
|
||||
<tr>
|
||||
<td>{$user.tUserId}</td>
|
||||
<td><a href ="ams?page=show_user&id={$user.tUserId}">{$user.name}</a></td>
|
||||
{if isset($isAdmin) && $isAdmin eq 'TRUE'}<td class="center"><a href="ams?page=show_sgroup&id={$target_id}&delete={$user.tUserId}"><font color="red"> Delete</font></a></td>{/if}
|
||||
</tr>
|
||||
{/foreach}
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{if isset($isAdmin) && $isAdmin eq 'TRUE'}
|
||||
<h2>Add user to '{$groupsname}'</h2>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<form id="addSGroup" class="form-vertical" method="post" action="ams?page=show_sgroup&id={$target_id}">
|
||||
<label>Username:</label>
|
||||
<input type="text" maxlength="15" id="Name" name="Name">
|
||||
<input type="hidden" name="function" value="add_user_to_sgroup">
|
||||
<input type="hidden" name="target_id" value="{$target_id}">
|
||||
<button type="submit" class="btn btn-primary" >Add</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
{if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "SUCCESS"}
|
||||
<font color="green">
|
||||
<p>{$add_to_group_success}</p>
|
||||
</font>
|
||||
{else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "ALREADY_ADDED"}
|
||||
<font color="red">
|
||||
<p>{$user_already_added}</p>
|
||||
</font>
|
||||
{else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "GROUP_NOT_EXISTING"}
|
||||
<font color="red">
|
||||
<p>{$group_not_existing}</p>
|
||||
</font>
|
||||
{else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "USER_NOT_EXISTING"}
|
||||
<font color="red">
|
||||
<p>{$user_not_existing}</p>
|
||||
</font>
|
||||
{else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "NOT_MOD_OR_ADMIN"}
|
||||
<font color="red">
|
||||
<p>{$not_mod_or_admin}</p>
|
||||
</font>
|
||||
{/if}
|
||||
|
||||
|
||||
<h2>Modify Email Settings</h2>
|
||||
<form id="modifyMailSGroup" class="form-vertical" method="post" action="ams?page=show_sgroup&id={$target_id}">
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<label>Group Email</label>
|
||||
<input type="text" id="GroupEmail" name="GroupEmail" value="{$groupemail}">
|
||||
</td>
|
||||
<td>
|
||||
<label>IMAP Mail Server</label>
|
||||
<input type="text" id="IMAP_MailServer" name="IMAP_MailServer" value="{$imap_mailserver}">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label>IMAP Username</label>
|
||||
<input type="text" id="IMAP_Username" name="IMAP_Username" value="{$imap_username}">
|
||||
</td>
|
||||
<td>
|
||||
<label>IMAP Password</label>
|
||||
<input type="password" id="IMAP_Password" name="IMAP_Password">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="hidden" name="function" value="modify_email_of_sgroup">
|
||||
<input type="hidden" name="target_id" value="{$target_id}">
|
||||
<button type="submit" class="btn btn-primary" >Update</button>
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
{if isset($RESULT_OF_MODIFYING) and $RESULT_OF_MODIFYING eq "SUCCESS"}
|
||||
<font color="green">
|
||||
{$modify_mail_of_group_success}
|
||||
</font>
|
||||
{else if isset($RESULT_OF_MODIFYING) and $RESULT_OF_MODIFYING eq "EMAIL_NOT_VALID"}
|
||||
<font color="red">
|
||||
{$email_not_valid}
|
||||
</font>
|
||||
{else if isset($RESULT_OF_MODIFYING) and $RESULT_OF_MODIFYING eq "NO_PASSWORD"}
|
||||
<font color="red">
|
||||
{$no_password_given}
|
||||
</font>
|
||||
{/if}
|
||||
|
||||
|
||||
{/if}
|
||||
|
||||
{/block}
|
||||
|
|
@ -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();
|
||||
-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
|
Loading…
Reference in a new issue