[Fedora-directory-commits] dsgw/orgbin org.in,1.3,1.4

Richard Allen Megginson (rmeggins) fedora-directory-commits at redhat.com
Thu Feb 28 02:49:23 UTC 2008


Author: rmeggins

Update of /cvs/dirsec/dsgw/orgbin
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv21628/dsgw/orgbin

Modified Files:
	org.in 
Log Message:
clean up org chart code - added tests for org chart


Index: org.in
===================================================================
RCS file: /cvs/dirsec/dsgw/orgbin/org.in,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- org.in	30 Jan 2008 02:22:46 -0000	1.3
+++ org.in	28 Feb 2008 02:49:20 -0000	1.4
@@ -76,10 +76,7 @@
 # Comm478 :   ---Mozilla/4.78 [en] (Windows NT 5.0; U)---
 # Nscp622 :   ---Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.4.1) Gecko/20020314 Netscape6/6.2.2---
 
-$browser_is_msie = "MSIE" if $agentstring =~ /MSIE/;
-
-# is this Windows?
-$isWindows = -d '\\';
+$browser_is_msie = "MSIE" if ($agentstring and ($agentstring =~ /MSIE/));
 
 ##########################################
 #
@@ -132,7 +129,7 @@
 	$uid = $cg->param("$config_tokens{'attrib-farleft-rdn'}")
 }
 
