fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [6955] Admin/Api: fix category subdelete


From: Sigurd Nes
Subject: [Fmsystem-commits] [6955] Admin/Api: fix category subdelete
Date: Tue, 08 Feb 2011 20:30:04 +0000

Revision: 6955
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=6955
Author:   sigurdne
Date:     2011-02-08 20:30:02 +0000 (Tue, 08 Feb 2011)
Log Message:
-----------
Admin/Api: fix category subdelete

Modified Paths:
--------------
    trunk/admin/inc/class.bocategories.inc.php
    trunk/admin/inc/class.uicategories.inc.php
    trunk/admin/templates/base/confirm_delete.xsl
    trunk/phpgwapi/inc/class.categories.inc.php

Modified: trunk/admin/inc/class.bocategories.inc.php
===================================================================
--- trunk/admin/inc/class.bocategories.inc.php  2011-02-08 11:26:36 UTC (rev 
6954)
+++ trunk/admin/inc/class.bocategories.inc.php  2011-02-08 20:30:02 UTC (rev 
6955)
@@ -138,9 +138,9 @@
                        return $this->cats->formatted_list($data);
                }
 
-               function delete($data)
+               function delete($cat_id, $drop_subs = False, $modify_subs = 
False)
                {
-                       $this->cats->delete($data);
+                       $this->cats->delete($cat_id, $drop_subs, $modify_subs);
                }
 
                function check_values($values)

Modified: trunk/admin/inc/class.uicategories.inc.php
===================================================================
--- trunk/admin/inc/class.uicategories.inc.php  2011-02-08 11:26:36 UTC (rev 
6954)
+++ trunk/admin/inc/class.uicategories.inc.php  2011-02-08 20:30:02 UTC (rev 
6955)
@@ -394,7 +394,7 @@
                        $appname = phpgw::get_var('appname');
                        $location= phpgw::get_var('location');
                        $global_cats  = phpgw::get_var('global_cats');
-
+                       $receipt = array();
                        $link_data = array
                        (
                                'menuaction'  => 'admin.uicategories.index',
@@ -425,8 +425,7 @@
                                                        
$GLOBALS['phpgw']->redirect_link('/index.php',$link_data);
                                                        break;
                                                default:
-                                                       $error          = 
array('Please choose one of the methods to handle the subcategories');
-                                                       $msgbox_error   = 
$GLOBALS['phpgw']->common->error_list($error);
+                                                       
$receipt['error'][]=array('msg'=>'Please choose one of the methods to handle 
the subcategories');
                                                        break;
                                        }
                                }
