Exemplo n.º 1
0
 /**
  * Format the current row's actions column.
  *
  * @param   tour    $tour       The tour for this row.
  * @return  string
  */
 protected function col_actions(tour $tour)
 {
     $actions = [];
     if ($tour->is_first_tour()) {
         $actions[] = helper::get_filler_icon();
     } else {
         $actions[] = helper::format_icon_link($tour->get_moveup_link(), 't/up', get_string('movetourup', 'tool_usertours'));
     }
     if ($tour->is_last_tour($this->tourcount)) {
         $actions[] = helper::get_filler_icon();
     } else {
         $actions[] = helper::format_icon_link($tour->get_movedown_link(), 't/down', get_string('movetourdown', 'tool_usertours'));
     }
     $actions[] = helper::format_icon_link($tour->get_view_link(), 't/viewdetails', get_string('view'));
     $actions[] = helper::format_icon_link($tour->get_edit_link(), 't/edit', get_string('edit'));
     $actions[] = helper::format_icon_link($tour->get_export_link(), 't/export', get_string('exporttour', 'tool_usertours'), 'tool_usertours');
     $actions[] = helper::format_icon_link($tour->get_delete_link(), 't/delete', get_string('delete'), null, ['data-action' => 'delete', 'data-id' => $tour->get_id()]);
     return implode(' ', $actions);
 }
Exemplo n.º 2
0
 /**
  * Print the edit tour page.
  *
  * @param   int         $id     The ID of the tour
  */
 protected function edit_tour($id = null)
 {
     global $PAGE;
     if ($id) {
         $tour = tour::instance($id);
         $PAGE->navbar->add($tour->get_name(), $tour->get_edit_link());
     } else {
         $tour = new tour();
         $PAGE->navbar->add(get_string('newtour', 'tool_usertours'), $tour->get_edit_link());
     }
     $form = new forms\edittour($tour);
     if ($form->is_cancelled()) {
         redirect(helper::get_list_tour_link());
     } else {
         if ($data = $form->get_data()) {
             // Creating a new tour.
             $tour->set_name($data->name);
             $tour->set_description($data->description);
             $tour->set_pathmatch($data->pathmatch);
             $tour->set_enabled(!empty($data->enabled));
             foreach (configuration::get_defaultable_keys() as $key) {
                 $tour->set_config($key, $data->{$key});
             }
             // Save filter values.
             foreach (helper::get_all_filters() as $filterclass) {
                 $filterclass::save_filter_values_from_form($tour, $data);
             }
             $tour->persist();
             redirect(helper::get_list_tour_link());
         } else {
             if (empty($tour)) {
                 $this->header('newtour');
             } else {
                 if (!empty($tour->get_config(self::CONFIG_SHIPPED_TOUR))) {
                     notification::add(get_string('modifyshippedtourwarning', 'tool_usertours'), notification::WARNING);
                 }
                 $this->header($tour->get_name());
                 $data = $tour->prepare_data_for_form();
                 // Prepare filter values for the form.
                 foreach (helper::get_all_filters() as $filterclass) {
                     $filterclass::prepare_filter_values_for_form($tour, $data);
                 }
                 $form->set_data($data);
             }
             $form->display();
             $this->footer();
         }
     }
 }
Exemplo n.º 3
0
 /**
  * Create the edit tour form.
  *
  * @param   tour        $tour       The tour being editted.
  */
 public function __construct(\tool_usertours\tour $tour)
 {
     $this->tour = $tour;
     parent::__construct($tour->get_edit_link());
 }