-if ($uid eq "") 
+if (!$uid or ($uid eq "")) 
 {
 	&output_html_header("no-javascript");
 	print "No username selected...</BODY></HTML>";
@@ -444,7 +441,7 @@
 			$people[$total-1][1] = $entry->{$config_tokens{'attrib-farleft-rdn'}}[0];
 			$people[$total-1][2] = url_encode($entry->{dn});
 			$people[$total-1][3] = $entry->{mail}[0];
-			$people[$total-1][4] = $entry->{$config_tokens{"attrib-job-title"}}[0];
+			$people[$total-1][4] = $entry->{$config_tokens{"attrib-job-title"}}[0] || "";
 
 			# AIM
 			$people[$total-1][5] = "(none)";
@@ -522,9 +519,8 @@
 {
 	my ($entry) = @_;
 
-	@manager= split (/,/ , $entry->{$config_tokens{'attrib-manager'}}[0]);
-	@splitagain = split (/=/, @manager[0] );
-	$manageruid = @splitagain[1];
+    my @rdns = ldap_explode_dn($entry->getValue($config_tokens{'attrib-manager'}), 1);
+	my $manageruid = $rdns[0];
 
 	if ( $entry->{$config_tokens{'attrib-farleft-rdn'}}[0]  eq  $manageruid)
 	{
@@ -728,9 +724,9 @@
 
 	my ($returnvalue) = "(none)";
 
-	if ( $status eq "discover" )
+	if ( $status and ( $status eq "discover" ) )
 	{
-		if (  ($screenname eq "(none)") || ($screenname eq "OFFLINE") )
+		if ( $screenname and ( ($screenname eq "(none)") || ($screenname eq "OFFLINE") ) )
 		{
 			$status = "OFFLINE";
 		}
@@ -980,12 +976,6 @@
 
 sub read_config_file()
 {
-my $curdir;
-if ($isWindows) {
-	$curdir = `cd`; chop($curdir);
-} else {
-	$curdir = `pwd`; chop($curdir);
-}
 if (!open (FILE, "@contextdir@/orgchart.conf") )
 {
 	&output_html_header("no-javascript");
@@ -1173,9 +1163,9 @@
 #  below code right after the MyOrgChart overrides above, to make sure the
 #  below has the final say, for the icon-related settings.
 #
-if ( $config_tokens{"icons-aim-visible"} eq "disabled" )  { $config_tokens{"icons-aim-visible"} eq "no"; }
-if ( $config_tokens{"icons-email-visible"} eq "disabled" )  { $config_tokens{"icons-email-visible"} eq "no"; }
-if ( $config_tokens{"icons-phonebook-visible"} eq "disabled" )  { $config_tokens{"icons-phonebook-visible"} eq "no"; }
+if ( $config_tokens{"icons-aim-visible"} eq "disabled" )  { $config_tokens{"icons-aim-visible"} = "no"; }
+if ( $config_tokens{"icons-email-visible"} eq "disabled" )  { $config_tokens{"icons-email-visible"} = "no"; }
+if ( $config_tokens{"icons-phonebook-visible"} eq "disabled" )  { $config_tokens{"icons-phonebook-visible"} = "no"; }
 if ( $config_tokens{"icons-locator-visible"} eq "disabled" )  { $config_tokens{"icons-locator-visible"} = "no"; }
 
 }
@@ -1496,7 +1486,7 @@
 	#					  the boxes that people are in are not printed, so by making
 	#					  border=1, at least you can see the box on the hardcopy version
 	#
-	if (  ( "$browser_is_msie" ) &&  ( $print_mode ) )
+	if (  ( $browser_is_msie ) &&  ( $print_mode ) )
 	{
 		print "<table border=1  CELLSPACING=1 > \n";
 	}
@@ -1520,10 +1510,11 @@
 	$emailstr = is_email_in_layer ( $config_tokens{"icons-email-visible"}, $entry->{mail}[0] );
 	$pbstr = is_pb_in_layer ( $config_tokens{"icons-phonebook-visible"}, $tempstr );
 	$locatorstr = is_locator_in_layer ( $config_tokens{"icons-locator-visible"}, $tempstr2 );
+    my $title = $entry->getValue($config_tokens{"attrib-job-title"}) || "";
 
 	if ( !($print_mode) )
 	{
-		print "\n\n <A HREF='javascript:return false;' target=_top onMouseOver=\"showLayer('$tempstr2','$entry->{$config_tokens{\"attrib-job-title\"}}[0]','$emailstr','$pbstr','$locatorstr','$aimid');\" onMouseOut=\"OutLayer();\">";
+		print "\n\n <A HREF='javascript:return false;' target=_top onMouseOver=\"showLayer('$tempstr2','$title','$emailstr','$pbstr','$locatorstr','$aimid');\" onMouseOut=\"OutLayer();\">";
 		print "<img src=\"@orguri@/arrow.gif\" border=0 align=TEXTTOP>";
 		print "</A> \n";
 	}
@@ -1536,17 +1527,20 @@
 	print_locator_icon_if_outside_layer( $config_tokens{"icons-locator-visible"}, $tempstr2 );
 
 	print "<BR>\n";
-	print "$entry->{$config_tokens{\"attrib-job-title\"}}[0]<BR>\n</font>";
+	print "$title<BR>\n</font>";
 
 	#
 	# Get the full name of the manager of the uid entered by the end-user
 	#
 
-	@manager= split (/,/ , $entry->{$config_tokens{'attrib-manager'}}[0]);
-	@splitagain = split (/=/, @manager[0] );
-	$manager = @splitagain[1];
-	$managerSearch = $config_tokens{'attrib-farleft-rdn'} . "=" . $manager;
-	$managerEntry = $conn->search($config_tokens{"ldap-search-base"},"subtree", $managerSearch, 0, @return_attribs);
+    my $mgrdn = $entry->getValue($config_tokens{'attrib-manager'});
+    my $managerEntry;
+    if ($mgrdn) {
+        my @rdns = ldap_explode_dn($entry->getValue($mgrdn), 1);
+        my $manager = $rdns[0];
+        my $managerSearch = $config_tokens{'attrib-farleft-rdn'} . "=" . $manager;
+        $managerEntry = $conn->search($config_tokens{"ldap-search-base"},"subtree", $managerSearch, 0, @return_attribs);
+    }
 
 	print "$fontstring";
 	print "Manager: ";
@@ -1555,7 +1549,7 @@
 	{
 		$tempstr = url_encode($managerEntry->{dn});
 		$tempstr2  = url_encode($managerEntry->{cn}[0]);
-		$managertitle = $managerEntry->{$config_tokens{"attrib-job-title"}}[0];
+		$managertitle = $managerEntry->{$config_tokens{"attrib-job-title"}}[0] || "";
 
 		$aimid = is_aimid_in_layer ( $config_tokens{"icons-aim-visible"} , $managerEntry->{nsAIMStatusText}[0] , $managerEntry->{nsaimid}[0] );
 		$emailstr = is_email_in_layer ( $config_tokens{"icons-email-visible"}, $managerEntry->{mail}[0] );
@@ -1633,7 +1627,7 @@
 			{
 				$info = $sortedPeople[$tempnum+1][0];
 				@tempdata = split(/\//, $info);
-				$nextentry = @tempdata[1];
+				$nextentry = $tempdata[1];
 			}
 
 			if ( "$entry" ne "$nextentry" )
@@ -1655,7 +1649,7 @@
 
 				print "\n $entry ";
 
-				if (  $sortedPeople[$tempnum][7] =~ /nonleaf/  )
+				if ( $sortedPeople[$tempnum][7] and ( $sortedPeople[$tempnum][7] =~ /nonleaf/  ) )
 				{
 					#
 					#  If we are only supposed to draw one level for the org chart,
@@ -1850,7 +1844,7 @@
 				#                     the boxes that people are in are not printed, so by making
 				#                     border=1, at least you can see the box on the hardcopy version
 				#
-				if (  ( "$browser_is_msie" ) &&  ( $print_mode ) )           
+				if (  ( $browser_is_msie ) &&  ( $print_mode ) )           
 				{
 					print "<table border=1  CELLSPACING=1 > \n"; 
 				}
@@ -1931,7 +1925,8 @@
 			#
 			#  then print the org chart icon
 			#
-			if (  ( $sortedPeople[$tempnum+1][0] =~ /$tempdata[@tempdata-1]/  ) ||  ( $sortedPeople[$tempnum][7] =~ /nonleaf/ )  )
+			if (  ( $sortedPeople[$tempnum+1][0] and ( $sortedPeople[$tempnum+1][0] =~ /$tempdata[@tempdata-1]/  ) ) ||
+                  ( $sortedPeople[$tempnum][7] and ( $sortedPeople[$tempnum][7] =~ /nonleaf/ ) ) )
 			{
 				if ( ($print_mode) &&  ($current_indent == 1 )  )
 				{




More information about the Fedora-directory-commits mailing list