Пример #1
0
 public function up()
 {
     //we'll need some places where the events can take place
     $locations = array('Rīga', 'Valmiera', 'Ventspils');
     foreach ($locations as $location) {
         $loc = \Model_Orm_Location::forge();
         $loc->title = $location;
         $loc->save();
     }
     //and let's create at least one event as well
     $demo_event = \Model_Orm_Event::forge();
     $demo_event->title = "Notikums pēc nedēļas";
     $demo_event->description = "Kaut kas, kam jānotiek nedēļu vēlāk nekā šī skripta izpilde.";
     $startdate = \Fuel\Core\Date::forge(time() + 7 * 24 * 60 * 60);
     $demo_event->start = $startdate->format('mysql', false);
     //'2013-11-27 07:00:00';
     $demo_event->location_id = 1;
     //pieņemsim, ka Rīgā;
     $demo_event->save();
     //the event shouldn't be empty - some agenda items
     $agenda_items = array('Notikuma pats, pats sākums', 'Kaut kad drusku vēlāk', 'Vēl mazliet vēlāk', 'Un nu jau arī beigas');
     foreach ($agenda_items as $agenda_item) {
         $demo_agenda = \Model_Orm_Agenda::forge();
         $demo_agenda->title = $agenda_item;
         $demo_agenda->event = $demo_event;
         $demo_agenda->save();
     }
     //we also need some users. at least two.
     \Auth::instance()->create_user("*****@*****.**", "fuel_dev", "*****@*****.**", 100, array("verified" => true, "verification_key" => md5(mt_rand(0, mt_getrandmax()))));
     \Auth::instance()->create_user("*****@*****.**", "fuel_dev", "*****@*****.**", 1, array("verified" => true, "verification_key" => md5(mt_rand(0, mt_getrandmax()))));
 }
Пример #2
0
 public function action_delete($id = null)
 {
     if ($item = Model_Orm_Agenda::find($id)) {
         $title = $item->title;
         $event_id = $item->event_id;
         $item->delete();
         Session::set_flash('success', 'Deleted the agenda item "' . $title . "'");
     } else {
         Session::set_flash('error', 'Could not delete agenda item "' . $title . '"');
     }
     Response::redirect('event/view/' . $event_id);
 }