/**
  * @return string
  */
 public function getRename()
 {
     $old_name = Input::get('file');
     $new_name = trim(Input::get('new_name'));
     $file_path = parent::getPath('directory');
     $thumb_path = parent::getPath('thumb');
     $old_file = $file_path . $old_name;
     if (!File::isDirectory($old_file)) {
         $extension = File::extension($old_file);
         $new_name = str_replace('.' . $extension, '', $new_name) . '.' . $extension;
     }
     $new_file = $file_path . $new_name;
     if (Config::get('lfm.alphanumeric_directory') && preg_match('/[^\\w-]/i', $new_name)) {
         return Lang::get('laravel-filemanager::lfm.error-folder-alnum');
     } elseif (File::exists($new_file)) {
         return Lang::get('laravel-filemanager::lfm.error-rename');
     }
     if (File::isDirectory($old_file)) {
         File::move($old_file, $new_file);
         Event::fire(new FolderWasRenamed($old_file, $new_file));
         return 'OK';
     }
     File::move($old_file, $new_file);
     if ('Images' === $this->file_type) {
         File::move($thumb_path . $old_name, $thumb_path . $new_name);
     }
     Event::fire(new ImageWasRenamed($old_file, $new_file));
     return 'OK';
 }
Exemple #2
0
 protected function listen(DataProvider $provider)
 {
     Event::listen(DataProvider::EVENT_FETCH_ROW, function (DataRow $row, DataProvider $provider) use($provider) {
         if ($provider !== $provider) {
             return;
         }
         $this->rows_processed++;
         foreach ($this->fields as $field) {
             $name = $field->getName();
             $operation = $this->getFieldOperation($name);
             switch ($operation) {
                 case self::OPERTATION_SUM:
                     $this->src[$name] += $row->getCellValue($field);
                     break;
                 case self::OPERATION_COUNT:
                     $this->src[$name] = $this->rows_processed;
                     break;
                 case self::OPERATION_AVG:
                     if (empty($this->src["{$name}_sum"])) {
                         $this->src["{$name}_sum"] = 0;
                     }
                     $this->src["{$name}_sum"] += $row->getCellValue($field);
                     $this->src[$name] = round($this->src["{$name}_sum"] / $this->rows_processed, 2);
                     break;
                 default:
                     throw new Exception("TotalsRow:Unknown aggregation operation.");
             }
         }
     });
 }
 /**
  * Prepares a new WebSocket server on a specified host & port.
  *
  * @param  string $tcpid
  *
  * @return YnievesDotNet\FourStream\FourStream\FourStreamServer
  */
 public function start($tcpid)
 {
     $oldNode = FSNode::all();
     echo "Closing old nodes", "\n";
     foreach ($oldNode as $node) {
         $node->delete();
     }
     $this->server = new Websocket(new Socket($tcpid));
     $this->server->on('open', function (Bucket $bucket) {
         Event::fire(new Events\ConnectionOpen($bucket));
     });
     $this->server->on('message', function (Bucket $bucket) {
         Event::fire(new Events\MessageReceived($bucket));
     });
     $this->server->on('binary-message', function (Bucket $bucket) {
         Event::fire(new Events\BinaryMessageReceived($bucket));
     });
     $this->server->on('ping', function (Bucket $bucket) {
         Event::fire(new Events\PingReceived($bucket));
     });
     $this->server->on('error', function (Bucket $bucket) {
         Event::fire(new Events\ErrorGenerated($bucket));
     });
     $this->server->on('close', function (Bucket $bucket) {
         Event::fire(new Events\ConnectionClose($bucket));
     });
     return $this;
 }
 public function testPermanentlyDeleteUser()
 {
     // Make sure our events are fired
     Event::fake();
     $this->actingAs($this->admin)->delete('/admin/access/user/' . $this->user->id)->notSeeInDatabase('users', ['id' => $this->user->id, 'deleted_at' => null])->visit('/admin/access/user/' . $this->user->id . '/delete')->seePageIs('/admin/access/user/deleted')->see('The user was deleted permanently.')->notSeeInDatabase('users', ['id' => $this->user->id]);
     Event::assertFired(UserPermanentlyDeleted::class);
 }
 /**
  * Register the application services.
  *
  * @return void
  */
 public function register()
 {
     $configPath = __DIR__ . '/../config/sql-logging.php';
     $this->mergeConfigFrom($configPath, 'sql-logging');
     if (config('sql-logging.log', false)) {
         Event::listen('illuminate.query', function ($query, $bindings, $time) {
             $data = compact('bindings', 'time');
             // Format binding data for sql insertion
             foreach ($bindings as $i => $binding) {
                 if ($binding instanceof \DateTime) {
                     $bindings[$i] = $binding->format('\'Y-m-d H:i:s\'');
                 } else {
                     if (is_string($binding)) {
                         $bindings[$i] = "'{$binding}'";
                     }
                 }
             }
             // Insert bindings into query
             $query = str_replace(array('%', '?'), array('%%', '%s'), $query);
             $query = vsprintf($query, $bindings);
             $log = new Logger('sql');
             $log->pushHandler(new StreamHandler(storage_path() . '/logs/sql-' . date('Y-m-d') . '.log', Logger::INFO));
             // add records to the log
             $log->addInfo($query, $data);
         });
     }
 }
 /**
  * Test the logout button redirects the user back to home and the login button is again visible
  */
 public function testLogoutRoute()
 {
     // Make sure our events are fired
     Event::fake();
     $this->actingAs($this->user)->visit('/logout')->see('Login')->see('Register');
     Event::assertFired(UserLoggedOut::class);
 }
 /**
  * Register any other events for your application.
  *
  * @param  \Illuminate\Contracts\Events\Dispatcher  $events
  * @return void
  */
 public function boot(DispatcherContract $events)
 {
     parent::boot($events);
     Event::listen('Aacotroneo\\Saml2\\Events\\Saml2LoginEvent', function (Saml2LoginEvent $event) {
         $user = $event->getSaml2User();
         /*$userData = [
               'id' => $user->getUserId(),
               'attributes' => $user->getAttributes(),
               'assertion' => $user->getRawSamlAssertion()
           ];*/
         $laravelUser = User::where("username", "=", $user->getUserId())->get()->first();
         if ($laravelUser != null) {
             Auth::login($laravelUser);
         } else {
             //if first user then create it and login
             $count = \App\User::all()->count();
             if ($count == 0) {
                 $data = array();
                 $data['lastname'] = "";
                 $data['firstname'] = "";
                 $data['username'] = $user->getUserId();
                 $data['role'] = "admin";
                 $user = \App\User::create($data);
                 \Auth::login($user);
                 return \Redirect::to('/');
             } else {
                 abort(401);
             }
         }
         //if it does not exist create it and go on  or show an error message
     });
 }
 /**
  * Upload an image/file and (for images) create thumbnail
  *
  * @param UploadRequest $request
  * @return string
  */
 public function upload()
 {
     try {
         $res = $this->uploadValidator();
         if (true !== $res) {
             return Lang::get('laravel-filemanager::lfm.error-invalid');
         }
     } catch (\Exception $e) {
         return $e->getMessage();
     }
     $file = Input::file('upload');
     $new_filename = $this->getNewName($file);
     $dest_path = parent::getPath('directory');
     if (File::exists($dest_path . $new_filename)) {
         return Lang::get('laravel-filemanager::lfm.error-file-exist');
     }
     $file->move($dest_path, $new_filename);
     if ('Images' === $this->file_type) {
         $this->makeThumb($dest_path, $new_filename);
     }
     Event::fire(new ImageWasUploaded(realpath($dest_path . '/' . $new_filename)));
     // upload via ckeditor 'Upload' tab
     if (!Input::has('show_list')) {
         return $this->useFile($new_filename);
     }
     return 'OK';
 }
 /**
  * EventsDataSource constructor.
  */
 public function __construct()
 {
     $this->points = [];
     Event::listen('*', function () {
         $this->points[] = ['memory' => memory_get_usage(true), 'time' => microtime(true)];
     });
 }
