314 lines
12 KiB
PHP
314 lines
12 KiB
PHP
|
|
<!--
|
||
|
|
/*****************************************************************************
|
||
|
|
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||
|
|
* Version 1.1 ("License"); You may not use this file except in compliance
|
||
|
|
* with the License. You may obtain a copy of the License at
|
||
|
|
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||
|
|
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||
|
|
* either express or implied.
|
||
|
|
*
|
||
|
|
* You may:
|
||
|
|
* a) Use and distribute this code exactly as you received without payment or
|
||
|
|
* a royalty or other fee.
|
||
|
|
* b) Create extensions for this code, provided that you make the extensions
|
||
|
|
* publicly available and document your modifications clearly.
|
||
|
|
* c) Charge for a fee for warranty or support or for accepting liability
|
||
|
|
* obligations for your customers.
|
||
|
|
*
|
||
|
|
* You may NOT:
|
||
|
|
* a) Charge for the use of the original code or extensions, including in
|
||
|
|
* electronic distribution models, such as ASP (Application Service
|
||
|
|
* Provider).
|
||
|
|
* b) Charge for the original source code or your extensions other than a
|
||
|
|
* nominal fee to cover distribution costs where such distribution
|
||
|
|
* involves PHYSICAL media.
|
||
|
|
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||
|
|
* or License text in the Licensed Software
|
||
|
|
* d) Assert any patent claims against the Licensor or Contributors, or
|
||
|
|
* which would in any way restrict the ability of any third party to use the
|
||
|
|
* Licensed Software.
|
||
|
|
*
|
||
|
|
* You must:
|
||
|
|
* a) Document any modifications you make to this code including the nature of
|
||
|
|
* the change, the authors of the change, and the date of the change.
|
||
|
|
* b) Make the source code for any extensions you deploy available via an
|
||
|
|
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||
|
|
* c) Notify the licensor of the availability of source code to your extensions
|
||
|
|
* and include instructions on how to acquire the source code and updates.
|
||
|
|
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||
|
|
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||
|
|
*
|
||
|
|
* The Original Code is: CommuniCore
|
||
|
|
* Olavo Farias
|
||
|
|
* 2006-04-7 olavo.farias@gmail.com
|
||
|
|
*
|
||
|
|
* The Initial Developer of the Original Code is CommuniCore.
|
||
|
|
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||
|
|
* All Rights Reserved.
|
||
|
|
********************************************************************************/
|
||
|
|
-->
|
||
|
|
<script language="javascript">
|
||
|
|
function check_checkbox(i,what)
|
||
|
|
{
|
||
|
|
if(document.getElementById("pom"+what+""+i).value==" checked")document.getElementById("pom"+what+""+i).value="";
|
||
|
|
else document.getElementById("pom"+what+""+i).value=" checked";
|
||
|
|
}
|
||
|
|
function check_all(num,check,start)
|
||
|
|
{
|
||
|
|
if(start=="subfolders")
|
||
|
|
{
|
||
|
|
for(i=0;i<=num-1;i++)
|
||
|
|
{
|
||
|
|
document.getElementById("read"+i).checked=check;
|
||
|
|
document.getElementById("write"+i).checked=check;
|
||
|
|
document.getElementById("add"+i).checked=check;
|
||
|
|
document.getElementById("delete"+i).checked=check;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
for(i=0;i<=num-1;i++)
|
||
|
|
{
|
||
|
|
if(document.getElementById("pomread"+i).value==" checked")document.getElementById("read"+i).checked=true;
|
||
|
|
else document.getElementById("read"+i).checked=false;
|
||
|
|
|
||
|
|
if(document.getElementById("pomwrite"+i).value==" checked")document.getElementById("write"+i).checked=true;
|
||
|
|
else document.getElementById("write"+i).checked=false;
|
||
|
|
|
||
|
|
if(document.getElementById("pomadd"+i).value==" checked")document.getElementById("add"+i).checked=true;
|
||
|
|
else document.getElementById("add"+i).checked=false;
|
||
|
|
|
||
|
|
if(document.getElementById("pomdelete"+i).value==" checked")document.getElementById("delete"+i).checked=true;
|
||
|
|
else document.getElementById("delete"+i).checked=false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
function check_row(i)
|
||
|
|
{
|
||
|
|
if(document.getElementById("all"+i).checked==false)
|
||
|
|
{
|
||
|
|
document.getElementById("read"+i).checked=true;
|
||
|
|
document.getElementById("write"+i).checked=true;
|
||
|
|
document.getElementById("add"+i).checked=true;
|
||
|
|
document.getElementById("delete"+i).checked=true;
|
||
|
|
|
||
|
|
document.getElementById("pomread"+i).value=" checked";
|
||
|
|
document.getElementById("pomwrite"+i).value=" checked";
|
||
|
|
document.getElementById("pomadd"+i).value=" checked";
|
||
|
|
document.getElementById("pomdelete"+i).value=" checked";
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
document.getElementById("read"+i).checked=false;
|
||
|
|
document.getElementById("write"+i).checked=false;
|
||
|
|
document.getElementById("add"+i).checked=false;
|
||
|
|
document.getElementById("delete"+i).checked=false;
|
||
|
|
|
||
|
|
document.getElementById("pomread"+i).value="";
|
||
|
|
document.getElementById("pomwrite"+i).value="";
|
||
|
|
document.getElementById("pomadd"+i).value="";
|
||
|
|
document.getElementById("pomdelete"+i).value="";
|
||
|
|
}
|
||
|
|
}
|
||
|
|
function check_column(what,num,check)
|
||
|
|
{
|
||
|
|
var c;
|
||
|
|
for(i=0;i<=num-1;i++)
|
||
|
|
{
|
||
|
|
if(document.getElementById(what+""+i))
|
||
|
|
{
|
||
|
|
document.getElementById(what+""+i).checked=check;
|
||
|
|
if(check==true)c=" checked";
|
||
|
|
else c="";
|
||
|
|
document.getElementById("pom"+what+""+i).value=c;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
//document.getElementById(what+"c").checked=check;
|
||
|
|
}
|
||
|
|
</script>
|
||
|
|
<?
|
||
|
|
require_once('include/formbase.php');
|
||
|
|
function list_dirs($dir,$dirs)
|
||
|
|
{
|
||
|
|
$dirs.=$dir."||";
|
||
|
|
$z="select id from ecmdocuments where iddir='".$dir."'";
|
||
|
|
$w=mysql_query($z);
|
||
|
|
while($r=mysql_fetch_array($w))$dirs=list_dirs($r['id'],$dirs);
|
||
|
|
return $dirs;
|
||
|
|
}
|
||
|
|
function set_permissions_down($i,$dir,$dirs)
|
||
|
|
{
|
||
|
|
$d=explode("||",$dirs);
|
||
|
|
for($j=0;$j<=count($d)-2;$j++)
|
||
|
|
{
|
||
|
|
set_permissions($i,$d[$j],0);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
function set_permissions($i,$dir,$rest)
|
||
|
|
{
|
||
|
|
$z="select id from ecmdocuments_permissions where userid='".$_POST['userid'][$i]."' and iddir='".$dir."'";
|
||
|
|
$w=mysql_query($z);
|
||
|
|
$ile=mysql_num_rows($w);
|
||
|
|
$r=mysql_fetch_array(mysql_query("select iddir from ecmdocuments where id='".$dir."'"));
|
||
|
|
$idkat=$r['iddir'];
|
||
|
|
if($ile==0)
|
||
|
|
{
|
||
|
|
if($rest)
|
||
|
|
{
|
||
|
|
$re=$_POST['read'][$i];
|
||
|
|
$wr=0;
|
||
|
|
$ad=0;
|
||
|
|
$de=0;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
$re=$_POST['read'][$i];
|
||
|
|
$wr=$_POST['write'][$i];
|
||
|
|
$ad=$_POST['add'][$i];
|
||
|
|
$de=$_POST['delete'][$i];
|
||
|
|
}
|
||
|
|
$za="insert into ecmdocuments_permissions values('".create_guid()."','".$_POST['userid'][$i]."','".$dir."','".$re."','".$wr."','".$ad."','".$de."')";
|
||
|
|
$wy=mysql_query($za);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
if($rest)
|
||
|
|
{
|
||
|
|
$re=$_POST['read'][$i];
|
||
|
|
$wr=0;
|
||
|
|
$ad=0;
|
||
|
|
$de=0;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
$re=$_POST['read'][$i];
|
||
|
|
$wr=$_POST['write'][$i];
|
||
|
|
$ad=$_POST['add'][$i];
|
||
|
|
$de=$_POST['delete'][$i];
|
||
|
|
}
|
||
|
|
if(!$re)$re=0;
|
||
|
|
if(!$wr)$wr=0;
|
||
|
|
$za="UPDATE ecmdocuments_permissions SET ecmdocuments_permissions.read='".$re."',ecmdocuments_permissions.write='".$wr."',ecmdocuments_permissions.add='".$ad."',ecmdocuments_permissions.delete='".$de."' WHERE ecmdocuments_permissions.userid='".$_POST['userid'][$i]."' AND ecmdocuments_permissions.iddir='".$dir."'";
|
||
|
|
$wy=mysql_query($za) or die(mysql_error());
|
||
|
|
}
|
||
|
|
if($idkat && $rest)set_permissions($i,$idkat,$rest);
|
||
|
|
}
|
||
|
|
if($_POST['save'] || $_POST['save1'])
|
||
|
|
{
|
||
|
|
for($i=0;$i<=$_POST['numusers']-1;$i++)
|
||
|
|
{
|
||
|
|
if($_POST['selecttype']=="thisfolder")
|
||
|
|
{
|
||
|
|
set_permissions($i,$_GET['record'],1);
|
||
|
|
set_permissions($i,$_GET['record'],0);
|
||
|
|
}
|
||
|
|
if($_POST['selecttype']=="subfolders")
|
||
|
|
{
|
||
|
|
$dirs=list_dirs($_GET['record'],"");
|
||
|
|
//set_permissions($i,$_GET['record'],1);
|
||
|
|
set_permissions_down($i,$_GET['record'],$dirs);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
ob_start();
|
||
|
|
handleRedirect($_GET['record'],'EcmDocuments');
|
||
|
|
}
|
||
|
|
?>
|
||
|
|
|
||
|
|
<table width='100%' cellpadding='0' cellspacing='0' border='0' class='moduleTitle'><tr><td valign='top'>
|
||
|
|
</td><td width='100%'><h2>Set Permissions:
|
||
|
|
<?
|
||
|
|
$z="select name from ecmdocuments where id='".$_GET['record']."'";
|
||
|
|
$w=mysql_query($z);
|
||
|
|
$r=mysql_fetch_array($w);
|
||
|
|
print " ".$r['name'];
|
||
|
|
?>
|
||
|
|
</h2></td>
|
||
|
|
</tr></table>
|
||
|
|
<form name="EditView" method="POST" enctype="multipart/form-data" action="index.php?module=EcmDocuments&action=SetPermissions&record=<?print $_GET['record'];?>">
|
||
|
|
<table cellpadding="0" cellspacing="0" border="0" width="100%">
|
||
|
|
<tr>
|
||
|
|
|
||
|
|
|
||
|
|
<td style="padding-bottom: 2px;">
|
||
|
|
<input title="Save" class="button" type="submit" name="save" value="Save" >
|
||
|
|
<select name="selecttype" onchange="check_all(<?print mysql_num_rows(mysql_query("select id from users where deleted='0' order by user_name asc"));?>,false,this.value);">
|
||
|
|
<option value="thisfolder">This folder</option>
|
||
|
|
<option value="subfolders">Subfolders</option>
|
||
|
|
</select></td>
|
||
|
|
</tr>
|
||
|
|
</table>
|
||
|
|
<p>
|
||
|
|
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="tabForm">
|
||
|
|
<tr>
|
||
|
|
<td class="dataLabel" ><strong>User name</strong></td>
|
||
|
|
<td class="dataLabel" ><strong>read</strong></td>
|
||
|
|
<td class="dataLabel" ><strong>write</strong></td>
|
||
|
|
<td class="dataLabel" ><strong>add</strong></td>
|
||
|
|
<td class="dataLabel" ><strong>delete</strong></td>
|
||
|
|
<?
|
||
|
|
$z="select user_name,id from users where deleted='0' order by user_name asc";
|
||
|
|
$w=mysql_query($z);
|
||
|
|
$i=0;
|
||
|
|
while($r=mysql_fetch_array($w))
|
||
|
|
{
|
||
|
|
$z1="select * from ecmdocuments_permissions where iddir='".$_GET['record']."' and userid='".$r['id']."'";
|
||
|
|
$w1=mysql_query($z1);
|
||
|
|
$ile=mysql_num_rows($w1);
|
||
|
|
if($ile==0)
|
||
|
|
{
|
||
|
|
$read=0;
|
||
|
|
$write=0;
|
||
|
|
$add=0;
|
||
|
|
$delete=0;
|
||
|
|
$readchecked="";
|
||
|
|
$writechecked="";
|
||
|
|
$addchecked="";
|
||
|
|
$deletechecked="";
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
$r1=mysql_fetch_array($w1);
|
||
|
|
$read=$r1['read'];
|
||
|
|
$write=$r1['write'];
|
||
|
|
$add=$r1['add'];
|
||
|
|
$delete=$r1['delete'];
|
||
|
|
if($read)$readchecked=" checked";
|
||
|
|
else $readchecked="";
|
||
|
|
if($write)$writechecked=" checked";
|
||
|
|
else $writechecked="";
|
||
|
|
if($add)$addchecked=" checked";
|
||
|
|
else $addchecked="";
|
||
|
|
if($delete)$deletechecked=" checked";
|
||
|
|
else $deletechecked="";
|
||
|
|
}
|
||
|
|
print '
|
||
|
|
<tr>
|
||
|
|
<td class="dataLabel" >'.$r['user_name'].'</td>
|
||
|
|
<td class="dataLabel" ><input type="hidden" name="pomread['.$i.']" id="pomread'.$i.'" value="'.$readchecked.'"><input type="checkbox" onclick="check_checkbox('.$i.',\'read\');" name="read['.$i.']" id="read'.$i.'" value="1"'.$readchecked.'></td>
|
||
|
|
<td class="dataLabel" ><input type="hidden" name="pomwrite['.$i.']" id="pomwrite'.$i.'" value="'.$writechecked.'"><input type="checkbox" onclick="check_checkbox('.$i.',\'write\');" name="write['.$i.']" id="write'.$i.'" value="1"'.$writechecked.'></td>
|
||
|
|
<td class="dataLabel" ><input type="hidden" name="pomadd['.$i.']" id="pomadd'.$i.'" value="'.$addchecked.'"><input type="checkbox" onclick="check_checkbox('.$i.',\'add\');" name="add['.$i.']" id="add'.$i.'" value="1"'.$addchecked.'></td>
|
||
|
|
<td class="dataLabel" ><input type="hidden" name="pomdelete['.$i.']" id="pomdelete'.$i.'" value="'.$deletechecked.'"><input type="checkbox" onclick="check_checkbox('.$i.',\'delete\');" name="delete['.$i.']" id="delete'.$i.'" value="1"'.$deletechecked.'></td>
|
||
|
|
<td class="dataLabel" ><input type="checkbox" name="all['.$i.']" id="all'.$i.'" value="1" onclick=\'check_row('.$i.');\' checked></td>
|
||
|
|
<input type="hidden" name="userid['.$i.']" value="'.$r['id'].'"></tr>
|
||
|
|
';
|
||
|
|
$i++;
|
||
|
|
}
|
||
|
|
?>
|
||
|
|
|
||
|
|
<tr>
|
||
|
|
<td class="dataLabel" ></td>
|
||
|
|
<td class="dataLabel" ><input type="checkbox" name="readc" id="readc" value="1" onclick="if(this.checked==true)check_column('read','<?print $i;?>',false);else check_column('read','<?print $i;?>',true);" checked></td>
|
||
|
|
<td class="dataLabel" ><input type="checkbox" name="writec" id="writec" value="1" onclick="if(this.checked==true)check_column('write','<?print $i;?>',false);else check_column('write','<?print $i;?>',true);" checked></td>
|
||
|
|
<td class="dataLabel" ><input type="checkbox" name="addc" id="addc" value="1" onclick="if(this.checked==true)check_column('add','<?print $i;?>',false);else check_column('add','<?print $i;?>',true);" checked></td>
|
||
|
|
<td class="dataLabel" ><input type="checkbox" name="deletec" id="deletec" value="1" onclick="if(this.checked==true)check_column('delete','<?print $i;?>',false);else check_column('delete','<?print $i;?>',true);" checked></td>
|
||
|
|
</tr>
|
||
|
|
</tr>
|
||
|
|
</table>
|
||
|
|
<input type="hidden" name="numusers" value="<?print $i;?>" />
|
||
|
|
</p>
|
||
|
|
<div style="padding-top: 2px">
|
||
|
|
<input title="save" class="button" type="submit" name="save1" value="Save" >
|
||
|
|
</div>
|
||
|
|
</form>
|
||
|
|
<!-- END: main -->
|