fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [7228] property: more on custom menues


From: Sigurd Nes
Subject: [Fmsystem-commits] [7228] property: more on custom menues
Date: Fri, 15 Apr 2011 13:43:55 +0000

Revision: 7228
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=7228
Author:   sigurdne
Date:     2011-04-15 13:43:54 +0000 (Fri, 15 Apr 2011)
Log Message:
-----------
property: more on custom menues

Modified Paths:
--------------
    trunk/property/inc/class.menu.inc.php
    trunk/property/inc/class.sogeneric.inc.php
    trunk/property/setup/setup.inc.php
    trunk/property/setup/tables_current.inc.php
    trunk/property/setup/tables_update.inc.php

Modified: trunk/property/inc/class.menu.inc.php
===================================================================
--- trunk/property/inc/class.menu.inc.php       2011-04-15 11:51:34 UTC (rev 
7227)
+++ trunk/property/inc/class.menu.inc.php       2011-04-15 13:43:54 UTC (rev 
7228)
@@ -882,6 +882,9 @@
                                        );
                        }
 
+                       $custom_menus = CreateObject('property.sogeneric');
+                       
$custom_menus->get_location_info('custom_menu_items',false);
+
                        if ( $acl->check('.document', PHPGW_ACL_READ, 
'property') )
                        {
                                $laws_url = 
$GLOBALS['phpgw']->link('/redirect.php',array('go' => 
urlencode('http://www.regelhjelp.no/')));
@@ -926,8 +929,6 @@
                                                'text'  => lang('gallery')
                                        );
 
-                               $custom_menus = 
CreateObject('property.sogeneric');
-                               
$custom_menus->get_location_info('custom_menu_items',false);
                                $custom_menu_items= 
$custom_menus->read(array('type' => 'custom_menu_items' , 'filter' => 
array('location' => '.document')));
                                foreach($custom_menu_items as $item)
                                {
@@ -971,6 +972,30 @@
                                                {
                                                        
$menus['navigation']["entity_{$entry['id']}"]['children'] = 
$entity->read_category_tree($entry['id'],'property.uientity.index', 
PHPGW_ACL_READ);
                                                }
+
+/*
+                                               $custom_menu_items= 
$custom_menus->read_tree(array('type' => 'custom_menu_items' , 'filter' => 
array('location' => ".entity.{$entry['id']}")));
+
+                                               if($custom_menu_items)
+                                               {
+                                                       
$menus['navigation']["entity_{$entry['id']}"]['children'][] = 
$custom_menu_items;
+                                               }
+*/
+/*
+                                               foreach($custom_menu_items as 
$item)
+                                               {
+                                                       if($item['local_files'])
+                                                       {
+                                                               $item['url'] = 
'file:///' . str_replace(':','|',$item['url']);
+                                                       }
+                                                       
$menus['navigation']["entity_{$entry['id']}"]['children'][] = array
+                                                               (
+                                                                       'url'   
=> $item['url'],
+                                                                       'text'  
=> $item['name'],
+                                                                       
'target'=> '_blank'
+                                                               );
+                                               }
+*/
                                        }
                                }
                        }

Modified: trunk/property/inc/class.sogeneric.inc.php
===================================================================
--- trunk/property/inc/class.sogeneric.inc.php  2011-04-15 11:51:34 UTC (rev 
7227)
+++ trunk/property/inc/class.sogeneric.inc.php  2011-04-15 13:43:54 UTC (rev 
7228)
@@ -45,6 +45,7 @@
                        $this->account  = 
$GLOBALS['phpgw_info']['user']['account_id'];
                        $this->custom   = 
createObject('property.custom_fields');
                        $this->_db              = & $GLOBALS['phpgw']->db;
+                       $this->_db2             = clone($this->_db);
                        $this->_like    = & $this->_db->like;
                        $this->_join    = & $this->_db->join;
                }
