phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] [19110] improve: no acl duplication if we are under r


From: Pascal Vilarem
Subject: [Phpgroupware-cvs] [19110] improve: no acl duplication if we are under root folder
Date: Tue, 21 Apr 2009 12:49:38 +0000

Revision: 19110
          
http://svn.sv.gnu.org/viewvc/?view=rev&root=phpgroupware&revision=19110
Author:   maat
Date:     2009-04-21 12:49:37 +0000 (Tue, 21 Apr 2009)
Log Message:
-----------
improve: no acl duplication if we are under root folder
improve: changed a few default values

Modified Paths:
--------------
    modules/ged/trunk/inc/class.ged_dm.inc.php

Modified: modules/ged/trunk/inc/class.ged_dm.inc.php
===================================================================
--- modules/ged/trunk/inc/class.ged_dm.inc.php  2009-03-11 18:31:14 UTC (rev 
19109)
+++ modules/ged/trunk/inc/class.ged_dm.inc.php  2009-04-21 12:49:37 UTC (rev 
19110)
@@ -72,7 +72,9 @@
                
$this->datadir=$GLOBALS['phpgw_info']['server']['files_dir']."/ged-data";
                                
                if ( ! is_dir ( $this->datadir ))
+               {
                        mkdir ( $this->datadir);
+               }
 
                $this->db=$GLOBALS['phpgw']->db;
                
$this->owner=intval($GLOBALS['phpgw_info']['user']['account_id']);
@@ -203,6 +205,7 @@
 
                        $download_result='NOK';
                        print ('NOOK FILE MOVE');
+                       return 'NOK';
 
                }
                
@@ -244,7 +247,7 @@
                        $minor=(int)$new_file['minor'];
                        $draft=(int)$new_file['draft'];
 
-                       $sql1=sprintf($sql_model1, $this->tables['versions'], 
$new_file['file_size'], addslashes($new_file['file_name']), 
addslashes($candidate_name), $extension, 
$GLOBALS['phpgw_info']['user']['account_id'], time(), 'working', 
$new_element_id, lang("First version"), $major, $minor, $draft);
+                       $sql1=sprintf($sql_model1, $this->tables['versions'], 
$new_file['file_size'], addslashes($new_file['file_name']), 
addslashes($candidate_name), $extension, 
$GLOBALS['phpgw_info']['user']['account_id'], time(), 'working', 
$new_element_id, $new_file['descriptionv'], $major, $minor, $draft);
 
                        //print ("<br/>".$sql1);
 
@@ -263,7 +266,7 @@
        {
                $myelement=$this->get_element_info($new_file['element_id']);
                $myparent=$this->get_element_info($myelement['parent_id']);
-
+               
                if ( $this->debug('update_file') )
                        print ( "update_file: entering.<br>\n");
 
@@ -278,7 +281,7 @@
                        $sep=", ";
                }
                        
-               if ( array_key_exists('description', $new_file) && 
$new_file['description'] != '')
+               if ( array_key_exists('description', $new_file) )
                {
                        
$sql.=$sep."description='".$this->cleanstr($new_file['description'])."'";
                        $sep=", ";
@@ -297,13 +300,13 @@
                        
$next_ref=$this->get_next_available_reference($new_file['doc_type'], 
$myelement['project_root'] );
                else
                        $next_ref=$this->cleanstr($new_file['reference']);
-
-               if ( $next_ref != "" && ( $this->admin == true || 
$this->can_write($new_file['element_id'] ) ) )
+               
+               if ( (!isset($newref) || $next_ref != "") && ( $this->admin == 
true || $this->can_write($new_file['element_id'] ) ) )
                {
                        $sql.=$sep."reference='".$next_ref."'";
                        $sep=", ";
                }
-
+                       
                if ( array_key_exists('validity_period', $new_file) )
                        $new_file2['validity_period']= (int) 
$new_file['validity_period'];
                else
@@ -1616,7 +1619,7 @@
                //print ( "element_id =".$element_id);
                //_debug_array($this->acl[$element_id]);
                
-               if ( (isset($this->acl[$element_id]) && 
$this->acl[$element_id]['read'] == 1) || $this->admin == true )
+               if ( (isset($this->acl[$element_id]) && 
$this->acl[$element_id]['read'] == 1) || $this->admin == true || $element_id == 
"0")
                {
                        $result=true;
 
@@ -2029,43 +2032,43 @@
                        //print ( "ensure_read_on_path($element_id, $account_id 
)" );
                        //print ( "<br/>");
 
-                       $element_acl=$this->get_element_acl ( $element_id );
-                                               
-                       if ( isset($element_acl[$account_id]) && 
is_array($element_acl[$account_id]) )
+               $element_acl=$this->get_element_acl ( $element_id );
+                                       
+               if ( isset($element_acl[$account_id]) && 
is_array($element_acl[$account_id]) )
+               {
+                       //print ( "<pre>");
+                       //print_r($element_acl_for_account);
+                       //print ( "</pre>");
+                       $element_acl_for_account=$element_acl[$account_id];
+                       
+                       $aclread=1;
+                       if ( $element_acl_for_account['statuses'] == "")
                        {
-                               //print ( "<pre>");
-                               //print_r($element_acl_for_account);
-                               //print ( "</pre>");
-                               
$element_acl_for_account=$element_acl[$account_id];
-                               
-                               $aclread=1;
-                               if ( $element_acl_for_account['statuses'] == "")
-                               {
-                                       $aclstatuses=array();
-                               }
-                               else
-                               {
-                                       
$aclstatuses=$element_acl_for_account['statuses'];
-                               }
-                               
-                               $aclwrite=$element_acl_for_account['write'];
-                               $acldelete=$element_acl_for_account['delete'];
-                               
$aclchangeacl=$element_acl_for_account['changeacl'];
-                               
-                               //print ( 
"set_acl(".$element_acl_for_account['acl_id'].", $aclread, $aclwrite, 
$aclchangeacl, false, false)" );
-                               //print ( "<br/>");
-                               
$this->set_acl($element_acl_for_account['acl_id'], $aclread, $aclstatuses, 
$aclwrite, $acldelete, $aclchangeacl, false, false);
+                               $aclstatuses=array();
                        }
                        else
                        {
-                               //print ( "new_acl($element_id, $account_id, 1, 
'null', 'null', false, false)" );
-                               //print ( "<br/>");
-                               $this->new_acl($element_id, $account_id, 1, '', 
'null', 'null', 'null', false, false);
+                               
$aclstatuses=$element_acl_for_account['statuses'];
                        }