@@ -459,10 +458,8 @@
 
                        if ($apps_cats)
                        {
-                               $error = array('This category is currently 
being used by applications as a parent category',
-                                                               'You will need 
to reassign these subcategories before you can delete this category');
-
-                               $msgbox_error   = 
$GLOBALS['phpgw']->common->error_list($error);
+                               $receipt['message'][]=array('msg'=>'This 
category is currently being used by applications as a parent category');
+                               $receipt['message'][]=array('msg'=>'You will 
need to reassign these subcategories before you can delete this category');
                                $show_done              = 'yes';
                        }
                        else
@@ -495,11 +492,12 @@
                        );
                        $link_data['menu_selection'] = 
$GLOBALS['phpgw_info']['flags']['menu_selection'];
 
+                       $msgbox_data = 
$GLOBALS['phpgw']->common->msgbox_data($receipt);
                        $data = array
                        (
                                'form_action'                   => 
$GLOBALS['phpgw']->link('/index.php', $link_data),
                                'show_done'                             => 
$show_done,
-                               'msgbox_data'                   => 
$msgbox_error,
+                               'msgbox_data'                   => 
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
                                'lang_delete'                   => 
lang('delete'),
                                'subs'                                  => 
$subs,
                                'lang_confirm_msg'              => $confirm_msg,

Modified: trunk/admin/templates/base/confirm_delete.xsl
===================================================================
--- trunk/admin/templates/base/confirm_delete.xsl       2011-02-08 11:26:36 UTC 
(rev 6954)
+++ trunk/admin/templates/base/confirm_delete.xsl       2011-02-08 20:30:02 UTC 
(rev 6955)
@@ -4,13 +4,44 @@
                <xsl:apply-templates select="delete"/>
        </xsl:template>
 
-       <xsl:template match="delete">
+       <xsl:template match="delete" xmlns:php="http://php.net/xsl";>
+               <xsl:choose>
+                       <xsl:when test="msgbox_data != ''">
+                               <tr>
+                                       <td align="left" colspan="3">
+                                               <xsl:call-template 
name="msgbox"/>
+                                       </td>
+                               </tr>
+                       </xsl:when>
+               </xsl:choose>
+
                        <h1><xsl:value-of select="lang_confirm_msg"/></h1>
                        <div class="button_group">
                                <form method="post" action="{form_action}">
-                                       <input type="submit" name="cancel" 
value="{lang_no}" />
+                                       <xsl:choose>
+                                               <xsl:when test="subs != ''">
+                                                       <select name="subs" >
+                                                               <option 
value="none">
+                                                                       
<xsl:value-of select="php:function('lang', 'select')" />
+                                                               </option>
+                                                               <option 
value="move">
+                                                                       
<xsl:value-of select="lang_sub_select_move"/>
+                                                               </option>
+                                                               <option 
value="drop">
+                                                                       
<xsl:value-of select="lang_sub_select_drop"/>
+                                                               </option>
+                                                       </select>
+                                               </xsl:when>
+                                       </xsl:choose>
+                                       <input type="submit" name="cancel" 
value="{lang_no}" title="{lang_no_statustext}"/>
 
-                                       <input type="submit" name="confirm" 
value="{lang_yes}"/>
+                                       <xsl:choose>
+                                               <xsl:when test="show_done = ''">
+                                                       <input type="submit" 
name="confirm" value="{lang_yes}" title="{lang_yes_statustext}"/>
+                                               </xsl:when>
+                                       </xsl:choose>
+
+
                                </form>
                        </div>
        </xsl:template>

Modified: trunk/phpgwapi/inc/class.categories.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.categories.inc.php 2011-02-08 11:26:36 UTC (rev 
6954)
+++ trunk/phpgwapi/inc/class.categories.inc.php 2011-02-08 20:30:02 UTC (rev 
6955)
@@ -834,16 +834,29 @@
                                }
                        }
 
+                       $this->db->query('SELECT cat_id FROM phpgw_categories 
WHERE cat_id=' . $cat_id . $subdelete . " AND cat_appname='"
+                                                       . $this->app_name . 
"'",__LINE__,__FILE__);
+                       $_cats = array();
+                       while ($this->db->next_record())
+                       {
+                               $_cats[] = $this->db->f('cat_id');              
        
+                       }
+
                        $this->db->query('DELETE FROM phpgw_categories WHERE 
cat_id=' . $cat_id . $subdelete . " AND cat_appname='"
                                                        . $this->app_name . 
"'",__LINE__,__FILE__);
-                       $args = array
-                       (
-                               'cat_id'        => $cat_id,
-                               'cat_owner'     => $this->account_id,
-                               'location'      => 'cat_delete',
-                               'location_id' => $this->location_id
-                       );
-                       $GLOBALS['phpgw']->hooks->single($args, 
$this->app_name);
+                       
+                       foreach($_cats as $_cat_id)
+                       {
+                               $args = array
+                               (
+                                       'cat_id'        => $_cat_id,
+                                       'cat_owner'     => $this->account_id,
+                                       'location'      => 'cat_delete',
+                                       'location_id' => $this->location_id
+                               );
+
+                               $GLOBALS['phpgw']->hooks->single($args, 
$this->app_name);
+                       }
                }
 
                /**




reply via email to

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