当前位置: 首页>>代码示例>>PHP>>正文


PHP Event::save方法代码示例

本文整理汇总了PHP中Event::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Event::save方法的具体用法?PHP Event::save怎么用?PHP Event::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Event的用法示例。


在下文中一共展示了Event::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionCreateEvent

 public function actionCreateEvent()
 {
     $transaction = Yii::app()->db->beginTransaction();
     try {
         $dU = new DateTimeHelper();
         $e = new Event();
         $e->title = $_POST['title'];
         $e->body = $_POST['body'];
         $dt = $dU->getDateTimeFromUI($_POST['end']);
         $e->end = $dt->getTimestamp();
         $dt = $dU->getDateTimeFromUI($_POST['start']);
         $e->start = $dt->getTimestamp();
         $e->user_id = Yii::app()->user->id;
         if (!$e->save()) {
             $transaction->commit();
             Response::ok(CJSON::encode(array("result" => "error", "message" => CJSON::encode($e->getErrors()))));
         } else {
             Response::ok(CJSON::encode(array("result" => "success", "message" => $e->id)));
         }
     } catch (Exception $exc) {
         $transaction->rollback();
         Yii::log($exc->getMessage(), DBLog::LOG_LEVEL_ERROR);
         Response::error(CJSON::encode(array("result" => "error", "message" => Yii::app()->params["httpErrorCode500Message"])));
     }
 }
开发者ID:MRodriguez08,项目名称:yii-bundles-app,代码行数:25,代码来源:CalendarController.php

