major rewrite to make it csp ready

place all javascript in a javascript file
This commit is contained in:
Uwe Steinmann 2015-12-11 08:14:42 +01:00
parent 940102f72f
commit 5387401098
2 changed files with 167 additions and 127 deletions

View File

@ -31,13 +31,117 @@ require_once("class.Bootstrap.php");
*/
class SeedDMS_View_GroupMgr extends SeedDMS_Bootstrap_Style {
function css() { /* {{{ */
$selgroup = $this->params['selgroup'];
$strictformcheck = $this->params['strictformcheck'];
header("Content-type: text/javascript");
?>
function checkForm1() {
msg = new Array();
if($("#name").val() == "") msg.push("<?php printMLText("js_no_name");?>");
<?php
if ($strictformcheck) {
?>
if($("#comment").val() == "") msg.push("<?php printMLText("js_no_comment");?>");
<?php
}
?>
if (msg != "") {
noty({
text: msg.join('<br />'),
type: 'error',
dismissQueue: true,
layout: 'topRight',
theme: 'defaultTheme',
_timeout: 1500,
});
return false;
} else
return true;
}
function checkForm2() {
msg = "";
if($("#userid").val() == -1) msg += "<?php printMLText("js_select_user");?>\n";
if (msg != "") {
noty({
text: msg,
type: 'error',
dismissQueue: true,
layout: 'topRight',
theme: 'defaultTheme',
_timeout: 1500,
});
return false;
} else
return true;
}
$(document).ready( function() {
$('body').on('submit', '#form_1', function(ev){
if(checkForm1())
return;
event.preventDefault();
});
$('body').on('submit', '#form_2', function(ev){
if(checkForm2())
return;
event.preventDefault();
});
$( "#selector" ).change(function() {
$('div.ajax').trigger('update', {groupid: $(this).val()});
});
});
<?php
} /* }}} */
function info() { /* {{{ */
$dms = $this->params['dms'];
$selgroup = $this->params['selgroup'];
$cachedir = $this->params['cachedir'];
$previewwidth = $this->params['previewWidthList'];
if($selgroup) {
$previewer = new SeedDMS_Preview_Previewer($cachedir, $previewwidth);
$this->contentHeading(getMLText("group_info"));
echo "<table class=\"table table-condensed\">\n";
$reviewstatus = $selgroup->getReviewStatus();
$i = 0;
foreach($reviewstatus as $rv) {
if($rv['status'] == 0) {
$i++;
/*
$document = $dms->getDocument($rv['documentID']);
$latestContent = $document->getLatestContent();
$previewer->createPreview($latestContent);
echo "<tr>";
print "<td><a href=\"../op/op.Download.php?documentid=".$res["documentID"]."&version=".$res["version"]."\">";
if($previewer->hasPreview($latestContent)) {
print "<img class=\"mimeicon\" width=\"".$previewwidth."\"src=\"../op/op.Preview.php?documentid=".$document->getID()."&version=".$latestContent->getVersion()."&width=".$previewwidth."\" title=\"".htmlspecialchars($latestContent->getMimeType())."\">";
} else {
print "<img class=\"mimeicon\" src=\"".$this->getMimeIcon($latestContent->getFileType())."\" title=\"".htmlspecialchars($latestContent->getMimeType())."\">";
}
print "</a></td>";
print "<td><a href=\"out.ViewDocument.php?documentid=".$document->getID()."&currenttab=revapp\">".htmlspecialchars($document->getName())."</a></td>";
echo "</tr>";
*/
}
}
echo "<tr><td>".getMLText('pending_reviews')."</td><td>".$i."</td></tr>";
$approvalstatus = $selgroup->getApprovalStatus();
$i = 0;
foreach($approvalstatus as $rv) {
if($rv['status'] == 0) {
$i++;
}
}
echo "<tr><td>".getMLText('pending_approvals')."</td><td>".$i."</td></tr>";
echo "</table>";
}
} /* }}} */
@ -48,7 +152,7 @@ class SeedDMS_View_GroupMgr extends SeedDMS_Bootstrap_Style {
$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';?>');">
<form action="../op/op.GroupMgr.php" name="form_1" id="form_1" method="post">
<?php
if($group) {
echo createHiddenFieldWithKey('editgroup');
@ -76,11 +180,11 @@ class SeedDMS_View_GroupMgr extends SeedDMS_Bootstrap_Style {
?>
<tr>
<td><?php printMLText("name");?>:</td>
<td><input type="text" name="name" value="<?php print $group ? htmlspecialchars($group->getName()) : '';?>"></td>
<td><input type="text" name="name" id="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>
<td><textarea name="comment" id="comment" rows="4" cols="50"><?php print $group ? htmlspecialchars($group->getComment()) : '';?></textarea></td>
</tr>
<tr>
<td></td>
@ -119,14 +223,14 @@ class SeedDMS_View_GroupMgr extends SeedDMS_Bootstrap_Style {
$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();?>');">
<form class="form-inline" action="../op/op.GroupMgr.php" method="POST" name="form_2" id="form_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">
<select name="userid" id="userid">
<option value="-1"><?php printMLText("select_one");?>
<?php
foreach ($allUsers as $currUser)
@ -167,65 +271,6 @@ class SeedDMS_View_GroupMgr extends SeedDMS_Bootstrap_Style {
$this->contentStart();
$this->pageNavigation(getMLText("admin_tools"), "admin_tools");
?>
<script language="JavaScript">
function checkForm1(num) {
msg = new Array();
eval("var formObj = document.form" + num + "_1;");
if (formObj.name.value == "") msg.push("<?php printMLText("js_no_name");?>");
<?php
if ($strictformcheck) {
?>
if (formObj.comment.value == "") msg.push("<?php printMLText("js_no_comment");?>");
<?php
}
?>
if (msg != "")
{
noty({
text: msg.join('<br />'),
type: 'error',
dismissQueue: true,
layout: 'topRight',
theme: 'defaultTheme',
_timeout: 1500,
});
return false;
}
else
return true;
}
function checkForm2(num) {
msg = "";
eval("var formObj = document.form" + num + "_2;");
if (formObj.userid.options[formObj.userid.selectedIndex].value == -1) msg += "<?php printMLText("js_select_user");?>\n";
if (msg != "")
{
noty({
text: msg,
type: 'error',
dismissQueue: true,
layout: 'topRight',
theme: 'defaultTheme',
_timeout: 1500,
});
return false;
}
else
return true;
}
function showGroup(selectObj) {
id = selectObj.options[selectObj.selectedIndex].value;
$('div.ajax').trigger('update', {groupid: id});
}
</script>
<?php
$this->contentHeading(getMLText("group_management"));
?>
@ -233,7 +278,7 @@ function showGroup(selectObj) {
<div class="span4">
<div class="well">
<?php echo getMLText("selection")?>:
<select class="chzn-select" onchange="showGroup(this)" id="selector" class="span9">
<select class="chzn-select" id="selector" class="span9">
<option value="-1"><?php echo getMLText("choose_group")?>
<option value="0"><?php echo getMLText("add_group")?>
<?php
@ -253,13 +298,6 @@ function showGroup(selectObj) {
</div>
</div>
<script language="JavaScript">
sel = document.getElementById("selector");
showGroup(sel);
</script>
<?php
$this->contentContainerEnd();
$this->htmlEndPage();

View File

@ -31,6 +31,52 @@ require_once("class.Bootstrap.php");
*/
class SeedDMS_View_UsrMgr extends SeedDMS_Bootstrap_Style {
function css() { /* {{{ */
$seluser = $this->params['seluser'];
?>
function checkForm()
{
msg = new Array();
if($("#login").val() == "") msg.push("<?php printMLText("js_no_login");?>");
if(($("#userid").val() == "0") && ($("#pwd").val() == "")) msg.push("<?php printMLText("js_no_pwd");?>");
if(($("#pwd").val() != $("#pwdconf").val())&&($("#pwd").val() != "")&&($("#pwd").val() != "")) msg.push("<?php printMLText("js_pwd_not_conf");?>");
if($("#name").val() == "") msg.push("<?php printMLText("js_no_name");?>");
if($("#email").val() == "") msg.push("<?php printMLText("js_no_email");?>");
<?php
if ($strictformcheck) {
?>
if($("#comment").val() == "") msg.push("<?php printMLText("js_no_comment");?>");
<?php
}
?>
if (msg != "") {
noty({
text: msg.join('<br />'),
type: 'error',
dismissQueue: true,
layout: 'topRight',
theme: 'defaultTheme',
_timeout: 1500,
});
return false;
}
else
return true;
}
$(document).ready( function() {
$('body').on('submit', '#form', function(ev){
if(checkForm()) return;
event.preventDefault();
});
$( "#selector" ).change(function() {
$('div.ajax').trigger('update', {userid: $(this).val()});
});
});
<?php
} /* }}} */
function info() { /* {{{ */
$dms = $this->params['dms'];
$seluser = $this->params['seluser'];
@ -76,17 +122,18 @@ class SeedDMS_View_UsrMgr extends SeedDMS_Bootstrap_Style {
$workflowmode = $this->params['workflowmode'];
$quota = $this->params['quota'];
?>
<form action="../op/op.UsrMgr.php" method="post" enctype="multipart/form-data" name="form<?php print $currUser ? $currUser->getID() : '0';?>" onsubmit="return checkForm('<?php print $currUser ? $currUser->getID() : '0';?>');">
<form action="../op/op.UsrMgr.php" method="post" enctype="multipart/form-data" name="form" id="form">
<?php
if($currUser) {
echo createHiddenFieldWithKey('edituser');
?>
<input type="hidden" name="userid" value="<?php print $currUser->getID();?>">
<input type="hidden" name="userid" id="userid" value="<?php print $currUser->getID();?>">
<input type="hidden" name="action" value="edituser">
<?php
} else {
echo createHiddenFieldWithKey('adduser');
?>
<input type="hidden" id="userid" value="0">
<input type="hidden" name="action" value="adduser">
<?php
}
@ -104,11 +151,11 @@ class SeedDMS_View_UsrMgr extends SeedDMS_Bootstrap_Style {
?>
<tr>
<td><?php printMLText("user_login");?>:</td>
<td><input type="text" name="login" value="<?php print $currUser ? htmlspecialchars($currUser->getLogin()) : "";?>"></td>
<td><input type="text" name="login" id="login" value="<?php print $currUser ? htmlspecialchars($currUser->getLogin()) : "";?>"></td>
</tr>
<tr>
<td><?php printMLText("password");?>:</td>
<td><input type="password" class="pwd" rel="strengthbar<?php echo $currUser ? $currUser->getID() : "0"; ?>" name="pwd"></td>
<td><input type="password" class="pwd" rel="strengthbar<?php echo $currUser ? $currUser->getID() : "0"; ?>" name="pwd" id="pwd"></td>
</tr>
<?php
if($passwordstrength > 0) {
@ -124,7 +171,7 @@ class SeedDMS_View_UsrMgr extends SeedDMS_Bootstrap_Style {
?>
<tr>
<td><?php printMLText("confirm_pwd");?>:</td>
<td><input type="Password" name="pwdconf"></td>
<td><input type="Password" name="pwdconf" id="pwdconf"></td>
</tr>
<?php
if($passwordexpiration > 0) {
@ -138,15 +185,15 @@ class SeedDMS_View_UsrMgr extends SeedDMS_Bootstrap_Style {
?>
<tr>
<td><?php printMLText("user_name");?>:</td>
<td><input type="text" name="name" value="<?php print $currUser ? htmlspecialchars($currUser->getFullName()) : "";?>"></td>
<td><input type="text" name="name" id="name" value="<?php print $currUser ? htmlspecialchars($currUser->getFullName()) : "";?>"></td>
</tr>
<tr>
<td><?php printMLText("email");?>:</td>
<td><input type="text" name="email" value="<?php print $currUser ? htmlspecialchars($currUser->getEmail()) : "";?>"></td>
<td><input type="text" name="email" id="email" value="<?php print $currUser ? htmlspecialchars($currUser->getEmail()) : "";?>"></td>
</tr>
<tr>
<td><?php printMLText("comment");?>:</td>
<td><textarea name="comment" rows="4" cols="50"><?php print $currUser ? htmlspecialchars($currUser->getComment()) : "";?></textarea></td>
<td><textarea name="comment" id="comment" rows="4" cols="50"><?php print $currUser ? htmlspecialchars($currUser->getComment()) : "";?></textarea></td>
</tr>
<tr>
<td><?php printMLText("role");?>:</td>
@ -372,55 +419,18 @@ class SeedDMS_View_UsrMgr extends SeedDMS_Bootstrap_Style {
$this->contentStart();
$this->pageNavigation(getMLText("admin_tools"), "admin_tools");
?>
<script language="JavaScript">
function checkForm(num)
{
msg = new Array();
eval("var formObj = document.form" + num + ";");
if (formObj.login.value == "") msg.push("<?php printMLText("js_no_login");?>");
if ((num == '0') && (formObj.pwd.value == "")) msg.push("<?php printMLText("js_no_pwd");?>");
if ((formObj.pwd.value != formObj.pwdconf.value)&&(formObj.pwd.value != "" )&&(formObj.pwd.value != "" )) msg.push("<?php printMLText("js_pwd_not_conf");?>");
if (formObj.name.value == "") msg.push("<?php printMLText("js_no_name");?>");
if (formObj.email.value == "") msg.push("<?php printMLText("js_no_email");?>");
//if (formObj.comment.value == "") msg.push("<?php printMLText("js_no_comment");?>");
if (msg != "")
{
noty({
text: msg.join('<br />'),
type: 'error',
dismissQueue: true,
layout: 'topRight',
theme: 'defaultTheme',
_timeout: 1500,
});
return false;
}
else
return true;
}
function showUser(selectObj) {
id = selectObj.options[selectObj.selectedIndex].value;
$('div.ajax').trigger('update', {userid: id});
}
</script>
<?php
$this->contentHeading(getMLText("user_management"));
?>
<div class="row-fluid">
<div class="span4">
<div class="well">
<?php echo getMLText("selection")?>:
<select class="chzn-select" onchange="showUser(this)" id="selector" class="span9">
<select class="chzn-select" id="selector" class="span9">
<option value="-1"><?php echo getMLText("choose_user")?>
<option value="0"><?php echo getMLText("add_user")?>
<?php
foreach ($users as $currUser) {
print "<option value=\"".$currUser->getID()."\" ".($seluser && $currUser->getID()==$currUser->getID() ? 'selected' : '').">" . htmlspecialchars($currUser->getLogin() . " - ". $currUser->getFullName());
print "<option value=\"".$currUser->getID()."\" ".($seluser && $currUser->getID()==$seluser->getID() ? 'selected' : '').">" . htmlspecialchars($currUser->getLogin() . " - ". $currUser->getFullName());
}
?>
</select>
@ -434,14 +444,6 @@ function showUser(selectObj) {
</div>
</div>
<script language="JavaScript">
sel = document.getElementById("selector");
showUser(sel);
</script>
<?php
$this->htmlEndPage();
} /* }}} */