Exemple #10
0
 public function title()
 {
     $oldTitle = $this->page->getTitle();
     $this->page->setTitle($this->request->input('title'));
     Event::fire(new Events\PageTitleWasChanged($this->page, $oldTitle, $this->page->getTitle()));
     return ['status' => $this->page->getCurrentVersion()->getStatus(), 'location' => (string) $this->page->url(true)];
 }
Exemple #11
0
 /**
  * Handle registering and returning registered settings.
  *
  * @return array
  */
 public function getRegisteredSettings()
 {
     $registry = new SettingsRegistry();
     $registry->register('General', [['name' => 'app.site.name', 'type' => 'text', 'label' => 'Site name', 'options' => ['required' => 'required']], ['name' => 'app.site.desc', 'type' => 'text', 'label' => 'Site desc', 'options' => ['required' => 'required']]]);
     Event::fire('register.settings', [$registry]);
     return $registry->collectSettings();
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $category = $this->categoryRepo->insert($request->input());
     Event::fire(new CategoryCreated($category));
     // TODO: flash message
     return redirect()->back();
 }
Exemple #13
0
 /**
  * Write a logout history item for this user
  *
  * @param $user
  */
 public static function handle($user)
 {
     $user->login_history()->save(new UserLoginHistory(['source' => Request::getClientIp(), 'user_agent' => Request::header('User-Agent'), 'action' => 'logout']));
     $message = 'User logged out from ' . Request::getClientIp();
     Event::fire('security.log', [$message, 'authentication']);
     return;
 }
 public function boot(Guard $guard, MixPanel $mixPanel)
 {
     include __DIR__ . '/Http/routes.php';
     $this->app->make(config('auth.model'))->observe(new MixPanelUserObserver($mixPanel));
     $eventHandler = new MixPanelEventHandler($guard, $mixPanel);
     Event::subscribe($eventHandler);
 }
 public static function deleteType($id)
 {
     // firing event so it can get catched for permission handling
     Event::fire('customprofile.deleting');
     $success = ProfileFieldType::findOrFail($id)->delete();
     return $success;
 }
