fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [13823] more on custom fields


From: Sigurd Nes
Subject: [Fmsystem-commits] [13823] more on custom fields
Date: Tue, 01 Sep 2015 13:32:47 +0000

Revision: 13823
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=13823
Author:   sigurdne
Date:     2015-09-01 13:32:46 +0000 (Tue, 01 Sep 2015)
Log Message:
-----------
more on custom fields

Modified Paths:
--------------
    branches/dev-syncromind/admin/inc/class.bo_custom.inc.php
    branches/dev-syncromind/admin/inc/class.ui_custom.inc.php
    branches/dev-syncromind/admin/templates/base/custom.xsl
    branches/dev-syncromind/phpgwapi/inc/class.phpgw.inc.php
    branches/dev-syncromind/phpgwapi/setup/phpgw_en.lang
    branches/dev-syncromind/phpgwapi/setup/phpgw_no.lang
    branches/dev-syncromind/preferences/inc/class.boadmin_acl.inc.php

Modified: branches/dev-syncromind/admin/inc/class.bo_custom.inc.php
===================================================================
--- branches/dev-syncromind/admin/inc/class.bo_custom.inc.php   2015-09-01 
10:28:58 UTC (rev 13822)
+++ branches/dev-syncromind/admin/inc/class.bo_custom.inc.php   2015-09-01 
13:32:46 UTC (rev 13823)
@@ -142,6 +142,16 @@
                        }
                }
 
+               public function delete_attrib_group($appname = '', $location = 
'', $group_id = 0)
+               {
+                       if ( !$appname || !$location || !$group_id  )
+                       {
+                               return;
+                       }
+
+                       return $this->so->delete_group($appname, $location, 
$group_id);
+               }
+
                function get_attribs($appname = '',$location = '', $allrows = 
null)
                {
                        if ( !is_null($allrows) )

Modified: branches/dev-syncromind/admin/inc/class.ui_custom.inc.php
===================================================================
--- branches/dev-syncromind/admin/inc/class.ui_custom.inc.php   2015-09-01 
10:28:58 UTC (rev 13822)
+++ branches/dev-syncromind/admin/inc/class.ui_custom.inc.php   2015-09-01 
13:32:46 UTC (rev 13823)
@@ -36,6 +36,8 @@
                        'edit_custom_function'   => true,
                        'list_attribute_group'   => true,
                        'edit_attrib_group'              => true,
+                       'query_attrib_group'     => true,
+                       'delete_attrib_group'    => true
                );
 
                public function __construct()
@@ -821,36 +823,62 @@
                        $GLOBALS['phpgw']->xslttpl->set_var('phpgw', 
array('delete' => $data));
                }
 
-               function list_attribute_group()
+               function delete_attrib_group()
                {
+                       $acl_delete      = $this->acl->check($this->location, 
PHPGW_ACL_DELETE, $this->appname);
 
-                       $location = phpgw::get_var('location', 'string');
+                       if(!$acl_delete)
+                       {
+                               return "NO ACCESS";
+                       }
 
-                       if($location && !$this->acl_read)
+                       $group_id                        = 
phpgw::get_var('group_id', 'int');
+                       $confirm                         = 
phpgw::get_var('confirm', 'bool', 'POST');
+
+                       if(phpgw::get_var('phpgw_return_as') == 'json')
                        {
-                               phpgwapi_cache::message_set("Go away...", 
'error');
-                               return;
+                               $this->bo->delete_attrib_group($this->appname, 
$this->location, $group_id);
+                               return lang("this record has been deleted");
+                       }
+               }
 
-//                             $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'property.uilocation.stop',
-//                                     'perm' => 1, 'acl_location' => 
$this->acl_location));
+               function query_attrib_group()
+               {
+                       if(!$this->acl_read)
+                       {
+                               phpgw::no_access($this->appname);
                        }
 
+                       if($location = 
phpgwapi_cache::session_get('admin_custom', 'location'))
+                       {
+                               $this->location = $location;
+                               phpgwapi_cache::session_clear('admin_custom', 
'location');
+                       }
+
                        $id              = phpgw::get_var('id', 'int');
                        $resort  = phpgw::get_var('resort');
+                       if($resort && $this->acl_edit)
+                       {
+                               phpgwapi_cache::session_set('admin_custom', 
'location', $this->location);
+                               $this->bo->resort_attrib_group($id, $resort);
+                       }
 
-                       if(phpgw::get_var('phpgw_return_as') == 'json')
+                       return $this->query(array
+                       (
+                               'method'         => 'list_attribute_group',
+                               'location'       => $this->location,
+                       ));
+
+               }
+
+               function list_attribute_group()
+               {
+                       if(!$this->acl_read)
                        {
-                               if($resort)
-                               {
-                                       $this->bo->resort_attrib_group($id, 
$resort);
-                               }
+                               phpgw::no_access($this->appname);
+                       }
+                       phpgwapi_cache::session_set('admin_custom', 'location', 
phpgw::get_var('location', 'string'));
 
-                               return $this->query(array
-                                       (
-                                       'method'         => 
'list_attribute_group',
-                                       'location'       => $location,
-                               ));
-                       }
                        $location_list = 
