Ignore:
Timestamp:
02/28/08 00:23:53 (4 years ago)
Author:
hverton
Message:

Trac Project Management and SVN interface module

File:
1 edited

Legend:

Unmodified
Added
Removed
  • modules/ExiteCMS/tracsvn/php-files/modules/tracsvn/admin.php

    r1279 r1320  
    1313require_once PATH_ROOT."/includes/theme_functions.php"; 
    1414 
     15require_once "tracsvn_include.php"; 
     16 
     17// check for the proper admin access rights 
     18if (!checkrights("wT") || !defined("iAUTH") || $aid != iAUTH) fallback(BASEDIR."index.php"); 
     19 
     20// load the locale for this module 
     21locale_load("modules.tracsvn"); 
     22 
     23// define the variables for this panel 
     24$variables = array(); 
     25 
     26if (isset($_POST['savesettings'])) { 
     27    // extract and validate the input 
     28    $database = stripinput($_POST['database']); 
     29    $url = stripinput($_POST['url']); 
     30    $cmd = stripinput($_POST['cmd']); 
     31    $auth = stripinput($_POST['auth']); 
     32    $extensions = stripinput($_POST['extensions']); 
     33    $variables['message'] = ""; 
     34     
     35    // check if the database exists and is a Trac database 
     36    if (empty($database) || !dbtable_exists("revision", $database)) { 
     37        $variables['message'] = ($variables['message'] == "" ? "" : "<br />") . $locale['406']; 
     38    } else { 
     39        // check if the cmd points to svn 
     40        $_tmp = explode(" ", $cmd); 
     41        if (CMS_GetOS() == "Windows") { 
     42            $_tmp = substr(strrchr($_tmp[0], "\\"),1); 
     43            if ($_tmp != "svn.exe") { 
     44                $variables['message'] = ($variables['message'] == "" ? "" : "<br />") . $locale['444']; 
     45            } 
     46        } else { 
     47            $_tmp = substr(strrchr($_tmp[0], "/"),1); 
     48            if ($_tmp != "svn") { 
     49                $variables['message'] = ($variables['message'] == "" ? "" : "<br />") . $locale['444']; 
     50            } 
     51        } 
     52        // add a trailing slash if needed 
     53        if (!empty($url) && substr($url, -1) != "/") { 
     54            $url .= "/"; 
     55        } 
     56        if ($variables['message'] == "") { 
     57            // executable is valid. check if the repository is readable 
     58            $output = tracsvn_extCmd($cmd." info ".$url." ".$auth); 
     59            if (!is_array($output) || !isset($output[5]) || $output[5] != "Node Kind: directory") { 
     60                $variables['message'] = ($variables['message'] == "" ? "" : "<br />") . $locale['449']; 
     61                foreach($output as $line) { 
     62                    $variables['message'] .= "<br />" . $line; 
     63                } 
     64            } 
     65        } 
     66    } 
     67    // if no errors are found, update 
     68    if ($variables['message'] == "") { 
     69        $result = dbquery("UPDATE ".$db_prefix."configuration SET cfg_value = '".$database."' WHERE cfg_name = 'tracsvn_database'"); 
     70        $result = dbquery("UPDATE ".$db_prefix."configuration SET cfg_value = '".$url."' WHERE cfg_name = 'tracsvn_url'"); 
     71        $result = dbquery("UPDATE ".$db_prefix."configuration SET cfg_value = '".$cmd."' WHERE cfg_name = 'tracsvn_svncmd'"); 
     72        $result = dbquery("UPDATE ".$db_prefix."configuration SET cfg_value = '".$auth."' WHERE cfg_name = 'tracsvn_svnauth'"); 
     73        $result = dbquery("UPDATE ".$db_prefix."configuration SET cfg_value = '".$extensions."' WHERE cfg_name = 'tracsvn_extensions'"); 
     74        redirect(FUSION_SELF.$aidlink); 
     75    } 
     76} else { 
     77    $database = $settings['tracsvn_database']; 
     78    $url = $settings['tracsvn_url']; 
     79    $cmd = $settings['tracsvn_svncmd']; 
     80    $auth = $settings['tracsvn_svnauth']; 
     81    $extensions = $settings['tracsvn_extensions']; 
     82} 
     83 
     84// store the variables 
     85$variables['database'] = $database; 
     86$variables['url'] = $url; 
     87$variables['cmd'] = $cmd; 
     88$variables['auth'] = $auth; 
     89$variables['extensions'] = $extensions; 
     90 
    1591// define the body panel variables 
    16 $template_panels[] = array('type' => 'body', 'name' => 'tracsvn.admin_panel', 'template' => 'modules.tracsvn.admin_panel.tpl', 'locale' => "modules.tracsvn"); 
     92$template_panels[] = array('type' => 'body', 'name' => 'tracsvn.admin_panel', 'template' => 'modules.tracsvn.admin.tpl', 'locale' => "modules.tracsvn"); 
    1793$template_variables['tracsvn.admin_panel'] = $variables; 
    1894 
Note: See TracChangeset for help on using the changeset viewer.