Esempio n. 1
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;
 }