$this->bolocation->select_location('filter', $this->location, false, true);
                        foreach($location_list as &$entry)
                        {
@@ -880,7 +908,6 @@
                                                                        
'menuaction' => 'admin.ui_custom.edit_attrib_group',
                                                                        
'appname'        => $this->appname,
                                                                        
'menu_selection'         => $this->menu_selection
-//                                                                     
'location'       => $location,
                                                                )),
                                                                'class'  => 
'new_item'
                                                        ),
@@ -889,7 +916,7 @@
                                ),
                                'datatable'              => array(
                                        'source'                 => 
self::link(array(
-                                               'menuaction'             => 
'admin.ui_custom.list_attribute_group',
+                                               'menuaction'             => 
'admin.ui_custom.query_attrib_group',
                                                'appname'                       
 => $this->appname,
                                                'phpgw_return_as'        => 
'json'
                                        )),
@@ -1015,7 +1042,7 @@
                                (
                                '/index.php', array
                                        (
-                                       'menuaction'     => 
'admin.ui_custom.delete_group',
+                                       'menuaction'     => 
'admin.ui_custom.delete_attrib_group',
                                        'menu_selection'         => 
$this->menu_selection
                                )
                                ),
@@ -1063,14 +1090,12 @@
                {
                        if(!$this->acl_add)
                        {
-                               phpgwapi_cache::message_set("Go away...", 
'error');
-                               return;
-
-//                             $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'property.uilocation.stop',
-//                                     'perm' => 2, 'acl_location' => 
$this->acl_location));
+                               phpgw::no_access($this->appname);
                        }
-                       $location = phpgw::get_var('location', 'string');
 
+                       $location = $this->location;
+                       $appname = $this->appname;
+
                        $id              = phpgw::get_var('id', 'int');
                        $values  = phpgw::get_var('values');
 
@@ -1093,12 +1118,23 @@
 
                                if($id)
                                {
+                                       if(!$this->acl->check($this->location, 
PHPGW_ACL_EDIT, $this->appname))
+                                       {
+                                          phpgw::no_access($this->appname);
+                                       }
                                        $values['id']    = $id;
                                        $action                  = 'edit';
                                }
+                               else
+                               {
+                                       if(!$this->acl->check($this->location, 
PHPGW_ACL_ADD, $this->appname))
+                                       {
+                                          phpgw::no_access($this->appname);
+                                       }
+                               }
 
                                $values['location'] = $location;
