mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-06 07:04:57 +00:00
rewrote using ajax (like UsrMgr)
This commit is contained in:
parent
d493715ae8
commit
e4ba3b44a8
|
@ -48,8 +48,7 @@ if(isset($_GET['groupid']) && $_GET['groupid']) {
|
|||
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
|
||||
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user, 'selgroup'=>$selgroup, 'allgroups'=>$allGroups, 'allusers'=>$allUsers, 'strictformcheck'=>$settings->_strictFormCheck));
|
||||
if($view) {
|
||||
$view->show();
|
||||
exit;
|
||||
$view($_GET);
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -31,6 +31,129 @@ require_once("class.Bootstrap.php");
|
|||
*/
|
||||
class SeedDMS_View_GroupMgr extends SeedDMS_Bootstrap_Style {
|
||||
|
||||
function info() { /* {{{ */
|
||||
$dms = $this->params['dms'];
|
||||
$selgroup = $this->params['selgroup'];
|
||||
|
||||
if($selgroup) {
|
||||
$this->contentHeading(getMLText("group_info"));
|
||||
echo "<table class=\"table table-condensed\">\n";
|
||||
echo "</table>";
|
||||
}
|
||||
} /* }}} */
|
||||
|
||||
function showGroupForm($group) { /* {{{ */
|
||||
$dms = $this->params['dms'];
|
||||
$user = $this->params['user'];
|
||||
$allUsers = $this->params['allusers'];
|
||||
$groups = $this->params['allgroups'];
|
||||
?>
|
||||
<form action="../op/op.GroupMgr.php" name="form<?php print $group ? $group->getID() : '0';?>_1" method="post" onsubmit="return checkForm1('<?php print $group ? $group->getID() : '0';?>');">
|
||||
<?php
|
||||
if($group) {
|
||||
echo createHiddenFieldWithKey('editgroup');
|
||||
?>
|
||||
<input type="hidden" name="groupid" value="<?php print $group->getID();?>">
|
||||
<input type="hidden" name="action" value="editgroup">
|
||||
<?php
|
||||
} else {
|
||||
echo createHiddenFieldWithKey('addgroup');
|
||||
?>
|
||||
<input type="hidden" name="action" value="addgroup">
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<table class="table-condensed">
|
||||
<?php
|
||||
if($group) {
|
||||
?>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><a href="../out/out.RemoveGroup.php?groupid=<?php print $group->getID();?>" class="btn"><i class="icon-remove"></i> <?php printMLText("rm_group");?></a></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td><?php printMLText("name");?>:</td>
|
||||
<td><input type="text" name="name" value="<?php print $group ? htmlspecialchars($group->getName()) : '';?>"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php printMLText("comment");?>:</td>
|
||||
<td><textarea name="comment" rows="4" cols="50"><?php print $group ? htmlspecialchars($group->getComment()) : '';?></textarea></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><button type="submit" class="btn"><i class="icon-save"></i> <?php printMLText("save")?></button></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<?php
|
||||
if($group) {
|
||||
$this->contentSubHeading(getMLText("group_members"));
|
||||
?>
|
||||
<table class="table-condensed">
|
||||
<?php
|
||||
$members = $group->getUsers();
|
||||
if (count($members) == 0)
|
||||
print "<tr><td>".getMLText("no_group_members")."</td></tr>";
|
||||
else {
|
||||
|
||||
foreach ($members as $member) {
|
||||
|
||||
print "<tr>";
|
||||
print "<td><i class=\"icon-user\"></i></td>";
|
||||
print "<td>" . htmlspecialchars($member->getFullName()) . "</td>";
|
||||
print "<td>" . ($group->isMember($member,true)?getMLText("manager"):" ") . "</td>";
|
||||
print "<td>";
|
||||
print "<form action=\"../op/op.GroupMgr.php\" method=\"post\" class=\"form-inline\" style=\"display: inline-block; margin-bottom: 0px;\"><input type=\"hidden\" name=\"action\" value=\"rmmember\" /><input type=\"hidden\" name=\"groupid\" value=\"".$group->getID()."\" /><input type=\"hidden\" name=\"userid\" value=\"".$member->getID()."\" />".createHiddenFieldWithKey('rmmember')."<button type=\"submit\" class=\"btn btn-mini\"><i class=\"icon-remove\"></i> ".getMLText("delete")."</button></form>";
|
||||
print " ";
|
||||
print "<form action=\"../op/op.GroupMgr.php\" method=\"post\" class=\"form-inline\" style=\"display: inline-block; margin-bottom: 0px;\"><input type=\"hidden\" name=\"groupid\" value=\"".$group->getID()."\" /><input type=\"hidden\" name=\"action\" value=\"tmanager\" /><input type=\"hidden\" name=\"userid\" value=\"".$member->getID()."\" />".createHiddenFieldWithKey('tmanager')."<button type=\"submit\" class=\"btn btn-mini\"><i class=\"icon-random\"></i> ".getMLText("toggle_manager")."</button></form>";
|
||||
print "</td></tr>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
|
||||
<?php
|
||||
$this->contentSubHeading(getMLText("add_member"));
|
||||
?>
|
||||
|
||||
<form class="form-inline" action="../op/op.GroupMgr.php" method="POST" name="form<?php print $group->getID();?>_2" onsubmit="return checkForm2('<?php print $group->getID();?>');">
|
||||
<?php echo createHiddenFieldWithKey('addmember'); ?>
|
||||
<input type="Hidden" name="action" value="addmember">
|
||||
<input type="Hidden" name="groupid" value="<?php print $group->getID();?>">
|
||||
<table class="table-condensed">
|
||||
<tr>
|
||||
<td>
|
||||
<select name="userid">
|
||||
<option value="-1"><?php printMLText("select_one");?>
|
||||
<?php
|
||||
foreach ($allUsers as $currUser)
|
||||
if (!$group->isMember($currUser))
|
||||
print "<option value=\"".$currUser->getID()."\">" . htmlspecialchars($currUser->getLogin()." - ".$currUser->getFullName()) . "\n";
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<label class="checkbox"><input type="checkbox" name="manager" value="1"><?php printMLText("manager");?></label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="submit" class="btn" value="<?php printMLText("add");?>">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
} /* }}} */
|
||||
|
||||
function form() { /* {{{ */
|
||||
$selgroup = $this->params['selgroup'];
|
||||
|
||||
$this->showGroupForm($selgroup);
|
||||
} /* }}} */
|
||||
|
||||
function show() { /* {{{ */
|
||||
$dms = $this->params['dms'];
|
||||
$user = $this->params['user'];
|
||||
|
@ -97,17 +220,9 @@ function checkForm2(num) {
|
|||
return true;
|
||||
}
|
||||
|
||||
obj = -1;
|
||||
function showUser(selectObj) {
|
||||
if (obj != -1)
|
||||
obj.style.display = "none";
|
||||
|
||||
function showGroup(selectObj) {
|
||||
id = selectObj.options[selectObj.selectedIndex].value;
|
||||
if (id == -1)
|
||||
return;
|
||||
|
||||
obj = document.getElementById("keywords" + id);
|
||||
obj.style.display = "";
|
||||
$('div.ajax').trigger('update', {groupid: id});
|
||||
}
|
||||
</script>
|
||||
<?php
|
||||
|
@ -118,136 +233,22 @@ function showUser(selectObj) {
|
|||
<div class="span4">
|
||||
<div class="well">
|
||||
<?php echo getMLText("selection")?>:
|
||||
<select onchange="showUser(this)" id="selector" class="span9">
|
||||
<select class="chzn-select" onchange="showGroup(this)" id="selector" class="span9">
|
||||
<option value="-1"><?php echo getMLText("choose_group")?>
|
||||
<option value="0"><?php echo getMLText("add_group")?>
|
||||
<?php
|
||||
$selected=0;
|
||||
$count=2;
|
||||
foreach ($allGroups as $group) {
|
||||
if ($selgroup && $group->getID()==$selgroup->getID()) $selected=$count;
|
||||
print "<option value=\"".$group->getID()."\">" . htmlspecialchars($group->getName());
|
||||
$count++;
|
||||
print "<option value=\"".$group->getID()."\" ".($selgroup && $group->getID()==$selgroup->getID() ? 'selected' : '').">" . htmlspecialchars($group->getName());
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="ajax" data-view="GroupMgr" data-action="info" <?php echo ($selgroup ? "data-query=\"groupid=".$selgroup->getID()."\"" : "") ?>></div>
|
||||
</div>
|
||||
|
||||
<div class="span8">
|
||||
<div class="well">
|
||||
<table class="table-condensed">
|
||||
<tr>
|
||||
<td id="keywords0" style="display : none;">
|
||||
|
||||
<form action="../op/op.GroupMgr.php" name="form0_1" method="post" onsubmit="return checkForm1('0');">
|
||||
<?php echo createHiddenFieldWithKey('addgroup'); ?>
|
||||
<input type="Hidden" name="action" value="addgroup">
|
||||
<table>
|
||||
<tr>
|
||||
<td><?php printMLText("name");?>:</td>
|
||||
<td><input type="text" name="name"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php printMLText("comment");?>:</td>
|
||||
<td><textarea name="comment" rows="4" cols="50"></textarea></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><input type="submit" class="btn" value="<?php printMLText("add_group");?>"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
</td>
|
||||
|
||||
<?php
|
||||
foreach ($allGroups as $group) {
|
||||
print "<td id=\"keywords".$group->getID()."\" style=\"display : none;\">";
|
||||
?>
|
||||
<form action="../op/op.GroupMgr.php" name="form<?php print $group->getID();?>_1" method="post" onsubmit="return checkForm1('<?php print $group->getID();?>');">
|
||||
<?php echo createHiddenFieldWithKey('editgroup'); ?>
|
||||
<input type="Hidden" name="groupid" value="<?php print $group->getID();?>">
|
||||
<input type="Hidden" name="action" value="editgroup">
|
||||
<table>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><a href="../out/out.RemoveGroup.php?groupid=<?php print $group->getID();?>" class="btn"><i class="icon-remove"></i> <?php printMLText("rm_group");?></a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php printMLText("name");?>:</td>
|
||||
<td><input type="text" name="name" value="<?php print htmlspecialchars($group->getName());?>"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php printMLText("comment");?>:</td>
|
||||
<td><textarea name="comment" rows="4" cols="50"><?php print htmlspecialchars($group->getComment());?></textarea></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><button type="submit" class="btn"><i class="icon-save"></i> <?php printMLText("save")?></button></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<?php
|
||||
$this->contentSubHeading(getMLText("group_members"));
|
||||
?>
|
||||
<table class="table-condensed">
|
||||
<?php
|
||||
$members = $group->getUsers();
|
||||
if (count($members) == 0)
|
||||
print "<tr><td>".getMLText("no_group_members")."</td></tr>";
|
||||
else {
|
||||
|
||||
foreach ($members as $member) {
|
||||
|
||||
print "<tr>";
|
||||
print "<td><i class=\"icon-user\"></i></td>";
|
||||
print "<td>" . htmlspecialchars($member->getFullName()) . "</td>";
|
||||
print "<td>" . ($group->isMember($member,true)?getMLText("manager"):" ") . "</td>";
|
||||
print "<td>";
|
||||
print "<form action=\"../op/op.GroupMgr.php\" method=\"post\" class=\"form-inline\" style=\"display: inline-block; margin-bottom: 0px;\"><input type=\"hidden\" name=\"action\" value=\"rmmember\" /><input type=\"hidden\" name=\"groupid\" value=\"".$group->getID()."\" /><input type=\"hidden\" name=\"userid\" value=\"".$member->getID()."\" />".createHiddenFieldWithKey('rmmember')."<button type=\"submit\" class=\"btn btn-mini\"><i class=\"icon-remove\"></i> ".getMLText("delete")."</button></form>";
|
||||
print " ";
|
||||
print "<form action=\"../op/op.GroupMgr.php\" method=\"post\" class=\"form-inline\" style=\"display: inline-block; margin-bottom: 0px;\"><input type=\"hidden\" name=\"groupid\" value=\"".$group->getID()."\" /><input type=\"hidden\" name=\"action\" value=\"tmanager\" /><input type=\"hidden\" name=\"userid\" value=\"".$member->getID()."\" />".createHiddenFieldWithKey('tmanager')."<button type=\"submit\" class=\"btn btn-mini\"><i class=\"icon-random\"></i> ".getMLText("toggle_manager")."</button></form>";
|
||||
print "</td></tr>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
|
||||
<?php
|
||||
$this->contentSubHeading(getMLText("add_member"));
|
||||
?>
|
||||
|
||||
<form class="form-inline" action="../op/op.GroupMgr.php" method="POST" name="form<?php print $group->getID();?>_2" onsubmit="return checkForm2('<?php print $group->getID();?>');">
|
||||
<?php echo createHiddenFieldWithKey('addmember'); ?>
|
||||
<input type="Hidden" name="action" value="addmember">
|
||||
<input type="Hidden" name="groupid" value="<?php print $group->getID();?>">
|
||||
<table class="table-condensed">
|
||||
<tr>
|
||||
<td>
|
||||
<select name="userid">
|
||||
<option value="-1"><?php printMLText("select_one");?>
|
||||
<?php
|
||||
foreach ($allUsers as $currUser)
|
||||
if (!$group->isMember($currUser))
|
||||
print "<option value=\"".$currUser->getID()."\">" . htmlspecialchars($currUser->getLogin()." - ".$currUser->getFullName()) . "\n";
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<label class="checkbox"><input type="checkbox" name="manager" value="1"><?php printMLText("manager");?></label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="submit" class="btn" value="<?php printMLText("add");?>">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</td>
|
||||
<?php } ?>
|
||||
|
||||
</tr>
|
||||
</table>
|
||||
<div class="ajax" data-view="GroupMgr" data-action="form" <?php echo ($selgroup ? "data-query=\"groupid=".$selgroup->getID()."\"" : "") ?>></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -255,8 +256,7 @@ function showUser(selectObj) {
|
|||
<script language="JavaScript">
|
||||
|
||||
sel = document.getElementById("selector");
|
||||
sel.selectedIndex=<?php print $selected ?>;
|
||||
showUser(sel);
|
||||
showGroup(sel);
|
||||
|
||||
</script>
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user