Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 3
0
 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;
 }
Exemplo n.º 4
0
 public function browse()
 {
     // Parameters
     $params = array('join_columns' => array(), 'join_items' => array());
     // Process filters
     $params = $this->parseCounters($params);
     // Process query string
     $qstring = $this->parseQuerystring($params['total']);
     // Actions
     $actions = array(0 => __('select', 'system'), 'approve' => __('approve', 'system'), 'decline' => __('decline', 'system'), 'delete' => __('delete', 'system'));
     // Check form action
     if (input::post('do_action')) {
         // Delete selected blogs
         if (input::post('action') && isset($actions[input::post('action')]) && input::post('blog_id') && is_array(input::post('blog_id'))) {
             foreach (input::post('blog_id') as $blogID) {
                 $blogID = (int) $blogID;
                 if ($blogID && $blogID > 0) {
                     $this->action(input::post('action'), $blogID);
                 }
             }
         }
         // Success
         view::setInfo(__('action_applied', 'system'));
         router::redirect('cp/plugins/blogs?' . $qstring['url'] . 'page=' . $qstring['page']);
     }
     // Get blogs
     $blogs = array();
     if ($params['total']) {
         $blogs = $this->blogs_model->getBlogs('in_list', $params['join_columns'], $params['join_items'], $qstring['order'], $qstring['limit']);
     }
     // Create table grid
     $grid = array('uri' => 'cp/plugins/blogs', 'keyword' => 'blogs', 'header' => array('check' => array('html' => 'blog_id', 'class' => 'check'), 'data_title' => array('html' => __('name', 'system'), 'class' => 'name', 'sortable' => true), 'user' => array('html' => __('user', 'system'), 'class' => 'user'), 'post_date' => array('html' => __('post_date', 'system'), 'class' => 'date', 'sortable' => true), 'status' => array('html' => __('status', 'system'), 'class' => 'status'), 'actions' => array('html' => __('actions', 'system'), 'class' => 'actions')), 'content' => array());
     // Create grid content
     foreach ($blogs as $blog) {
         if ($blog['active'] == 1) {
             $status = html_helper::anchor('cp/plugins/blogs/decline/' . $blog['blog_id'] . '?' . $qstring['url'] . 'page=' . $qstring['page'], __('active', 'system'), array('class' => 'label small success'));
         } else {
             $status = html_helper::anchor('cp/plugins/blogs/approve/' . $blog['blog_id'] . '?' . $qstring['url'] . 'page=' . $qstring['page'], $blog['active'] ? __('pending', 'system') : __('inactive', 'system'), array('class' => 'label small ' . ($blog['active'] ? 'info' : 'important')));
         }
         $grid['content'][] = array('check' => array('html' => $blog['blog_id']), 'data_title' => array('html' => html_helper::anchor('cp/plugins/blogs/edit/' . $blog['blog_id'], text_helper::truncate($blog['data_title'], 64))), 'user' => array('html' => users_helper::anchor($blog['user'])), 'post_date' => array('html' => date_helper::formatDate($blog['post_date'])), 'status' => array('html' => $status), 'actions' => array('html' => array('edit' => html_helper::anchor('cp/plugins/blogs/edit/' . $blog['blog_id'], __('edit', 'system'), array('class' => 'edit')), 'delete' => html_helper::anchor('cp/plugins/blogs/delete/' . $blog['blog_id'] . '?' . $qstring['url'] . 'page=' . $qstring['page'], __('delete', 'system'), array('data-html' => __('blog_delete?', 'blogs'), 'data-role' => 'confirm', 'class' => 'delete')))));
     }
     // Set pagination
     $config = array('base_url' => config::siteURL('cp/plugins/blogs?' . $qstring['url']), 'total_items' => $params['total'], 'items_per_page' => $this->blogsPerPage, 'current_page' => $qstring['page'], 'uri_segment' => 'page');
     $pagination = loader::library('pagination', $config, null);
     // Filter hooks
     hook::filter('cp/plugins/blogs/browse/grid', $grid);
     hook::filter('cp/plugins/blogs/browse/actions', $actions);
     // Assign vars
     view::assign(array('grid' => $grid, 'actions' => $actions, 'pagination' => $pagination));
     // Set title
     view::setTitle(__('blogs_manage', 'system_navigation'));
     // Set trail
     if ($qstring['search_id']) {
         view::setTrail('cp/plugins/blogs?' . $qstring['url'] . 'page=' . $qstring['page'], __('search_results', 'system'));
     }
     // Assign actions
     view::setAction('#', __('search', 'system'), array('class' => 'icon-text icon-system-search', 'onclick' => '$(\'#blogs-search\').toggle();return false;'));
     // Load view
     view::load('cp/plugins/blogs/browse');
 }