Exemple #16
0
 /**
  *
  */
 protected function registerListeners()
 {
     EventFacade::listen('*', function ($param) {
         $this->data[] = ['name' => EventFacade::firing(), 'param' => $param, 'time' => microtime(true)];
         $this->stream();
     });
 }
Exemple #17
0
 public function __construct()
 {
     $this->middleware('jwt.auth');
     Event::listen('tymon.jwt.valid', function ($user) {
         $this->user = $user;
     });
 }
Exemple #18
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  UserRequest $request
  * @return \Illuminate\Http\Response
  */
 public function store(UserRequest $request)
 {
     $user = $this->userRepository->save($request->all());
     Event::fire(new SendMail($user));
     Session::flash('message', 'User successfully added!');
     return redirect('user');
 }
Exemple #19
0
 public function fire($job, $data)
 {
     // build the event data
     $event_data = $this->event_builder->buildBlockEventData($data['hash']);
     // fire an event
     try {
         Log::debug("Begin xchain.block.received {$event_data['height']} ({$event_data['hash']})");
         Event::fire('xchain.block.received', [$event_data]);
         Log::debug("End xchain.block.received {$event_data['height']} ({$event_data['hash']})");
         // job successfully handled
         $job->delete();
     } catch (Exception $e) {
         EventLog::logError('BTCBlockJob.failed', $e, $data);
         // this block had a problem
         //   but it might be found if we try a few more times
         $attempts = $job->attempts();
         if ($attempts > self::MAX_ATTEMPTS) {
             // we've already tried MAX_ATTEMPTS times - give up
             Log::debug("Block {$data['hash']} event failed after attempt " . $attempts . ". Giving up.");
             $job->delete();
         } else {
             $release_time = 2;
             Log::debug("Block {$data['hash']} event failed after attempt " . $attempts . ". Trying again in " . self::RETRY_DELAY . " seconds.");
             $job->release(self::RETRY_DELAY);
         }
     }
 }
 public function boot()
 {
     Event::listen('backend.menu.extendItems', function ($manager) {
         $manager->addSideMenuItems('Genius.Base', 'pages', ['contacts' => ['label' => 'genius.contacts::lang.settings.menu_label', 'icon' => 'icon-envelope-o', 'url' => Backend::url('genius/contacts/settings/update/1'), 'order' => 20]]);
         $manager->addSideMenuItems('Genius.Base', 'admin', ['contacts' => ['label' => 'genius.contacts::lang.contacts.menu_label', 'icon' => 'icon-envelope-o', 'url' => Backend::url('genius/contacts/contacts'), 'order' => 20]]);
     });
 }
 public function filesUploadReadyToCompareNotice($event)
 {
     $this->setEventName('diff_tool.file_uploads_ready_to_compare');
     $this->setDto($event);
     //1) Get the keys from incoming event to make the notification(s)
     //  1. Project ID from
     //  2. Request ID from
     $this->setFrom($this->getDto()->project_id);
     $this->setFromType('Approve\\Projects\\Project');
     //2) Set User IDs to (add this to the DTO for now on)
     $this->setToWhom();
     $this->setToType('Approve\\Profile\\User');
     if (count($this->getToWhom()) < 1) {
         return false;
     }
     //3) Make a title/category for this based on the Event name eg
     //  diff_tool.file_uploads_ready_to_compare
     //  if it does not exist make the notification_category
     $this->setCategory();
     //4) Make the Notification Message in the db
     $this->setMessage("File uploads ready to compare for Project");
     $this->createMessage();
     //5) Make the Notifications From To in the DB
     //    store each To id in an array to send them all at once
     //    after to pusher via an Event Listener
     $this->createNotificationsForEachToWhom();
     //6) Fire Notification using the above keys/ids for To
     //    and message in a NotificationsListenerDTO
     Event::fire('notifications.' . $this->getEventName(), [$this->getNotificationsMade()]);
 }
