[LON-CAPA-cvs] cvs: loncom(version_2_9_X) /interface loncommon.pm

raeburn raeburn@source.lon-capa.org
Mon, 07 Sep 2009 13:13:59 -0000


raeburn		Mon Sep  7 13:13:59 2009 EDT

  Modified files:              (Branch: version_2_9_X)
    /loncom/interface	loncommon.pm 
  Log:
  - Backport 1.886, 1.887, 1.888.
  
  
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.692.4.16 loncom/interface/loncommon.pm:1.692.4.17
--- loncom/interface/loncommon.pm:1.692.4.16	Sun Aug 16 22:41:50 2009
+++ loncom/interface/loncommon.pm	Mon Sep  7 13:13:58 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.692.4.16 2009/08/16 22:41:50 raeburn Exp $
+# $Id: loncommon.pm,v 1.692.4.17 2009/09/07 13:13:58 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -482,7 +482,7 @@
 
 sub coursebrowser_javascript {
     my ($domainfilter,$sec_element,$formname)=@_;
-    my $crs_or_grp_alert = &mt('Please select the type of LON-CAPA entity - Course or Community - for which you wish to add/modify a user role');
+    my $crs_or_grp_alert = &mt('Please select the type of LON-CAPA entity - Course or Community - for which you wish to add/modify a user role.');
     my $id_functions = &javascript_index_functions();
     my $output = '
 <script type="text/javascript" language="JavaScript">
@@ -597,7 +597,7 @@
     my $id_functions = &javascript_index_functions();
     return <<"ENDUSERBRW";
 
-function openuserbrowser(formname,uname,udom,ulast,ufirst,uemail,hideudom,crsdom) {
+function openuserbrowser(formname,uname,udom,ulast,ufirst,uemail,hideudom,crsdom,caller) {
     var url = '/adm/pickuser?';
     var userdom = getDomainFromSelectbox(formname,udom);
     if (userdom != null) {
@@ -612,6 +612,9 @@
                                 '&uemailelement='+uemail+
                                 '&hideudomelement='+hideudom+
                                 '&coursedom='+crsdom;
+    if ((caller != null) && (caller != undefined)) {
+        url += '&caller='+caller;
+    }
     var title = 'User_Browser';
     var options = 'scrollbars=1,resizable=1,menubar=0';
     options += ',width=700,height=600';
@@ -619,23 +622,27 @@
     stdeditbrowser.focus();
 }
 
-function fix_domain (formname,udom,origdom) {
+function fix_domain (formname,udom,origdom,uname) {
     var formid = getFormIdByName(formname);
     if (formid > -1) {
+        var unameid = getIndexByName(formid,uname);
         var domid = getIndexByName(formid,udom);
         var hidedomid = getIndexByName(formid,origdom);
         if (hidedomid > -1) {
             var fixeddom = document.forms[formid].elements[hidedomid].value;
-            if (domid > -1) {
-                var slct = document.forms[formid].elements[domid];
-                if (slct.type == 'select-one') {
-                    var i;
-                    for (i=0;i<slct.length;i++) {
-                        if (slct.options[i].value==fixeddom) { slct.selectedIndex=i; }
+            var unameval = document.forms[formid].elements[unameid].value;
+            if ((fixeddom != '') && (fixeddom != undefined) && (fixeddom != null) && (unameval != '') && (unameval != undefined) && (unameval != null)) {
+                if (domid > -1) {
+                    var slct = document.forms[formid].elements[domid];
+                    if (slct.type == 'select-one') {
+                        var i;
+                        for (i=0;i<slct.length;i++) {
+                            if (slct.options[i].value==fixeddom) { slct.selectedIndex=i; }
+                        }
+                    }
+                    if (slct.type == 'hidden') {
+                        slct.value = fixeddom;
                     }
-                }
-                if (slct.type == 'hidden') {
-                    slct.value = fixeddom;
                 }
             }
         }
@@ -711,9 +718,9 @@
 
 sub selectuser_link {
     my ($form,$unameelem,$domelem,$lastelem,$firstelem,$emailelem,$hdomelem,
-        $coursedom,$linktext) = @_;
+        $coursedom,$linktext,$caller) = @_;
     return '<a href="javascript:openuserbrowser('."'$form','$unameelem','$domelem',".
-           "'$lastelem','$firstelem','$emailelem','$hdomelem','$coursedom'".
+           "'$lastelem','$firstelem','$emailelem','$hdomelem','$coursedom','$caller'".
            ');">'.$linktext.'</a>';
 }
 
@@ -2971,7 +2978,7 @@
 }
 
 sub track_student_link {
-    my ($linktext,$sname,$sdom,$target,$start) = @_;
+    my ($linktext,$sname,$sdom,$target,$start,$only_body) = @_;
     my $link ="/adm/trackstudent?";
     my $title = 'View recent activity';
     if (defined($sname) && $sname !~ /^\s*$/ &&
@@ -2985,6 +2992,7 @@
         $target = '';
     }
     if ($start) { $link.='&amp;start='.$start; }
+    if ($only_body) { $link .= '&amp;only_body=1'; }
     $title = &mt($title);
     $linktext = &mt($linktext);
     return qq{<a href="$link" title="$title" $target>$linktext</a>}.