public function index($leadership_event_id, $activity_id) { $event = LeadershipEvent::find($leadership_event_id); $activity = Activity::find($activity_id); $this->layout->with('subtitle', $event->name()); $this->layout->content = View::make('signup.index')->with('event', $event)->with('activity', $activity); }
public function destroy($id) { $ac = Activity::find($id); $ac->delete(); Session::flash('success', 'Data telah dihapus.'); return Redirect::to('/' . Auth::user()->role . '/activity'); }
public function show($id) { $activity = Activity::find($id); $participations = Participation::with('issue', 'employee')->where('activity_id', '=', $id)->get(); $menu = 'academic'; $courses = Course::where('project_id', '=', Auth::user()->curr_project_id)->where('location_id', '=', Auth::user()->location_id)->get(); return View::make('participations.show', compact('activity', 'participations', 'courses', 'menu')); }
public function upload(Request $request) { // loop through files and move the chunks to a temporarily created directory if (!empty($_FILES)) { foreach ($_FILES as $file) { // check the error status if ($file['error'] != 0) { $this->_log('error ' . $file['error'] . ' in file ' . $_POST['flowFilename']); continue; } // init the destination file (format <filename.ext>.part<#chunk> // the file is stored in a temporary directory $temp_dir = public_path() . '/temp/' . $_POST['flowIdentifier']; $dest_file = $temp_dir . '/' . $_POST['flowFilename'] . '.part' . $_POST['flowChunkNumber']; // create the temporary directory if (!is_dir($temp_dir)) { mkdir($temp_dir, 0777, true); } // move the temporary file if (!move_uploaded_file($file['tmp_name'], $dest_file)) { $this->_log('Error saving (move_uploaded_file) chunk ' . $_POST['flowChunkNumber'] . ' for file ' . $_POST['flowFilename']); } else { // check if all the parts present, and create the final destination file $this->createFileFromChunks($temp_dir, $_POST['flowFilename'], $_POST['flowChunkSize'], $_POST['flowTotalSize']); if ($request->input('mode') == "register") { $user = User::find($request->input('id')); $user->pictureDist = 'temp/' . $_POST['flowFilename']; $user->update(); } else { if ($request->input('mode') == "activity") { $activity = Activity::find($request->input('id')); $activity->pictureDist = 'temp/' . $_POST['flowFilename']; $activity->update(); } else { if ($request->input('mode') == "task") { $activity = TaskList::find($request->input('id')); $activity->pictureLocation = 'temp/' . $_POST['flowFilename']; $activity->update(); } } } } } } //////////////////////////////////////////////////////////////////// // THE SCRIPT //////////////////////////////////////////////////////////////////// //check if request is GET and the requested chunk exists or not. this makes testChunks work if ($_SERVER['REQUEST_METHOD'] === 'GET') { $temp_dir = 'temp/' . $_GET['flowIdentifier']; $chunk_file = $temp_dir . '/' . $_GET['flowFilename'] . '.part' . $_GET['flowChunkNumber']; if (file_exists($chunk_file)) { header("HTTP/1.0 200 Ok"); } else { header("HTTP/1.0 404 Not Found"); } } }
/** * This is a temp solution, we need something better depending * on authority to update activity stored. * **/ public function saveActivity($activity_id, $activity_def) { $exists = \Activity::find($activity_id); //if the object activity exists, remove and update with recent if ($exists) { \Activity::where('_id', $activity_id)->delete(); } //save record \Activity::insert(array('_id' => $activity_id, 'definition' => $activity_def)); }
public function destroy($id) { $activity = Activity::find($id); if ($activity->participations()->count() > 0) { Session::flash('message', 'Tidak dapat membatalkan agenda kegiatan! Kegiatan ini pernah dijalankan!'); } else { Activity::destroy($id); Session::flash('message', 'Sukses membatalkan agenda kegiatan'); } }
/** * [search description] * @param array $params [description] * @param string $module [description] * @param integer $id [description] * @return [type] [description] */ public function search($params, $entity = NULL, $entity_id = NULL) { $query = Activity::find()->active()->related($entity, $entity_id); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'country_id' => $this->country_id]); $query->andFilterWhere(['like', 'cityName', $this->cityName])->andFilterWhere(['like', 'zipCode', $this->zipCode])->andFilterWhere(['like', 'postBox', $this->postBox])->andFilterWhere(['like', 'addresslineOne', $this->addresslineOne])->andFilterWhere(['like', 'addresslineTwo', $this->addresslineTwo])->andFilterWhere(['like', 'regionName', $this->regionName]); return $dataProvider; }
/** * Test Activity */ public function testActivityCRUD() { $activity = new Activity(); $activity->_id = \app\locker\helpers\Helpers::getRandomValue(); $activity->definition = array('type' => \app\locker\helpers\Helpers::getRandomValue(), 'name' => array('en-US' => \app\locker\helpers\Helpers::getRandomValue()), 'description' => array('en-US' => \app\locker\helpers\Helpers::getRandomValue())); $result = $activity->save(); $this->assertTrue($result); // Load activity from db $aid = $activity->_id; $db_activity = Activity::find($aid); $this->assertEquals($db_activity->_id, $activity->_id); // Delete activity $db_activity->delete(); $this->assertEquals(Activity::find($aid), NULL); }
function shutdown() { global $user_activity_id, $info; if ($user_activity_id != 0) { $active = Activity::find($user_activity_id); $active->date_end = Carbon::now(); $active->save(); } if (empty($info['type']) || $info['type'] == 'live') { fastcgi_finish_request(); posix_kill(getmypid(), 9); } else { exit; } }
public function updateActivity($id, $action = null, $doer_id = null, $victim_id = null, $feed_type = null) { $activity = Activity::find($id); if (!empty($action)) { $activity->action = $action; } if (!empty($doer_id)) { $activity->doer_id = $doer_id; } if (!empty($victim_id)) { $activity->victim_id = $victim_id; } if (!empty($feed_type)) { $activity->feed_type = $feed_type; } return $activity->save(); }
<?php include '../../inc/init.inc'; if (isset($id) && is_numeric($id) && Activity::exists($id)) { $activity = Activity::find($id); if ($activity->user_id != $res->user->id) { throw new Exception('Unauthorized action'); } } else { $activity = new Activity(); } $activity->name = $name; $activity->start = $start . " " . $startTime; $activity->end = $end . " " . $endTime; $activity->status = $status; $activity->privacy = $privacy; $activity->description = $description; $activity->user_id = $res->user->id; if ($activity->is_valid()) { $activity->save(); if (isset($member_list_values)) { preg_match_all('#\\(([^)]+)\\)#', $member_list_values, $organizers_ids); Activities_User::table()->delete(array('activity_id' => $activity->id)); $organizers_ids[1][] = $activity->user_id; foreach ($organizers_ids[1] as $organizers_id) { if (!User::exists($organizers_id)) { continue; } $activity_user = Activities_User::create(array('activity_id' => $activity->id, 'user_id' => $organizers_id)); } }
<?php include '../../inc/init.inc'; $list = array(); foreach ($res->user->getPotientialUserNetwork()->asArray() as $potentialUserNetwork) { $list[] = "" <img src='" . $potentialUserNetwork->getPicture(16) . " /> " . $potentialUserNetwork->name() . " " . "(" . $potentialUserNetwork->id . ")" . """; } if (count($list) > 0) { $res->memberList = implode(',', $list); } if (isset($id)) { $res->activity = Activity::find($id); $res->is_new = false; } else { $res->activity = new Activity(); $res->is_new = true; } if (isset($infos)) { $res->useTemplate('Administration de l\'activité', $infos); } else { $res->useTemplate('Administration de l\'activité'); }
/** * 功能:商家菜单页美食分类,商品的分类和活动是一起的,不过活动还是单独列一张表出来的 */ public function getGoodCategory($shop_id) { $data = array(); $shop = Shop::find($shop_id); $groups = $shop->groups->all(); $goods_category = array(); $good_activity = array(); foreach ($groups as $group) { $one = array(); if ($group->activity_id == 0) { // 不是活动 $one['classify_name'] = $group->name; $one['classify_name_abbr'] = $group->name_abbr; $one['classify_id'] = $group->id; $one['classify_count'] = Menu::where('shop_id', $shop_id)->where('group_id', $group->activity_id)->get()->count('shop_id'); $one['classify_icon'] = $group->icon; array_push($goods_category, $one); } else { // 是活动的 $act = Activity::find($group->activity_id); $one['activity_name'] = $act->name; $one['activity_id'] = $act->aid; $one['activity_icon'] = $act->icon; $one['activity_statement'] = $act->intro; array_push($good_activity, $one); } } $data['goods_category'] = $goods_category; $data['good_activity'] = $good_activity; return $data; }
<?php $res->edit = true; if (isset($id) && Page::exists($id)) { $page = Page::find($id); $res->title = $page->title; $res->content = $page->content; $res->id = $page->id; if (isset($page->activity_id) && $page->activity_id > 0) { $res->edit = $res->user->id == $page->user_id; } else { $res->edit = 2; } } else { $res->title = ""; $res->content = ""; $res->id = ""; } if (isset($activity) && is_numeric($activity) && $res->user->id == Activity::find($activity)->id) { $res->activity = $activity; } $res->useTemplate();
function testFind() { //Arrange $activity_name = "Activity One"; $activity_date = '2016-01-01'; $activity_location = "Location"; $activity_description = "Description of Activity One"; $activity_price = "Price of Activity One"; $activity_quantity = 10; $business_id = 1; $activity_category_id = 2; $id = 1; $test_activity = new Activity($activity_name, $activity_date, $activity_location, $activity_description, $activity_price, $activity_quantity, $business_id, $activity_category_id, $id); $test_activity->save(); $activity_name2 = "Activity Two"; $activity_date2 = '2016-02-02'; $activity_location2 = "Location Two"; $activity_description2 = "Description of Activity Two"; $activity_price2 = "Price of Activity Two"; $activity_quantity2 = 20; $business_id2 = 21; $activity_category_id2 = 22; $id2 = 2; $test_activity2 = new Activity($activity_name, $activity_date, $activity_location, $activity_description, $activity_price, $activity_quantity, $business_id, $activity_category_id, $id = null); $test_activity2->save(); //Act $result = Activity::find($test_activity->getId()); //Assert $this->assertEquals($test_activity, $result); }
<?php include 'config.php'; $message = []; if (isset($_GET['delete_all'])) { $del_activities = Activity::all(); foreach ($del_activities as $del_activity) { $del_activity->delete(); } $message['type'] = "success"; $message['message'] = "Old activities deleted"; } if (isset($_GET['delete'])) { $de_activity = Activity::find($_GET['delete']); $de_activity->delete(); $mssage['type'] = "success"; $message['message'] = "Activity deleted"; } $activity = Activity::where('date_end', '=', '0000-00-00 00:00:00')->get(); echo $template->view()->make('activities')->with('activities', $activity)->with('message', $message)->render();