Exemplo n.º 5
0
 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;
 }
Exemplo n.º 6
0
 public function browse()
 {
     // Parameters
     $params = array('join_columns' => array(), 'join_items' => array());
     // Process filters
     $params = $this->parseCounters($params);
     // Process query string
     $qstring = $this->parseQuerystring($params['total']);
     // Actions
     $actions = array(0 => __('select', 'system'), 'delete' => __('delete', 'system'));
     // Check form action
     if (input::post('do_action')) {
         // Delete selected news
         if (input::post('action') == 'delete') {
             if (input::post('news_id') && is_array(input::post('news_id'))) {
                 foreach (input::post('news_id') as $newsID) {
                     $newsID = (int) $newsID;
                     if ($newsID && $newsID > 0) {
                         $this->delete($newsID);
                     }
                 }
             }
         }
         // Success
         view::setInfo(__('action_applied', 'system'));
         router::redirect('cp/content/news?' . $qstring['url'] . 'page=' . $qstring['page']);
     }
     // Get news
     $news = array();
     if ($params['total']) {
         $news = $this->news_model->getEntries('in_list', $params['join_columns'], $params['join_items'], $qstring['order'], $qstring['limit']);
     }
     // Create table grid
     $grid = array('uri' => 'cp/content/news', 'keyword' => 'news', 'header' => array('check' => array('html' => 'news_id', 'class' => 'check'), 'data_title_' . session::item('language') => array('html' => __('name', 'system'), 'class' => 'name', 'sortable' => true), 'post_date' => array('html' => __('post_date', 'system'), 'class' => 'date', 'sortable' => true), 'status' => array('html' => __('status', 'system'), 'class' => 'status'), 'actions' => array('html' => __('actions', 'system'), 'class' => 'actions')), 'content' => array());
     // Create grid content
     foreach ($news as $entry) {
         $grid['content'][] = array('check' => array('html' => $entry['news_id']), 'data_title_' . session::item('language') => array('html' => html_helper::anchor('cp/content/news/edit/' . $entry['news_id'], text_helper::truncate($entry['data_title'], 64))), 'post_date' => array('html' => date_helper::formatDate($entry['post_date'])), 'status' => array('html' => $entry['active'] ? '<span class="label success small">' . __('yes', 'system') . '</span>' : '<span class="label important small">' . __('no', 'system') . '</span>'), 'actions' => array('html' => array('edit' => html_helper::anchor('cp/content/news/edit/' . $entry['news_id'], __('edit', 'system'), array('class' => 'edit')), 'delete' => html_helper::anchor('cp/content/news/delete/' . $entry['news_id'] . '?' . $qstring['url'] . 'page=' . $qstring['page'], __('delete', 'system'), array('data-html' => __('entry_delete?', 'news'), 'data-role' => 'confirm', 'class' => 'delete')))));
     }
     // Set pagination
     $config = array('base_url' => config::siteURL('cp/content/news?' . $qstring['url']), 'total_items' => $params['total'], 'items_per_page' => $this->newsPerPage, 'current_page' => $qstring['page'], 'uri_segment' => 'page');
     $pagination = loader::library('pagination', $config, null);
     // Filter hooks
     hook::filter('cp/content/news/browse/grid', $grid);
     hook::filter('cp/content/news/browse/actions', $actions);
     // Assign vars
     view::assign(array('grid' => $grid, 'actions' => $actions, 'pagination' => $pagination));
     // Set title
     view::setTitle(__('news_manage', 'system_navigation'));
     // Set trail
     if ($qstring['search_id']) {
         view::setTrail('cp/content/news?' . $qstring['url'] . 'page=' . $qstring['page'], __('search_results', 'system'));
     }
     // Assign actions
     view::setAction('cp/content/news/edit/', __('entry_new', 'news'), array('class' => 'icon-text icon-news-new'));
     view::setAction('#', __('search', 'system'), array('class' => 'icon-text icon-system-search', 'onclick' => '$(\'#news-search\').toggle();return false;'));
     // Load view
     view::load('cp/content/news/browse');
 }
