diff -ruN course/category.php /home/dan/course/category.php
--- course/category.php	2006-12-24 18:56:00.000000000 +0000
+++ /home/dan/course/category.php	2006-12-24 18:53:56.000000000 +0000
@@ -315,43 +315,10 @@
             echo '<td><a '.$linkcss.' href="view.php?id='.$acourse->id.'">'.$acourse->fullname.'</a></td>';
             if ($creatorediting) {
                 echo "<td>";
-                if (has_capability('moodle/course:update', $coursecontext)) {
-                    echo '<a title="'.$strsettings.'" href="'.$CFG->wwwroot.'/course/edit.php?id='.
-                         $acourse->id.'">'.
-                         '<img src="'.$CFG->pixpath.'/t/edit.gif" height="11" width="11" border="0" alt="'.$stredit.'" /></a> ';        }
-                
-                // role assignment link     
-                if (has_capability('moodle/role:assign', $coursecontext)) { 
-                    echo'<a title="'.get_string('assignroles', 'role').'" href="'.$CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.$coursecontext->id.'"><img src="'.$CFG->pixpath.'/i/roles.gif" height="11" width="11" alt="'.get_string('assignroles', 'role').'" /></a>';
-                }                       
-                         
-                if (has_capability('moodle/course:delete', $coursecontext)) {
-                    echo '<a title="'.$strdelete.'" href="delete.php?id='.$acourse->id.'">'.
-                            '<img src="'.$CFG->pixpath.'/t/delete.gif" height="11" width="11" border="0" alt="'.$strdelete.'" /></a> ';
-                }
-
-                if (has_capability('moodle/course:visibility', $coursecontext)) {
-                    if (!empty($acourse->visible)) {
-                        echo '<a title="'.$strhide.'" href="category.php?id='.$category->id.'&amp;page='.$page.
-                            '&amp;perpage='.$perpage.'&amp;hide='.$acourse->id.'&amp;sesskey='.$USER->sesskey.'">'.
-                            '<img src="'.$CFG->pixpath.'/t/hide.gif" height="11" width="11" border="0" alt="'.$strhide.'" /></a> ';
-                    } else {
-                        echo '<a title="'.$strshow.'" href="category.php?id='.$category->id.'&amp;page='.$page.
-                            '&amp;perpage='.$perpage.'&amp;show='.$acourse->id.'&amp;sesskey='.$USER->sesskey.'">'.
-                            '<img src="'.$CFG->pixpath.'/t/show.gif" height="11" width="11" border="0" alt="'.$strshow.'" /></a> ';
-                    }
-                }
 
-                if (has_capability('moodle/site:backup', $coursecontext)) {
-                    echo '<a title="'.$strbackup.'" href="../backup/backup.php?id='.$acourse->id.'">'.
-                            '<img src="'.$CFG->pixpath.'/t/backup.gif" height="11" width="11" border="0" alt="'.$strbackup.'" /></a> ';
-                }
-                    
-                if (has_capability('moodle/site:restore', $coursecontext)) {
-                    echo '<a title="'.$strrestore.'" href="../files/index.php?id='.$acourse->id.
-                         '&amp;wdir=/backupdata">'.
-                         '<img src="'.$CFG->pixpath.'/t/restore.gif" height="11" width="11" border="0" alt="'.$strrestore.'" /></a> ';
-                }
+		$returl= $CFG->wwwroot . '/course/category.php?id='.$category->id;
+		$returl.= '&amp;page='.$page. '&amp;perpage='.$perpage.'&amp;sesskey='.$USER->sesskey;
+		print_course_editbar($acourse->id, $returl);
 
                 if (has_capability('moodle/category:update', $context)) {
                     if ($up) {
diff -ruN course/lib.php /home/dan/course/lib.php
--- course/lib.php	2006-12-24 18:55:35.000000000 +0000
+++ /home/dan/course/lib.php	2006-12-24 18:53:48.000000000 +0000
@@ -2332,4 +2332,67 @@
 	return $sectionname;
 }
 
+/**
+ * prints the various course edit options based on users permissions
+ *
+ * @param  int $courseid ID of course in quetion
+ * @param  string $showhideurl url with which to be used with show/hide interface
+ */
+
+function print_course_editbar($courseid, $showhideurl){
+    global $CFG;
+
+    $courseroot = $CFG->wwwroot . '/course';
+
+    if( ! $course = get_record('course','id', $courseid) ){
+      return false;
+    }
+
+    $coursecontext = get_context_instance(CONTEXT_COURSE, $courseid);
+
+
+    // checks whether user can update course settings
+    if (has_capability('moodle/course:update', $coursecontext)) {
+      echo '<a title="'.get_string('settings')."\" href=\"$courseroot/edit.php?id=$courseid\"><img".
+	' src="' . $CFG->pixpath . '/t/edit.gif" height="11" width="11" border="0" alt="'.get_string("settings").'"></a> ';
+    }
+
+    // checks whether user can do role assignment
+    if (has_capability('moodle/role:assign', $coursecontext)) {
+      echo'<a title="'.get_string('assignroles', 'role').'" href="'.$CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.$coursecontext->id.'">';
+      echo '<img src="' . $CFG->pixpath . '/i/roles.gif" height="11" width="11" alt="'.get_string('assignroles', 'role').'" /></a> ';
+    }                
+
+    // checks whether user can delete course
+    if (has_capability('moodle/course:delete', $coursecontext)) {  
+      echo '<a title="'.get_string("delete")."\" href=\"$courseroot/delete.php?id=$courseid\"><img".
+	' src="' . $CFG->pixpath . '/t/delete.gif" height="11" width="11" border="0" alt="' . get_string("delete"). '"></a> ';
+    }  
+
+    // checks whether user can change visibility
+    if (has_capability('moodle/course:visibility', $coursecontext)) {
+      if (!empty($course->visible)) {
+	echo '<a title="'.get_string("hide").'" href="' . $showhideurl . '&amp;hide=' . $courseid .'"><img'.
+	  ' src="'.$CFG->pixpath.'/t/hide.gif" height="11" width="11" border="0" alt="'.get_string("hide").'"></a> ';
+      } else {
+	echo '<a title="'.get_string("show").'" href="' . $showhideurl . '&amp;show=' . $courseid .'"><img'.
+	  ' src="'.$CFG->pixpath.'/t/show.gif" height="11" width="11" border="0" alt="'.get_string("show").'"></a> ';
+      }
+    }              
+
+    // checks whether user can do site backup
+    if (has_capability('moodle/site:backup', $coursecontext)) {
+      echo '<a title="'.get_string("backup")."\" href=\"$CFG->wwwroot/backup/backup.php?id=$courseid\"><img".
+	' src="'.$CFG->pixpath.'/t/backup.gif" height="11" width="11" border="0" alt="'.get_string("backup").'"></a> ';
+    }
+
+    // checks whether user can do restore
+    if (has_capability('moodle/site:restore', $coursecontext)) {
+      echo '<a title="'.get_string("restore")."\" href=\"$CFG->wwwroot/files/index.php?id=$courseid&wdir=/backupdata\"><img".
+	' src="'.$CFG->pixpath.'/t/restore.gif" height="11" width="11" border="0" alt="'.get_string("restore").'"></a> ';
+    }
+
+    return true;
+}
+
 ?>
diff -ruN course/search.php /home/dan/course/search.php
--- course/search.php	2006-12-24 18:56:00.000000000 +0000
+++ /home/dan/course/search.php	2006-12-24 18:53:56.000000000 +0000
@@ -184,53 +184,8 @@
                 
                 echo "</td>";
                 echo "<td>";
-                if (empty($THEME->custompix)) {
-                    $pixpath = "$CFG->wwwroot/pix";
-                } else {
-                    $pixpath = "$CFG->themedir/$CFG->theme/pix";
-                }
-                
-                // checks whether user can update course settings
-                if (has_capability('moodle/course:update', $coursecontext)) {
-                    echo "<a title=\"".get_string("settings")."\" href=\"$CFG->wwwroot/course/edit.php?id=$course->id\"><img".
-                        " src=\"$pixpath/t/edit.gif\" height=\"11\" width=\"11\" border=\"0\" alt=\"".get_string("settings")."\"></a> ";
-                }
-
-                // checks whether user can do role assignment
-    		    if (has_capability('moodle/role:assign', $coursecontext)) {
-                    echo'<a title="'.get_string('assignroles', 'role').'" href="'.$CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.$coursecontext->id.'">';
-    		        echo '<img src="'.$CFG->pixpath.'/i/roles.gif" height="11" width="11" alt="'.get_string('assignroles', 'role').'" /></a>';
-    		    }                
-
-                // checks whether user can delete course
-                if (has_capability('moodle/course:delete', $coursecontext)) {  
-                    echo "<a title=\"".get_string("delete")."\" href=\"delete.php?id=$course->id\"><img".
-                        " src=\"$pixpath/t/delete.gif\" height=\"11\" width=\"11\" border=\"0\" alt=\"".get_string("delete")."\"></a> ";
-                }  
-
-                // checks whether user can change visibility
-                if (has_capability('moodle/course:visibility', $coursecontext)) {
-                    if (!empty($course->visible)) {
-                        echo "<a title=\"".get_string("hide")."\" href=\"search.php?search=$encodedsearch&amp;perpage=$perpage&amp;page=$page&amp;hide=$course->id&amp;sesskey=$USER->sesskey\"><img".
-                            " src=\"$pixpath/t/hide.gif\" height=\"11\" width=\"11\" border=\"0\" alt=\"".get_string("hide")."\"></a> ";
-                    } else {
-                        echo "<a title=\"".get_string("show")."\" href=\"search.php?search=$encodedsearch&amp;perpage=$perpage&amp;page=$page&amp;show=$course->id&amp;sesskey=$USER->sesskey\"><img".
-                            " src=\"$pixpath/t/show.gif\" height=\"11\" width=\"11\" border=\"0\" alt=\"".get_string("show")."\"></a> ";
-                    }
-                }              
-
-                // checks whether user can do site backup
-                if (has_capability('moodle/site:backup', $coursecontext)) {
-                    echo "<a title=\"".get_string("backup")."\" href=\"../backup/backup.php?id=$course->id\"><img".
-                        " src=\"$pixpath/t/backup.gif\" height=\"11\" width=\"11\" border=\"0\" alt=\"".get_string("backup")."\"></a> ";
-                }
-                
-                // checks whether user can do restore
-                if (has_capability('moodle/site:restore', $coursecontext)) {
-                    echo "<a title=\"".get_string("restore")."\" href=\"../files/index.php?id=$course->id&wdir=/backupdata\"><img".
-                        " src=\"$pixpath/t/restore.gif\" height=\"11\" width=\"11\" border=\"0\" alt=\"".get_string("restore")."\"></a> ";
-                }
-
+		$returl = $CFG->wwwroot . "/course/search.php?search=$encodedsearch&amp;perpage=$perpage&amp;page=$page&amp;sesskey=$USER->sesskey";
+		print_course_editbar($course->id,$returl);
                 echo "</td></tr>";
             }
             echo "<tr><td colspan=\"4\" align=\"center\">";
