/**
  * Renderers actions for individual course actions.
  *
  * @param course_in_list $course The course to renderer actions for.
  * @return string
  */
 public function search_listitem_actions(course_in_list $course)
 {
     $baseurl = new moodle_url('/course/managementsearch.php', array('courseid' => $course->id, 'categoryid' => $course->category, 'sesskey' => sesskey()));
     $actions = array();
     // Edit.
     if ($course->can_access()) {
         if ($course->can_edit()) {
             $actions[] = $this->output->action_icon(new moodle_url('/course/edit.php', array('id' => $course->id)), new pix_icon('t/edit', get_string('edit')), null, array('class' => 'action-edit'));
         }
         // Show/Hide.
         if ($course->can_change_visibility()) {
             if ($course->visible) {
                 $actions[] = $this->output->action_icon(new moodle_url($baseurl, array('action' => 'hidecourse')), new pix_icon('t/show', get_string('hide')), null, array('data-action' => 'hide', 'class' => 'action-hide'));
             } else {
                 $actions[] = $this->output->action_icon(new moodle_url($baseurl, array('action' => 'showcourse')), new pix_icon('t/hide', get_string('show')), null, array('data-action' => 'show', 'class' => 'action-show'));
             }
         }
     }
     if (empty($actions)) {
         return '';
     }
     return html_writer::span(join('', $actions), 'course-item-actions item-actions');
 }
Exemple #2
0
 /**
  * Returns an array of actions that can be performed on the course being displayed.
  *
  * @param \course_in_list $course
  * @return array
  */
 public static function get_course_detail_actions(\course_in_list $course)
 {
     $params = array('courseid' => $course->id, 'categoryid' => $course->category, 'sesskey' => \sesskey());
     $baseurl = new \moodle_url('/course/management.php', $params);
     $actions = array();
     // View.
     if ($course->is_uservisible()) {
         $actions['view'] = array('url' => new \moodle_url('/course/view.php', array('id' => $course->id)), 'string' => \get_string('view'));
     }
     // Edit.
     if ($course->can_edit()) {
         $actions['edit'] = array('url' => new \moodle_url('/course/edit.php', array('id' => $course->id)), 'string' => \get_string('edit'));
     }
     // Permissions.
     if ($course->can_review_enrolments()) {
         $actions['enrolledusers'] = array('url' => new \moodle_url('/enrol/users.php', array('id' => $course->id)), 'string' => \get_string('enrolledusers', 'enrol'));
     }
     // Delete.
     if ($course->can_delete()) {
         $actions['delete'] = array('url' => new \moodle_url('/course/delete.php', array('id' => $course->id)), 'string' => \get_string('delete'));
     }
     // Show/Hide.
     if ($course->can_change_visibility()) {
         if ($course->visible) {
             $actions['hide'] = array('url' => new \moodle_url($baseurl, array('action' => 'hidecourse')), 'string' => \get_string('hide'));
         } else {
             $actions['show'] = array('url' => new \moodle_url($baseurl, array('action' => 'showcourse')), 'string' => \get_string('show'));
         }
     }
     // Backup.
     if ($course->can_backup()) {
         $actions['backup'] = array('url' => new \moodle_url('/backup/backup.php', array('id' => $course->id)), 'string' => \get_string('backup'));
     }
     // Restore.
     if ($course->can_restore()) {
         $actions['restore'] = array('url' => new \moodle_url('/backup/restorefile.php', array('contextid' => $course->get_context()->id)), 'string' => \get_string('restore'));
     }
     return $actions;
 }