phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] api/class.acl.php, 1.1.1.1.2.14


From: nomail
Subject: [Phpgroupware-cvs] api/class.acl.php, 1.1.1.1.2.14
Date: Tue, 6 Jul 2004 09:23:49 +0200

Update of /api
Modified Files:
        Branch: proposal-branch
          class.acl.php

date: 2004/07/06 07:23:49;  author: jengo;  state: Exp;  lines: +127 -15

Log Message:
Initial work to ACL, more info is in the wiki journal
=====================================================================
Index: api/class.acl.php
diff -u api/class.acl.php:1.1.1.1.2.13 api/class.acl.php:1.1.1.1.2.14
--- api/class.acl.php:1.1.1.1.2.13      Sat May  8 06:00:10 2004
+++ api/class.acl.php   Tue Jul  6 07:23:49 2004
@@ -52,11 +52,11 @@
        );
 
        // Some basic common ACL values 
-        define('PHPGW_ACL_READ',1);
-        define('PHPGW_ACL_ADD',2);
-        define('PHPGW_ACL_EDIT',4);
-        define('PHPGW_ACL_DELETE',8);
-        define('PHPGW_ACL_PRIVATE',16);
+        define('PHPGW_ACL_READ',1);
+        define('PHPGW_ACL_ADD',2);
+        define('PHPGW_ACL_EDIT',4);
+        define('PHPGW_ACL_DELETE',8);
+        define('PHPGW_ACL_PRIVATE',16);
         define('PHPGW_ACL_GROUP_MANAGERS',32);
 
        class api_acl
@@ -277,6 +277,8 @@
                        $args->set('type', 0, 'number');
                        $args->set('acl_isop', $this->acl_isop, 'number');
                        $args->set('data', NULL, 'any');
+                       $args->set('acl_id',0,'number');
+                       $args->set('account_id',$this->account_id,'number');
                        $args = $args->get(func_get_args());
 
                        if($args['acl_isop'] == 1 && $args['op'] != '.')
@@ -284,25 +286,113 @@
                                $args['op'] = '.'.$args['op'];
                        }
 
-                       $sql = "SELECT acl_rights FROM phpgw_acl WHERE 
(acl_isop = '".$args['acl_isop']."' ";
-                       $sql .= " and acl_account = ".$this->account_id;
-                       $sql .= " and acl_op = '".$args['op']."' and 
acl_type=".$args['type'].")";
-                       $dbresult = $GLOBALS['phpgw']->db->Execute($sql);
-                       if(!$dbresult->EOF)
+                       $dbresult = $GLOBALS['phpgw']->db->Execute("
+                               SELECT
+                                       acl_rights
+                               FROM
+                                       phpgw_acl
+                               WHERE
+                               (
+                                               acl_isop = '" . 
$args['acl_isop'] . "'
+                                       AND
+                                               acl_account = " . 
$args['account_id'] . "
+                                       AND
+                                               acl_op = '" . $args['op'] . "'
+                                       AND
+                                               acl_type=" . $args['type'] . "
+                               )
+                       ");
+
+                       if (! $dbresult->EOF)
                        {
                                $newrights = $this->bit_set($args['rights'], 
(int)$dbresult->fields['acl_rights']);
-                               $sql = "UPDATE phpgw_acl SET acl_rights 
=".$newrights;
-                               $sql .= " WHERE acl_host=".$this->host_id." AND 
acl_isop=".$args['acl_isop']." AND acl_account=".$this->account_id." AND 
acl_op='".$args['op']."' AND acl_type=".$args['type'];
+                               $sql = "
+                                       UPDATE
+                                               phpgw_acl
+                                       SET
+                                               acl_rights=" . $newrights . "
+                                       WHERE
+                                               acl_host=" . $this->host_id . "
+                                       AND
+                                               acl_isop=" . $args['acl_isop'] 
. "
+                                       AND
+                                               acl_account=" . 
$args['account_id'] . "
+                                       AND
+                                               acl_op='" . $args['op'] . "'
+                                       AND
+                                               acl_type=" . $args['type'] . "
+                                       AND
+                                               acl_id=" . $args['acl_id'];
                        }
                        else
                        {
-                               $sql = "INSERT INTO phpgw_acl 
(acl_host,acl_isop,acl_account,acl_op,acl_rights,acl_type,acl_data) VALUES 
(".$this->host_id.",".$args['acl_isop'].",".$this->account_id.",'".$args['op']."',".$args['rights'].",".$args['type'].",'".$args['data']."')";
+                               $sql = "
+                                       INSERT INTO
+                                               phpgw_acl
+                                       (
+                                               acl_host,
+                                               acl_isop,
+                                               acl_account,
+                                               acl_op,
+                                               acl_rights,
+                                               acl_type,
+                                               acl_data,
+                                               acl_id
+                                       )
+                                       VALUES
+                                       (
+                                               " . $this->host_id . ",
+                                               " . $args['acl_isop'] . ",
+                                               " . $args['account_id'] . ",
+                                               '" . $args['op'] . "',
+                                               " . $args['rights'] . ",
+                                               " . $args['type'] . ",
+                                               '" . $args['data'] . "',
+                                               " . $args['acl_id'] . "
+                                       )
+                               ";
                        }
                        $GLOBALS['phpgw']->db->Execute($sql);
                        $this->rights_cache = Array();
                        $this->masks_cache = Array();
                }
 
