Ejemplo n.º 1
0
 public function deleteCounters($resource, $itemID)
 {
     // Get resource ID
     $resourceID = config::item('resources', 'core', $resource, 'resource_id');
     $reval = $this->db->delete('core_counters', array('resource_id' => $resourceID, 'item_id' => $itemID), is_array($itemID) ? count($itemID) : 1);
     return $reval;
 }
Ejemplo n.º 2
0
 public function __construct()
 {
     parent::__construct();
     if (!config::item('news_blog', 'news') && uri::segment(1) != 'news') {
         router::redirect('news/' . utf8::substr(uri::getURI(), 5));
     }
 }
Ejemplo n.º 3
0
 protected function _saveSubject($subjectID)
 {
     // Check if demo mode is enabled
     if (input::demo()) {
         return false;
     }
     // Create rules
     $rules = $input = array();
     // Get subject data
     $subjectData = array();
     foreach (config::item('languages', 'core', 'keywords') as $languageID => $language) {
         $rules['name_' . $language] = array('label' => __('name', 'system') . (count(config::item('languages', 'core', 'keywords')) > 1 ? ' [' . config::item('languages', 'core', 'names', $languageID) . ']' : ''), 'rules' => array('trim', 'required', 'max_length' => 255));
         $input[] = 'name_' . $language;
     }
     // Assign rules
     validate::setRules($rules);
     // Validate fields
     if (!validate::run()) {
         return false;
     }
     // Get subject data
     $subject = input::post($input);
     $subject['active'] = input::post('active') ? 1 : 0;
     // Save subject
     if (!($subjectID = $this->reports_subjects_model->saveSubject($subjectID, $subject))) {
         view::setError(__('save_error', 'system'));
         return false;
     }
     // Success
     view::setInfo(__('subject_saved', 'reports_subjects'));
     router::redirect('cp/content/reports/subjects/edit/' . $subjectID);
 }
Ejemplo n.º 4
0
 public function postBlog($items, $users)
 {
     $stream = array();
     loader::model('blogs/blogs');
     $params = array('select_users' => false);
     // Get blogs
     $columns = array('`b`.`blog_id` IN (' . implode(',', array_keys($items)) . ')');
     $blogs = codebreeder::instance()->blogs_model->getBlogs('in_list', $columns, array(), false, count($items), $params);
     foreach ($items as $itemID => $data) {
         if (isset($blogs[$itemID]) && isset($users[$blogs[$itemID]['user_id']])) {
             foreach ($data as $actionID => $item) {
                 $stream[$itemID][$actionID]['html'] = view::load('blogs/timeline/blog', array('user' => $users[$blogs[$itemID]['user_id']], 'blog' => $blogs[$itemID], 'params' => $item['params']), true);
                 $stream[$itemID][$actionID]['rating']['total_votes'] = $blogs[$itemID]['total_votes'];
                 $stream[$itemID][$actionID]['rating']['total_score'] = $blogs[$itemID]['total_score'];
                 $stream[$itemID][$actionID]['rating']['total_rating'] = $blogs[$itemID]['total_rating'];
                 $stream[$itemID][$actionID]['rating']['total_likes'] = $blogs[$itemID]['total_likes'];
                 $stream[$itemID][$actionID]['rating']['type'] = config::item('blog_rating', 'blogs');
                 $stream[$itemID][$actionID]['comments']['total_comments'] = $blogs[$itemID]['total_comments'];
                 $stream[$itemID][$actionID]['comments']['privacy'] = $blogs[$itemID]['comments'];
                 $stream[$itemID][$actionID]['comments']['post'] = $blogs[$itemID]['comments'] && codebreeder::instance()->users_model->getPrivacyAccess($blogs[$itemID]['user_id'], $blogs[$itemID]['comments'], false, $users[$blogs[$itemID]['user_id']]['friends'] ? 1 : 0) ? true : false;
             }
         }
     }
     return $stream;
 }