Exemplo n.º 7
0
 public static function stampToDate($stamp = '')
 {
     if (strlen($stamp) == 8) {
         $stamp = date_helper::month(ltrim(substr($stamp, 4, 2), '0')) . ' ' . (int) substr($stamp, -2) . ', ' . substr($stamp, 0, 4);
     } elseif (strlen($stamp) == 4) {
         $stamp = date_helper::month(ltrim(substr($stamp, 0, 2), '0')) . ' ' . (int) substr($stamp, -2);
     }
     return $stamp;
 }
Exemplo n.º 8
0
 public function browse()
 {
     // Parameters
     $params = array('join_columns' => array());
     // Process filters
     $params = $this->parseCounters($params);
     // Process query string
     $qstring = $this->parseQuerystring($params['total']);
     // Actions
     $actions = array(0 => __('select', 'system'), 'delete' => __('delete', 'system'));
     // Check form action
     if (input::post('do_action')) {
         // Delete selected messages
         if (input::post('action') == 'delete') {
             if (input::post('message_id') && is_array(input::post('message_id'))) {
                 foreach (input::post('message_id') as $messageID) {
                     $messageID = (int) $messageID;
                     if ($messageID && $messageID > 0) {
                         $this->delete($messageID);
                     }
                 }
             }
         }
         // Success
         view::setInfo(__('action_applied', 'system'));
         router::redirect('cp/plugins/messages?' . $qstring['url'] . 'page=' . $qstring['page']);
     }
     // Get messages
     $messages = array();
     if ($params['total']) {
         $messages = $this->messages_model->getMessages($params['join_columns'], $qstring['order'], $qstring['limit']);
     }
     // Create table grid
     $grid = array('uri' => 'cp/plugins/messages', 'keyword' => 'messages', 'header' => array('check' => array('html' => 'message_id', 'class' => 'check'), 'message' => array('html' => __('message', 'messages'), 'class' => 'name'), 'user' => array('html' => __('user', 'system'), 'class' => 'user'), 'post_date' => array('html' => __('post_date', 'system'), 'class' => 'date', 'sortable' => true), 'actions' => array('html' => __('actions', 'system'), 'class' => 'actions')), 'content' => array());
     // Create grid content
     foreach ($messages as $message) {
         $grid['content'][] = array('check' => array('html' => $message['message_id']), 'message' => array('html' => html_helper::anchor('cp/plugins/messages/edit/' . $message['message_id'], text_helper::truncate($message['message'], 64))), 'user' => array('html' => users_helper::anchor($message['user'])), 'post_date' => array('html' => date_helper::formatDate($message['post_date'])), 'actions' => array('html' => array('edit' => html_helper::anchor('cp/plugins/messages/edit/' . $message['message_id'], __('edit', 'system'), array('class' => 'edit')), 'delete' => html_helper::anchor('cp/plugins/messages/delete/' . $message['message_id'] . '?' . $qstring['url'] . 'page=' . $qstring['page'], __('delete', 'system'), array('data-html' => __('message_delete?', 'messages'), 'data-role' => 'confirm', 'class' => 'delete')))));
     }
     // Set pagination
     $config = array('base_url' => config::siteURL('cp/plugins/messages?' . $qstring['url']), 'total_items' => $params['total'], 'items_per_page' => $this->messagesPerPage, 'current_page' => $qstring['page'], 'uri_segment' => 'page');
     $pagination = loader::library('pagination', $config, null);
     // Filter hooks
     hook::filter('cp/plugins/messages/browse/grid', $grid);
     hook::filter('cp/plugins/messages/browse/actions', $actions);
     // Assign vars
     view::assign(array('grid' => $grid, 'actions' => $actions, 'pagination' => $pagination));
     // Set title
     view::setTitle(__('messages_manage', 'system_navigation'));
     // Set trail
     if ($qstring['search_id']) {
         view::setTrail('cp/plugins/messages?' . $qstring['url'] . 'page=' . $qstring['page'], __('search_results', 'system'));
     }
     // Assign actions
     view::setAction('#', __('search', 'system'), array('class' => 'icon-text icon-system-search', 'onclick' => '$(\'#messages-search\').toggle();return false;'));
     // Load view
     view::load('cp/plugins/messages/browse');
 }
