fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [16218] more on eventplanner


From: sigurdne
Subject: [Fmsystem-commits] [16218] more on eventplanner
Date: Wed, 1 Feb 2017 05:44:53 -0500 (EST)

Revision: 16218
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=16218
Author:   sigurdne
Date:     2017-02-01 05:44:52 -0500 (Wed, 01 Feb 2017)
Log Message:
-----------
more on eventplanner

Modified Paths:
--------------
    trunk/eventplanner/inc/class.socustomer.inc.php
    trunk/eventplanner/inc/class.sovendor.inc.php
    trunk/eventplanner/inc/class.uiapplication.inc.php
    trunk/eventplanner/inc/class.uibooking.inc.php
    trunk/eventplanner/inc/model/class.booking.inc.php
    trunk/eventplannerfrontend/inc/class.uibooking.inc.php
    trunk/phpgwapi/inc/class.socommon.inc.php
    trunk/phpgwapi/inc/class.uicommon.inc.php

Modified: trunk/eventplanner/inc/class.socustomer.inc.php
===================================================================
--- trunk/eventplanner/inc/class.socustomer.inc.php     2017-02-01 04:16:07 UTC 
(rev 16217)
+++ trunk/eventplanner/inc/class.socustomer.inc.php     2017-02-01 10:44:52 UTC 
(rev 16218)
@@ -37,6 +37,8 @@
                public function __construct()
                {
                        parent::__construct('eventplanner_customer', 
eventplanner_customer::get_fields());
+                       $this->acl_location = 
eventplanner_customer::acl_location;
+                       $this->use_acl = true;
                }
 
                /**

Modified: trunk/eventplanner/inc/class.sovendor.inc.php
===================================================================
--- trunk/eventplanner/inc/class.sovendor.inc.php       2017-02-01 04:16:07 UTC 
(rev 16217)
+++ trunk/eventplanner/inc/class.sovendor.inc.php       2017-02-01 10:44:52 UTC 
(rev 16218)
@@ -36,6 +36,8 @@
                public function __construct()
                {
                        parent::__construct('eventplanner_vendor', 
eventplanner_vendor::get_fields());
+                       $this->acl_location = eventplanner_vendor::acl_location;
+                       $this->use_acl = true;
                }
 
                /**

Modified: trunk/eventplanner/inc/class.uiapplication.inc.php
===================================================================
--- trunk/eventplanner/inc/class.uiapplication.inc.php  2017-02-01 04:16:07 UTC 
(rev 16217)
+++ trunk/eventplanner/inc/class.uiapplication.inc.php  2017-02-01 10:44:52 UTC 
(rev 16218)
@@ -337,7 +337,7 @@
 
                        $datatable_def[] = array(
                                'container' => 'datatable-container_1',
-                               'requestUrl' => 
json_encode(self::link(array('menuaction' => 
"{$this->currentapp}.uibooking.query",
+                               'requestUrl' => 
json_encode(self::link(array('menuaction' => 
"{$this->currentapp}.uibooking.query_relaxed",
                                        'filter_application_id' => $id,
                                        'filter_active' => 1,
                                        'phpgw_return_as' => 'json'))),

Modified: trunk/eventplanner/inc/class.uibooking.inc.php
===================================================================
--- trunk/eventplanner/inc/class.uibooking.inc.php      2017-02-01 04:16:07 UTC 
(rev 16217)
+++ trunk/eventplanner/inc/class.uibooking.inc.php      2017-02-01 10:44:52 UTC 
(rev 16218)
@@ -38,6 +38,7 @@
                        'add' => true,
                        'index' => true,
                        'query' => true,
+                       'query_relaxed'=> true,
                        'get_list'=> true,
                        'view' => true,
                        'edit' => true,

Modified: trunk/eventplanner/inc/model/class.booking.inc.php
===================================================================
--- trunk/eventplanner/inc/model/class.booking.inc.php  2017-02-01 04:16:07 UTC 
(rev 16217)
+++ trunk/eventplanner/inc/model/class.booking.inc.php  2017-02-01 10:44:52 UTC 
(rev 16218)
@@ -96,6 +96,7 @@
                                        'label' => 'id',
                                        'sortable'=> true,
                                        'formatter' => 
'JqueryPortico.formatLink',
+                                       'public'        => true
                                        ),
                                'owner_id' => array('action'=> PHPGW_ACL_ADD,
                                        'type' => 'int',
@@ -117,6 +118,7 @@
                                        'label' => 'from',
                                        'history' => true,
                                        'required' => true,
+                                       'public'        => true
                                        ),
                                'to_' => array('action'=> PHPGW_ACL_READ | 
PHPGW_ACL_ADD | PHPGW_ACL_EDIT,
                                        'type' => 'date',
@@ -123,6 +125,7 @@
                                        'label' => 'to',
                                        'history' => true,
                                        'required' => true,
+                                       'public'        => true
                                ),
                                'application_id' => array('action'=> 
PHPGW_ACL_ADD | PHPGW_ACL_EDIT,
                                        'type' => 'int',
@@ -129,11 +132,13 @@
                                        'label' => 'application',
                                        'sortable' => true,
                                        'required' => true,
+                                       'public'        => true
                                        ),
                                'application_name' => array('action'=>  
PHPGW_ACL_READ,
                                        'type' => 'string',
                                        'query' => true,
                                        'label' => 'application',
+                                       'public'        => true,
                                        'join' => array(
                                                'table' => 
'eventplanner_application',
                                                'fkey' => 'application_id',
@@ -146,11 +151,13 @@
                                        'label' => 'customer',
                                        'sortable' => true,
                                        'history' => true,
+                                       'public'        => true
                                        ),
                                'customer_name' => array('action'=>  
PHPGW_ACL_READ,
                                        'type' => 'string',
                                        'query' => true,
                                        'label' => 'customer',
+                                       'public'        => true,
                                        'join' => array(
                                                'table' => 
'eventplanner_customer',
                                                'fkey' => 'customer_id',
@@ -190,6 +197,7 @@
                                        'query' => true,
                                        'label' => 'location',
                                        'history' => true,
+                                       'public'        => true
                                        ),
                                'comments' => array(
                                        'action'=> PHPGW_ACL_ADD | 
PHPGW_ACL_EDIT,

Modified: trunk/eventplannerfrontend/inc/class.uibooking.inc.php
===================================================================
--- trunk/eventplannerfrontend/inc/class.uibooking.inc.php      2017-02-01 
04:16:07 UTC (rev 16217)
+++ trunk/eventplannerfrontend/inc/class.uibooking.inc.php      2017-02-01 
10:44:52 UTC (rev 16218)
@@ -20,6 +20,17 @@
                        return $this->jquery_results($values);
                }
 
+               public function query_relaxed()
+               {
+                       $params = $this->bo->build_default_read_params();
+                       $params['relaxe_acl'] = true;
+                       $params['filters']['status'] = 
eventplanner_application::STATUS_APPROVED;
+                       $values = $this->bo->read($params);
+                       array_walk($values["results"], array($this, 
"_add_links"), "eventplannerfrontend.uibooking.edit");
+
+                       return $this->jquery_results($values);
+               }
+
                public function edit()
                {
                        parent::edit();

Modified: trunk/phpgwapi/inc/class.socommon.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.socommon.inc.php   2017-02-01 04:16:07 UTC (rev 
16217)
+++ trunk/phpgwapi/inc/class.socommon.inc.php   2017-02-01 10:44:52 UTC (rev 
16218)
@@ -43,6 +43,7 @@
                protected $use_acl = false;
                protected $currentapp;
                protected $acl;
+               protected $relaxe_acl;
 
                public function __construct( $table_name, $fields )
                {
@@ -210,10 +211,13 @@
                        $dir = isset($params['dir']) && $params['dir'] ? 
$params['dir'] : 'asc';
                        $query = isset($params['query']) && $params['query'] ? 
$params['query'] : null;
                        $filters = isset($params['filters']) && 
$params['filters'] ? $params['filters'] : array();
+                       $relaxe_acl = isset($params['relaxe_acl']) && 
$params['relaxe_acl'] ? $params['relaxe_acl'] : false;
+                       $this->relaxe_acl = $relaxe_acl;
                        $cols_joins = $this->_get_cols_and_joins($filters);
                        $cols = join(',', $cols_joins[0]);
                        $joins = join(' ', $cols_joins[1]);
                        $condition = $this->_get_conditions($query, $filters);
+                       $this->relaxe_acl = false;
 
                        // Calculate total number of records
                        $this->db->query("SELECT count(1) AS count FROM 
$this->table_name $joins WHERE $condition", __LINE__, __FILE__);
@@ -256,6 +260,11 @@
                                $row = array();
                                foreach ($this->fields as $field => $params)
                                {
+                                       if($relaxe_acl && !$params['public'])
+                                       {
+                                               continue;
+                                       }
+
                                        $row[$field] = 
$this->unmarshal($this->db->f($field, false), $params['type']);
                                }
                                $results[] = $row;
@@ -268,6 +277,10 @@
                                }
                                foreach ($this->fields as $field => $params)
                                {
+                                       if($relaxe_acl && !$params['public'])
+                                       {
+                                               continue;
+                                       }
                                        if ($params['manytomany'])
                                        {
                                                $table = 
$params['manytomany']['table'];
@@ -346,7 +359,9 @@
                                $id_value = intval($id_params);
                        }
 
-                       return $this->table_name . '.id=' . $id_value;
+                       $conditions = "{$this->table_name}.id={$id_value}";
+
+                       return $conditions;
                }
 
                function read_single( $id, $return_object = false )
@@ -357,12 +372,34 @@
                        }
                        $row = array();
                        $pk_params = $this->primary_key_conditions($id);
+
+                       $acl_condition = $this->get_acl_condition();
+
                        $cols_joins = $this->_get_cols_and_joins();
                        $cols = join(',', $cols_joins[0]);
                        $joins = join(' ', $cols_joins[1]);
-                       $this->db->query("SELECT $cols FROM $this->table_name 
$joins WHERE $pk_params", __LINE__, __FILE__);
+
+                       /**
+                        * test
+                        */
+                       $acl_test = false;
+                       if($acl_condition)
+                       {
+                               $this->db->query("SELECT DISTINCT {$cols} FROM 
{$this->table_name} {$joins} WHERE {$pk_params} AND {$acl_condition}", 
__LINE__, __FILE__); //DISTINCT: There might be LEFT JOINs..
+                               if ($this->db->next_record())
+                               {
+                                       $acl_test = true;
+                               }
+                       }
+
+                       $this->db->query("SELECT DISTINCT $cols FROM 
$this->table_name $joins WHERE $pk_params", __LINE__, __FILE__); //DISTINCT: 
There might be LEFT JOINs..
                        if ($this->db->next_record())
                        {
+                               if($acl_condition && !$acl_test)
+                               {
+                                       phpgw::no_access();
+                               }
+
                                foreach ($this->fields as $field => $params)
                                {
                                        if (!empty($params['manytomany']))
@@ -523,7 +560,7 @@
                {
                        $clause = '';
 
-                       if($this->use_acl && $this->currentapp && 
$this->acl_location)
+                       if(!$this->relaxe_acl && ($this->use_acl && 
$this->currentapp && $this->acl_location))
                        {
                                $paranthesis = false;
 
@@ -608,7 +645,7 @@
                                }
                        }
 
-                       if($this->use_acl && $this->currentapp && 
$this->acl_location)
+                       if(!$this->relaxe_acl && ($this->use_acl && 
$this->currentapp && $this->acl_location))
                        {
                                $joins[] = " JOIN phpgw_accounts ON 
({$this->table_name}.owner_id = phpgw_accounts.account_id)";
                                $joins[] = " JOIN phpgw_group_map ON 
(phpgw_accounts.account_id = phpgw_group_map.account_id)";

Modified: trunk/phpgwapi/inc/class.uicommon.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.uicommon.inc.php   2017-02-01 04:16:07 UTC (rev 
16217)
+++ trunk/phpgwapi/inc/class.uicommon.inc.php   2017-02-01 10:44:52 UTC (rev 
16218)
@@ -37,6 +37,7 @@
                        'add' => true,
                        'index' => true,
                        'query' => true,
+                       'query_relaxed'=> true,
                        'view' => true,
                        'edit' => true,
                        'save' => true,
@@ -211,7 +212,7 @@
                        }
                }
 
-               private function get_data()
+               private function get_data($relaxe_acl = false)
                {
                        if (empty($this->permissions[PHPGW_ACL_READ]))
                        {
@@ -218,6 +219,7 @@
                                phpgw::no_access();
                        }
                        $params = $this->bo->build_default_read_params();
+                       $params['relaxe_acl'] = $relaxe_acl;
                        return $this->bo->read($params);
                }
 
@@ -225,14 +227,20 @@
                 * (non-PHPdoc)
                 * @see eventplanner/inc/eventplanner_uicommon#query()
                 */
-               public function query()
+               public function query($relaxe_acl = false)
                {
-                       $values = $this->get_data();
+                       $values = $this->get_data($relaxe_acl);
                        array_walk($values["results"], array($this, 
"_add_links"), 
"{$this->called_class_arr[0]}.{$this->called_class_arr[1]}.edit");
 
                        return $this->jquery_results($values);
                }
 
+               public function query_relaxed()
+               {
+                       $relaxe_acl = true;
+                       return $this->query($relaxe_acl);
+               }
+
                /**
                 * Returns a minimum for - let say - autocomplete
                 * @param void




reply via email to

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