+               function _get_location()
+               {
+                       $args = new safe_args();
+                       $args->set('location',REQUIRED,'alphanumeric');
+                       extract($args->get(func_get_args()));
+
+                       $dbresult = $GLOBALS['phpgw']->db->execute("
+                               SELECT
+                                       acl_id,
+                                       acl_account,
+                                       acl_rights,
+                                       acl_data
+                               FROM
+                                       phpgw_acl
+                               WHERE
+                                       acl_op='." . $location . "'
+                       ");
+
+                       if (is_object($dbresult))
+                       {
+                               while (! $dbresult->EOF)
+                               {
+                                       $result[] = array
+                                       (
+                                               'acl_id'      => 
$dbresult->fields['acl_id'],
+                                               'acl_account' => 
$dbresult->fields['acl_account'],
+                                               'acl_rights'  => 
$dbresult->fields['acl_rights'],
+                                               'acl_data'    => 
$dbresult->fields['acl_data']
+                                       );
+                                       $dbresult->movenext();
+                               }
+                       }
+
+                       return $result;
+               }
+
                function set()
                {
                        $args = new safe_args();
@@ -339,7 +429,29 @@
                        {
                                if($args['rights'] != 0)
                                {
-                                       $sql = "INSERT INTO phpgw_acl 
(acl_host,acl_isop,acl_account,acl_op,acl_rights,acl_type,acl_data) VALUES 
(".$this->host_id.",".$args['acl_isop'].",".$this->account_id.",'".$args['op']."',".$args['rights'].",".$args['type'].",'".$args['data']."')";
+                                       $sql = "INSERT INTO
+                                                       phpgw_acl
+                                               (
+                                                       acl_host,
+                                                       acl_isop,
+                                                       acl_account,
+                                                       acl_op,
+                                                       acl_rights,
+                                                       acl_type,
+                                                       acl_data,
+                                                       acl_id
+                                               )
+                                               VALUES
+                                               (
+                                                       " . $this->host_id . ",
+                                                       " . $args['acl_isop'] . 
",
+                                                       " . $this->account_id . 
",
+                                                       '" . $args['op'] . "',
+                                                       " . $args['rights'] . ",
+                                                       " . $args['type'] . ",
+                                                       '" . $args['data'] . "',
+                                                       0
+                                               )";
                                        $GLOBALS['phpgw']->db->Execute($sql);
                                }
                        }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]