-               
-               if ( $element_id !="0" )
+                       
+                       $aclwrite=$element_acl_for_account['write'];
+                       $acldelete=$element_acl_for_account['delete'];
+                       $aclchangeacl=$element_acl_for_account['changeacl'];
+                       
+                       //print ( 
"set_acl(".$element_acl_for_account['acl_id'].", $aclread, $aclwrite, 
$aclchangeacl, false, false)" );
+                       //print ( "<br/>");
+                       $this->set_acl($element_acl_for_account['acl_id'], 
$aclread, $aclstatuses, $aclwrite, $acldelete, $aclchangeacl, false, false);
+               }
+               else
                {
-                       $parent_id=$this->get_parent_id($element_id);
+                       //print ( "new_acl($element_id, $account_id, 1, 'null', 
'null', false, false)" );
+                       //print ( "<br/>");
+                       $this->new_acl($element_id, $account_id, 1, '', 'null', 
'null', 'null', false, false);
+               }
+                       
+               $parent_id=$this->get_parent_id($element_id);
+               if ( $element_id !="0" && $parent_id != "0" )
+               {
                        $this->ensure_read_on_path($parent_id, $account_id );
                }
                
@@ -2148,9 +2151,9 @@
                        $this->db->unlock();
                }
                
-               if ( $check_read_on_path && $aclread !='null'  )
+               $parent_id=$this->get_parent_id($element_id);
+               if ( $parent_id != "0" && $check_read_on_path && $aclread 
!='null'  )
                {
-                       $parent_id=$this->get_parent_id($element_id);
                        $this->ensure_read_on_path($parent_id, $account_id);
                }
                
@@ -2165,15 +2168,18 @@
        // Heritage des droits du parent
        function set_default_acl($element_id)
        {               
-               //ihnerit acl from parent
+               // ihnerit acl from parent
+               // except if we are just under ged root folder
                $parent_id=$this->get_parent_id($element_id);
-               
-               $parent_acl=$this->get_element_acl ( $parent_id );
-               if ( is_array($parent_acl)) 
-                       foreach ( $parent_acl as $ac )
-                       {
-                               $this->new_acl($element_id, $ac['account_id'], 
$ac['read'], $ac['statuses'], $ac['write'], $ac['delete'], $ac['changeacl']);
-                       }
+               if ($parent_id != "0");
+               {
+                       $parent_acl=$this->get_element_acl ( $parent_id );
+                       if ( is_array($parent_acl))
+                               foreach ( $parent_acl as $ac )
+                               {
+                                       $this->new_acl($element_id, 
$ac['account_id'], $ac['read'], $ac['statuses'], $ac['write'], $ac['delete'], 
$ac['changeacl']);
+                               }
+               }
        }
        
        function set_acl($acl_id, $aclread, $aclstatuses, $aclwrite, 
$acldelete, $aclchangeacl, $recursive=false, $check_read_on_path=true)
@@ -2262,9 +2268,9 @@
                }
                        
                //Control remontant
-               if ( $check_read_on_path && $aclread !='null'  )
-               {
-                       $parent_id=$this->get_parent_id($element_id);
+               $parent_id=$this->get_parent_id($element_id);
+               if ( $parent_id != "0" && $check_read_on_path && $aclread 
!='null'  )
+               {       
                        $this->ensure_read_on_path($parent_id, 
$acl_info['account_id']);
                }
                
@@ -3112,6 +3118,7 @@
        {               
                
                $i=0;
+               $list=null;
                
                if ( $show_notype == true )
                {
@@ -3165,7 +3172,7 @@
                        
                if($db2->next_record())
                {
-                       $out=$db2->f('type_desc');
+                       $out=$db2->f('type_ref');
                }
                        
                $db2->unlock();         





reply via email to

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