Пример #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_create()
 {
     //assumption: this will only be called using ajax
     if (!Input::is_ajax()) {
         return Response::forge("Access forbidden, only AJAX calls allowed", 403);
     }
     if (!Auth::has_access("location.create")) {
         return Response::forge("Only admins allowed here", 403);
     }
     if (Input::post("location_title", null) != null) {
         $loc = Model_Orm_Location::forge();
         $loc->title = Input::post("location_title");
         $loc->save();
         $ret = array("id" => $loc->id);
         return Response::forge(Format::forge()->to_json($ret), 200, array("Content-Type" => "application/json"));
     }
 }