fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [17296] check for unique cat-names


From: sigurdne
Subject: [Fmsystem-commits] [17296] check for unique cat-names
Date: Sat, 11 Nov 2017 11:56:36 -0500 (EST)

Revision: 17296
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=17296
Author:   sigurdne
Date:     2017-11-11 11:56:35 -0500 (Sat, 11 Nov 2017)
Log Message:
-----------
check for unique cat-names

Modified Paths:
--------------
    trunk/admin/inc/class.bocategories.inc.php
    trunk/phpgwapi/inc/class.categories.inc.php

Modified: trunk/admin/inc/class.bocategories.inc.php
===================================================================
--- trunk/admin/inc/class.bocategories.inc.php  2017-11-11 16:56:02 UTC (rev 
17295)
+++ trunk/admin/inc/class.bocategories.inc.php  2017-11-11 16:56:35 UTC (rev 
17296)
@@ -171,6 +171,7 @@
                                        $exists = $this->exists(array
                                        (
                                                'type'     => 'appandsubs',
+                                               'cat_parent' => 
$values['parent'],
                                                'cat_name' => $values['name'],
                                                'cat_id'   => $values['cat_id']
                                        ));

Modified: trunk/phpgwapi/inc/class.categories.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.categories.inc.php 2017-11-11 16:56:02 UTC (rev 
17295)
+++ trunk/phpgwapi/inc/class.categories.inc.php 2017-11-11 16:56:35 UTC (rev 
17296)
@@ -58,7 +58,7 @@
                * @param string $type Can be 'subs', 'mains', 'appandmains', 
'appandsubs', 'noglobal' or 'noglobalapp'
                * @return string|boolean Part of SQL where clause or false
                */
-               function filter($type)
+               function filter($type, $cat_parent = 0)
                {
                        
                        $filter_location = '';
@@ -79,7 +79,14 @@
                                        $s = " AND 
cat_appname='{$this->app_name}' {$filter_location} AND cat_parent = 0";
                                         break;
                                case 'appandsubs':
-                                       $s = " AND 
cat_appname='{$this->app_name}' {$filter_location} AND cat_parent <> 0";
+                                       if($cat_parent)
+                                       {
+                                               $s = " AND 
cat_appname='{$this->app_name}' {$filter_location} AND cat_parent = " . (int) 
$cat_parent;
+                                       }
+                                       else
+                                       {
+                                               $s = " AND 
cat_appname='{$this->app_name}' {$filter_location} AND cat_parent <> 0";
+                                       }
                                        break;
                                case 'noglobal':
                                        $s = " AND cat_appname != 
'{$this->app_name}' {$filter_location}";
@@ -1018,12 +1025,13 @@
                * @param $cat_id Category ID
                * @return boolean True when the category exists otherwise false
                */
-               function exists($type, $cat_name = '', $cat_id = 0 )
+               function exists($type, $cat_name = '', $cat_id = 0, $cat_parent 
= 0 )
                {
                        if ( is_array($type) )
                        {
                                $real_type = $type['type'];
                                $cat_id = $type['cat_id'];
+                               $cat_parent = $type['cat_parent'];
                                $cat_name = $type['cat_name'];
                                $type = $real_type;
                                unset($real_type);
@@ -1030,7 +1038,7 @@
                        }
                        
                        $cat_id = (int) $cat_id;
-                       $filter = $this->filter($type);
+                       $filter = $this->filter($type, $cat_parent);
 
                        if ($cat_name)
                        {




reply via email to

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