示例2: createOrUpdate

 protected function createOrUpdate(Event $model)
 {
     if (isset($_POST['Event'])) {
         $model->scenario = 'backend';
         $model->attributes = $_POST['Event'];
         $categories = EventCategory::model()->findAllByPk($_POST['Event']['categories']);
         $links = array();
         if (!$model->isNewRecord) {
             EventLink::model()->deleteAllByAttributes(array('eventId' => $model->id));
         }
         if (isset($_POST['EventLink'])) {
             foreach ($_POST['EventLink'] as $i => $info) {
                 $link = new EventLink();
                 $link->attributes = $info;
                 if (strlen($link->url) > 0) {
                     $links[] = $link;
                 }
             }
         }
         $model->categories = $categories;
         $model->links = $links;
         $model->validate();
         if ($model->save()) {
             if ($pictureSmall = CUploadedFile::getInstance($model, 'pictureSmall')) {
                 $model->pictureSmall = $pictureSmall;
             }
             if ($pictureBig = CUploadedFile::getInstance($model, 'pictureBig')) {
                 $model->pictureBig = $pictureBig;
             }
             $model->setTags($_POST['Event']['tagsString'])->save();
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
 }
开发者ID:niranjan2m,项目名称:Voyanga,代码行数:34,代码来源:EventController.php

示例3: afterDelete

 public function afterDelete()
 {
     $event = new Event(['cart_id' => $this->cart_id, 'user_id' => \Users\User::$cur->id, 'cart_event_type_id' => 2, 'info' => $this->item_offer_price_id]);
     $event->save();
     \Ecommerce\Warehouse\Block::deleteList([['cart_id', $this->cart->id], ['item_offer_id', $this->price->item_offer_id]]);
     $this->cart->checkStage();
 }
开发者ID:krvd,项目名称:cms-Inji,代码行数:7,代码来源:Item.php

示例4: actionAddEvent

 public function actionAddEvent()
 {
     $data = $_POST;
     $model = new Event();
     $model->u_id = $data['uid'];
     $model->lat = $data['lat'];
     $model->lng = $data['lng'];
     $model->address = $data['address'];
     $model->message = $data['message'];
     $model->status = 0;
     if ($model->save()) {
         $e_id = $model->primaryKey;
         $model = new EventMedia();
         foreach (explode(",", $data['files'], -1) as $id) {
             $model->updateByPk($id, array("e_id" => $e_id));
         }
         $tids = explode(",", $data['tid']);
         foreach ($tids as $tid) {
             $model = new EventType();
             $model->event = $e_id;
             $model->node = $tid;
             $model->save();
         }
         echo 1;
     } else {
         echo 0;
     }
 }
开发者ID:snipesn,项目名称:UkrYama-2,代码行数:28,代码来源:EventController.php

示例5: _add

 private function _add()
 {
     use_helper('Validate');
     $data = $_POST['event'];
     Flash::set('event_postdata', $data);
     // Add pre-save checks here
     $errors = false;
     // CSRF checks
     if (isset($_POST['csrf_token'])) {
         $csrf_token = $_POST['csrf_token'];
         if (!SecureToken::validateToken($csrf_token, BASE_URL . 'event/add')) {
             Flash::set('error', __('Invalid CSRF token found!'));
             redirect(get_url('event/add'));
         }
     } else {
         Flash::set('error', __('No CSRF token found!'));
         redirect(get_url('event/add'));
     }
     if (empty($data['name'])) {
         Flash::set('error', __('You have to specify a event name!'));
         redirect(get_url('event/add'));
     }
     if ($errors !== false) {
         // Set the errors to be displayed.
         Flash::set('error', implode('<br/>', $errors));
         redirect(get_url('event/add'));
     }
     $oEvent = new Event();
     $last_seq = $oEvent->getLastEventSeq();
     $new_event = new Event($data);
     $new_event->created_by_id = AuthUser::getId();
     $new_event->created_on = date('Y-m-d H:i:s');
     $new_event->sequence = $last_seq + 1;
     if ($new_event->save()) {
         if (isset($_FILES)) {
             if (strlen($_FILES['upload_file']['name']) > 0) {
                 $event_id = $new_event->lastInsertId();
                 //okstmtcc 20150827 Replace image filename spaces
                 $_FILES['upload_file']['name'] = str_replace(array(" ", "(", ")"), array("_", "", ""), $_FILES['upload_file']['name']);
                 $overwrite = false;
                 $file = $this->upload_event_main_image($event_id, $_FILES['upload_file']['name'], FILES_DIR . '/event/images/', $_FILES['upload_file']['tmp_name'], $overwrite);
                 if ($file === false) {
                     Flash::set('error', __('Image has not been uploaded!'));
                     redirect(get_url('event/edit/' . $new_event->id));
                 }
             }
         }
         Flash::set('success', __('Event has been added!'));
         Observer::notify('event_after_add', $new_event->name);
         // save and quit or save and continue editing?
         if (isset($_POST['commit'])) {
             redirect(get_url('event'));
         } else {
             redirect(get_url('event/edit/' . $new_event->id));
         }
     } else {
         Flash::set('error', __('Event has not been added!'));
         redirect(get_url('event/add'));
     }
 }
开发者ID:sindotnet,项目名称:canareef,代码行数:60,代码来源:EventController.php

示例6: createEvent

 /**
  * Create an event
  * @return void
  */
 private function createEvent()
 {
     // if post data is set, we are creating an event
     if (isset($_POST) && count($_POST) > 0) {
         require_once FRAMEWORK_PATH . 'models/event.php';
         $event = new Event($this->registry, 0);
         $event->setName($this->registry->getObject('db')->sanitizeData($_POST['name']));
         $event->setDescription($this->registry->getObject('db')->sanitizeData($_POST['description']));
         $event->setDate($this->registry->getObject('db')->sanitizeData($_POST['date']), false);
         $event->setStartTime($this->registry->getObject('db')->sanitizeData($_POST['start_time']));
         $event->setEndTime($this->registry->getObject('db')->sanitizeData($_POST['end_time']));
         $event->setCreator($this->registry->getObject('authenticate')->getUser()->getID());
         $event->setType($this->registry->getObject('db')->sanitizeData($_POST['type']));
         if (isset($_POST['invitees']) && is_array($_POST['invitees']) && count($_POST['invitees']) > 0) {
             // assumes invitees are added to a table using javascript, with a hidden field with name invitees[] for the ID of invitee
             $is = array();
             foreach ($_POST['invitees'] as $i) {
                 $is[] = intval($i);
             }
             $event->setInvitees($is);
         }
         $event->save();
         $this->registry->redirectUser($this->registry->buildURL(array('event', 'view', $event->getID()), '', false), 'Event created', 'Thanks, the event has been created', false);
     } else {
         $this->registry->getObject('template')->buildFromTemplates('header.tpl.php', 'events/create.tpl.php', 'footer.tpl.php');
     }
 }
开发者ID:simontakite,项目名称:cookbooks,代码行数:31,代码来源:controller.php

示例7: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $postdata = file_get_contents("php://input");
     //var_dump($postdata);
     $request = json_decode($postdata);
     $model = new Event();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (array_key_exists('host_phone', $request) and array_key_exists('subject', $request) and array_key_exists('planned_time', $request) and array_key_exists('current_time', $request) and array_key_exists('invites', $request)) {
         //POST
         //host_phone
         //subject
         //planned_time
         //current_time
         //invites => "2384238034823,23423423424,42342342343,23432423"
         $user = User::model()->findByAttributes(array('phone_number' => $request->host_phone));
         $model->host_id = $user->id;
         $model->create_time = time();
         $model->planned_time = time() + (intval($request->planned_time) - intval($request->current_time));
         $model->subject = $request->subject;
         $invites = split(',', $request->invites);
         array_push($invites, $request->host_phone);
         //parse the $_POST['invites'] csv
         if ($model->save()) {
             echo $model->id;
             foreach ($invites as $invite) {
                 if (strlen($invite) < 5) {
                     continue;
                 }
                 $user = User::model()->findByAttributes(array('phone_number' => intval($invite)));
                 if (!$user or $user->status == 0) {
                     //twilio
                     if (!$user) {
                         $new_user = new User();
                         $new_user->create_time = time();
                         $new_user->phone_number = $invite;
                         $new_user->status = 0;
                         $new_user->save(false);
                     }
                     //$response = http_get("http://jakemor.com/services/sendSMS", array("number"=>$invite, 'message'=>1, 'key'=>"123"), $info);
                 } else {
                     //send user the message, etc
                     $viter = new Invite();
                     $viter->event_id = $model->id;
                     $viter->create_time = time();
                     $viter->receiver_id = $user->id;
                     $viter->sender_id = $model->host_id;
                     $viter->status = 0;
                     $viter->save(false);
                 }
             }
         } else {
             var_dump($model->errors);
         }
     } else {
         echo "did not receive parameters";
     }
 }
开发者ID:jamding,项目名称:CliqMobileBackend,代码行数:62,代码来源:EventController.php

示例8: schedule

 /**
  * @before _secure, _school
  */
 public function schedule()
 {
     if (RequestMethods::post("action") == "addEvent") {
         $date = RequestMethods::post("date");
         $date = explode("T", $date);
         $event = new Event(array("user_id" => $this->user->id, "organization_id" => $this->organization->id, "description" => RequestMethods::post("description"), "title" => RequestMethods::post("title"), "start" => $date[0] . " 00:00:00", "end" => $date[0] . " 23:59:59", "allDay" => true, "live" => true));
         $event->save();
     }
     self::redirect("/events");
 }
开发者ID:SwiftSchool,项目名称:School,代码行数:13,代码来源:events.php

示例9: Set

 static function Set($Subject, $action, $Object = false, $object_is_string = false, $offset = 0)
 {
     if (!$Subject || !$action) {
         return false;
     }
     $Event = new Event();
     $Event->populate_alt(array_merge(array('subject_class' => get_class($Subject), 'subject_id' => $Subject->id, 'action' => $action), $Object != false ? array('object_class' => $object_is_string ? $Object : get_class($Object), 'object_id' => !$object_is_string ? $Object->id : null) : array()));
     $Event->set_datetime('timestamp', $offset != 0 ? time() + (int) $offset : null);
     return $Event->save();
 }
开发者ID:nemoDreamer,项目名称:endo,代码行数:10,代码来源:model.event.php

示例10: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Event();
     if (isset($_POST['Event'])) {
         $model->attributes = $_POST['Event'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:GuraYaroslava,项目名称:hello-yii,代码行数:15,代码来源:EventController.php

示例11: actionAdd

 public function actionAdd()
 {
     $event = new Event();
     $event->scenario = 'frontend';
     $event->attributes = $_POST;
     if ($event->save()) {
         $this->send(array('id' => $event->id, 'message' => 'Создано новое событие с именем ' . $event->title));
     } else {
         $this->sendError(500, 'Error while saving event');
     }
 }
开发者ID:niranjan2m,项目名称:Voyanga,代码行数:11,代码来源:EventController.php

示例12: test_for_table_inheritance

 public function test_for_table_inheritance()
 {
     $Event = new Event(array('description' => 'Uncategorized Event'));
     $this->assertTrue($Event->save());
     $Concert = new Concert(array('description' => 'Madonna at Barcelona'));
     $this->assertTrue($Concert->save());
     $OpenHouseMeeting = new OpenHouseMeeting(array('description' => 'Networking event at Akelos'));
     $this->assertTrue($OpenHouseMeeting->save());
     $this->assertEqual($OpenHouseMeeting->get('type'), 'Open house meeting');
     $this->assertTrue($OpenHouseMeeting = $Event->findFirstBy('description', 'Networking event at Akelos'));
     $this->assertEqual($OpenHouseMeeting->get('description'), 'Networking event at Akelos');
     $this->assertEqual($OpenHouseMeeting->getType(), 'OpenHouseMeeting');
 }
开发者ID:bermi,项目名称:akelos,代码行数:13,代码来源:table_inheritance.php

示例13: executeSave

 public function executeSave(sfWebRequest $request)
 {
     $items = $request->getParameter('events');
     $config = $request->getParameter('config');
     $place = PlaceTable::getInstance()->findOneById((int) $config['place_id']);
     $user = $this->getUser()->getGuardUser();
     $this->events = array();
     foreach ($items as $item) {
         $event = new Event();
         $event->fromArray(array('icon' => $config['icon'], 'title' => $item['title'], 'description' => $item['description'], 'fire_at' => date('Y-m-d H:i:s', strtotime($item['fire_at'])), 'place_id' => (int) $config['place_id'], 'user_id' => $user->id, 'geo_lat' => $place->geo_lat, 'geo_lng' => $place->geo_lng));
         $event->save();
         $this->events[] = $event;
     }
 }
开发者ID:pycmam,项目名称:neskuchaik.ru,代码行数:14,代码来源:actions.class.php

示例14: store

 public static function store()
 {
     $params = $_POST;
     $team = $params['team'];
     $Event = new Event(array('description' => $params['description'], 'time' => $params['time'], 'place' => $params['place'], 'team_id' => $team));
     $errors = $Event->errors();
     if (count($errors) != 0) {
         $p = self::get_user_logged_in();
         $teams = Teammember::findByPlayer($p->id);
         View::make('/Event/new.html', array('errors' => $errors, 'event' => $Event, 'teams' => $teams));
     } else {
         $Event->save();
         Redirect::to('/event/' . $Event->id, array('message' => 'Tapahtuma luotu!'));
     }
 }
开发者ID:Jonharju,项目名称:Tsoha-Bootstrap,代码行数:15,代码来源:event_controller.php

示例15: updateImportedEvent

 /**
  * @param Event                         $unlinkedEvent
  * @param OphInBiometry_Imported_Events $importedEvent
  */
 private function updateImportedEvent(Event $unlinkedEvent, OphInBiometry_Imported_Events $importedEvent)
 {
     $transaction = Yii::app()->db->beginTransaction();
     try {
         $unlinkedEvent->episode_id = $this->episode->id;
         if ($unlinkedEvent->save()) {
             $importedEvent->is_linked = 1;
             $importedEvent->save();
         }
         $transaction->commit();
     } catch (Exception $e) {
         $transaction->rollBack();
         Yii::app()->user->setFlash('warning.event_error', "{$e->getMessage()}");
         Yii::log($e->getMessage(), CLogger::LEVEL_ERROR);
     }
 }
开发者ID:openeyes,项目名称:openeyes,代码行数:20,代码来源:DefaultController.php


注:本文中的Event::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。