Ignore:
Timestamp:
08/21/08 21:06:15 (4 years ago)
Author:
hverton
Message:

Merged trunk revisions 1588:1665 into the PLi-Fusion branch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/PLi-Fusion/administration/reports.php

    r1511 r1666  
    55| Copyright 2007 Harro "WanWizard" Verton, Exite BV  | 
    66| for support, please visit http://exitecms.exite.eu | 
    7 +----------------------------------------------------+ 
    8 | Some portions copyright 2002 - 2006 Nick Jones     | 
    9 | http://www.php-fusion.co.uk/                       | 
    107+----------------------------------------------------+ 
    118| Released under the terms & conditions of v2 of the | 
     
    3027// check if the report_id variable is defined, if not, assign a default 
    3128if (!isset($report_id) || !isNum($report_id)) $report_id = 0; 
     29$variables['report_id'] = $report_id; 
    3230 
    33 // process the action requested 
    34 switch ($action) { 
     31// save requested? 
     32if (isset($_POST['save'])) { 
     33    $visibility = isset($_POST['report_visibility']) && isNum($_POST['report_visibility']) ? $_POST['report_visibility'] : 103; 
     34    switch ($_POST['action']) { 
     35        case "add": 
     36            // not implemented yet 
     37            break; 
     38        case "edit": 
     39            $result = dbquery("UPDATE ".$db_prefix."reports SET report_visibility='$visibility' WHERE report_id = '$report_id'"); 
     40            $action = ""; 
     41            break; 
     42        default: 
     43            die('invalid action passed!'); 
     44    }        
     45} 
    3546 
    36     case "add": 
    37         $variables['report'] = array( 
    38             'report_id' => 0, 
    39             'report_mod_id' => 0, 
    40             'report_name' => "", 
    41             'report_title' => "", 
    42             'report_version' => "", 
    43             'report_active' => 0, 
    44             'report_visibility' => 103 
    45         ); 
    46         break; 
     47// add a new report definition 
     48if ($action == "add" && !isset($variables['report'])) { 
     49    $variables['report'] = array( 
     50        'report_id' => 0, 
     51        'report_mod_id' => 0, 
     52        'report_mod_core' => 0, 
     53        'report_name' => "", 
     54        'report_title' => "", 
     55        'report_version' => "", 
     56        'report_active' => 0, 
     57        'report_visibility' => 103 
     58    ); 
     59} 
    4760 
    48     case "edit": 
    49         $result = dbquery("SELECT * FROM ".$db_prefix."reports WHERE report_id = '".$report_id."'"); 
    50         if ($variables['report'] = dbarray($result)) { 
    51             _debug($variables, true); 
    52             // found the record 
     61// edit an existing report definition 
     62if ($action == "edit" && !isset($variables['report'])) { 
     63    $result = dbquery("SELECT r.*, m.mod_folder FROM ".$db_prefix."reports r LEFT JOIN ".$db_prefix."modules m ON r.report_mod_id = m.mod_id"); 
     64    if ($data = dbarray($result)) { 
     65        // get the title for this report 
     66        if ($data['report_mod_id']) { 
     67            $data['custom'] = false; 
     68            locale_load("modules.".$data['mod_folder']); 
     69            $data['report_title'] = $locale[$data['report_title']]; 
     70            $locales[] = "modules.".$data['mod_folder']; 
    5371        } else { 
    54             // return to the overview screen 
    55             $action = ""; 
     72            if ($data['report_mod_core']) { 
     73                $data['mod_folder'] = "ExiteCMS"; 
     74                $data['custom'] = false; 
     75            } else { 
     76                $data['mod_folder'] = "-"; 
     77                $data['custom'] = true; 
     78            } 
     79            // it's a core report, get the title for the module locales 
     80            locale_load("main.reports"); 
     81            if (isset($locale[$data['report_title']])) { 
     82                $data['report_title'] = $locale[$data['report_title']]; 
     83            } else { 
     84                // not found, assume it's a static title 
     85            } 
    5686        } 
    57         break; 
    58  
    59     case "setstatus": 
    60         // if a status is passed, validate it 
    61         if (isset($status) && isNum($status) && $status >= 0 && $status <= 1) { 
    62             $result = dbquery("UPDATE ".$db_prefix."reports SET report_active = '".$status."' WHERE report_id = '".$report_id."'"); 
    63         } 
     87        $variables['report'] = $data; 
     88    } else { 
    6489        // return to the overview screen 
    6590        $action = ""; 
    66         break; 
     91    } 
     92} 
     93//_debug($variables, true); 
     94// add a new or edit an existing report definition 
     95if ($action == "add" || $action == "edit") { 
     96    // get the list of defined user groups 
     97    $variables['usergroups'] = getusergroups(true); 
     98} 
     99 
     100// toggle the report status 
     101if ($action == "setstatus") { 
     102    // if a status is passed, validate it 
     103    if (isset($status) && isNum($status) && $status >= 0 && $status <= 1) { 
     104        $result = dbquery("UPDATE ".$db_prefix."reports SET report_active = '".$status."' WHERE report_id = '".$report_id."'"); 
     105    } 
     106    // return to the overview screen 
     107    $action = ""; 
    67108} 
    68109 
     
    79120            $data['report_title'] = $locale[$data['report_title']]; 
    80121        } else { 
    81             // make sure this field is not NULL 
    82             $data['mod_folder'] = ""; 
     122            // make sure this field is not NULL, we need it later 
     123            $variables['mod_folder'] = ""; 
     124            // it's a core report, get the title for the module locales 
     125            locale_load("main.reports"); 
     126            if (isset($locale[$data['report_title']])) { 
     127                $data['report_title'] = $locale[$data['report_title']]; 
     128            } else { 
     129                // not found, assume it's a static title 
     130            } 
    83131        } 
    84132        $data['groupname'] = getgroupname($data['report_visibility']); 
     
    97145} 
    98146 
    99 //_debug($variables, true); 
     147// store the action variable 
     148$variables['action'] = $action; 
    100149 
    101150// define the admin body panel 
Note: See TracChangeset for help on using the changeset viewer.