public function updateModifyDate($adID) { $retval = $this->db->update('classifieds_data', array('modify_date' => date_helper::now()), array('ad_id' => $adID), 1); // Action hook hook::action('classifieds/date/update', $adID); return $retval; }
public function updateModifyDate($albumID) { $retval = $this->db->update('pictures_albums_data', array('modify_date' => date_helper::now()), array('album_id' => $albumID), 1); // Action hook hook::action('pictures/albums/date/update', $albumID); return $retval; }
public function savePictureFile($fileID, $adID, $ad, $extra = array()) { // Basic picture data $picture = array('file_id' => $fileID, 'ad_id' => $adID, 'user_id' => session::item('user_id'), 'post_date' => date_helper::now(), 'active' => session::permission('pictures_approve', 'classifieds') ? 1 : 9, 'order_id' => $ad['total_pictures'] + $ad['total_pictures_i'] + 1); // Do we have extras? if ($extra) { // Merge extras $picture = array_merge($picture, $extra); } // Save picture $pictureID = $this->db->insert('classifieds_pictures_data', $picture); // Do we have picture ID? if ($pictureID) { // Update album's counter $column = $picture['active'] == 1 ? 'total_pictures' : 'total_pictures_i'; $this->db->query("UPDATE `:prefix:classifieds_data` SET `{$column}`=`{$column}`+1 WHERE `user_id`=? AND `ad_id`=? LIMIT 1", array(session::item('user_id'), $adID)); // Does album have a cover? if (!$ad['picture_id']) { // Update ad cover $this->classifieds_model->updatePicture($adID, $pictureID); } // Action hook hook::action('classifieds/pictures/insert', $pictureID, $picture); } return $pictureID; }
public function savePageData($pageID, $parentID, $pageOld, $fields, $extra = array()) { // Is this a new page if (!$pageID) { // Get last page $lastPage = $this->db->query("SELECT `order_id` FROM `:prefix:pages_data` WHERE `parent_id`=? ORDER BY `order_id` DESC LIMIT 1", array($parentID))->row(); $extra['order_id'] = $lastPage ? $lastPage['order_id'] + 1 : 1; $extra['post_date'] = date_helper::now(); } // Save page if (!($newPageID = $this->fields_model->saveValues('page', $pageID, $pageOld, $fields, $extra))) { return 0; } // Is this an existing page? if ($pageID) { $children = $this->getChildren($pageID); foreach ($children as $child) { if ($location = $this->getLocation($child['page_id'])) { $this->db->update('pages_data', array('location' => $location), array('page_id' => $child['page_id']), 1); } } // Action hook hook::action('pages/update', $newPageID, $extra); } else { // Action hook hook::action('pages/insert', $newPageID, $extra); } return $newPageID; }
public function saveReport($resourceID, $userID, $itemID, $subjectID, $message) { // Report data $report = array('poster_id' => session::item('user_id'), 'resource_id' => $resourceID, 'user_id' => $userID, 'item_id' => $itemID, 'subject_id' => $subjectID, 'message' => $message, 'post_date' => date_helper::now()); // Insert report if ($reportID = $this->db->insert('reports', $report)) { // Action hook hook::action('reports/insert', session::item('poster_id'), $resourceID, $userID, $itemID, $subjectID, $message); } return $reportID; }
public function addUser($userID) { $data = array('user_id' => session::item('user_id'), 'blocked_id' => $userID, 'post_date' => date_helper::now()); // Insert blocked user $this->db->insert('users_blocked', $data); // Update counters $this->db->query("UPDATE `:prefix:users` SET `total_blocked`=`total_blocked`+1 WHERE `user_id`=? LIMIT 1", array(session::item('user_id'))); // Action hook hook::action('users/blocked/add', session::item('user_id'), $userID); return true; }
public function addFriend($userID) { $request = array('user_id' => session::item('user_id'), 'friend_id' => $userID, 'post_date' => date_helper::now(), 'active' => 0); // Insert request $this->db->insert('users_friends', $request); // Update counters $this->db->query("UPDATE `:prefix:users` SET `total_friends_i`=`total_friends_i`+1 WHERE `user_id`=? LIMIT 1", array($userID)); // Action hook hook::action('users/friends/request', session::item('user_id'), $userID); return true; }
public function usersProfileViewCounters($counters, $user) { if (users_helper::isLoggedin() && $user['user_id'] == session::item('user_id')) { $counters['total_classifieds'] = session::item('total_classifieds'); return $counters; } $columns = array('`a`.`user_id`=' . $user['user_id'], '`a`.`post_date`>' . (date_helper::now() - config::item('ad_expiration', 'classifieds') * 60 * 60 * 24)); $params = array(); loader::model('classifieds/classifieds'); $counters['total_classifieds'] = $this->classifieds_model->countAds($columns, array(), $params); return $counters; }
public static function getFileURL($serviceID, $path, $name, $ext, $suffix = '', $stamp = '') { // Get storage service and settings $service = config::item('storages', 'core', $serviceID); $settings = config::item('storages', 'core', 'settings', $serviceID); if (!$service) { return ''; } // Load library loader::library('storages/' . $service, $settings, 'storage_' . $service); $str = codebreeder::instance()->{'storage_' . $service}->getFileURL($path, $name, $ext, $suffix, $stamp && $stamp > date_helper::now() - 60 * 60 * 24 * 3 ? $stamp : ''); return $str; }
public function saveBlogData($blogID, $userID, $blogOld, $fields, $extra = array()) { // Is this a new blog? if (!$blogID) { $extra['post_date'] = date_helper::now(); } // Do we have user ID? if ($userID) { $extra['active'] = session::permission('blogs_approve', 'blogs') ? 1 : 9; $extra['user_id'] = $userID; } // Save blog if (!($newBlogID = $this->fields_model->saveValues('blog', $blogID, $blogOld, $fields, $extra))) { return 0; } // Is this a new blog? if (!$blogID && $userID) { $column = $extra['active'] == 1 ? 'total_blogs' : 'total_blogs_i'; $this->db->query("UPDATE `:prefix:users` SET `{$column}`=`{$column}`+1 WHERE `user_id`=? LIMIT 1", array($userID)); } // Did blog status change? if ($blogID && $extra['active'] != $blogOld['active']) { // Did we approve this blog? if ($extra['active'] == 1) { $this->db->query("UPDATE `:prefix:users` SET `total_blogs`=`total_blogs`+1, `total_blogs_i`=`total_blogs_i`-1 WHERE `user_id`=? LIMIT 1", array($blogOld['user_id'])); } elseif ($blogID && $blogOld['active'] == 1) { $this->db->query("UPDATE `:prefix:users` SET `total_blogs`=`total_blogs`-1, `total_blogs_i`=`total_blogs_i`+1 WHERE `user_id`=? LIMIT 1", array($blogOld['user_id'])); } } // Did we add a new blog or privacy setting changed? if (!$blogID || $extra['privacy'] != $blogOld['privacy']) { // Clean up counters $this->counters_model->deleteCounters('user', $blogID ? $blogOld['user_id'] : $userID); } if ($blogID) { // Update timeline action timeline_helper::update(true, 'blog_post', $blogOld['user_id'], $newBlogID, $extra['active'], $extra['privacy']); // Action hook hook::action('blogs/update', $newBlogID, $extra); } else { // Save timeline action if (session::item('timeline_blog_post', 'config') === false || session::item('timeline_blog_post', 'config')) { timeline_helper::save('blog_post', $userID, $newBlogID, $extra['active'], $extra['privacy']); } // Action hook hook::action('blogs/insert', $newBlogID, $extra); } return $newBlogID; }
public function cleanup() { $timestamp = date_helper::now() - 60 * 60 * 24 * config::item('notices_cleanup_delay', 'timeline'); // Get old unseen notices $notices = $this->db->query("SELECT * FROM `:prefix:timeline_notices` WHERE `new`=1 AND `post_date`<?", array($timestamp))->result(); foreach ($notices as $notice) { $this->db->query("UPDATE `:prefix:users` SET `total_notices_new`=`total_notices_new`-1 WHERE `user_id`=? LIMIT 1", array($notice['user_id'])); } // Delete notices $retval = $this->db->query("DELETE FROM `:prefix:timeline_notices` WHERE `post_date`<?", array($timestamp)); // Action hook hook::action('timeline/notices/cleanup'); $this->cron_model->addLog('[Timeline] Cleaned up old timeline notifications.'); return $retval; }
public function cleanup() { $timestamp = date_helper::now() - 60 * 60 * 24 * config::item('cleanup_delay', 'users'); // Get old visitors $visitors = $this->db->query("SELECT * FROM `:prefix:users_visitors` WHERE `post_date`<?", array($timestamp))->result(); foreach ($visitors as $visitor) { $this->db->query("UPDATE `:prefix:users` SET `total_visitors`=`total_visitors`-1 " . ($visitor['new'] ? ", `total_visitors_new`=`total_visitors_new`-1" : "") . " WHERE `user_id`=? LIMIT 1", array($visitor['user_id'])); } // Delete visitors $retval = $this->db->query("DELETE FROM `:prefix:users_visitors` WHERE `post_date`<?", array($timestamp)); // Action hook hook::action('users/visitors/cleanup'); $this->cron_model->addLog('[Users] Deleted ' . count($visitors) . ' user visitors.'); return $retval; }
public function run() { $shash = uri::segment(3); // Verify security string if (!$shash || strcmp($shash, config::item('cron_shash', 'system')) !== 0) { error::show('Invalid security string.'); } if (strcmp(config::item('cron_last_run', 'system'), date('Ymd', date_helper::now())) === 0) { error::show('You may run this file only once per day.'); } // Action hook hook::action('cron/run'); echo "Performed tasks:<br/>"; echo implode(" <br/>\n", $this->cron_model->getLog()); $this->cron_model->finalize(); exit; }
public function saveTransaction($transactionID, $gatewayID, $invoiceID, $receiptID, $userID, $amount) { $transaction = array('user_id' => $userID, 'invoice_id' => $invoiceID, 'gateway_id' => $gatewayID, 'receipt_id' => $receiptID ? $receiptID : text_helper::random(10), 'amount' => $amount); // Is this a new transaction? if (!$transactionID) { $transaction['post_date'] = date_helper::now(); // Save transaction $transactionID = $this->db->insert('billing_transactions', $transaction); // Action hook hook::action('billing/transactions/insert', $transactionID, $transaction); } else { // Save transaction $this->db->update('billing_transactions', $transaction, array('transaction_id' => $transactionID), 1); // Action hook hook::action('billing/transactions/update', $transactionID, $transaction); } return $transactionID; }
public function saveEntryData($newsID, $newsOld, $fields, $extra = array()) { // Is this a new entry if (!$newsID) { $extra['post_date'] = date_helper::now(); } // Save entry if (!($newNewsID = $this->fields_model->saveValues('news', $newsID, $newsOld, $fields, $extra))) { return 0; } if ($newsID) { // Action hook hook::action('news/update', $newNewsID, $extra); } else { // Action hook hook::action('news/insert', $newNewsID, $extra); } return $newNewsID; }
public static function getAds($params = array()) { loader::model('classifieds/classifieds'); $template = isset($params['template']) ? $params['template'] : 'classifieds/helpers/classifieds'; $user = isset($params['user']) && $params['user'] ? $params['user'] : array(); $userID = $user ? $user['user_id'] : (isset($params['user_id']) ? $params['user_id'] : 0); if ($userID) { $params['join_columns'][] = '`a`.`user_id`=' . $userID; } if (!$userID || $userID != session::item('user_id')) { if ($userID) { $params['join_columns'][] = '`a`.`post_date`>' . (date_helper::now() - config::item('ad_expiration', 'classifieds') * 60 * 60 * 24); } else { $params['join_columns'][] = '`u`.`active`=1'; } } $params['limit'] = isset($params['limit']) ? $params['limit'] : 10; $params['order'] = isset($params['order']) ? $params['order'] : ''; $ads = codebreeder::instance()->classifieds_model->getAds('in_list', $params['join_columns'], array(), $params['order'], $params['limit'], $params); view::assign(array('ads' => $ads, 'user' => $user, 'params' => $params), '', $template); return view::load($template, array(), 1); }
public function savePictureFile($fileID, $albumID, $album, $extra = array()) { // Basic picture data $picture = array('file_id' => $fileID, 'album_id' => $albumID, 'user_id' => session::item('user_id'), 'post_date' => date_helper::now(), 'active' => session::permission('pictures_approve', 'pictures') ? 1 : 9, 'order_id' => $album['total_pictures'] + $album['total_pictures_i'] + 1); // Do we have extras? if ($extra) { // Merge extras $picture = array_merge($picture, $extra); } // Save picture $pictureID = $this->db->insert('pictures_data', $picture); // Do we have picture ID? if ($pictureID) { // Update album's counter $column = $picture['active'] == 1 ? 'total_pictures' : 'total_pictures_i'; $this->db->query("UPDATE `:prefix:pictures_albums_data` SET `{$column}`=`{$column}`+1 WHERE `user_id`=? AND `album_id`=? LIMIT 1", array(session::item('user_id'), $albumID)); $this->db->query("UPDATE `:prefix:users` SET `{$column}`=`{$column}`+1 WHERE `user_id`=? LIMIT 1", array(session::item('user_id'))); // Does album have a cover? if (!$album['picture_id']) { // Update album cover $this->pictures_albums_model->updateCover($albumID, $pictureID); } // Did we have any activity in the past hour? if (session::item('timeline_picture_post', 'config') === false || session::item('timeline_picture_post', 'config')) { if ($action = timeline_helper::get('picture_post', session::item('user_id'), $albumID, 12)) { $counter = isset($action['params']['count']) ? $action['params']['count'] + 1 : 1; // Update activity timeline_helper::update($action['action_id'], 'picture_post', session::item('user_id'), $albumID, $picture['active'], false, array('count' => $counter), $action['attachments'] < 5 ? $fileID : false); } else { // Save activity timeline_helper::save('picture_post', session::item('user_id'), $albumID, $picture['active'], $album['privacy'], array('count' => 1), $fileID); } } // Action hook hook::action('pictures/insert', $pictureID, $picture); } return $pictureID; }
public function checkExpiration() { // Get expired users $users = $this->db->query("SELECT * FROM `:prefix:users` WHERE `expire_date`>0 AND `expire_date`<?", array(date_helper::now()))->result(); foreach ($users as $user) { $this->db->query("UPDATE `:prefix:users` SET `group_id`=?, `old_group_id`=0, `expire_date`=0 WHERE `user_id`=? LIMIT 1", array($user['old_group_id'] ? $user['old_group_id'] : config::item('group_default_id', 'users'), $user['user_id'])); } // Action hook hook::action('billing/plans/check_expiration'); $this->cron_model->addLog('[Billing] Processed ' . count($users) . ' expired subscriptions.'); }
<?php } ?> <?php echo html_helper::anchor('classifieds/view/' . $ad['ad_id'] . '/' . text_helper::slug($ad['data_title'], 100), '<span class="name">' . $ad['data_title'] . '</span>', array('class' => 'image')); ?> </div> </figure> <header class="item-header"> <h2> <?php echo html_helper::anchor('classifieds/view/' . $ad['ad_id'] . '/' . text_helper::slug($ad['data_title'], 100), $ad['data_title']); ?> <?php if ($ad['post_date'] < date_helper::now() - config::item('ad_expiration', 'classifieds') * 60 * 60 * 24) { ?> - <?php echo __('ad_expired', 'classifieds'); ?> <?php } ?> </h2> </header> <dl class="content-grid"> <?php if (isset($ad['data_price'])) { ?> <dt><?php
<div class="row"> <label> <?php echo __('picture_current', 'users_picture'); ?> </label> <div class="field"> <figure class="image users-image" id="uploader_picture_view"> <?php if (session::item('picture', 'signup', 'file_id')) { ?> <?php view::load('users/profile/elements/picture', array('picture_file_service_id' => session::item('picture', 'signup', 'service_id'), 'picture_file_path' => session::item('picture', 'signup', 'path'), 'picture_file_name' => session::item('picture', 'signup', 'name'), 'picture_file_ext' => session::item('picture', 'signup', 'extension'), 'picture_file_modify_date' => date_helper::now(), 'picture_file_suffix' => 'p', 'picture_active' => 1, 'picture_url' => true)); ?> <figcaption class="image-caption"> <?php /*<?=html_helper::anchor('#', __('picture_change', 'users_picture'), array('onclick' => "\$('#signup_uploader_form').toggle();return false;"))?> -*/ ?> <?php echo html_helper::anchor('users/signup/thumbnail', __('picture_thumbnail_edit', 'system_files')); ?> - <?php echo html_helper::anchor('users/signup/picture/delete', __('picture_delete', 'users_picture'), array('data-html' => __('picture_delete?', 'users_picture'), 'data-role' => 'confirm')); ?> </figcaption>
public function saveFile($fileID, $parentID, $serviceID, $resourceID, $userID, $data) { // Is this a new file if (!$fileID) { $data['parent_id'] = $parentID; $data['resource_id'] = $resourceID; $data['service_id'] = $serviceID; $data['user_id'] = $userID; $data['post_date'] = date_helper::now(); // Save file $fileID = $this->db->insert('storage_files', $data); } else { $data['modify_date'] = date_helper::now(); // Update file $this->db->update('storage_files', $data, array('file_id' => $fileID), 1); if ($parentID) { $this->db->update('storage_files', array('modify_date' => date_helper::now()), array('file_id' => $parentID), 1); } } return $fileID; }
public function saveLike($resource, $userID, $itemID, $like, $table = '', $column = '') { // Get resource ID if (!($resourceID = config::item('resources', 'core', $resource, 'resource_id'))) { return false; } // Get table and column names $table = $table ? $table : config::item('resources', 'core', $resource, 'table'); $column = $column ? $column : config::item('resources', 'core', $resource, 'column'); $data = array('resource_id' => $resourceID, 'item_id' => $itemID, 'user_id' => session::item('user_id')); // Like if ($like) { $data['post_date'] = date_helper::now(); // Update total likes if ($retval = $this->db->query("UPDATE `:prefix:" . $table . "` SET `total_likes`=`total_likes`+1 WHERE `" . $column . "`=? LIMIT 1", array($itemID))) { // Save like $this->db->insert('core_likes', $data); // Action hook hook::action('likes/insert', session::item('user_id'), $resourceID, $itemID); // Do we have user id? if ($userID && $userID != session::item('user_id')) { // Save notification timeline_helper::notice($resource . '_like', $userID, session::item('user_id'), $itemID); } } } else { // Update total likes if ($retval = $this->db->query("UPDATE `:prefix:" . $table . "` SET `total_likes`=`total_likes`-1 WHERE `" . $column . "`=? LIMIT 1", array($itemID))) { // Save like if ($this->db->delete('core_likes', $data, 1)) { // Action hook hook::action('likes/unlike', session::item('user_id'), $resourceID, $itemID); // Delete notification timeline_helper::unnotice($resource . '_like', $userID, session::item('user_id'), $itemID); } } } return $retval; }
public function saveVote($resource, $userID, $itemID, $score, $table = '', $column = '') { // Get resource ID if (!($resourceID = config::item('resources', 'core', $resource, 'resource_id'))) { return false; } // Get table and column names $table = $table ? $table : config::item('resources', 'core', $resource, 'table'); $column = $column ? $column : config::item('resources', 'core', $resource, 'column'); $data = array('resource_id' => $resourceID, 'item_id' => $itemID, 'user_id' => session::item('user_id'), 'score' => $score, 'post_date' => date_helper::now()); // Update total votes and score $retval = $this->db->query("UPDATE `:prefix:" . $table . "`\n\t\t\tSET `total_votes`=`total_votes`+1, `total_score`=`total_score`+?, `total_rating`=`total_score`/`total_votes`\n\t\t\tWHERE `" . $column . "`=? LIMIT 1", array($score, $itemID)); if ($retval) { // Save vote $this->db->insert('core_votes', $data); // Action hook hook::action('votes/insert', session::item('user_id'), $resourceID, $itemID, $score); // Do we have user id? if ($userID != session::item('user_id')) { // Save notification timeline_helper::notice($resource . '_vote', $userID, session::item('user_id'), $itemID); } } return $retval; }
public function cleanup() { // Remove old sessions $this->db->query("DELETE FROM `:prefix:users_sessions` WHERE `active_date`<?", array(date_helper::now() - 60 * 60 * 24)); $this->cron_model->addLog('[Users] Deleted old user sessions.'); // Remove profile pictures uploaded by unregistered users older than 24 hours $resourceID = config::item('resources', 'core', 'user', 'resource_id'); $files = $this->db->query("SELECT `file_id` FROM `:prefix:storage_files` WHERE `resource_id`=? AND `user_id`=0 AND `parent_id`=0 AND `post_date`<?", array($resourceID, date_helper::now() - 60 * 60 * 24))->result(); foreach ($files as $file) { $this->storage_model->deleteFiles($file['file_id'], 5); } $this->cron_model->addLog('[Users] Deleted ' . count($files) . ' incomplete profile pictures.'); }
public function cleanup() { $this->db->query("DELETE FROM `:prefix:core_counters` WHERE (`post_date`+`expiration`*60)<?", array(date_helper::now())); $this->cron_model->addLog('[System] Deleted expired search counters.'); }
public function vote() { // Is user logged in? if (!users_helper::isLoggedin()) { view::ajaxError(__('no_login', 'system_info'), 403); } // Get vars $resource = input::post_get('resource'); $itemID = (int) input::post_get('item_id'); $score = (int) input::post_get('score'); // Get resource ID $resourceID = config::item('resources', 'core', $resource, 'resource_id'); if (!$resourceID || !$itemID || $score < 1 || $score > 5) { return false; } // Load votes model loader::model('comments/votes'); // Get resource item and vote if exists $item = $this->votes_model->getResourceVote($resource, $itemID); // Do resource or vote exist? if (!$item || $item['post_date']) { return false; } // Save vote if (!$this->votes_model->saveVote($resource, isset($item['user_id']) ? $item['user_id'] : 0, $itemID, $score)) { if (!validate::getTotalErrors()) { view::setError(__('save_error', 'system')); } return false; } $rating = number_format(($item['total_score'] + $score) / ($item['total_votes'] + 1), 2); $params = array('resource' => $resource, 'itemID' => $itemID, 'votes' => $item['total_votes'] + 1, 'score' => $item['total_score'], 'rating' => $rating, 'voted' => $score, 'date' => date_helper::now()); $output = view::load('comments/rating', $params, true); view::ajaxResponse($output); }
protected function parseCounters($params = array()) { // Get fields $filters = array(); if (count(config::item('usertypes', 'core', 'keywords')) > 1) { // Set extra fields $filters[] = array('name' => __('user_type', 'users'), 'type' => 'select', 'keyword' => 'type_id', 'items' => config::item('usertypes', 'core', 'names'), 'select' => 1); foreach (config::item('usertypes', 'core', 'keywords') as $id => $type) { $filters['types'][$id] = $this->fields_model->getFields('users', $id, 'edit', input::get('a') ? 'in_search_advanced' : 'in_search', true); } } else { $filters = $this->fields_model->getFields('users', config::item('type_default_id', 'users'), 'edit', input::get('a') ? 'in_search_advanced' : 'in_search', true); } // Additional options $options = array(); // Pictures if (config::item('search_option_picture', 'users')) { $options['pictures'] = __('search_option_picture', 'users', array(), array(), false); } // Online if (config::item('search_option_online', 'users')) { $options['online'] = __('search_option_online', 'users', array(), array(), false); } if ($options) { $filters[] = array('name' => __('search_options', 'system', array(), array(), false), 'type' => 'checkbox', 'keyword' => 'search_options', 'items' => $options); } // Assign vars view::assign(array('filters' => $filters, 'values' => array())); // Did user submit the filter form? if (input::post_get('do_search')) { $values = array(); $params['total'] = $params['max'] = 0; // Check extra pictures field $pictures = in_array('pictures', input::post_get('search_options', array())); if ($pictures) { $params['join_columns'][] = "`u`.`picture_id`!='' AND `u`.`picture_active`=1"; $values['search_options'][] = 'pictures'; } // Check extra online field $online = in_array('online', input::post_get('search_options', array())); if ($online) { $params['join_columns'][] = "`u`.`visit_date`>=" . (date_helper::now() - 60 * 5); $values['search_options'][] = 'online'; } // Check extra type field $typeID = count(config::item('usertypes', 'core', 'keywords')) > 1 ? input::post_get('type_id') : config::item('type_default_id', 'users'); if (config::item('usertypes', 'core', 'keywords', $typeID)) { $params['join_columns'][] = '`u`.`type_id`=' . $typeID; $values['type_id'] = $typeID; // Search users $searchID = $this->search_model->searchData('profile', $filters, $params['join_columns'], $values, array('type_id' => $typeID)); // Do we have any search terms? if ($searchID == 'no_terms') { view::setError(__('search_no_terms', 'system')); } elseif ($searchID == 'no_results') { view::setError(__('search_no_results', 'system')); return $params; } else { router::redirect('users/results?' . (input::get('a') ? 'a=1&' : '') . 'search_id=' . $searchID); } } else { view::setError(__('search_no_type', 'users')); } } // Do we have a search ID? if (!input::post_get('do_search') && input::get('search_id')) { // Get search if (!($search = $this->search_model->getSearch(input::get('search_id')))) { view::setError(__('search_expired', 'system')); router::redirect('users'); } // Set results $params['join_columns'] = $search['conditions']['columns']; $params['join_items'] = $search['conditions']['items']; $params['values'] = $search['values']; $params['total'] = $search['results']; $params['max'] = config::item('max_search_results', 'system') && config::item('max_search_results', 'system') < $params['total'] ? config::item('max_search_results', 'system') : $params['total']; // Assign vars view::assign(array('values' => $search['values'])); } return $params; }
public function cleanup() { $this->db->query("DELETE FROM `:prefix:core_search` WHERE `post_date`<?", array(date_helper::now() - 60 * 60 * 12)); $this->cron_model->addLog('[System] Deleted expired search queries.'); }
public function countRecentComments() { $time = date_helper::now() - session::permission('comments_delay_time', 'comments') * (session::permission('comments_delay_type', 'comments') == 'minutes' ? 60 : 3600); $comments = $this->db->query("SELECT COUNT(*) AS `totalrows`\n\t\t\tFROM `:prefix:core_comments`\n\t\t\tWHERE `poster_id`=? AND `post_date`>?", array(session::item('user_id'), $time))->row(); return $comments['totalrows']; }
public function finalize() { $this->db->update('core_config', array('val' => date('Ymd', date_helper::now())), array('plugin' => 'system', 'keyword' => 'cron_last_run'), 1); return true; }