/**
  * Handle the event.
  */
 public function handle()
 {
     if (!$this->config->get('app.debug') && !$this->session->get(__CLASS__ . 'warned') && $this->request->path() == 'admin/dashboard' && $this->modules->get('anomaly.module.installer')) {
         $this->session->set(__CLASS__ . 'warned', true);
         $this->messages->error('streams::message.delete_installer');
     }
 }
 /**
  * Handle the command.
  *
  * @param ContactFormBuilder $builder
  * @param MessageBag         $messages
  * @param Mailer             $mailer
  */
 public function handle(ContactFormBuilder $builder, MessageBag $messages, Mailer $mailer)
 {
     // Validation failed!
     if ($builder->hasFormErrors()) {
         return;
     }
     // Delegate these for now.
     $view = $this->dispatch(new GetMessageView($builder));
     $data = $this->dispatch(new GetMessageData($builder));
     // Build the message object.
     $message = function (Message $message) use($builder) {
         $this->dispatch(new BuildMessage($message, $builder));
     };
     // Send the email.
     $mailer->send($view, $data, $message);
     // If there are any failures, report.
     if (count($mailer->failures()) > 0) {
         $messages->error($builder->getFormOption('error_message', 'anomaly.plugin.contact::error.send_message'));
     } else {
         // Otherwise, show success.
         $messages->success($builder->getFormOption('success_message', 'anomaly.plugin.contact::success.send_message'));
     }
     // Clear the form!
     $builder->resetForm();
 }
 public function migrate(Request $request, MessageBag $bag, FolderRepositoryInterface $folders)
 {
     $input = $request->input();
     if (!$input['table'] || !$input['column']) {
         $bag->error("Table and column are both required");
         return redirect('/admin/migrator/migrate_column');
     }
     $data = DB::select('select `id`, ' . $input['column'] . ' from ' . $input['table']);
     echo "<table><thead><tr><th>Row</th><th>Original ID</th><th>New Id</th></tr></thead><tbody>";
     foreach ($data as $row) {
         $remoteFile = json_decode($this->getData($this->baseUrl . '/migrator/get_file/' . $row->{$input['column']}));
         $folder = $folders->findByPath($remoteFile->path, $this->disk);
         $foundFile = false;
         if ($folder) {
             foreach ($folder->getFiles() as $file) {
                 if ($file->getName() == $remoteFile->file) {
                     $foundFile = true;
                     // return 'found file ID: ' . $file->getId();
                     echo "<tr><td>" . $row->id . "</td><td>" . $row->{$input['column']} . "</td><td>" . $file->getId() . "</td>";
                 }
             }
         }
         if (!$foundFile) {
             echo "<tr><td>" . $row->id . "</td><td>" . $row->{$input['column']} . "</td><td>Could not find file to migrate to.<br>";
             echo "<b>Path:</b> " . $remoteFile->path . "<br>";
             echo "<b>File:</b> " . $remoteFile->file . "<br>";
             echo "<b>Filename:</b> " . $remoteFile->filename;
             echo "</td></tr>";
         }
     }
     echo "</tbody></table>";
     var_dump($input['table']);
     var_dump($input['column']);
 }
 /**
  * Handle the command.
  *
  * @param MessageBag $messages
  */
 public function handle(MessageBag $messages)
 {
     $form = $this->builder->getForm();
     $errors = $form->getErrors();
     if ($errors instanceof \Illuminate\Support\MessageBag) {
         $messages->error($errors->all());
     }
 }
 public function __construct(SettingRepositoryInterface $settings, MessageBag $bag)
 {
     $this->baseUrl = $settings->get('bloveless.module.migrator::base_url')->value;
     $this->disk = $settings->get('bloveless.module.migrator::disk')->value;
     if (!isset($this->baseUrl) || !isset($this->disk)) {
         $bag->error("The base url and disk are required for this module to function. Set them in \"Settings\"");
     }
     parent::__construct();
 }
 /**
  * Handle the command.
  *
  * @param UserActivator $activator
  * @param MessageBag    $messages
  */
 public function handle(UserActivator $activator, MessageBag $messages)
 {
     /* @var UserInterface $user */
     $user = $this->builder->getFormEntry();
     $activator->send($user, $this->builder->getFormOption('activate_redirect', '/'));
     if (!is_null($message = $this->builder->getFormOption('confirm_message'))) {
         $messages->info($message);
     }
 }
 /**
  * Handle the command.
  *
  * @param UserActivator $activator
  * @param MessageBag    $messages
  */
 public function handle(UserActivator $activator, MessageBag $messages)
 {
     /* @var UserInterface $user */
     $user = $this->builder->getFormEntry();
     $activator->force($user);
     if (!is_null($message = $this->builder->getFormOption('activated_message'))) {
         $messages->info($message);
     }
 }
 /**
  * Fired when builder is ready to build.
  *
  * @param UserRepositoryInterface $users
  * @param BreadcrumbCollection    $breadcrumbs
  * @param MessageBag              $messages
  * @param Redirector              $redirect
  * @return \Illuminate\Http\RedirectResponse
  */
 public function onReady(UserRepositoryInterface $users, RoleRepositoryInterface $roles, BreadcrumbCollection $breadcrumbs, MessageBag $messages, Redirector $redirect)
 {
     $this->setEntry($user = $users->find($this->getEntry()));
     if ($user->hasRole($roles->findBySlug('admin'))) {
         $messages->warning('anomaly.module.users::warning.modify_admin_user');
         $this->setFormResponse($redirect->to('admin/users'));
         return;
     }
     $breadcrumbs->add($user->getDisplayName(), 'admin/users/edit/' . $user->getId());
     $breadcrumbs->add('anomaly.module.users::breadcrumb.permissions', 'admin/users/permissions/' . $user->getId());
 }