Exemplo n.º 9
0
 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;
 }
Exemplo n.º 10
0
 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;
 }
Exemplo n.º 11
0
 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;
 }
Exemplo n.º 12
0
 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;
 }
Exemplo n.º 13
0
 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;
 }
Exemplo n.º 14
0
 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;
 }
Exemplo n.º 15
0
 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;
 }
Exemplo n.º 16
0
 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;
 }
Exemplo n.º 17
0
 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;
 }
Exemplo n.º 18
0
 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;
 }
Exemplo n.º 19
0
 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;
 }
Exemplo n.º 20
0
 public function usersSettingsAccountOptions($settings, $user = array())
 {
     if (input::isCP()) {
         if (uri::segment(3) == 'edit') {
             loader::helper('array');
             $expiration = array('name' => __('expire_date', 'users_account'), 'keyword' => 'expire_date', 'type' => 'date', 'value' => $user ? $user['expire_date'] : 0, 'rules' => array('valid_date'), 'select' => true);
             $credits = array('name' => __('credits_current', 'users_account'), 'keyword' => 'total_credits', 'type' => 'number', 'value' => $user ? $user['total_credits'] : 0, 'rules' => array('required' => 1, 'min_value' => 0));
             $settings = array_helper::spliceArray($settings, 'group_id', $credits, 'total_credits');
             $settings = array_helper::spliceArray($settings, 'group_id', $expiration, 'expire_date');
         }
     } else {
         if (config::item('subscriptions_active', 'billing')) {
             $settings['subscription'] = array('name' => __('plan_current', 'users_account'), 'keyword' => 'subscription', 'type' => 'static', 'value' => config::item('usergroups', 'core', session::item('group_id')) . (session::item('expire_date') ? ' (' . __('expire_date', 'users_account') . ': ' . date_helper::formatDate(session::item('expire_date'), 'date') . ')' : '') . (session::permission('plans_purchase', 'billing') ? ' - ' . html_helper::anchor('billing/plans', __('plan_change', 'users_account')) : ''));
         }
         if (config::item('credits_active', 'billing')) {
             $settings['credits'] = array('name' => __('credits_current', 'users_account'), 'keyword' => 'subscription', 'type' => 'static', 'value' => session::item('total_credits') . (session::permission('credits_purchase', 'billing') ? ' - ' . html_helper::anchor('billing/credits', __('credits_purchase', 'users_account')) : ''));
         }
     }
     return $settings;
 }
Exemplo n.º 21
0
 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);
 }
Exemplo n.º 22
0
 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;
 }
