public function deleteEntry($newsID, $news) { // Delete entry $retval = $this->fields_model->deleteValues('news', $newsID); if ($retval) { // Delete comments if ($news['total_comments']) { loader::model('comments/comments'); $this->comments_model->deleteComments('news', $newsID, $news['total_comments']); } // Delete likes if ($news['total_likes']) { loader::model('comments/likes'); $this->likes_model->deleteLikes('news', $newsID, $news['total_likes']); } // Delete votes if ($news['total_votes']) { loader::model('comments/votes'); $this->votes_model->deleteVotes('news', $newsID, $news['total_votes']); } // Action hook hook::action('news/delete', $newsID, $news); } return $retval; }
public function deleteType($typeID, $type) { loader::library('dbforge'); $this->dbforge->dropTable(':prefix:users_data_' . $type['keyword']); // Delete user type if ($retval = $this->db->delete('users_types', array('type_id' => $typeID), 1)) { // Update order IDs $this->db->query("UPDATE `:prefix:users_types` SET `order_id`=`order_id`-1 WHERE `order_id`>?", array($type['order_id'])); // Select fields IDs $fieldIDs = array(); foreach ($this->db->query("SELECT `field_id`, `category_id`, `keyword` FROM `:prefix:core_fields` WHERE `category_id`=?", array($typeID))->result() as $field) { $fieldIDs[] = $field['field_id']; } // Do we have any field IDs? if ($fieldIDs) { // Delete field items $this->db->query("DELETE FROM `:prefix:core_fields_items` WHERE `field_id` IN (" . implode(',', $fieldIDs) . ")"); } // Delete fields $this->db->delete('core_fields', array('category_id' => $typeID)); // Action hook hook::action('users/types/delete', $typeID, $type); } $this->cache->cleanup(); return $retval; }
public function initialize($config = array()) { $this->data = array(); if (isset($config['cache']) && !$config['cache'] || !($this->data = $this->cache->item('core_config_' . (input::isCP() ? 'cp' : 'fe'), true)) || isset($this->data['settings']['system']['devmode']) && $this->data['settings']['system']['devmode']) { if (isset($this->data['settings']['system']['devmode'])) { $this->cache->cleanup(); } $this->getSettings(); $this->getPlugins(); $this->getResources(); $this->getHooks(); $this->getLanguages(); $this->getTemplates(); $this->getStorages(); $this->cache->set('core_config_' . (input::isCP() ? 'cp' : 'fe'), $this->data, 60 * 60 * 24 * 30, true); } $this->setSettings(); $this->setPlugins(); $this->setResources(); $this->setHooks(); $this->setLanguages(); $this->setTemplates(); $this->setStorages(); hook::action('initialize'); }
public function __construct($tabs = true, $loggedin = true) { parent::__construct(); // Is user loggedin ? if ($loggedin && !users_helper::isLoggedin()) { router::redirect('users/login'); } // Set trail view::setTrail(session::item('slug'), __('my_profile', 'system_navigation')); view::setTrail('users/settings', __('settings', 'users')); // Set tabs if ($tabs) { view::setTab('users/settings', __('settings', 'users'), array('class' => (uri::segment(1) == 'users' && uri::segment(2) == 'settings' && (!uri::segment(3) || in_array(uri::segment(3), array('email', 'password', 'username', 'cancel'))) || uri::segment(1) == 'billing' && uri::segment(2) != 'invoices' ? 'active' : '') . ' icon-users-settings')); if (config::item('privacy_edit', 'users')) { view::setTab('users/settings/privacy', __('privacy', 'users'), array('class' => (uri::segment(1) == 'users' && uri::segment(3) == 'privacy' ? 'active' : '') . ' icon-users-privacy')); } if (config::item('notifications_edit', 'users')) { view::setTab('users/settings/notifications', __('notifications', 'users'), array('class' => (uri::segment(1) == 'users' && uri::segment(3) == 'notifications' ? 'active' : '') . ' icon-users-notifications')); } if (config::item('blacklist_active', 'users')) { view::setTab('users/blocked', __('blacklist', 'users'), array('class' => (uri::segment(1) == 'users' && uri::segment(2) == 'blocked' ? 'active' : '') . ' icon-users-blacklist')); } } // Filter hook hook::action('users/settings/tabs'); }
public function deleteUser($userID, $user) { // Delete messages $retval = $this->db->query("DELETE FROM `:prefix:timeline_messages` WHERE `user_id`=? OR `poster_id`=?", array($userID, $userID)); // Action hook hook::action('timeline/messages/delete_user', $userID, $user); return $retval; }
public function deleteBanner($groupID, $bannerID, $banner) { $retval = $this->db->delete('banners_data', array('banner_id' => $bannerID), 1); if ($retval) { // Action hook hook::action('banners/delete', $bannerID, $banner); } return $retval; }
public function deleteUser($userID, $user) { // Delete reports $retval = $this->db->query("DELETE FROM `:prefix:reports` WHERE `user_id`=? OR `poster_id`=?", array($userID, $userID)); if ($retval) { // Action hook hook::action('reports/delete_user', $userID, $user); } return $retval; }
public function toggleItemStatus($plugin, $type, $keyword, $status) { $retval = $this->db->update('core_lists', array('active' => $status), array('plugin' => $plugin, 'type' => $type, 'keyword' => $keyword), 1); if ($retval) { // Action hook hook::action('system/templates/navigation/status', $plugin, $type, $keyword, $status); } $this->cache->cleanup(); return $retval; }
public function process($userID, $productID, $params) { // Get credits package $package = $this->getPackage($productID); // Update total credits $retval = $this->addCredits($userID, $package['credits']); // Action hook hook::action('billing/credits/process', $productID, $userID, $package['credits']); return $retval; }
public function saveMetaTags($plugin, $keyword, $data) { $retval = $this->db->update('core_meta_tags', $data, array('plugin' => $plugin, 'keyword' => $keyword), 1); if ($retval) { // Action hook hook::action('system/seo/update', $plugin, $keyword, $data); } $this->cache->cleanup(); return $retval; }
public function sendFeedback($email, $subject, $message) { loader::library('email'); $this->email->reply($email); $retval = $this->email->sendEmail(config::item('feedback_email', 'feedback'), $subject, $message); if ($retval) { // Action hook hook::action('feedback/send/post', $email, $subject, $message); } return $retval; }
public function deleteGroup($groupID, $group) { // Delete banner group $retval = $this->db->delete('banners_groups', array('group_id' => $groupID), 1); if ($retval) { // Delete banners $this->db->delete('banners_data', array('group_id' => $groupID)); // Action hook hook::action('banners/groups/delete', $groupID, $group); } return $retval; }
public function deleteUser($userID, $user) { // Get users $users = $this->db->query("SELECT * FROM `:prefix:users_blocked` WHERE `blocked_id`=?", array($userID))->result(); foreach ($users as $user) { $this->db->query("UPDATE `:prefix:users` SET `total_blocked`=`total_blocked`-1 WHERE `user_id`=? LIMIT 1", array($user['user_id'])); } // Delete blocked users $retval = $this->db->query("DELETE FROM `:prefix:users_blocked` WHERE `user_id`=? OR `blocked_id`=?", array($userID, $userID)); // Action hook hook::action('users/blocked/delete_user', $userID, $user); return $retval; }
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 saveSetting($plugin, $keyword, $value, $orderID = false) { $data = array('val' => $value); if ($orderID !== false) { $data['order_id'] = $orderID; } $retval = $this->db->update('core_config', $data, array('plugin' => $plugin, 'keyword' => $keyword), 1); if ($retval) { // Action hook hook::action('system/settings/update', $plugin, $keyword, $value, $orderID); } session::delete('', 'config'); $this->cache->cleanup(); 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; }
<?php if ($user['group_id'] != config::item('group_cancelled_id', 'users') && $user['verified'] && $user['active']) { ?> <?php if (config::item('messages_active', 'messages')) { ?> <li><?php echo html_helper::anchor('messages/send/' . $user['slug_id'], __('message_send', 'users')); ?> </li> <?php } } ?> <?php echo hook::action('users/profile/browse/actions', $user);
public function uninstall($captchaID, $captcha) { // Delete captcha $retval = $this->db->delete('security_captcha', array('captcha_id' => $captchaID), 1); if ($retval) { // Action hook hook::action('security/forms/uninstall', $captchaID, $captcha); } return $retval; }
public function deleteUser($userID, $user) { // Get friends $friends = $this->db->query("SELECT * FROM `:prefix:users_friends` WHERE `user_id`=? OR `friend_id`=?", array($userID, $userID))->result(); foreach ($friends as $friend) { if ($friend['active']) { $this->db->query("UPDATE `:prefix:users` SET `total_friends`=`total_friends`-1 WHERE `user_id`=? LIMIT 1", array($friend['user_id'] == $userID ? $friend['friend_id'] : $friend['user_id'])); } elseif ($friend['user_id'] == $userID) { $this->db->query("UPDATE `:prefix:users` SET `total_friends_i`=`total_friends_i`-1 WHERE `user_id`=? LIMIT 1", array($friend['friend_id'])); } } // Delete friends $retval = $this->db->query("DELETE FROM `:prefix:users_friends` WHERE `user_id`=? OR `friend_id`=?", array($userID, $userID)); // Action hook hook::action('users/friends/delete_user', $userID, $user); return $retval; }
public function deletePictures($adID, $userID, $ad) { // Do we have any pictures? if (!($ad['total_pictures'] + $ad['total_pictures_i'])) { return true; } $pictureIDs = $fileIDs = array(); // Get picture and file IDs $result = $this->db->query("SELECT `picture_id`, `file_id` FROM `:prefix:classifieds_pictures_data` WHERE `ad_id`=? LIMIT ?", array($adID, $ad['total_pictures'] + $ad['total_pictures_i']))->result(); foreach ($result as $picture) { $pictureIDs[] = $picture['picture_id']; $fileIDs[] = $picture['file_id']; } // Delete pictures if ($pictureIDs) { $retval = $this->fields_model->deleteValues('classified_picture', $adID, $ad['total_pictures'] + $ad['total_pictures_i'], '', 'ad_id'); // Delete pictures if ($retval) { // Delete files $this->storage_model->deleteFiles($fileIDs, 3); // Delete reports loader::model('reports/reports'); $this->reports_model->deleteReports('classified_picture', $pictureIDs); } } // Action hook hook::action('classifieds/pictures/delete_multiple', $pictureIDs, $ad); return true; }
public function deleteUser($userID, $user, $update = false) { // Load pictures model loader::model('classifieds/pictures', array(), 'classifieds_pictures_model'); // Get ad IDs $result = $this->db->query("SELECT * FROM `:prefix:classifieds_data` WHERE `user_id`=? LIMIT ?", array($userID, $user['total_classifieds'] + $user['total_classifieds_i']))->result(); foreach ($result as $ad) { // Delete pictures $this->classifieds_pictures_model->deletePictures($ad['ad_id'], $userID, $ad); } $retval = $this->fields_model->deleteValues('classified_ad', $userID, $user['total_classifieds'] + $user['total_classifieds_i'], '', 'user_id'); if ($update) { // Update user counters $this->db->update('users', array('total_classifieds' => 0, 'total_classifieds_i' => 0), array('user_id' => $userID), 1); } // Action hook hook::action('classifieds/delete_user', $userID, $user); return $retval; }
public function deleteFiles($fileID, $limit = 1) { $files = $this->getFiles($fileID, $limit); if (!$files) { return true; } $services = array(); foreach ($files as $file) { // Did we already load storage library? if (!isset($services[$file['service_id']])) { // Get storage service and settings $service = config::item('storages', 'core', $file['service_id']); $settings = config::item('storages', 'core', 'settings', $file['service_id']); // Load library loader::library('storages/' . $service, $settings, 'storage_' . $service); $services[$file['service_id']] = true; } $this->{'storage_' . $service}->delete($file['path'], $file['name'], $file['extension'], $file['suffix']); } if (is_array($fileID)) { $retval = $this->db->query("DELETE FROM `:prefix:storage_files` WHERE `file_id` IN (?) OR `parent_id` IN (?) LIMIT ?", array($fileID, $fileID, count($files))); } else { $retval = $this->db->query("DELETE FROM `:prefix:storage_files` WHERE `file_id`=? OR `parent_id`=? LIMIT ?", array($fileID, $fileID, count($files))); } if ($retval) { // Action hook hook::action('system/storage/files/delete', $fileID, $files); } return $retval; }
public function uninstall($languageID, $language) { // Delete language $retval = $this->db->delete('core_languages', array('language_id' => $languageID), 1); if ($retval) { // Update users with the new system language ID $this->db->update('users', array('language_id' => config::item('language_id', 'system')), array('language_id' => $languageID)); // Load dbforge library loader::library('dbforge'); // Languages $this->dbforge->dropColumns(':prefix:core_languages_data', array('value_' . $language['keyword'])); // Email templates $this->dbforge->dropColumns(':prefix:core_email_templates', array('subject_' . $language['keyword'])); $this->dbforge->dropColumns(':prefix:core_email_templates', array('message_html_' . $language['keyword'])); $this->dbforge->dropColumns(':prefix:core_email_templates', array('message_text_' . $language['keyword'])); // Meta tags $this->dbforge->dropColumns(':prefix:core_meta_tags', array('meta_title_' . $language['keyword'])); $this->dbforge->dropColumns(':prefix:core_meta_tags', array('meta_description_' . $language['keyword'])); $this->dbforge->dropColumns(':prefix:core_meta_tags', array('meta_keywords_' . $language['keyword'])); // Custom fields $this->dbforge->dropColumns(':prefix:core_fields', array('name_' . $language['keyword'])); $this->dbforge->dropColumns(':prefix:core_fields', array('sname_' . $language['keyword'])); $this->dbforge->dropColumns(':prefix:core_fields', array('vname_' . $language['keyword'])); $this->dbforge->dropColumns(':prefix:core_fields', array('validate_error_' . $language['keyword'])); $this->dbforge->dropColumns(':prefix:core_fields_items', array('name_' . $language['keyword'])); $this->dbforge->dropColumns(':prefix:core_fields_items', array('sname_' . $language['keyword'])); // Geo data foreach (array('countries', 'states', 'cities') as $table) { $this->dbforge->dropColumns(':prefix:geo_' . $table, array('name_' . $language['keyword'])); } // Report subjects $this->dbforge->dropColumns(':prefix:reports_subjects', array('name_' . $language['keyword'])); if ($languageID == session::item('language_id')) { session::set('language', config::item('language_id', 'system')); session::delete('', 'config'); } // Action hook hook::action('system/languages/uninstall', $languageID, $language['keyword']); $this->cache->cleanup(); } return $retval; }
public function deleteUser($userID, $user) { $data = array(); $result = $this->db->query("SELECT * FROM `:prefix:core_likes` WHERE `user_id`=?", array($userID))->result(); foreach ($result as $like) { // Get resource ID if (!($resource = config::item('resources', 'core', $like['resource_id']))) { return false; } $table = config::item('resources', 'core', $resource, 'table'); $column = config::item('resources', 'core', $resource, 'column'); // Update total likes $retval = $this->db->query("UPDATE `:prefix:" . $table . "` SET `total_likes`=`total_likes`-1 WHERE `" . $column . "`=? LIMIT 1", array($like['item_id'])); } // Delete likes $retval = $this->db->query("DELETE FROM `:prefix:core_likes` WHERE `user_id`=?", array($userID)); // Action hook hook::action('likes/delete_user', $userID, $user); return $retval; }
public function deleteUser($userID, $user) { $data = array(); $result = $this->db->query("SELECT * FROM `:prefix:core_comments` WHERE `poster_id`=?", array($userID))->result(); foreach ($result as $comment) { // Get resource ID if (!($resource = config::item('resources', 'core', $comment['resource_id']))) { return false; } if (!isset($data[$resource])) { $data[$resource] = array('resource' => $comment['resource_id'], 'table' => config::item('resources', 'core', $resource, 'table'), 'column' => config::item('resources', 'core', $resource, 'column'), 'items' => array()); } if (!isset($data[$resource]['items'][$comment['item_id']])) { $data[$resource]['items'][$comment['item_id']] = 0; } $data[$resource]['items'][$comment['item_id']]++; } foreach ($data as $resource => $items) { foreach ($items['items'] as $itemID => $total) { // Update comment count $this->db->query("UPDATE `:prefix:" . $items['table'] . "` SET `total_comments`=`total_comments`-? WHERE `" . $items['column'] . "`=? LIMIT 1", array($total, $itemID)); } } // Delete comments $retval = $this->db->query("DELETE FROM `:prefix:core_comments` WHERE `user_id`=? OR `poster_id`=?", array($userID, $userID)); // Action hook hook::action('comments/delete_user', $userID, $user); return $retval; }
public function deleteUser($userID, $user) { $data = array(); $result = $this->db->query("SELECT * FROM `:prefix:core_votes` WHERE `user_id`=?", array($userID))->result(); foreach ($result as $vote) { // Get resource ID if (!($resource = config::item('resources', 'core', $vote['resource_id']))) { return false; } $table = config::item('resources', 'core', $resource, 'table'); $column = config::item('resources', 'core', $resource, 'column'); // Update total votes and score $retval = $this->db->query("UPDATE `:prefix:" . $table . "`\n\t\t\t\tSET `total_votes`=`total_votes`-1, `total_score`=`total_score`-?, `total_rating`=`total_score`/`total_votes`\n\t\t\t\tWHERE `" . $column . "`=? LIMIT 1", array($vote['score'], $vote['item_id'])); } // Delete votes $retval = $this->db->query("DELETE FROM `:prefix:core_votes` WHERE `user_id`=?", array($userID)); // Action hook hook::action('votes/delete_user', $userID, $user); return $retval; }
public function deletePage($pageID, $page) { // Get children IDs $pageIDs = array($pageID); foreach ($this->getChildren($pageID) as $page) { $pageIDs[] = $page['page_id']; } // Delete pages $retval = $this->fields_model->deleteValues('page', $pageIDs, count($pageIDs)); if ($retval) { // Update order IDs $this->db->query("UPDATE `:prefix:pages_data` SET `order_id`=`order_id`-1 WHERE `parent_id`=? AND `order_id`>?", array($page['parent_id'], $page['order_id'])); // Load models loader::model('comments/comments'); loader::model('comments/likes'); loader::model('comments/votes'); // Delete comments, like, votes $this->comments_model->deleteComments('page', $pageIDs); $this->likes_model->deleteLikes('page', $pageIDs); $this->votes_model->deleteVotes('page', $pageIDs); // Action hook hook::action('pages/delete_multiple', $pageIDs); } return $retval; }
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.'); }
public function saveCity($countryID, $stateID, $cityID, $data) { if ($data['name_' . config::item('languages', 'core', 'keywords', config::item('language_id', 'system'))]) { $data['name'] = $data['name_' . config::item('languages', 'core', 'keywords', config::item('language_id', 'system'))]; } if ($cityID) { $retval = $this->db->update('geo_cities', $data, array('city_id' => $cityID), 1); // Action hook hook::action('system/geo/cities/update', $cityID, $data); } else { $data['country_id'] = $countryID; $data['state_id'] = $stateID; $retval = $this->db->insert('geo_cities', $data); // Action hook hook::action('system/geo/cities/insert', $retval, $data); } return $retval; }
public function uninstall($gateway) { // Delete gateway $retval = $this->db->delete('billing_gateways', array('gateway_id' => $gateway['gateway_id']), 1); if ($retval) { // Action hook hook::action('billing/gateways/uninstall', $gateway['gateway_id'], $gateway); } return $retval; }