Ejemplo n.º 5
0
 public function invoices()
 {
     // Get page
     $page = is_numeric(input::get('page')) && input::get('page') > 0 ? input::get('page') : 1;
     // Parameters
     $params = array('join_columns' => array('`t`.`user_id`=' . session::item('user_id')));
     // Process query string
     $qstring = $this->parseQuerystring(config::item('invoices_per_page', 'billing'), session::item('total_transactions'));
     // Get invoices
     $invoices = array();
     if (session::item('total_transactions')) {
         $invoices = $this->transactions_model->getTransactions($params['join_columns'], '', $qstring['limit']);
     } else {
         view::setInfo(__('no_invoices_user', 'billing_transactions'));
     }
     // Set pagination
     $config = array('base_url' => config::siteURL('billing/invoices?'), 'total_items' => session::item('total_transactions'), 'items_per_page' => config::item('invoices_per_page', 'billing'), 'current_page' => $page, 'uri_segment' => 'page');
     $pagination = loader::library('pagination', $config, null);
     // Assign vars
     view::assign(array('invoices' => $invoices, 'pagination' => $pagination));
     // Set title
     view::setTitle(__('invoices', 'billing_transactions'));
     // Load view
     view::load('billing/invoices');
 }
Ejemplo n.º 6
0
 protected function _sendFeedback()
 {
     // Check if demo mode is enabled
     if (input::demo()) {
         return false;
     }
     // Extra rules
     $rules = array('name' => array('rules' => array('required', 'is_string', 'trim', 'min_length' => 2, 'max_length' => 255)), 'email' => array('rules' => array('required', 'is_string', 'trim', 'valid_email', 'min_length' => 4, 'max_length' => 255)), 'subject' => array('rules' => array('required', 'is_string', 'trim', 'min_length' => 5, 'max_length' => 255)), 'message' => array('rules' => array('required', 'is_string', 'trim', 'min_length' => 10, 'max_length' => 10000)));
     if (config::item('feedback_captcha', 'feedback') == 1 || config::item('feedback_captcha', 'feedback') == 2 && !users_helper::isLoggedin()) {
         $rules['captcha'] = array('rules' => array('is_captcha'));
     }
     validate::setRules($rules);
     // Validate form values
     if (!validate::run($rules)) {
         return false;
     }
     // Get values
     $email = input::post('email');
     $subject = input::post('subject');
     $message = input::post('message') . "\n\n--\n" . input::post('name') . ' <' . input::post('email') . '>' . "\n" . input::ipaddress();
     // Send feedback
     if (!$this->feedback_model->sendFeedback($email, $subject, $message)) {
         if (!validate::getTotalErrors()) {
             view::setError(__('send_error', 'system'));
         }
         return false;
     }
     // Success
     view::setInfo(__('message_sent', 'feedback'));
     router::redirect('feedback');
 }
Ejemplo n.º 7
0
 public function sendTemplate($keyword, $email, $tags = array(), $language = '')
 {
     loader::model('system/emailtemplates');
     if (!$language) {
         $language = config::item('language_id', 'system');
     }
     if (is_numeric($language)) {
         $language = config::item('languages', 'core', 'keywords', $language);
     } elseif (!in_array($language, config::item('languages', 'core', 'keywords'))) {
         return false;
     }
     if (!($template = config::item($keyword . '_' . $language, '_system_emails_cache'))) {
         if (!($template = $this->cache->item('core_email_template_' . $keyword . '_' . $language))) {
             $template = $this->emailtemplates_model->prepareTemplate($keyword, $language);
             if (count($template) == 3) {
                 if ($template[$keyword]['active']) {
                     $template = array('subject' => $template[$keyword]['subject'], 'message_html' => utf8::trim($template['header']['message_html'] . $template[$keyword]['message_html'] . $template['footer']['message_html']), 'message_text' => utf8::trim($template['header']['message_text'] . "\n\n" . $template[$keyword]['message_text'] . "\n\n" . $template['footer']['message_text']));
                 } else {
                     $template = 'none';
                 }
             } else {
                 error::show('Could not fetch email template from the database: ' . $keyword);
             }
             $this->cache->set('core_email_template_' . $keyword . '_' . $language, $template, 60 * 60 * 24 * 30);
         }
         config::set(array($keyword . '_' . $language => $template), '', '_system_emails_cache');
     }
     $retval = true;
     if (is_array($template) && $template) {
         $retval = $this->sendEmail($email, $template['subject'], $template['message_text'], $template['message_html'], $tags);
     }
     return $retval;
 }
Ejemplo n.º 8
0
 public static function formatDate($time = '', $format = 'stamp', $usa = true, $offset = 0, $dst = null)
 {
     $usa = config::item('time_euro', 'system') ? false : true;
     $offset = session::item('time_zone') * 60 * 60;
     $dst = date('i') ? 3600 : 0;
     return parent::formatDate($time, $format, $usa, $offset, $dst);
 }
