Changeset 1488

Show
Ignore:
Timestamp:
12/22/07 19:00:47 (8 months ago)
Author:
rho
Message:

fixed page's parent reassign

  • when updating a page's parent that has childs, childs wasn't updated
    to lose parent

Signed-off: Rolando Espinoza La fuente <rho@prosoftpeople.com>

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • devel/mod/pages/lib.php

    r1486 r1488  
    359359                $parent = $li[0]; 
    360360                $childs = isset($li[1]) ? $li[1] : null; 
     361 
     362                // workaround 
     363                if (!$parent) { 
     364                    // this never should happen 
     365                    trigger_error(__FUNCTION__.": invalid menu element", E_USER_NOTICE); 
     366                    continue; 
     367                } 
    361368 
    362369                // set owner 
  • devel/mod/pages/lib/pages.inc.php

    r1486 r1488  
    102102                        $rs = true; 
    103103                    } else { 
     104                        $oldparent = get_field('pages', 'parent', 'ident', $page->ident); 
    104105                        $rs = update_record('pages', $page); 
    105106                        if ($rs) { 
    106107                            $messages[] = __gettext('Page updated successful'); 
     108 
     109                            // check parent menu changes 
     110                            // If it's top menu, update childs  
     111                            if ($page->parent != $oldparent && $oldparent == 0) { 
     112                                // set childs' parent to 0 (top menu) 
     113                                execute_sql("UPDATE {$CFG->prefix}pages SET parent=0 WHERE parent={$page->ident} AND owner={$owner}", false); 
     114                            } 
    107115                        } else { 
    108116                            $messages[] = __gettext('Error updating the page. Please try again.'); 
     
    137145                pages_header_redirect(pages_url($owner, 'pages::')); 
    138146            } else { 
    139                 trigger_error(__FUNCTION__.": Trying to delete an non-existent page (page id: $page_id, owner: $owner)"); 
     147                trigger_error(__FUNCTION__.": Trying to delete an non-existent page (page id: $page_id, owner: $owner)", E_USER_NOTICE); 
    140148            } 
    141149        }