Exemple #22
0
 public function handle()
 {
     $this->deleteChildren();
     $this->reassignURLs();
     PageFacade::delete($this->page);
     Event::fire(new PageWasDeleted($this->page));
 }
Exemple #23
0
 public function seen(Request $request)
 {
     $user = Auth::user();
     $holder = $request->input('holder');
     Event::fire(new seenMessage($holder));
     MessageUser::where('parentable_type', 'App\\User')->where('parentable_id', $holder)->where('user_id', $user->id)->where('status', 0)->update(['status' => 1]);
 }
Exemple #24
0
 /**
  * Handles the event
  * @param  Event  $event
  * @return void
  */
 public function handle(Event $event)
 {
     $subscription = $this->storage->subscription($event->customer(), true);
     // we are not doing anything special here,
     // just firing the event to be handeled by the app.
     IlluminateEvent::fire('cashew.invoice.created', array($subscription['user_id'], $event->invoice()));
 }
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     Task::created(function ($task) {
         Event::fire(new TaskWasIncludedEvent($task));
         //event(new TaskWasIncludedEvent($task));
     });
 }
Exemple #26
0
 /**
  * Save Queue
  *
  * Persist all queued Events into Event Store.
  * @return void
  */
 public function publishQueue()
 {
     foreach (static::$queue as $record) {
         EventBus::fire('publish:' . $record['event'], $record['payload']);
     }
     static::$queue = [];
 }
 public function postOrder()
 {
     log::debug('postOrder::Input params');
     log::debug(Input::all());
     //Validation rules
     $rules = array('pizza_marinara' => array('required', 'integer', 'between:0,3'), 'pizza_margherita' => array('required', 'integer', 'between:0,3'), 'olio' => array('min:1|max:20'), 'name' => array('required', 'min:1|max:20'), 'email' => array('required', 'email', 'min:1|max:20'), 'freeOrder' => array('exists:menu,dish'));
     // The validator
     $validation = Validator::make(Input::all(), $rules);
     // Check for fails
     if ($validation->fails()) {
         // Validation has failed.
         log::error('Validation has failed');
         $messages = $validation->messages();
         $returnedMsg = "";
         foreach ($messages->all() as $message) {
             $returnedMsg = $returnedMsg . " - " . $message;
         }
         log::error('Validation fail reason: ' . $returnedMsg);
         return redirect()->back()->withErrors($validation);
     }
     log::debug('Validation passed');
     $msg = array('email' => Input::get('email'), 'name' => Input::get('name'));
     $response = Event::fire(new ExampleEvent($msg));
     $response = Event::fire(new OrderCreated($msg));
     return view('orderdone', ['msg' => $msg]);
 }
 /**
  * Do the Artisan commands fire?
  */
 public function testCommands()
 {
     $self = $this;
     $this->prepareSpecify();
     $this->specify('Boots', function () use($self) {
         $target = $self->getProvider(['package']);
         $target->shouldReceive('package');
         $target->boot();
     });
     $this->prepareSpecify();
     $this->specify('Identifies provisions', function () use($self) {
         $target = $self->getProvider();
         verify($target->provides())->notEmpty();
     });
     $this->prepareSpecify();
     $this->specify('Binds to application', function () use($self) {
         App::shouldReceive('bind')->with('/^toolbox\\.commands\\./', Mockery::on(function ($closure) {
             $command = $closure();
             verify_that('is a command', is_a($command, 'Illuminate\\Console\\Command'));
             return true;
         }));
         Event::shouldReceive('listen')->with('toolbox.build', Mockery::on(function ($closure) {
             $app = Mockery::mock('Illuminate\\Console\\Application[call]');
             $app->shouldReceive('call');
             $command = $closure($app);
             return true;
         }));
         $target = $self->getProvider(['commands']);
         $target->shouldReceive('commands')->with(Mockery::type('array'));
         $target->register();
     });
 }