Ejemplo n.º 9
0
 /**
  * Fired when builder is ready to build.
  *
  * @param RoleRepositoryInterface $roles
  * @param BreadcrumbCollection    $breadcrumbs
  * @param MessageBag              $messages
  * @param Redirector              $redirect
  * @return \Illuminate\Http\RedirectResponse
  */
 public function onReady(RoleRepositoryInterface $roles, BreadcrumbCollection $breadcrumbs, MessageBag $messages, Redirector $redirect)
 {
     $this->setEntry($role = $roles->find($this->getEntry()));
     if ($role->getSlug() === 'admin') {
         $messages->warning('anomaly.module.users::warning.modify_admin_role');
         $this->setFormResponse($redirect->to('admin/users/roles'));
         return;
     }
     $breadcrumbs->add($role->getName(), 'admin/users/roles/edit/' . $role->getId());
     $breadcrumbs->add('anomaly.module.users::breadcrumb.permissions', 'admin/users/roles/permissions/' . $role->getId());
 }
 /**
  * Handle the form.
  *
  * @param ForgotPasswordFormBuilder $builder
  * @param UserRepositoryInterface   $users
  * @param UserPassword              $password
  * @param MessageBag                $messages
  * @param Repository                $config
  */
 public function handle(ForgotPasswordFormBuilder $builder, UserRepositoryInterface $users, UserPassword $password, MessageBag $messages, Repository $config)
 {
     if ($builder->hasFormErrors()) {
         return;
     }
     $user = $users->findByEmail($builder->getFormValue('email'));
     if ($path = $builder->getFormOption('reset_path')) {
         $config->set('anomaly.module.users::paths.reset', $path);
     }
     $password->forgot($user);
     $password->send($user, $builder->getFormOption('reset_redirect'));
     $messages->success('anomaly.module.users::message.confirm_reset_password');
 }
