Page MenuHomeIn-Portal Phabricator

in-link
No OneTemporary

File Metadata

Created
Fri, Sep 19, 6:24 PM
Index: branches/5.2.x/units/link_validation/link_validation_config.php
===================================================================
--- branches/5.2.x/units/link_validation/link_validation_config.php (revision 14876)
+++ branches/5.2.x/units/link_validation/link_validation_config.php (revision 14877)
@@ -1,171 +1,171 @@
<?php
/**
* @version $Id$
* @package In-Link
* @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.org/license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
$config = Array (
'Prefix' => 'link-validation',
'ItemClass' => Array ('class' => 'kDBItem', 'file' => '', 'build_event' => 'OnItemBuild'),
'ListClass' => Array ('class' => 'kDBList', 'file' => '', 'build_event' => 'OnListBuild'),
'EventHandlerClass' => Array ('class' => 'LinkValidationEventHandler', 'file' => 'link_validation_eh.php', 'build_event' => 'OnBuild'),
'TagProcessorClass' => Array ('class' => 'LinkValidationTagProcessor', 'file' => 'link_validation_tp.php', 'build_event' => 'OnBuild'),
'AutoLoad' => true,
'Hooks' => Array (
Array (
'Mode' => hAFTER,
'Conditional' => true,
'HookToPrefix' => 'l',
'HookToSpecial' => '*',
'HookToEvent' => Array('OnAfterConfigRead'),
'DoPrefix' => '',
'DoSpecial' => '*',
'DoEvent' => 'OnPrepareLinkEditing',
),
),
'QueryString' => Array (
1 => 'id',
2 => 'Page',
3 => 'PerPage',
4 => 'event',
5 => 'mode',
),
- 'RegularEvents' => Array (
+ 'ScheduledTasks' => Array (
'link_validation' => Array ('EventName' => 'OnCronValidation', 'RunInterval' => 3600*24, 'Type' => reAFTER),
),
'IDField' => 'LinkValidationId',
'TableName' => TABLE_PREFIX.'LinkValidation',
'StatusField' => Array ('ValidationStatus', 'LinkStatus'),
'TitlePresets' => Array (
'link_validation_list' => Array ('prefixes' => Array ('link-validation_List'), 'format' => "!la_tab_LinkValidation!"),
'link_validation_progress' => Array ('format' => '!la_tab_ValidatingLinks!'),
),
'PermSection' => Array('main' => 'in-link:link_validation'),
'Sections' => Array (
'in-link:link_validation' => Array (
'parent' => 'in-link',
'icon' => 'in-link:validate',
'label' => 'la_tab_LinkValidation',
'url' => Array('t' => 'in-link/link_validation/link_validation_list', 'pass' => 'm'),
'permissions' => Array('view', 'advanced:continue', 'advanced:restart', 'advanced:validate', 'advanced:reset'),
'priority' => 3,
'type' => stTREE,
),
),
'ListSQLs' => Array (
'' => ' SELECT %1$s.* %2$s
FROM ' . TABLE_PREFIX . 'Link l
LEFT JOIN %1$s ON %1$s.LinkId = l.LinkId
LEFT JOIN ' . TABLE_PREFIX . 'CategoryItems ci ON ci.ItemResourceId = l.ResourceId
LEFT JOIN '.TABLE_PREFIX.'Category c ON c.CategoryId = ci.CategoryId',
),
'ListSortings' => Array (
'' => Array (
'Sorting' => Array ('LinkValidationId' => 'desc'),
)
),
'CalculatedFields' => Array (
'' => Array (
'ForeignLinkId' => 'l.LinkId',
'LinkName' => 'l.Name',
'LinkUrl' => 'l.Url',
'LinkCreatedOn' => 'l.CreatedOn',
'LinkStatus' => 'l.Status',
'LinkValidationStatus' => 'IF(%1$s.ValidationStatus IS NULL, ' . LINK_VALIDATION_NOT_VALIDATED . ', %1$s.ValidationStatus)',
'CategoryId' => 'ci.CategoryId',
),
),
'Fields' => Array (
'LinkValidationId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
'LinkId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
'ValidationTime' => Array ('type' => 'int', 'formatter' => 'kDateFormatter', 'default' => NULL),
'ValidationCode' => Array (
'type' => 'string',
'formatter' => 'kOptionsFormatter', 'options' => Array (200 => '200 OK', 301 => '301 Moved Permanently', 302 => '302 Found', 400 => '400 Bad Request', 403 => '403 Forbidden', 404 => '404 Not Found', 500 => '500 Internal Server Error'),
'max_len' => 50, 'default' => NULL
),
'ValidationStatus' => Array (
'type' => 'int',
'formatter' => 'kOptionsFormatter', 'options' => Array (0 => 'lc_Text_Not_Validated', 1 => 'lc_Text_Valid', 2 => 'lc_Text_Invalid'), 'use_phrases' => 1,
'not_null' => 1, 'default' => 0
),
),
'VirtualFields' => Array (
'ForeignLinkId' => Array ('type' => 'int', 'default' => 0),
'LinkName' => Array('type' => 'string', /*'formatter' => 'kMultiLanguage',*/ 'max_len' => 255, 'default' => ''),
'LinkUrl' => Array ('type' => 'string', 'default' => ''),
'LinkCreatedOn' => Array('type' => 'int', 'formatter' => 'kDateFormatter', 'default' => '#NOW#'),
'LinkStatus' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Active', 2 => 'la_Pending', 0 => 'la_Disabled'), 'use_phrases' => 1, 'default' => 2),
'LinkValidationStatus' => Array (
'type' => 'int',
'formatter' => 'kOptionsFormatter', 'options' => Array (0 => 'lc_Text_Not_Validated', 1 => 'lc_Text_Valid', 2 => 'lc_Text_Invalid'), 'use_phrases' => 1,
'default' => 0
),
// for category path drawing
'CategoryId' => Array ('type' => 'int', 'default' => 0),
'CachedNavbar' => Array ('type' => 'string', 'default' => ''),
),
'Grids' => Array (
'Default' => Array (
'Icons' => Array (
'default' => 'icon16_link.png',
// for valid links
LINK_VALIDATION_VALID . '_' . STATUS_DISABLED => 'icon16_valid_disabled.gif',
LINK_VALIDATION_VALID . '_' . STATUS_ACTIVE => 'icon16_valid.gif',
LINK_VALIDATION_VALID . '_' . STATUS_PENDING => 'icon16_valid_pend.gif',
// for invalid links
LINK_VALIDATION_INVALID . '_' . STATUS_DISABLED => 'icon16_invalid_disabled.gif',
LINK_VALIDATION_INVALID . '_' . STATUS_ACTIVE => 'icon16_invalid.gif',
LINK_VALIDATION_INVALID . '_' . STATUS_PENDING => 'icon16_invalid_pend.gif',
// for not validated links
LINK_VALIDATION_NOT_VALIDATED . '_' . STATUS_DISABLED => 'icon16_not_validated_disabled.gif',
LINK_VALIDATION_NOT_VALIDATED . '_' . STATUS_ACTIVE => 'icon16_not_validated.gif',
LINK_VALIDATION_NOT_VALIDATED . '_' . STATUS_PENDING => 'icon16_not_validated_pend.gif',
'_' . STATUS_DISABLED => 'icon16_not_validated_disabled.gif',
'_' . STATUS_ACTIVE => 'icon16_not_validated.gif',
'_' . STATUS_PENDING => 'icon16_not_validated_pend.gif',
),
'Fields' => Array (
'ForeignLinkId' => Array ('title' => 'column:la_fld_Id', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter', 'module' => 'In-Link', 'width' => 60, ),
'LinkName' => Array ('data_block' => 'grid_link_name_td', 'filter_block' => 'grid_like_filter', 'first_chars' => 30, 'width' => 180, ),
'LinkUrl' => Array ('title' => 'la_col_LinkUrl', 'data_block' => 'grid_url_td', 'filter_block' => 'grid_like_filter', 'width' => 200, ),
'LinkValidationStatus' => Array ('title' => 'column:la_fld_Status', 'filter_block' => 'grid_options_filter', 'width' => 87, ),
'ValidationCode' => Array ('title' => 'la_col_ValidationCode', 'filter_block' => 'grid_options_filter', 'width' => 155, ),
'ValidationTime' => Array ('title' => 'la_col_ValidatedOn', 'filter_block' => 'grid_date_range_filter', 'width' => 140, ),
'LinkCreatedOn' => Array ('title' => 'column:la_fld_CreatedOn', 'filter_block' => 'grid_date_range_filter', 'width' => 140, ),
),
),
),
);
\ No newline at end of file
Index: branches/5.2.x/units/link_validation/link_validation_eh.php
===================================================================
--- branches/5.2.x/units/link_validation/link_validation_eh.php (revision 14876)
+++ branches/5.2.x/units/link_validation/link_validation_eh.php (revision 14877)
@@ -1,558 +1,558 @@
<?php
/**
* @version $Id$
* @package In-Link
* @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.org/license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
class LinkValidationEventHandler extends kDBEventHandler {
/**
* Allows to override standard permission mapping
*
*/
function mapPermissions()
{
parent::mapPermissions();
$permissions = Array (
'OnResetValidationStatus' => Array ('self' => 'advanced:reset',),
'OnRestartValidation' => Array ('self' => 'advanced:restart',),
'OnContinueValidation' => Array ('self' => 'advanced:continue',),
'OnValidateSelected' => Array ('self' => 'advanced:validate',),
'OnValidateProgress' => Array ('self' => 'advanced:validate|advanced:continue|advanced:restart|advanced:reset',),
'OnCancelValidation' => Array ('self' => 'advanced:validate|advanced:continue|advanced:restart|advanced:reset',),
'OnCronValidation' => Array ('self' => 'advanced:validate|advanced:continue|advanced:restart|advanced:reset',),
);
$this->permMapping = array_merge($this->permMapping, $permissions);
}
function mapEvents()
{
parent::mapEvents();
$events_map = Array (
'OnApproveLinks' => 'iterateItems',
'OnDeclineLinks' => 'iterateItems',
);
$this->eventMethods = array_merge($this->eventMethods, $events_map);
}
/**
* Checks user permission to execute given $event
*
* @param kEvent $event
* @return bool
* @access public
*/
public function CheckPermission(&$event)
{
$check_events = Array ('OnApproveLinks', 'OnDeclineLinks', 'OnDeleteLinks');
if (in_array($event->Name, $check_events)) {
$ids = $this->_getSelectedIds($event);
$perm_value = true;
if ($ids) {
$perm_helper =& $this->Application->recallObject('PermissionsHelper');
/* @var $perm_helper kPermissionsHelper */
$items = $perm_helper->GetCategoryItemData('l', $ids);
$check_method = $event->Name == 'OnDeleteLinks' ? 'DeleteCheckPermission' : 'ModifyCheckPermission';
foreach ($items as $item_id => $item_data) {
if ($perm_helper->$check_method($item_data['CreatedById'], $item_data['CategoryId'], 'l') == 0) {
// one of items selected has no permission
$perm_value = false;
break;
}
}
if (!$perm_value) {
$event->status = kEvent::erPERM_FAIL;
}
}
return $perm_value;
}
return parent::CheckPermission($event);
}
/**
* Adds calculates fields for category name
*
* @param kDBItem|kDBList $object
* @param kEvent $event
* @return void
* @access protected
*/
protected function prepareObject(&$object, &$event)
{
parent::prepareObject($object, $event);
$object->addCalculatedField('CachedNavbar', 'c.l'.$this->Application->GetVar('m_lang').'_CachedNavbar');
}
/**
* Allows to show only invalid links
*
* @param kEvent $event
* @return void
* @access protected
* @see kDBEventHandler::OnListBuild()
*/
protected function SetCustomQuery(&$event)
{
$object =& $event->getObject();
/* @var $object kDBList */
$object->addFilter('primary_category_filter', 'ci.PrimaryCat = 1');
if ($event->Special == 'invalid') {
$object->addFilter('status_filter', '%1$s.ValidationStatus = ' . LINK_VALIDATION_INVALID);
}
}
/**
* Restarts link validation process
*
* @param kEvent $event
*/
function OnRestartValidation(&$event)
{
$this->_resetValidation($event);
$this->OnContinueValidation($event);
}
/**
* Restarts link validation process
*
* @param kEvent $event
*/
function _resetValidation(&$event)
{
// 1. delete previous validation results
$sql = 'SELECT ' . $this->Application->getUnitOption($event->Prefix, 'IDField') . '
FROM ' . $this->Application->getUnitOption($event->Prefix, 'TableName');
$ids = $this->Conn->GetCol($sql);
if ($ids) {
$temp_handler =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler');
/* @var $temp_handler kTempTablesHandler */
$temp_handler->DeleteItems($event->Prefix, $event->Special, $ids);
}
}
/**
* Validates only selected links
*
* @param kEvent $event
*/
function OnValidateSelected(&$event)
{
$link_ids = $this->_getSelectedIds($event);
if (!$link_ids) {
return ;
}
$validation_data = Array (
'processed' => 0,
'total' => count($link_ids),
'items' => $link_ids,
);
$this->Application->StoreVar($event->Prefix . '_status', serialize($validation_data));
$event->redirect = $this->Application->GetVar('progress_template');
}
/**
* Validates only links, that were not previously validated
*
* @param kEvent $event
*/
function OnContinueValidation(&$event)
{
$have_data = $this->_prepareValidation($event);
if ($have_data) {
$event->redirect = $this->Application->GetVar('progress_template');
}
}
/**
* Performs validation
*
* @param kEvent $event
* @param bool $from_ajax
*/
function _validate(&$event, $from_ajax = true)
{
$validation_data = unserialize( $this->Application->RecallVar($event->Prefix . '_status') );
$i = 0;
$link_ids = $validation_data['items'];
$per_page = count($link_ids) >= LINK_VALIDATION_PER_PAGE ? LINK_VALIDATION_PER_PAGE : count($link_ids);
while ($i < $per_page) {
$this->_validateLink($link_ids[$i]);
$i++;
}
// remove processed links from array
array_splice($link_ids, 0, LINK_VALIDATION_PER_PAGE);
// store validation progress
$validation_data['processed'] += $i;
$validation_data['items'] = $link_ids;
if ($validation_data['processed'] >= $validation_data['total']) {
// finished
$this->Application->EmailEventAdmin('LINK.VALIDATION.RESULTS');
$this->Application->RemoveVar($event->Prefix . '_status');
return true;
}
// show progress, proceed to next step
$this->Application->StoreVar($event->Prefix . '_status', serialize($validation_data));
if ($from_ajax) {
echo $validation_data['processed'] / $validation_data['total'] * 100;
$event->status = kEvent::erSTOP;
}
return false;
}
/**
* Performs validation of links (called from AjaxProgressBar)
*
* @param kEvent $event
*/
function OnValidateProgress(&$event)
{
$done = $this->_validate($event, true);
if ($done) {
$this->Application->Redirect( $this->Application->GetVar('finish_template') );
}
}
/**
* Returns categories, that are located inside recycle bin category
*
* @return Array
*/
function _getRecycleBinCategories()
{
$recycle_bin = $this->Application->ConfigValue('RecycleBinFolder');
if (!is_numeric($recycle_bin)) {
return Array ();
}
$recycle_categories = $this->Application->RecallVar('recycle_categories');
if ($recycle_categories === false) {
$tree_indexes = $this->Application->getTreeIndex($recycle_bin);
$sql = 'SELECT ' . $this->Application->getUnitOption('c', 'IDField') . '
FROM ' . $this->Application->getUnitOption('c', 'TableName') . '
WHERE TreeLeft BETWEEN ' . $tree_indexes['TreeLeft'] . ' AND ' . $tree_indexes['TreeRight'];
$recycle_categories = serialize( $this->Conn->GetCol($sql) );
// store recycle bin categories in session to prevent query below happening on each link validation step
$this->Application->StoreVar('recycle_categories', $recycle_categories);
}
return unserialize($recycle_categories);
}
/**
* Checks, that link is located in one of RecycleBin subcategories
*
* @param unknown_type $resource_id
* @return unknown
*/
function _inRecycleBin($resource_id)
{
static $recycle_bin = null;
if (!isset($recycle_bin)) {
$recycle_bin = $this->_getRecycleBinCategories();
}
if (!$recycle_bin) {
// Recycle Bin not used in system -> link is 100% not there
return false;
}
$sql = 'SELECT CategoryId
FROM ' . $this->Application->getUnitOption('l-ci', 'TableName') . '
WHERE ItemResourceId = ' . $resource_id . ' AND PrimaryCat = 1';
return in_array( $this->Conn->GetOne($sql), $recycle_bin);
}
function _validateLink($link_id)
{
$curl_helper =& $this->Application->recallObject('CurlHelper');
/* @var $curl_helper kCurlHelper */
$sql = 'SELECT Url, ResourceId
FROM ' . $this->Application->getUnitOption('l', 'TableName') . '
WHERE ' . $this->Application->getUnitOption('l', 'IDField') . ' = ' . $link_id;
$link_data = $this->Conn->GetRow($sql);
if (!preg_match('/^(http|https):\/\/(.*)/U', $link_data['Url']) || $this->_inRecycleBin($link_data['ResourceId'])) {
return ;
}
$curl_helper->timeout = LINK_VALIDATION_TIMEOUT;
$result = $curl_helper->Send($link_data['Url']);
if ($result === false || $curl_helper->lastErrorMsg != '') {
$curl_helper->lastErrorCode = 500;
}
$link_validation =& $this->Application->recallObject($this->Prefix . '.-item', null, Array ('skip_autoload' => true));
/* @var $link_validation kDBItem */
$link_validation->Load($link_id, 'LinkId');
$now = adodb_mktime();
$fields_hash = Array (
'LinkId' => $link_id,
'ValidationTime_date' => $now,
'ValidationTime_time' => $now,
'ValidationCode' => $curl_helper->lastHTTPCode,
'ValidationStatus' => $curl_helper->lastHTTPCode < 400 ? LINK_VALIDATION_VALID : LINK_VALIDATION_INVALID,
);
$link_validation->SetDBFieldsFromHash($fields_hash);
return $link_validation->isLoaded() ? $link_validation->Update() : $link_validation->Create();
}
/**
* Cancels validation (from validation progress bar)
*
* @param kEvent $event
*/
function OnCancelValidation(&$event)
{
$this->Application->RemoveVar($event->Prefix . '_status');
}
/**
* Resets validation status for selected
*
* @param kEvent $event
*/
function OnResetValidationStatus(&$event)
{
$ids = $this->_getSelectedIds($event, true);
if (!$ids) {
return ;
}
$temp_handler =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler');
/* @var $temp_handler kTempTablesHandler */
$temp_handler->DeleteItems($event->Prefix, $event->Special, $ids);
}
/**
* Returns ids, that user has checked in grid
*
* @param kEvent $event
* @param bool $transform convert link ids to link validation ids
* @return Array
*/
function _getSelectedIds(&$event, $transform = false)
{
$ids = Array();
$items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) );
if ($items_info) {
foreach ($items_info as $id => $field_values) {
if ( getArrayValue($field_values, 'ForeignLinkId') ) {
// we are not gathering ids by unit idfield here!
array_push($ids, $id);
}
}
}
if ($transform && $ids) {
$sql = 'SELECT ' . $this->Application->getUnitOption($event->Prefix, 'IDField') . '
FROM ' . $this->Application->getUnitOption($event->Prefix, 'TableName') . '
WHERE LinkId IN (' . implode(',', $ids) . ')';
$ids = $this->Conn->GetCol($sql);
}
return $ids;
}
/**
* Approves/declines selected links
*
* @param kEvent $event
* @return void
* @access protected
*/
protected function iterateItems(&$event)
{
if ( $this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1) ) {
$event->status = kEvent::erFAIL;
return;
}
$ids = $this->_getSelectedIds($event);
if ( !$ids ) {
return;
}
$object =& $this->Application->recallObject('l.-item', null, Array ('skip_autoload' => true));
/* @var $object kCatDBItem */
foreach ($ids as $id) {
$ret = true;
$object->Load($id);
switch ( $event->Name ) {
case 'OnApproveLinks':
$ret = $object->ApproveChanges();
break;
case 'OnDeclineLinks':
$ret = $object->DeclineChanges();
break;
}
if ( !$ret ) {
$event->status = kEvent::erFAIL;
$event->redirect = false;
break;
}
}
}
/**
* Deletes selected links
*
* @param kEvent $event
*/
function OnDeleteLinks(&$event)
{
if ($this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1)) {
$event->status = kEvent::erFAIL;
return;
}
$ids = $this->_getSelectedIds($event);
if (!$ids) {
return ;
}
$temp_handler =& $this->Application->recallObject('l_TempHandler', 'kTempTablesHandler');
/* @var $temp_handler kTempTablesHandler */
$temp_handler->DeleteItems('l', '', $ids);
}
/**
* [HOOK] Allows to edit links, used in selected link validation records
*
* @param kEvent $event
*/
function OnPrepareLinkEditing(&$event)
{
// hook to OnAfterConfigRead instead of OnEdit, because fake ids should be available in CheckPermission
if ($this->Application->GetVar('l_event') != 'OnEdit') {
return ;
}
$ids = $this->_getSelectedIds($event);
$id_field = $this->Application->getUnitOption('l', 'IDField');
$items_info = Array ();
foreach ($ids as $id) {
$items_info[$id][$id_field] = 'on';
}
$this->Application->SetVar('l', $items_info);
}
/**
* Gets all links, that are not yet validated and prepare data
*
* @param kEvent $event
*
* @return bool
*/
function _prepareValidation(&$event)
{
// 2. get ids of all links and put them into validation queue
$id_field = $this->Application->getUnitOption('l', 'IDField');
$sql = 'SELECT ' . $id_field . '
FROM ' . $this->Application->getUnitOption('l', 'TableName') . '
WHERE LinkId NOT IN (SELECT LinkId FROM ' . $this->Application->getUnitOption($event->Prefix, 'TableName') . ')';
$link_ids = $this->Conn->GetCol($sql);
if ($link_ids) {
$validation_data = Array (
'processed' => 0,
'total' => count($link_ids),
'items' => $link_ids,
);
$this->Application->StoreVar($event->Prefix . '_status', serialize($validation_data)); // 4K links will be 78KB serialized
return true;
}
return false;
}
/**
- * [REGULAR EVENT] Performs link validation throught cron
+ * [SCHEDULED TASK] Performs link validation through cron
*
* @param kEvent $event
*/
function OnCronValidation(&$event)
{
$this->_resetValidation($event); // remove this for continuing to non validated before links
$have_data = $this->_prepareValidation($event);
if ($have_data) {
do {
$done = $this->_validate($event, false);
} while (!$done);
}
}
/**
* Makes calculated fields to go to multilingual link fields
*
* @param kEvent $event
* @return void
* @access protected
*/
protected function OnAfterConfigRead(kEvent &$event)
{
parent::OnAfterConfigRead($event);
$calculated_fields = $this->Application->getUnitOption($event->Prefix, 'CalculatedFields');
$calculated_fields['']['LinkName'] = 'l.l' . $this->Application->GetVar('m_lang') . '_Name';
$this->Application->setUnitOption($event->Prefix, 'CalculatedFields', $calculated_fields);
}
}
\ No newline at end of file
Index: branches/5.2.x/units/listings/listings_config.php
===================================================================
--- branches/5.2.x/units/listings/listings_config.php (revision 14876)
+++ branches/5.2.x/units/listings/listings_config.php (revision 14877)
@@ -1,175 +1,175 @@
<?php
/**
* @version $Id$
* @package In-Link
* @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.org/license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
$config = Array (
'Prefix' => 'ls',
'ItemClass' => Array ('class' => 'kDBItem', 'file' => '', 'build_event' => 'OnItemBuild'),
'ListClass' => Array ('class' => 'kDBList', 'file' => '', 'build_event' => 'OnListBuild'),
'EventHandlerClass' => Array ('class' => 'ListingsEventHandler', 'file' => 'listings_event_handler.php', 'build_event' => 'OnBuild'),
'TagProcessorClass' => Array ('class' => 'ListingsTagProcessor', 'file' => 'listings_tag_processor.php', 'build_event' => 'OnBuild'),
'AutoLoad' => true,
'Hooks' => Array (
Array (
'Mode' => hAFTER,
'Conditional' => false,
'HookToPrefix' => 'l',
'HookToSpecial' => '*',
'HookToEvent' => Array ('OnBeforeDeleteOriginal'),
'DoPrefix' => '',
'DoSpecial' => '*',
'DoEvent' => 'OnMoveEnhancement',
),
),
'QueryString' => Array (
1 => 'id',
2 => 'Page',
3 => 'PerPage',
4 => 'event',
5 => 'mode',
),
- 'RegularEvents' => Array (
+ 'ScheduledTasks' => Array (
'listings_expiration' => Array ('EventName' => 'OnCheckExpiredPaidListings', 'RunInterval' => 1800, 'Type' => reAFTER),
),
'IDField' => 'ListingId',
'StatusField' => Array ('Status', 'PendingRenewal'),
'TitleField' => 'LinkName',
'TitlePresets' => Array (
'default' => Array ( 'new_status_labels' => Array ('ls' => '!la_title_AddingListing!'),
'edit_status_labels' => Array ('ls' => '!la_title_EditingListing!'),
'new_titlefield' => Array ('ls' => '!la_title_NewListing!'),
),
'listing_list' => Array ('prefixes' => Array ('ls_List'), 'format' => "!la_title_PaidListings!",),
'listing_edit' => Array ('prefixes' => Array ('ls'), 'format' => "#ls_status# '#ls_titlefield#' - !la_title_General!",),
),
'PermSection' => Array ('main' => 'in-link:paid_listings'),
'Sections' => Array (
'in-link:paid_listings_folder' => Array (
'parent' => 'in-link',
'icon' => 'paid_listings',
'label' => 'la_tab_PaidListings',
'use_parent_header' => 1,
'permissions' => Array (),
'priority' => 1,
'type' => stTREE,
),
'in-link:paid_listings' => Array (
'parent' => 'in-link:paid_listings_folder',
'icon' => 'paid_listings',
'label' => 'la_tab_Listings',
'url' => Array ('t' => 'in-link/paid_listings/paid_listings_list', 'pass' => 'm'),
'permissions' => Array ('view', 'add', 'edit', 'delete', 'advanced:approve', 'advanced:decline'),
'priority' => 1.1, // <parent_priority>.<own_priority>, because this section replaces parent in tree
'type' => stTAB,
),
),
'TableName' => TABLE_PREFIX.'Listings',
'ListSQLs' => Array ( '' => ' SELECT %1$s.* %2$s
FROM %1$s
LEFT JOIN '.TABLE_PREFIX.'Link item_table ON item_table.ResourceId = %1$s.ItemResourceId
LEFT JOIN '.TABLE_PREFIX.'PortalUser u ON u.PortalUserId = item_table.CreatedById'),
'ItemSQLs' => Array ( '' => ' SELECT %1$s.* %2$s
FROM %1$s
LEFT JOIN '.TABLE_PREFIX.'Link item_table ON item_table.ResourceId = %1$s.ItemResourceId
LEFT JOIN '.TABLE_PREFIX.'PortalUser u ON u.PortalUserId = item_table.CreatedById'),
'ListSortings' => Array (
'' => Array (
'Sorting' => Array ('PurchasedOn' => 'desc'),
)
),
'CalculatedFields' => Array (
'' => Array (
'LinkName' => 'CONCAT(item_table.Name, " (", item_table.Url, ")")',
'LinkOwner' => 'IF (ISNULL(u.Username), IF (item_table.CreatedById = ' . USER_ROOT . ', "root", IF (item_table.CreatedById = ' . USER_GUEST . ', "Guest", "n/a")), u.Username)',
),
),
'Fields' => Array (
'ListingId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0,),
'ListingTypeId' => Array (
'type' => 'int',
'formatter' => 'kOptionsFormatter',
'options_sql' => 'SELECT %s
FROM '.TABLE_PREFIX.'ListingTypes
ORDER BY Name',
'option_key_field' => 'ListingTypeId', 'option_title_field' => 'Name',
'default' => 0,
),
'ItemResourceId' => Array (
'type' => 'int',
'required' => 1, 'unique' => Array ('ItemResourceId'), 'default' => null,
'error_field' => 'LinkName',
),
'PurchasedOn' => Array ('type' => 'int', 'formatter' => 'kDateFormatter', 'default' => '#NOW#'),
'ExpiresOn' => Array ('type' => 'int', 'formatter' => 'kDateFormatter', 'default' => '#NOW#', 'required' =>1),
'Status' => Array (
'type' => 'int',
'formatter' => 'kOptionsFormatter',
'options' => Array (1 => 'la_Active', 2 => 'la_Pending', 0 => 'la_Disabled'), 'use_phrases' => 1,
'not_null' => 1, 'default' => 2,
),
'PendingRenewal' => Array (
'type' => 'int',
'formatter' => 'kOptionsFormatter',
'options' => Array (0 => 'la_NotPendingRenewal', 1 => 'la_PendingRenewal'), 'use_phrases' => 1,
'not_null' => 1, 'default' => 0,
),
'RenewalReminderSent' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
),
'VirtualFields' => Array (
'LinkName' => Array ('type' => 'string', 'default' => ''),
'LinkOwner' => Array ('type' => 'string', 'default' => ''),
),
'Grids' => Array (
'Default' => Array (
'Icons' => Array (
'default' => 'icon16_item.png',
'1_0' => 'icon16_link.png',
'0_0' => 'icon16_link_disabled.png',
'2_0' => 'icon16_link_pending.png',
'1_1' => 'icon16_link_pending.png',
'0_1' => 'icon16_link_disabled.png',
'2_1' => 'icon16_link_pending.png'),
'module' => 'core',
'Fields' => Array (
'ListingId' => Array ( 'title' => 'column:la_fld_Id' , 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter', 'width' => 60, ),
'LinkName' => Array ('data_block' => 'link_td', 'filter_block' => 'grid_like_filter', 'width' => 170, ),
'ListingTypeId' => Array ( 'title' => 'column:la_fld_ListingTypeName' , 'data_block' => 'listing_type_td', 'filter_block' => 'grid_like_filter', 'width' => 100, ),
'LinkOwner' => Array ('filter_block' => 'grid_like_filter', 'width' => 115, ),
'PendingRenewal' => Array ('filter_block' => 'grid_options_filter', 'width' => 143, ),
'PurchasedOn' => Array ('filter_block' => 'grid_date_range_filter', 'width' => 140, ),
'ExpiresOn' => Array ('filter_block' => 'grid_date_range_filter', 'width' => 140, ),
'Status' => Array ('filter_block' => 'grid_options_filter'),
),
),
),
);
\ No newline at end of file

Event Timeline