Index: branches/5.0.x/in-link/constants.php =================================================================== --- branches/5.0.x/in-link/constants.php (revision 12737) +++ branches/5.0.x/in-link/constants.php (revision 12738) @@ -1,29 +1,29 @@ <?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.net/license/ for copyright notices and details. +* See http://www.in-portal.org/license for copyright notices and details. */ // link reciprocal statuses define('LINK_IS_RECIPROCAL', 1); define('LINK_IS_NOT_RECIPROCAL', 2); // link validation constants define('LINK_VALIDATION_NOT_VALIDATED', 0); define('LINK_VALIDATION_VALID', 1); define('LINK_VALIDATION_INVALID', 2); /** * Validate this much links on each progress bar step * */ define('LINK_VALIDATION_PER_PAGE', 5); // in links define('LINK_VALIDATION_TIMEOUT', 10); // in seconds \ No newline at end of file Index: branches/5.0.x/in-link/units/links/links_event_handler.php =================================================================== --- branches/5.0.x/in-link/units/links/links_event_handler.php (revision 12737) +++ branches/5.0.x/in-link/units/links/links_event_handler.php (revision 12738) @@ -1,488 +1,488 @@ <?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.net/license/ for copyright notices and details. +* See http://www.in-portal.org/license for copyright notices and details. */ defined('FULL_PATH') or die('restricted access!'); class LinksEventHandler extends kCatDBEventHandler { /** * Allows to override standart permission mapping * */ function mapPermissions() { parent::mapPermissions(); $permissions = Array( 'OnContactFormSubmit' => Array('self' => true), 'OnProcessReciprocalLinks' => Array('self' => true), 'OnSetGrouping' => Array('self' => 'view'), 'OnStoreSelected' => Array('self' => 'view'), 'OnMerge' => Array('self' => 'edit'), ); $this->permMapping = array_merge($this->permMapping, $permissions); } /** * Enter description here... * * @param kEvent $event */ function SetCustomQuery(&$event) { parent::SetCustomQuery($event); $object =& $event->getObject(); if (!$this->Application->isAdminUser) { $object->addFilter('expire_filter', '(Expire > '.adodb_mktime().' OR Expire IS NULL)'); } if (substr($event->Special, 0, 10) == 'duplicates') { $object->removeFilter('category_filter'); $link_helper =& $this->Application->recallObject('LinkHelper'); /* @var $link_helper LinkHelper */ $grouping = $link_helper->getGrouping( $event->getPrefixSpecial() ); switch ($event->Special) { case 'duplicates': foreach ($grouping as $group_field) { $object->AddGroupByField($object->TableName.'.'.$group_field); } $object->addFilter('has_dupes_filter', 'DupeCount > 1', AGGREGATE_FILTER, FLT_SYSTEM); break; case 'duplicates-sub': $main_object =& $this->Application->recallObject($event->Prefix.'.duplicates'); foreach ($grouping as $field_index => $group_field) { $object->addFilter('dupe_filter_'.$field_index, '%1$s.`'.$group_field.'` = '.$this->Conn->qstr($main_object->GetDBField($group_field)) ); } break; } $object->addFilter('primary_filter', TABLE_PREFIX.'CategoryItems.PrimaryCat = 1'); } } /** * Set groping fields for link duplicate checker * * @param kEvent $event */ function OnSetGrouping(&$event) { $this->Application->LinkVar($event->getPrefixSpecial(true).'_dupe_fields', $event->getPrefixSpecial().'_dupe_fields'); } /** * Merge duplicate links together (only categories) & delete duplicates * * @param kEvent $event */ function OnMerge(&$event) { $link_helper =& $this->Application->recallObject('LinkHelper'); /* @var $link_helper LinkHelper */ $grouping = $link_helper->getGrouping( $event->getPrefixSpecial() ); $ids = $this->StoreSelectedIDs($event); if (!$ids) { return true; } // check, that user has not selected multiple links from same group $primary_links = Array(); $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField'); $table_name = $this->Application->getUnitOption($event->Prefix, 'TableName'); $sql = 'SELECT * FROM '.$table_name.' WHERE '.$id_field.' IN ('.implode(',', $ids).')'; $links = $this->Conn->Query($sql, $id_field); $groping_error = false; foreach ($links as $link_id => $link_data) { $group_key = ''; foreach ($grouping as $grouping_field) { $group_key .= 'main_table.`'.$grouping_field.'` = '.$this->Conn->qstr($link_data[$grouping_field]).' AND '; } $group_key = substr($group_key, 0, -5); if (isset($primary_links[$group_key])) { $groping_error = true; break; } else { $primary_links[$group_key] = $link_data['ResourceId']; } } if (!$groping_error) { $temp =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler'); $categories_sql = 'SELECT main_table.ResourceId, ci.CategoryId, main_table.'.$id_field.' FROM '.$table_name.' main_table LEFT JOIN '.TABLE_PREFIX.'CategoryItems ci ON main_table.ResourceId = ci.ItemResourceId WHERE %s'; foreach ($primary_links as $group_key => $primary_resource_id) { $categories = Array(); $group_links = Array(); $group_categories = $this->Conn->Query(sprintf($categories_sql, $group_key)); foreach ($group_categories as $category_data) { $group_links[ $category_data['ResourceId'] ] = $category_data[$id_field]; $categories[$category_data['ResourceId'] == $primary_resource_id ? 'remove' : 'add'][] = $category_data['CategoryId']; } unset($group_links[$primary_resource_id]); $categories = array_unique( array_diff($categories['add'], $categories['remove']) ); if ($categories) { // add link to other link categories $values_sql = ''; foreach ($categories as $category_id) { $values_sql .= '('.$category_id.','.$primary_resource_id.',0),'; } $values_sql = substr($values_sql, 0, -1); $insert_sql = 'INSERT INTO '.TABLE_PREFIX.'CategoryItems (CategoryId,ItemResourceId,PrimaryCat) VALUES '.$values_sql; $this->Conn->Query($insert_sql); } // delete all links from group except primary $temp->DeleteItems($event->Prefix, $event->Special, array_values($group_links)); } } else { $event->status = erFAIL; $event->redirect = false; $this->Application->SetVar($event->getPrefixSpecial().'_error', 1); } } /** * Stores ids, that were selected in duplicate checker * * @param kEvent $event */ function OnStoreSelected(&$event) { $this->StoreSelectedIDs($event); $event->SetRedirectParam('pass', 'm,' . $event->getPrefixSpecial()); } /** * Allows to enhance link after creation * * @param kEvent $event */ function OnCreate(&$event) { parent::OnCreate($event); if ($event->status == erSUCCESS) { $object =& $event->getObject(); /* @var $object kDBItem */ // replace 0 id in post with actual created id (used in enhancement process) $items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) ); array_rename_key($items_info, 0, $object->GetID()); $this->Application->SetVar($event->getPrefixSpecial(true), $items_info); // listing was created -> enhance it right away $enhancement_event = new kEvent('ls:OnRequestEnhancement'); $this->Application->HandleEvent($enhancement_event); if (($enhancement_event->status == erSUCCESS) && strlen($enhancement_event->redirect)) { $event->SetRedirectParam('next_template', $event->redirect); $event->redirect = $enhancement_event->redirect; } } } /** * Adds free listing option to listing type selection * * @param kEvent $event */ function OnAfterConfigRead(&$event) { parent::OnAfterConfigRead($event); if (defined('IS_INSTALL') && IS_INSTALL) { return ; } $free_listings = $this->Application->ConfigValue('Link_AllowFreeListings'); $virtual_fields = $this->Application->getUnitOption($event->Prefix, 'VirtualFields'); $virtual_fields['ListingTypeId']['options'] = $free_listings ? Array (0 => 'lu_free_listing') : Array (); $language_id = $this->Application->GetVar('m_lang'); $duplicate_options = array_flip($virtual_fields['DuplicateCheckFields']['options']); $duplicate_options['NAME'] = 'l' . $language_id . '_Name'; $virtual_fields['DuplicateCheckFields']['options'] = array_flip($duplicate_options); $default = $virtual_fields['DuplicateCheckFields']['default']; $virtual_fields['DuplicateCheckFields']['default'] = str_replace('|Name|', '|l' . $language_id . '_Name|', $default); $this->Application->setUnitOption($event->Prefix, 'VirtualFields', $virtual_fields); if (!$this->Application->isAdminUser) { // for now only on Front-End $this->Application->setUnitOption($event->Prefix, 'PopulateMlFields', true); } } /** * contact us form submitted on link details page * * @param kEvent $event */ function OnContactFormSubmit(&$event) { $fields = Array ( 'ContactFormFullName', 'ContactFormEmail', 'ContactFormSubject', 'ContactFormBody', 'ContactFormCaptcha' ); // reset errors var $this->Application->SetVar('ContactForm_HasErrors', ''); // 1. validate form fields $required_fields = $this->Application->GetVar('FormRequiredFields'); foreach ($fields as $field_name) { $field_value = trim($this->Application->GetVar($field_name)); if (in_array($field_name, $required_fields)) { // custom captcha validation if ($field_name == 'ContactFormCaptcha') { if (!strlen($field_value) || ($field_value != $this->Application->RecallVar($event->Prefix . '_captcha_code'))) { $this->Application->SetVar('error_'.$field_name, 1); $captcha_helper =& $this->Application->recallObject('CaptchaHelper'); /* @var $captcha_helper kCaptchaHelper */ $this->Application->StoreVar($event->Prefix . '_captcha_code', $captcha_helper->GenerateCaptchaCode()); $event->status = erFAIL; $event->redirect = false; } } // email validation elseif (!strlen($field_value) || ($field_name == 'ContactFormEmail' && !preg_match('/'.REGEX_EMAIL_USER.'@'.REGEX_EMAIL_DOMAIN.'/', $field_value))) { $this->Application->SetVar('error_'.$field_name, 1); $event->status = erFAIL; $event->redirect = false; } } } if ($event->status != erSUCCESS) { // set errors var $this->Application->SetVar('ContactForm_HasErrors', 1); return ; } $object =& $event->getObject(); // get link object /* @var $object kDBItem */ $send_params = Array( 'from_name' => $this->Application->GetVar('ContactFormFullName'), 'from_email' => $this->Application->GetVar('ContactFormEmail'), 'from_subject' => $this->Application->GetVar('ContactFormSubject'), 'message' => $this->Application->GetVar('ContactFormBody'), 'to_linkname' => $object->GetField('Name'), ); $email_event =& $this->Application->EmailEventUser('LINK.CONTACTFORM', $object->GetDBField('CreatedById'), $send_params); if ($email_event->status == erSUCCESS) { $event->redirect = $this->Application->GetVar('success_template'); $redirect_params = Array ( 'opener' => 's', 'pass' => 'all', 'thankyou_header' => $this->Application->GetVar('success_label_header'), 'thankyou_text' => $this->Application->GetVar('success_label_body') ); $event->setRedirectParams($redirect_params); $this->Application->EmailEventAdmin('LINK.CONTACTFORM', null, $send_params); } else { $this->Application->SetVar('error_ContactFormEmail', 1); $event->status = erFAIL; $event->redirect = false; } } /** * Makes reciprocal check on link, when it is created * * @param kEvent $event */ function OnBeforeItemCreate(&$event) { parent::OnBeforeItemCreate($event); $this->_checkLink($event); } /** * Makes reciprocal check on link, when it is updated * * @param kEvent $event */ function OnBeforeItemUpdate(&$event) { parent::OnBeforeItemUpdate($event); $this->_checkLink($event); } /** * Makes reciprocal check on link & saves results * * @param kEvent $event */ function _checkLink(&$event) { if (!$this->Application->ConfigValue('ReciprocalLinkChecking')) { return ; } $object =& $event->getObject(); /* @var $object kDBItem */ if ($object->GetDBField('Url') != $object->GetOriginalField('Url')) { // check only when url was changed $link_helper =& $this->Application->recallObject('LinkHelper'); /* @var $link_helper LinkHelper */ $link_checked = $link_helper->CheckReciprocalURL($object->GetDBField('Url')); $object->SetDBField('ReciprocalLinkFound', $link_checked ? LINK_IS_RECIPROCAL : LINK_IS_NOT_RECIPROCAL); if (!$link_checked) { $this->Application->EmailEventAdmin('LINK.RECIPROCAL.CHECK.FAILED'); } } } /** * Update links status by their reciprocal status * * @param kEvent $event */ function OnProcessReciprocalLinks(&$event) { if (!$this->Application->ConfigValue('ReciprocalLinkChecking')) { return ; } $object =& $event->getObject( Array('skip_autoload' => true) ); /* @var $object kDBItem */ $link_helper =& $this->Application->recallObject('LinkHelper'); /* @var $link_helper LinkHelper */ // 1. verify all links, that were not verified previously $sql = 'SELECT ' . $id_field . ' FROM ' . $table_name . ' WHERE (ReciprocalLinkFound = 0)'; $not_checked_links = $this->Conn->GetCol($sql); foreach ($not_checked_links as $link_id) { $object->Load($link_id); $link_checked = $link_helper->CheckReciprocalURL($object->GetDBField('Url')); $object->SetDBField('ReciprocalLinkFound', $link_checked ? LINK_IS_RECIPROCAL : LINK_IS_NOT_RECIPROCAL); $object->Update(); if ($link_checked) { $object->ApproveChanges(); } else { $object->DeclineChanges(); $this->Application->EmailEventAdmin('LINK.RECIPROCAL.CHECK.FAILED'); } } // 2. approve all links, that have succeeded in reciprocal check (during adding/changing on front-end) $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField'); $table_name = $this->Application->getUnitOption($event->Prefix, 'TableName'); $sql = 'SELECT ' . $id_field . ' FROM ' . $table_name . ' WHERE (ReciprocalLinkFound = ' . LINK_IS_RECIPROCAL . ') AND (Status <> ' . STATUS_ACTIVE . ')'; $verified_links = $this->Conn->GetCol($sql); foreach ($verified_links as $link_id) { $object->Load($link_id); $object->ApproveChanges(); } // 3. decline all links, that failed in reciprocal check (during adding/changing on front-end) $sql = 'SELECT ' . $id_field . ' FROM ' . $table_name . ' WHERE (ReciprocalLinkFound = ' . LINK_IS_NOT_RECIPROCAL . ') AND (Status <> ' . STATUS_DISABLED . ')'; $not_verified_links = $this->Conn->GetCol($sql); foreach ($not_verified_links as $link_id) { $object->Load($link_id); $object->DeclineChanges(); } } /** * Allows to load duplicate link by special id * * @param kEvent $event * @return int */ function getPassedID(&$event) { $id = parent::getPassedID($event); if (($event->Special == 'duplicates') && !is_numeric($id)) { $load_keys = unserialize( base64_decode($id) ); // can't return $load_keys as $id, because "kCatDBItem::GetKeyClause" will ignore them foreach ($load_keys as $field => $value) { $load_keys[$field] = $field . ' = ' . $this->Conn->qstr($value); } $sql = 'SELECT ' . $this->Application->getUnitOption($event->Prefix, 'IDField') . ' FROM ' . $this->Application->getUnitOption($event->Prefix, 'TableName') . ' WHERE (' . implode(') AND (', $load_keys) . ')'; $id = $this->Conn->GetOne($sql); } return $id; } /** * Returns events, that require item-based (not just event-name based) permission check * * @return Array */ function _getMassPermissionEvents() { $events = parent::_getMassPermissionEvents(); $events[] = 'OnMerge'; return $events; } } \ No newline at end of file Index: branches/5.0.x/in-link/units/links/links_config.php =================================================================== --- branches/5.0.x/in-link/units/links/links_config.php (revision 12737) +++ branches/5.0.x/in-link/units/links/links_config.php (revision 12738) @@ -1,571 +1,571 @@ <?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.net/license/ for copyright notices and details. +* See http://www.in-portal.org/license for copyright notices and details. */ defined('FULL_PATH') or die('restricted access!'); $config = Array( 'Prefix' => 'l', 'ItemClass' => Array('class'=>'kCatDBItem','file'=>'','build_event'=>'OnItemBuild'), 'ListClass' => Array('class'=>'kCatDBList','file'=>'','build_event'=>'OnListBuild'), 'EventHandlerClass' => Array('class' => 'LinksEventHandler', 'file' => 'links_event_handler.php', 'require_classes' => Array('kCatDBEventHandler'), 'build_event'=>'OnBuild'), 'TagProcessorClass' => Array('class'=>'LinkTagProcessor','file'=>'link_tag_processor.php', 'require_classes' => Array('kCatDBTagProcessor'), 'build_event'=>'OnBuild'), 'AutoLoad' => true, 'ConfigPriority' => 0, 'RewritePriority' => 101, 'RewriteListener' => 'ModRewriteHelper:CategoryItemRewriteListener', 'Hooks' => Array ( Array ( 'Mode' => hBEFORE, 'Conditional' => false, 'HookToPrefix' => '', 'HookToSpecial' => '*', 'HookToEvent' => Array('OnAfterConfigRead'), 'DoPrefix' => 'cdata', 'DoSpecial' => '*', 'DoEvent' => 'OnDefineCustomFields', ), Array ( 'Mode' => hBEFORE, 'Conditional' => false, 'HookToPrefix' => '', 'HookToSpecial' => '*', 'HookToEvent' => Array('OnAfterConfigRead'), 'DoPrefix' => '#file', 'DoSpecial' => '*', 'DoEvent' => 'OnDefineFiles', ), Array ( 'Mode' => hAFTER, 'Conditional' => false, 'HookToPrefix' => '', 'HookToSpecial' => '*', 'HookToEvent' => Array('OnAfterConfigRead'), 'DoPrefix' => 'captcha', 'DoSpecial' => '*', 'DoEvent' => 'OnPrepareCaptcha', ), ), 'QueryString' => Array( 1 => 'id', 2 => 'Page', 3 => 'event', 4 => 'mode', ), 'AggregateTags' => Array ( Array ( 'AggregateTo' => 'l', 'AggregatedTagName' => 'ListLinks', 'LocalTagName' => 'PrintList2', ), ), 'CatalogItem' => true, 'AdminTemplatePath' => 'links', 'AdminTemplatePrefix' => 'links_', 'SearchConfigPostfix' => 'links', 'IDField' => 'LinkId', 'StatusField' => Array('Status'), // field, that is affected by Approve/Decline events 'ItemType' => 4, 'StatisticsInfo' => Array( 'pending' => Array( 'icon' => 'icon16_link_pending.png', 'label' => 'la_Text_Links', 'js_url' => '#url#', 'url' => Array('t' => 'catalog/advanced_view', 'SetTab' => 'l', 'pass' => 'm,l.showall', 'l.showall_event' => 'OnSetFilterPattern', 'l.showall_filters' => 'show_active=0,show_pending=1,show_disabled=0,show_new=1,show_hot=1,show_pop=1,show_pick=1'), 'status' => STATUS_PENDING, ), ), 'TitlePhrase' => 'la_Text_Link', // phrase used to specify item type in relationship list 'ViewMenuPhrase' => 'la_title_Links', 'CatalogTabIcon' => 'in-link:icon16_links.png', 'UsePendingEditing' => true, // item editing is controlled by LINK.ADD/EDIT, LINK.ADD/EDIT.PENDING permissions 'CatalogSelectorName' => 'linklist', // used in old catalog section 'ItemPropertyMappings' => Array( 'NewDays' => 'Link_NewDays', // number of days item to be NEW 'MinPopVotes' => 'Link_MinPopVotes', // minimum number of votes for an item to be POP 'MinPopRating' => 'Link_MinPopRating', // minimum rating for an item to be POP 'MaxHotNumber' => 'Link_MaxHotNumber', // maximum number of HOT items 'HotLimit' => 'Link_HotLimit', // variable name in inp_Cache table 'ClickField' => 'Hits', // item click count is stored here (in item table) ), 'TitleField' => 'Name', 'TitlePresets' => Array( 'default' => Array( 'new_status_labels' => Array('l' => '!la_title_AddingLink!'), 'edit_status_labels' => Array('l'=>'!la_title_EditingLink!'), 'new_titlefield' => Array('l'=>'!la_title_NewLink!'), ), 'links_edit' => Array( 'prefixes' => Array('l'), 'format' => "#l_status# '#l_titlefield#' - !la_title_General!", 'toolbar_buttons' => Array ('select', 'cancel', 'prev', 'next'), ), 'link_list' => Array( 'prefixes' => Array('c_List', 'l_List'), 'format' => "!la_title_Categories! (#c_recordcount#) - !la_title_Links!", 'toolbar_buttons' => Array (), ), 'links_categories' => Array( 'prefixes' => Array('l','l-ci_List'), 'format' => "#l_status# '#l_titlefield#' - !la_title_Categories!", 'toolbar_buttons' => Array ('select', 'cancel', 'prev', 'next', 'new_item', 'delete', 'setprimary',), ), 'links_relations' => Array( 'prefixes' => Array('l'), 'format' => "#l_status# '#l_titlefield#' - !la_title_Relations!", 'toolbar_buttons' => Array ('select', 'cancel', 'prev', 'next', 'new_item', 'edit', 'delete', 'approve', 'decline', 'view', 'dbl-click'), ), 'links_images' => Array( 'prefixes' => Array('l'), 'format' => "#l_status# '#l_titlefield#' - !la_title_Images!", 'toolbar_buttons' => Array ('select', 'cancel', 'prev', 'next', 'new_item', 'edit', 'delete', 'move_up', 'move_down', 'setprimary', 'view', 'dbl-click'), ), 'links_files' => Array( 'prefixes' => Array('l'), 'format' => "#l_status# '#l_titlefield#' - !la_title_Files!", 'toolbar_buttons' => Array ('select', 'cancel', 'prev', 'next', 'new_item', 'edit', 'delete', 'view', 'dbl-click'), ), 'links_reviews' => Array( 'prefixes' => Array('l'), 'format' => "#l_status# '#l_titlefield#' - !la_title_Reviews!", 'toolbar_buttons' => Array ('select', 'cancel', 'prev', 'next', 'new_item', 'edit', 'delete', 'approve', 'decline', 'move_up', 'move_down', 'view', 'dbl-click'), ), 'links_custom' => Array( 'prefixes' => Array('l'), 'format' => "#l_status# '#l_titlefield#' - !la_title_Custom!", 'toolbar_buttons' => Array ('select', 'cancel', 'prev', 'next'), ), 'images_edit' => Array( 'prefixes' => Array('l', 'l-img'), 'new_status_labels' => Array('l-img' => '!la_title_Adding_Image!'), 'edit_status_labels' => Array('l-img' => '!la_title_Editing_Image!'), 'new_titlefield' => Array('l-img' => '!la_title_New_Image!'), 'format' => "#l_status# '#l_titlefield#' - #l-img_status# '#l-img_titlefield#'", 'toolbar_buttons' => Array ('select', 'cancel'), ), 'file_edit' => Array ( 'prefixes' => Array ('l', 'l-file'), 'new_status_labels' => Array ('l-file' => "!la_title_AddingFile!"), 'edit_status_labels' => Array ('l-file' => '!la_title_EditingFile!'), 'new_titlefield' => Array ('l-file' => '!la_title_NewFile!'), 'format' => "#l_status# '#l_titlefield#' - #l-file_status# '#l-file_titlefield#'", 'toolbar_buttons' => Array ('select', 'cancel'), ), 'reviews_edit' => Array( 'prefixes' => Array('l', 'l-rev'), 'new_status_labels' => Array('l-rev'=>"!la_title_Adding_Review! '!la_title_New_Review!'"), 'edit_status_labels' => Array('l-rev'=>'!la_title_Editing_Review!'), 'format' => "#l_status# '#l_titlefield#' - #l-rev_status#", 'toolbar_buttons' => Array ('select', 'cancel'), ), 'relations_edit' => Array( 'prefixes' => Array('l', 'l-rel'), 'new_status_labels' => Array('l-rel'=>"!la_title_Adding_Relationship! '!la_title_New_Relationship!'"), 'edit_status_labels' => Array('l-rel'=>'!la_title_Editing_Relationship!'), 'format' => "#l_status# '#l_titlefield#' - #l-rel_status#", 'toolbar_buttons' => Array ('select', 'cancel'), ), 'links_export' => Array('format' => '!la_title_LinksExport!'), 'links_import' => Array('format' => '!la_title_ImportLinks!'), 'duplicate_links' => Array( 'prefixes' => Array('l.duplicates_List'), 'format' => "!la_title_DuplicateLinks! - %s", 'toolbar_buttons' => Array ('edit', 'view', 'dbl-click'), ), 'duplicate_links_view' => Array( 'prefixes' => Array('l.duplicates-sub_List'), 'format' => "!la_title_Links!", 'toolbar_buttons' => Array ('cancel', 'edit', 'delete', 'merge_links', 'view', 'dbl-click'), ), 'tree_in-link' => Array('format' => '!la_Text_Version! '.$this->Application->findModule('Name', 'In-Link', 'Version')), ), 'EditTabPresets' => Array ( 'Default' => Array ( 'general' => Array ('title' => 'la_tab_General', 't' => 'in-link/links/links_edit', 'priority' => 1), 'categories' => Array ('title' => 'la_tab_Categories', 't' => 'in-link/links/links_categories', 'priority' => 2), 'relations' => Array ('title' => 'la_tab_Relations', 't' => 'in-link/links/links_relations', 'priority' => 3), 'images' => Array ('title' => 'la_tab_Images', 't' => 'in-link/links/links_images', 'priority' => 4), 'files' => Array ('title' => 'la_tab_Files', 't' => 'in-link/links/links_files', 'priority' => 5), 'reviews' => Array ('title' => 'la_tab_Reviews', 't' => 'in-link/links/links_reviews', 'priority' => 6), 'custom' => Array ('title' => 'la_tab_Custom', 't' => 'in-link/links/links_custom', 'priority' => 7), ), ), 'PermItemPrefix' => 'LINK', 'PermTabText' => 'In-Link', 'PermSection' => Array('main' => 'CATEGORY:in-link:links_list', 'search' => 'in-link:configuration_search', 'email' => 'in-link:configuration_email', 'custom' => 'in-link:configuration_custom'), 'Sections' => Array( 'in-link' => Array( 'parent' => 'in-portal:root', 'icon' => 'settings_in-link', 'label' => 'la_title_In-Link', 'url' => Array('t' => 'index', 'pass_section' => true, 'pass' => 'm'), 'permissions' => Array('view'), 'priority' => 2.3, 'container' => true, 'type' => stTREE, ), 'in-link:links' => Array( 'parent' => 'in-portal:site', 'icon' => 'links', 'label' => 'la_tab_Links', 'url' => Array('t' => 'catalog/advanced_view', 'anchor' => 'tab-l.showall', 'pass' => 'm'), 'onclick' => 'setCatalogTab(\'l.showall\')', 'permissions' => Array('view'), 'priority' => 3.1, 'type' => stTREE, ), 'in-link:duplicate_checker' => Array( 'parent' => 'in-link', 'icon' => 'duplicate_checker', 'label' => 'la_tab_DuplicateChecker', 'url' => Array('t' => 'in-link/duplicate_checker', 'pass' => 'm'), 'permissions' => Array('view', 'add', 'edit', 'delete'), 'priority' => 2, 'type' => stTREE, ), // link settings 'in-link:setting_folder' => Array ( 'parent' => 'in-portal:system', 'icon' => 'conf_directory', 'label' => 'la_title_In-Link', 'url' => Array ('t' => 'index', 'pass_section' => true, 'pass' => 'm'), 'permissions' => Array ('view'), 'priority' => 3.3, 'container' => true, 'type' => stTREE, ), /*'in-link:inlink_general' => Array( 'parent' => 'in-link:setting_folder', 'icon' => 'core:settings_general', 'label' => 'la_tab_GeneralSettings', 'url' => Array('t' => 'config/config_general', 'pass_section' => true, 'pass' => 'm'), 'permissions' => Array('view', 'edit'), 'priority' => 0.9, 'type' => stTREE, ),*/ 'in-link:configuration_output' => Array( 'parent' => 'in-link:setting_folder', 'icon' => 'core:conf_output', 'label' => 'la_tab_ConfigOutput', 'url' => Array('t' => 'config/config_general', 'pass_section' => true, 'pass' => 'm'), 'permissions' => Array('view', 'edit'), 'priority' => 1, 'type' => stTREE, ), 'in-link:configuration_search' => Array( 'parent' => 'in-link:setting_folder', 'icon' => 'core:conf_search', 'label' => 'la_tab_ConfigSearch', 'url' => Array('t' => 'config/config_search', 'module_key' => 'links', 'pass_section' => true, 'pass' => 'm'), 'permissions' => Array('view', 'edit'), 'priority' => 2, 'type' => stTREE, ), 'in-link:configuration_email' => Array( 'parent' => 'in-link:setting_folder', 'icon' => 'core:conf_email', 'label' => 'la_tab_ConfigE-mail', 'url' => Array('t' => 'config/config_email', 'pass_section' => true, 'pass' => 'm'), 'permissions' => Array('view', 'edit'), 'priority' => 3, 'type' => stTREE, ), 'in-link:configuration_custom' => Array( 'parent' => 'in-link:setting_folder', 'icon' => 'core:conf_customfields', 'label' => 'la_tab_ConfigCustom', 'url' => Array('t' => 'custom_fields/custom_fields_list', 'cf_type' => 4, 'pass_section' => true, 'pass' => 'm,cf'), 'permissions' => Array('view', 'add', 'edit', 'delete'), 'priority' => 4, 'type' => stTREE, ), ), 'FilterMenu' => Array( 'Groups' => Array( Array('mode' => 'AND', 'filters' => Array('show_active','show_pending','show_disabled'), 'type' => WHERE_FILTER), Array('mode' => 'AND', 'filters' => Array('show_new'), 'type' => HAVING_FILTER), Array('mode' => 'AND', 'filters' => Array('show_hot'), 'type' => HAVING_FILTER), Array('mode' => 'AND', 'filters' => Array('show_pop'), 'type' => HAVING_FILTER), Array('mode' => 'AND', 'filters' => Array('show_pick'), 'type' => WHERE_FILTER), ), 'Filters' => Array( 'show_active' => Array('label' =>'la_Active', 'on_sql' => '', 'off_sql' => '%1$s.Status != 1' ), 'show_pending' => Array('label' => 'la_Pending', 'on_sql' => '', 'off_sql' => '%1$s.Status != 2' ), 'show_disabled' => Array('label' => 'la_Disabled', 'on_sql' => '', 'off_sql' => '%1$s.Status != 0' ), 's1' => Array(), 'show_new' => Array('label' => 'la_Text_New', 'on_sql' => '', 'off_sql' => '`IsNew` != 1' ), 'show_hot' => Array('label' => 'la_Text_Hot', 'on_sql' => '', 'off_sql' => '`IsHot` != 1' ), 'show_pop' => Array('label' => 'la_Text_Pop', 'on_sql' => '', 'off_sql' => '`IsPop` != 1' ), 'show_pick' => Array('label' => 'la_prompt_EditorsPick', 'on_sql' => '', 'off_sql' => '%1$s.`EditorsPick` != 1' ), ) ), 'TableName' => TABLE_PREFIX.'Link', 'CalculatedFields' => Array ( '' => Array ( 'UserName' => 'IF (ISNULL(u.Login), IF (%1$s.CreatedById = -1, "root", IF (%1$s.CreatedById = -2, "Guest", "n/a")), u.Login)', 'CategoryId' => TABLE_PREFIX.'%3$sCategoryItems.CategoryId', 'Filename' => TABLE_PREFIX.'%3$sCategoryItems.Filename', 'CategoryFilename' => TABLE_PREFIX.'Category.NamedParentPath', 'PrimaryCat' => TABLE_PREFIX.'%3$sCategoryItems.PrimaryCat', 'ParentPath' => TABLE_PREFIX.'Category.ParentPath', 'SameImages' => 'img.SameImages', 'LocalThumb' => 'img.LocalThumb', 'ThumbPath' => 'img.ThumbPath', 'ThumbUrl' => 'img.ThumbUrl', 'LocalImage' => 'img.LocalImage', 'LocalPath' => 'img.LocalPath', 'FullUrl' => 'img.Url', ), ), 'CacheModRewrite' => true, 'AggregatedCalculatedFields' => Array( 'duplicates' => Array ( 'DupeCount' => 'COUNT(*)', ), ), 'ListSQLs' => Array( ''=>' SELECT %1$s.* %2$s FROM %1$s LEFT JOIN '.TABLE_PREFIX.'%3$sCategoryItems ON '.TABLE_PREFIX.'%3$sCategoryItems.ItemResourceId = %1$s.ResourceId LEFT JOIN '.TABLE_PREFIX.'Category ON '.TABLE_PREFIX.'Category.CategoryId = '.TABLE_PREFIX.'%3$sCategoryItems.CategoryId LEFT JOIN '.TABLE_PREFIX.'Images img ON img.ResourceId = %1$s.ResourceId AND img.DefaultImg = 1 LEFT JOIN '.TABLE_PREFIX.'PermCache perm ON perm.CategoryId = '.TABLE_PREFIX.'%3$sCategoryItems.CategoryId LEFT JOIN '.TABLE_PREFIX.'PortalUser u ON %1$s.CreatedById = u.PortalUserId LEFT JOIN '.TABLE_PREFIX.'%3$sLinkCustomData cust ON %1$s.ResourceId = cust.ResourceId', ), // key - special, value - list select sql 'ListSortings' => Array( '' => Array( 'ForcedSorting' => Array('Priority' => 'desc'), 'Sorting' => Array('Name' => 'asc', 'Description' => 'desc'), ) ), 'ItemSQLs' => Array( ''=>' SELECT %1$s.* %2$s FROM %1$s LEFT JOIN '.TABLE_PREFIX.'%3$sCategoryItems ON '.TABLE_PREFIX.'%3$sCategoryItems.ItemResourceId = %1$s.ResourceId LEFT JOIN '.TABLE_PREFIX.'Category ON '.TABLE_PREFIX.'Category.CategoryId = '.TABLE_PREFIX.'%3$sCategoryItems.CategoryId LEFT JOIN '.TABLE_PREFIX.'Images img ON img.ResourceId = %1$s.ResourceId AND img.DefaultImg = 1 LEFT JOIN '.TABLE_PREFIX.'PortalUser u ON %1$s.CreatedById = u.PortalUserId LEFT JOIN '.TABLE_PREFIX.'%3$sLinkCustomData cust ON %1$s.ResourceId = cust.ResourceId'), 'SubItems' => Array('l-rev', 'l-ci', 'l-rel', 'l-img', 'l-cdata', 'l-fav', 'l-file'), 'Fields' => Array ( 'LinkId' => Array('type' => 'int', 'not_null' => 1, 'default' => 0,), 'Name' => Array('type' => 'string', 'formatter' => 'kMultiLanguage', 'not_null' => 1, 'required' => 1, 'max_len' => 255, 'default' => ''), 'AutomaticFilename' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array(1 => 'la_Yes', 0 => 'la_No'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 1), 'Description' => Array('type' => 'string', 'formatter' => 'kMultiLanguage', 'using_fck' => 1, 'default' => null), 'Url' => Array('type' => 'string', 'not_null' => 1, 'required' => 1, 'default' => ''), 'CreatedOn' => Array('type' => 'int', 'formatter' => 'kDateFormatter', 'default' => '#NOW#'), 'Modified' => Array('type' => 'int', 'formatter' => 'kDateFormatter', 'default' => '#NOW#'), 'Expire' => Array('type' => 'int', 'formatter' => 'kDateFormatter', 'default' => null), 'Hits' => Array('type' => 'double', 'formatter' => 'kFormatter', 'format' => '%d', 'not_null' => 1, 'default' => 0), 'CachedRating' => Array('type' => 'string', 'not_null' => 1, 'formatter' => 'kFormatter', 'default' => 0), 'CachedVotesQty' => Array('type' => 'int', 'formatter' => 'kFormatter', 'not_null' => 1, 'default' => 0), 'CachedReviewsQty' => Array('type' => 'int', 'not_null' => 1, 'default' => 0), 'CreatedById' => Array('type' => 'int', 'formatter' => 'kLEFTFormatter', 'error_msgs' => Array ('invalid_option' => '!la_error_UserNotFound!'), 'options' => Array(-1 => 'root', -2 => 'Guest'),'left_sql'=>'SELECT %s FROM '.TABLE_PREFIX.'PortalUser WHERE `%s` = \'%s\'', 'left_key_field' => 'PortalUserId', 'left_title_field' => 'Login', 'not_null' => 1, 'default' => -1), 'ModifiedById' => Array('type' => 'int', 'formatter' => 'kLEFTFormatter', 'error_msgs' => Array ('invalid_option' => '!la_error_UserNotFound!'), 'options' => Array(-1 => 'root', -2 => 'Guest'),'left_sql'=>'SELECT %s FROM '.TABLE_PREFIX.'PortalUser WHERE `%s` = \'%s\'', 'left_key_field' => 'PortalUserId', 'left_title_field' => 'Login', 'not_null' => 1, 'default' => -1), 'Priority' => Array('type' => 'int', 'not_null' => 1, 'default' => 0), '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), 'EditorsPick' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Yes', 0 => 'la_No'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 0), 'ResourceId' => Array('type' => 'int', 'default' => null), 'HotItem' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (2 => 'la_Auto', 1 => 'la_Always', 0 => 'la_Never'), 'use_phrases' => 1, 'not_null' => 1,'default' => 2), 'PopItem' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (2 => 'la_Auto', 1 => 'la_Always', 0 => 'la_Never'), 'use_phrases' => 1, 'not_null' => 1,'default' => 2), 'NewItem' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (2 => 'la_Auto', 1 => 'la_Always', 0 => 'la_Never'), 'use_phrases' => 1, 'not_null' => 1,'default' => 2), 'OrgId' => Array('type' => 'int', 'default' => null), 'CustomTemplate' => Array('type' => 'string', 'not_null' => 1, 'default' => ''), 'MetaKeywords' => Array('type' => 'string', 'default' => null), 'MetaDescription' => Array('type' => 'string', 'formatter' => 'kFormatter', 'using_fck' => 1, 'default' => null), 'ReciprocalLinkFound' => Array ( 'type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (0 => 'la_NotChecked', 1 => 'la_Yes', 2 => 'la_No'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 0 ), ), 'VirtualFields' => Array( 'UserName' => Array('type' => 'string', 'default' => ''), 'DupeCount' => Array('type' => 'string', 'default' => ''), 'ListingTypeId' => Array ('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %1$s FROM '.TABLE_PREFIX.'ListingTypes ORDER BY Name', 'option_title_field' => 'Name', 'option_key_field' => 'ListingTypeId', 'default' => 0), 'MoreCategories' => Array ('type' => 'string', 'default' => ''), // export related fields: begin 'CategoryId' => Array ('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (), 'default' => 0), 'ExportFormat' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array(1 => 'CSV', /*2 => 'XML'*/), 'default' => 1), 'ExportFilename' => Array('type' => 'string', 'default' => ''), 'FieldsSeparatedBy' => Array('type' => 'string', 'default' => ','), 'FieldsEnclosedBy' => Array('type' => 'string', 'default' => '"'), 'LineEndings' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array(1 => 'Windows', 2 => 'UNIX'), 'default' => 1), 'LineEndingsInside' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array(1 => 'CRLF', 2 => 'LF'), 'default' => 2), 'IncludeFieldTitles' => Array('type' => 'int', 'default' => 1), 'ExportColumns' => Array('type' => 'string', 'formatter' => 'kOptionsFormatter', 'options' => Array()), 'AvailableColumns' => Array('type' => 'string', 'formatter' => 'kOptionsFormatter', 'options' => Array()), 'CategoryFormat' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array(1 => 'la_MixedCategoryPath', 2 => 'la_SeparatedCategoryPath'), 'use_phrases' => 1, 'default' => 1), 'CategorySeparator' => Array('type' => 'string', 'error_field' => 'CategoryFormat', 'default' => ':'), 'IsBaseCategory' => Array('type' => 'int', 'default' => 0), // export related fields: end // import related fields: begin 'FieldTitles' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array(1 => 'la_Automatic', 2 => 'la_Manual'), 'use_phrases' => 1, 'default' => 1), 'ImportSource' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array(1 => 'la_Upload', 2 => 'la_Local'), 'use_phrases' => 1, 'default' => 2), 'ImportFilename' => Array('type' => 'string', 'formatter' => 'kUploadFormatter', 'max_size' => MAX_UPLOAD_SIZE, 'upload_dir' => (defined('EXPORT_BASE_PATH') ? EXPORT_BASE_PATH : '/system/export') . '/'), 'ImportLocalFilename' => Array('type' => 'string', 'formatter' => 'kOptionsFormatter', 'default' => ''), 'CheckDuplicatesMethod' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array(1 => 'la_IDField', 2 => 'la_OtherFields'), 'use_phrases' => 1, 'default' => 1), 'ReplaceDuplicates' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array(0 => 'la_No', 1 => 'la_Yes'), 'use_phrases' => 1, 'default' => 0), 'DuplicateCheckFields' => Array('type' => 'string', 'formatter' => 'kOptionsFormatter', 'options' => Array('Name' => 'NAME', 'Url' => 'URL'), 'default' => '|Name|Url|'), 'SkipFirstRow' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array(1 => 'la_Yes', 0 => 'la_No'), 'use_phrases' => 1, 'default' => 1), // import related fields: end 'ThumbnailImage' => Array('type' => 'string', 'default' => ''), 'FullImage' => Array('type' => 'string', 'default' => ''), 'ImageAlt' => Array('type' => 'string', 'default' => ''), 'Filename' => Array('type' => 'string','not_null' => 1,'default' => ''), 'CachedNavbar' => Array('type' => 'string', 'default' => ''), 'ParentPath' => Array('type' => 'string', 'default' => ''), // for primary image 'SameImages' => Array('type' => 'string', 'default' => ''), 'LocalThumb' => Array('type' => 'string', 'default' => ''), 'ThumbPath' => Array('type' => 'string', 'default' => ''), 'ThumbUrl' => Array('type' => 'string', 'default' => ''), 'LocalImage' => Array('type' => 'string', 'default' => ''), 'LocalPath' => Array('type' => 'string', 'default' => ''), 'FullUrl' => Array('type' => 'string', 'default' => ''), ), 'Grids' => Array ( 'Default' => Array ( 'Icons' => Array ( 0 => 'icon16_link_disabled.png', 1 => 'icon16_link.png', 2 => 'icon16_link_pending.png', 'NEW' => 'icon16_link_new.png', ), 'Fields' => Array ( 'LinkId' => Array ('title'=>'la_col_Id', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter', 'width' => 60, ), 'Name' => Array ('title'=>'la_col_LinkName', 'data_block' => 'grid_catitem_td', 'width' => 200, ), 'Url' => Array ('title' => 'la_col_LinkUrl', 'width' => 200, ), 'Description' => Array ('title' => 'la_col_Description', 'first_chars' => 100, 'width' => 100, ), 'CreatedOn' => Array ('title' => 'la_col_CreatedOn', 'filter_block' => 'grid_date_range_filter', 'width' => 145, ), 'Modified' => Array ('title' => 'la_col_Modified', 'filter_block' => 'grid_date_range_filter', 'width' => 145, ), 'Status' => Array('title' => 'la_col_Status', 'filter_block' => 'grid_options_filter', 'width' => 70, ), 'Hits' => Array ('title' => 'la_col_Hits', 'filter_block' => 'grid_range_filter', 'width' => 60, ), 'CachedRating' => Array ('title' => 'la_col_Rating', 'filter_block' => 'grid_range_filter', 'width' => 70, ), 'CachedVotesQty' => Array ('title' => 'la_col_VoteCount', 'filter_block' => 'grid_range_filter', 'width' => 70, ), 'CachedReviewsQty' => Array ('title' => 'la_col_ReviewCount', 'filter_block' => 'grid_range_filter', 'width' => 85, ), ), ), 'Radio' => Array ( 'Icons' => Array ( 0 => 'icon16_link_disabled.png', 1 => 'icon16_link.png', 2 => 'icon16_link_pending.png', 'NEW' => 'icon16_link_new.png', ), 'Selector' => 'radio', 'Fields' => Array ( 'LinkId' => Array ('title'=>'la_col_Id', 'data_block' => 'grid_radio_td', 'filter_block' => 'grid_range_filter', 'width' => 70, ), 'Name' => Array ('title'=>'la_col_LinkName', 'data_block' => 'grid_catitem_td', 'width' => 200, ), 'Url' => Array ('title' => 'la_col_LinkUrl', 'width' => 200, ), 'Description' => Array ('title' => 'la_col_Description', 'first_chars' => 100, 'width' => 100, ), 'CreatedOn' => Array ('title' => 'la_col_CreatedOn', 'filter_block' => 'grid_date_range_filter', 'width' => 145, ), 'Modified' => Array ('title' => 'la_col_Modified', 'filter_block' => 'grid_date_range_filter', 'width' => 145, ), 'Status' => Array('title' => 'la_col_Status', 'filter_block' => 'grid_options_filter', 'width' => 70, ), 'Hits' => Array ('title' => 'la_col_Hits', 'filter_block' => 'grid_range_filter', 'width' => 60, ), 'CachedRating' => Array ('title' => 'la_col_Rating', 'filter_block' => 'grid_range_filter', 'width' => 70, ), 'CachedVotesQty' => Array ('title' => 'la_col_VoteCount', 'filter_block' => 'grid_range_filter', 'width' => 70, ), 'CachedReviewsQty' => Array ('title' => 'la_col_ReviewCount', 'filter_block' => 'grid_range_filter', 'width' => 85, ), ), ), 'Duplicates' => Array ( 'Icons' => Array ( 0 => 'icon16_link_disabled.png', 1 => 'icon16_link.png', 2 => 'icon16_link_pending.png', 'NEW' => 'icon16_link_new.png', ), 'Fields' => Array ( 'Name' => Array ('title' => 'la_col_LinkName', 'filter_block' => 'grid_like_filter', 'width' => 250, ), 'Url' => Array ('title' => 'la_col_LinkUrl', 'filter_block' => 'grid_like_filter', 'width' => 300, ), 'DupeCount' => Array ('title' => 'la_col_DupeCount', 'filter_block' => 'grid_range_filter', 'width' => 100, ), ), ), ), 'ConfigMapping' => Array( 'PerPage' => 'Perpage_Links', 'ShortListPerPage' => 'Perpage_Links_Short', 'ForceEditorPick' => 'Link_ShowPick', 'DefaultSorting1Field' => 'Link_SortField', 'DefaultSorting2Field' => 'Link_SortField2', 'DefaultSorting1Dir' => 'Link_SortOrder', 'DefaultSorting2Dir' => 'Link_SortOrder2', 'RatingDelayValue' => 'link_RatingDelay_Value', 'RatingDelayInterval' => 'link_RatingDelay_Interval', ), ); \ No newline at end of file Index: branches/5.0.x/in-link/units/links/link_tag_processor.php =================================================================== --- branches/5.0.x/in-link/units/links/link_tag_processor.php (revision 12737) +++ branches/5.0.x/in-link/units/links/link_tag_processor.php (revision 12738) @@ -1,459 +1,459 @@ <?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.net/license/ for copyright notices and details. +* See http://www.in-portal.org/license for copyright notices and details. */ defined('FULL_PATH') or die('restricted access!'); class LinkTagProcessor extends kCatDBTagProcessor { /** * Returns object used in tag processor * * @access public * @return kDBBase */ /*function &getObject($params = Array()) { $object =& parent::getObject($params); // Forces item loading (compatibility with old theme) if (is_subclass_of($object, 'kDBItem')) { // force reload when using from old code $id = $this->Application->GetVar($this->Prefix.'_id'); if ($object->isLoaded() && $id && ($object->GetID() != $id)) { $object->Load($id); } } return $object; }*/ function getListingInfo($resource_id, $field = null) { $sql = 'SELECT * FROM '.$this->Application->getUnitOption('ls', 'TableName').' WHERE ItemResourceId = '.$resource_id; $listing_info = $this->Conn->GetRow($sql); return isset($field) ? $listing_info[$field] : $listing_info; } /** * Detects listing enhancement status (enhanced or not) * * @param Array $params * @return int */ function LinkIsEnhanced($params) { $object =& $this->getObject(); /* @var $object kDBItem */ if ($object->GetDBField('Status') == STATUS_PENDING || $object->GetDBField('Status') == STATUS_PENDING_EDITING) { return false; } $listing_type_id = $this->getListingInfo($object->GetDBField('ResourceId'), 'ListingTypeId'); $this->Application->SetVar('lst_id', $listing_type_id); // compatibility with old-theme return $listing_type_id ? 1 : 0; } /** * Detects if enhancement is pending approval * * @param Array $params * @return int */ function EnhancementIsPending($params) { $object =& $this->getObject(); /* @var $object kDBItem */ $status = $this->getListingInfo($object->GetDBField('ResourceId'), 'Status'); return $status == STATUS_PENDING ? 1 : 0; } function ListingTypeField($params) { $object =& $this->getObject(); /* @var $object kDBItem */ $lst_id = $this->getListingInfo($object->GetDBField('ResourceId'), 'ListingTypeId'); $lst_object =& $this->Application->recallObject('lst', null, Array('skip_autoload' => true)); $lst_object->Load($lst_id); return $lst_object->GetField( $this->SelectParam($params, 'name,field') ); } function EnhancementField($params) { $object =& $this->getObject(); /* @var $object kDBItem */ $listing_id = $this->getListingInfo($object->GetDBField('ResourceId'), 'ListingId'); $listing_object =& $this->Application->recallObject('ls', null, Array('skip_autoload' => true)); $listing_object->Load($listing_id); return $listing_object->GetField( $this->SelectParam($params, 'name,field') ); } function IsRenewalPeriod($params) { $object =& $this->getObject(); /* @var $object kDBItem */ $listing_info = $this->getListingInfo($object->GetDBField('ResourceId')); $sql = 'SELECT RenewalReminder FROM '.$this->Application->getUnitOption('lst', 'TableName').' WHERE ListingTypeId = '.$listing_info['ListingTypeId']; $renewal_interval = $this->Conn->GetOne($sql) * 3600 * 24; return ($listing_info['ExpiresOn'] - adodb_mktime() < $renewal_interval) ? 1 : 0; } function FirstListingType($params) { static $first = true; if ($first) { $first = false; return true; } else { return false; } } function IsReocurringEnhancement($params) { $params['name'] = 'Recurring'; return $this->ListingTypeField($params); } function EnhanceUsingInCommerce($params) { if (!$this->Application->isModuleEnabled('In-Commerce')) { return 0; } $object =& $this->getObject(); /* @var $object kDBItem */ $listtype_id = $this->getListingInfo($object->GetDBField('ResourceId'), 'ListingTypeId'); $lst_object =& $this->Application->recallObject('lst', null, Array('skip_autoload' => true)); $lst_object->Load($listtype_id); return $lst_object->GetDBField('EnableBuying'); } function ClickLink($params) { $object =& $this->getObject($params); return $this->Application->HREF($params['t'], '', Array('l_id' => $object->GetID(), 'pass'=>'all,l' )); } function ListRelatedLinks($params) { return $this->PrintList2($params); } function LinkLink($params) { return $this->ItemLink($params, 'link'); } function ListingDescription($params) { $listing_type =& $this->Application->recallObject('lst'); /* @var $listing_type kDBItem */ return $listing_type->GetDBField('Description'); } function ListingTypeDetailsLink($params) { $listing_type =& $this->Application->recallObject('lst', null, Array ('raise_warnings' => 0)); /* @var $listing_type kDBList */ $params['lst_id'] = $listing_type->isLoaded() ? $listing_type->GetID() : $this->Application->Parser->GetParam('key'); return $this->Application->ProcessParsedTag('m', 'Link', $params); } /** * Register hit & go to link url * * @param Array $params */ function FollowLocation($params) { $object =& $this->getObject(); /* @var $object kCatDBItem */ if (!$object->isLoaded()) { trigger_error('No Link ID for redirect', E_USER_ERROR); } $object->RegisterHit(); // save user and time if (!$this->Application->isAdmin && $this->Application->LoggedIn()) { $resource_id = $object->GetDBField('ResourceId'); $user_id = $this->Application->RecallVar('user_id'); $link_visit = $this->Application->recallObject('l-visit', null, Array ('skip_autoload' => true)); /* @var $link_visit kDBItem */ $link_visit->Load( Array ('ResourceId' => $resource_id, 'PortalUserId' => $user_id) ); if ($link_visit->isLoaded()) { // for existing visits update date $link_visit->SetDBField('VisitTimestamp_date', adodb_mktime()); $link_visit->SetDBField('VisitTimestamp_time', adodb_mktime()); } else { // for new visits set user & link, visit will be set as default value $link_visit->SetDBField('ResourceId', $resource_id); $link_visit->SetDBField('PortalUserId', $user_id); } $status = $link_visit->isLoaded() ? $link_visit->Update() : $link_visit->Create(); } $url = $object->GetDBField('Url'); if (!preg_match('/^(http|ftp|mailto:)(.*)/U', $url)) { $url = 'http://'.$url; } $this->Application->Redirect('external:'.$url); } /** * Returns formatted address (from custom fields) for using with google * * @param Array $params * @return string */ function GetGoogleAddress($params) { $object =& $this->getObject(); if (isset($params['display_info']) && $params['display_info']) { $ret = $object->GetField('cust_LinkAddress') ? $object->GetField('cust_LinkAddress').'<BR/>' : ''; $ret .= $object->GetField('cust_LinkCity') ? $object->GetField('cust_LinkCity').',' : ''; $ret .= $object->GetField('cust_LinkState') ? $object->GetField('cust_LinkState') : ''; $ret .= $object->GetField('cust_LinkZipCode') ? $object->GetField('cust_LinkZipCode').'<BR/>' : ''; $ret .= $object->GetField('cust_LinkCountry') ? $object->GetField('cust_LinkCountry').'<BR/>' : ''; $ret .= $object->GetField('cust_LinkPhone') ? '<b>'.$this->Application->Phrase('lu_fld_LinkPhone').':</b> '.$object->GetField('cust_LinkPhone') : ''; return $ret; } $ret = $object->GetField('cust_LinkAddress') ? $object->GetField('cust_LinkAddress').',' : ''; $ret .= $object->GetField('cust_LinkCity') ? $object->GetField('cust_LinkCity').',' : ''; $ret .= $object->GetField('cust_LinkState') ? $object->GetField('cust_LinkState').',' : ''; $ret .= $object->GetField('cust_LinkZipCode') ? $object->GetField('cust_LinkZipCode').',' : ''; $ret .= $object->GetField('cust_LinkCountry') ? $object->GetField('cust_LinkCountry') : ''; return $ret; } /** * Returns timestamp of last link visit for logged in users only. * * @param Array $params * @return string */ function LastVisited($params) { if (!$this->Application->LoggedIn()) { // we don't gather link visit statistics for Guests return ''; } static $link_visited = Array (); $object =& $this->getObject(); /* @var $object kDBList */ if (!isset($link_visited[$this->Special])) { $resource_ids = $object->GetCol('ResourceId'); $user_id = $this->Application->RecallVar('user_id'); $table_name = $this->Application->getUnitOption('l-visit', 'TableName'); $sql = 'SELECT VisitTimestamp, ResourceId FROM '.$table_name.' WHERE (PortalUserId = '.$user_id.') AND (ResourceId IN ('.implode(',', $resource_ids).'))'; $link_visited[$this->Special] = $this->Conn->GetCol($sql, 'ResourceId'); } if (!isset($link_visited[$this->Special][$object->GetDBField('ResourceId')])) { // link has no visit information for current user return ''; } $link_visit = $link_visited[$this->Special][$object->GetDBField('ResourceId')]; if (isset($params['formatted']) && $params['formatted']) { // format the date $lang =& $this->Application->recallObject('lang.current'); if (isset($params['display_time']) && $params['display_time']) { $display_format = $lang->GetDBField('DateFormat').' @ '.$lang->GetDBField('TimeFormat'); } else { $display_format = $lang->GetDBField('DateFormat'); } return adodb_date($display_format, $link_visit); } return $link_visit; } /** * Checks if specified Custom Fields and condition are true * * @param Array $params * @return string */ function HasValue($params) { $condition = isset($params['condition']) ? strtolower($params['condition']) : false; $fields = isset($params['fields']) ? $params['fields'] : false; if (!$fields || !in_array($condition, Array('or', 'and'))) { // required parameters not passed return false; } $fields = explode(',', $fields); $object =& $this->getObject(); /* @var $object kDBList */ switch ($condition) { case 'or': foreach ($fields as $field) { if (strlen($object->GetDBField($field))) { return true; } } break; case 'and': foreach ($fields as $field) { if (!strlen($object->GetDBField($field))) { return false; } } break; } return $condition == 'and' ? true : false; } /** * Gets and parses custom details template or default one * * @param Array $params * @return string */ function DisplayDetailTemplate($params) { $object =& $this->getObject($params); /* @var $object kDBItem */ $template_name = $object->GetDBField('CustomTemplate'); if (!$template_name || !$this->Application->TemplatesCache->TemplateExists($template_name)) { $template_name = $params['default_template']; } $block_params['name'] = $template_name; // parse template return $this->Application->ParseBlock($block_params); } /** * Changes title preset of "Duplicate checker" section to show current grouping * * @param Array $params */ function ModifyUnitConfig($params) { $grid = array_key_exists('grid', $params) ? $params['grid'] : false; if ($grid != 'Duplicates') { // only for "Duplicate Checker" section return ; } $link_helper =& $this->Application->recallObject('LinkHelper'); /* @var $link_helper LinkHelper */ // 1. get current grouping $grouping = $link_helper->getGrouping( $this->getPrefixSpecial() ); // 2. replace field names in grouping with their corresponding column titles $grids = $this->Application->getUnitOption($this->Prefix, 'Grids'); foreach ($grouping as $index => $group_field) { $group_field = preg_replace('/^l[\d]+_/', '', $group_field); // remove ml prefix $grouping[$index] = $this->Application->Phrase($grids[$grid]['Fields'][$group_field]['title']); } // 3. patch resulting title preset $concat_with = "' " . $this->Application->Phrase('la_and') . " '"; $title_presets = $this->Application->getUnitOption($this->Prefix, 'TitlePresets'); $title_presets['duplicate_links'] = str_replace('%s', "'" . implode($concat_with, $grouping) . "'", $title_presets['duplicate_links']); $this->Application->setUnitOption($this->Prefix, 'TitlePresets', $title_presets); } /** * Allows to modify block params & current list record before PrintList parses record * * @param kDBList $object * @param Array $block_params */ function PrepareListElementParams(&$object, &$block_params) { $grid = array_key_exists('grid', $block_params) ? $block_params['grid'] : false; if ($grid != 'Duplicates') { // only for "Duplicate Checker" section return ; } static $grouping = null; if (!isset($grouping)) { $link_helper =& $this->Application->recallObject('LinkHelper'); /* @var $link_helper LinkHelper */ // 1. get current grouping $grouping = $link_helper->getGrouping( $this->getPrefixSpecial() ); } $fields_hash =& $object->getCurrentRecord(); $key_fields = Array (); foreach ($grouping as $group_field) { $key_fields[$group_field] = $fields_hash[$group_field]; } $fields_hash['LinkId'] = base64_encode( serialize($key_fields) ); } } \ No newline at end of file Index: branches/5.0.x/in-link/units/helpers/link_helper.php =================================================================== --- branches/5.0.x/in-link/units/helpers/link_helper.php (revision 12737) +++ branches/5.0.x/in-link/units/helpers/link_helper.php (revision 12738) @@ -1,77 +1,77 @@ <?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.net/license/ for copyright notices and details. +* See http://www.in-portal.org/license for copyright notices and details. */ defined('FULL_PATH') or die('restricted access!'); class LinkHelper extends kHelper { /** * Checks, that we have link to our website on given site url * * @param string $url * @return bool */ function CheckReciprocalURL($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 10); $html = curl_exec($ch); if (curl_errno($ch) != 0) { // connection error return false; } $info = curl_getinfo($ch); if ($info['http_code'] != 200) { // http error return false; } curl_close($ch); $reciprocal_url = rtrim($this->Application->BaseURL()); if (preg_match('/<a[^<]*href=(["\']?)' . preg_quote($reciprocal_url, '/') . '[\\/]?.*(\\1).*>(.*)<\\/a.*>/sUi', $html, $ret)) { return true; } return false; } /** * Returns grouping fields for "Duplicate Checker" section * * @param string $prefix_special * @return Array */ function getGrouping($prefix_special) { // cut "sub" postfix from special $prefix_special = preg_replace('/(.*)-sub$/', '\\1', $prefix_special); $grouping = $this->Application->RecallVar($prefix_special . '_dupe_fields'); if (!$grouping) { $grouping = '|Url|'; $this->Application->StoreVar($prefix_special . '_dupe_fields', $grouping); } return explode('|', substr($grouping, 1, -1)); } } \ No newline at end of file Index: branches/5.0.x/in-link/units/helpers/helpers_config.php =================================================================== --- branches/5.0.x/in-link/units/helpers/helpers_config.php (revision 12737) +++ branches/5.0.x/in-link/units/helpers/helpers_config.php (revision 12738) @@ -1,24 +1,24 @@ <?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.net/license/ for copyright notices and details. +* See http://www.in-portal.org/license for copyright notices and details. */ defined('FULL_PATH') or die('restricted access!'); $config = Array ( 'Prefix' => 'in-link-helpers', 'EventHandlerClass' => Array ('class' => 'kEventHandler', 'file' => '', 'build_event' => 'OnBuild'), 'RegisterClasses' => Array ( Array ('pseudo' => 'LinkHelper', 'class' => 'LinkHelper', 'file' => 'link_helper.php', 'build_event' => '', 'require_classes' => 'kHelper'), ), ); \ No newline at end of file Index: branches/5.0.x/in-link/units/link_validation/link_validation_tp.php =================================================================== --- branches/5.0.x/in-link/units/link_validation/link_validation_tp.php (revision 12737) +++ branches/5.0.x/in-link/units/link_validation/link_validation_tp.php (revision 12738) @@ -1,58 +1,58 @@ <?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.net/license/ for copyright notices and details. +* See http://www.in-portal.org/license for copyright notices and details. */ defined('FULL_PATH') or die('restricted access!'); class LinkValidationTagProcessor extends kDBTagProcessor { function FormatUrl($params) { $object =& $this->getObject($params); $url = $object->GetDBField($params['field']); if (!preg_match('/^(http|ftp|mailto:)(.*)/U', $url)) { $url = 'http://' . $url; } return $url; } /** * Show CachedNavbar of current item primary category * * @param Array $params * @return string */ function CategoryName($params) { // show category cachednavbar of $object =& $this->getObject($params); $category_id = isset($params['cat_id']) ? $params['cat_id'] : $object->GetDBField('CategoryId'); $category_path = $this->Application->getCache('category_paths', $category_id); if ($category_path === false) { // not chached if ($category_id > 0) { $cached_navbar = preg_replace('/^(Content&\|&|Content)/i', '', $object->GetDBField('CachedNavbar')); $category_path = trim($this->CategoryName( Array('cat_id' => 0) ).' > '.str_replace('&|&', ' > ', $cached_navbar), ' > '); } else { $category_path = $this->Application->Phrase( $this->Application->ConfigValue('Root_Name') ); } $this->Application->setCache('category_paths', $category_id, $category_path); } return $category_path; } } \ No newline at end of file Index: branches/5.0.x/in-link/units/link_validation/link_validation_config.php =================================================================== --- branches/5.0.x/in-link/units/link_validation/link_validation_config.php (revision 12737) +++ branches/5.0.x/in-link/units/link_validation/link_validation_config.php (revision 12738) @@ -1,182 +1,182 @@ <?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.net/license/ for copyright notices and details. +* 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 => 'event', 4 => 'mode', ), 'RegularEvents' => 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, ), ), 'FilterMenu' => Array ( 'Groups' => Array( Array('mode' => 'AND', 'filters' => Array('show_valid', 'show_invalid', 'show_not_validated'), 'type' => WHERE_FILTER), ), 'Filters' => Array ( 'show_valid' => Array ('label' =>'la_Text_Valid', 'on_sql' => '', 'off_sql' => '%1$s.ValidationStatus != ' . LINK_VALIDATION_VALID . ' OR %1$s.ValidationStatus IS NULL'), 'show_invalid' => Array ('label' => 'la_Text_Invalid', 'on_sql' => '', 'off_sql' => '%1$s.ValidationStatus != ' . LINK_VALIDATION_INVALID . ' OR %1$s.ValidationStatus IS NULL'), 'show_not_validated' => Array ('label' => 'la_Text_Not_Validated', 'on_sql' => '', 'off_sql' => '%1$s.ValidationStatus != ' . LINK_VALIDATION_NOT_VALIDATED . ' OR %1$s.ValidationStatus IS NOT NULL'), ) ), '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 => 'la_Text_Not_Validated', 1 => 'la_Text_Valid', 2 => 'la_Text_Invalid'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 0 ), ), 'VirtualFields' => Array ( 'ForeignLinkId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0), 'LinkName' => Array('type' => 'string', /*'formatter' => 'kMultiLanguage',*/ 'not_null' => 1, 'max_len' => 255, 'default' => ''), 'LinkUrl' => Array ('type' => 'string', 'not_null' => 1, '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, 'not_null' => 1, 'default' => 2), 'LinkValidationStatus' => Array ( 'type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (0 => 'la_Text_Not_Validated', 1 => 'la_Text_Valid', 2 => 'la_Text_Invalid'), 'use_phrases' => 1, 'not_null' => 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' => 'la_col_Id', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter', 'module' => 'In-Link', 'width' => 60, ), 'LinkName' => Array ('title' => 'la_col_LinkName', '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' => 'la_col_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' => 'la_col_CreatedOn', 'filter_block' => 'grid_date_range_filter', 'width' => 140, ), ), ), ), ); \ No newline at end of file Index: branches/5.0.x/in-link/units/link_validation/link_validation_eh.php =================================================================== --- branches/5.0.x/in-link/units/link_validation/link_validation_eh.php (revision 12737) +++ branches/5.0.x/in-link/units/link_validation/link_validation_eh.php (revision 12738) @@ -1,544 +1,544 @@ <?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.net/license/ for copyright notices and details. +* 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 standart 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 permissions of user * * @param kEvent $event */ 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 = erPERM_FAIL; } } return $perm_value; } return parent::CheckPermission($event); } /** * Adds calculates fields for category name * * @param kDBItem $object * @param kEvent $event */ 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 */ 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 = 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 */ function iterateItems(&$event) { if ($this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1)) { 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) { $object->Load($id); switch ($event->Name) { case 'OnApproveLinks': $ret = $object->ApproveChanges(); break; case 'OnDeclineLinks': $ret = $object->DeclineChanges(); break; } if (!$ret) { $event->status = erFAIL; $event->redirect = false; break; } } } /** * Deletes selected links * * @param kEvent $event */ function OnDeleteLinks(&$event) { if ($this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1)) { 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 * * @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 calcualated fields to go to multilingual link fields * * @param kEvent $event */ function OnAfterConfigRead(&$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.0.x/in-link/units/l-visits/l-visits_config.php =================================================================== --- branches/5.0.x/in-link/units/l-visits/l-visits_config.php (revision 12737) +++ branches/5.0.x/in-link/units/l-visits/l-visits_config.php (revision 12738) @@ -1,85 +1,85 @@ <?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.net/license/ for copyright notices and details. +* See http://www.in-portal.org/license for copyright notices and details. */ defined('FULL_PATH') or die('restricted access!'); $config = Array ( 'Prefix' => 'l-visit', 'ItemClass' => Array('class' => 'kDBItem', 'file' => '', 'build_event' => 'OnItemBuild'), 'EventHandlerClass' => Array('class' => 'LinkVisitEventHandler', 'file' => 'l-visit_eh.php', 'build_event' => 'OnBuild'), 'AutoLoad' => true, 'Hooks' => Array ( Array ( 'Mode' => hAFTER, 'Conditional' => false, 'HookToPrefix' => 'u', 'HookToSpecial' => '-item', // from OnMassDelete event 'HookToEvent' => Array('OnAfterItemDelete'), 'DoPrefix' => '', 'DoSpecial' => '*', 'DoEvent' => 'OnDeleteVisits', ), Array ( 'Mode' => hAFTER, 'Conditional' => false, 'HookToPrefix' => 'l', 'HookToSpecial' => '-item', // from "Catalog" 'HookToEvent' => Array('OnAfterItemDelete'), 'DoPrefix' => '', 'DoSpecial' => '*', 'DoEvent' => 'OnDeleteVisits', ), Array ( 'Mode' => hAFTER, 'Conditional' => false, 'HookToPrefix' => 'l', 'HookToSpecial' => 'showall-item', // from "Advanced View" 'HookToEvent' => Array('OnAfterItemDelete'), 'DoPrefix' => '', 'DoSpecial' => '*', 'DoEvent' => 'OnDeleteVisits', ), ), 'QueryString' => Array ( 1 => 'id', 2 => 'page', 3 => 'event', ), 'IDField' => 'VisitId', 'TableName' => TABLE_PREFIX.'LinkVisits', 'AutoDelete' => true, 'ListSQLs' => Array ('' => 'SELECT * FROM %s'), 'ItemSQLs' => Array ('' => 'SELECT * FROM %s'), 'ListSortings' => Array ( '' => Array( 'Sorting' => Array('VisitTimestamp' => 'desc'), ) ), 'Fields' => Array ( 'VisitId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0), 'ResourceId' => Array ('type' => 'int', 'default' => NULL), 'PortalUserId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0), 'VisitTimestamp' => Array ('type' => 'int', 'formatter' => 'kDateFormatter', 'default' => '#NOW#'), ), ); \ No newline at end of file Index: branches/5.0.x/in-link/units/l-visits/l-visit_eh.php =================================================================== --- branches/5.0.x/in-link/units/l-visits/l-visit_eh.php (revision 12737) +++ branches/5.0.x/in-link/units/l-visits/l-visit_eh.php (revision 12738) @@ -1,35 +1,35 @@ <?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.net/license/ for copyright notices and details. +* See http://www.in-portal.org/license for copyright notices and details. */ defined('FULL_PATH') or die('restricted access!'); class LinkVisitEventHandler extends kDBEventHandler { /** * Deletes visits when user/link got deleted * * @param kEvent $event */ function OnDeleteVisits(&$event) { $key_field = $event->MasterEvent->Prefix == 'u' ? 'PortalUserId' : 'ResourceId'; $table_name = $this->Application->getUnitOption($this->Prefix, 'TableName'); $object =& $event->MasterEvent->getObject(); $sql = 'DELETE FROM '.$table_name.' WHERE '.$key_field.' = '.$object->GetDBField($key_field); $this->Conn->Query($sql); } } \ No newline at end of file Index: branches/5.0.x/in-link/units/listings/listings_event_handler.php =================================================================== --- branches/5.0.x/in-link/units/listings/listings_event_handler.php (revision 12737) +++ branches/5.0.x/in-link/units/listings/listings_event_handler.php (revision 12738) @@ -1,770 +1,770 @@ <?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.net/license/ for copyright notices and details. +* See http://www.in-portal.org/license for copyright notices and details. */ defined('FULL_PATH') or die('restricted access!'); class ListingsEventHandler extends kDBEventHandler { /** * Allows to override standart permission mapping * */ function mapPermissions() { parent::mapPermissions(); $permissions = Array( // front 'OnRequestEnhancement' => Array ('self' => true), 'OnCancelEnhancement' => Array ('self' => true), 'OnExtendEnhancement' => Array ('self' => true), ); $this->permMapping = array_merge($this->permMapping, $permissions); } /** * Adds selected link to listing * * @param kEvent $event */ function OnProcessSelected(&$event) { $object =& $event->getObject(); $selected_ids = $this->Application->GetVar('selected_ids'); if ($selected_ids['l']) { $link_id = $selected_ids['l']; $sql = 'SELECT ResourceId FROM '.$this->Application->getUnitOption('l', 'TableName').' WHERE '.$this->Application->getUnitOption('l', 'IDField').' = '.$link_id; $object->SetDBField($this->Application->RecallVar('dst_field'), $this->Conn->GetOne($sql)); $object->IgnoreValidation = true; // $this->RemoveRequiredFields($object); $object->Update(); } $this->finalizePopup($event); } function OnPreSaveListing(&$event) { $event->redirect=false; $object =& $event->getObject( Array('skip_autoload' => true) ); $object->IgnoreValidation = true; // $this->RemoveRequiredFields($object); $event->CallSubEvent('OnPreSave'); $this->Application->SetVar($event->getPrefixSpecial(true).'_id', $object->GetId()); return; } function OnBeforeItemUpdate(&$event) { $object =& $event->getObject(); if ($object->IgnoreValidation) { $object->UpdateFormattersMasterFields(); } } function OnBeforeItemCreate(&$event) { $object =& $event->getObject(); if ($object->IgnoreValidation) { $object->UpdateFormattersMasterFields(); } } /** * Enter description here... * * @param kEvent $event */ function OnBeforeDeleteFromLive(&$event) { $object =& $event->getObject(); $sql = 'SELECT * FROM '.$this->Application->getUnitOption($event->Prefix, 'TableName').' WHERE ListingId = '.$object->GetId(); $original_values = $this->Conn->GetRow($sql); $type_modified = ($object->GetDBField('ListingTypeId') != $original_values['ListingTypeId']); $link_modified = ($object->GetDBField('ItemResourceId') != $original_values['ItemResourceId']); $status_modified = ($object->GetDBField('Status') != $original_values['Status']); if ($status_modified) { $email_event = $object->GetDBField('Status') ? 'LINK.ENHANCE.APPROVE' : 'LINK.ENHANCE.DENY'; $sql = 'SELECT CreatedById FROM '.$this->Application->getUnitOption('l', 'TableName').' WHERE ResourceId = '.$object->GetDBField('ItemResourceId'); $email_event_user =& $this->Application->EmailEventUser($email_event, $this->Conn->GetOne($sql)); $email_event_admin =& $this->Application->EmailEventAdmin($email_event); } if ( $type_modified || $link_modified ) { $this->ResetLink($original_values); } if ( $status_modified || $type_modified || $link_modified ) { $this->EnhanceLink($object, $original_values); } if ( $status_modified && !($type_modified || $link_modified) ) { $this->ResetLink($original_values); } } function EnhanceLink(&$object, $original_values) { if ($object->GetDBField('Status') != STATUS_ACTIVE) { return false; } if ($object->GetDBField('ExpiresOn') < adodb_mktime()) { $object->SetDBField('Status', STATUS_PENDING); $object->Update(); $this->ResetLink($original_values); return false; } $this->UpdateLink('OnPurchase', $object->GetDBField('ItemResourceId'), $object->GetDBField('ListingTypeId')); $listtype_object =& $this->Application->recallObject('lst'); if ( $listtype_object->GetDBField('OnPurchaseAddToCatEnabled') ) { $link_object =& $this->Application->recallObject('l'); $add_to_cat = (int)$listtype_object->GetDBField('OnPurchaseAddToCat'); $sql = 'DELETE FROM '.$this->Application->getUnitOption('l-ci', 'TableName').' WHERE CategoryId = '.$add_to_cat.' AND ItemResourceId = '.$link_object->GetDBField('ResourceId').' AND PrimaryCat = 0'; $this->Conn->Query($sql); $sql = 'INSERT INTO '.$this->Application->getUnitOption('l-ci', 'TableName').' (CategoryId, ItemResourceId, PrimaryCat) VALUES ('.$add_to_cat.', '.$link_object->GetDBField('ResourceId').', 0)'; $this->Conn->Query($sql); } } function ResetLink($original_values) { static $has_been_reset = Array(); if( $original_values['Status'] != STATUS_ACTIVE || getArrayValue($has_been_reset, $original_values['ListingId']) ) { return; } $has_been_reset[$original_values['ListingId']] = 1; $this->UpdateLink('OnExpire', $original_values['ItemResourceId'], $original_values['ListingTypeId']); $listtype_object =& $this->Application->recallObject('lst'); if( $listtype_object->GetDBField('OnExpireRemoveFromCatEnabled') ) { $remove_from_cat = $listtype_object->GetDBField('OnExpireRemoveFromCat'); $sql = 'DELETE FROM '.$this->Application->getUnitOption('l-ci', 'TableName').' WHERE ItemResourceId = '.$original_values['ItemResourceId'].' AND CategoryId = '.$remove_from_cat.' AND PrimaryCat = 0'; $this->Conn->Query($sql); } } function UpdateLink($action_prefix, $resource_id, $listtype_id) { $link_object =& $this->Application->recallObject('l', null, Array('skip_autoload' => true)); $link_object->Load($resource_id, 'ResourceId'); // "-item", because can be called as regular after event, and just "lst" recalls list instead $listtype_object =& $this->Application->recallObject('lst.-item', null, Array('skip_autoload' => true)); $listtype_object->Load($listtype_id); $action_fields = Array( 'EdPick' => 'EditorsPick', 'New' => 'NewItem', 'Hot' => 'HotItem', 'Pop' => 'PopItem', 'Status' => 'Status', 'CustomTemplate' => 'CustomTemplate', ); // $action_prefix = 'OnPurchase'; foreach($action_fields as $action => $field) { $action_value = $listtype_object->GetDBField($action_prefix.$action); if( $action_value != 3 ) { $link_object->SetDBField($field, $action_value); } } $priority_value = $listtype_object->GetDBField($action_prefix.'PriorityValue'); switch( $listtype_object->GetDBField($action_prefix.'PriorityAction') ) { case 1: // equal $link_object->SetDBField('Priority', $priority_value); break; case 2: // increase $original_priority = $link_object->GetDBField('Priority'); $link_object->SetDBField('Priority', $original_priority + $priority_value); break; case 3: // decrease $original_priority = $link_object->GetDBField('Priority'); $link_object->SetDBField('Priority', $original_priority - $priority_value); break; default: } $link_object->Update(); } /** * Enter description here... * * @param kEvent $event */ function OnRequestEnhancement(&$event) { if ($this->Application->isModuleEnabled('In-Commerce')) { $l_info = $this->Application->GetVar('l'); if (!$l_info) { return false; } list ($link_id, $link_info) = each($l_info); $listing_type_id = $link_info['ListingTypeId']; $listing_type =& $this->Application->recallObject('lst', null, Array('skip_autoload' => true)); $listing_type->Load($listing_type_id); if ($listing_type->GetDBField('EnableBuying')) { $add_to_cart_event = new kEvent('ord:OnAddVirtualProductToCart'); $this->Application->HandleEvent($add_to_cart_event); if ($add_to_cart_event->redirect) { $event->SetRedirectParam('pass', 'm'); $event->redirect = $add_to_cart_event->redirect; } return true; } } $event->CallSubEvent('OnListingCreate'); } /** * Create listing or extend existing listing period * * @param kEvent $event */ function OnListingCreate(&$event) { $object =& $event->getObject( Array('skip_autoload' => true) ); switch ($event->Name) { case 'EnhanceLinkAfterOrderApprove': case 'EnhancedLinkOnCompleteOrder': // when order with listing virtual product is approved $fields = $event->getEventParam('field_values'); $item_data = unserialize($fields['ItemData']); $listing_type_id = $item_data['ListingTypeId']; $link_id = $item_data['LinkId']; $new_processing = getArrayValue($item_data, 'HasNewProcessing'); break; case 'OnListingCreate': // when requesting enhancement from front (and not via in-commerce) $links_info = $this->Application->GetVar('l'); if (!$links_info) return false; $event->redirect = false; list($link_id, $link_info) = each($links_info); $listing_type_id = $link_info['ListingTypeId']; $new_processing = false; break; } if (!$listing_type_id) { // free or invalid listing type selected return false; } // get resource_id of link beeing enhanced $sql = 'SELECT ResourceId FROM '.$this->Application->getUnitOption('l', 'TableName').' WHERE LinkId = '.$link_id; $resource_id = $this->Conn->GetOne($sql); // get listing by link's resource_id $object->Load($resource_id, 'ItemResourceId'); if ($object->isLoaded()) { $original_values = $object->FieldValues; } else { // set initial fields to listing $object->SetDBField('ListingTypeId', $listing_type_id); $object->SetDBField('ItemResourceId', $resource_id); if ($event->Name == 'OnListingCreate' || $new_processing) { $item_status = STATUS_PENDING; } else { $item_status = STATUS_ACTIVE; } $object->SetDBField('Status', $item_status); } // set date of purchase for new listings $purchased_on = max(adodb_mktime(), $object->GetDBField('ExpiresOn')); if (!$object->isLoaded()) { $object->SetDBField('PurchasedOn_date', $purchased_on); $object->SetDBField('PurchasedOn_time', $purchased_on); } // set expiration time for listing $listing_type =& $this->Application->recallObject('lst', null, Array('skip_autoload' => true)); $listing_type->Load($listing_type_id); $dur_type_mapping = Array( 1 => 1, 2 => 60, 3 => 3600, 4 => 3600*24, 5 => 3600*24*7, 6 => 3600*24*365/12, 7 => 3600*24*365 ); $duration = $listing_type->GetDBField('Duration'); $duration_type = $listing_type->GetDBField('DurationType'); $expiration_interval = $duration * $dur_type_mapping[$duration_type]; $expiration_date = $purchased_on + $expiration_interval; $object->SetDBField('ExpiresOn_date', $expiration_date); $object->SetDBField('ExpiresOn_time', $expiration_date); // when extending enhancement mark listing as non-received renewal reminder $object->SetDBField('RenewalReminderSent', 0); $action = $object->isLoaded() ? 'Update' : 'Create'; if ($object->$action()) { $event->status = erSUCCESS; switch ($event->Name) { case 'EnhanceLinkAfterOrderApprove': case 'EnhancedLinkOnCompleteOrder': // when order with listing virtual product is approved if (getArrayValue($original_values, 'Status') != STATUS_ACTIVE) { $this->EnhanceLink($object, Array()); } break; case 'OnListingCreate': // when requesting enhancement from front (and not via in-commerce) $event->redirect = $this->Application->GetVar('success_template'); $sql = 'SELECT CreatedById FROM '.$this->Application->getUnitOption('l', 'TableName').' WHERE ResourceId = '.$object->GetDBField('ItemResourceId'); $email_event_user =& $this->Application->EmailEventUser('LINK.ENHANCE', $this->Conn->GetOne($sql)); $email_event_admin =& $this->Application->EmailEventAdmin('LINK.ENHANCE'); break; } } else { $event->status = erFAIL; } } /** * Enter description here... * * @param kEvent $event */ function EnhancedLinkOnCompleteOrder(&$event) { // create enhancement, but pending $this->OnListingCreate($event); // save created listing_id back to itemdata $object =& $event->getObject( Array('skip_autoload' => true) ); $fields = $event->getEventParam('field_values'); $item_data = unserialize($fields['ItemData']); unset($item_data['ListingTypeId']); $item_data['ListingId'] = $object->GetID(); $orditems_idfield = $this->Application->getUnitOption('orditems', 'IDField'); $orditems_table = $this->Application->getUnitOption('orditems', 'TableName'); $this->Conn->doUpdate( Array('ItemData' => serialize($item_data)), $orditems_table, $orditems_idfield.' = '.$fields['OrderItemId'] ); } /** * Enter description here... * * @param kEvent $event */ function EnhanceLinkAfterOrderApprove(&$event) { $object =& $event->getObject( Array('skip_autoload' => true) ); $fields = $event->getEventParam('field_values'); $item_data = unserialize($fields['ItemData']); if ( getArrayValue($item_data, 'HasNewProcessing') ) { // new processing: just approve created listing here $listing_id = $item_data['ListingId']; $object->Load($listing_id); // moved enhancement period to time admin approved enhancement $time_diff = adodb_mktime() - $object->GetDBField('PurchasedOn'); $object->SetDBField('PurchasedOn_date', $object->GetDBField('PurchasedOn_date') + $time_diff); $object->SetDBField('PurchasedOn_time', $object->GetDBField('PurchasedOn_time') + $time_diff); $object->SetDBField('ExpiresOn_date', $object->GetDBField('ExpiresOn_date') + $time_diff); $object->SetDBField('ExpiresOn_time', $object->GetDBField('ExpiresOn_time') + $time_diff); $object->SetDBField('Status', STATUS_ACTIVE); $object->Update(); $this->EnhanceLink($object, Array()); return true; } else { // create listing & approve it at the same time $this->OnListingCreate($event); } } /** * Delete listing * * @param kEvent $event */ function EnhanceLinkAfterOrderDeny(&$event) { $object =& $event->getObject( Array('skip_autoload' => true) ); $fields = $event->getEventParam('field_values'); $item_data = unserialize($fields['ItemData']); $listing_id = $item_data['ListingId']; $temp_handler =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler'); $temp_handler->DeleteItems($event->Prefix, $event->Special, Array($listing_id)); } /** * Enter description here... * * @param kEvent $event */ function ExpireLink(&$event) { $object =& $event->getObject( Array('skip_autoload' => true) ); $fields = $event->getEventParam('field_values'); $item_data = unserialize($fields['ItemData']); $sql = 'SELECT ListingId FROM '.$this->Application->getUnitOption($event->Prefix, 'TableName').' WHERE ItemResourceId = '.$item_data['LinkId']; $listing_id = $this->Conn->GetOne($sql); $object->Load($listing_id); $original_values = $object->FieldValues; $object->SetDBField('Status', 2); if($object->Update()) { $event->status = erSUCCESS; $this->ResetLink($original_values); } else { $event->status = erFAIL; } } function iterateItems(&$event) { $object =& $event->getObject( Array('skip_autoload' => true) ); $ids = $this->StoreSelectedIDs($event); if ($event->Name == 'OnMassApprove') { foreach ($ids as $id) { $object->Load($id); if ($object->GetDBField('Status') != STATUS_ACTIVE) { $original_values = $object->FieldValues; $object->SetDBField('Status', STATUS_ACTIVE); $this->EnhanceLink($object, $original_values); } } } if ($event->Name == 'OnMassDecline') { foreach ($ids as $id) { $object->Load($id); if ($object->GetDBField('Status') == STATUS_ACTIVE) { $original_values = $object->FieldValues; $this->ResetLink($original_values); $sql = 'SELECT CreatedById FROM '.$this->Application->getUnitOption('l', 'TableName').' WHERE ResourceId = '.$object->GetDBField('ItemResourceId'); $email_event_user =& $this->Application->EmailEventUser('LINK.ENHANCE.DENY', $this->Conn->GetOne($sql)); $email_event_admin =& $this->Application->EmailEventAdmin('LINK.ENHANCE.DENY'); } } } parent::iterateItems($event); // extend period for pending/renewal links (if owner has agreed) if ($event->Name == 'OnMassApprove') { $lst_object =& $this->Application->recallObject('lst', null, Array('skip_autoload' => true)); foreach ($ids as $id) { $object->Load($id); $sql = 'SELECT CreatedById FROM '.$this->Application->getUnitOption('l', 'TableName').' WHERE ResourceId = '.$object->GetDBField('ItemResourceId'); $owner_id = $this->Conn->GetOne($sql); if ($object->GetDBField('PendingRenewal') == 1) { $lst_object->Load( $object->GetDBField('ListingTypeId') ); $dur_type_mapping = Array( 1 => 1, 2 => 60, 3 => 3600, 4 => 3600*24, 5 => 3600*24*7, 6 => 3600*24*365/12, 7 => 3600*24*365 ); $duration = $lst_object->GetDBField('Duration'); $duration_type = $lst_object->GetDBField('DurationType'); $expiration_interval = $duration * $dur_type_mapping[$duration_type]; $renewal_begins = max( adodb_mktime(), $object->GetDBField('ExpiresOn') ); $expiration_date = $renewal_begins + $expiration_interval; $object->SetDBField('ExpiresOn_date', $expiration_date); $object->SetDBField('ExpiresOn_time', $expiration_date); $object->SetDBField('RenewalReminderSent', 0); $object->SetDBField('PendingRenewal', 0); if ($object->Update()) { $event->status = erSUCCESS; $event->redirect_params = Array('opener' => 's'); //stay! $email_event_user =& $this->Application->EmailEventUser('LINK.ENHANCE.RENEW', $owner_id); $email_event_admin =& $this->Application->EmailEventAdmin('LINK.ENHANCE.RENEW'); } else { $event->status=erFAIL; $event->redirect=false; break; } } else { $email_event_user =& $this->Application->EmailEventUser('LINK.ENHANCE.APPROVE', $owner_id); $email_event_admin =& $this->Application->EmailEventAdmin('LINK.ENHANCE.APPROVE'); } } } } /** * Redirects to cancel template on front-end * * @param kEvent $event */ function OnCancel(&$event) { parent::OnCancel($event); if (!$this->Application->isAdmin) { $event->SetRedirectParam('opener', 's'); $event->redirect = $this->Application->GetVar('cancel_template'); } } /** * Checks that user is owner of link & returns listing id if permissions are ok * * @param kEvent $event * @return mixed */ function verifyListingOwner(&$event) { $link_id = $this->Application->GetVar('l_id'); $user_id = $this->Application->RecallVar('user_id'); $sql = 'SELECT ResourceId FROM '.$this->Application->getUnitOption('l', 'TableName').' WHERE (LinkId = '.$link_id.') AND (CreatedById = '.$user_id.')'; $resource_id = $this->Conn->GetOne($sql); if (!$resource_id) { $event->status = erFAIL; return false; } $sql = 'SELECT ListingId FROM '.$this->Application->getUnitOption($event->Prefix, 'TableName').' WHERE ItemResourceId = '.$resource_id; return $this->Conn->GetOne($sql); } function OnExtendEnhancement(&$event) { $listing_id = $this->verifyListingOwner($event); if (!$listing_id) { return ; } $object =& $event->getObject( Array('skip_autoload' => true) ); $object->Load($listing_id); $object->SetDBField('PendingRenewal', 1); $object->Update(); $event->redirect = $this->Application->GetVar('success_template'); $sql = 'SELECT CreatedById FROM '.$this->Application->getUnitOption('l', 'TableName').' WHERE ResourceId = '.$object->GetDBField('ItemResourceId'); $email_event_user =& $this->Application->EmailEventUser('LINK.ENHANCE.EXTEND', $this->Conn->GetOne($sql)); $email_event_admin =& $this->Application->EmailEventAdmin('LINK.ENHANCE.EXTEND'); } function OnCancelEnhancement(&$event) { $listing_id = $this->verifyListingOwner($event); if (!$listing_id) { return ; } $object =& $event->getObject( Array('skip_autoload' => true) ); $object->Load($listing_id); $original_values = $object->FieldValues; $original_values['Status'] = 1; $this->ResetLink($original_values); $sql = 'SELECT CreatedById FROM '.$this->Application->getUnitOption('l', 'TableName').' WHERE ResourceId = '.$object->GetDBField('ItemResourceId'); $email_event_user =& $this->Application->EmailEventUser('LINK.ENHANCE.CANCEL', $this->Conn->GetOne($sql)); $email_event_admin =& $this->Application->EmailEventAdmin('LINK.ENHANCE.CANCEL'); $object->Delete(); $event->redirect = $this->Application->GetVar('success_template'); } function OnCheckExpiredPaidListings(&$event) { $sql = 'SELECT ListingId FROM '.$this->Application->getUnitOption($event->Prefix, 'TableName').' WHERE ExpiresOn < '.adodb_mktime().' AND Status = 1'; $expired_listings = $this->Conn->GetCol($sql); if(is_array($expired_listings) && count($expired_listings) > 0) { $object =& $this->Application->recallObject($event->Prefix.'.-item', null, Array('skip_autoload' => true)); foreach($expired_listings as $listing_id) { $object->Load($listing_id); $original_values = $object->FieldValues; $this->ResetLink($original_values); $object->SetDBField('Status', 2); $object->Update(); $sql = 'SELECT CreatedById FROM '.$this->Application->getUnitOption('l', 'TableName').' WHERE ResourceId = '.$object->GetDBField('ItemResourceId'); $email_event_user =& $this->Application->EmailEventUser('LINK.ENHANCE.EXPIRE', $this->Conn->GetOne($sql)); $email_event_admin =& $this->Application->EmailEventAdmin('LINK.ENHANCE.EXPIRE'); } } $sql = 'SELECT ls.ListingId, l.CreatedById FROM '.$this->Application->getUnitOption($event->Prefix, 'TableName').' ls LEFT JOIN '.$this->Application->getUnitOption('lst', 'TableName').' lst ON ls.ListingTypeId = lst.ListingTypeId LEFT JOIN '.$this->Application->getUnitOption('l', 'TableName').' l ON ls.ItemResourceId = l.ResourceId WHERE ls.Status = 1 AND ls.ExpiresOn < '.adodb_mktime().' + lst.RenewalReminder * 3600 *24 AND ls.RenewalReminderSent = 0'; $res = $this->Conn->Query($sql); if(is_array($res) && count($res) > 0) { $listing_ids = Array(); foreach($res as $record) { $email_event_user =& $this->Application->EmailEventUser('LINK.ENHANCE.RENEWAL.NOTICE', $record['CreatedById']); $email_event_admin =& $this->Application->EmailEventAdmin('LINK.ENHANCE.RENEWAL.NOTICE'); $listing_ids[] = $record['ListingId']; } $sql = 'UPDATE '.$this->Application->getUnitOption($event->Prefix, 'TableName').' SET RenewalReminderSent = 1 WHERE ListingId IN ('.implode(',', $listing_ids).')'; $this->Conn->Query($sql); } } function OnMassDelete(&$event) { $object =& $event->getObject( Array('skip_autoload' => true) ); $ids = $this->StoreSelectedIDs($event); foreach($ids as $id) { $object->Load($id); if($object->GetDBField('Status') == 1) { $original_values = $object->FieldValues; $this->ResetLink($original_values); } } parent::OnMassDelete($event); } /** * Moves enhancement from original link to it's pending copy, that is going to be approved * * @param kEvent $event */ function OnMoveEnhancement(&$event) { $id_field = $this->Application->getUnitOption($event->MasterEvent->Prefix, 'IDField'); $item_table_name = $this->Application->getUnitOption($event->MasterEvent->Prefix, 'TableName'); $pending_id = $event->MasterEvent->getEventParam('id'); $original_id = $event->MasterEvent->getEventParam('original_id'); $sql = 'SELECT ResourceId, '.$id_field.' FROM '.$item_table_name.' WHERE '.$id_field.' IN ('.$pending_id.','.$original_id.')'; $resource_ids = $this->Conn->GetCol($sql, $id_field); $table_name = $this->Application->getUnitOption($event->Prefix, 'TableName'); $sql = 'UPDATE '.$table_name.' SET ItemResourceId = '.$resource_ids[$pending_id].' WHERE ItemResourceId = '.$resource_ids[$original_id]; $this->Conn->Query($sql); } /** * Makes calcualated fields to go to multilingual link fields * * @param kEvent $event */ function OnAfterConfigRead(&$event) { parent::OnAfterConfigRead($event); $language_id = $this->Application->GetVar('m_lang'); $calculated_fields = $this->Application->getUnitOption($event->Prefix, 'CalculatedFields'); $calculated_fields['']['LinkName'] = 'CONCAT(item_table.l' . $language_id . '_Name, " (", item_table.Url, ")")'; $this->Application->setUnitOption($event->Prefix, 'CalculatedFields', $calculated_fields); } } \ No newline at end of file Index: branches/5.0.x/in-link/units/listings/listings_config.php =================================================================== --- branches/5.0.x/in-link/units/listings/listings_config.php (revision 12737) +++ branches/5.0.x/in-link/units/listings/listings_config.php (revision 12738) @@ -1,166 +1,166 @@ <?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.net/license/ for copyright notices and details. +* 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 => 'event', 4 => 'mode', ), 'RegularEvents' => 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.Login), IF (item_table.CreatedById = -1, "root", IF (item_table.CreatedById = -2, "Guest", "n/a")), u.Login)', ), ), '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'), 'error_field' => 'LinkName', 'default' => NULL), 'PurchasedOn' => Array('type' => 'int', 'formatter'=>'kDateFormatter','default'=>'#NOW#'), 'ExpiresOn' => Array('type' => 'int', 'formatter'=>'kDateFormatter','default' => '#NOW#','required'=>1), 'Status' => Array('type' => 'int', 'not_null' => 1, 'default' => 2, 'formatter'=>'kOptionsFormatter','options' => Array(1 => 'la_Active', 2 => 'la_Pending', 0 => 'la_Disabled'),'use_phrases' => 1), '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'), 'LinkOwner' => Array ('type' => 'string'), ), 'FilterMenu' => Array( 'Groups' => Array( Array('mode' => 'AND', 'filters' => Array(0,1,2), 'type' => WHERE_FILTER), Array('mode' => 'AND', 'filters' => Array(3), 'type' => WHERE_FILTER), ), 'Filters' => Array( 0 => Array('label' =>'la_Enabled', 'on_sql' => '', 'off_sql' => '%1$s.Status != 1' ), 1 => Array('label' => 'la_Disabled', 'on_sql' => '', 'off_sql' => '%1$s.Status != 0' ), 2 => Array('label' => 'la_Pending', 'on_sql' => '', 'off_sql' => '%1$s.Status != 2' ), 3 => Array('label' => 'la_PendingRenewal', 'on_sql' => '', 'off_sql' => '%1$s.PendingRenewal != 1' ), ) ), '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'=>'la_col_Id' , 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter', 'width' => 60, ), 'LinkName' => Array( 'title'=>'la_col_LinkName' , 'data_block' => 'link_td', 'filter_block' => 'grid_like_filter', 'width' => 170, ), 'ListingTypeId' => Array( 'title'=>'la_col_ListingTypeName' , 'data_block' => 'listing_type_td', 'filter_block' => 'grid_like_filter', 'width' => 100, ), 'LinkOwner' => Array( 'title'=>'la_col_LinkOwner', 'filter_block' => 'grid_like_filter', 'width' => 115, ), 'PendingRenewal' => Array( 'title'=>'la_col_PendingRenewal', 'filter_block' => 'grid_options_filter', 'width' => 143, ), 'PurchasedOn' => Array( 'title'=>'la_col_PurchasedOn', 'filter_block' => 'grid_date_range_filter', 'width' => 140, ), 'ExpiresOn' => Array( 'title'=>'la_col_ExpiresOn', 'filter_block' => 'grid_date_range_filter', 'width' => 140, ), ), ), ), ); \ No newline at end of file Index: branches/5.0.x/in-link/units/listings/listings_tag_processor.php =================================================================== --- branches/5.0.x/in-link/units/listings/listings_tag_processor.php (revision 12737) +++ branches/5.0.x/in-link/units/listings/listings_tag_processor.php (revision 12738) @@ -1,104 +1,104 @@ <?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.net/license/ for copyright notices and details. +* See http://www.in-portal.org/license for copyright notices and details. */ defined('FULL_PATH') or die('restricted access!'); class ListingsTagProcessor extends kDBTagProcessor { /** * Returns a link for editing product * * @param Array $params * @return string */ function ListingTypeLink($params) { $object =& $this->Application->recallObject($this->getPrefixSpecial(), $this->Prefix, $params); return $this->Application->HREF($params['edit_template'],'', Array( 'm_opener' => 'd', 'lst_mode' => 't', 'lst_event' => 'OnEdit', 'lst_id' => $object->GetDBField('ListingTypeId'), 'pass' => 'all,lst' ), 'index.php'); } function LinkEditLink($params) { $object =& $this->Application->recallObject( $this->getPrefixSpecial(), $this->Prefix, $params ); $sql = 'SELECT '.$this->Application->getUnitOption('l', 'IDField').' FROM '.$this->Application->getUnitOption('l', 'TableName').' WHERE ResourceId = '.$object->GetDBField('ItemResourceId'); return $this->Application->HREF($params['edit_template'],'', Array( 'm_opener' => 'd', 'l_mode' => 't', 'l_event' => 'OnEdit', 'l_id' => $this->Conn->GetOne($sql), 'pass' => 'all,l' )); } function ExpirationDate($params) { $object =& $this->Application->recallObject( $this->getPrefixSpecial(), $this->Prefix, $params ); $listing_type =& $this->Application->recallObject( 'lst', 'lst', $params ); $dur_type_mapping = Array( 1 => 1, 2 => 60, 3 => 3600, 4 => 3600*24, 5 => 3600*24*7, 6 => 3600*24*365/12, 7 => 3600*24*365 ); $duration = $listing_type->GetDBField('Duration'); $duration_type = $listing_type->GetDBField('DurationType'); $expiration_interval = $duration * $dur_type_mapping[$duration_type]; $expiration_date = adodb_mktime() + $expiration_interval; $lang =& $this->Application->recallObject('lang.current'); $format = $lang->GetDBField('DateFormat'); $expiration_date = adodb_date($format, $expiration_date); return $expiration_date; } function ExpirationTime($params) { $object =& $this->Application->recallObject( $this->getPrefixSpecial(), $this->Prefix, $params ); $listing_type =& $this->Application->recallObject( 'lst', 'lst', $params ); $dur_type_mapping = Array( 1 => 1, 2 => 60, 3 => 3600, 4 => 3600*24, 5 => 3600*24*7, 6 => 3600*24*365/12, 7 => 3600*24*365 ); $duration = $listing_type->GetDBField('Duration'); $duration_type = $listing_type->GetDBField('DurationType'); $expiration_interval = $duration * $dur_type_mapping[$duration_type]; $expiration_date = adodb_mktime() + $expiration_interval; $lang =& $this->Application->recallObject('lang.current'); $format = $lang->GetDBField('TimeFormat'); $expiration_date = adodb_date($format, $expiration_date); return $expiration_date; } } \ No newline at end of file Index: branches/5.0.x/in-link/units/listing_types/listing_types_event_handler.php =================================================================== --- branches/5.0.x/in-link/units/listing_types/listing_types_event_handler.php (revision 12737) +++ branches/5.0.x/in-link/units/listing_types/listing_types_event_handler.php (revision 12738) @@ -1,84 +1,84 @@ <?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.net/license/ for copyright notices and details. +* See http://www.in-portal.org/license for copyright notices and details. */ defined('FULL_PATH') or die('restricted access!'); class ListingTypesEventHandler extends kDBEventHandler { /** * Allows to override standart permission mapping * */ function mapPermissions() { parent::mapPermissions(); $permissions = Array( 'OnItemBuild' => Array('self' => true), ); $this->permMapping = array_merge($this->permMapping, $permissions); } /** * Set's selected category to listing type * * @param kEvent $event */ function OnProcessSelected(&$event) { $object =& $event->getObject(); $selected_ids = $this->Application->GetVar('selected_ids'); $object->SetDBField($this->Application->RecallVar('dst_field'), $selected_ids['c']); $this->RemoveRequiredFields($object); $object->Update(); $this->finalizePopup($event); } function OnPreSaveListingType(&$event) { $event->redirect = false; $object =& $event->getObject( Array('skip_autoload' => true) ); $this->RemoveRequiredFields($object); $event->CallSubEvent('OnPreSave'); $this->Application->SetVar($event->getPrefixSpecial(true).'_id', $object->GetID()); } function OnPreSave(&$event) { $object =& $event->getObject(); $item_info = $this->Application->GetVar($event->Prefix); if(is_array($item_info)) { $item_info = array_shift($item_info); if( getArrayValue($item_info, 'EnableBuying') ) { $options = $object->GetFieldOptions('ShopCartName'); $options['required'] = 1; $object->SetFieldOptions('ShopCartName', $options); } } parent::OnPreSave($event); } function OnEdit(&$event) { if ($this->Application->prefixRegistred('p')) { $this->Application->recallObject('p', null, Array('skip_autoload' => true)); } parent::OnEdit($event); } } \ No newline at end of file Index: branches/5.0.x/in-link/units/listing_types/listing_types_config.php =================================================================== --- branches/5.0.x/in-link/units/listing_types/listing_types_config.php (revision 12737) +++ branches/5.0.x/in-link/units/listing_types/listing_types_config.php (revision 12738) @@ -1,152 +1,152 @@ <?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.net/license/ for copyright notices and details. +* See http://www.in-portal.org/license for copyright notices and details. */ defined('FULL_PATH') or die('restricted access!'); $config = Array( 'Prefix' => 'lst', 'ItemClass' => Array('class'=>'kDBItem','file'=>'','build_event'=>'OnItemBuild'), 'ListClass' => Array('class'=>'kDBList','file'=>'','build_event'=>'OnListBuild'), 'EventHandlerClass' => Array('class'=>'ListingTypesEventHandler','file'=>'listing_types_event_handler.php','build_event'=>'OnBuild'), 'TagProcessorClass' => Array('class'=>'ListingTypesTagProcessor','file'=>'listing_types_tag_processor.php','build_event'=>'OnBuild'), 'AutoLoad' => true, 'AggregateTags' => Array( Array( 'AggregateTo' => 'l', 'AggregatedTagName' => 'ListListingTypes', 'LocalTagName' => 'PrintList', ), Array( 'AggregateTo' => 'l', 'AggregatedTagName' => 'ListingTypeField', 'LocalTagName' => 'Field', ), ), 'Hooks' => Array(), 'QueryString' => Array( 1 => 'id', 2 => 'page', 3 => 'event', 4 => 'mode', ), 'IDField' => 'ListingTypeId', 'TitleField' => 'Name', 'TitlePresets' => Array( 'default' => Array( 'new_status_labels' => Array('lst'=>'!la_title_AddingPaidListingType!'), 'edit_status_labels' => Array('lst'=>'!la_title_EditingPaidListingType!'), 'new_titlefield' => Array('lst'=>'!la_title_NewPaidListingType!'), ), 'listing_type_list'=>Array( 'prefixes' => Array('lst_List'), 'format' => "!la_title_PaidListingTypes!", ), 'listing_type_edit'=>Array( 'prefixes' => Array('lst'), 'new_titlefield' => Array('lst'=>'!la_title_NewPaidListingType!'), 'format' => "#lst_status# '#lst_titlefield#' - !la_title_General!", ), 'listing_type_shop_cart'=>Array( 'prefixes' => Array('lst'), 'new_titlefield' => Array('lst'=>'!la_title_NewPaidListingType!'), 'format' => "#lst_status# '#lst_titlefield#' - !la_title_ShopCartEntry!", ), ), 'EditTabPresets' => Array ( 'Default' => Array ( 'general' => Array ('title' => 'la_tab_General', 't' => 'in-link/paid_listings/paid_listing_type_edit', 'priority' => 1), ), ), 'PermSection' => Array('main' => 'in-link:listing_types'), 'Sections' => Array( 'in-link:listing_types' => Array( 'parent' => 'in-link:paid_listings_folder', 'icon' => 'paid_listings', 'label' => 'la_tab_ListingTypes', 'url' => Array('t' => 'in-link/paid_listings/paid_listing_types_list', 'pass' => 'm'), 'permissions' => Array('view', 'add', 'edit', 'delete'), 'priority' => 1.2, // <parent_priority>.<own_priority>, because this section replaces parent in tree 'type' => stTAB, ), ), 'TableName' => TABLE_PREFIX.'ListingTypes', 'ListSQLs' => Array( ''=>'SELECT * FROM %s',), // key - special, value - list select sql 'ItemSQLs' => Array( ''=>'SELECT * FROM %s',), 'ListSortings' => Array( '' => Array( 'Sorting' => Array('ListingTypeId' => 'asc'), ) ), 'Fields' => Array ( 'ListingTypeId' => Array('type' => 'int', 'not_null' => 1, 'default' => 0,), 'Name' => Array('type' => 'string','not_null' => '1','default' => '','required' => '1'), 'Description' => Array('type' => 'string', 'formatter' => 'kFormatter', 'using_fck' => 1, 'default' => NULL), 'Duration' => Array('type' => 'int', 'not_null' => 1, 'default' => 0), 'DurationType' => Array('type' => 'int', 'not_null' => 1, 'default' => 0, 'formatter'=>'kOptionsFormatter','use_phrases' => 1,'options' => Array(1 => 'la_opt_sec', 2 => 'la_opt_min', 3 => 'la_opt_hour', 4 => 'la_opt_day', 5 => 'la_opt_week', 6 => 'la_opt_month', 7 => 'la_opt_year')), 'OnPurchaseEdPick' => Array('type' => 'int','not_null' => '1','formatter'=>'kOptionsFormatter','use_phrases' => 1,'options' => Array(3 => 'la_Unchanged', 1 => 'la_On', 0 => 'la_Off'), 'default' => 3), 'OnPurchaseStatus' => Array('type' => 'int','not_null' => '1','formatter'=>'kOptionsFormatter','use_phrases' => 1,'options' => Array(3 => 'la_Unchanged', 1 => 'la_Enabled', 0 => 'la_Disabled', 2 => 'la_Pending'),'default' => 3), 'OnPurchaseNew' => Array('type' => 'int','not_null' => '1','formatter'=>'kOptionsFormatter','use_phrases' => 1,'options' => Array(3 => 'la_Unchanged', 1 => 'la_On', 0 => 'la_Off', 2 => 'la_Auto'),'default' => 3), 'OnPurchasePop' => Array('type' => 'int','not_null' => '1','formatter'=>'kOptionsFormatter','use_phrases' => 1,'options' => Array(3 => 'la_Unchanged', 1 => 'la_On', 0 => 'la_Off', 2 => 'la_Auto'),'default' => 3), 'OnPurchaseHot' => Array('type' => 'int','not_null' => '1','formatter'=>'kOptionsFormatter','use_phrases' => 1,'options' => Array(3 => 'la_Unchanged', 1 => 'la_On', 0 => 'la_Off', 2 => 'la_Auto'),'default' => 3), 'OnPurchasePriorityAction' => Array('type' => 'int','not_null' => '1','formatter'=>'kOptionsFormatter','use_phrases' => 1,'options' => Array(0 => 'la_DontChange', 1 => 'la_SetEqualTo', 2 => 'la_IncreaseBy', 3 => 'la_DecreaseBy'),'default' => 0), 'OnPurchasePriorityValue' => Array('type' => 'int','not_null' => '1','default' => 1), 'OnPurchaseAddToCatEnabled' => Array('type' => 'int','not_null' => '1','default' => 0), 'OnPurchaseAddToCat' => Array('type' => 'int','not_null' => '1','default' => 0), 'OnPurchaseCustomTemplate' => Array('type' => 'string','not_null' => 1,'default' => ''), 'OnExpireEdPick' => Array('type' => 'int','formatter'=>'kOptionsFormatter','use_phrases' => 1,'options' => Array(3 => 'la_Unchanged', 1 => 'la_On', 0 => 'la_Off'),'not_null' => '1','default' => 3), 'OnExpireNew' => Array('type' => 'int','not_null' => '1','formatter'=>'kOptionsFormatter','use_phrases' => 1,'options' => Array(3 => 'la_Unchanged', 1 => 'la_On', 0 => 'la_Off', 2 => 'la_Auto'),'default' => 3), 'OnExpirePop' => Array('type' => 'int','not_null' => '1','formatter'=>'kOptionsFormatter','use_phrases' => 1,'options' => Array(3 => 'la_Unchanged', 1 => 'la_On', 0 => 'la_Off', 2 => 'la_Auto'),'default' => 3), 'OnExpireHot' => Array('type' => 'int','not_null' => '1','formatter'=>'kOptionsFormatter','use_phrases' => 1,'options' => Array(3 => 'la_Unchanged', 1 => 'la_On', 0 => 'la_Off', 2 => 'la_Auto'),'default' => 3), 'OnExpirePriorityAction' => Array('type' => 'int','not_null' => '1','formatter'=>'kOptionsFormatter','use_phrases' => 1,'options' => Array(0 => 'la_DontChange', 1 => 'la_SetEqualTo', 2 => 'la_IncreaseBy', 3 => 'la_DecreaseBy'),'default' => 0), 'OnExpirePriorityValue' => Array('type' => 'int','not_null' => '1','default' => 1), 'OnExpireRemoveFromCatEnabled' => Array('type' => 'int','not_null' => '1','default' => 0), 'OnExpireRemoveFromCat' => Array('type' => 'int','not_null' => '1','default' => 0), 'OnExpireCustomTemplate' => Array('type' => 'string','not_null' => 1,'default' => ''), 'OnExpireStatus' => Array('type' => 'int','not_null' => '1','formatter'=>'kOptionsFormatter','use_phrases' => 1,'options' => Array(3 => 'la_Unchanged', 1 => 'la_Enabled', 0 => 'la_Disabled', 2 => 'la_Pending'),'default' => 3), 'RenewalReminder' => Array('type' => 'int','not_null' => '1','default' => 0), 'EnableBuying' => Array('type' => 'int','not_null' => '1','default' => 0), 'ShopCartName' => Array('type' => 'string', 'default' => null), 'Price' => Array('type' => 'double','default' => ''), 'Recurring' => Array('type' => 'int','not_null' => '1','default' => 0), 'VirtualProductId' => Array('type' => 'int','not_null' => '1','default' => 0), ), 'Grids' => Array( 'Default' => Array( 'Icons' => Array( 'default' => 'icon16_item.png', 0 => 'icon16_disbaled.png', 1 => 'icon16_item.png', 'module' => 'core', ), 'Fields' => Array( 'ListingTypeId' => Array( 'title'=>'la_col_Id' , 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter', 'width' => 60), 'Name' => Array( 'title'=>'la_col_Name', 'filter_block' => 'grid_like_filter', 'width' => 250), 'Duration' => Array( 'title'=>'la_col_Duration' , 'data_block' => 'duration_td', 'filter_block' => 'grid_like_filter', 'width' => 100), ), ), ), ); \ No newline at end of file Index: branches/5.0.x/in-link/units/listing_types/listing_types_tag_processor.php =================================================================== --- branches/5.0.x/in-link/units/listing_types/listing_types_tag_processor.php (revision 12737) +++ branches/5.0.x/in-link/units/listing_types/listing_types_tag_processor.php (revision 12738) @@ -1,46 +1,46 @@ <?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.net/license/ for copyright notices and details. +* See http://www.in-portal.org/license for copyright notices and details. */ defined('FULL_PATH') or die('restricted access!'); class ListingTypesTagProcessor extends kDBTagProcessor { function CategoryPath($params) { $object =& $this->getObject($params); $params['cat_id'] = $object->GetDBField($params['field']); return $this->Application->ProcessParsedTag('c', 'CategoryPath', $params); } /** * Makes 1st listing type default * * @param Array $params * @return bool */ function IsDefault($params) { static $listing_type_id = null; $object =& $this->getObject(); /* @var $object kDBItem */ if (!isset($listing_type_id)) { $listing_type_id = $object->GetID(); } return $listing_type_id == $object->GetID(); } } \ No newline at end of file Index: branches/5.0.x/in-link/install/upgrades.php =================================================================== --- branches/5.0.x/in-link/install/upgrades.php (revision 12737) +++ branches/5.0.x/in-link/install/upgrades.php (revision 12738) @@ -1,141 +1,141 @@ <?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.net/license/ for copyright notices and details. +* See http://www.in-portal.org/license for copyright notices and details. */ defined('FULL_PATH') or die('restricted access!'); $upgrade_class = 'InLinkUpgrades'; /** * Class, that holds all upgrade scripts for "Core" module * */ class InLinkUpgrades extends kHelper { /** * Install toolkit instance * * @var kInstallToolkit */ var $_toolkit = null; /** * Sets common instance of installator toolkit * * @param kInstallToolkit $instance */ function setToolkit(&$instance) { $this->_toolkit =& $instance; } /** * Changes table structure, where multilingual fields of TEXT type are present * * @param string $mode when called mode {before, after) */ function Upgrade_5_0_0($mode) { if ($mode == 'after') { $root_category = $this->Application->findModule('Name', 'In-Link', 'RootCat'); $sql = 'UPDATE ' . $this->Application->getUnitOption('c', 'TableName') . ' SET UseMenuIconUrl = 1, MenuIconUrl = "in-link/img/menu_links.gif" WHERE ' . $this->Application->getUnitOption('c', 'IDField') . ' = ' . $root_category; $this->Conn->Query($sql); $this->_updateDetailTemplate('l', 'inlink/detail', 'in-link/designs/detail'); // copy link name and description to their multilingual equivalents $this->_copyToMultilingual(); } } /** * Copy link values from normal fields to multilingual * */ function _copyToMultilingual() { $fields = Array ('Name', 'Description'); $primary_language = $this->Application->GetDefaultLanguageId(); $set_clause = Array (); foreach ($fields as $field) { $set_clause[] = 'l' . $primary_language . '_' . $field . ' = ' . $field; } $sql = 'UPDATE ' . TABLE_PREFIX . 'Link SET ' . implode(', ', $set_clause); $this->Conn->Query($sql); } /** * Replaces deprecated detail template design with new one * * @param string $prefix * @param string $from_template * @param string $to_template */ function _updateDetailTemplate($prefix, $from_template, $to_template) { $sql = 'SELECT CustomFieldId FROM ' . TABLE_PREFIX . 'CustomField WHERE FieldName = "' . $prefix . '_ItemTemplate"'; $custom_field_id = $this->Conn->GetOne($sql); $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); /* @var $ml_formatter kMultiLanguage */ $field = $ml_formatter->LangFieldName('cust_' . $custom_field_id, true); $sql = 'UPDATE ' . TABLE_PREFIX . 'CategoryCustomData SET ' . $field . ' = "' . $to_template . '" WHERE ' . $field . ' = "' . $from_template . '"'; $this->Conn->Query($sql); } /** * Update to 5.0.1 * * @param string $mode when called mode {before, after) */ function Upgrade_5_0_1($mode) { if ($mode == 'after') { $this->_updateDetailTemplate('l', 'in-link/designs/detail', 'in-link/links/link_detail'); // delete old events $events_to_delete = Array ( 'LINK.OWNER.MODIFY.PENDING', 'LINK.OWNER.MODIFY' ); $sql = 'SELECT EventId FROM ' . TABLE_PREFIX . 'Events WHERE Event IN ("' . implode('","', $events_to_delete) . '")'; $event_ids = $this->Conn->GetCol($sql); if ($event_ids) { $sql = 'DELETE FROM ' . TABLE_PREFIX . 'EmailMessage WHERE EventId IN (' . implode(',', $event_ids) . ')'; $this->Conn->Query($sql); $sql = 'DELETE FROM ' . TABLE_PREFIX . 'Events WHERE EventId IN (' . implode(',', $event_ids) . ')'; $this->Conn->Query($sql); $sql = 'DELETE FROM ' . TABLE_PREFIX . 'Phrase WHERE Phrase IN ("la_event_link.owner.modify", "la_event_link.owner.modify.pending")'; $this->Conn->Query($sql); } } } } \ No newline at end of file Index: branches/5.0.x/in-link/install/prerequisites.php =================================================================== --- branches/5.0.x/in-link/install/prerequisites.php (revision 12737) +++ branches/5.0.x/in-link/install/prerequisites.php (revision 12738) @@ -1,79 +1,79 @@ <?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.net/license/ for copyright notices and details. +* See http://www.in-portal.org/license for copyright notices and details. */ defined('FULL_PATH') or die('restricted access!'); $prerequisite_class = 'InLinkPrerequisites'; /** * Class, that holds all prerequisite scripts for "In-Link" module * */ class InLinkPrerequisites extends kHelper { /** * Install toolkit instance * * @var kInstallToolkit */ var $_toolkit = null; /** * Sets common instance of installator toolkit * * @param kInstallToolkit $instance */ function setToolkit(&$instance) { $this->_toolkit =& $instance; } /** * Checks minimal version, that could be upgradeable * * @param string $mode when called mode {install, standalone, upgrade) */ function CheckPrerequisites($versions, $mode) { $errors = Array (); if ($mode == 'standalone') { if (!$this->Application->isModuleEnabled('In-Portal')) { $errors[] = 'Please install or enable "In-Portal" module first'; } } if ($mode == 'upgrade') { $sql = 'SELECT Version FROM ' . TABLE_PREFIX . 'Modules WHERE Name = "In-Portal"'; $inportal_version = $this->Conn->GetOne($sql); if ($inportal_version === false) { // only, when In-Portal was installed return $errors; } $min_version = '4.3.1'; $current_version = $this->_toolkit->ConvertModuleVersion($inportal_version); $needed_version = $this->_toolkit->ConvertModuleVersion($min_version); if ($current_version < $needed_version) { $errors[] = 'Please upgrade "In-Portal" to version ' . $min_version; } } return $errors; } } \ No newline at end of file Index: branches/5.0.x/in-link/install.php =================================================================== --- branches/5.0.x/in-link/install.php (revision 12737) +++ branches/5.0.x/in-link/install.php (revision 12738) @@ -1,53 +1,53 @@ <?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.net/license/ for copyright notices and details. +* See http://www.in-portal.org/license for copyright notices and details. */ $module_folder = 'in-link'; 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('Directory', 'Link Directory', '/in-link/designs/section', 'in-link/img/menu_links.gif'); $toolkit->RunSQL('/' . $module_folder . '/install/install_schema.sql'); $toolkit->RunSQL('/' . $module_folder . '/install/install_data.sql', '{LinkCatId}', $category->GetID()); $toolkit->ImportLanguage('/' . $module_folder . '/install/english'); $toolkit->SetModuleRootCategory($module_folder, $category->GetID()); $toolkit->linkCustomFields($module_folder, 'l', 4); // to create Custom Fields for Links $toolkit->linkCustomFields('KERNEL', 'c', 1); // to create ItemTemplate custom field $toolkit->setModuleItemTemplate($category, 'l', 'in-link/links/link_detail'); $toolkit->finalizeModuleInstall($module_folder, true); \ No newline at end of file