Exemple #29
0
 /**
  * Update a user's profile
  *
  * @param User $user
  * @param $attributes
  *
  * @return static
  */
 public static function updateProfile(User $user, array $attributes)
 {
     $profile = $user->profile;
     $new = false;
     if (is_null($profile)) {
         $profile = new static();
         $new = true;
     }
     $profile->first_name = $attributes['first_name'];
     $profile->last_name = $attributes['last_name'];
     $profile->location = array_key_exists('location', $attributes) ? $attributes['location'] : '';
     $profile->skill_id = array_key_exists('describe', $attributes) ? $attributes['describe'] : '';
     $profile->profession_id = array_key_exists('profession', $attributes) ? $attributes['profession'] : '';
     $profile->about = array_key_exists('about', $attributes) ? $attributes['about'] : '';
     $profile->facebook = array_key_exists('facebook', $attributes) ? $attributes['facebook'] : '';
     $profile->twitter = array_key_exists('twitter', $attributes) ? $attributes['twitter'] : '';
     $profile->youtube = array_key_exists('youtube', $attributes) ? $attributes['youtube'] : '';
     $profile->published = array_key_exists('published', $attributes) ? true : false;
     $profile->user_id = $user->id;
     // To prevent incomplete profiles from been shown, check if the main skill is missing.
     if (is_null($profile->skill()) or $profile->skill_id == 0) {
         $profile->published = false;
     }
     if ($new) {
         $profile->save();
         $user->profile = $profile;
         Event::fire(new ProfileCreated($profile, $user));
     }
     return $profile;
 }
 /**
  * Register the service provider.
  */
 public function register()
 {
     App::bind('toolbox.commands.controllers', function () {
         return new \Impleri\Toolbox\Commands\ControllersCommand();
     });
     App::bind('toolbox.commands.models', function () {
         return new \Impleri\Toolbox\Commands\ModelsCommand();
     });
     App::bind('toolbox.commands.routes', function () {
         return new \Impleri\Toolbox\Commands\RoutesCommand();
     });
     App::bind('toolbox.commands.schema', function () {
         return new \Impleri\Toolbox\Commands\SchemaCommand();
     });
     App::bind('toolbox.commands.views', function () {
         return new \Impleri\Toolbox\Commands\ViewsCommand();
     });
     App::bind('toolbox.commands.build', function () {
         return new \Impleri\Toolbox\Commands\BuildCommand();
     });
     $this->commands($this->provides());
     // Subscribe our own commands to toolbox.compile
     Event::listen('toolbox.build', function ($app) {
         $app->call('toolbox:routes');
         $app->call('toolbox:controllers');
         $app->call('toolbox:models');
         $app->call('toolbox:schema');
         $app->call('toolbox:views');
     });
 }