@@ -1874,6 +1875,22 @@
                                                (
                                                        array
                                                        (
+                                                               'name'          
        => 'parent_id',
+                                                               'descr'         
        => lang('parent'),
+                                                               'type'          
        => 'select',
+                                                               'sortable'      
        => true,
+                                                               'nullable'      
        => true,
+                                                               'filter'        
        => false,
+                                                               'role'          
        => 'parent',
+                                                               'values_def'    
=> array
+                                                               (
+                                                                       
'valueset'              => false,
+                                                                       
'method'                => 'property.bogeneric.get_list',
+                                                                       
'method_input'  => array('type' => 'custom_menu_items', 'role' => 'parent', 
'selected' => '##parent_id##')
+                                                               )
+                                                       ),
+                                                       array
+                                                       (
                                                                'name' => 
'name',
                                                                'descr' => 
lang('name'),
                                                                'type' => 
'varchar'
@@ -2535,7 +2552,124 @@
                        return $this->tree;
                } 
 
+
                /**
+                * used for retrive a child-node from a hierarchy
+                *
+                * @param integer $entity_id Entity id
+                * @param integer $parent is the parent of the children we want 
to see
+                * @param integer $level is increased when we go deeper into 
the tree,
+                * @return array $child Children
+                */
+
+               protected function get_children($data, $parent, $level)
+               {       
+                       $children = array();
+
+                       $this->get_location_info($data['type'], 
$data['type_id']);
+
+                       if (!isset($this->location_info['table']) || !$table = 
$this->location_info['table'])
+                       {
+                               return $children;
+                       }
+                       $this->table = $table;
+
+                       $filtermthod = 'WHERE parent_id = ' . (int)$parent;
+
+                       $sql = "SELECT * FROM {$table} {$filtermthod} ORDER BY 
name ASC";
+                       $this->_db2->query($sql,__LINE__,__FILE__);
+
+                       $fields = array(0 => 'id');
+                       foreach ($this->location_info['fields'] as $field)
+                       {
+                               $fields[] = $field['name'];
+                       }
+
+                       while ($this->_db2->next_record())
+                       {
+                               $id     = $this->_db2->f('id');
+                               foreach($fields as $field)
+                               {
+                                       $children[$id][$field] = 
$this->_db2->f($field,true);
+                               }
+                       }
+
+                       foreach($children as &$child)
+                       {
+                               $_children = $this->get_children($data, 
$child['id'], $level+1);
+                               if($_children)
+                               {
+                                       $child['children'] = $_children;
+                               }
+                       }
+                       return $children;
+               } 
+
+
+               public function read_tree($data)
+               {
+                       $tree = array();
+
+                       $this->get_location_info($data['type'], 
$data['type_id']);
+
+                       if (!isset($this->location_info['table']) || !$table = 
$this->location_info['table'])
+                       {
+                               return $tree;
+                       }
+                       $this->table = $table;
+
+                       $filtermthod = 'WHERE (parent_id = 0 OR parent_id IS 
NULL)';
+
+                       if (isset($data['filter']) && is_array($data['filter']))
+                       {
+                               $_filter = array();
+                               foreach ($data['filter'] as $_field => $_value)
+                               {
+                                       $_filter[] = "{$_field} = '{$_value}'";
+                               }
+                               if($_filter)
+                               {
+                                       $filtermthod .= ' AND ' . implode(' AND 
', $_filter);
+                               }
+                       }
+
+                       $sql = "SELECT * FROM {$table} {$filtermthod}";
+
+                       $this->_db2->query($sql,__LINE__,__FILE__);
+                       $this->total_records = $this->_db2->num_rows();
+
+                       $fields = array(0 => 'id');
+                       foreach ($this->location_info['fields'] as $field)
+                       {
+                               $fields[] = $field['name'];
+                       }
+                       $node = array();
+                       while ($this->_db2->next_record())
+                       {
+                               $id     = $this->_db2->f('id');
+                               
+                               foreach($fields as $field)
+                               {
+                                       $tree[$id][$field] = 
$this->_db2->f($field,true);
+                               }
+                       }
+
+                       foreach($tree as &$node)
+                       {
+                               $children = $this->get_children($data, 
$node['id'], 0);
+                               if ($children)
+                               {
+                                       $node['children'] = $children;
+                               }
+                       }
+if($tree)
+{
+//     _debug_array($tree);die();
+}
+                       return $tree;
+               }
+
+               /**
                 * used for retrive the path for a particular node from a 
hierarchy
                 *
                 * @param integer $node is the id of the node we want the path 
of

Modified: trunk/property/setup/setup.inc.php
===================================================================
--- trunk/property/setup/setup.inc.php  2011-04-15 11:51:34 UTC (rev 7227)
+++ trunk/property/setup/setup.inc.php  2011-04-15 13:43:54 UTC (rev 7228)
@@ -12,7 +12,7 @@
        */
 
        $setup_info['property']['name']                 = 'property';
-       $setup_info['property']['version']              = '0.9.17.615';
+       $setup_info['property']['version']              = '0.9.17.616';
        $setup_info['property']['app_order']    = 8;
        $setup_info['property']['enable']               = 1;
        $setup_info['property']['app_group']    = 'office';

Modified: trunk/property/setup/tables_current.inc.php
===================================================================
--- trunk/property/setup/tables_current.inc.php 2011-04-15 11:51:34 UTC (rev 
7227)
+++ trunk/property/setup/tables_current.inc.php 2011-04-15 13:43:54 UTC (rev 
7228)
@@ -2220,6 +2220,7 @@
                'fm_custom_menu_items' => array(
                        'fd' => array(
                                'id' => array('type' => 'auto', 'precision' => 
4,'nullable' => False),
+                               'parent_id' => array('type' => 
'int','precision' => '4','nullable' => True),
                                'name' => array('type' => 'varchar', 
'precision' => 200,'nullable' => False),
                                'url' => array('type' => 'text','nullable' => 
True),
                                'location' => array('type' => 'varchar', 
'precision' => 200,'nullable' => False),

Modified: trunk/property/setup/tables_update.inc.php
===================================================================
--- trunk/property/setup/tables_update.inc.php  2011-04-15 11:51:34 UTC (rev 
7227)
+++ trunk/property/setup/tables_update.inc.php  2011-04-15 13:43:54 UTC (rev 
7228)
@@ -5201,7 +5201,27 @@
                }
        }
 
+       /**
+       * Update property version from 0.9.17.615 to 0.9.17.616
+       * Enable hierarchy to custom menu
+       * 
+       */
 
+       $test[] = '0.9.17.615';
+       function property_upgrade0_9_17_615()
+       {
+               $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+
+               
$GLOBALS['phpgw_setup']->oProc->AddColumn('fm_custom_menu_items','parent_id', 
array('type' => 'int','precision' => '4','nullable' => True));
+
+               if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
+               {
+                       $GLOBALS['setup_info']['property']['currentver'] = 
'0.9.17.616';
+                       return $GLOBALS['setup_info']['property']['currentver'];
+               }
+       }
+
+
        /**
        * Update property version from 0.9.17.607 to 0.9.17.608
        * Add more room for address at tickets




reply via email to

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