diff options
author | Preston Cody <codeman@gentoo.org> | 2006-06-11 03:26:48 +0000 |
---|---|---|
committer | Preston Cody <codeman@gentoo.org> | 2006-06-11 03:26:48 +0000 |
commit | 88e9716e411aa0195c43d83321cac1cb6f847c9d (patch) | |
tree | b5c8cddb50c1c1f9d0322be0ef7a7db793e347f6 /scire | |
parent | adding adodb path link, tho not used yet (diff) | |
download | scire-88e9716e411aa0195c43d83321cac1cb6f847c9d.tar.gz scire-88e9716e411aa0195c43d83321cac1cb6f847c9d.tar.bz2 scire-88e9716e411aa0195c43d83321cac1cb6f847c9d.zip |
adding initial users and clients pages.
these do not yet use dynamic fields
most of users is functional, clients is not
it is still in progress.
svn path=/; revision=96
Diffstat (limited to 'scire')
-rwxr-xr-x | scire/.smarty/templates/client.tpl | 213 | ||||
-rwxr-xr-x | scire/.smarty/templates/clients.tpl | 38 | ||||
-rw-r--r-- | scire/.smarty/templates/clients_groups.tpl | 74 | ||||
-rw-r--r-- | scire/.smarty/templates/header.tpl | 2 | ||||
-rw-r--r-- | scire/.smarty/templates/login.tpl | 51 | ||||
-rwxr-xr-x | scire/.smarty/templates/user.tpl | 209 | ||||
-rwxr-xr-x | scire/.smarty/templates/users.tpl | 30 | ||||
-rw-r--r-- | scire/.smarty/templates/users_groups.tpl | 74 | ||||
-rw-r--r-- | scire/.smarty/templates/users_permissions.tpl | 26 | ||||
-rwxr-xr-x | scire/client.php | 152 | ||||
-rwxr-xr-x | scire/clients.php | 117 | ||||
-rw-r--r-- | scire/images/sort_asc.png | bin | 0 -> 102 bytes | |||
-rw-r--r-- | scire/images/sort_desc.png | bin | 0 -> 98 bytes | |||
-rw-r--r-- | scire/s.gif | bin | 0 -> 51 bytes | |||
-rwxr-xr-x | scire/user.php | 151 | ||||
-rwxr-xr-x | scire/users.php | 111 |
16 files changed, 1233 insertions, 15 deletions
diff --git a/scire/.smarty/templates/client.tpl b/scire/.smarty/templates/client.tpl new file mode 100755 index 0000000..6fd0a82 --- /dev/null +++ b/scire/.smarty/templates/client.tpl @@ -0,0 +1,213 @@ +{include file="header.tpl" title="Clients"} +<form action="" method="post" name="edit_clientform"> +{if $Action eq "addgroup"} + <table width="100%" border="0" cellspacing="0" cellpadding="5"> + <tr><td class="boxtitle">Add client to group</td></tr> + <tr> + <td colspan="2" align="center" valign="top"> + <table class="box" width="100%" border="1" cellspacing="0" cellpadding="0"> + <tr> + <td class="boxtitle" width="15">Add</td><td class="boxtitle">Group Name</td> + </tr> + {foreach from=$groups name=ugroup item=item key=id} + <tr> + <td><input type="checkbox" name="addgroupid[]" value="{$id}" + {if isset($ingroups)} {if in_array($id, $ingroups)} checked {/if} {/if} + ></td> + <td>{$item}</td> + </tr> + {/foreach} + <tr><td> + <input type="hidden" name="clientid" value="{$clientid}"> + <input type="hidden" name="gacl_clientid" value="{$gacl_clientid}"> + <input type="submit" name="addgroup_confirm" value="Save Changes"> + </td></tr> + </table> + </td> + </tr> + </table> +{elseif $Action eq "create"} +<table width="100%" border="0" cellspacing="0" cellpadding="5"> + <tr> + <td colspan="2" align="center" valign="top"> + <table class="box" width="100%" border="1" cellspacing="0" cellpadding="0"> + <tr> + <td class="boxtitle">Client</td><td class="boxtitle">Groups</td> + </tr> + <tr> + <td> + <table border="0" cellspacing="0" cellpadding="5"> + <tr> + <td><label for="addhostname">*Hostname:</label></td> + <td><input type="text" id="addhostname" name="addhostname" /></td> + <td><label for="ip">*IP Address:</label></td> + <td><input type="text" id="ip" name="ip" /></td> + + </tr> + <tr> + <td><label for="assetid">Asset ID:</label></td> + <td><input type="text" id="assetid" name="assetid" /></td> + <td><label for="mac">MAC:</label></td> + <td><input type="text" id="mac" name="mac" /></td> + + </tr> + <tr> + <td><label for="digest">Digest (DO NOT EDIT):</label></td> + <td colspan="3"><input type="text" id="digest" name="digest" size="55"></td> + </tr> + <tr> + <td><label for="gli_profile">GLI Profile:</lablel></td> + <td><input type="text" name="gli_profile" id="gli_profile"></td> + <td><label for="status">Status:</label></td> + <td><select id="status" name="status" size="1"> + <option value="active" selected="selected">Active</option> + <option value="disabled">Disabled</option> + </select> + </td> + </tr> + <tr> + <td><label for="os">OS:</label></td> + <td><input type="text" id="email" name="email" /></td> + <td><label for="contact">Contact:</label></td> + <td><input type="text" id="contact" name="contact" /></td> + </tr> + <tr> + <td><label for="install_time">Install Time <br>(leave blank for NOW):</label></td> + <td colspan="3"><input type="text" id="install_time" name="install_time" size="25"/></td> + </tr> + </table> + <p><input type="submit" name="AddClientSubmit" value="Add Client" /></p> + </td> + <td> + <table> + <tr><td>Assign client to the following groups:</td></tr> + <tr><td> + <select name="groups[]" size="10" multiple="multiple" id="groups"> + {foreach from=$groups item=ugroup key=id} + <option value="{$id}">{$ugroup}</option> + {/foreach} + </select> + </td> + </tr></table> + </td> + </tr> + </table> + </td> + </tr> +{elseif $Action eq "edit"} +<h1>EDITING</h1> + <table width="100%" border="0" cellspacing="0" cellpadding="5"> + <tr> + <td colspan="2" align="center" valign="top"> + <table class="box" width="100%" border="1" cellspacing="0" cellpadding="0"> + <tr> + <td class="boxtitle">Client</td> + </tr> + <tr> + <td> + <table border="0" cellspacing="0" cellpadding="5"> + <tr> + <td><label for="edithostname">*Hostname:</label></td> + <td><input type="text" id="edithostname" name="edithostname" value="{$client.hostname}" disabled /></td> + <td><label for="passwd">*Password:</label></td> + <td><input type="password" id="passwd" name="passwd" disabled /></td> + </tr> + <tr> + <td><label for="real_name">Real name:</label></td> + <td><input type="text" id="real_name" name="real_name" value="{$client.real_name}" /></td> + <td><label for="passwd2">Confirm Password:</label></td> + <td><input type="password" id="passwd2" name="passwd2" disabled /></td> + </tr> + <tr> + <td><label for="comment">Comment:</label></td> + <td><input type="text" id="comment" name="comment" value="{$client.comment}" /></td> + <td><label for="status">Status:</label></td> + <td> + <select id="status" name="status" size="1"> + <option value="active" selected="selected">Active</option> + <option value="disabled">Disabled</option> + </select> + </td> + </tr> + <tr> + <td><label for="email">*Email Address:</label></td> + <td><input type="text" id="email" name="email" value="{$client.email}" /></td> + <td><label for="phone">Phone:</label></td> + <td><input type="text" id="phone" name="phone" value="{$client.phone}" /></td> + </tr> + <tr> + <td><label for="pager">Pager:</label></td> + <td><input type="text" id="pager" name="pager" value="{$client.pager}" /></td> + </tr> + </table><input type="hidden" name="clientid" value="{$client.clientid}"> + <input type="hidden" name="gacl_clientid" value="{$gacl_clientid}"> + <p><input type="submit" name="EditClientSubmit" value="Update" /></p> + </td> + </tr> + </table> + </td> + </tr> + <tr> + <td align="center" valign="top"> + <table class="box" width="100%" border="1" cellspacing="0" cellpadding="0"> + <tr> + <td class="boxtitle">Groups</td> + </tr> + <tr> + <td> + <table class="table" width="100%" border="1" cellspacing="0" cellpadding="0"> + <tr> + <th>Groupname</th> + <th>Actions</th> + </tr> + {section name=group loop=$groups} + <tr> + <td>{$groups[group].name}{if $groups[group].parent} (subgroup of {$groups[group].parent}){/if}</td> + <td><input type="submit" name="rmug_{$groups[group].id}" value="Remove"></td> + </tr> + {/section} + <tr><td><a href="client.php?clientid={$client.clientid}&gacl_clientid={$gacl_clientid}&Action=addgroup">Add client to a group</a></td></tr> + </table> + </td> + </tr> + </table> + </td> + <td align="center" valign="top"> + <table class="box" width="100%" border="1" cellspacing="0" cellpadding="0"> + <tr> + <td class="boxtitle">Permissions</td> + </tr> + <tr> + <td> + <table class="table" width="100%" border="1" cellspacing="0" cellpadding="0"> + <tr> + <th>Permission</th> + <th>On</th> + <th>Actions</th> + </tr> + <tr> + <td>Install packages</td> + <td>@frontend, workstation12</td> + <td><form id="form1" name="form1" method="post" action=""><input type="hidden" name="id" value="1" /><input type="submit" name="submit" value="Remove" /></form></td> + </tr> + <tr> + <td>Update packages</td> + <td>@db, @frontend, workstation12</td> + <td><form id="form2" name="form2" method="post" action=""><input type="hidden" name="id" value="2" /><input type="submit" name="submit" value="Remove" /></form></td> + </tr> + </table> + </td> + </tr> + </table> + </td> + </tr> +</table> +{elseif $Action eq "delete"} +<h1>DELETING</h1> +<b>Are you absolutely SURE you want to delete client {$client.hostname}?</b> +<input type="hidden" name="clientid" value="{$client.clientid}"> +<input type="hidden" name="gacl_clientid" value="{$gacl_clientid}"> +<input type="submit" name="delete_confirm" value="Yes, get rid of the bastard!"><input type="submit" name="delete_cancel" value="No wait!"> +{/if} +</form> +{include file="footer.tpl"} diff --git a/scire/.smarty/templates/clients.tpl b/scire/.smarty/templates/clients.tpl new file mode 100755 index 0000000..078feb2 --- /dev/null +++ b/scire/.smarty/templates/clients.tpl @@ -0,0 +1,38 @@ +{include file="header.tpl" title="Clients"} +<form action="" method="post" name="clientsform"> +<p><strong>Search filter: + <input type="text" name="searchfield"> +</strong></p> +{if $clients} + <table class="box" width="100%" border="1" cellpadding="0" cellspacing="0"> + <tr><td class="boxtitle">Clients</td></tr> + <tr><td> + + <table class="table" width="100%" border="1" cellspacing="0" cellpadding="0"> + <tr> + <th><a href="clients.php?sortby=hostname&sort={if $sort_hostname eq "desc"}asc{else}desc{/if}">Hostname</a> <img src="images/sort_{if $sort_hostname eq "desc"}desc{else}asc{/if}.png"></th> + <th><a href="clients.php?sortby=ip&sort={if $sort_ip eq "desc"}asc{else}desc{/if}">IP Address</a> <img src="images/sort_{if $sort_ip eq "desc"}desc{else}asc{/if}.png"></th> + <th><a href="clients.php?sortby=profile_name&sort={if $sort_profile_name eq "desc"}asc{else}desc{/if}">GLI Profile</a> <img src="images/sort_{if $sort_profile_name eq "desc"}desc{else}asc{/if}.png"></th> + <th><a href="clients.php?sortby=osname&sort={if $sort_osname eq "desc"}asc{else}desc{/if}">OS Name</a> <img src="images/sort_{if $sort_osname eq "desc"}desc{else}asc{/if}.png"></th> + <th><a href="clients.php?sortby=username&sort={if $sort_username eq "desc"}asc{else}desc{/if}">Contact</a> <img src="images/sort_{if $sort_username eq "desc"}desc{else}asc{/if}.png"></th> + <th><a href="clients.php?sortby=installtime&sort={if $sort_installtime eq "desc"}asc{else}desc{/if}">Install Time</a> <img src="images/sort_{if $sort_installtime eq "desc"}desc{else}asc{/if}.png"></th> + <th><a href="clients.php?sortby=status&sort={if $sort_status eq "desc"}asc{else}desc{/if}">Status</a> <img src="images/sort_{if $sort_status eq "desc"}desc{else}asc{/if}.png"></th><th>Actions</th> + </tr> + {section name=clients loop=$clients} + <tr> + <td><a href="client.php?clientid={$clients[clients].clientid}&Action=edit">{$clients[clients].hostname}</a></td> + <td>{$clients[clients].ip}</td> + <td>{$clients[clients].profile_name}</td> + <td>{$clients[clients].osname}</td> + <td>{$clients[clients].username}</td> + <td>{$clients[clients].installtime}</td> + <td>{$clients[clients].status}</td> + <td><a href="client.php?clientid={$clients[clients].clientid}&Action=edit">Edit</a> <a href="client.php?clientid={$clients[clients].clientid}&Action=delete">Delete</a></td> + </tr> + {/section} + + </td></tr> + </table> +{/if} +</form> +{include file="footer.tpl"} diff --git a/scire/.smarty/templates/clients_groups.tpl b/scire/.smarty/templates/clients_groups.tpl new file mode 100644 index 0000000..bb9c776 --- /dev/null +++ b/scire/.smarty/templates/clients_groups.tpl @@ -0,0 +1,74 @@ +{include file="header.tpl" title="Clients"} +<form action="" method="post" name="clientsgroupsform"> +{if $Action eq "create"} + <table class="box" width="100%" border="1" cellpadding="0" cellspacing="0"> + <tr><td class="boxtitle">Create a Client Group</td></tr> + <tr><td> + + <table class="table" width="100%" border="1" cellspacing="0" cellpadding="0"> + <tr> + <td class="boxtitle">Add Client Group</td><td class="boxtitle">Parent Group</td> + </tr> + <tr> + <td> + <label for="addgroupname">Name:</label> + <input type="text" name="addgroupname" id="addgroupname"> + </td> + <td> + <select name="parentgroup" id="parentgroup"> + {foreach item=cgroup key=ckey from=$groups} + <option value="{$ckey}">{$cgroup}</option> + {/foreach} + </select> + </td> + </tr> + <tr><td>as a subgroup of ---></td></tr> + <tr><td></td><td><input type="submit" name="addgroup" value="Add Client Group"></td></tr> + </table> + </table> + {elseif $Action eq "edit"} + <input type="hidden" name="groupid" value="{$groupid}"> + <table class="box" width="100%" border="1" cellpadding="0" cellspacing="0"> + <tr><td class="boxtitle">Edit Client Group {$groupdata[3]}</td></tr> + <tr><td> + + <table class="table" width="100%" border="1" cellspacing="0" cellpadding="0"> + <tr> + <td class="boxtitle">Edit Client Group</td><td class="boxtitle">Parent Group</td> + </tr> + <tr> + <td> + <label for="editgroupname">Name:</label> + <input type="text" name="editgroupname" id="editgroupname" value="{$groupdata[3]}"> + </td> + <td> + <select name="parentgroup" id="parentgroup"> + {foreach item=cgroup key=ckey from=$groups} + <option value="{$ckey}" {if $groupdata[1] == $ckey} selected {/if}>{$cgroup}</option> + {/foreach} + </select> + </td> + </tr> + <tr><td>as a subgroup of ---></td></tr> + <tr><td></td><td><input type="submit" name="editgroup" value="Save Changes"></td></tr> + </table> + </table> + {elseif $Action eq "delete"} + <h1>Delete</h1> + <b>Are you absolutely SURE you want to delete this group?</b> + <input type="hidden" name="delgroup" value="{$groupid}"> +<input type="submit" name="delgroup_confirm" value="Yes, remove the group"><input type="submit" name="delete_cancel" value="No wait! Cancel!"> + {else} + <table class="box" width="100%" border="1" cellpadding="0" cellspacing="0"> + <tr><td class="boxtitle">Client Groups</td></tr> + <tr><td> + + <table class="table" width="100%" border="1" cellspacing="0" cellpadding="0"> + <tr><td class="boxtitle">Group Name</td><td class="boxtitle">Edit</td><td class="boxtitle">Delete</td></tr> + {foreach item=group key=key from=$groups} + <tr><td>{$group}</td><td><a href="clients.php?View=groups&Action=edit&groupid={$key}">Edit</a></td><td><a href="clients.php?View=groups&Action=delete&groupid={$key}">Delete</a></td></tr> + {/foreach} + {/if} <!-- action --> + +</form> +{include file="footer.tpl"} diff --git a/scire/.smarty/templates/header.tpl b/scire/.smarty/templates/header.tpl index 5383973..def5c61 100644 --- a/scire/.smarty/templates/header.tpl +++ b/scire/.smarty/templates/header.tpl @@ -201,7 +201,7 @@ {if $desc ne ""} <h2>{$desc}</h2>{/if} </td> <td align="right" valign="top"> -{if isset($status)} <p>OK</p>{/if} +{if isset($status)} <p>{$status}</p>{/if} </td> </tr> </table> diff --git a/scire/.smarty/templates/login.tpl b/scire/.smarty/templates/login.tpl index 523cfff..b726587 100644 --- a/scire/.smarty/templates/login.tpl +++ b/scire/.smarty/templates/login.tpl @@ -1,16 +1,39 @@ {include file="header.tpl" title="Login"} -<b>Please Login to use Scire:</b> -<form id="form1" name="form1" method="post" action=""> - <label>Username - <input name="username" type="text" id="username" /> - </label> - <p> - <label>Password - <input name="passwd" type="password" id="passwd" /> - </label> - </p> - <p> - <input name="submit" type="Submit" label="Submit"> - </p> -</form> + +<div style="display: table; width: 100%; height: 100%; _position: relative; overflow: hidden;"> +<div style="_position: absolute; _top: 50%; display: table-cell; vertical-align: middle;"> +<div style="_position: relative; _top: -50%;"> +<table class="box" align="center" border="1" cellspacing="0" cellpadding="0"> + <tr> + <td class="boxtitle">Please Login to use Scire</td> + </tr> + <tr> + <td> + <form id="login" name="login" method="post" action=""> + <table border="0" cellspacing="5" cellpadding="5"> + <tr> + + <td><label for="username">Username:</label></td> + <td><input type="text" id="username" name="username" value="" /></td> + </tr> + <tr> + <td><label for="passwd">Password:</label></td> + <td><input type="passwd" id="passwd" name="passwd" /></td> + </tr> + <tr> + + <td colspan="2" align="center"> + <input type="submit" name="submit" value="Login" /> + </td> + </tr> + </table> + </form> + </td> + </tr> + </table> + +</div> +</div> +</div> + {include file="footer.tpl"} diff --git a/scire/.smarty/templates/user.tpl b/scire/.smarty/templates/user.tpl new file mode 100755 index 0000000..a5ce608 --- /dev/null +++ b/scire/.smarty/templates/user.tpl @@ -0,0 +1,209 @@ +{include file="header.tpl" title="Users"} +<form action="" method="post" name="edit_userform"> +{if $Action eq "addgroup"} + <table width="100%" border="0" cellspacing="0" cellpadding="5"> + <tr><td class="boxtitle">Add user to group</td></tr> + <tr> + <td colspan="2" align="center" valign="top"> + <table class="box" width="100%" border="1" cellspacing="0" cellpadding="0"> + <tr> + <td class="boxtitle" width="15">Add</td><td class="boxtitle">Group Name</td> + </tr> + {foreach from=$groups name=ugroup item=item key=id} + <tr> + <td><input type="checkbox" name="addgroupid[]" value="{$id}" + {if isset($ingroups)} {if in_array($id, $ingroups)} checked {/if} {/if} + ></td> + <td>{$item}</td> + </tr> + {/foreach} + <tr><td> + <input type="hidden" name="userid" value="{$userid}"> + <input type="hidden" name="gacl_userid" value="{$gacl_userid}"> + <input type="submit" name="addgroup_confirm" value="Save Changes"> + </td></tr> + </table> + </td> + </tr> + </table> +{elseif $Action eq "create"} +<table width="100%" border="0" cellspacing="0" cellpadding="5"> + <tr> + <td colspan="2" align="center" valign="top"> + <table class="box" width="100%" border="1" cellspacing="0" cellpadding="0"> + <tr> + <td class="boxtitle">User</td><td class="boxtitle">Groups</td> + </tr> + <tr> + <td> + <table border="0" cellspacing="0" cellpadding="5"> + <tr> + <td><label for="addusername">*Username:</label></td> + <td><input type="text" id="addusername" name="addusername" /></td> + <td><label for="passwd">*Password:</label></td> + <td><input type="password" id="passwd" name="passwd" /></td> + + </tr> + <tr> + <td><label for="real_name">Real name:</label></td> + <td><input type="text" id="real_name" name="real_name" /></td> + <td><label for="passwd2">Confirm Password:</label></td> + <td><input type="password" id="passwd2" name="passwd2" /></td> + + </tr> + <tr> + <td><label for="comment">Comment:</label></td> + <td><input type="text" id="comment" name="comment" /></td> + <td><label for="status">Status:</label></td> + <td><select id="status" name="status" size="1"> + <option value="active" selected="selected">Active</option> + <option value="disabled">Disabled</option> + </select> + </td> + </tr> + <tr> + <td><label for="email">*Email Address:</label></td> + <td><input type="text" id="email" name="email" /></td> + <td><label for="phone">Phone:</label></td> + <td><input type="text" id="phone" name="phone" /></td> + </tr> + <tr> + <td><label for="pager">Pager:</label></td> + <td><input type="text" id="pager" name="pager" /></td> + </tr> + </table> + <p><input type="submit" name="AddUserSubmit" value="Add User" /></p> + </td> + <td> + <table> + <tr><td>Assign user to the following groups:</td></tr> + <tr><td> + <select name="groups[]" size="10" multiple="multiple" id="groups"> + {foreach from=$groups item=ugroup key=id} + <option value="{$id}">{$ugroup}</option> + {/foreach} + </select> + </td> + </tr></table> + </td> + </tr> + </table> + </td> + </tr> +{elseif $Action eq "edit"} +<h1>EDITING</h1> + <table width="100%" border="0" cellspacing="0" cellpadding="5"> + <tr> + <td colspan="2" align="center" valign="top"> + <table class="box" width="100%" border="1" cellspacing="0" cellpadding="0"> + <tr> + <td class="boxtitle">User</td> + </tr> + <tr> + <td> + <table border="0" cellspacing="0" cellpadding="5"> + <tr> + <td><label for="editusername">*Username:</label></td> + <td><input type="text" id="editusername" name="editusername" value="{$user.username}" disabled /></td> + <td><label for="passwd">*Password:</label></td> + <td><input type="password" id="passwd" name="passwd" disabled /></td> + </tr> + <tr> + <td><label for="real_name">Real name:</label></td> + <td><input type="text" id="real_name" name="real_name" value="{$user.real_name}" /></td> + <td><label for="passwd2">Confirm Password:</label></td> + <td><input type="password" id="passwd2" name="passwd2" disabled /></td> + </tr> + <tr> + <td><label for="comment">Comment:</label></td> + <td><input type="text" id="comment" name="comment" value="{$user.comment}" /></td> + <td><label for="status">Status:</label></td> + <td> + <select id="status" name="status" size="1"> + <option value="active" selected="selected">Active</option> + <option value="disabled">Disabled</option> + </select> + </td> + </tr> + <tr> + <td><label for="email">*Email Address:</label></td> + <td><input type="text" id="email" name="email" value="{$user.email}" /></td> + <td><label for="phone">Phone:</label></td> + <td><input type="text" id="phone" name="phone" value="{$user.phone}" /></td> + </tr> + <tr> + <td><label for="pager">Pager:</label></td> + <td><input type="text" id="pager" name="pager" value="{$user.pager}" /></td> + </tr> + </table><input type="hidden" name="userid" value="{$user.userid}"> + <input type="hidden" name="gacl_userid" value="{$gacl_userid}"> + <p><input type="submit" name="EditUserSubmit" value="Update" /></p> + </td> + </tr> + </table> + </td> + </tr> + <tr> + <td align="center" valign="top"> + <table class="box" width="100%" border="1" cellspacing="0" cellpadding="0"> + <tr> + <td class="boxtitle">Groups</td> + </tr> + <tr> + <td> + <table class="table" width="100%" border="1" cellspacing="0" cellpadding="0"> + <tr> + <th>Groupname</th> + <th>Actions</th> + </tr> + {section name=group loop=$groups} + <tr> + <td>{$groups[group].name}{if $groups[group].parent} (subgroup of {$groups[group].parent}){/if}</td> + <td><input type="submit" name="rmug_{$groups[group].id}" value="Remove"></td> + </tr> + {/section} + <tr><td><a href="user.php?userid={$user.userid}&gacl_userid={$gacl_userid}&Action=addgroup">Add user to a group</a></td></tr> + </table> + </td> + </tr> + </table> + </td> + <td align="center" valign="top"> + <table class="box" width="100%" border="1" cellspacing="0" cellpadding="0"> + <tr> + <td class="boxtitle">Permissions</td> + </tr> + <tr> + <td> + <table class="table" width="100%" border="1" cellspacing="0" cellpadding="0"> + <tr> + <th>Permission</th> + <th>On</th> + <th>Actions</th> + </tr> + <tr> + <td>Install packages</td> + <td>@frontend, workstation12</td> + <td><form id="form1" name="form1" method="post" action=""><input type="hidden" name="id" value="1" /><input type="submit" name="submit" value="Remove" /></form></td> + </tr> + <tr> + <td>Update packages</td> + <td>@db, @frontend, workstation12</td> + <td><form id="form2" name="form2" method="post" action=""><input type="hidden" name="id" value="2" /><input type="submit" name="submit" value="Remove" /></form></td> + </tr> + </table> + </td> + </tr> + </table> + </td> + </tr> +</table> +{elseif $Action eq "delete"} +<h1>DELETING</h1> +<b>Are you absolutely SURE you want to delete user {$user.username}?</b> +<input type="hidden" name="userid" value="{$user.userid}"> +<input type="hidden" name="gacl_userid" value="{$gacl_userid}"> +<input type="submit" name="delete_confirm" value="Yes, get rid of the bastard!"><input type="submit" name="delete_cancel" value="No wait!"> +{/if} +</form> +{include file="footer.tpl"} diff --git a/scire/.smarty/templates/users.tpl b/scire/.smarty/templates/users.tpl new file mode 100755 index 0000000..97bb7a7 --- /dev/null +++ b/scire/.smarty/templates/users.tpl @@ -0,0 +1,30 @@ +{include file="header.tpl" title="Users"} +<form action="" method="post" name="usersform"> +<p><strong>Search filter: + <input type="text" name="searchfield"> +</strong></p> +{if $users} + <table class="box" width="100%" border="1" cellpadding="0" cellspacing="0"> + <tr><td class="boxtitle">Users</td></tr> + <tr><td> + + <table class="table" width="100%" border="1" cellspacing="0" cellpadding="0"> + <tr> + <th><a href="users.php?sortby=username&sort={if $sort_username eq "desc"}asc{else}desc{/if}">Username</a> <img src="images/sort_{if $sort_username eq "desc"}desc{else}asc{/if}.png"></th><th><a href="users.php?sortby=real_name&sort={if $sort_real_name eq "desc"}asc{else}desc{/if}">Real Name</a> <img src="images/sort_{if $sort_real_name eq "desc"}desc{else}asc{/if}.png"></th><th><a href="users.php?sortby=comment">Comment</a></th><th>Groups</th><th><a href="users.php?sortby=status&sort={if $sort_status eq "desc"}asc{else}desc{/if}">Status</a> <img src="images/sort_{if $sort_status eq "desc"}desc{else}asc{/if}.png"></th><th>Actions</th> + </tr> + {section name=users loop=$users} + <tr> + <td><a href="user.php?userid={$users[users].userid}&Action=edit">{$users[users].username}</a></td> + <td>{$users[users].real_name}</td> + <td>{$users[users].comment}</td> + <td>{$users[users].groups}</td> + <td></td> + <td><a href="user.php?userid={$users[users].userid}&Action=edit">Edit</a> <a href="user.php?userid={$users[users].userid}&Action=delete">Delete</a></td> + </tr> + {/section} + + </td></tr> + </table> +{/if} +</form> +{include file="footer.tpl"} diff --git a/scire/.smarty/templates/users_groups.tpl b/scire/.smarty/templates/users_groups.tpl new file mode 100644 index 0000000..f838ffc --- /dev/null +++ b/scire/.smarty/templates/users_groups.tpl @@ -0,0 +1,74 @@ +{include file="header.tpl" title="Users"} +<form action="" method="post" name="usersgroupsform"> +{if $Action eq "create"} + <table class="box" width="100%" border="1" cellpadding="0" cellspacing="0"> + <tr><td class="boxtitle">Create a User Group</td></tr> + <tr><td> + + <table class="table" width="100%" border="1" cellspacing="0" cellpadding="0"> + <tr> + <td class="boxtitle">Add User Group</td><td class="boxtitle">Parent Group</td> + </tr> + <tr> + <td> + <label for="addgroupname">Name:</label> + <input type="text" name="addgroupname" id="addgroupname"> + </td> + <td> + <select name="parentgroup" id="parentgroup"> + {foreach item=cgroup key=ckey from=$groups} + <option value="{$ckey}">{$cgroup}</option> + {/foreach} + </select> + </td> + </tr> + <tr><td>as a subgroup of ---></td></tr> + <tr><td></td><td><input type="submit" name="addgroup" value="Add User Group"></td></tr> + </table> + </table> + {elseif $Action eq "edit"} + <input type="hidden" name="groupid" value="{$groupid}"> + <table class="box" width="100%" border="1" cellpadding="0" cellspacing="0"> + <tr><td class="boxtitle">Edit User Group {$groupdata[3]}</td></tr> + <tr><td> + + <table class="table" width="100%" border="1" cellspacing="0" cellpadding="0"> + <tr> + <td class="boxtitle">Edit User Group</td><td class="boxtitle">Parent Group</td> + </tr> + <tr> + <td> + <label for="editgroupname">Name:</label> + <input type="text" name="editgroupname" id="editgroupname" value="{$groupdata[3]}"> + </td> + <td> + <select name="parentgroup" id="parentgroup"> + {foreach item=cgroup key=ckey from=$groups} + <option value="{$ckey}" {if $groupdata[1] == $ckey} selected {/if}>{$cgroup}</option> + {/foreach} + </select> + </td> + </tr> + <tr><td>as a subgroup of ---></td></tr> + <tr><td></td><td><input type="submit" name="editgroup" value="Save Changes"></td></tr> + </table> + </table> + {elseif $Action eq "delete"} + <h1>Delete</h1> + <b>Are you absolutely SURE you want to delete this group?</b> + <input type="hidden" name="delgroup" value="{$groupid}"> +<input type="submit" name="delgroup_confirm" value="Yes, remove the group"><input type="submit" name="delete_cancel" value="No wait! Cancel!"> + {else} + <table class="box" width="100%" border="1" cellpadding="0" cellspacing="0"> + <tr><td class="boxtitle">User Groups</td></tr> + <tr><td> + + <table class="table" width="100%" border="1" cellspacing="0" cellpadding="0"> + <tr><td class="boxtitle">Group Name</td><td class="boxtitle">Edit</td><td class="boxtitle">Delete</td></tr> + {foreach item=group key=key from=$groups} + <tr><td>{$group}</td><td><a href="users.php?View=groups&Action=edit&groupid={$key}">Edit</a></td><td><a href="users.php?View=groups&Action=delete&groupid={$key}">Delete</a></td></tr> + {/foreach} + {/if} <!-- action --> + +</form> +{include file="footer.tpl"} diff --git a/scire/.smarty/templates/users_permissions.tpl b/scire/.smarty/templates/users_permissions.tpl new file mode 100644 index 0000000..8b3219f --- /dev/null +++ b/scire/.smarty/templates/users_permissions.tpl @@ -0,0 +1,26 @@ +{include file="header.tpl" title="Users"} +<form action="" method="post" name="userspermsform"> +{if $Action eq "create"} + <table class="box" width="100%" border="1" cellpadding="0" cellspacing="0"> + <tr><td class="boxtitle">Create a Permission</td></tr> + <tr><td> + + <table class="table" width="100%" border="1" cellspacing="0" cellpadding="0"> + <tr><td class="boxtitle">Add Permission</td></tr> + <tr> + <td> + <label for="permname">Name:</label> + <input name="permname" type="text" id="permname"> + </td> + </tr> + <tr> + <td> + <label for="permdesc">Description:</label> + <input name="permdesc" type="text" id="permdesc"> + </td> + </tr> +{elseif $Action eq "edit"} +{elseif $Action eq "delete"} + +{else} <!-- default to Show --> +{/if} diff --git a/scire/client.php b/scire/client.php new file mode 100755 index 0000000..7e34247 --- /dev/null +++ b/scire/client.php @@ -0,0 +1,152 @@ +<?php +include('.lib/common.php'); + +$smarty->assign('leftbar', "on"); +$leftbar_menu = array(); + +add_leftbar($leftbar_menu, "««Cancel", "clients.php"); + + +$clientid = ""; + +##################################################### +#Deal with submitted forms. + +############################################### +#Adding a client to clientgroups. +if ($_POST['addgroup_confirm']) { + $ingroups = $acl->get_object_groups($_POST['gacl_clientid'],'AXO'); + $clientdata = $acl->get_object_data($_POST['gacl_clientid'], 'AXO'); + $newgroups = $_POST['addgroupid']; + #remove first. + foreach ($ingroups as $ingroup) { + if (!in_array($ingroup, $newgroups)) { + $acl->del_group_object($ingroup, $clientdata[0][0], $clientdata[0][1], 'AXO'); + } + } + foreach ($newgroups as $newgroup) { + print "newgroup: $newgroup"; + $acl->add_group_object($newgroup, $clientdata[0][0], $clientdata[0][1], 'AXO'); + } + $_GET['Action'] = "edit"; + $_GET['clientid'] = $_POST['clientid']; +} + +############################################### +# Adding a client. +if ($_POST['addhostname']) { + if ($_POST['passwd'] == $_POST['passwd2']) { + if ($_POST['addhostname'] and $_POST['passwd'] and $_POST['email']) { + $status = scire_add_client($_POST['addhostname'], $_POST['passwd'], $_POST['real_name'], $_POST['comment'], $_POST['email'], $_POST['phone'], $_POST['pager']); + if ($status == 1) { $status = "Client Addition successfull"; } + $obj_id = $acl->add_object("clients", $_POST['addhostname'], $_POST['addhostname'], 1, 0, 'AXO'); + #print "Object id: $obj_id <BR>"; + if ($_POST['groups']) { + #print "Adding client to groups ".$_POST['groups']; + foreach( $_POST['groups'] as $group) { + $worked = $acl->add_group_object($group, "clients", $_POST['addhostname'], 'AXO'); + #if ($worked) { + # print "Group $group Addition successfull.<br>"; + #} else { + # print "ERROR adding group $group <br>"; + #} + } + } + } else { + $status = "Error required fields are not filled!"; + } + } else { + $status = "Error passwords do not match!"; + } + header('Location: ' . $baseurl . 'clients.php'); +} +############################################### +# Editing a client's information. +if ($_POST['edithostname']) { + $clientinfo = get_scire_client($_GET['clientid']); + $smarty->assign('client', $clientinfo); + + if ($_POST['real_name'] and ($_POST['real_name'] != $clientinfo['real_name'])) { + $fields['real_name'] = $_POST['real_name']; + } + if ($_POST['comment'] and ($_POST['comment'] != $clientinfo['comment'])){ + $fields['comment'] = $_POST['comment']; + } + if ($_POST['email'] and ($_POST['email'] != $clientinfo['email'])) { + $fields['email'] = $_POST['email']; + } + if ($_POST['phone'] and ($_POST['phone'] != $clientinfo['phone'])) { + $fields['phone'] = $_POST['phone']; + } + if ($_POST['pager'] and ($_POST['pager'] != $clientinfo['pager'])) { + $fields['pager'] = $_POST['pager']; + } + $status = scire_edit_client($_POST['clientid'], $fields); + $_GET['Action'] = "edit"; + $_GET['clientid'] = $_POST['clientid']; +} + +############################################### +# Delete a client. +if ($_POST['delete_confirm']) { + $status = scire_del_client($_POST['clientid']); + $id = $acl->get_object_id("clients", $_POST['gacl_clientid'], 'AXO'); + $acl->del_object($id, 'AXO', TRUE); #True means erase referencing objects. + header('Location: ' . $baseurl . 'clients.php'); +} + +switch($_GET['Action']) { + case "addgroup": + $smarty->assign('desc', "Add a client to a client group."); + $smarty->assign('clientid', $_GET['clientid']); + $smarty->assign('groups', $acl->format_groups($acl->sort_groups('AXO'), TEXT)); + $smarty->assign('gacl_clientid', $_GET['gacl_clientid']); + $ingroups = array(); + $ingroups = $acl->get_object_groups($_GET['gacl_clientid'],'AXO'); + var_dump($ingroups); + $smarty->assign('ingroups', $ingroups); + case "create": + $smarty->assign('desc', "Add a client."); + $smarty->assign('groups', $acl->format_groups($acl->sort_groups('AXO'), TEXT)); + break; + case "edit": + #make the topbar look good + $smarty->assign('desc', "Edit client information."); + $clientinfo = get_scire_client($_GET['clientid']); + $smarty->assign('client', $clientinfo); + + $clientgroups = array(); + $id = $acl->get_object_id("clients",$clientinfo['hostname'],'AXO'); + $smarty->assign('gacl_clientid', $id); + $groups = $acl->get_object_groups($id,'AXO'); + if ($groups) { + foreach ($groups as $group) { + $group_data = $acl->get_group_data($group, 'AXO'); + $clientgroups_entry['name'] = $group_data[3]; + $clientgroups_entry['id'] = $group_data[0]; + if ($group_data[1]) { + $parent_group_data = $acl->get_group_data($group_data[1],'AXO'); + $clientgroups_entry['parent'] = $parent_group_data[3]; + } else { + $clientgroups_entry['parent'] = ""; + } + array_push($clientgroups, $clientgroups_entry); + } + } + $smarty->assign('groups', $clientgroups); + break; + case "delete": + $clientinfo = get_scire_client($_GET['clientid']); + $smarty->assign('client', $clientinfo); + $id = $acl->get_object_id("clients",$clientinfo['hostname'],'AXO'); + $smarty->assign('gacl_clientid', $id); + break; +} + + +$smarty->assign('leftbar_menu', $leftbar_menu); +$smarty->assign('Action', $_GET['Action']); +$smarty->assign('status', $status); +$smarty->display('client.tpl'); +var_dump($_POST); +?> diff --git a/scire/clients.php b/scire/clients.php new file mode 100755 index 0000000..ea36899 --- /dev/null +++ b/scire/clients.php @@ -0,0 +1,117 @@ +<?php +include('.lib/common.php'); + +$smarty->assign('leftbar', "on"); +$leftbar_menu = array(); +$leftbar_submenu = array(); +$template = "clients.tpl"; +$status = ""; + +############################################ +## Deal with submitted forms first. +if ($_POST['addgroupname']) { #Adding a group. + if (!$_POST['parentgroup']) { + $_POST['parentgroup'] = 0; + } + $newgroup_id = $acl->add_group($_POST['addgroupname'], $_POST['addgroupname'], $_POST['parentgroup'], 'AXO'); + $_GET['Action'] = "created"; + $_GET['View'] = "groups"; + $status = "Client Group Created Successfully."; +} +if ($_POST['editgroupname']) { + $group_id = $acl->edit_group($_POST['groupid'], $_POST['editgroupname'], $_POST['editgroupname'], $_POST['parentgroup'], 'AXO'); + $_GET['Action'] = "edited"; + $_GET['View'] = "groups"; + $status = "Client Group Edited Successfully."; +} +if($_POST['delgroup_confirm']) { + #Check if the group has children. + $result = $acl->del_group($_POST['delgroup'],TRUE, 'AXO'); + if ($result) { + $status = "Group deleted successfully."; + } else { + $status = "ERROR: Group could not be successfully deleted."; + } + $_GET['Action'] = "deleted"; + $_GET['View'] = "groups"; +} + + + + + +$smarty->assign('desc', "View, create, edit, and delete clients"); + +######################################## +# Generate content + +switch($_GET['View']) { + case "groups": + $template = "clients_groups.tpl"; + switch($_GET['Action']) { + case "create": + add_leftbar($leftbar_menu, "««Cancel", "clients.php?View=groups"); + $smarty->assign('groups', $acl->format_groups($acl->sort_groups('AXO'), TEXT)); + break; + case "edit": + add_leftbar($leftbar_menu, "««Cancel", "clients.php?View=groups"); + $smarty->assign('groups', $acl->format_groups($acl->sort_groups('AXO'), TEXT)); + $smarty->assign('groupid', $_GET['groupid']); + $smarty->assign('groupdata', $acl->get_group_data($_GET['groupid'], 'AXO')); + break; + case "delete": + add_leftbar($leftbar_menu, "««Cancel", "clients.php?View=groups"); + $smarty->assign('groupid', $_GET['groupid']); + break; + default: #Show clientgroups. + add_leftbar($leftbar_menu, "Clients", "clients.php"); + add_leftbar($leftbar_menu, "Permissions", "clients.php?View=permissions"); + $smarty->assign('leftbar_submenu_title', "Actions"); + add_leftbar($leftbar_submenu, "Create Client Group", "clients.php?View=groups&Action=create"); + + + $groups = $acl->format_groups($acl->sort_groups('AXO'), HTML); + $smarty->assign('groups', $groups); + + break; + } + break; + case "permissions": + $template = "clients_permissions.tpl"; + break; + + default: #Show clients. + add_leftbar($leftbar_menu, "Groups", "clients.php?View=groups"); + add_leftbar($leftbar_menu, "Permissions", "clients.php?View=permissions"); + $smarty->assign('leftbar_submenu_title', "Actions"); + add_leftbar($leftbar_submenu, "Create Client", "client.php?Action=create"); + + ############################################ + ## Deal with sorting for the query. + $clients = get_scire_clients($_GET['sortby'], $_GET['sort']); + #var_dump($clients); + $smarty->assign('sort_'.$_GET['sortby'], $_GET['sort']); + foreach ($clients as $key => $client) { + $id = $acl->get_object_id("clients",$client['hostname'],'AXO'); + $groups = $acl->get_object_groups($id,'AXO'); + $group_string = ""; + if ($groups) { + foreach ($groups as $group) { + $group_data = $acl->get_group_data($group, 'AXO'); + $group_string .= $group_data[3]. " | "; + } + } + $clients[$key]['groups'] = $group_string; + } + $smarty->assign('clients', $clients); + break; +} + +$smarty->assign('leftbar_menu', $leftbar_menu); +$smarty->assign('leftbar_submenu', $leftbar_submenu); +$smarty->assign('View', $_GET['View']); +$smarty->assign('Action', $_GET['Action']); +$smarty->assign('status', $status); +$smarty->display($template); +var_dump($_POST); +?> diff --git a/scire/images/sort_asc.png b/scire/images/sort_asc.png Binary files differnew file mode 100644 index 0000000..aacd970 --- /dev/null +++ b/scire/images/sort_asc.png diff --git a/scire/images/sort_desc.png b/scire/images/sort_desc.png Binary files differnew file mode 100644 index 0000000..5d2ec1d --- /dev/null +++ b/scire/images/sort_desc.png diff --git a/scire/s.gif b/scire/s.gif Binary files differnew file mode 100644 index 0000000..5035948 --- /dev/null +++ b/scire/s.gif diff --git a/scire/user.php b/scire/user.php new file mode 100755 index 0000000..a083c73 --- /dev/null +++ b/scire/user.php @@ -0,0 +1,151 @@ +<?php +include('.lib/common.php'); + +$smarty->assign('leftbar', "on"); +$leftbar_menu = array(); + +add_leftbar($leftbar_menu, "««Cancel", "users.php"); + + +$userid = ""; + +##################################################### +#Deal with submitted forms. + +############################################### +#Adding a user to usergroups. +if ($_POST['addgroup_confirm']) { + $ingroups = $acl->get_object_groups($_POST['gacl_userid'],'ARO'); + $userdata = $acl->get_object_data($_POST['gacl_userid'], 'ARO'); + $newgroups = $_POST['addgroupid']; + #remove first. + foreach ($ingroups as $ingroup) { + if (!in_array($ingroup, $newgroups)) { + $acl->del_group_object($ingroup, $userdata[0][0], $userdata[0][1], 'ARO'); + } + } + foreach ($newgroups as $newgroup) { + print "newgroup: $newgroup"; + $acl->add_group_object($newgroup, $userdata[0][0], $userdata[0][1], 'ARO'); + } + $_GET['Action'] = "edit"; + $_GET['userid'] = $_POST['userid']; +} + +############################################### +# Adding a user. +if ($_POST['addusername']) { + if ($_POST['passwd'] == $_POST['passwd2']) { + if ($_POST['addusername'] and $_POST['passwd'] and $_POST['email']) { + $status = scire_add_user($_POST['addusername'], $_POST['passwd'], $_POST['real_name'], $_POST['comment'], $_POST['email'], $_POST['phone'], $_POST['pager']); + if ($status == 1) { $status = "User Addition successfull"; } + $obj_id = $acl->add_object("users", $_POST['addusername'], $_POST['addusername'], 1, 0, 'ARO'); + #print "Object id: $obj_id <BR>"; + if ($_POST['groups']) { + #print "Adding user to groups ".$_POST['groups']; + foreach( $_POST['groups'] as $group) { + $worked = $acl->add_group_object($group, "users", $_POST['addusername'], 'ARO'); + #if ($worked) { + # print "Group $group Addition successfull.<br>"; + #} else { + # print "ERROR adding group $group <br>"; + #} + } + } + } else { + $status = "Error required fields are not filled!"; + } + } else { + $status = "Error passwords do not match!"; + } + header('Location: ' . $baseurl . 'users.php'); +} +############################################### +# Editing a user's information. +if ($_POST['editusername']) { + $userinfo = get_scire_user($_GET['userid']); + $smarty->assign('user', $userinfo); + + if ($_POST['real_name'] and ($_POST['real_name'] != $userinfo['real_name'])) { + $fields['real_name'] = $_POST['real_name']; + } + if ($_POST['comment'] and ($_POST['comment'] != $userinfo['comment'])){ + $fields['comment'] = $_POST['comment']; + } + if ($_POST['email'] and ($_POST['email'] != $userinfo['email'])) { + $fields['email'] = $_POST['email']; + } + if ($_POST['phone'] and ($_POST['phone'] != $userinfo['phone'])) { + $fields['phone'] = $_POST['phone']; + } + if ($_POST['pager'] and ($_POST['pager'] != $userinfo['pager'])) { + $fields['pager'] = $_POST['pager']; + } + $status = scire_edit_user($_POST['userid'], $fields); + $_GET['Action'] = "edit"; + $_GET['userid'] = $_POST['userid']; +} + +############################################### +# Delete a user. +if ($_POST['delete_confirm']) { + $status = scire_del_user($_POST['userid']); + $id = $acl->get_object_id("users", $_POST['gacl_userid'], 'ARO'); + $acl->del_object($id, 'ARO', TRUE); #True means erase referencing objects. + header('Location: ' . $baseurl . 'users.php'); +} + +switch($_GET['Action']) { + case "addgroup": + $smarty->assign('userid', $_GET['userid']); + $smarty->assign('groups', $acl->format_groups($acl->sort_groups('aro'), TEXT)); + $smarty->assign('gacl_userid', $_GET['gacl_userid']); + $ingroups = array(); + $ingroups = $acl->get_object_groups($_GET['gacl_userid'],'ARO'); + var_dump($ingroups); + $smarty->assign('ingroups', $ingroups); + case "create": + $smarty->assign('desc', "Add a user."); + $smarty->assign('groups', $acl->format_groups($acl->sort_groups('aro'), TEXT)); + break; + case "edit": + #make the topbar look good + $smarty->assign('desc', "Edit user information."); + $userinfo = get_scire_user($_GET['userid']); + $smarty->assign('user', $userinfo); + + $usergroups = array(); + $id = $acl->get_object_id("users",$userinfo['username'],'ARO'); + $smarty->assign('gacl_userid', $id); + $groups = $acl->get_object_groups($id,'ARO'); + if ($groups) { + foreach ($groups as $group) { + $group_data = $acl->get_group_data($group, 'ARO'); + $usergroups_entry['name'] = $group_data[3]; + $usergroups_entry['id'] = $group_data[0]; + if ($group_data[1]) { + $parent_group_data = $acl->get_group_data($group_data[1],'ARO'); + $usergroups_entry['parent'] = $parent_group_data[3]; + } else { + $usergroups_entry['parent'] = ""; + } + array_push($usergroups, $usergroups_entry); + } + } + $smarty->assign('groups', $usergroups); + break; + case "delete": + $userinfo = get_scire_user($_GET['userid']); + $smarty->assign('user', $userinfo); + $id = $acl->get_object_id("users",$userinfo['username'],'ARO'); + $smarty->assign('gacl_userid', $id); + break; +} + + +$smarty->assign('leftbar_menu', $leftbar_menu); +$smarty->assign('Action', $_GET['Action']); +$smarty->assign('status', $status); +$smarty->display('user.tpl'); +var_dump($_POST); +?> diff --git a/scire/users.php b/scire/users.php new file mode 100755 index 0000000..6e4bc51 --- /dev/null +++ b/scire/users.php @@ -0,0 +1,111 @@ +<?php +include('.lib/common.php'); + +$smarty->assign('leftbar', "on"); +$leftbar_menu = array(); +$leftbar_submenu = array(); +$template = "users.tpl"; +$status = ""; + +############################################ +## Deal with submitted forms first. +if ($_POST['addgroupname']) { #Adding a group. + $newgroup_id = $acl->add_group($_POST['addgroupname'], $_POST['addgroupname'], $_POST['parentgroup'], 'ARO'); + $_GET['Action'] = "created"; + $_GET['View'] = "groups"; + $status = "User Group Created Successfully."; +} +if ($_POST['editgroupname']) { + $group_id = $acl->edit_group($_POST['groupid'], $_POST['editgroupname'], $_POST['editgroupname'], $_POST['parentgroup'], 'ARO'); + $_GET['Action'] = "edited"; + $_GET['View'] = "groups"; + $status = "User Group Edited Successfully."; +} +if($_POST['delgroup_confirm']) { + #Check if the group has children. + $result = $acl->del_group($_POST['delgroup'],TRUE, 'ARO'); + if ($result) { + $status = "Group deleted successfully."; + } else { + $status = "ERROR: Group could not be successfully deleted."; + } + $_GET['Action'] = "deleted"; + $_GET['View'] = "groups"; +} + + + + + +$smarty->assign('desc', "View, create, edit, and delete users"); + + +switch($_GET['View']) { + case "groups": + $template = "users_groups.tpl"; + switch($_GET['Action']) { + case "create": + add_leftbar($leftbar_menu, "««Cancel", "users.php?View=groups"); + $smarty->assign('groups', $acl->format_groups($acl->sort_groups('aro'), TEXT)); + break; + case "edit": + add_leftbar($leftbar_menu, "««Cancel", "users.php?View=groups"); + $smarty->assign('groups', $acl->format_groups($acl->sort_groups('aro'), TEXT)); + $smarty->assign('groupid', $_GET['groupid']); + $smarty->assign('groupdata', $acl->get_group_data($_GET['groupid'], 'ARO')); + break; + case "delete": + add_leftbar($leftbar_menu, "««Cancel", "users.php?View=groups"); + $smarty->assign('groupid', $_GET['groupid']); + break; + default: #Show usergroups. + add_leftbar($leftbar_menu, "Users", "users.php"); + add_leftbar($leftbar_menu, "Permissions", "users.php?View=permissions"); + $smarty->assign('leftbar_submenu_title', "Actions"); + add_leftbar($leftbar_submenu, "Create User Group", "users.php?View=groups&Action=create"); + + + $groups = $acl->format_groups($acl->sort_groups('aro'), HTML); + $smarty->assign('groups', $groups); + + break; + } + break; + case "permissions": + $template = "users_permissions.tpl"; + break; + + default: #Show users. + add_leftbar($leftbar_menu, "Groups", "users.php?View=groups"); + add_leftbar($leftbar_menu, "Permissions", "users.php?View=permissions"); + $smarty->assign('leftbar_submenu_title', "Actions"); + add_leftbar($leftbar_submenu, "Create User", "user.php?Action=create"); + + ############################################ + ## Deal with sorting for the query. + $users = get_scire_users($_GET['sortby'], $_GET['sort']); + $smarty->assign('sort_'.$_GET['sortby'], $_GET['sort']); + foreach ($users as $key => $user) { + $id = $acl->get_object_id("users",$user['username'],'ARO'); + $groups = $acl->get_object_groups($id,'ARO'); + $group_string = ""; + if ($groups) { + foreach ($groups as $group) { + $group_data = $acl->get_group_data($group, 'ARO'); + $group_string .= $group_data[3]. " | "; + } + } + $users[$key]['groups'] = $group_string; + } + $smarty->assign('users', $users); + break; +} + +$smarty->assign('leftbar_menu', $leftbar_menu); +$smarty->assign('leftbar_submenu', $leftbar_submenu); +$smarty->assign('View', $_GET['View']); +$smarty->assign('Action', $_GET['Action']); +$smarty->assign('status', $status); +$smarty->display($template); +var_dump($_POST); +?> |