Index: in-auction/units/listing/listing_config.php =================================================================== --- in-auction/units/listing/listing_config.php (revision 15024) +++ in-auction/units/listing/listing_config.php (working copy) @@ -23,7 +23,7 @@ 'ScheduledTasks' => Array( - 'list_items' => Array('EventName' => 'OnListItems', 'RunInterval' => 600, 'Type' => reAFTER), + 'list_items' => Array('EventName' => 'OnListItems', 'RunInterval' => 600), ), 'QueryString' => Array ( Index: in-auction/units/sections/sections_config.php =================================================================== --- in-auction/units/sections/sections_config.php (revision 15024) +++ in-auction/units/sections/sections_config.php (working copy) @@ -27,16 +27,16 @@ ), 'ScheduledTasks' => Array( - 'seller_transactions' => Array('EventName' => 'OnGetSellerTransactions', 'RunInterval' => 600, 'Type' => reAFTER), - 'seller_list' => Array('EventName' => 'OnGetSellerList', 'RunInterval' => 600, 'Type' => reAFTER), - 'auto_dispute' => Array('EventName' => 'OnAutoDispute', 'RunInterval' => 600, 'Type' => reAFTER), - 'auctions_schedule' => Array('EventName' => 'OnProcessSchedule', 'RunInterval' => 1800, 'Type' => reAFTER), - 'subscribe_ebay_notifications' => Array('EventName' => 'OnSubscribeListingNotifications', 'RunInterval' => 360000, 'Type' => reAFTER), - 'delete_old_hits' => Array('EventName' => 'OnDeleteOldHits', 'RunInterval' => 72000, 'Type' => reAFTER), - 'revise_checkout_statuses' => Array('EventName' => 'OnReviseCheckoutStatuses', 'RunInterval' => 43200, 'Type' => reAFTER), - 'receive_feedbacks' => Array('EventName' => 'OnReceiveFeedbacks', 'RunInterval' => 43200, 'Type' => reAFTER), - 'send_feedbacks' => Array('EventName' => 'OnSendFeedbacks', 'RunInterval' => 43200, 'Type' => reAFTER), - 'send_feedback_notifications' => Array('EventName' => 'OnSendFeedbackNotifications', 'RunInterval' => 43200, 'Type' => reAFTER), + 'seller_transactions' => Array('EventName' => 'OnGetSellerTransactions', 'RunInterval' => 600), + 'seller_list' => Array('EventName' => 'OnGetSellerList', 'RunInterval' => 600), + 'auto_dispute' => Array('EventName' => 'OnAutoDispute', 'RunInterval' => 600), + 'auctions_schedule' => Array('EventName' => 'OnProcessSchedule', 'RunInterval' => 1800), + 'subscribe_ebay_notifications' => Array('EventName' => 'OnSubscribeListingNotifications', 'RunInterval' => 360000), + 'delete_old_hits' => Array('EventName' => 'OnDeleteOldHits', 'RunInterval' => 72000), + 'revise_checkout_statuses' => Array('EventName' => 'OnReviseCheckoutStatuses', 'RunInterval' => 43200), + 'receive_feedbacks' => Array('EventName' => 'OnReceiveFeedbacks', 'RunInterval' => 43200), + 'send_feedbacks' => Array('EventName' => 'OnSendFeedbacks', 'RunInterval' => 43200), + 'send_feedback_notifications' => Array('EventName' => 'OnSendFeedbackNotifications', 'RunInterval' => 43200), ), Index: in-commerce/units/affiliates/affiliates_config.php =================================================================== --- in-commerce/units/affiliates/affiliates_config.php (revision 15024) +++ in-commerce/units/affiliates/affiliates_config.php (working copy) @@ -42,6 +42,28 @@ 'DoSpecial' => 'register', 'DoEvent' => 'OnRegisterAffiliate', ), + + Array( + 'Mode' => hAFTER, + 'Conditional' => false, + 'HookToPrefix' => 'adm', + 'HookToSpecial' => '', + 'HookToEvent' => Array('OnStartup'), + 'DoPrefix' => '', + 'DoSpecial' => '', + 'DoEvent' => 'OnResetStatistics', + ), + + Array( + 'Mode' => hAFTER, + 'Conditional' => false, + 'HookToPrefix' => 'adm', + 'HookToSpecial' => '', + 'HookToEvent' => Array('OnStartup'), + 'DoPrefix' => '', + 'DoSpecial' => '', + 'DoEvent' => 'OnStoreAffiliate', + ), ), 'AggregateTags' => Array( Array( @@ -85,11 +107,6 @@ 5 => 'mode', ), - 'ScheduledTasks' => Array( - 'store_affiliate' => Array('EventName' => 'OnStoreAffiliate', 'RunInterval' => 0, 'Type' => reBEFORE), - 'reset_affiliate_stats' => Array('EventName' => 'OnResetStatistics', 'RunInterval' => 0, 'Type' => reBEFORE), - ), - 'IDField' => 'AffiliateId', 'StatusField' => Array('Status'), // field, that is affected by Approve/Decline events Index: in-commerce/units/affiliates/affiliates_event_handler.php =================================================================== --- in-commerce/units/affiliates/affiliates_event_handler.php (revision 15024) +++ in-commerce/units/affiliates/affiliates_event_handler.php (working copy) @@ -159,16 +159,14 @@ } /** - * Stores affiliate id using method from Config (session or cookie) if correct code is present in url + * [HOOK] Stores affiliate id using method from Config (session or cookie) if correct code is present in url * * @param kEvent $event * @return bool */ function OnStoreAffiliate(&$event) { - $event->Init($event->Prefix, '-item'); - - $object =& $event->getObject(Array ('skip_autoload' => true)); + $object =& $this->Application->recallObject($event->Prefix . '.-item', null, Array ('skip_autoload' => true)); /* @var $object kDBItem */ $affiliate_storage_method = $this->Application->ConfigValue('Comm_AffiliateStorageMethod'); @@ -182,23 +180,21 @@ $object->Load($affiliate_id); } - if( $object->isLoaded() && ($object->GetDBField('Status') == 1) ) - { + if ( $object->isLoaded() && ($object->GetDBField('Status') == 1) ) { // user is found with such email - $affiliate_user =& $this->Application->recallObject('u.affiliate', null, Array('skip_autoload'=>true) ); - $affiliate_user->Load( $object->GetDBField('PortalUserId') ); + $affiliate_user =& $this->Application->recallObject('u.affiliate', null, Array ('skip_autoload' => true)); + /* @var $affiliate_user UsersItem */ - if($affiliate_user->GetDBField('Status') == 1) - { + $affiliate_user->Load($object->GetDBField('PortalUserId')); + + if ( $affiliate_user->GetDBField('Status') == 1 ) { $affiliate_id = $object->GetDBField('AffiliateId'); $this->Application->setVisitField('AffiliateId', $affiliate_id); - if($affiliate_storage_method == 1) - { + if ( $affiliate_storage_method == 1 ) { $this->Application->StoreVar('affiliate_id', $affiliate_id); // per session } - else - { + else { // in cookie $this->Application->Session->SetCookie('affiliate_id', $affiliate_id, $this->getCookieExpiration()); } @@ -473,40 +469,48 @@ } /** - * Resets statistics (accumulated amount & items sold) for affiliates based on ResetInterval in their plan + * [HOOK] Resets statistics (accumulated amount & items sold) for affiliates based on ResetInterval in their plan * * @param kEvent $event * @author Alex */ function OnResetStatistics(&$event) { - $intervals = Array(86400 => 'la_day', 604800 => 'la_week', 2628000 => 'la_month', 7884000 => 'la_quartely', 31536000 => 'la_year'); + $intervals = Array (86400 => 'la_day', 604800 => 'la_week', 2628000 => 'la_month', 7884000 => 'la_quartely', 31536000 => 'la_year'); - $affil_table = $this->Application->getUnitOption($event->Prefix, 'TableName'); - $ap_table = $this->Application->getUnitOption('ap', 'TableName'); + $affiliates_table = $this->Application->getUnitOption($event->Prefix, 'TableName'); + $affiliate_plan_table = $this->Application->getUnitOption('ap', 'TableName'); - $sql = 'SELECT AffiliateId - FROM '.$affil_table.' a - LEFT JOIN '.$ap_table.' ap ON a.AffiliatePlanId = ap.AffiliatePlanId'; + $base_time = adodb_mktime(); + $where_clause = Array (); - $base_time = adodb_mktime(); - $where_clause = Array(); - foreach($intervals as $interval_length => $interval_description) - { + foreach ($intervals as $interval_length => $interval_description) { $start_timestamp = $this->getPeriodStartTS($base_time, $interval_length); - $where_clause[] = 'ap.ResetInterval = '.$interval_length.' AND LastOrderDate < '.$start_timestamp; + $where_clause[] = 'ap.ResetInterval = ' . $interval_length . ' AND LastOrderDate < ' . $start_timestamp; } - $sql .= ' WHERE ('.implode(') OR (', $where_clause).')'; + $sql = 'SELECT AffiliateId + FROM ' . $affiliates_table . ' a + LEFT JOIN ' . $affiliate_plan_table . ' ap ON a.AffiliatePlanId = ap.AffiliatePlanId + WHERE (' . implode(') OR (', $where_clause) . ')'; $affiliate_ids = $this->Conn->GetCol($sql); - if ($affiliate_ids && defined('DEBUG_MODE') && DEBUG_MODE && $this->Application->isDebugMode()) { + if ( !$affiliate_ids ) { + return; + } + + if ( defined('DEBUG_MODE') && DEBUG_MODE && $this->Application->isDebugMode() ) { $this->Application->Debugger->appendHTML('Affiliates Pending Totals Reset: '); $this->Application->Debugger->dumpVars($affiliate_ids); } - $sql = 'UPDATE '.$affil_table.' SET AccumulatedAmount = 0, ItemsSold = 0, LastOrderDate = %s WHERE AffiliateId IN (%s)'; - if($affiliate_ids) $this->Conn->Query( sprintf($sql, $base_time, implode(',', $affiliate_ids) ) ); + $fields_hash = Array ( + 'AccumulatedAmount' => 0, + 'ItemsSold' => 0, + 'LastOrderDate' => $base_time, + ); + + $this->Conn->doUpdate($fields_hash, $affiliates_table, 'AffiliateId IN (' . implode(',', $affiliate_ids) . ')'); } /** @@ -519,43 +523,43 @@ */ function getPeriodStartTS($base_time, $period_length) { - switch($period_length) - { - case 86400: // day - $start_timestamp = adodb_mktime(0,0,0, adodb_date('m', $base_time), adodb_date('d', $base_time), adodb_date('Y', $base_time) ); + $start_timestamp = 0; + + switch ($period_length) { + case 86400: // day + $start_timestamp = adodb_mktime(0, 0, 0, adodb_date('m', $base_time), adodb_date('d', $base_time), adodb_date('Y', $base_time)); break; case 604800: // week $day_seconds = 86400; $first_week_day = $this->Application->ConfigValue('FirstDayOfWeek'); - $morning = adodb_mktime(0,0,0, adodb_date('m', $base_time), adodb_date('d', $base_time), adodb_date('Y', $base_time) ); + $morning = adodb_mktime(0, 0, 0, adodb_date('m', $base_time), adodb_date('d', $base_time), adodb_date('Y', $base_time)); $week_day = adodb_date('w', $morning); - if($week_day == $first_week_day) - { + if ( $week_day == $first_week_day ) { // if it is already first week day, then don't search for previous week day $day_diff = 0; } - else - { + else { // this way, because sunday is 0, but not 7 as it should be - $day_diff = $week_day != 0 ? $week_day - $first_week_day: 7 - $first_week_day; + $day_diff = $week_day != 0 ? $week_day - $first_week_day : 7 - $first_week_day; } $start_timestamp = $morning - $day_diff * $day_seconds; break; case 2628000: // month - $start_timestamp = adodb_mktime(0,0,0, adodb_date('m', $base_time), 1, adodb_date('Y', $base_time) ); + $start_timestamp = adodb_mktime(0, 0, 0, adodb_date('m', $base_time), 1, adodb_date('Y', $base_time)); break; case 7884000: // quartal - $first_quartal_month = (ceil( adodb_date('m', $base_time) / 3)-1)*3 + 1; - $start_timestamp = adodb_mktime(0,0,0, $first_quartal_month, 1, adodb_date('Y', $base_time) ); + $first_quartal_month = (ceil(adodb_date('m', $base_time) / 3) - 1) * 3 + 1; + $start_timestamp = adodb_mktime(0, 0, 0, $first_quartal_month, 1, adodb_date('Y', $base_time)); break; case 31536000: - $start_timestamp = adodb_mktime(0,0,0,1,1, adodb_date('Y', $base_time) ); + $start_timestamp = adodb_mktime(0, 0, 0, 1, 1, adodb_date('Y', $base_time)); break; } + return $start_timestamp; } Index: in-link/units/link_validation/link_validation_config.php =================================================================== --- in-link/units/link_validation/link_validation_config.php (revision 15024) +++ in-link/units/link_validation/link_validation_config.php (working copy) @@ -45,7 +45,7 @@ ), 'ScheduledTasks' => Array ( - 'link_validation' => Array ('EventName' => 'OnCronValidation', 'RunInterval' => 3600*24, 'Type' => reAFTER), + 'link_validation' => Array ('EventName' => 'OnCronValidation', 'RunInterval' => 3600*24), ), 'IDField' => 'LinkValidationId', Index: in-link/units/listings/listings_config.php =================================================================== --- in-link/units/listings/listings_config.php (revision 15024) +++ in-link/units/listings/listings_config.php (working copy) @@ -44,7 +44,7 @@ ), 'ScheduledTasks' => Array ( - 'listings_expiration' => Array ('EventName' => 'OnCheckExpiredPaidListings', 'RunInterval' => 1800, 'Type' => reAFTER), + 'listings_expiration' => Array ('EventName' => 'OnCheckExpiredPaidListings', 'RunInterval' => 1800), ), 'IDField' => 'ListingId', Index: in-news/units/articles/articles_config.php =================================================================== --- in-news/units/articles/articles_config.php (revision 15024) +++ in-news/units/articles/articles_config.php (working copy) @@ -116,6 +116,17 @@ 'DoSpecial' => '*', 'DoEvent' => 'OnCloneSubItem', ), + + Array( + 'Mode' => hAFTER, + 'Conditional' => false, + 'HookToPrefix' => 'adm', + 'HookToSpecial' => '', + 'HookToEvent' => Array('OnStartup'), + 'DoPrefix' => '', + 'DoSpecial' => '', + 'DoEvent' => 'OnUpdateRSSArticles', + ), ), 'CatalogItem' => true, @@ -131,10 +142,6 @@ 5 => 'mode', ), - 'ScheduledTasks' => Array ( - 'rss_category_update' => Array ('EventName' => 'OnUpdateRSSAtricles', 'RunInterval' => 0, 'Type' => reBEFORE), - ), - 'IDField' => 'NewsId', 'StatusField' => Array ('Status'), // field, that is affected by Approve/Decline events Index: in-news/units/articles/articles_event_handler.php =================================================================== --- in-news/units/articles/articles_event_handler.php (revision 15024) +++ in-news/units/articles/articles_event_handler.php (working copy) @@ -60,11 +60,11 @@ /** - * [SCHEDULED TASK] Deletes expired articles + update existing articles from rss feed with new data (key - article url) + * [HOOK] Deletes expired articles + update existing articles from rss feed with new data (key - article url) * * @param kEvent $event */ - function OnUpdateRSSAtricles(&$event) + function OnUpdateRSSArticles(&$event) { $category_table = $this->Application->getUnitOption('c', 'TableName'); $custom_table = $this->Application->getUnitOption('c-cdata', 'TableName'); @@ -125,8 +125,10 @@ (LENGTH(cd.'.$article_custom_fields['RssOriginalURL'].') > 0)'; $article_ids = $this->Conn->GetCol($sql); if ($article_ids) { - $temp =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler'); - $temp->DeleteItems($event->Prefix, $event->Special, $article_ids); + $temp_handler =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler'); + /* @var $temp_handler kTempTablesHandler */ + + $temp_handler->DeleteItems($event->Prefix, $event->Special, $article_ids); } $sql = 'UPDATE '.$custom_table.'