/** * @Acl allow blog-writer * @Acl allow blog-admin */ public function save($title, $text, $tags) { $blog = new Blog($title, UserSession::get()->username, $text, CoOrg::getLanguage()); $config = BlogConfig::get(); $blog->commentsAllowed = $config->enableComments; if ($config->enableCommentsFor) { $blog->commentsCloseDate = time()+60*60*24*$config->enableCommentsFor; } $blog->tags = $tags; try { $blog->save(); $this->notice(t('Your blog item is saved')); $year = date('Y', $blog->datePosted); $month = date('m', $blog->datePosted); $day = date('d', $blog->datePosted); $this->redirect('blog/show', $year, $month, $day, $blog->ID); } catch (ValidationException $e) { $this->blog = $blog; $this->error(t('Your blog item is not saved')); $this->render('create'); } }
/** * @Acl allow blog-admin */ public function configsave($enableComments, $enableCommentsFor, $moderationEmail, $moderationTime) { $config = BlogConfig::get(); $config->enableComments = $enableComments; $config->enableCommentsFor = $enableCommentsFor; $config->moderationEmail = $moderationEmail; $config->moderationTime = $moderationTime; try { $config->save(); $this->notice(t('Saved blog configuration')); $this->redirect('admin/blog/config'); } catch (ValidationException $e) { $this->_adminTab = 'BlogConfigureAdminTab'; $this->openForOptions = BlogConfig::openForOptions(); $this->moderationTimeOptions = BlogConfig::moderationTimeOptions(); $this->blogConfig = $config; $this->error('Blog configuration not saved'); $this->render('admin/config'); } }