|
From: <al...@us...> - 2008-09-29 21:18:34
|
Revision: 710
http://sciret.svn.sourceforge.net/sciret/?rev=710&view=rev
Author: alpeb
Date: 2008-09-29 21:17:58 +0000 (Mon, 29 Sep 2008)
Log Message:
-----------
added ability to report articles (offensive articles, unaccurate content, etc)
Modified Paths:
--------------
trunk/actions/SavePreferences.php
trunk/flowMap.php
trunk/setup/final.sql
trunk/style.css
trunk/templates/EditPreferences.tpl
trunk/templates/ViewArticle.tpl
trunk/views/EditPreferences.php
trunk/views/ViewArticle.php
Added Paths:
-----------
trunk/actions/SendReportArticle.php
trunk/forms/ReportArticleForm.php
trunk/images/flag.png
trunk/templates/ReportArticle.tpl
trunk/views/ReportArticle.php
Modified: trunk/actions/SavePreferences.php
===================================================================
--- trunk/actions/SavePreferences.php 2008-09-29 16:53:06 UTC (rev 709)
+++ trunk/actions/SavePreferences.php 2008-09-29 21:17:58 UTC (rev 710)
@@ -49,6 +49,7 @@
$this->configuration->setConfigValue('mailFromName', $_POST['mailFromName']);
$this->configuration->setConfigValue('mailFromMail', $_POST['mailFromMail']);
$this->configuration->setConfigValue('mailCategoryRequest', $_POST['mailCategoryRequest']);
+ $this->configuration->setConfigValue('mailArticleReports', $_POST['mailArticleReports']);
$this->configuration->setConfigValue('smtpServer', $_POST['smtpServer']);
$this->configuration->setConfigValue('smtpUser', $_POST['smtpUser']);
$this->configuration->setConfigValue('smtpPassword', $_POST['smtpPassword']);
Added: trunk/actions/SendReportArticle.php
===================================================================
--- trunk/actions/SendReportArticle.php (rev 0)
+++ trunk/actions/SendReportArticle.php 2008-09-29 21:17:58 UTC (rev 710)
@@ -0,0 +1,77 @@
+<?php
+
+/*
+* @copyright Copyright (C) 2005-2008 Keyboard Monkeys Ltd. http://www.kb-m.com
+* @license http://www.fsf.org/copyleft/lgpl.html GNU Lesser General Public License
+* @author Alejandro Pedraza
+* @since Sciret 1.2
+* @package Sciret
+* @packager Keyboard Monkeys
+*/
+
+require 'actions/Action.php';
+
+class SendReportArticle extends Action
+{
+ private $_artId;
+
+ public function dispatch()
+ {
+ $this->_artId = (int)$_POST['artId'];
+
+ if (!$this->_artId) {
+ $_SESSION['message'] = $this->user->lang('Bad article ID');
+ Library::redirect(Library::getLink(array('view' => 'MainView')));
+ }
+
+ $form = new ReportArticleForm(null, $this->user);
+ $this->_validateForm($form);
+
+ $article = new Article($this->_artId);
+
+ $mail = new EmailGateway($this->configuration);
+
+ $mail->AddAddress($this->configuration->getConfigValue('mailArticleReports'));
+ $mail->Subject = $this->user->lang('Article has been reported in the Knowledge Base');
+ $mail->Body = $this->user->lang("The article #%s (%s), located at %s, has been reported in the Knowledge Base, by user %s (%s), with the following comment:\r\n\r\n%s",
+ $this->_artId,
+ $article->getTitle(),
+ 'http://'.$_SERVER['HTTP_HOST'].substr($_SERVER['REQUEST_URI'], 0, strrpos($_SERVER['REQUEST_URI'], '/')).'/index.php?view=ViewArticle&id='.$this->_artId,
+ $form->getValue('name'),
+ $form->getValue('email'),
+ $form->getValue('comments'));
+
+ if (!$mail->Send()) {
+ $_SESSION['message'] = $this->user->lang('Sorry, there was a problem sending the report to the administrators, please try again later');
+ Library::redirect(Library::getLink(array('view' => 'MainView')));
+ }
+
+ $_SESSION['message'] = $this->user->lang('Thank you for your input. The administrators have been sent your report.');
+ Library::redirect(Library::getLink(array('view' => 'ViewArticle', 'id' => $this->_artId)));
+ }
+
+ private function _validateForm($form)
+ {
+ $formData = array(
+ 'comments' => $_POST['comments'],
+ );
+
+ if (!$this->user->isAnonymous()) {
+ $formData['name'] = $this->user->getFullName();
+
+ // Some users might not have an E-mail registered
+ $formData['email'] = $this->user->email?
+ $this->user->email
+ : $this->user->lang('No registered E-mail');
+ } else {
+ $formData['name'] = $_POST['name'];
+ $formData['email'] = $_POST['email'];
+ }
+
+ if (!$form->isValid($formData)) {
+ $appSession = Zend_Registry::get('appSession');
+ $appSession->reportArticleForm = $form;
+ Library::redirect(Library::getLink(array('view' => 'ReportArticle', 'artId' => $this->_artId)));
+ }
+ }
+}
Modified: trunk/flowMap.php
===================================================================
--- trunk/flowMap.php 2008-09-29 16:53:06 UTC (rev 709)
+++ trunk/flowMap.php 2008-09-29 21:17:58 UTC (rev 710)
@@ -45,6 +45,7 @@
'EditTodo' => array(User::ROLE_REGISTERED, true, false, false),
'Upgrade' => array(User::ROLE_ANONYMOUS, true, true, true, false),
'UpgradeOk' => array(User::ROLE_ANONYMOUS, true, true, true, false),
+ 'ReportArticle' => array(User::ROLE_ANONYMOUS, true, true, true, false),
);
// ClassName => array(minimumRole, loadConfiguration, allowOnlyIfPublicKB(for User::ROLE_ANONYMOUS)?)
@@ -89,6 +90,7 @@
'Upgrade' => array(User::ROLE_ANONYMOUS, true, false),
'HideCategory' => array(User::ROLE_ANONYMOUS, true, true),
'ShowCategory' => array(User::ROLE_ANONYMOUS, true, true),
+ 'SendReportArticle' => array(User::ROLE_ANONYMOUS, true, true),
);
?>
Added: trunk/forms/ReportArticleForm.php
===================================================================
--- trunk/forms/ReportArticleForm.php (rev 0)
+++ trunk/forms/ReportArticleForm.php 2008-09-29 21:17:58 UTC (rev 710)
@@ -0,0 +1,46 @@
+<?php
+
+class ReportArticleForm extends Zend_Form
+{
+ private $_user;
+
+ public function __construct($options = null, $user)
+ {
+ $this->_user = $user;
+
+ parent::__construct($options);
+ }
+
+ public function init()
+ {
+ $name = new Zend_Form_Element_Text('name');
+ $name->setLabel($this->_user->lang('Your name'))
+ ->setRequired(true);
+
+ $email = new Zend_Form_Element_Text('email');
+ $email->setLabel($this->_user->lang('E-mail'))
+ ->addFilter('StringToLower')
+ ->setRequired(true);
+ //->addValidator('EmailAddress'); // The Admin user doesn't have an E-mail by default :S
+
+ $comments = new Zend_Form_Element_Textarea('comments');
+ $comments->setLabel($this->_user->lang('What do you want to report? The administrators will receive this message'))
+ ->setRequired(true)
+ ->setAttrib('rows', 4);
+
+ $this->AddElements(array($name, $email, $comments));
+ }
+
+ /**
+ * Overrides Zend_Form method to fix issue
+ * @see http://www.nabble.com/Zend_Form-without-MVC-problem-td17375245.html
+ */
+ public function setView(Zend_View_Interface $view)
+ {
+ parent::setView($view);
+ foreach ($this as $item) {
+ $item->setView($view);
+ }
+ return $this;
+ }
+}
Property changes on: trunk/images/flag.png
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/setup/final.sql
===================================================================
--- trunk/setup/final.sql 2008-09-29 16:53:06 UTC (rev 709)
+++ trunk/setup/final.sql 2008-09-29 21:17:58 UTC (rev 710)
@@ -58,7 +58,7 @@
CREATE TABLE `configuration` (
`field` varchar(25) NOT NULL default '',
- `value` varchar(25) NOT NULL default '',
+ `value` varchar(50) NOT NULL default '',
PRIMARY KEY (`field`)
) ENGINE=MyISAM;
Modified: trunk/style.css
===================================================================
--- trunk/style.css 2008-09-29 16:53:06 UTC (rev 709)
+++ trunk/style.css 2008-09-29 21:17:58 UTC (rev 710)
@@ -296,6 +296,7 @@
background: transparent url(images/bg_title_article.gif) no-repeat scroll right;
color: #fff;
display: block;
+ position: relative;
height: 30px;
text-decoration: none;
margin-right: 0;
Modified: trunk/templates/EditPreferences.tpl
===================================================================
--- trunk/templates/EditPreferences.tpl 2008-09-29 16:53:06 UTC (rev 709)
+++ trunk/templates/EditPreferences.tpl 2008-09-29 21:17:58 UTC (rev 710)
@@ -165,12 +165,18 @@
</td>
</tr>
<tr class="row_off">
+ <td style="text-align:right; font-weight:bold">[l]Send article reports to (email)[/l]:</td>
+ <td>
+ <input type="text" name="mailArticleReports" value="{mailArticleReports}"/>
+ </td>
+ </tr>
+ <tr class="row_off">
<td style="text-align:right; font-weight:bold">[l]Send category creation request to (email)[/l]:</td>
<td>
<input type="text" name="mailCategoryRequest" value="{mailCategoryRequest}"/>
</td>
</tr>
- <tr class="row_on">
+ <tr class="row_of">
<td style="text-align:right; font-weight:bold">[l]Send mail using[/l]:</td>
<td>
<select name="mailTransport" onchange="javascript:toggleSMTPSettings(value);">
@@ -179,7 +185,7 @@
</select>
</td>
</tr>
- <tr class="row_off" id="smtp_options" {showSMTPOptions}>
+ <tr class="row_on" id="smtp_options" {showSMTPOptions}>
<td colspan="2">
<p style="text-align:center; font-weight:bold">[l]SMTP settings[/l]:</p>
<ul>
@@ -190,7 +196,7 @@
</ul>
</td>
</tr>
- <tr class="row_on">
+ <tr class="row_off">
<td style="text-align:right; font-weight:bold">
[l]Check uploaded files for viruses[/l]:<br />
[l](You need to have <a href="http://www.clamav.net">ClamAV</a> in your system)[/l]
Added: trunk/templates/ReportArticle.tpl
===================================================================
--- trunk/templates/ReportArticle.tpl (rev 0)
+++ trunk/templates/ReportArticle.tpl 2008-09-29 21:17:58 UTC (rev 710)
@@ -0,0 +1,18 @@
+<!-- BEGIN reportForm_block -->
+<strong>
+ [l]Report Article[/l] #{artId}: {artTitle}
+</strong>
+<form action="{reportArticleFormAction}" method="post" style="margin-top:10px">
+ <input type="hidden" name="artId" value="{artId}" />
+ {formName}
+ {formEmail}
+ {formComments}
+ <input type="submit" id="submitReport" value="[l]Send[/l]" />
+ <script>
+ new YAHOO.widget.Button("submitReport");
+ </script>
+</form>
+<!-- END reportForm_block -->
+<!-- BEGIN reportsNotConfigured_block -->
+[l]Sorry, but the Article Report functionality is not enabled. Please contact your administrator.[/l]
+<!-- END reportsNotConfigured_block -->
Modified: trunk/templates/ViewArticle.tpl
===================================================================
--- trunk/templates/ViewArticle.tpl 2008-09-29 16:53:06 UTC (rev 709)
+++ trunk/templates/ViewArticle.tpl 2008-09-29 21:17:58 UTC (rev 710)
@@ -29,6 +29,7 @@
<a href="javascript:void(0);" onclick="addFavorite('article', {art_id});"><img id="favoriteStarImg" src="images/icon_favorite_16.png" alt="[l]Add article to favorites[/l]" title="[l]Add article to favorites[/l]" style="display:{favoriteArticleStarImgDisplay}" /><img id="unFavoriteStarImg" src="images/star_crossed.png" alt="[l]Remove article from favorites[/l]" title="[l]Remove article from favorites[/l]" style="display:{unFavoriteArticleStarImgDisplay}"/><img id="favoriteProgressImg" src="images/progress.gif" style="display:none" /></a>
<!-- END favoriteArticle_block -->
</span>
+ <a href="{reportArticleLink}"><img src="images/flag.png" alt="[l]Report article[/l]" title="[l]Report article[/l]" style="position:absolute; right:5px; top:5px" /></a>
</div>
<p class="view_left">
<strong>[l]Title[/l]:</strong> {title}<br />
Modified: trunk/views/EditPreferences.php
===================================================================
--- trunk/views/EditPreferences.php 2008-09-29 16:53:06 UTC (rev 709)
+++ trunk/views/EditPreferences.php 2008-09-29 21:17:58 UTC (rev 710)
@@ -58,6 +58,7 @@
'mailFromName' => $this->configuration->getConfigValue('mailFromName'),
'mailFromMail' => $this->configuration->getConfigValue('mailFromMail'),
'mailCategoryRequest' => $this->configuration->getConfigValue('mailCategoryRequest'),
+ 'mailArticleReports' => $this->configuration->getConfigValue('mailArticleReports'),
'sendMailUsing_sendmail_selected' => $this->configuration->getConfigValue('mailTransport') == 'sendmail' ? 'selected="true" ': '',
'sendMailUsing_smtp_selected' => $this->configuration->getConfigValue('mailTransport') == 'smtp' ? 'selected="true" ': '',
'showSMTPOptions' => $this->configuration->getConfigValue('mailTransport') == 'smtp' ? '' : 'style="display:none;"',
Added: trunk/views/ReportArticle.php
===================================================================
--- trunk/views/ReportArticle.php (rev 0)
+++ trunk/views/ReportArticle.php 2008-09-29 21:17:58 UTC (rev 710)
@@ -0,0 +1,78 @@
+<?php
+
+/*
+* @copyright Copyright (C) 2005-2008 Keyboard Monkeys Ltd http://www.kb-m.com
+* @license http://www.fsf.org/copyleft/lgpl.html GNU Lesser General Public License
+* @author Alejandro Pedraza
+* @since Sciret 1.0
+* @package Sciret
+* @packager Keyboard Monkeys
+*/
+
+require_once 'views/View.php';
+
+class ReportArticle extends View
+{
+ private $_artId;
+
+ public function preDispatch()
+ {
+ $this->_artId = (int)$_GET['artId'];
+
+ if (!$this->_artId) {
+ $_SESSION['message'] = $this->user->lang('Bad article ID');
+ Library::redirect(Library::getLink(array('view' => 'MainView')));
+ }
+ }
+
+ public function dispatch()
+ {
+ $article = new Article($this->_artId);
+
+ $this->tpl->set_file('main', 'ReportArticle.tpl');
+ $this->tpl->set_block('main', 'reportForm_block', 'reportForm');
+ $this->tpl->set_block('main', 'reportsNotConfigured_block', 'reportsNotConfigured');
+
+ if (!$this->configuration->getConfigValue('mailArticleReports')) {
+ $this->tpl->set_var('reportForm', '');
+ $this->tpl->parse('reportsNotConfigured', 'reportsNotConfigured_block');
+ } else {
+ $this->tpl->set_var(array(
+ 'reportsNotConfigured' => '',
+ 'reportArticleFormAction' => Library::getLink(array('action' => 'SendReportArticle')),
+ 'artId' => $this->_artId,
+ 'artTitle' => $article->getTitle(),
+ ));
+
+ $appSession = Zend_Registry::get('appSession');
+ if (isset($appSession->reportArticleForm)) {
+ $form = $appSession->reportArticleForm;
+ unset($appSession->reportArticleForm);
+ } else {
+ $form = new ReportArticleForm(null, $this->user);
+ }
+
+ $view = new Zend_View();
+ $form->setView($view);
+ $this->tpl->set_var(array(
+ 'formComments' => $form->comments->render(),
+ ));
+
+ if ($this->user->isAnonymous()) {
+ $this->tpl->set_var(array(
+ 'formName' => $form->name->render(),
+ 'formEmail' => $form->email->render(),
+ ));
+ } else {
+ $this->tpl->set_var(array(
+ 'formName' => '',
+ 'formEmail' => '',
+ ));
+ }
+
+ $this->tpl->parse('reportForm', 'reportForm_block');
+ }
+
+ $this->tpl->pparse('out', 'main');
+ }
+}
Modified: trunk/views/ViewArticle.php
===================================================================
--- trunk/views/ViewArticle.php 2008-09-29 16:53:06 UTC (rev 709)
+++ trunk/views/ViewArticle.php 2008-09-29 21:17:58 UTC (rev 710)
@@ -151,6 +151,7 @@
'editArticleLink' => Library::getLink(array('view' => 'EditArticle', 'id' => $this->article->getId())),
'addCommentsAction' => Library::getLink(array('action' => 'AddCommentAndRating', 'artId' => $this->article->getId())),
'addRelatedAction' => Library::getLink(array('action' => 'AddRelatedArticles', 'artId' => $this->article->getId())),
+ 'reportArticleLink' => Library::getLink(array('view' => 'ReportArticle', 'artId' => $this->article->getId())),
'art_id' => $this->article->getId(),
'category' => $this->_getCategoryPath($this->article->getCategoryId(), 'MainView', true),
'lang_status' => $status,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|