Ejemplo n.º 11
0
 /**
  * Fired just after
  * saving the form entry.
  *
  * This is basically a validator
  * but I am putting it here because
  * it's far easier to test being that
  * the disk is being loaded already.
  *
  * @param MountManager $manager
  * @param MessageBag   $messages
  * @param Redirector   $redirector
  */
 public function onSaved(MountManager $manager, MessageBag $messages, Redirector $redirector)
 {
     /* @var DiskFormBuilder $builder */
     $builder = $this->forms->get('disk');
     /* @var DiskInterface $entry */
     $entry = $builder->getFormEntry();
     app()->call('Anomaly\\FilesModule\\Disk\\Listener\\RegisterDisks@handle');
     try {
         $manager->has($entry->path('test.me'));
     } catch (\Exception $e) {
         $messages->error($e->getMessage());
         $this->setFormResponse($redirector->to('admin/files/disks/edit/' . $entry->getId()));
     }
 }
Ejemplo n.º 12
0
 /**
  * Handle the command.
  *
  * @param Request    $request
  * @param MessageBag $messages
  * @param Translator $translator
  */
 public function handle(Request $request, MessageBag $messages, Translator $translator)
 {
     if ($this->builder->isAjax()) {
         return;
     }
     $errors = $this->builder->getFormErrors();
     $messages->error($errors->all());
     if ($request->segment(1) == 'admin' && ($stream = $this->builder->getFormStream()) && $stream->isTrashable()) {
         /* @var AssignmentInterface $assignment */
         foreach ($stream->getUniqueAssignments() as $assignment) {
             if ($this->builder->hasFormError($assignment->getFieldSlug())) {
                 $messages->warning($translator->trans('streams::validation.unique_trash', ['attribute' => '"' . $translator->trans($assignment->getFieldName()) . '"']));
             }
         }
     }
 }
 /**
  * Handle the command.
  *
  * @param InviteFormBuilder $builder
  * @param MessageBag $messages
  */
 public function handle(InviteFormBuilder $builder, MessageBag $messages)
 {
     // Validation failed!
     if ($builder->hasFormErrors()) {
         return;
     }
     $reply = $this->dispatch(new SendInvite($builder));
     if (array_get($reply, 'ok') === true) {
         $messages->success('anomaly.extension.slack_inviter::success.send_invite');
     } else {
         $messages->error('anomaly.extension.slack_inviter::error.send_invite');
         $messages->error('anomaly.extension.slack_inviter::error.' . $reply['error']);
     }
     // Clear the form!
     $builder->resetForm();
 }
 /**
  * @param  UserAuthenticator                      $authenticator
  * @param  MessageBag                             $message
  * @param  Redirector                             $redirect
  * @return bool|\Illuminate\Http\RedirectResponse
  */
 public function handle(UserAuthenticator $authenticator, MessageBag $message, Redirector $redirect)
 {
     if (!$this->user->isActivated()) {
         $message->error('Your account has not been activated.');
         $authenticator->logout();
         // Just in case.
         return $redirect->back();
     }
     if (!$this->user->isEnabled()) {
         $message->error('Your account has been disabled.');
         $authenticator->logout();
         // Just in case.
         return $redirect->back();
     }
     return true;
 }
 /**
  * Check the authorization of module access.
  *
  * @param  Request  $request
  * @param  \Closure $next
  * @return \Illuminate\Http\RedirectResponse
  */
 public function handle(Request $request, Closure $next)
 {
     if (in_array($request->path(), ['admin/login', 'admin/logout'])) {
         return $next($request);
     }
     if ($request->segment(1) == 'admin' && !$this->authorizer->authorize('anomaly.module.users::general.control_panel')) {
         abort(403);
     }
     if (!$this->authorizer->authorize(array_get($this->route->getAction(), 'anomaly.module.users::permission'))) {
         if ($message = array_get($this->route->getAction(), 'anomaly.module.users::message')) {
             $this->messages->error($message);
         }
         if ($redirect = array_get($this->route->getAction(), 'anomaly.module.users::redirect')) {
             return $this->redirect->to($redirect);
         }
         abort(403);
     }
     return $next($request);
 }
 /**
  * Handle the form.
  *
  * @param UserRepositoryInterface  $users
  * @param ResetPasswordFormBuilder $builder
  * @param MessageBag               $messages
  * @param UserPassword             $password
  */
 public function handle(UserRepositoryInterface $users, ResetPasswordFormBuilder $builder, MessageBag $messages, UserPassword $password)
 {
     $user = $users->findByEmail($builder->getEmail());
     /**
      * If we can't find the user by the email
      * provided then head back to the form.
      */
     if (!$user) {
         $messages->error(trans('anomaly.module.users::error.reset_password'));
         return;
     }
     /**
      * If we can't successfully reset the
      * provided user then back back to the form.
      */
     if (!$password->reset($user, $builder->getCode(), $builder->getFormValue('password'))) {
         $messages->error(trans('anomaly.module.users::error.reset_password'));
         return;
     }
     $messages->success(trans('anomaly.module.users::success.reset_password'));
 }
