[Openupload-svn-update] SF.net SVN: openupload:[107] trunk/lib/modules/default/admin.inc.php
Status: Beta
Brought to you by:
tsdogs
|
From: <ts...@us...> - 2008-11-04 18:46:37
|
Revision: 107
http://openupload.svn.sourceforge.net/openupload/?rev=107&view=rev
Author: tsdogs
Date: 2008-11-04 18:46:28 +0000 (Tue, 04 Nov 2008)
Log Message:
-----------
Change rights administration
delete files now works
Modified Paths:
--------------
trunk/lib/modules/default/admin.inc.php
Modified: trunk/lib/modules/default/admin.inc.php
===================================================================
--- trunk/lib/modules/default/admin.inc.php 2008-11-04 18:00:26 UTC (rev 106)
+++ trunk/lib/modules/default/admin.inc.php 2008-11-04 18:46:28 UTC (rev 107)
@@ -19,6 +19,9 @@
),
"adminpluginsoptions" => array (
1 => "pluginoptions",
+ 2 => "pluginoptionadd",
+ 3 => "pluginoptionedit",
+ 4 => "pluginoptiondelete",
),
"adminfiles" => array (
1 => "files",
@@ -40,9 +43,7 @@
),
"adminrights" => array (
1 => "rights",
- 2 => "rightadd",
- 3 => "rightedit",
- 4 => "rightdel",
+ 2 => "rightedit",
),
"adminbanned" => array (
1 => "banned",
@@ -242,73 +243,104 @@
function rights() {
$groups = app()->auth->groupinfo();
+ array_unshift($groups,array('name' => '*','description' => tr('Any group')));
$this->tpl->assign('groups',$groups);
- $rights = app()->db->read('acl',array(),array('group_name','module'));
+ $rights = app()->db->read('acl',array(),array('group_name','module'),'',array('group_name','module','action'));
$this->tpl->assign('rights',$rights);
}
- function rightadd() {
- global $_POST;
-
- $modules = app()->config['modules'];
- $modules['*']='*';
- $this->tpl->assign('modules',$modules);
- $groups = app()->auth->groupinfo();
- $groups[]='*';
- $this->tpl->assign('groups',$groups);
- $access['allow']=tr('Allow');
- $access['deny']=tr('Deny');
- $this->tpl->assign('access',$access);
- $right['module']='*';
- $right['group_name']='*';
- $right['action']='*';
- $right['access']='deny';
- if (isset($_POST['addrightgroup'])) {
- $right['group_name']=$_POST['addrightgroup'];
- $right['module']=$_POST['addrightmodule'];
- $right['action']=$_POST['addrightaction'];
- $right['access']=$_POST['addrightaccess'];
- app()->db->insert('acl',$right);
- $this->nextStep(1);
+ function checkAcl($acl,$group,$module,$action,&$comb) {
+ $result = 'deny'; /* not defined are denyed by default */
+ $comb['group']=$group;
+ $comb['module']=$module;
+ $comb['action']=$action;
+ if (isset($acl[$group][$module][$action])) {
+ $result = $acl[$group][$module][$action]['access'];
+ } else if (isset($acl[$group][$module]['*'])) {
+ $result = $acl[$group][$module]['*']['access'];
+ $comb['action']='*';
+ } else if (isset($acl[$group]['*']['*'])) {
+ $result = $acl[$group]['*']['*']['access'];
+ $comb['module']='*';
+ $comb['action']='*';
+ } else if (isset($acl['*'][$module][$action])) {
+ $result = $acl['*'][$module][$action];
+ $comb['group']='*';
+ } else if (isset($acl['*'][$module]['*'])) {
+ $result = $acl['*'][$module]['*']['access'];
+ $comb['group']='*';
+ $comb['action']='*';
+ } else if (isset($acl['*']['*']['*'])) {
+ $result = $acl['*']['*']['*']['access']; /* this should be avoided imho */
+ $comb['group']='*';
+ $comb['module']='*';
+ $comb['action']='*';
}
- app()->tpl->assign('right',$right);
+ return $result;
}
function rightedit() {
+ global $_GET;
global $_POST;
- global $_GET;
- $right = app()->db->read('acl',array('id' => $_GET['id']));
- $right = $right[0];
- $modules = app()->config['modules'];
- $modules['*']='*';
+
+ if (isset($_POST['id'])) {
+ $id = $_POST['id'];
+ foreach ($_POST as $k => $v) {
+ if (strpos($k,'right_')!==FALSE) {
+ $key = explode('_',$k);
+ /* delete and reinsert the right */
+ app()->db->delete('acl',array('group_name' => $id, 'module' => $key[1], 'action' => $key[2]));
+ if ($v != '') {
+ $acl['group_name']=$id;
+ $acl['module']=$key[1];
+ $acl['action']=$key[2];
+ $acl['access']=$v;
+ app()->db->insert('acl',$acl);
+ }
+ }
+ }
+ redirect('?action=adminrights&step=2&id='.$id);
+ } else {
+ $id = $_GET['id'];
+ }
+ $this->tpl->assign('group',$id);
+ $tmpmodules = app()->config['modules'];
+ foreach ($tmpmodules as $k => $m) {
+ if ($m != 'admin') {
+ $modules[$m]['name'] = $m;
+ $modules[$m]['actions'] = array_merge(app()->modules[$m]->actions,array('*' => array()));
+ }
+ }
+ $modules['admin']['name'] = 'admin';
+ $modules['admin']['actions'] = array('*' => array());
+ $modules = array_merge($modules,array('*'=> array('name' => '['.tr('ANY').']','actions' => array('*'=> array()))));
$this->tpl->assign('modules',$modules);
- $groups = app()->auth->groupinfo();
- $groups[]='*';
- $this->tpl->assign('groups',$groups);
+ $access['']='-';
$access['allow']=tr('Allow');
$access['deny']=tr('Deny');
$this->tpl->assign('access',$access);
- if (isset($_POST['editaclid'])) {
- $right = app()->db->read('acl',array('id' => $_POST['editaclid']));
- $right = $right[0];
- $right['group_name']=$_POST['editrightgroup'];
- $right['module']=$_POST['editrightmodule'];
- $right['action']=$_POST['editrightaction'];
- $right['access']=$_POST['editrightaccess'];
- app()->db->update('acl',$right,array('id' => $_POST['editaclid']));
- $this->nextStep(1);
- }
- app()->tpl->assign('right',$right);
- }
- function rightdel() {
- global $_GET;
- /* should check if sub users exsist */
- if (isset($_GET['id'])) {
- app()->db->delete('acl',array('id' => $_GET['id']));
- $this->nextStep(1);
+ $acl = array_merge(app()->db->read('acl',array('group_name' => $id),array('module','action'),'',
+ array('group_name','module','action')),
+ app()->db->read('acl',array('group_name' => '*'),array('module','action'),'',
+ array('group_name','module','action')));
+ foreach ($modules as $mk => $m) {
+ foreach ($m['actions'] as $a => $av) {
+ $res = $this->checkAcl($acl,$id,$mk,$a,$comb);
+ if ($res == 'allow') {
+ $rightlist[$id][$mk][$a]['access']=$acl[$id][$mk][$a]['access'];
+ $rightlist[$id][$mk][$a]['result']=tr('Allow');
+ $rightlist[$id][$mk][$a]['comb']=$comb;
+ } else {
+ $rightlist[$id][$mk][$a]['access']=$acl[$id][$mk][$a]['access'];
+ $rightlist[$id][$mk][$a]['result']=tr('Deny');
+ $rightlist[$id][$mk][$a]['comb']=$comb;
+ }
+ }
}
+ $this->tpl->assign('rights',$rightlist);
+ $this->tpl->assign('defaultgroup',app()->config['nologingroup']);
}
function files() {
@@ -330,9 +362,13 @@
global $_GET;
if ($_GET['id']!='') {
- app()->db->delete('files',array('id' => $_GET['id']));
- /* TODO: remove the file */
+ $f = app()->db->read('files',array('id'=>$_GET['id']));
+ if ($f[0]['id']==$_GET['id']) {
+ app()->db->delete('files',array('id' => $_GET['id']));
+ unlink(app()->config['DATA_PATH'].'/'.$_GET['id']);
+ }
}
+ $this->nextStep(1);
}
function filesplugin() {
@@ -409,8 +445,27 @@
}
function pluginoptions() {
+ /* list the plugins */
+ foreach (app()->config['plugins'] as $p) {
+ $list[$p]['name']=$p;
+ $list[$p]['description']=app()->plugins[$p]->description;
+ }
+ $this->tpl->assign('pluginlist',$list);
}
+ function pluginoptiondetail() {
+ }
+
+
+ function pluginoptionadd() {
+ }
+
+ function pluginoptionedit() {
+ }
+
+ function pluginoptiondelete() {
+ }
+
function settings() {
$this->tpl->assign('config',app()->config);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|