-                               $values['appname'] = $this->appname;
+                               $values['appname'] = $appname;
 
                                if(!$values['group_name'])
                                {
@@ -1133,7 +1169,7 @@
 
                        if($id)
                        {
-                               $values                  = 
$this->bo->read_single_attrib_group($this->appname, $location, $id);
+                               $values                  = 
$this->bo->read_single_attrib_group($appname, $location, $id);
                                $type_name               = $values['type_name'];
                                $function_msg    = lang('edit attribute group') 
. ' ' . lang($type_name);
                                $action                  = 'edit';
@@ -1145,14 +1181,13 @@
                        }
 
 
-                       $location_id = 
$GLOBALS['phpgw']->locations->get_id($this->appname, $location);
+                       $location_id = 
$GLOBALS['phpgw']->locations->get_id($appname, $location);
 
-                       $parent_list = 
$GLOBALS['phpgw']->custom_fields->find_group($this->appname, $location, 0, '', 
'', '', true);
+                       $parent_list = 
$GLOBALS['phpgw']->custom_fields->find_group($appname, $location, 0, '', '', 
'', true);
 
                        $bocommon = CreateObject('property.bocommon');
 
                        $parent_list = 
$bocommon->select_list($values['parent_id'], $parent_list);
-//_debug_array($parent_list);die();
 
                        if($id)
                        {
@@ -1175,37 +1210,32 @@
                        }
 
                        $link_data = array
-                               (
+                       (
                                'menuaction'             => 
'admin.ui_custom.edit_attrib_group',
-                               'appname'                        => 
$this->appname,
+                               'appname'                        => $appname,
                                'id'                             => $id,
                                'menu_selection'         => 
$this->menu_selection
                        );
 
-
-                       //              $entity          = 
$this->bo->read_single($entity_id, false);
-                       //              $category        = 
$this->bo->read_single_category($entity_id, $cat_id);
-
                        $msgbox_data = (isset($receipt) ? 
$bocommon->msgbox_data($receipt) : '');
 
                        $data = array
                        (
-                               'appname'                                       
 => $this->appname,
+                               'appname'                                       
 => $appname,
                                'value_location'                         => 
$location,
                                'msgbox_data'                            => 
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
                                'form_action'                            => 
$GLOBALS['phpgw']->link('/index.php', $link_data),
                                'done_action'                            => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'admin.ui_custom.list_attribute_group',
-                                                                               
                'appname'        => $this->appname,
-                                                                               
                'location'       => $location,
-                                                                               
                'menu_selection'         => $this->menu_selection)),
+                                                                               
                'appname'               => $appname,
+                                                                               
                'menu_selection'=> $this->menu_selection)),
                                'value_id'                                      
 => $id,
                                'value_group_name'                       => 
$values['group_name'],
                                'value_descr'                            => 
$values['descr'],
                                'value_remark'                           => 
$values['remark'],
-                               'parent_list'                            => 
$parent_list,
+                               'parent_list'                            => 
array('options' => $parent_list),
                                'select_name_location'           => 'location',
                                'select_location_required'       => true,
-                               'location_list' => 
$this->bolocation->select_location('select', $location, false, true),
+                               'location_list'                          => 
array('options' => $this->bolocation->select_location('select', $location, 
false, true)),
                                'tabs'                                          
 => phpgwapi_jquery::tabview_generate($tabs, $active_tab),
                                'validator'                                     
 => phpgwapi_jquery::formvalidator_generate(array('location',
                                        'date', 'security', 'file'))
@@ -1213,7 +1243,7 @@
                        //_debug_array($values);
 
 
-                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang($this->appname) . ' - ' . $location . ': ' . $function_msg;
+                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang($appname) . ' - ' . $location . ': ' . $function_msg;
                        $GLOBALS['phpgw']->xslttpl->set_var('phpgw', 
array('edit_attrib_group' => $data));
                }
 
