コード例 #1
0
 /**
  * @Request({"user", "key"})
  */
 public function activateAction($username, $activation)
 {
     $message = '';
     if (empty($username) || empty($activation) || !($user = User::where(['username' => $username, 'activation' => $activation, 'status' => User::STATUS_BLOCKED, 'login IS NULL'])->first())) {
         return AuthController::messageView(['message' => __('Invalid key.'), 'success' => false]);
     }
     if ($admin = $this->module->config('registration') == 'approval' and !$user->get('verified')) {
         $user->activation = App::get('auth.random')->generateString(32);
         $this->sendApproveMail($user);
         $message = __('Your email has been verified. Once an administrator approves your account, you will be notified by email.');
     } else {
         $user->set('verified', true);
         $user->status = User::STATUS_ACTIVE;
         $user->activation = '';
         $this->sendWelcomeEmail($user);
         if ($admin) {
             $message = __('The user\'s account has been activated and the user has been notified about it.');
         } else {
             $message = __('Your account has been activated.');
         }
     }
     $user->save();
     App::message()->success($message);
     return App::redirect('@user/login');
 }
コード例 #2
0
 /**
  * @Route("/{id}", name="id")
  */
 public function projectAction($id = 0)
 {
     if (!($project = Project::where(['id = ?', 'date < ?'], [$id, new \DateTime()])->first())) {
         App::abort(404, __('Project not found.'));
     }
     $project->intro = App::content()->applyPlugins($project->intro, ['project' => $project, 'markdown' => $project->get('markdown')]);
     $project->content = App::content()->applyPlugins($project->content, ['project' => $project, 'markdown' => $project->get('markdown')]);
     $previous = Project::getPrevious($project);
     $next = Project::getNext($project);
     return ['$view' => ['title' => __($project->title), 'name' => 'bixie/portfolio/project.php'], 'portfolio' => $this->portfolio, 'config' => $this->portfolio->config(), 'previous' => $previous, 'next' => $next, 'project' => $project];
 }
コード例 #3
0
 /**
  * @Route("/{id}", name="id")
  */
 public function postAction($id = 0)
 {
     if (!($post = Post::where(['id = ?', 'status = ?', 'date < ?'], [$id, Post::STATUS_PUBLISHED, new \DateTime()])->related('user')->first())) {
         App::abort(404, __('Post not found!'));
     }
     if (!$post->hasAccess(App::user())) {
         App::abort(403, __('Insufficient User Rights.'));
     }
     $post->excerpt = App::content()->applyPlugins($post->excerpt, ['post' => $post, 'markdown' => $post->get('markdown')]);
     $post->content = App::content()->applyPlugins($post->content, ['post' => $post, 'markdown' => $post->get('markdown')]);
     $user = App::user();
     return ['$view' => ['title' => __($post->title), 'name' => 'blog/post.php'], '$comments' => ['config' => ['post' => $post->id, 'enabled' => $post->isCommentable(), 'requireinfo' => $this->blog->config('comments.require_email'), 'max_depth' => $this->blog->config('comments.max_depth')], 'user' => ['name' => $user->name, 'isAuthenticated' => $user->isAuthenticated(), 'canComment' => $user->hasAccess('blog: post comments'), 'skipApproval' => $user->hasAccess('blog: skip comment approval')]], 'blog' => $this->blog, 'post' => $post];
 }
コード例 #4
0
 /**
  * @Request({"order": "array"}, csrf=true)
  */
 public function reorderAction($order = [])
 {
     $widgets = $this->dashboard->getWidgets();
     $reordered = [];
     foreach ($order as $id) {
         if ($widget = $this->dashboard->getWidget($id)) {
             $reordered[$id] = $widget;
         }
     }
     if (count($widgets) == count($reordered)) {
         $this->dashboard->saveWidgets($reordered);
     }
     return ['message' => __('Widgets reordered.')];
 }
コード例 #5
0
 /**
  * @Route("/{id}", name="id")
  */
 public function postAction($id = 0)
 {
     if (!($post = Post::where(['id = ?', 'status = ?', 'date < ?'], [$id, Post::STATUS_PUBLISHED, new \DateTime()])->related('user')->first())) {
         App::abort(404, __('Post not found!'));
     }
     if (!$post->hasAccess(App::user())) {
         App::abort(403, __('Insufficient User Rights.'));
     }
     $post->excerpt = App::content()->applyPlugins($post->excerpt, ['post' => $post, 'markdown' => $post->get('markdown')]);
     $post->content = App::content()->applyPlugins($post->content, ['post' => $post, 'markdown' => $post->get('markdown')]);
     $user = App::user();
     $description = $post->get('meta.og:description');
     if (!$description) {
         $description = strip_tags($post->excerpt ?: $post->content);
         $description = rtrim(mb_substr($description, 0, 150), " \t\n\r\v.,") . '...';
     }
     return ['$view' => ['title' => __($post->title), 'name' => 'blog/post.php', 'og:type' => 'article', 'article:published_time' => $post->date->format(\DateTime::ATOM), 'article:modified_time' => $post->modified->format(\DateTime::ATOM), 'article:author' => $post->user->name, 'og:title' => $post->get('meta.og:title') ?: $post->title, 'og:description' => $description, 'og:image' => $post->get('image.src') ? App::url()->getStatic($post->get('image.src'), [], 0) : false], '$comments' => ['config' => ['post' => $post->id, 'enabled' => $post->isCommentable(), 'requireinfo' => $this->blog->config('comments.require_email'), 'max_depth' => $this->blog->config('comments.max_depth'), 'user' => ['name' => $user->name, 'isAuthenticated' => $user->isAuthenticated(), 'canComment' => $user->hasAccess('blog: post comments'), 'skipApproval' => $user->hasAccess('blog: skip comment approval')]]], 'blog' => $this->blog, 'post' => $post];
 }
コード例 #6
0
 /**
  * @Request({"user", "key"})
  */
 public function activateAction($username, $activation)
 {
     if (empty($username) || empty($activation) || !($user = User::where(['username' => $username, 'activation' => $activation, 'login IS NULL'])->first())) {
         App::abort(400, __('Invalid key.'));
     }
     $verifying = false;
     if ($this->module->config('require_verification') && !$user->get('verified')) {
         $user->set('verified', true);
         $verifying = true;
     }
     if ($this->module->config('registration') === 'approval' && $user->status === User::STATUS_BLOCKED && $verifying) {
         $user->activation = App::get('auth.random')->generateString(32);
         $this->sendApproveMail($user);
         $message = __('Your email has been verified. Once an administrator approves your account, you will be notified by email.');
     } else {
         $user->status = User::STATUS_ACTIVE;
         $user->activation = '';
         $this->sendWelcomeEmail($user);
         $message = $verifying ? __('Your account has been activated.') : __('The user\'s account has been activated and the user has been notified about it.');
     }
     $user->save();
     App::message()->success($message);
     return App::redirect('@user/login');
 }