Ejemplo n.º 9
0
 public static function getTimeline($user = array(), $privacy = 2, $template = 'timeline/helpers/timeline')
 {
     loader::model('timeline/timeline');
     // Get actions
     $actions = codebreeder::instance()->timeline_model->getActions($user ? $user['user_id'] : 0, true, 0, config::item('actions_per_page', 'timeline'));
     $ratings = array();
     // Do we have actions and are we logged in?
     if ($actions && users_helper::isLoggedin()) {
         foreach ($actions as $action) {
             if ($action['rating']) {
                 $ratings[$action['relative_resource']][] = $action['item_id'];
             } else {
                 $ratings['timeline'][] = $action['action_id'];
             }
         }
         // Load votes and like models
         loader::model('comments/votes');
         loader::model('comments/likes');
         // Get likes and votes
         $likes = codebreeder::instance()->likes_model->getMultiLikes($ratings);
         $votes = codebreeder::instance()->votes_model->getMultiVotes($ratings);
         $ratings = $likes + $votes;
     }
     // Can we post messages?
     $post = session::permission('messages_post', 'timeline') && codebreeder::instance()->users_model->getPrivacyAccess($user['user_id'], $privacy, false) ? true : false;
     view::assign(array('actions' => $actions, 'user' => $user, 'post' => $post, 'ratings' => $ratings), '', $template);
     // Update comments pagination
     config::set('comments_per_page', config::item('comments_per_page', 'timeline'), 'comments');
     return view::load($template, array(), 1);
 }
Ejemplo n.º 10
0
 /**
  * Generates a style tag
  * @param  string $name style name
  * @return void
  */
 public static function style($name)
 {
     $format = '<link rel="stylesheet" href="%s" />';
     $name .= '.css';
     config::load('locations');
     $location = config::item('location_css');
     printf($format, BASE . $location . $name);
 }
Ejemplo n.º 11
0
 public function usersSignup($userID, $user)
 {
     if (config::item('credits_signup_bonus', 'billing') && (!isset($user['total_credits']) || $user['total_credits'] == 0)) {
         loader::model('billing/credits');
         $this->credits_model->addCredits($userID, config::item('credits_signup_bonus', 'billing'));
     }
     return true;
 }
Ejemplo n.º 12
0
 public function saveThumbnail($pictureID, $x, $y, $w, $h)
 {
     $files = $this->storage_model->getFiles($pictureID, 2, array('', 't'));
     $retval = $this->storage_model->thumbnail($files[''], $x, $y, $w, $h, config::item('picture_dimensions_t', 'classifieds'), $files['t']['suffix'], $files['t']['file_id']);
     // Action hook
     hook::action('classifieds/pictures/thumbnail', $pictureID);
     return $retval;
 }
Ejemplo n.º 13
0
 public function cronRun()
 {
     if (config::item('notices_cleanup_delay', 'timeline')) {
         loader::model('timeline/notices', array(), 'timeline_notices_model');
         $this->timeline_notices_model->cleanup();
     }
     return true;
 }
Ejemplo n.º 14
0
 public function cronRun()
 {
     $this->users_model->cleanup();
     if (config::item('cleanup_delay', 'users')) {
         loader::model('users/visitors', array(), 'users_visitors_model');
         $this->users_visitors_model->cleanup();
     }
     return true;
 }
Ejemplo n.º 15
0
 public static function captcha($name, $value = '')
 {
     $service = config::item('default_captcha', 'security');
     $settings = config::item('default_captcha_settings', 'security');
     // Load library
     loader::library('captchas/' . $service, $settings, 'captcha_' . $service);
     $str = codebreeder::instance()->{'captcha_' . $service}->getCaptcha($name);
     return $str;
 }
Ejemplo n.º 16
0
 public function install($languageID, $language)
 {
     $this->dbforge->addColumn(':prefix:billing_plans', array('name' => 'name_' . $language, 'type' => 'varchar', 'constraint' => 255, 'null' => true));
     $this->dbforge->addColumn(':prefix:billing_plans', array('name' => 'description_' . $language, 'type' => 'varchar', 'constraint' => 255, 'null' => true));
     $default = config::item('languages', 'core', 'keywords', config::item('language_id', 'system'));
     $this->db->query("UPDATE `:prefix:billing_plans` SET `name_" . $language . "`=`name_" . $default . "`");
     $this->db->query("UPDATE `:prefix:billing_plans` SET `description_" . $language . "`=`description_" . $default . "`");
     return true;
 }