Ejemplo n.º 17
0
 /**
  * Check the authorization of module access.
  *
  * @param  Request  $request
  * @param  \Closure $next
  * @return \Illuminate\Http\RedirectResponse
  */
 public function handle(Request $request, Closure $next)
 {
     if (in_array($request->path(), ['admin/login', 'admin/logout'])) {
         return $next($request);
     }
     /* @var UserInterface $user */
     $user = $this->auth->user();
     $role = array_get($this->route->getAction(), 'anomaly.module.users::role');
     $redirect = array_get($this->route->getAction(), 'anomaly.module.users::redirect');
     $message = array_get($this->route->getAction(), 'anomaly.module.users::message');
     if ($role && (!$user || !$user->hasAnyRole((array) $role))) {
         if ($message) {
             $this->messages->error($message);
         }
         if ($redirect) {
             return $this->redirect->to($redirect);
         }
         abort(403);
     }
     return $next($request);
 }
Ejemplo n.º 18
0
 /**
  * Handle the request.
  *
  * @param \Illuminate\Http\Request $request
  * @param callable                 $next
  * @return \Illuminate\Http\RedirectResponse|mixed
  */
 public function handle($request, Closure $next)
 {
     // If the method is not a post - skip.
     if (!$request->isMethod('post')) {
         return $next($request);
     }
     // Get the route action.
     $action = $this->route->getAction();
     // If the route disabled the CSRF - skip.
     if (array_get($action, 'csrf') === false) {
         return $next($request);
     }
     /**
      * Try validating the CSRF token with the
      * base Laravel Middleware.
      */
     try {
         return parent::handle($request, $next);
     } catch (TokenMismatchException $e) {
         $this->messages->error('streams::message.csrf_token_mismatch');
         return $this->redirector->back();
     }
 }
Ejemplo n.º 19
0
 /**
  * Execute an action.
  *
  * @param  TableBuilder    $builder
  * @param  ActionInterface $action
  * @throws \Exception
  */
 public function execute(TableBuilder $builder, ActionInterface $action)
 {
     $options = $builder->getTableOptions();
     $handler = $action->getHandler();
     // Self handling implies @handle
     if (is_string($handler) && !str_contains($handler, '@')) {
         $handler .= '@handle';
     }
     /*
      * Authorize the action.
      */
     if (!$this->authorizer->authorize($action->getPermission())) {
         $this->messages->error('streams::message.403');
         return;
     }
     /*
      * Get the IDs of the selected rows.
      */
     $selected = $this->request->get($options->get('prefix') . 'id', []);
     /*
      * If the handler is a callable string or Closure
      * then call it using the IoC container.
      */
     if (is_string($handler) || $handler instanceof \Closure) {
         if (is_string($handler) && class_exists($handler)) {
             $handler .= '@handle';
         }
         app()->call($handler, compact('builder', 'selected'));
         return;
     }
     /*
      * If the handle is an instance of ActionHandlerInterface
      * simply call the handle method on it.
      */
     if ($handler instanceof ActionHandlerInterface) {
         $handler->handle($builder, $selected);
         return;
     }
     throw new \Exception('Action $handler must be a callable string, Closure or ActionHandlerInterface.');
 }
 /**
  * Handle the command.
  *
  * @param MessageBag $messages
  */
 public function handle(MessageBag $messages)
 {
     if (!is_null($message = $this->builder->getFormOption('pending_message'))) {
         $messages->info($message);
     }
 }