Exemplo n.º 23
0
 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'];
 }
Exemplo n.º 24
0
        if ($album['data_description']) {
            ?>
								<?php 
            echo $album['data_description'];
            ?>
							<?php 
        }
        ?>
						</div>

						<footer class="item-footer">

							<ul class="unstyled content-meta clearfix">
								<li class="date">
									<?php 
        echo __('post_date', 'system_info', array('%date' => date_helper::formatDate($album['post_date'])));
        ?>
								</li>
								<?php 
        if (config::item('album_views', 'pictures')) {
            ?>
									<li class="views">
										<?php 
            if ($album['total_views'] > 0) {
                ?>
											<?php 
                echo __('views_num' . ($album['total_views'] == 1 ? '_one' : ''), 'system_info', array('%views' => $album['total_views']));
                ?>
										<?php 
            } else {
                ?>
Exemplo n.º 25
0
					<?php 
        view::load('users/profile/elements/picture', array_merge($notice['user'], array('picture_file_suffix' => 't')));
        ?>
				</figure>

				<div class="item-article">
					<?php 
        echo $notice['html'];
        ?>
				</div>

				<footer class="item-footer">
					<ul class="unstyled content-meta clearfix">
						<li class="date">
							<?php 
        echo __('author_date', 'system_info', array('%author' => users_helper::anchor($notice['user']), '%date' => date_helper::formatDate($notice['post_date'])));
        ?>
						</li>
					</ul>
				</footer>

			</article>

		</li>

	<?php 
    }
    ?>

	<li class="clearfix loader <?php 
    echo text_helper::alternate('odd', 'even');
Exemplo n.º 26
0
 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;
 }
Exemplo n.º 27
0
				<li class="<?php 
        echo text_helper::alternate('odd', 'even');
        ?>
 clearfix" id="row-invoice-<?php 
        echo $invoice['transaction_id'];
        ?>
">
					<span class="name">
						<?php 
        echo $invoice['name'];
        ?>
					</span>
					<span class="date">
						<?php 
        echo date_helper::formatDate($invoice['post_date']);
        ?>
					</span>
					<span class="amount">
						<?php 
        echo money_helper::symbol(config::item('currency', 'billing')) . $invoice['amount'];
        ?>
					</span>
				</li>

			<?php 
    }
    ?>

		</ul>
Exemplo n.º 28
0
						<div class="item-article">
							<span class="author">
								<?php 
        echo users_helper::anchor($comment['user']);
        ?>
							</span>
							<?php 
        echo $comment['comment'];
        ?>
						</div>

						<ul class="unstyled content-meta clearfix">
							<li class="date">
								<?php 
        echo date_helper::humanSpan($comment['post_date']);
        ?>
							</li>
							<?php 
        if (session::permission('comments_delete', 'comments') && ($comment['poster_id'] == session::item('user_id') || $comment['user_id'] && $comment['user_id'] == session::item('user_id'))) {
            ?>
								<li class="delete">
									<?php 
            echo html_helper::anchor('comments/browse', __('comment_delete', 'comments'), array('onclick' => "deleteComment(this.href,{'resource':'{$resource}','item_id':{$itemID},'page':" . $pagination->getCurrentPage() . ",'delete':" . $comment['comment_id'] . ",'split':" . $split . ",'post':" . ($post ? 1 : 0) . ",'info':" . ($info ? 1 : 0) . "},'" . __('comment_delete?', 'comments') . "');return false;"));
            ?>
									<span class="icon icon-system-ajax ajax hidden" id="ajax-comments-<?php 
            echo $resource;
            ?>
-<?php 
            echo $itemID;
            ?>
Exemplo n.º 29
0
 public function _is_valid_time_zone($timezone)
 {
     $timezones = date_helper::timezones();
     if (!isset($timezones[$timezone])) {
         return config::item('time_zone', 'system');
     }
     return $timezone;
 }
Exemplo n.º 30
0
 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;
 }