Ejemplo n.º 17
0
 public function getPlugins($escape = true)
 {
     $plugins = array();
     $result = $this->db->query("SELECT `plugin` FROM `:prefix:core_meta_tags` GROUP BY `plugin`")->result();
     foreach ($result as $plugin) {
         $plugins[$plugin['plugin']] = $escape ? text_helper::entities(config::item('plugins', 'core', $plugin['plugin'], 'name')) : config::item('plugins', 'core', $plugin['plugin'], 'name');
     }
     asort($plugins);
     return $plugins;
 }
Ejemplo n.º 18
0
 public function getFriend($userID, $active = true)
 {
     if (($user = config::item('u' . $userID, '_users_cache_friends')) === false) {
         $user = $this->db->query("SELECT `user_id`, `friend_id`, `post_date`, `active`\n\t\t\t\tFROM `:prefix:users_friends`\n\t\t\t\tWHERE (`user_id`=? AND `friend_id`=? OR `user_id`=? AND `friend_id`=?) LIMIT 1", array(session::item('user_id'), $userID, $userID, session::item('user_id')))->row();
         config::set(array('u' . $userID => $user), '', '_users_cache_friends');
     }
     if ($active && (!isset($user['active']) || !$user['active'])) {
         return array();
     }
     return $user;
 }
Ejemplo n.º 19
0
 public function usersSettingsNotificationsOptions($settings, $user = array())
 {
     if (config::item('messages_active', 'messages')) {
         $settings['general']['items']['notify_messages'] = __('notify_messages', 'users_notifications');
         $settings['general']['rules']['callback__parse_config_array']['items'][] = 'notify_messages';
         if ($user && (!isset($user['config']['notify_messages']) || $user['config']['notify_messages']) || !$user && (session::item('notify_messages', 'config') === false || session::item('notify_messages', 'config'))) {
             $settings['general']['value']['notify_messages'] = 1;
         }
     }
     return $settings;
 }
Ejemplo n.º 20
0
 public function __construct()
 {
     parent::__construct();
     // Is user loggedin ?
     if (!users_helper::isLoggedin()) {
         router::redirect('users/login');
     } elseif (!config::item('credits_active', 'billing')) {
         router::redirect('users/settings');
     }
     loader::model('billing/credits');
 }
Ejemplo n.º 21
0
 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;
 }
Ejemplo n.º 22
0
 public function __construct()
 {
     parent::__construct();
     // Does user have permission to access this plugin?
     if (!session::permission('settings_manage', 'billing')) {
         view::noAccess();
     }
     view::setCustomParam('section', 'billing');
     view::setCustomParam('options', config::item('cp_top_nav', 'lists', 'billing', 'items'));
     view::setTrail('cp/billing/transactions', __('billing', 'system_navigation'));
 }
Ejemplo n.º 23
0
 /**
  * Connect to the database
  * Private
  * @param  String $host The Database host (normaly localhost)
  * @param  String $user The Database username
  * @param  String $pass Said User's Password
  * @param  String $db   The database we are going to work on
  * @return [type]       [description]
  */
 private static function connect($host = null, $user = null, $pass = null, $db = null)
 {
     //Set Defaults from config
     config::load('database');
     $host = $host === NULL ? config::item('db_host') : $host;
     $user = $user === NULL ? config::item('db_user') : $user;
     $pass = $pass === NULL ? config::item('db_pass') : $pass;
     $db = $db === NULL ? config::item('db_db') : $db;
     self::$link = @mysql_connect($host, $user, $pass);
     mysql_select_db($db);
 }
Ejemplo n.º 24
0
 public function usersSettingsPrivacyOptions($settings, $user = array())
 {
     if (config::item('timeline_active', 'timeline') && isset($settings['privacy_timeline'])) {
         $settings['privacy_timeline']['items']['timeline_classified_post'] = __('timeline_classified_post', 'users_privacy');
         $settings['privacy_timeline']['rules']['callback__parse_config_array']['items'][] = 'timeline_classified_post';
         if ($user && (!isset($user['config']['timeline_classified_post']) || $user['config']['timeline_classified_post']) || !$user && (session::item('timeline_classified_post', 'config') === false || session::item('timeline_classified_post', 'config'))) {
             $settings['privacy_timeline']['value']['timeline_classified_post'] = 1;
         }
     }
     return $settings;
 }
