[evolvis-commits] r8861: Added Dracos Moinescu cvsweb contrib↵

mirabilos at evolvis.org mirabilos at evolvis.org
Thu Feb 24 16:54:01 CET 2011


Author: mirabilos
Date: 2011-02-24 16:54:00 +0100 (Thu, 24 Feb 2011)
New Revision: 8861

Added:
   trunk/gforge_base/evolvisforge-5.1/gforge/common/include/cvsweb/
   trunk/gforge_base/evolvisforge-5.1/gforge/common/include/cvsweb/DirectoryHandler.class
   trunk/gforge_base/evolvisforge-5.1/gforge/common/include/cvsweb/ErrorHandler.class
   trunk/gforge_base/evolvisforge-5.1/gforge/common/include/cvsweb/FileHandler.class
   trunk/gforge_base/evolvisforge-5.1/gforge/common/include/cvsweb/RCSHandler.class
   trunk/gforge_base/evolvisforge-5.1/gforge/www/scm/viewFile.php
Modified:
   trunk/gforge_base/evolvisforge-5.1/gforge/ChangeLog
   trunk/gforge_base/evolvisforge-5.1/gforge/common/include/Group.class
   trunk/gforge_base/evolvisforge-5.1/gforge/www/scm/index.php
Log:
Added Dracos Moinescu cvsweb contrib


Modified: trunk/gforge_base/evolvisforge-5.1/gforge/ChangeLog
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge/ChangeLog	2011-02-24 15:53:58 UTC (rev 8860)
+++ trunk/gforge_base/evolvisforge-5.1/gforge/ChangeLog	2011-02-24 15:54:00 UTC (rev 8861)
@@ -1,6 +1,7 @@
-2003-06-09 Christian Bayle	<bayle at debian.org>
+2003-06-10 Christian Bayle	<bayle at debian.org>
 
 	* Added Ronald Petty cvs browser as an alternate cvs browser
+	* Added Dracos Moinescu cvs browser as an alternate cvs browser
 
 2003-06-09  Roland Mas  <99.roland.mas at aist.enst.fr>
 

Modified: trunk/gforge_base/evolvisforge-5.1/gforge/common/include/Group.class
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge/common/include/Group.class	2011-02-24 15:53:58 UTC (rev 8860)
+++ trunk/gforge_base/evolvisforge-5.1/gforge/common/include/Group.class	2011-02-24 15:54:00 UTC (rev 8861)
@@ -790,7 +790,37 @@
 	}
 
 
