Page MenuHomeIn-Portal Phabricator

in-bulletin
No OneTemporary

File Metadata

Created
Sat, Feb 1, 5:50 AM

in-bulletin

Index: branches/5.0.x/in-bulletin/units/poll_comments/poll_comment_eh.php
===================================================================
--- branches/5.0.x/in-bulletin/units/poll_comments/poll_comment_eh.php (revision 12359)
+++ branches/5.0.x/in-bulletin/units/poll_comments/poll_comment_eh.php (revision 12360)
@@ -1,150 +1,150 @@
<?php
/**
* @version $Id$
* @package In-Bulletin
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license GNU/GPL
* In-Portal is Open Source software.
* This means that this software may have been modified pursuant
* the GNU General Public License, and as distributed it includes
* or is derivative of works licensed under the GNU General Public License
* or other free or open source software licenses.
* See http://www.in-portal.net/license/ for copyright notices and details.
*/
class PollCommentEventHandler extends kDBEventHandler {
/**
* Allows to override standart permission mapping
*
*/
function mapPermissions()
{
parent::mapPermissions();
$permissions = Array(
'OnCreate' => Array('self' => true, 'subitem' => true,),
'OnItemBuild' => Array('self' => true, 'subitem' => true,),
);
$this->permMapping = array_merge($this->permMapping, $permissions);
}
function OnAfterConfigRead(&$event)
{
if ($this->Application->RecallVar('user_id') == '-2') { // Guest
// make Guest Name and Email required for guests
$fields = $this->Application->getUnitOption($event->Prefix, 'Fields');
$fields['GuestName']['required'] = 1;
$fields['GuestEmail']['required'] = 1;
$this->Application->setUnitOption($event->Prefix, 'Fields', $fields);
}
}
/**
* Applies special filter, that allows to select all commented from current poll
*
* @param kEvent $event
*/
function SetCustomQuery(&$event)
{
if ($this->Application->IsAdmin()) {
return ;
}
$object =& $event->getObject();
/* @var $object kDBList */
$object->addFilter('comment_status', '(%1$s.Status = ' .STATUS_ACTIVE. ')');
}
/**
* Before New PollComment created
*
* @param kEvent $event
*/
function OnBeforeItemCreate(&$event)
{
if ($this->Application->IsAdmin()) {
return ;
}
$object =& $event->getObject();
/* @var $object kDBItem */
// get Poll info
$parent_prefix = $this->Application->getUnitOption($this->Prefix, 'ParentPrefix');
if($parent_prefix) {
$main_object =& $this->Application->recallObject($parent_prefix.'.'.$special, null,Array('raise_warnings' => 0));
/* @var $main_object kDBItem */
if (!$main_object->isLoaded()) {
$main_object =& $this->Application->recallObject($parent_prefix);
}
$poll_id = $main_object->GetDBField($this->Application->getUnitOption($event->Prefix, 'ForeignKey'));
}
if ($poll_id) {
$spam_helper =& $this->Application->recallObject('SpamHelper');
/* @var $spam_helper SpamHelper */
$spam_helper->InitHelper($poll_id, 'PollComment', 0); // ResourceId used for SpamControl only
if ($spam_helper->InSpamControl()) {
$event->status = erFAIL;
$object->SetError('CommentText', 'too_frequent', 'lu_error_AlreadyCommented');
return ;
}
}
$object->SetDBField('CreatedById', $this->Application->RecallVar('user_id'));
$object->SetDBField('UserIP', $_SERVER['REMOTE_ADDR']);
$object->SetDBField('PollId', $poll_id); // PollId
$object->SetDBField('Status', STATUS_ACTIVE);
parent::OnBeforeItemCreate($event);
}
/**
* Updates item review counter
*
* @param kEvent $event
*/
- function onCreate(&$event)
+ function OnCreate(&$event)
{
parent::OnCreate($event);
if ($this->Application->IsAdmin()) {
return;
}
if ($event->status == erSUCCESS) {
$event->setRedirectParam('opener', 's');
$event->setRedirectParam('pass', 'm,poll');
$event->redirect = $this->Application->GetVar('success_template');
}
}
/**
* Updates item review counter
*
* @param kEvent $event
*/
function OnAfterItemCreate(&$event)
{
// return;
if (!$this->Application->IsAdmin()) {
$spam_helper =& $this->Application->recallObject('SpamHelper');
/* @var $spam_helper SpamHelper */
$object =& $event->getObject();
$config_mapping = $this->Application->getUnitOption($event->Prefix, 'ConfigMapping');
$comment_settings = $config_mapping['CommentDelayValue'].':'.$config_mapping['CommentDelayInterval'];
$spam_helper->InitHelper($object->GetDBField('PollId'), 'PollComment', $comment_settings);
$spam_helper->AddToSpamControl();
}
}
}
?>
\ No newline at end of file
Index: branches/5.0.x/in-bulletin/install.php
===================================================================
--- branches/5.0.x/in-bulletin/install.php (revision 12359)
+++ branches/5.0.x/in-bulletin/install.php (revision 12360)
@@ -1,49 +1,53 @@
<?php
/**
* @version $Id$
* @package In-Bulletin
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license GNU/GPL
* In-Portal is Open Source software.
* This means that this software may have been modified pursuant
* the GNU General Public License, and as distributed it includes
* or is derivative of works licensed under the GNU General Public License
* or other free or open source software licenses.
* See http://www.in-portal.net/license/ for copyright notices and details.
*/
$module_folder = 'in-bulletin';
if (!defined('IS_INSTALL')) {
// separate module install
define('IS_INSTALL', 1);
define('ADMIN', 1);
define('REL_PATH', $module_folder);
define('FULL_PATH', realpath(dirname(__FILE__) . '/..') );
include_once(FULL_PATH . '/core/kernel/startup.php');
require_once FULL_PATH . '/core/install/install_toolkit.php';
$toolkit = new kInstallToolkit();
}
else {
// install, using installation wizard
$toolkit =& $this->toolkit;
/* @var $toolkit kInstallToolkit */
}
$application =& kApplication::Instance();
$application->Init();
+ if ($application->RecallVar('user_id') != -1) {
+ die('restricted access!');
+ }
+
$category =& $toolkit->createModuleCategory('Forums', 'Discussion Forums', '/in-bulletin/designs/section', 'in-bulletin/img/menu_topics.gif');
$toolkit->RunSQL('/' . $module_folder . '/install/install_schema.sql');
$toolkit->RunSQL('/' . $module_folder . '/install/install_data.sql', '{TopicCatId}', $category->GetID());
$toolkit->ImportLanguage('/' . $module_folder . '/install/english');
$toolkit->SetModuleRootCategory($module_folder, $category->GetID());
// $toolkit->linkCustomFields($module_folder, 'bb', 3); // to create Custom Fields for Topics
$toolkit->linkCustomFields('KERNEL', 'c', 1); // to create ItemTemplate custom field
$toolkit->setModuleItemTemplate($category, 'bb', 'in-bulletin/topics/topic_detail');
$toolkit->finalizeModuleInstall($module_folder, true);
\ No newline at end of file

Event Timeline