Changeset 1324 in ExiteCMS


Ignore:
Timestamp:
02/28/08 15:19:38 (4 years ago)
Author:
hverton
Message:

Added security to the SVN module\ncompleted the Trac-to-CMS user mapping

Location:
modules/ExiteCMS/tracsvn/php-files/modules/tracsvn
Files:
9 edited

Legend:

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

    r1320 r1324  
    2525 
    2626if (isset($_POST['savesettings'])) { 
     27 
    2728    // extract and validate the input 
    2829    $database = stripinput($_POST['database']); 
     
    3132    $auth = stripinput($_POST['auth']); 
    3233    $extensions = stripinput($_POST['extensions']); 
     34    $view_svn = isNum($_POST['view_svn']) ? $_POST['view_svn'] : 102; 
     35    $view_diff = isNum($_POST['view_diff']) ? $_POST['view_diff'] : 102; 
     36    $view_file = isNum($_POST['view_file']) ? $_POST['view_file'] : 102; 
     37     
    3338    $variables['message'] = ""; 
    34      
     39 
    3540    // check if the database exists and is a Trac database 
    3641    if (empty($database) || !dbtable_exists("revision", $database)) { 
     
    6570        } 
    6671    } 
     72 
    6773    // if no errors are found, update 
    6874    if ($variables['message'] == "") { 
     
    7278        $result = dbquery("UPDATE ".$db_prefix."configuration SET cfg_value = '".$auth."' WHERE cfg_name = 'tracsvn_svnauth'"); 
    7379        $result = dbquery("UPDATE ".$db_prefix."configuration SET cfg_value = '".$extensions."' WHERE cfg_name = 'tracsvn_extensions'"); 
     80        $result = dbquery("UPDATE ".$db_prefix."configuration SET cfg_value = '".$view_svn."' WHERE cfg_name = 'tracsvn_view_svn'"); 
     81        $result = dbquery("UPDATE ".$db_prefix."configuration SET cfg_value = '".$view_diff."' WHERE cfg_name = 'tracsvn_view_diff'"); 
     82        $result = dbquery("UPDATE ".$db_prefix."configuration SET cfg_value = '".$view_file."' WHERE cfg_name = 'tracsvn_view_file'"); 
    7483        redirect(FUSION_SELF.$aidlink); 
    7584    } 
     85 
     86} elseif (isset($_POST['savealias'])) { 
     87 
     88    // process the selection 
     89    foreach($_POST['username'] as $idx => $user_id) { 
     90        if ($user_id) { 
     91            if ($_POST['orgmap'][$idx]) { 
     92                // update of a previous mapping 
     93                $result = dbquery("UPDATE ".$db_prefix."tracsvn_alias SET tracsvn_userid = '".$user_id."' WHERE tracsvn_username = '".stripinput($_POST['tracuser'][$idx])."'"); 
     94            } else { 
     95                // new mapping 
     96                $result = dbquery("INSERT INTO ".$db_prefix."tracsvn_alias (tracsvn_userid, tracsvn_username) VALUES ('".$user_id."', '".stripinput($_POST['tracuser'][$idx])."')"); 
     97            } 
     98        } else { 
     99            // no mapping for this trac user 
     100            $result = dbquery("DELETE FROM ".$db_prefix."tracsvn_alias WHERE tracsvn_username = '".stripinput($_POST['tracuser'][$idx])."'"); 
     101        } 
     102    } 
     103    redirect(FUSION_SELF.$aidlink); 
     104 
    76105} else { 
     106 
     107    // populate the fields for the settings panel 
    77108    $database = $settings['tracsvn_database']; 
    78109    $url = $settings['tracsvn_url']; 
     
    80111    $auth = $settings['tracsvn_svnauth']; 
    81112    $extensions = $settings['tracsvn_extensions']; 
     113    $view_svn = $settings['tracsvn_view_svn']; 
     114    $view_diff = $settings['tracsvn_view_diff']; 
     115    $view_file = $settings['tracsvn_view_file']; 
     116 
     117    // get the list of user groups 
     118    $groups = getusergroups(); 
     119    $variables['usergroups'] = array(); 
     120    foreach ($groups as $group) { 
     121        $variables['usergroups'][] = $group; 
     122    } 
     123 
     124    // get the information for the alias panel 
     125    $tracusers = array(); 
     126 
     127    // if we have a valid Trac database configured... 
     128    if (!empty($database) && dbtable_exists("revision", $database)) { 
     129        // get the trac user accounts from the ticket table 
     130        $result = dbquery("SELECT DISTINCT owner, reporter FROM ".$settings['tracsvn_database'].".ticket"); 
     131        while ($data = dbarray($result)) { 
     132            // add it to the users array, if not already present 
     133            if (!in_array($data['owner'], $tracusers)) { 
     134                $tracusers[] = $data['owner']; 
     135            } 
     136            if (!in_array($data['reporter'], $tracusers)) { 
     137                $tracusers[] = $data['reporter']; 
     138            } 
     139        } 
     140 
     141        // get the trac user accounts from the revisions table 
     142        $result = dbquery("SELECT DISTINCT author FROM ".$settings['tracsvn_database'].".revision"); 
     143        while ($data = dbarray($result)) { 
     144            // add it to the users array, if not already present 
     145            if (!in_array($data['author'], $tracusers)) { 
     146                $tracusers[] = $data['author']; 
     147            } 
     148        } 
     149 
     150        // sort the users 
     151        sort($tracusers); 
     152    } 
     153 
     154    // get the alias mapping for this users 
     155    $variables['aliases'] = array(); 
     156    foreach($tracusers as $tracuser) { 
     157        $result = dbquery("SELECT t.*, u.user_name FROM ".$db_prefix."tracsvn_alias t, ".$db_prefix."users u WHERE t.tracsvn_userid = u.user_id AND tracsvn_username = '$tracuser'"); 
     158        if (dbrows($result)) { 
     159            $data = dbarray($result); 
     160            $variables['aliases'][] = array('tracuser' => $tracuser, 'user_id' => $data['tracsvn_userid'], 'user_name' => $data['user_name']); 
     161        } else { 
     162            $variables['aliases'][] = array('tracuser' => $tracuser, 'user_id' => 0, 'user_name' => ""); 
     163        } 
     164    } 
     165 
     166    // get the list of all users for the dropdown 
     167    $variables['members'] = array(); 
     168    $result = dbquery("SELECT user_id, user_name FROM ".$db_prefix."users WHERE user_status = '0' ORDER BY user_name"); 
     169    while ($data = dbarray($result)) { 
     170        $variables['members'][] = $data; 
     171    } 
    82172} 
    83  
     173//_debug($variables, true); 
    84174// store the variables 
    85175$variables['database'] = $database; 
     
    88178$variables['auth'] = $auth; 
    89179$variables['extensions'] = $extensions; 
     180$variables['view_svn'] = $view_svn; 
     181$variables['view_diff'] = $view_diff; 
     182$variables['view_file'] = $view_file; 
    90183 
    91184// define the body panel variables 
  • modules/ExiteCMS/tracsvn/php-files/modules/tracsvn/module_installer.php

    r1320 r1324  
    7272$localestrings['en']['406'] = "Database not found, no access to database, or database is not a Trac database"; 
    7373$localestrings['en']['407'] = "Trac & SVN user aliases"; 
    74 $localestrings['en']['408'] = "Add alias"; 
     74$localestrings['en']['408'] = "Save aliases"; 
    7575$localestrings['en']['409'] = "There are no aliases defined"; 
    7676$localestrings['en']['410'] = "Save settings"; 
    7777$localestrings['en']['411'] = "Trac MySQL database name:"; 
    7878$localestrings['en']['412'] = "Trac username"; 
    79 $localestrings['en']['413'] = "Member"; 
     79$localestrings['en']['413'] = "Member Name"; 
    8080$localestrings['en']['414'] = "Milestone"; 
    8181$localestrings['en']['415'] = ""; 
     
    114114$localestrings['en']['448'] = "Generate diffs for file extensions:"; 
    115115$localestrings['en']['449'] = "Could not connect to the SVN repository. Output of the command is:<br />"; 
     116$localestrings['en']['450'] = "View SubVersion information:"; 
     117$localestrings['en']['451'] = "View SVN commit diffs:"; 
     118$localestrings['en']['452'] = "View SVN source files:"; 
    116119 
    117120$localestrings['en']['500'] = "Changeset"; 
     
    144147$localestrings['nl']['406'] = "Database niet gevonden, geen toegang tot de database, of de database is geen Trac database"; 
    145148$localestrings['nl']['407'] = "Trac & SVN gebruikersaliassen"; 
    146 $localestrings['nl']['408'] = "Alias toevoegen"; 
     149$localestrings['nl']['408'] = "Aliasen aanpassen"; 
    147150$localestrings['nl']['409'] = "Er zijn geen aliassen gedefinieerd"; 
    148151$localestrings['nl']['410'] = "Bewaar instellingen"; 
    149152$localestrings['nl']['411'] = "Trac MySQL database naam:"; 
    150153$localestrings['nl']['412'] = "Trac gebruiker"; 
    151 $localestrings['nl']['413'] = "Lid"; 
     154$localestrings['nl']['413'] = "Lid naam"; 
    152155$localestrings['nl']['414'] = "Mijlpaal"; 
    153156$localestrings['nl']['415'] = "Opgeleverd op"; 
     
    186189$localestrings['nl']['448'] = "Genereer diffs voor deze file extensies:"; 
    187190$localestrings['nl']['449'] = "Kan geen verbinding maken met de SVN repository. Uitvoer van het commando is:<br />"; 
     191$localestrings['nl']['450'] = "SubVersion informatie bekijken:"; 
     192$localestrings['nl']['451'] = "SVN commit diffs bekijken:"; 
     193$localestrings['nl']['452'] = "SVN bron bestanden bekijken:"; 
    188194 
    189195$localestrings['nl']['500'] = "Changeset"; 
     
    219225$mod_install_cmds[] = array('type' => 'db', 'value' => "INSERT INTO ".$db_prefix."configuration( cfg_name, cfg_value ) VALUES ('tracsvn_svnauth', '--username name_here --password pass_here')"); 
    220226$mod_install_cmds[] = array('type' => 'db', 'value' => "INSERT INTO ".$db_prefix."configuration( cfg_name, cfg_value ) VALUES ('tracsvn_extensions', 'php,tpl,sh')"); 
     227$mod_install_cmds[] = array('type' => 'db', 'value' => "INSERT INTO ".$db_prefix."configuration( cfg_name, cfg_value ) VALUES ('tracsvn_view_svn', '102')"); 
     228$mod_install_cmds[] = array('type' => 'db', 'value' => "INSERT INTO ".$db_prefix."configuration( cfg_name, cfg_value ) VALUES ('tracsvn_view_diff', '102')"); 
     229$mod_install_cmds[] = array('type' => 'db', 'value' => "INSERT INTO ".$db_prefix."configuration( cfg_name, cfg_value ) VALUES ('tracsvn_view_file', '102')"); 
    221230 
    222231// create the table: tracsvn_alias 
    223232$mod_install_cmds[] = array('type' => 'db', 'value' => "CREATE TABLE ##PREFIX##tracsvn_alias ( 
    224   tracsvn_id mediumint(8) unsigned NOT NULL default '0', 
     233  tracsvn_id mediumint(8) unsigned NOT NULL AUTO_INCREMENT, 
    225234  tracsvn_userid mediumint(8) unsigned NOT NULL default '0', 
    226235  tracsvn_username varchar(50) NOT NULL default '', 
  • modules/ExiteCMS/tracsvn/php-files/modules/tracsvn/svn.php

    r1320 r1324  
    2828 
    2929// get the rights for the current user 
    30 $variables['view_svn'] = true; 
     30$variables['view_svn'] = iMEMBER && checkgroup($settings['tracsvn_view_svn']); 
    3131if (!$variables['view_svn']) { 
    3232    // redirect back to the trac module  
    3333    redirect("trac.php"); 
    3434} 
    35 $variables['view_diff'] = true; 
    36 $variables['view_file'] = true; 
     35$variables['view_diff'] = iMEMBER && checkgroup($settings['tracsvn_view_diff']); 
     36$variables['view_file'] = iMEMBER && checkgroup($settings['tracsvn_view_file']); 
    3737 
    3838// check if we have a revision number 
  • modules/ExiteCMS/tracsvn/php-files/modules/tracsvn/templates/modules.tracsvn.admin.tpl

    r1320 r1324  
    6565            </td> 
    6666        </tr> 
     67 
     68        <tr> 
     69            <td width='50%' class='tbl'> 
     70                {$locale.450} 
     71            </td> 
     72            <td width='50%' class='tbl'> 
     73                <select name='view_svn' class='textbox'> 
     74                {section name=id loop=$usergroups} 
     75                    <option value='{$usergroups[id].0}'{if $usergroups[id].0 == $view_svn} selected="selected"{/if}>{$usergroups[id].1}</option> 
     76                {/section} 
     77                </select> 
     78            </td> 
     79        </tr> 
     80        <tr> 
     81            <td width='50%' class='tbl'> 
     82                {$locale.451} 
     83            </td> 
     84            <td width='50%' class='tbl'> 
     85                <select name='view_diff' class='textbox'> 
     86                {section name=id loop=$usergroups} 
     87                    <option value='{$usergroups[id].0}'{if $usergroups[id].0 == $view_diff} selected="selected"{/if}>{$usergroups[id].1}</option> 
     88                {/section} 
     89                </select> 
     90            </td> 
     91        </tr> 
     92        <tr> 
     93            <td width='50%' class='tbl'> 
     94                {$locale.452} 
     95            </td> 
     96            <td width='50%' class='tbl'> 
     97                <select name='view_file' class='textbox'> 
     98                {section name=id loop=$usergroups} 
     99                    <option value='{$usergroups[id].0}'{if $usergroups[id].0 == $view_file} selected="selected"{/if}>{$usergroups[id].1}</option> 
     100                {/section} 
     101                </select> 
     102            </td> 
     103        </tr> 
    67104        <tr> 
    68105            <td align='center' colspan='2' class='tbl'> 
     
    75112{include file="_closetable.tpl"} 
    76113{include file="_opentable.tpl" name=$_name title=$locale.407 state=$_state style=$_style} 
    77 <table align='center' cellpadding='0' cellspacing='1' class='tbl-border' width='500'> 
    78     <tr> 
    79         <td class='tbl2' align='center'> 
    80             {$locale.412} 
    81         </td> 
    82         <td class='tbl2' align='center'> 
    83             {$locale.413} 
    84         </td> 
    85     </tr> 
    86     {section name=id loop=$aliases} 
     114<form name='aliasform' method='post' action='{$smarty.const.FUSION_SELF}{$aidlink}'> 
     115    <table align='center' cellpadding='0' cellspacing='1' class='tbl-border' width='500'> 
    87116        <tr> 
    88             <td class='tbl1' align='center'> 
     117            <td class='tbl2' width='50%' align='center'> 
     118                <b>{$locale.412}</b> 
    89119            </td> 
    90             <td class='tbl1' align='center'> 
     120            <td class='tbl2' width='50%' align='center'> 
     121                <b>{$locale.413}</b> 
    91122            </td> 
    92123        </tr> 
    93     {sectionelse} 
     124        {section name=id loop=$aliases} 
     125            <tr> 
     126                <td class='tbl1' align='center'> 
     127                    {$aliases[id].tracuser} 
     128                    <input type='hidden' name='tracuser[]' value='{$aliases[id].tracuser}' /> 
     129                    <input type='hidden' name='orgmap[]' value='{$aliases[id].user_id}' /> 
     130                </td> 
     131                <td class='tbl1' align='center'> 
     132                    <select name='username[]' class='textbox' style='width:200px;'> 
     133                        <option value='0'{if $aliases[id].user_id == 0} selected='selected'{/if}></option> 
     134                        {section name=usr loop=$members} 
     135                            <option value='{$members[usr].user_id}'{if $aliases[id].user_id == $members[usr].user_id} selected='selected'{/if}>{$members[usr].user_name}</option> 
     136                        {/section} 
     137                    </section> 
     138                </td> 
     139            </tr> 
     140        {sectionelse} 
     141            <tr> 
     142                <td class='tbl1' colspan='2' align='center'> 
     143                    {$locale.409} 
     144                </td> 
     145            </tr> 
     146        {/section} 
     147    </table> 
     148    <br /> 
     149    <table align='center' cellpadding='0' cellspacing='0' width='500'> 
    94150        <tr> 
    95             <td class='tbl1' colspan='2' align='center'> 
    96                 {$locale.409} 
     151            <td align='center' colspan='2' class='tbl'> 
     152                <input type='submit' name='savealias' value='{$locale.408}' class='button' /> 
    97153            </td> 
    98154        </tr> 
    99     {/section} 
    100 </table> 
    101 <br /> 
    102 <table align='center' cellpadding='0' cellspacing='0' width='500'> 
    103     <tr> 
    104         <td align='center' colspan='2' class='tbl'> 
    105             <input type='submit' name='addalias' value='{$locale.408}' class='button' /> 
    106         </td> 
    107     </tr> 
    108 </table> 
     155    </table> 
     156</form> 
    109157{include file="_closetable.tpl"} 
    110158{***************************************************************************} 
  • modules/ExiteCMS/tracsvn/php-files/modules/tracsvn/templates/modules.tracsvn.side_panel.tpl

    r1320 r1324  
    2626            <br /> 
    2727            <span class='small'>{$locale.404}</span>  
    28             <b>{$dev}</b> 
     28            <b>{$dev.user_name}</b> 
    2929        </div> 
    3030    {else} 
  • modules/ExiteCMS/tracsvn/php-files/modules/tracsvn/templates/modules.tracsvn.svn.tpl

    r1320 r1324  
    105105            </td> 
    106106            <td class='tbl' align='left'> 
    107                 {$revs.author} 
     107                {if $revs.author.user_id} 
     108                    <a href='{$smarty.const.BASEDIR}profile.php?lookup={$revs.author.user_id}' title=''>{$revs.author.user_name}</a> 
     109                {else} 
     110                    {$revs.author.user_name} 
     111                {/if} 
    108112            </td> 
    109113        </tr> 
     
    135139                        <div style='float:left;background-color:#ffffff;height:7px;width:7px;margin-top:3px;margin-right:4px;border:1px solid #000;'></div> 
    136140                    {/if} 
    137                     {if $nodes[id].change_type != "D"}          {* No links to deleted files *} 
     141                    {if $nodes[id].change_type != "D" && $view_file} 
    138142                        <a href='{$smarty.const.FUSION_SELF}?rev={$rev}&amp;file={$nodes[id].path}' title='{$locale.517}'>{$nodes[id].s_path}</a> 
    139143                    {else} 
     
    259263                <span class='small'>{$revs[id].time|date_format:"%H:%M"}</span> 
    260264            </td> 
    261             <td class='tbl'> 
     265            <td class='tbl2'> 
    262266                {$locale.500} 
    263                 <a href='{$smarty.const.FUSION_SELF}?rev={$revs[id].rev}' title='{$locale.516}'>[{$revs[id].rev}]</a> 
    264                 {$locale.404} {$revs[id].author} 
    265                 <br /> 
    266                 {$revs[id].message} 
    267             </td> 
    268         </tr> 
    269  
     267                [<a href='{$smarty.const.FUSION_SELF}?rev={$revs[id].rev}' title='{$locale.516}'>{$revs[id].rev}</a>] 
     268                {$locale.404} 
     269                {if $revs[id].author.user_id} 
     270                    <a href='{$smarty.const.BASEDIR}profile.php?lookup={$revs[id].author.user_id}' title=''>{$revs[id].author.user_name}</a> 
     271                {else} 
     272                    {$revs[id].author.user_name} 
     273                {/if} 
     274            </td> 
     275        </tr> 
     276        <tr> 
     277            <td class='tbl2' align='right' valign='top' width='1%' style='white-space:nowrap;'> 
     278            </td> 
     279            <td class='tbl' > 
     280                <div style='float;white-space:nowrap;overflow:auto'><img src='{$smarty.const.THEME}images/bullet.gif' alt='' /> {$revs[id].message}</div> 
     281            </td> 
     282        </tr> 
    270283    {sectionelse} 
    271284    {/section} 
  • modules/ExiteCMS/tracsvn/php-files/modules/tracsvn/templates/modules.tracsvn.trac.tpl

    r1320 r1324  
    169169            </td> 
    170170            <td class='tbl1' align='left'> 
    171                 {$ticket.reporter} 
     171                {if $ticket.reporter.user_id} 
     172                    <a href='{$smarty.const.BASEDIR}profile.php?lookup={$ticket.reporter.user_id}' title=''>{$ticket.reporter.user_name}</a> 
     173                {else} 
     174                    {$ticket.reporter.user_name} 
     175                {/if} 
    172176            </td> 
    173177            <td class='tbl2' align='left'> 
     
    175179            </td> 
    176180            <td class='tbl1' align='left'> 
    177                 {$ticket.owner} 
     181                {if $ticket.owner.user_id} 
     182                    <a href='{$smarty.const.BASEDIR}profile.php?lookup={$ticket.owner.user_id}' title=''>{$ticket.owner.user_name}</a> 
     183                {else} 
     184                    {$ticket.owner.user_name} 
     185                {/if} 
    178186            </td> 
    179187        </tr> 
     
    240248            <tr> 
    241249                <td class='tbl2'> 
    242                     <span style='small'>{$changes[id].time|date_format:"forumdate"}  - {$locale.441} {$locale.404} {$changes[id].author}</span> 
     250                    <span style='small'> 
     251                        {$changes[id].time|date_format:"forumdate"}  - {$locale.441} {$locale.404} 
     252                        {if $changes[id].author.user_id} 
     253                            <a href='{$smarty.const.BASEDIR}profile.php?lookup={$changes[id].author.user_id}' title=''>{$changes[id].author.user_name}</a> 
     254                        {else} 
     255                            {$changes[id].author.user_name} 
     256                        {/if} 
     257                    </span> 
    243258                </td> 
    244259            </tr> 
     
    248263                        {$changes[id].newvalue} 
    249264                    {elseif $changes[id].oldvalue == ""} 
    250                         <img src='{$smart.const.THEME}/images/bullet.gif' alt='' /> <b>{$changes[id].field}</b> {$locale.441} {$locale.443} </span class='small2'>{$changes[id].newvalue}</span> 
     265                        <img src='{$smart.const.THEME}/images/bullet.gif' alt='' /> <b>{$changes[id].field}</b> {$locale.441} {$locale.443} <span class='small2'>{$changes[id].newvalue}</span> 
    251266                    {else} 
    252                         <img src='{$smart.const.THEME}/images/bullet.gif' alt='' />  <b>{$changes[id].field}</b> {$locale.441} {$locale.442} <span class='small2'>{$changes[id].oldvalue}</span> {$locale.443} </span class='small2'>{$changes[id].newvalue}</span> 
     267                        <img src='{$smart.const.THEME}/images/bullet.gif' alt='' />  <b>{$changes[id].field}</b> {$locale.441} {$locale.442} <span class='small2'>{$changes[id].oldvalue}</span> {$locale.443} <span class='small2'>{$changes[id].newvalue}</span> 
    253268                    {/if} 
    254269                </td> 
  • modules/ExiteCMS/tracsvn/php-files/modules/tracsvn/tracsvn.side_panel.php

    r1320 r1324  
    2424        $variables['rev'] = $data['rev']; 
    2525        $variables['date'] = $data['time']; 
    26         // translate SVN users to ExiteCMS users if needed 
    27         $result = dbquery("SELECT u.user_name FROM ".$db_prefix."users u, ".$db_prefix."tracsvn_alias t WHERE t.tracsvn_userid = u.user_id AND t.tracsvn_username = '".$data['author']."'");  
    28         if (dbrows($result)) { 
    29             $data = dbarray($result); 
    30             $variables['dev'] = $data['user_name']; 
    31         } else { 
    32             $variables['dev'] = tracsvn_getalias($data['author']); 
    33         } 
     26        $variables['dev'] = tracsvn_getalias($data['author']); 
    3427    } 
    3528} 
  • modules/ExiteCMS/tracsvn/php-files/modules/tracsvn/tracsvn_include.php

    r1320 r1324  
    3939function tracsvn_wiki2html($text) { 
    4040 
    41     // get rid of double line breaks 
    42     $text = str_replace("[[BR]]\r\n", "", $text); 
     41    // get rid of trailing whitespace 
     42    $text = rtrim($text); 
    4343    // bullit implies line break 
    44     $text = str_replace("\r\*", "\*", $text); 
     44    $text = str_replace("\r\n*", "*", $text); 
     45    $text = str_replace("[[BR]]*", "*", $text); 
    4546    // bullet lists 
     47    $text = str_replace("\r\n *", "<br />*", $text); 
    4648    $text = preg_replace("/\*\s(.*?)(\w)/i", "&bull; \\1\\2", $text); 
    47     // line breaks 
    48     $text = str_replace("\r\n", "<br />", $text); 
     49    // convert linebreaks 
     50    if (FUSION_SELF == "trac.php") { 
     51        $text = str_replace("\r\n", "<br />", $text); 
     52        $text = str_replace("\n", "<br />", $text); 
     53    } else { 
     54        $text = str_replace("\r\n", "<br /><img src='".THEME."images/bullet.gif' alt=\"\" /> ", $text); 
     55        $text = str_replace("\n", "<br /><img src='".THEME."images/bullet.gif' alt=\"\" /> ", $text); 
     56    } 
     57    // forced line breaks 
     58    $text = str_replace("[[BR]]", "<br />", $text); 
    4959    // strike-through 
    5060    $text = preg_replace("/~~(.*?)~~/si", "<span style='text-decoration:line-through;'>\\1</span>", $text); 
     
    7181        $text = preg_replace("/#([0-9]+)/si", "#<a href='trac.php?step=ticket&amp;id=\\1' title=''>\\1</a>", $text); 
    7282    } 
     83    $text = preg_replace("/rev. ([0-9]+)/i", "rev. <a href='svn.php?rev=\\1' title=''>\\1</a>", $text); 
    7384     
    7485    // return the converted text     
     
    8293     
    8394    // validate the parameter 
    84     if (!empty($tracname) && !is_string($tracname)) { 
     95    if (!empty($tracname) && is_string($tracname)) { 
    8596        // translate Trac/SVN users to ExiteCMS users if needed 
    86         $result = dbquery("SELECT u.user_name FROM ".$db_prefix."users u, ".$db_prefix."tracsvn_alias t WHERE t.tracsvn_userid = u.user_id AND t.tracsvn_username = '$tracname' LIMIT 1");  
     97        $result = dbquery("SELECT u.user_id, u.user_name FROM ".$db_prefix."users u, ".$db_prefix."tracsvn_alias t WHERE t.tracsvn_userid = u.user_id AND t.tracsvn_username = '$tracname' LIMIT 1");  
    8798        if (dbrows($result)) { 
    88             $data = dbarray($result); 
    89             $tracname = $data['user_name']; 
    90         } 
    91     } 
    92  
    93     // test code!!! 
    94     if ($tracname == "hverton") $tracname = "WanWizard"; 
    95     if ($tracname == "root") $tracname = "Webmaster"; 
    96      
     99            $tracname = dbarray($result); 
     100        } 
     101    } 
     102    // not found? maybe there's a direct link with a member 
     103    if (!is_array($tracname)) { 
     104        // check the users table 
     105        $result = dbquery("SELECT user_id, user_name FROM ".$db_prefix."users WHERE user_name = '$tracname' LIMIT 1");  
     106        if (dbrows($result)) { 
     107            $tracname = dbarray($result); 
     108        } 
     109    } 
     110 
     111    // still not found? Use the tracname 
     112    if (!is_array($tracname)) { 
     113        $tracname = array('user_id' => '0', 'user_name' => $tracname); 
     114    } 
     115         
    97116    return $tracname; 
    98117} 
Note: See TracChangeset for help on using the changeset viewer.