-
+	/**
+	 * getGroupAdmins() - Get group admin list
+	 *
+	 */
+	function getGroupAdmins() {
+		    // this function gets all group admins in order to send Jabber and mail messages
+		    $q = "SELECT user_id FROM user_group WHERE admin_flags = 'A' AND group_id = ".$this->getID();
+		    //echo($q."<br/>");
+		    $res = db_query($q);
+		    $users = array();
+		    for($i=0;$i<db_numrows($res);$i++)
+			array_push($users,db_result($res,$i,'user_id'));
+		    return implode(",",$users);
+	}
+		
+	/**
+	 * getMemberRole() - Get member role
+	 *
+	 * @param	   int	 The user ID
+	 *
+	 */
+	function getMemberRole($user_id) {
+		    $q = "SELECT member_role FROM user_group WHERE user_id = $user_id AND group_id = ".$this->getID();
+		    $res = db_query($q);
+		    if(db_numrows($res))
+		    {
+			return db_result($res,0,'member_role');
+		    }
+		    return 0;
+	}
+		
 	/*
 
 		Common Group preferences for tools
@@ -1650,6 +1680,7 @@
 	}
 }
 
+
 // Local Variables:
 // mode: php
 // c-file-style: "bsd"

Added: trunk/gforge_base/evolvisforge-5.1/gforge/common/include/cvsweb/DirectoryHandler.class
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge/common/include/cvsweb/DirectoryHandler.class	                        (rev 0)
+++ trunk/gforge_base/evolvisforge-5.1/gforge/common/include/cvsweb/DirectoryHandler.class	2011-02-24 15:54:00 UTC (rev 8861)
@@ -0,0 +1,80 @@
+<?php
+class DirectoryHandler extends ErrorHandler
+{
+    var $__DIR_HANDLER = null;
+    var $__DIR_NAME = "";
+    var $__TO_HIDE = null;
+    
+    function openDirectory()
+    {
+	if($this->__DIR_NAME == "")
+	{
+	    $this->setError("You must provide a directory name");
+	    return false;
+	}
+	if(!is_dir($this->__DIR_NAME))
+	{
+	    $this->setError($this->__DIR_NAME." is not a directory");
+	    return false;
+	}
+	$this->__DIR_HANDLER = @opendir($this->__DIR_NAME);
+	$this->__DIR_NAME = $DIRNAME;
+	if(!$this->__DIR_HANDLER)
+	{
+	    $this->setError("Could not open directory '".$this->__DIR_NAME."'");
+	    return false;
+	}
+	return true;
+    }
+    
+    function closeDirectory()
+    {
+	closedir($this->__DIR_HANDLER);
+	$this->__DIR_HANDLER = null;
+	$this->__DIR_NAME = "";
+    }
+    
+    function readDirectory($DIRNAME)
+    {
+	$this->__DIR_NAME = $DIRNAME;
+	if(!$this->openDirectory())
+	    return false;
+	
+	$directories = array();
+	$files = array();
+	while(false !== ($file = readdir($this->__DIR_HANDLER)))
+	{	
+	    $allow = 1;
+	    if(is_array($this->__TO_HIDE))
+	    {
+		foreach($this->__TO_HIDE AS $k=>$v)
+		{
+		    if($v == ".")
+			$v = "\.";
+		    $pregString = "/^$v/";
+		    if(preg_match($pregString,$file))
+			$allow = 0;
+		}
+	    }
+
+	    if($allow)
+	    {
+	        if(is_dir($DIRNAME."/".$file))
+		    array_push($directories,$file);
+		if(is_file($DIRNAME."/".$file))
+		    array_push($files,$file);
+	    }
+	}
+	
+	$this->closeDirectory();
+	
+	sort($files);
+	sort($directories);
+	
+	return array_merge($directories,$files);
+    }
+    
+    function hideFiles($FILES=".|CVS")
+    {	$this->__TO_HIDE = explode("|",$FILES);}
+}
+?>
\ No newline at end of file

Added: trunk/gforge_base/evolvisforge-5.1/gforge/common/include/cvsweb/ErrorHandler.class
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge/common/include/cvsweb/ErrorHandler.class	                        (rev 0)
+++ trunk/gforge_base/evolvisforge-5.1/gforge/common/include/cvsweb/ErrorHandler.class	2011-02-24 15:54:00 UTC (rev 8861)
@@ -0,0 +1,16 @@
+<?php
+class ErrorHandler
+{
+    var $__ERROR = "NONE";
+    
+    function setError($string)
+    {	$this->__ERROR = $string;}
+    
+    function getError()
+    {
+	$error = $this->__ERROR;
+	$this->__ERROR = "NONE";
+	return $error;
+    }
+}
+?>
\ No newline at end of file

Added: trunk/gforge_base/evolvisforge-5.1/gforge/common/include/cvsweb/FileHandler.class
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge/common/include/cvsweb/FileHandler.class	                        (rev 0)
+++ trunk/gforge_base/evolvisforge-5.1/gforge/common/include/cvsweb/FileHandler.class	2011-02-24 15:54:00 UTC (rev 8861)
@@ -0,0 +1,71 @@
+<?php
+class FileHandler extends ErrorHandler
+{
+    var $__FILE_HANDLER = null;
+    var $__FILE_NAME = "";
+    
+    function openFile($FILENAME,$MODE="r+")
+    {
+	$this->__FILE_NAME = $FILENAME;
+	if(false === ($result = fopen($FILENAME,$MODE)))
+	{
+	    $this->setError("Could not open '$FILENAME'");
+	    return false;
+	}
+	$this->__FILE_HANDLER = $result;
+	return true;
+    }
+    
+    function closeFile()
+    {
+	fclose($this->__FILE_HANDLER);
+	$this->__FILE_HANDLER = null;
+    }
+    
+    function readContents($FILENAME,$OVERWRITE=false)
+    {
+	if($this->__FILE_HANDLER && !$OVERWRITE)
+	{
+	    $this->setError("Another file was opened before: $this->__FILE_NAME");
+	    return false;
+	}
+	
+	$this->openFile($FILENAME);
+	$CONTENTS = fread($this->__FILE_HANDLER,filesize($FILENAME));
+	$this->closeFile();
+	
+	return $CONTENTS;
+    }
+    
+    function generateTemp($DIR="/tmp")
+    {
+	list($msec,$sec) = explode(" ",microtime());
+	$srand = (float)$msec * 100000 + (float)$sec;
+	srand($srand);
+	$temp = $DIR."/".MD5(rand());
+	return $temp;
+    }
+    
+    function deleteFile($FILENAME)
+    {
+	if(!unlink($FILENAME))
+	{
+	    $this->setError("Could not delete '$FILENAME'");
+	    return false;
+	}
+	return true;
+    }
+    
+    function getFileType($FILENAME)
+    {
+	if(is_dir($FILENAME))
+	    return 1;
+	if(is_file($FILENAME))
+	    return 2;
+	return 0;
+    }
+    
+    function getBasename($FILENAME)
+    {	return basename($FILENAME);}
+}
+?>
\ No newline at end of file

Added: trunk/gforge_base/evolvisforge-5.1/gforge/common/include/cvsweb/RCSHandler.class
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge/common/include/cvsweb/RCSHandler.class	                        (rev 0)
+++ trunk/gforge_base/evolvisforge-5.1/gforge/common/include/cvsweb/RCSHandler.class	2011-02-24 15:54:00 UTC (rev 8861)
@@ -0,0 +1,334 @@
+<?php
+class RCSHandler extends FileHandler
+{
+    var $__LOG = "";
+
+    function getRCSLog($RCSFILE,$REV="all")
+    {
+	$rev = "";
+	if($REV != "all")
+	    $rev = "-r$REV";
+	
+	$file = $this->generateTemp();	
+	$cmd = "rlog $rev $RCSFILE > $file";
+	if(false === ($result = system($cmd)))
+	{
+	    $this->setError("Could not execute '$cmd'");
+	    return false;
+	}
+	
+	if(false === ($log = $this->readContents($file)))
+	    return false;
+	
+	$this->__LOG = $log;
+	
+	if(!$this->deleteFile($file))
+	    return false;
+
+	return true;
+    }
+    
+    function handleRCSLog()
+    {
+	if($this->__LOG == "")
+	{
+	    $this->setError("Get RCSLog (getRCSLog(\$RCSFILE)) before handling");
+	    return false;
+	}
+    	
+	$nfo = explode("----------------------------\n",$this->__LOG);
+	
+	$revisions = array();
+
+	for($i=1;$i<count($nfo);$i++)
+	{
+	    $rev = array();
+	    $revision = array();
+	    $info = array();
+	    
+	    $rev = explode("\n",$nfo[$i]);
+	    $info = explode(";",$rev[1]);
+
+	    $revision['REV'] = trim(substr($rev[0],9));
+	    $revision['DATE'] = trim(substr($info[0],6));
+    	    $revision['AUTHOR'] = trim(substr($info[1],10));
+	    $revision['BRANCH'] = "MAIN";
+	    $revision['LOG'] = "";
+	    
+	    $beginAt = 2;
+	    if(substr($rev[2],0,9) == "branches:")
+	    {
+		$revision['BRANCH'] = substr(substr($rev[2],10),0,-1);
+		$beginAt = 3;
+	    }
+	    
+	    $count = count($rev);
+	    for($j=$beginAt;$j<$count-1;$j++)
+	    {	
+		if(substr($rev[$j],40,5) != "=====")
+		    $revision['LOG'] .= $rev[$j];
+		if($j+2 < $count)
+		    $revision['LOG'] .= "\n";
+	    }
+	    $revisions[$revision['REV']] = $revision;
+	}
+	//krsort($revisions);
+	
+	return $revisions;
+    }
+
+    function getRevisionInfo($RCSFILE,$REV="")
+    {
+	if(false === $this->getRCSLog($RCSFILE,$REV))
+	    return false;
+	
+	if(false === ($revisions = $this->handleRCSLog()))
+	    return false;
+	
+	if($REV == "")
+	{
+	    $keys = array_keys($revisions);
+	    $REV = $keys[0];
+	}
+	
+	return $revisions[$REV];
+    }
+
+    function getRCSContent($RCSFILE,$REV="")
+    {
+	$file = $this->generateTemp();
+	$cmd = "co -r$REV -p $RCSFILE > $file";
+	if(false === ($result = system($cmd)))
+	{
+	    $this->setError("Could not execute '$cmd'");
+	    return false;
+	}
+	
+	if(false === ($content = $this->readContents($file)))
+	    return false;
+	
+	if(!$this->deleteFile($file))
+	    return false;
+
+
+	$content = str_replace("<","<",$content);
+	$content = str_replace(">",">",$content);
+	return $content;	
+    }
+    
+    function doDiff($RCSFILE,$REV1,$MODE="SC",$REV2="")
+    {
+	$file = $this->generateTemp();
+
+	$cmd = "rcsdiff -r$REV1 -r$REV2 -t %option% $RCSFILE > $file";
+
+	switch($MODE)
+	{
+	    case "SC":
+		$option = "";
+		$command = str_replace("%option%",$option,$cmd);
+		break;
+	    case "LC":
+		$option = "--side-by-side --width=120";
+		$command = str_replace("%option%",$option,$cmd);
+		break;
+	    case "U":
+		$option = "-u";
+		$command = str_replace("%option%",$option,$cmd);
+		break;
+	    default:
+		$option = "";
+		$command = str_replace("%option%",$option,$cmd);
+	}
+    
+	if(false === ($result = system($command)))
+	{
+	    $this->setError("Could not execute '$command'");
+	    return false;
+	}
+
+	if(false === ($DIFF = $this->readContents($file)))
+	    return false;
+	    
+	if(!$this->deleteFile($file))
+	    return false;
+	
+	switch($MODE)
+	{
+	    case "SC":
+		$DIFF = $this->shortDiff($DIFF);
+		$DIFF = "<i>Left colomn: </i><b>Revision $REV1</b> ||| <i>Right colomn: </i><b>Revision $REV2</b><br>".$DIFF;
+		break;
+	    case "LC":
+		$DIFF = $this->longDiff($DIFF,120);
+		$DIFF = "<i>Left colomn: </i><b>Revision $REV1</b> ||| <i>Right colomn: </i><b>Revision $REV2</b><br>".$DIFF;
+		break;
+	    case "U":
+		$DIFF = str_replace("\n","<br>",$DIFF);
+		break;
+	    default:
+		$DIFF = $this->shortDiff($DIFF);
+	}
+	
+	return $DIFF;
+    }
+    
+    function shortDiff($DIFF)
+    {
+	$diffChars = array("a","c","d");
+	$colors = array(
+	    "a" => array("#F0F0F0","#00FF00"),
+	    "d" => array("#FF0000","#F0F0F0"),
+	    "c" => array("#FFFF00","#FFFF00")
+	);
+	
+	$CONTENT = "
+	    <table cellpadding=\"1\" cellspacing=\"0\" border=\"0\" width=\"100%\">
+	";
+	$lines = explode("\n",$DIFF);
+	$i = 0;
+	while($i<count($lines)-1)
+	{
+	    $tr = "<tr><td width=\"50%\" bgcolor=\"%bgc1%\" valign=\"top\">%left%</td><td width=\"1\" bgcolor=\"#000000\"></td><td width=\"50%\" bgcolor=\"%bgc2%\" valign=\"top\">%right%</td></tr>";
+	    $firstChar = substr($lines[$i],0,1);
+	    if(is_numeric($firstChar))
+	    {
+		foreach($diffChars AS $k=>$vDiff)
+		{
+		    $position = strpos($lines[$i],$vDiff);
+		    if($position !== false)
+			break;
+		}
+		$diffTerms = explode($vDiff,$lines[$i]);	
+		$leftTerm = $diffTerms[0];
+		$rightTerm = $diffTerms[1];
+		
+		$LEFT = "";
+		$leftItems = explode(",",$leftTerm);
+		if($vDiff == "c" || $vDiff == "d")
+		{
+		    $nrLeft = count($leftItems);
+		    if($nrLeft == 1)
+		    {
+			$i++;
+			$LEFT .= substr($lines[$i],1,60);
+			$i++;
+		    }
+		    else
+		    {
+			$i++;
+			$numLines = $leftItems[1] - $leftItems[0];
+			for($j=$i;$j<=$i+$numLines;$j++)
+			{
+			    $LEFT .= substr($lines[$j],1,60)."<br>";
+		        }
+			$i+= $numLines+1;
+		    }
+		    $LEFT = str_replace("<","<",$LEFT);
+		    $LEFT = str_replace(">",">",$LEFT);
+		}
+		
+		$RIGHT = "";
+		$rightItems = explode(",",$rightTerm);
+		if($vDiff == "c" || $vDiff == "a")
+		{
+		    $nrRight = count($rightItems);
+		    if($nrRight == 1)
+		    {
+			$i++;
+			$RIGHT .= substr($lines[$i],1,60);
+			$i++;
+		    }
+		    else
+		    {
+			$i++;
+			$numLines = $rightItems[1] - $rightItems[0];
+			for($j=$i;$j<=$i+$numLines;$j++)
+			{
+			    $RIGHT .= substr($lines[$j],1,60)."<br>";
+			}
+			$i += $numLines;
+		    }
+		    $RIGHT = str_replace("<","<",$RIGHT);
+		    $RIGHT = str_replace(">",">",$RIGHT);
+		}
+		
+		$trLines = $tr;
+		$trLines = str_replace("%bgc1%","#FF6600",$trLines);
+		$trLines = str_replace("%bgc2%","#FF6600",$trLines);
+		$trLines = str_replace("%left%","<b>Line: ".$leftItems[0]."</b>",$trLines);
+		$trLines = str_replace("%right%","<b>Line: ".$rightItems[0]."</b>",$trLines);
+		
+		$trColor = array();
+		$trColor = $colors[$vDiff];
+		$tr = str_replace("%bgc1%",$trColor[0],$tr);
+		$tr = str_replace("%bgc2%",$trColor[1],$tr);
+		$tr = str_replace("%left%",str_replace(" "," ",$LEFT),$tr);
+		$tr = str_replace("%right%",str_replace(" "," ",$RIGHT),$tr);
+		$CONTENT .= $trLines.$tr;
+	    }
+	    else
+	    {	$i++;}
+	}
+	$CONTENT .= "</table>";
+	return $CONTENT;
+    }
+    
+    function longDiff($DIFF,$WIDTH)
+    {
+	$colors = array(
+	    ">" => array("#F0F0F0","#00FF00"),
+	    "<" => array("#FF0000","#F0F0F0"),
+	    "|" => array("#FFFF00","#FFFF00"),
+	    " " => array("#F0F0F0","#F0F0F0")
+	);
+	
+	$CONTENT = "
+	    <table cellpadding=\"1\" cellspacing=\"0\" border=\"0\" width=\"100%\">
+	";
+	$lines = explode("\n",$DIFF);
+	$i = 1;
+	$charPos = $WIDTH/2 - 1;// (!) $WIDTH % 2 == 0
+	while($i<count($lines)-1)
+	{
+	    if($lines[$i] != "")
+	    {
+		$tr = "<tr><td width=\"50%\" bgcolor=\"%bgc1%\" valign=\"top\">%left%</td><td width=\"1\" bgcolor=\"#000000\"></td><td width=\"50%\" bgcolor=\"%bgc2%\" valign=\"top\">%right%</td></tr>";
+		$diffChar = substr($lines[$i],$charPos,1);
+		$LEFT = substr($lines[$i],0,$charPos);
+		$LEFT = str_replace("<","<",$LEFT);
+		$LEFT = str_replace(">",">",$LEFT);
+		$RIGHT = substr($lines[$i],$charPos+1);
+		$RIGHT = str_replace("<","<",$RIGHT);
+		$RIGHT = str_replace(">",">",$RIGHT);
+
+		$trColor = array();
+		$trColor = $colors[$diffChar];
+		$tr = str_replace("%bgc1%",$trColor[0],$tr);
+		$tr = str_replace("%bgc2%",$trColor[1],$tr);
+		$tr = str_replace("%left%",str_replace(" "," ",$LEFT),$tr);
+		$tr = str_replace("%right%",str_replace(" "," ",$RIGHT),$tr);
+		$CONTENT .= $tr;
+	    }
+	    else
+	    {
+		$tr = "<tr><td width=\"50%\" bgcolor=\"%bgc1%\" valign=\"top\">%left%</td><td width=\"1\" bgcolor==\"#000000\"> </td><td width=\"50%\" bgcolor=\"%bgc2%\" valign=\"top\">%right%</td></tr>";
+		$diffChar = " ";
+		$LEFT = " ";
+		$RIGHT = " ";
+
+		$trColor = array();
+		$trColor = $colors[$diffChar];
+		$tr = str_replace("%bgc1%",$trColor[0],$tr);
+		$tr = str_replace("%bgc2%",$trColor[1],$tr);
+		$tr = str_replace("%left%",str_replace(" "," ",$LEFT),$tr);
+		$tr = str_replace("%right%",str_replace(" "," ",$RIGHT),$tr);
+		$CONTENT .= $tr;
+	    }
+	    $i++;
+	}
+	$CONTENT .= "</table>";
+	return $CONTENT;
+    }
+}
+?>
\ No newline at end of file

Modified: trunk/gforge_base/evolvisforge-5.1/gforge/www/scm/index.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge/www/scm/index.php	2011-02-24 15:53:58 UTC (rev 8860)
+++ trunk/gforge_base/evolvisforge-5.1/gforge/www/scm/index.php	2011-02-24 15:54:00 UTC (rev 8861)
@@ -114,14 +114,18 @@
 	echo $Language->getText('scm_index', 'browsetree');
 ?>
 		<UL>
-		<li><a href=<?php print account_group_cvsweb_url($project->getUnixName()); ?> >
+		<LI><a href=<?php print account_group_cvsweb_url($project->getUnixName()); ?> >
 			<b><?php echo $Language->getText('scm_index', 'browseit'); ?>(cvsweb)</b></a>
 		</UL>
 
 		<UL>
-		<li><a href=/scm/controller.php?group_id=<?php echo $group_id; ?> >
-			<b><?php echo $Language->getText('scm_index', 'browseit'); ?>(php)</b></a>
+		<LI>Ronald Petty contrib<BR><a href=/scm/controller.php?group_id=<?php echo $group_id; ?> >
+			<b><?php echo $Language->getText('scm_index', 'browseit'); ?> (php)</b></a>
 		</UL>
+		<UL>
+		<LI>Dracos Moinescu contrib<BR><a href="/scm/controlleroo.php?group_id=<?php echo $group_id; ?>&hide_attic=0" >
+			<b><?php echo $Language->getText('scm_index', 'browseit'); ?> (php OO)</b></a>
+		</UL>
 <?php
 }
 

Added: trunk/gforge_base/evolvisforge-5.1/gforge/www/scm/viewFile.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge/www/scm/viewFile.php	                        (rev 0)
+++ trunk/gforge_base/evolvisforge-5.1/gforge/www/scm/viewFile.php	2011-02-24 15:54:00 UTC (rev 8861)
@@ -0,0 +1,140 @@
+<?php
+/**
+  *
+  * SourceForge CVS Frontend
+  *
+  * SourceForge: Breaking Down the Barriers to Open Source Development
+  * Copyright 1999-2001 (c) VA Linux Systems
+  * http://sourceforge.net
+  *
+  * @version   $Id$
+  *
+  */
+
+
+require_once('pre.php');    
+require_once('common/include/account.php');
+
+require_once('common/include/cvsweb/ErrorHandler.class');
+require_once('common/include/cvsweb/DirectoryHandler.class');
+require_once('common/include/cvsweb/FileHandler.class');
+require_once('common/include/cvsweb/RCSHandler.class');
+
+//only projects can use cvs, and only if they have it turned on
+$project =& group_get_object($group_id);
+$cvsroot = $project->getUnixName();
+$sys_cvsroot_dir = '/cvsroot/';
+
+if (!$project->isProject()) {
+ 	exit_error($Language->getText('scm_index','error_only_projects_can_use_cvs'));
+}
+if (!$project->usesCVS()) {
+	exit_error($language->getText('scm_index','error_this_project_has_turned_off'));
+}
+
+site_project_header(array('title'=>$Language->getText('scm_index','cvs_repository'),'group'=>$group_id,'toptab'=>'scm_index','pagename'=>'scm_index','sectionvals'=>array($project->getPublicName())));
+
+if($project->enableAnonCVS()) {
+	$allow = 1;
+} else {
+	if(session_loggedin()) {
+		$user =& session_get_user();
+		$memberRole = $project->getMemberRole($user->getID());
+		if($memberRole == 1 || $memberRole == 2) {//only for Project Manager & Developer - others must not view sources
+			$allow = 1;
+		} else {
+			$allow = 0;
+		}
+	} else {
+		$allow = 0;
+	}
+}
+
+if($allow)
+{
+    $DHD = new DirectoryHandler();
+    $FHD = new FileHandler();
+    $RCH = new RCSHandler();
+
+    $CVSROOT = $GLOBALS['sys_cvsroot_dir'].$cvsroot;
+    $DIRNAME = ($file_name != "")?"$file_name":"";
+    $DIRNAME = $CVSROOT.$DIRNAME;
+
+    $DIRPATH = explode("/",$file_name);
+    for($i=0;$i<count($DIRPATH)-1;$i++)
+    {
+	$LINKPATH = array();
+	for($j=0;$j<=$i;$j++)
+	    $LINKPATH[] = $DIRPATH[$j];
+	$LINK = implode("/",$LINKPATH);
+	$value = ($DIRPATH[$i] == "")?"CVSROOT":$DIRPATH[$i];
+	echo("<b><a href=\"http://".$GLOBALS['sys_default_domain']."/scm/index.php?group_id=$group_id&dir_name=$LINK&hide_attic=$hide_attic\">$value</a>/</b>");
+    }
+
+    echo("<br>");
+    echo("<br>");
+    $value = "<font size=\"+2\"><b>".$DIRPATH[count($DIRPATH)-1]."</b></font>";
+    $fileLink = "<a href=\"http://".$GLOBALS['sys_default_domain']."/scm/viewFile.php?group_id=$group_id&file_name=$file_name&r2=$r2&hide_attic=$hide_attic\">$value</a>";
+    echo($fileLink);
+    echo("<br>");
+    echo("<br>");
+
+    if($view_action == "")
+	$view_action = "l";
+
+    $RCSFile = $DIRNAME.",v";
+    switch($view_action)
+    {
+	case "l":
+	    if(false === $RCH->getRCSLog($RCSFile))
+		echo("Error: ".$RCH->getError());
+
+	    if(false === ($revisions = $RCH->handleRCSLog()))
+	    {    echo("Error: ".$RCH->getError());}
+	    else
+	    {
+		$diffr = "";
+		foreach($revisions AS $k=>$v)
+		{
+		    $viewLink = "<a href=\"http://".$GLOBALS['sys_default_domain']."/scm/viewFile.php?group_id=$group_id&file_name=$file_name&view_action=v&r=".$v['REV']."&hide_attic=$hide_attic\">view file</a>";
+		    $diffLink = "<a href=\"http://".$GLOBALS['sys_default_domain']."/scm/viewFile.php?group_id=$group_id&file_name=$file_name&view_action=d&r2=$diffr&r1=".$v['REV']."&hide_attic=$hide_attic\">revision $diffr</a>";
+		    if(isset($r2) && $r2 != "")
+			$diffLink .= ", or selected <a href=\"http://".$GLOBALS['sys_default_domain']."/scm/viewFile.php?group_id=$group_id&file_name=$file_name&view_action=d&r2=$r2&r1=".$v['REV']."&hide_attic=$hide_attic\">revision $r2</a>";
+		    $selectForDiff = "<a href=\"http://".$GLOBALS['sys_default_domain']."/scm/viewFile.php?group_id=$group_id&file_name=$file_name&view_action=l&r2=".$v['REV']."&hide_attic=$hide_attic\">select for diff</a>";
+    		    echo("<b>Revision:</b> ".$v['REV']." ($viewLink) - ($selectForDiff)<br>");
+		    echo("<b>Date:</b> ".$v['DATE']."<br>");
+		    echo("<b>Author:</b> ".$v['AUTHOR']."<br>");
+		    echo("<b>Branch:</b> ".$v['BRANCH']."<br>");
+		    echo("<b>Log:</b> ".$v['LOG']."<br>");
+		    echo("<b>Diff To:</b> $diffLink<br>");
+		    echo("<hr>");
+		    $diffr = $v['REV'];
+		}
+	    }
+	    break;
+	case "v":
+    	    if(false === ($content = $RCH->getRCSContent($RCSFile,$r)))
+		echo("Error: ".$RCH->getError());
+	    $content = str_replace("\n","<br>",$content);
+	    $content = str_replace("\t","        ",$content);
+	    echo($content);
+	    break;
+	case "d":
+	    $diffL1 = "<a href=\"http://".$GLOBALS['sys_default_domain']."/scm/viewFile.php?group_id=$group_id&file_name=$file_name&view_action=d&r2=$r2&r1=$r1&diff_type=SC&hide_attic=$hide_attic\">Short Color Diff</a>";
+	    $diffL2 = "<a href=\"http://".$GLOBALS['sys_default_domain']."/scm/viewFile.php?group_id=$group_id&file_name=$file_name&view_action=d&r2=$r2&r1=$r1&diff_type=LC&hide_attic=$hide_attic\">Long Color Diff</a>";
+	    $diffL3 = "<a href=\"http://".$GLOBALS['sys_default_domain']."/scm/viewFile.php?group_id=$group_id&file_name=$file_name&view_action=d&r2=$r2&r1=$r1&diff_type=U&hide_attic=$hide_attic\">Unified Diff</a>";
+	    echo("<b>".$diffL1." | ".$diffL2." | ".$diffL3."</b><br><br>");
+	    if($diff_type == "")
+		$diff_type = "LC";
+	    if(false === ($content = $RCH->doDiff($RCSFile,$r1,$diff_type,$r2)))
+		echo("Error: ".$RCH->getError());
+	    echo($content);
+	    break;
+    }
+}
+else
+{
+    echo("Error: u don't have acces rigths to <b>".$project->getPublicName()."</b> CVS root");
+}
+site_project_footer(array());
+?>



More information about the evolvis-commits mailing list