Ejemplo n.º 25
0
 public function install($languageID, $language)
 {
     $this->dbforge->addColumn(':prefix:messages_templates', array('name' => 'name_' . $language, 'constraint' => 255, 'type' => 'varchar', 'null' => true));
     $this->dbforge->addColumn(':prefix:messages_templates', array('name' => 'subject_' . $language, 'constraint' => 255, 'type' => 'varchar', 'null' => true));
     $this->dbforge->addColumn(':prefix:messages_templates', array('name' => 'message_' . $language, 'type' => 'text'));
     $default = config::item('languages', 'core', 'keywords', config::item('language_id', 'system'));
     $this->db->query("UPDATE `:prefix:messages_templates` SET `name_" . $language . "`=`name_" . $default . "`");
     $this->db->query("UPDATE `:prefix:messages_templates` SET `subject_" . $language . "`=`subject_" . $default . "`");
     $this->db->query("UPDATE `:prefix:messages_templates` SET `message_" . $language . "`=`message_" . $default . "`");
     return true;
 }
Ejemplo n.º 26
0
 public function index()
 {
     $service = config::item('default_captcha', 'security');
     $settings = config::item('default_captcha_settings', 'security');
     // Load library
     $captcha = loader::library('captcha', $settings, null);
     if (uri::segment(3) == 'reload') {
         $captcha->create();
     }
     echo $captcha->render();
     exit;
 }
Ejemplo n.º 27
0
 public function __construct()
 {
     parent::__construct();
     // Does user have permission to access this plugin?
     if (!session::permission('fields_manage', 'pages')) {
         view::noAccess();
     }
     view::setCustomParam('section', 'content');
     view::setCustomParam('options', config::item('cp_top_nav', 'lists', 'content', 'items', 'content/pages', 'items'));
     view::setTrail('cp/system/plugins', __('content', 'system_navigation'));
     view::setTrail('cp/content/pages', __('pages', 'system_navigation'));
 }
Ejemplo n.º 28
0
 public function __construct()
 {
     parent::__construct();
     // Does user have permission to access this plugin?
     if (!session::permission('counters_manage', 'utilities')) {
         view::noAccess();
     }
     view::setCustomParam('section', 'system');
     view::setCustomParam('options', config::item('cp_top_nav', 'lists', 'system', 'items', 'system/utilities', 'items'));
     loader::model('utilities/counters', array(), 'recalculate_model');
     view::setTrail('cp/system/config/system', __('system', 'system_navigation'));
     view::setTrail('cp/utilities/counters', __('utilities_counters', 'system_navigation'));
 }
Ejemplo n.º 29
0
 public function install($languageID, $language)
 {
     $this->dbforge->addColumn(':prefix:pages_data', array('name' => 'data_title_' . $language, 'constraint' => 255, 'type' => 'varchar', 'null' => true));
     $this->dbforge->addColumn(':prefix:pages_data', array('name' => 'data_body_' . $language, 'type' => 'text'));
     $this->dbforge->addColumn(':prefix:pages_data', array('name' => 'data_meta_keywords_' . $language, 'constraint' => 255, 'type' => 'varchar', 'null' => true));
     $this->dbforge->addColumn(':prefix:pages_data', array('name' => 'data_meta_description_' . $language, 'constraint' => 255, 'type' => 'varchar', 'null' => true));
     $default = config::item('languages', 'core', 'keywords', config::item('language_id', 'system'));
     $this->db->query("UPDATE `:prefix:pages_data` SET `data_title_" . $language . "`=`data_title_" . $default . "`");
     $this->db->query("UPDATE `:prefix:pages_data` SET `data_body_" . $language . "`=`data_body_" . $default . "`");
     $this->db->query("UPDATE `:prefix:pages_data` SET `data_meta_keywords_" . $language . "`=`data_meta_keywords_" . $default . "`");
     $this->db->query("UPDATE `:prefix:pages_data` SET `data_meta_description_" . $language . "`=`data_meta_description_" . $default . "`");
     return true;
 }
Ejemplo n.º 30
0
 protected function _savePluginSettings($keyword, $value)
 {
     // Toggle feedback
     if ($keyword == 'feedback_active' && config::item($keyword, 'feedback') != $value) {
         loader::model('system/lists');
         if ($value) {
             $data = array('uri' => 'contact', 'name' => 'feedback_contact_us|system_navigation');
             $this->lists_model->addItem('feedback', 'site_bottom_nav', 'feedback', $data);
         } else {
             $this->lists_model->deleteItem('feedback', 'site_bottom_nav', 'feedback');
         }
     }
 }