@@ -1287,7 +1317,7 @@
                                        break;
                                case 'list_attribute_group':
                                        $variable        = array(
-                                               'menuaction' => 
'admin.ui_custom.list_attribute_group',
+                                               'menuaction' => 
'admin.ui_custom.query_attrib_group',
                                                'appname'                => 
$this->appname,
                                                'location'               => 
$this->location,
                                                'allrows'                => 
$this->allrows,

Modified: branches/dev-syncromind/admin/templates/base/custom.xsl
===================================================================
--- branches/dev-syncromind/admin/templates/base/custom.xsl     2015-09-01 
10:28:58 UTC (rev 13822)
+++ branches/dev-syncromind/admin/templates/base/custom.xsl     2015-09-01 
13:32:46 UTC (rev 13823)
@@ -593,7 +593,15 @@
                                                        <input type="hidden" 
name="location" value="{value_location}" />
                                                </xsl:when>
                                                <xsl:otherwise>
-                                                       <xsl:call-template 
name="select_location"/>
+                                                       <select id="location" 
name="location"  data-validation="required" >
+                                                               <xsl:attribute 
name="data-validation-error-msg">
+                                                                       
<xsl:value-of select="php:function('lang', 'location')"/>
+                                                               </xsl:attribute>
+                                                               <option 
value="">
+                                                                       
<xsl:value-of select="php:function('lang', 'select')"/>
+                                                               </option>
+                                                               
<xsl:apply-templates select="location_list/options"/>
+                                                       </select>
                                                </xsl:otherwise>
                                        </xsl:choose>
                                </div>
@@ -617,7 +625,7 @@
                                                                <option 
value="">
                                                                        
<xsl:value-of select="php:function('lang', 'select parent')"/>
                                                                </option>
-                                                               
<xsl:apply-templates select="parent_list"/>
+                                                               
<xsl:apply-templates select="parent_list/options"/>
                                                        </select>
                                                </div>
                                        </xsl:when>
@@ -682,6 +690,7 @@
                        <xsl:value-of select="php:function('lang', 'done')"/>
                </xsl:variable>
                <form method="post" action="{$done_action}">
+                       <input type="hidden" name="location" 
value="{value_location}" />
                        <input type="submit" class="pure-button 
pure-button-primary" name="done" value="{$lang_done}">
                                <xsl:attribute name="title">
                                        <xsl:value-of 
select="php:function('lang', 'Back to the list')"/>

Modified: branches/dev-syncromind/phpgwapi/inc/class.phpgw.inc.php
===================================================================
--- branches/dev-syncromind/phpgwapi/inc/class.phpgw.inc.php    2015-09-01 
10:28:58 UTC (rev 13822)
+++ branches/dev-syncromind/phpgwapi/inc/class.phpgw.inc.php    2015-09-01 
13:32:46 UTC (rev 13823)
@@ -529,4 +529,20 @@
                                        trigger_error(lang('Unable to load 
class: %1', $classname), E_USER_ERROR);
                                }
                        }
+
+                       /**
+                        * Display a message - and quit.
+                        * @param string $appname
+                        * @param string $message
+                        */
+                       public static function no_access($appname = '', 
$message = '')
+                       {
+                               $GLOBALS['phpgw_info']['flags']['xslt_app'] = 
false;
+                               $message = $message ? $message : lang('no 
access');
+                               $appname = $appname ? $appname : 
$GLOBALS['phpgw_info']['flags']['currentapp'];
+                               phpgwapi_cache::message_set($message, 'error');
+                               $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang($appname) . '::' . lang('No access');
+                               $GLOBALS['phpgw']->common->phpgw_header(true);
+                               $GLOBALS['phpgw']->common->phpgw_exit();
+                       }
                }

Modified: branches/dev-syncromind/phpgwapi/setup/phpgw_en.lang
===================================================================
--- branches/dev-syncromind/phpgwapi/setup/phpgw_en.lang        2015-09-01 
10:28:58 UTC (rev 13822)
+++ branches/dev-syncromind/phpgwapi/setup/phpgw_en.lang        2015-09-01 
13:32:46 UTC (rev 13823)
@@ -549,4 +549,5 @@
 yugoslavia     common  en      YUGOSLAVIA
 zambia common  en      ZAMBIA
 zimbabwe       common  en      ZIMBABWE
-browser not supported  common  en      The browser seems to not support HTML5
\ No newline at end of file
+browser not supported  common  en      The browser seems to not support HTML5
+no access      common  en      No Access
\ No newline at end of file

Modified: branches/dev-syncromind/phpgwapi/setup/phpgw_no.lang
===================================================================
--- branches/dev-syncromind/phpgwapi/setup/phpgw_no.lang        2015-09-01 
10:28:58 UTC (rev 13822)
+++ branches/dev-syncromind/phpgwapi/setup/phpgw_no.lang        2015-09-01 
13:32:46 UTC (rev 13823)
@@ -154,4 +154,5 @@
 datatype       common  no      Datatype
 sorting        common  no      Sortering
 up     common  no      opp
-down   common  no      ned
\ No newline at end of file
+down   common  no      ned
+no access      common  no      Ingen Tilgang
\ No newline at end of file

Modified: branches/dev-syncromind/preferences/inc/class.boadmin_acl.inc.php
===================================================================
--- branches/dev-syncromind/preferences/inc/class.boadmin_acl.inc.php   
2015-09-01 10:28:58 UTC (rev 13822)
+++ branches/dev-syncromind/preferences/inc/class.boadmin_acl.inc.php   
2015-09-01 13:32:46 UTC (rev 13823)
@@ -144,10 +144,10 @@
                        $location_list = array();
 
                        $locations = 
$GLOBALS['phpgw']->locations->get_locations($grant, $this->acl_app, 
$allow_c_attrib, $allow_c_functions);
-
                        $i = 0;
                        foreach ( $locations as $loc_id => $loc_descr )
                        {
+                               $name = "{$loc_id} [{$loc_descr}]";
                                $sel_loc = '';
                                if ($loc_id == $selected)
                                {
@@ -157,7 +157,8 @@
                                $location_list[$i] = array
                                (
                                        'id'            => $loc_id,
-                                       'descr'         => "{$loc_id} 
[{$loc_descr}]",
+                                       'name'          => $name,
+                                       'descr'         => $name,
                                        'selected'      => $sel_loc
                                );
 




reply via email to

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