/** * Run this cronjob * @see \phpbb\cron\task\task::run() */ public function run() { $now = time(); // Extensions $available_updates = $this->version_checker->check_ext_versions(); // phpBB $phpbb_update = $this->version_checker->check_phpbb_version(); if (is_array($available_updates) && is_array($phpbb_update)) { $available_updates = array_merge($available_updates, $phpbb_update); } else { if (is_array($phpbb_update)) { //TODO: Store errors, this shouldn't happen, even with no updates there should be an array $available_updates = $phpbb_update; } else { // phpBB Version check failed //TODO: Store errors and if they happen too often in a row, create a new notification. } } if (is_array($available_updates)) { foreach ($available_updates as $extname => $data) { $notify_data = array('name' => $extname, 'version' => $data['new'], 'old_version' => $data['current']); $notification_type = $extname === 'phpbb' ? 'phpbb_update' : 'ext_update'; $this->notification_manager->add_notifications('gn36.versionchecknotifier.notification.type.' . $notification_type, $notify_data); } } $this->config->set('versionchecknotifier_last_gc', $now, true); }
public function notification_add($event) { $notifications_data = array(array('item_type' => 'gn36.hookup.notification.type.active_date_set', 'method' => 'notification.method.email'), array('item_type' => 'gn36.hookup.notification.type.active_date_reset', 'method' => 'notification.method.email'), array('item_type' => 'gn36.hookup.notification.type.date_added', 'method' => 'notification.method.email'), array('item_type' => 'gn36.hookup.notification.type.invited', 'method' => 'notification.method.email')); foreach ($notifications_data as $subscription) { $this->notification_manager->add_subscription($subscription['item_type'], 0, $subscription['method'], $event['user_id']); } }
public function notification_add($event) { if (!$this->config['email_enable']) { return; } $notifications_data = array(array('item_type' => 'gn36.versionchecknotify.notification.type.ext_update', 'method' => 'notification.method.email'), array('item_type' => 'gn36.versionchecknotify.notification.type.phpbb_update', 'method' => 'notification.method.email')); foreach ($notifications_data as $subscription) { $this->notification_manager->add_subscription($subscription['item_type'], 0, $subscription['method'], $event['user_id']); } }
/** * Add notification * * @param object $event The event object * @return null * @access public */ public function notification_add($event) { if (!$this->config['email_enable']) { return; } $notifications_data = array(array('item_type' => 'tas2580.wiki.notification.type.articke_edit', 'method' => 'notification.method.email')); foreach ($notifications_data as $subscription) { $this->notification_manager->add_subscription($subscription['item_type'], 0, $subscription['method'], $event['user_id']); } }
/** * Send notifications * * @param string $type Type of notification to send (group_added|group_removed) * @param array $user_id_ary Array of user(s) to notify * @param int $group_id The usergroup identifier * @return null * @access public */ public function send_notifications($type, $user_id_ary, $group_id) { if (!function_exists('get_group_name')) { include $this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext; } $this->notification_manager->add_notifications("phpbb.autogroups.notification.type.{$type}", array('user_ids' => $user_id_ary, 'group_id' => $group_id, 'group_name' => get_group_name($group_id))); }
/** * Update website verification number after a missing backlink, and send notificaton * * @param array $u_array Information about website * @param int $next_prune Date of next auto check * @return null */ private function _update_check($u_array, $next_prune) { if (!class_exists('messenger')) { include $this->root_path . 'includes/functions_messenger.' . $this->php_ext; } $messenger = new \messenger(false); // cron.php don't call $user->setup(), so $this->timezone is unset. // We need to define it, because we use user->format_date below $this->user->timezone = new \DateTimeZone($this->config['board_timezone']); $sql = 'UPDATE ' . DIR_LINK_TABLE . ' SET link_nb_check = link_nb_check + 1 WHERE ' . $this->db->sql_in_set('link_id', array_keys($u_array)); $this->db->sql_query($sql); foreach ($u_array as $data) { strip_bbcode($data['link_description']); $notification_data = array('cat_name' => \ernadoo\phpbbdirectory\core\categorie::getname((int) $data['link_cat']), 'link_id' => $data['link_id'], 'link_name' => $data['link_name'], 'link_url' => $data['link_url'], 'link_description' => $data['link_description'], 'next_cron' => $this->user->format_date($next_prune, $data['user_dateformat'])); if ($data['link_nb_check']) { $this->notification->delete_notifications('ernadoo.phpbbdirectory.notification.type.directory_website_error_cron', $notification_data); } // New notification system can't send mail to an anonymous user with an email address stored in another table than phpbb_users if ($data['link_user_id'] == ANONYMOUS) { $username = $email = $data['link_guest_email']; $messenger->template('@ernadoo_phpbbdirectory/directory_website_error_cron', $data['user_lang']); $messenger->to($email, $username); $messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($username), 'LINK_NAME' => $data['link_name'], 'LINK_URL' => $data['link_url'], 'LINK_DESCRIPTION' => $data['link_description'], 'NEXT_CRON' => $this->user->format_date($next_prune, $data['user_dateformat']))); $messenger->send(NOTIFY_EMAIL); } else { $this->notification->add_notifications('ernadoo.phpbbdirectory.notification.type.directory_website_error_cron', $notification_data); } } }
/** * Activate user * * @param object $event The event object * @return null * @access public */ private function user_justification_activate() { $user = $this->data; if (!function_exists('user_active_flip')) { include $this->root_path . 'includes/functions_user.' . $this->php_ext; } if (!class_exists('messenger')) { include $this->root_path . 'includes/functions_messenger.' . $this->php_ext; } user_active_flip('activate', $user['user_id']); $messenger = new \messenger(false); $messenger->template('admin_welcome_activated', $user['user_lang']); $messenger->to($user['user_email'], $user['username']); $messenger->anti_abuse_headers($this->config, $this->user); $messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($user['username']))); $messenger->send(NOTIFY_EMAIL); $messenger->save_queue(); // Remove the notification $this->notification_manager->delete_notifications('notification.type.admin_activate_user', $user['user_id']); $sql = 'UPDATE ' . USERS_TABLE . "\n\t\t\tSET user_actkey = ''\n\t\t\tWHERE user_id = {$user['user_id']}"; $this->db->sql_query($sql); // Create the correct logs $this->log->add('user', $this->user->data['user_id'], $this->user->ip, 'LOG_USER_ACTIVE_USER', false, array('reportee_id' => $user['user_id'])); $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_USER_ACTIVE', false, array($user['username'])); }
public function handle($notify_id = 0) { $this->user->add_lang_ext('gn36/versionchecknotifier', 'global'); if (!$notify_id) { trigger_error('INVALID_NOTIFICATION_ID_REDIRECT'); } if (!$this->user->data['is_registered']) { login_box(); } $notifications = $this->manager->load_notifications(array('notification_id' => intval($notify_id))); if (!isset($notifications['notifications'][$notify_id])) { trigger_error('INVALID_NOTIFICATION_ID_REDIRECT'); } /** @var $notification \phpbb\notification\type\base */ $notification = $notifications['notifications'][$notify_id]; $url = $notification->get_url(); redirect($url, false, true); }
/** * Sends notifications for approved topics * * @param array $topic_info Array containing the topic_info (topic_id => topic_data) that is approved */ public function approve_topics_notifications($topic_info) { foreach ($topic_info as $topic_id => $topic_data) { if ($topic_data['topic_visibility'] == ITEM_UNAPPROVED) { $this->notification_manager->add_notifications(array('wolfsblvt.mentions.notification.type.mention'), $topic_data); } $this->notification_manager->mark_notifications_read('wolfsblvt.mentions.notification.type.mention', $topic_data['post_id'], $this->user->data['user_id']); } }
/** * Mark this item read/unread helper * * @param bool $unread Unread (True/False) (Default: False) * @param bool $return True to return a string containing the SQL code to update this item, False to execute it (Default: False) * @return string|null If $return is False, nothing will be returned, else the sql code to update this item */ protected function mark($unread = true, $return = false) { $this->notification_read = (bool) (!$unread); if ($return) { $where = array('notification_type_id = ' . (int) $this->notification_type_id, 'item_id = ' . (int) $this->item_id, 'user_id = ' . (int) $this->user_id); $where = implode(' AND ', $where); return $where; } else { $this->notification_manager->mark_notifications($this->get_type(), (int) $this->item_id, (int) $this->user_id, false, $this->notification_read); } }
/** * Process adding dates * @param \phpbb\event\data $event * @param bool $is_member_or_owner */ protected function process_add_date($event, $is_member_or_owner) { $add_dates = $this->request->variable('add_date', '', true); if (empty($add_dates)) { return array(); } if (!$is_member_or_owner) { return array($this->user->lang('NOT_AUTH_HOOKUP')); } $hookup_errors = array(); $add_dates = array_map("trim", explode("\n", $add_dates)); //replace german date formats $add_dates = preg_replace('#(\\d{1,2})\\. ?(\\d{1,2})\\. ?(\\d{2})[,:]?[,: ]#', '20$3-$2-$1 ', $add_dates); $add_dates = preg_replace('#(\\d{1,2})\\. ?(\\d{1,2})\\. ?(\\d{4})[,:]?[,: ]#', '$3-$2-$1 ', $add_dates); $date_added = false; foreach ($add_dates as $date) { $text_match = preg_match('#\\#(.*)#', $date, $text); //strtotime uses the local (server) timezone, so parse manually and use gmmktime to ignore any timezone if (!preg_match('#(\\d{4})-(\\d{1,2})-(\\d{1,2}) (\\d{1,2}):(\\d{2})#', $date) && !$text_match) { $hookup_errors[] = "{$date}: {$this->user->lang['INVALID_DATE']}"; } else { $hookup_continue = true; if ($text_match) { $text = trim($text[1]); $date_time = '0'; } else { $text = null; $date_time = $this->user->get_timestamp_from_format('Y-m-d H:i', $date); if ($date_time < time()) { $hookup_continue = false; $hookup_errors[] = "{$date}: {$this->user->lang['CANNOT_ADD_PAST']}"; } } if ($hookup_continue) { //check for duplicate if (!$this->hookup->add_date($date_time, $text)) { $hookup_errors[] = sprintf($this->user->lang['DATE_ALREADY_ADDED'], $this->user->format_date($date_time, $text)); } else { $date_added = true; } } } } if ($date_added) { // Notification $notify_data = array('user_id' => $this->user->data['user_id'], 'topic_title' => $event['topic_data']['topic_title'], 'topic_id' => $event['topic_id'], 'forum_id' => $event['forum_id']); $this->notification_manager->update_notifications('gn36.hookup.notification.type.date_added', $notify_data); } return $hookup_errors; }
/** * Send account activation notification to user * * @param array $user_row The user data array * @param InputInterface $input The input stream used to get the options * @return null */ protected function send_notification($user_row, InputInterface $input) { $this->notifications->delete_notifications('notification.type.admin_activate_user', $user_row['user_id']); if ($input->getOption('send-email')) { if (!class_exists('messenger')) { require $this->phpbb_root_path . 'includes/functions_messenger.' . $this->php_ext; } $messenger = new \messenger(false); $messenger->template('admin_welcome_activated', $user_row['user_lang']); $messenger->set_addresses($user_row); $messenger->anti_abuse_headers($this->config, $this->user); $messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($user_row['username']))); $messenger->send(NOTIFY_EMAIL); } }
function random_bonus_increment($user_id) { /** * Read out config values */ $sql = 'SELECT * FROM ' . $this->points_values_table; $result = $this->db->sql_query($sql); $points_values = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); $bonus_chance = ''; $bonus = false; // Basic value, sorry.. $bonus_value = 0.0; // Basic value // Following numbers are 'times 100' to get rid of commas, as mt_rand doesn't get comma numbers. $bonus_chance = $points_values['points_bonus_chance'] * 100; // The chance percentage for a user to get the bonus $random_number = mt_rand(0, 10000); // The random number we compare to the chance percentage if ($random_number <= $bonus_chance) { $bonus = true; // Check if we want a fixed bonus value or not if ($points_values['points_bonus_min'] == $points_values['points_bonus_max']) { $bonus_value = $points_values['points_bonus_min']; } else { // Create the bonus value, between the set minimum and maximum // Following numbers are 'times 100' to get rid of commas, as mt_rand doesn't get comma numbers. $bonus_random = mt_rand($points_values['points_bonus_min'] * 100, $points_values['points_bonus_max'] * 100) / 100; $bonus_value = round($bonus_random, 0, PHP_ROUND_HALF_UP); } } if ($bonus && $bonus_value) { $this->add_points((int) $user_id, $bonus_value); // Send out notification // Increase our notification sent counter $this->config->increment('points_notification_id', 1); // Store the notification data we will use in an array $data = array('points_notify_id' => (int) $this->config['points_notification_id'], 'points_notify_msg' => sprintf($this->user->lang['NOTIFICATION_RANDOM_BONUS'], $bonus_value, $this->config['points_name']), 'sender' => (int) $this->user->data['user_id'], 'receiver' => (int) $user_id, 'mode' => 'logs'); $this->notification_manager->add_notifications('dmzx.ultimatepoints.notification.type.points', $data); $sql_array = array('SELECT' => 'username', 'FROM' => array(USERS_TABLE => 'u'), 'WHERE' => 'user_id = ' . (int) $user_id); $sql = $this->db->sql_build_query('SELECT', $sql_array); $result = $this->db->sql_query($sql); $points_user = $this->db->sql_fetchrow($result); // Add logs $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_MOD_POINTS_RANDOM', false, array($points_user['username'])); } }
/** * Send notification to users * * @param int $rule_id The rule identifier * @return null * @access public */ public function send_notification($rule_id) { // Use a confirmation box routine when sending notifications if (confirm_box(true)) { // Increment our notifications sent counter $this->config->increment('boardrules_notification', 1); // Store the notification data we will use in an array $notification_data = array('rule_id' => $rule_id, 'notification_id' => $this->config['boardrules_notification']); // Create the notification $this->notification_manager->add_notifications('phpbb.boardrules.notification.type.boardrules', $notification_data); // Log the notification $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'ACP_BOARDRULES_NOTIFY_LOG'); } else { // Request confirmation from the user to send notification to all users // Build a hidden array of the form data confirm_box(false, $this->user->lang('ACP_BOARDRULES_NOTIFY_CONFIRM'), build_hidden_fields(array('action_send_notification' => true, 'rule_id' => $rule_id))); } }
/** * Output all the notification methods to the template * * @param \phpbb\notification\manager $phpbb_notifications * @param \phpbb\template\template $template * @param \phpbb\user $user * @param string $block */ public function output_notification_methods(\phpbb\notification\manager $phpbb_notifications, \phpbb\template\template $template, \phpbb\user $user, $block = 'notification_methods') { $notification_methods = $phpbb_notifications->get_subscription_methods(); foreach ($notification_methods as $method => $method_data) { $template->assign_block_vars($block, array('METHOD' => $method_data['id'], 'NAME' => $user->lang($method_data['lang']))); } }
function main($checked_user) { // Get all values $sql = 'SELECT * FROM ' . $this->points_values_table; $result = $this->db->sql_query($sql); $points_values = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); // Get all point config names and config values $sql = 'SELECT config_name, config_value FROM ' . $this->points_config_table; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { $points_config[$row['config_name']] = $row['config_value']; } $this->db->sql_freeresult($result); // Check, if user is allowed to use the robbery if (!$this->auth->acl_get('u_use_robbery')) { $message = $this->user->lang['NOT_AUTHORISED'] . '<br /><br /><a href="' . $this->helper->route('dmzx_ultimatepoints_controller') . '">« ' . $this->user->lang['BACK_TO_PREV'] . '</a>'; trigger_error($message); } // Check, if robbery is enabled if (!$points_config['robbery_enable']) { $message = $this->user->lang['ROBBERY_DISABLED'] . '<br /><br /><a href="' . $this->helper->route('dmzx_ultimatepoints_controller') . '">« ' . $this->user->lang['BACK_TO_PREV'] . '</a>'; trigger_error($message); } // Add part to bar $this->template->assign_block_vars('navlinks', array('U_VIEW_FORUM' => $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'robbery')), 'FORUM_NAME' => sprintf($this->user->lang['POINTS_ROBBERY'], $this->config['points_name']))); // Read out cash of current user $pointsa = $this->user->data['user_points']; // Check key add_form_key('robbery_attack'); $submit = isset($_POST['submit']) ? true : false; if ($submit) { if (!check_form_key('robbery_attack')) { trigger_error('FORM_INVALID'); } // Add all required informations $username = utf8_normalize_nfc($this->request->variable('username', '', true)); $attacked_amount = round($this->request->variable('attacked_amount', 0.0), 2); if ($attacked_amount <= 0) { $message = $this->user->lang['ROBBERY_TOO_SMALL_AMOUNT'] . '<br /><br /><a href="' . $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'robbery')) . '">« ' . $this->user->lang['BACK_TO_PREV'] . '</a>'; trigger_error($message); } // Check, if user has entered the name of the user to be robbed if (empty($username)) { $message = $this->user->lang['ROBBERY_NO_ID_SPECIFIED'] . '<br /><br /><a href="' . $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'robbery')) . '">« ' . $this->user->lang['BACK_TO_PREV'] . '</a>'; trigger_error($message); } // Check, if user tries to rob himself if ($this->user->data['username_clean'] == utf8_clean_string($username)) { $message = $this->user->lang['ROBBERY_SELF'] . '<br /><br /><a href="' . $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'robbery')) . '">« ' . $this->user->lang['BACK_TO_PREV'] . '</a>'; trigger_error($message); } // Check, if user is trying to rob to much cash if ($points_values['robbery_loose'] != 0) { if ($this->user->data['user_points'] < $attacked_amount / 100 * $points_values['robbery_loose']) { $message = $this->user->lang['ROBBERY_TO_MUCH'] . '<br /><br /><a href="' . $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'robbery')) . '">« ' . $this->user->lang['BACK_TO_PREV'] . '</a>'; trigger_error($message); } } // Select the user_id of user to be robbed $sql_array = array('SELECT' => 'user_id', 'FROM' => array(USERS_TABLE => 'u'), 'WHERE' => 'username_clean = "' . $this->db->sql_escape(utf8_clean_string($username)) . '"'); $sql = $this->db->sql_build_query('SELECT', $sql_array); $result = $this->db->sql_query($sql); $user_id = (int) $this->db->sql_fetchfield('user_id'); $this->db->sql_freeresult($result); // If no matching user id is found if (!$user_id) { $message = $this->user->lang['POINTS_NO_USER'] . '<br /><br /><a href="' . $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'robbery')) . '">« ' . $this->user->lang['BACK_TO_PREV'] . '</a>'; trigger_error($message); } // If the robbed user doesn't have enough cash $sql_array = array('SELECT' => 'user_points', 'FROM' => array(USERS_TABLE => 'u'), 'WHERE' => 'user_id = ' . (int) $user_id); $sql = $this->db->sql_build_query('SELECT', $sql_array); $result = $this->db->sql_query($sql); $pointsa = $this->db->sql_fetchfield('user_points'); $this->db->sql_freeresult($result); if ($attacked_amount > $pointsa) { $message = $this->user->lang['ROBBERY_TO_MUCH_FROM_USER'] . '<br /><br /><a href="' . $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'robbery')) . '">« ' . $this->user->lang['BACK_TO_PREV'] . '</a>'; trigger_error($message); } // Check, if user tries to rob more than x % of users cash if ($points_values['robbery_max_rob'] != 0) { if ($attacked_amount > $pointsa / 100 * $points_values['robbery_max_rob']) { $message = sprintf($this->user->lang['ROBBERY_MAX_ROB'], $points_values['robbery_max_rob']) . '<br /><br /><a href="' . $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'robbery')) . '">« ' . $this->user->lang['BACK_TO_PREV'] . '</a>'; trigger_error($message); } } // Get some info about the robbed user $user_namepoints = get_username_string('full', $checked_user['user_id'], $checked_user['username'], $checked_user['user_colour']); // Genarate a random number $rand_base = $points_values['robbery_chance']; $rand_value = rand(0, 100); // If robbery was successful and notification is enabled, send notification if ($rand_value <= $rand_base) { $this->functions_points->add_points($this->user->data['user_id'], $attacked_amount); $this->functions_points->substract_points($user_id, $attacked_amount); // Add robbery to the log $sql = 'INSERT INTO ' . $this->points_log_table . ' ' . $this->db->sql_build_array('INSERT', array('point_send' => (int) $this->user->data['user_id'], 'point_recv' => $user_id, 'point_amount' => $attacked_amount, 'point_sendold' => $this->user->data['user_points'], 'point_recvold' => $pointsa, 'point_comment' => '', 'point_type' => '3', 'point_date' => time())); $this->db->sql_query($sql); if ($points_config['robbery_notify']) { // Increase our notification sent counter $this->config->increment('points_notification_id', 1); // Store the notification data we will use in an array $data = array('points_notify_id' => (int) $this->config['points_notification_id'], 'points_notify_msg' => sprintf($this->user->lang['NOTIFICATION_ROBBERY_SUCCES'], $attacked_amount, $this->config['points_name']), 'sender' => (int) $this->user->data['user_id'], 'receiver' => (int) $user_id, 'mode' => 'robbery'); // Create the notification $this->notification_manager->add_notifications('dmzx.ultimatepoints.notification.type.points', $data); } $message = $this->user->lang['ROBBERY_SUCCESFUL'] . '<br /><br /><a href="' . $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'robbery')) . '">« ' . $this->user->lang['BACK_TO_PREV'] . '</a>'; trigger_error($message); } else { if ($points_values['robbery_loose'] != 0) { $lose = $attacked_amount / 100 * $points_values['robbery_loose']; $this->functions_points->substract_points($this->user->data['user_id'], $lose); if ($points_config['robbery_notify']) { // Increase our notification sent counter $this->config->increment('points_notification_id', 1); // Store the notification data we will use in an array $data = array('points_notify_id' => (int) $this->config['points_notification_id'], 'points_notify_msg' => $this->user->lang['NOTIFICATION_ROBBERY_FAILED'], 'sender' => (int) $this->user->data['user_id'], 'receiver' => (int) $user_id, 'mode' => 'robbery'); // Create the notification $this->notification_manager->add_notifications('dmzx.ultimatepoints.notification.type.points', $data); } $message = $this->user->lang['ROBBERY_BAD'] . '<br /><br /><a href="' . $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'robbery')) . '">« ' . $this->user->lang['BACK_TO_PREV'] . '</a>'; trigger_error($message); } } $this->template->assign_vars(array('USER_NAME' => get_username_string('full', $checked_user['user_id'], $points_config['username'], $points_config['user_colour']), 'U_ACTION' => $this->u_action, 'S_HIDDEN_FIELDS' => $hidden_fields)); } $this->template->assign_vars(array('USER_POINTS' => sprintf($this->functions_points->number_format_points($pointsa)), 'POINTS_NAME' => $this->config['points_name'], 'LOTTERY_NAME' => $points_values['lottery_name'], 'BANK_NAME' => $points_values['bank_name'], 'L_ROBBERY_CHANCE' => sprintf($this->user->lang['ROBBERY_CHANCE'], $this->functions_points->number_format_points($points_values['robbery_max_rob']), $this->functions_points->number_format_points($points_values['robbery_chance'])), 'L_ROBBERY_AMOUNTLOSE' => sprintf($this->user->lang['ROBBERY_AMOUNTLOSE'], $this->functions_points->number_format_points($points_values['robbery_loose'])), 'U_FIND_USERNAME' => append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", "mode=searchuser&form=post&field=username"), 'U_TRANSFER_USER' => $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'transfer_user')), 'U_LOGS' => $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'logs')), 'U_LOTTERY' => $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'lottery')), 'U_BANK' => $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'bank')), 'U_ROBBERY' => $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'robbery')), 'U_INFO' => $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'info')), 'U_USE_TRANSFER' => $this->auth->acl_get('u_use_transfer'), 'U_USE_LOGS' => $this->auth->acl_get('u_use_logs'), 'U_USE_LOTTERY' => $this->auth->acl_get('u_use_lottery'), 'U_USE_BANK' => $this->auth->acl_get('u_use_bank'), 'U_USE_ROBBERY' => $this->auth->acl_get('u_use_robbery'))); // Generate the page page_header($this->user->lang['POINTS_ROBBERY']); // Generate the page template $this->template->set_filenames(array('body' => 'points/points_robbery.html')); page_footer(); }
/** * Set notification manager (required) * * @param \phpbb\notification\manager $notification_manager */ public function set_notification_manager(\phpbb\notification\manager $notification_manager) { $this->notification_manager = $notification_manager; $this->notification_type_id = $this->notification_manager->get_notification_type_id($this->get_type()); }
function main() { // Get all values $sql = 'SELECT * FROM ' . $this->points_values_table; $result = $this->db->sql_query($sql); $points_values = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); // Check Points Config Table if Bank is Enabled $sql = 'SELECT config_value FROM ' . $this->points_config_table . ' WHERE config_name = "bank_enable"'; $result = $this->db->sql_query($sql); $is_bank_enabled = $this->db->sql_fetchfield('config_value'); $this->db->sql_freeresult($result); // Check if bank is enabled if (1 > $points_values['bank_pay_period']) { $message = $this->user->lang['BANK_ERROR_PAYOUTTIME_SHORT'] . '<br /><br /><a href="' . $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'bank')) . '">« ' . $this->user->lang['BACK_TO_PREV'] . '</a>'; trigger_error($message); } if ($is_bank_enabled != 1) { $message = $this->user->lang['BANK_DISABLED'] . '<br /><br /><a href="' . $this->helper->route('dmzx_ultimatepoints_controller') . '">« ' . $this->user->lang['BACK_TO_PREV'] . '</a>'; trigger_error($message); } if (!$this->auth->acl_get('u_use_bank')) { $message = $this->user->lang['NOT_AUTHORISED'] . '<br /><br /><a href="' . $this->helper->route('dmzx_ultimatepoints_controller') . '">« ' . $this->user->lang['BACK_TO_PREV'] . '</a>'; trigger_error($message); } $withdrawtotal_check = ''; // Add part to bar $this->template->assign_block_vars('navlinks', array('U_VIEW_FORUM' => $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'bank')), 'FORUM_NAME' => $points_values['bank_name'])); // Check, if it's time to pay users $time = time(); if ($time - $points_values['bank_last_restocked'] > $points_values['bank_pay_period']) { $this->functions_points->set_points_values('bank_last_restocked', $time); // Pay the users $sql = 'UPDATE ' . $this->points_bank_table . ' SET holding = holding + round((holding / 100) * ' . $points_values['bank_interest'] . ') WHERE holding < ' . $points_values['bank_interestcut'] . ' OR ' . $points_values['bank_interestcut'] . ' = 0'; $this->db->sql_query($sql); // Mantain the bank costs if ($points_values['bank_cost'] != '0') { $sql = 'UPDATE ' . $this->points_bank_table . ' SET holding = holding - ' . $points_values['bank_cost'] . ' WHERE holding >= ' . $points_values['bank_cost'] . ''; $this->db->sql_query($sql); } // Increase our notification sent counter $this->config->increment('points_notification_id', 1); $data = array('points_notify_id' => (int) $this->config['points_notification_id'], 'points_notify_msg' => $this->user->lang['NOTIFICATION_BANK_PAYOUT'], 'sender' => $this->user->data['user_id'], 'receiver' => (int) $this->user->data['user_id'], 'mode' => 'bank'); // Send the notification $this->notification_manager->add_notifications('dmzx.ultimatepoints.notification.type.points', $data); $sql_array = array('SELECT' => 'username', 'FROM' => array(USERS_TABLE => 'u'), 'WHERE' => 'user_id = ' . (int) $this->user->data['user_id']); $sql = $this->db->sql_build_query('SELECT', $sql_array); $result = $this->db->sql_query($sql); $points_user = $this->db->sql_fetchrow($result); // Add logs $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_MOD_POINTS_BANK_PAYS', false, array($points_user['username'])); } $sql_array = array('SELECT' => '*', 'FROM' => array($this->points_bank_table => 'u'), 'WHERE' => 'user_id = ' . (int) $this->user->data['user_id']); $sql = $this->db->sql_build_query('SELECT', $sql_array); $result = $this->db->sql_query($sql); $row = $this->db->sql_fetchrow($result); $action = $this->request->variable('action', ''); add_form_key('bank_action'); // Default bank info page if (empty($action)) { $this->template->set_filenames(array('body' => 'points/points_bank.html')); if (!isset($row['holding']) && $this->user->data['user_id'] > 0 && $this->user->data['username'] != ANONYMOUS) { $this->template->assign_block_vars('no_account', array('USER_NO_ACCOUNT' => sprintf($this->user->lang['BANK_USER_NO_ACCOUNT'], $points_values['bank_name']), 'OPEN_ACCOUNT' => sprintf($this->user->lang['BANK_OPEN_ACCOUNT'], '<a href="' . $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'bank', 'action' => 'createaccount')) . '" title="' . $this->user->lang['BANK_OPEN_ACCOUNT'] . '!">', '</a>'))); } else { if ($this->user->data['user_id'] > 0 && $this->user->data['username'] != ANONYMOUS) { $this->template->assign_block_vars('has_account', array()); } } $sql_array = array('SELECT' => 'SUM(holding) AS total_holding, count(user_id) AS total_users', 'FROM' => array($this->points_bank_table => 'u'), 'WHERE' => 'id > 0'); $sql = $this->db->sql_build_query('SELECT', $sql_array); $result = $this->db->sql_query($sql); $b_row = $this->db->sql_fetchrow($result); $bankholdings = $b_row['total_holding'] ? $b_row['total_holding'] : 0; $bankusers = $b_row['total_users']; $withdrawtotal = $row['fees'] == 'on' ? $row['holding'] - round($row['holding'] / 100 * $points_values['bank_fees']) : $row['holding']; if ($row['fees'] == 'on' && $this->user->lang['BANK_WITHDRAW_RATE']) { $this->template->assign_block_vars('switch_withdraw_fees', array()); } if ($points_values['bank_min_withdraw']) { $this->template->assign_block_vars('switch_min_with', array()); } if ($points_values['bank_min_deposit']) { $this->template->assign_block_vars('switch_min_depo', array()); } $banklocation = ' -> <a href="' . $this->helper->route('dmzx_ultimatepoints_controller') . '" class="nav">' . $points_values['bank_name'] . '</a>'; $title = $points_values['bank_name'] . '; ' . (!is_numeric($row['holding']) ? $this->user->lang['BANK_ACCOUNT_OPENING'] : $this->user->lang['BANK_DEPOSIT_WITHDRAW'] . ' ' . $this->config['points_name']); page_header($points_values['bank_name']); $bank_enable = $is_bank_enabled; $this->template->assign_vars(array('BANK_NAME' => $points_values['bank_name'], 'BANKLOCATION' => $banklocation, 'BANK_OPENED' => $this->user->format_date($bank_enable), 'BANK_HOLDINGS' => sprintf($this->functions_points->number_format_points($bankholdings)), 'BANK_ACCOUNTS' => $bankusers, 'BANK_FEES' => $points_values['bank_fees'], 'BANK_INTEREST' => $points_values['bank_interest'], 'BANK_MIN_WITH' => sprintf($this->functions_points->number_format_points($points_values['bank_min_withdraw'])), 'BANK_MIN_DEPO' => sprintf($this->functions_points->number_format_points($points_values['bank_min_deposit'])), 'BANK_MAX_HOLD' => sprintf($this->functions_points->number_format_points($points_values['bank_interestcut'])), 'BANK_TITLE' => $title, 'POINTS_NAME' => $this->config['points_name'], 'USER_BALANCE' => sprintf($this->functions_points->number_format_points($row['holding'])), 'USER_GOLD' => $this->user->data['user_points'], 'USER_WITHDRAW' => sprintf(number_format($withdrawtotal, 2, '.', '')), 'U_WITHDRAW' => $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'bank', 'action' => 'withdraw')), 'U_DEPOSIT' => $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'bank', 'action' => 'deposit')))); } else { if ($action == 'createaccount') { if (!$this->user->data['is_registered']) { login_box(); } $this->template->set_filenames(array('body' => 'points/points_bank.html')); if (is_numeric($row['holding'])) { trigger_error(' ' . $this->user->lang['YES_ACCOUNT'] . '!<br /><br />' . sprintf($this->user->lang['BANK_BACK_TO_BANK'], '<a href="' . $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'bank')) . '">', '</a>') . sprintf('<br />' . $this->user->lang['BANK_BACK_TO_INDEX'], '<a href="' . append_sid("{$this->phpbb_root_path}index.{$this->phpEx}") . '">', '</a>')); } else { $sql = 'INSERT INTO ' . $this->points_bank_table . ' ' . $this->db->sql_build_array('INSERT', array('user_id' => (int) $this->user->data['user_id'], 'opentime' => time(), 'fees' => 'on')); $this->db->sql_query($sql); trigger_error(' ' . $this->user->lang['BANK_WELCOME_BANK'] . ' ' . $points_values['bank_name'] . '! <br />' . $this->user->lang['BANK_START_BALANCE'] . '<br />' . $this->user->lang['BANK_YOUR_ACCOUNT'] . '!<br /><br />' . sprintf($this->user->lang['BANK_BACK_TO_BANK'], '<a href="' . $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'bank')) . '">', '</a>') . sprintf('<br />' . $this->user->lang['BANK_BACK_TO_INDEX'], '<a href="' . append_sid("{$this->phpbb_root_path}index.{$this->phpEx}") . '">', '</a>')); } } else { if ($action == 'deposit') { if (!check_form_key('bank_action')) { trigger_error('FORM_INVALID'); } $deposit = round($this->request->variable('deposit', 0.0), 2); if (!$this->user->data['is_registered']) { login_box(); } if ($deposit < $points_values['bank_min_deposit']) { $message = sprintf($this->user->lang['BANK_DEPOSIT_SMALL_AMOUNT'], $points_values['bank_min_deposit'], $this->config['points_name']) . '<br /><br /><a href="' . $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'bank')) . '">« ' . $this->user->lang['BACK_TO_PREV'] . '</a>'; trigger_error($message); } else { if ($deposit < 1) { $message = $this->user->lang['BANK_ERROR_DEPOSIT'] . '<br /><br /><a href="' . $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'bank')) . '">« ' . $this->user->lang['BACK_TO_PREV'] . '</a>'; trigger_error($message); } else { if ($deposit > $this->user->data['user_points']) { $message = sprintf($this->user->lang['BANK_ERROR_NOT_ENOUGH_DEPOSIT'], $this->config['points_name']) . '<br /><br /><a href="' . $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'bank')) . '">« ' . $this->user->lang['BACK_TO_PREV'] . '</a>'; trigger_error($message); } } } $this->functions_points->substract_points($this->user->data['user_id'], $deposit); $sql_array = array('SELECT' => 'holding, totaldeposit', 'FROM' => array($this->points_bank_table => 'b'), 'WHERE' => 'user_id = ' . (int) $this->user->data['user_id']); $sql = $this->db->sql_build_query('SELECT', $sql_array); $result = $this->db->sql_query($sql); $user_bank = $this->db->sql_fetchrow($result); $user_holding = $user_bank['holding']; $user_totaldeposit = $user_bank['totaldeposit']; $this->db->sql_freeresult($result); $data = array('holding' => $user_holding + $deposit, 'totaldeposit' => $user_totaldeposit + $deposit); $sql = 'UPDATE ' . $this->points_bank_table . ' SET ' . $this->db->sql_build_array('UPDATE', $data) . ' WHERE user_id = ' . (int) $this->user->data['user_id']; $this->db->sql_query($sql); trigger_error(' ' . $this->user->lang['BANK_HAVE_DEPOSIT'] . ' ' . sprintf($this->functions_points->number_format_points($deposit)) . ' ' . $this->config['points_name'] . ' ' . $this->user->lang['BANK_TO_ACCOUNT'] . '<br />' . $this->user->lang['BANK_NEW_BALANCE'] . ' ' . sprintf($this->functions_points->number_format_points($row['holding'] + $deposit)) . '.<br />' . $this->user->lang['BANK_LEAVE_WITH'] . ' ' . sprintf($this->functions_points->number_format_points($this->user->data['user_points'] - $deposit)) . ' ' . $this->config['points_name'] . ' ' . $this->user->lang['BANK_ON_HAND'] . '.<br /><br />' . sprintf($this->user->lang['BANK_BACK_TO_BANK'], '<a href="' . $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'bank')) . '">', '</a>') . sprintf('<br />' . $this->user->lang['BANK_BACK_TO_INDEX'], '<a href="' . append_sid("{$this->phpbb_root_path}index.{$this->phpEx}") . '">', '</a>')); } else { if ($action == 'withdraw') { if (!check_form_key('bank_action')) { trigger_error('FORM_INVALID'); } $withdraw = round($this->request->variable('withdraw', 0.0), 2); if (!$this->user->data['is_registered']) { login_box(); } if ($withdraw < $points_values['bank_min_withdraw']) { $message = sprintf($this->user->lang['BANK_WITHDRAW_SMALL_AMOUNT'], $points_values['bank_min_withdraw'], $this->config['points_name']) . '<br /><br /><a href="' . $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'bank')) . '">« ' . $this->user->lang['BACK_TO_PREV'] . '</a>'; trigger_error($message); } else { if ($withdraw < 1) { $message = $this->user->lang['BANK_ERROR_WITHDRAW'] . '<br /><br /><a href="' . $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'bank')) . '">« ' . $this->user->lang['BACK_TO_PREV'] . '</a>'; trigger_error($message); } } if ($row['fees'] == 'on') { $withdrawtotal_check = $row['fees'] == 'on' ? $row['holding'] - round($row['holding'] / 100 * $points_values['bank_fees']) : $row['holding']; $fees = round($row['holding'] / 100 * $points_values['bank_fees']); if ($withdraw == $withdrawtotal_check) { $withdrawtotal = $withdraw + $fees; } else { $withdrawtotal = round($withdraw / 100 * $points_values['bank_fees']) + $withdraw; } } else { $withdrawtotal = 0; } if ($row['holding'] < $withdrawtotal) { $message = sprintf($this->user->lang['BANK_ERROR_NOT_ENOUGH_WITHDRAW'], $this->config['points_name']) . '<br /><br /><a href="' . $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'bank')) . '">« ' . $this->user->lang['BACK_TO_PREV'] . '</a>'; trigger_error($message); } // Transfer points to users cash account $this->functions_points->add_points($this->user->data['user_id'], $withdraw); // Update users bank account $sql_array = array('SELECT' => 'holding, totalwithdrew', 'FROM' => array($this->points_bank_table => 'b'), 'WHERE' => 'user_id = ' . (int) $this->user->data['user_id']); $sql = $this->db->sql_build_query('SELECT', $sql_array); $result = $this->db->sql_query($sql); $user_bank = $this->db->sql_fetchrow($result); $user_holding = $user_bank['holding']; $user_totalwithdrew = $user_bank['totalwithdrew']; $this->db->sql_freeresult($result); $data = array('holding' => $user_holding - $withdrawtotal, 'totalwithdrew' => $user_totalwithdrew + $withdraw); $sql = 'UPDATE ' . $this->points_bank_table . ' SET ' . $this->db->sql_build_array('UPDATE', $data) . ' WHERE user_id = ' . (int) $this->user->data['user_id']; $this->db->sql_query($sql); trigger_error(' ' . $this->user->lang['BANK_HAVE_WITHDRAW'] . ' ' . sprintf($this->functions_points->number_format_points($withdraw)) . ' ' . $this->config['points_name'] . ' ' . $this->user->lang['BANK_FROM_ACCOUNT'] . '. <br />' . $this->user->lang['BANK_NEW_BALANCE'] . ' ' . sprintf($this->functions_points->number_format_points($row['holding'] - $withdrawtotal)) . ' ' . $this->config['points_name'] . '.<br />' . $this->user->lang['BANK_NOW_HAVE'] . ' ' . sprintf($this->functions_points->number_format_points($this->user->data['user_points'] + $withdraw)) . ' ' . $this->config['points_name'] . ' ' . $this->user->lang['BANK_ON_HAND'] . '.<br /><br />' . sprintf($this->user->lang['BANK_BACK_TO_BANK'], '<a href="' . $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'bank')) . '">', '</a>') . sprintf('<br />' . $this->user->lang['BANK_BACK_TO_INDEX'], '<a href="' . append_sid("{$this->phpbb_root_path}index.{$this->phpEx}") . '">', '</a>')); } else { redirect($this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'bank'))); } } } } // Generate most rich banker to show $limit = $points_values['number_show_top_points']; $sql_array = array('SELECT' => 'u.user_id, u.username, u.user_colour, b.*', 'FROM' => array(USERS_TABLE => 'u'), 'LEFT_JOIN' => array(array('FROM' => array($this->points_bank_table => 'b'), 'ON' => 'u.user_id = b.user_id')), 'WHERE' => 'b.holding > 0', 'ORDER_BY' => 'b.holding DESC, u.username ASC'); $sql = $this->db->sql_build_query('SELECT', $sql_array); $result = $this->db->sql_query_limit($sql, $limit); while ($row = $this->db->sql_fetchrow($result)) { $this->template->assign_block_vars('bank', array('USERNAME' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'POINT' => sprintf($this->functions_points->number_format_points($row['holding'])))); } $this->db->sql_freeresult($result); // Generate the time format function time_format($secs, $filter = false) { global $user; $output = ''; $filter = $filter ? explode('|', strtolower($filter)) : false; $time_array = array('year' => 60 * 60 * 24 * 365, 'month' => 60 * 60 * 24 * 30, 'week' => 60 * 60 * 24 * 7, 'day' => 60 * 60 * 24, 'hour' => 60 * 60, 'minute' => 60, 'second' => 0); foreach ($time_array as $key => $value) { if ($filter && !in_array($key, $filter)) { continue; } $item = $value ? intval(intval($secs) / $value) : intval($secs); if ($item > 0) { $secs = $secs - $item * $value; $output .= ' ' . $item . ' ' . ($item > 1 ? $user->lang['TIME_' . strtoupper($key) . 'S'] : $user->lang['TIME_' . strtoupper($key)]); } } return $output; } $this->template->assign_vars(array('BANK_INTEREST_PERIOD' => time_format($points_values['bank_pay_period']), 'BANK_COST' => sprintf($this->functions_points->number_format_points($points_values['bank_cost'])), 'LOTTERY_NAME' => $points_values['lottery_name'], 'BANK_NAME' => $points_values['bank_name'], 'BANK_NOBODY_IN_BANK' => sprintf($this->user->lang['BANK_NOBODY_IN_BANK'], $this->config['points_name'], $points_values['bank_name']), 'S_DISPLAY_INDEX' => $points_values['number_show_top_points'] > 0 ? true : false, 'L_BANK_DESCRIPTION' => sprintf($this->user->lang['BANK_DESCRIPTION'], $this->config['points_name']), 'U_TRANSFER_USER' => $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'transfer_user')), 'U_LOGS' => $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'logs')), 'U_LOTTERY' => $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'lottery')), 'U_BANK' => $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'bank')), 'U_ROBBERY' => $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'robbery')), 'U_INFO' => $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'info')), 'U_USE_TRANSFER' => $this->auth->acl_get('u_use_transfer'), 'U_USE_LOGS' => $this->auth->acl_get('u_use_logs'), 'U_USE_LOTTERY' => $this->auth->acl_get('u_use_lottery'), 'U_USE_BANK' => $this->auth->acl_get('u_use_bank'), 'U_USE_ROBBERY' => $this->auth->acl_get('u_use_robbery'))); page_footer(); }
public function notification_markread($item_ids) { // Mark post notifications read for this user in this topic $this->notification_manager->mark_notifications_read(array('gfksx.thanksforposts.notification.type.thanks', 'gfksx.thanksforposts.notification.type.thanks_remove'), $item_ids, $this->user->data['user_id']); }
public function posts_merging($event) { $mode = $event['mode']; $subject = $event['subject']; $username = $event['username']; $topic_type = $event['topic_type']; $poll = $event['poll']; $data = $event['data']; $update_message = $event['update_message']; $update_search_index = $event['update_search_index']; $current_time = time(); $do_not_merge_with_previous = $this->request->variable('posts_merging_option', false); if (!$do_not_merge_with_previous && !$this->helper->post_needs_approval($data) && in_array($mode, array('reply', 'quote')) && $this->merge_interval && !$this->helper->excluded_from_merge($data)) { $merge_post_data = $this->helper->get_last_post_data($data); // Do not merge if there's no last post data, the post is locked or allowed merge period has left if (!$merge_post_data || $merge_post_data['post_edit_locked'] || $current_time - (int) $merge_post_data['topic_last_post_time'] > $this->merge_interval || !$this->user->data['is_registered']) { return; } // Also, don't let user to violate attachments limit by posts merging // In this case, also don't merge posts and return // Exceptions are administrators and forum moderators $num_old_attachments = $this->helper->count_post_attachments((int) $merge_post_data['post_id']); $num_new_attachments = sizeof($data['attachment_data']); $total_attachments_count = $num_old_attachments + $num_new_attachments; if ($total_attachments_count > $this->config['max_attachments'] && !$this->auth->acl_get('a_') && !$this->auth->acl_get('m_', (int) $data['forum_id'])) { return; } $data['post_id'] = (int) $merge_post_data['post_id']; $merge_post_data['post_attachment'] = $total_attachments_count ? 1 : 0; // Decode old message and addon $merge_post_data['post_text'] = $this->helper->prepare_text_for_merge($merge_post_data); $data['message'] = $this->helper->prepare_text_for_merge($data); // Handle inline attachments BBCode in old message if ($num_new_attachments) { $merge_post_data['post_text'] = preg_replace('#\\[attachment=([0-9]+)\\](.*?)\\[\\/attachment\\]#e', "'[attachment='.(\\1 + {$num_new_attachments}).']\\2[/attachment]'", $merge_post_data['post_text']); } // Prepare message separator $this->user->add_lang_ext('rxu/PostsMerging', 'posts_merging'); $interval = $this->helper->get_time_interval($current_time, $merge_post_data['post_time']); $time = array(); $time[] = $interval->h ? $this->user->lang('D_HOURS', $interval->h) : null; $time[] = $interval->i ? $this->user->lang('D_MINUTES', $interval->i) : null; $time[] = $interval->s ? $this->user->lang('D_SECONDS', $interval->s) : null; $separator = $this->user->lang('MERGE_SEPARATOR', implode(' ', $time)); // Merge subject if (!empty($subject) && $subject != $merge_post_data['post_subject'] && $merge_post_data['post_id'] != $merge_post_data['topic_first_post_id']) { $separator .= sprintf($this->user->lang['MERGE_SUBJECT'], $subject); } // Merge posts $merge_post_data['post_text'] = $merge_post_data['post_text'] . $separator . $data['message']; // Make sure the message is safe $this->type_cast_helper->recursive_set_var($merge_post_data['post_text'], '', true); //Prepare post for submit $options = ''; $warn_msg = generate_text_for_storage($merge_post_data['post_text'], $merge_post_data['bbcode_uid'], $merge_post_data['bbcode_bitfield'], $options, $merge_post_data['enable_bbcode'], $merge_post_data['enable_magic_url'], $merge_post_data['enable_smilies']); // If $warn_msg is not empty, the merged message does not conform some restrictions // In this case we simply don't merge and return back to the function submit_post() if (!empty($warn_msg)) { return; } // Update post time and submit post to database $merge_post_data['post_time'] = $data['post_time'] = $current_time; $this->helper->submit_post_to_database($merge_post_data); // Submit attachments $this->helper->submit_attachments($data); // Update read tracking $this->helper->update_read_tracking($data); // If a username was supplied or the poster is a guest, we will use the supplied username. // Doing it this way we can use "...post by guest-username..." in notifications when // "guest-username" is supplied or ommit the username if it is not. $username = $username !== '' || !$this->user->data['is_registered'] ? $username : $this->user->data['username']; // Send Notifications // Despite the post_id is the same and users who've been already notified // won't be notified again about the same post_id, we send notifications // for new users possibly subscribed to it $notification_data = array_merge($data, array('topic_title' => isset($data['topic_title']) ? $data['topic_title'] : $subject, 'post_username' => $username, 'poster_id' => (int) $data['poster_id'], 'post_text' => $data['message'], 'post_time' => $merge_post_data['post_time'], 'post_subject' => $subject)); $this->notification_manager->add_notifications(array('notification.type.quote', 'notification.type.bookmark', 'notification.type.post'), $notification_data); // Update search index $this->helper->update_search_index($merge_post_data); //Generate redirection URL and redirecting $params = $add_anchor = ''; $params .= '&t=' . $data['topic_id']; $params .= '&p=' . $data['post_id']; $add_anchor = '#p' . $data['post_id']; $url = "{$this->phpbb_root_path}viewtopic.{$this->php_ext}"; $url = append_sid($url, 'f=' . $data['forum_id'] . $params) . $add_anchor; /** * Modify the data for post submitting * * @event rxu.postsmerging.posts_merging_end * @var string mode Variable containing posting mode value * @var string subject Variable containing post subject value * @var string username Variable containing post author name * @var int topic_type Variable containing topic type value * @var array poll Array with the poll data for the post * @var array data Array with the data for the post * @var bool update_message Flag indicating if the post will be updated * @var bool update_search_index Flag indicating if the search index will be updated * @var string url The "Return to topic" URL * @since 2.0.0 */ $vars = array('mode', 'subject', 'username', 'topic_type', 'poll', 'data', 'update_message', 'update_search_index', 'url'); extract($this->phpbb_dispatcher->trigger_event('rxu.postsmerging.posts_merging_end', compact($vars))); redirect($url); } }
/** * Edit an article * * @param string $article URL of the article * @return object */ public function edit_article($article) { // @TODO $this->option['bbcode'] = $this->option['url'] = $this->option['img'] = $this->option['flash'] = $this->option['quote'] = $this->option['smilies'] = true; // If no auth to edit, display error message if (!$this->auth->acl_get('u_wiki_edit')) { trigger_error('NO_ARTICLE'); } // Setup message parser $this->message_parser = $this->setup_parser(); // Get data for article $this->data = $this->get_article_data($article); // Article is a redirect and no auth to edit redirect if (!empty($this->data['article_redirect']) && !$this->auth->acl_get('u_wiki_set_redirect')) { trigger_error('NOT_AUTHORISED'); } $this->user->add_lang('posting'); $preview = $this->request->is_set_post('preview'); $submit = $this->request->is_set_post('submit'); $error = array(); if ($preview || $submit) { $this->data['article_title'] = $this->request->variable('title', '', true); $this->data['article_text'] = $this->request->variable('message', '', true); $this->data['article_description'] = $this->request->variable('article_description', '', true); $this->data['article_edit_reason'] = $this->request->variable('edit_reason', '', true); $this->data['article_sources'] = $this->request->variable('sources', '', true); $this->data['article_topic_id'] = $this->auth->acl_get('u_wiki_edit_topic') ? $this->request->variable('topic_id', '', true) : $this->data['article_topic_id']; $this->data['article_approved'] = $this->auth->acl_get('u_wiki_set_active') ? $this->request->variable('set_active', 0) : 0; $this->data['article_sticky'] = $this->auth->acl_get('u_wiki_set_sticky') ? $this->request->variable('set_sticky', 0) : $this->data['article_sticky']; $this->data['article_redirect'] = $this->auth->acl_get('u_wiki_set_redirect') ? $this->request->variable('article_redirect', '', true) : $this->data['article_redirect']; $this->data['article_time_created'] = empty($this->data['article_time_created']) ? time() : $this->data['article_time_created']; // Validate user input $validate_array = array('article_title' => array('string', false, 1, 255), 'article_text' => array('string', false, $this->config['min_post_chars'], $this->config['max_post_chars']), 'article_edit_reason' => array('string', true, 0, 255), 'article_redirect' => array('string', true, 0, 255), 'article_description' => array('string', true, 0, 255), 'article_sources' => array('string', true, 0, 255)); if (!function_exists('validate_data')) { include $this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext; } $error = validate_data($this->data, $validate_array); // Validate sources URL $sources_array = explode("\n", $this->data['article_sources']); foreach ($sources_array as $source) { if (!empty($source) && !filter_var($source, FILTER_VALIDATE_URL)) { $error[] = $this->user->lang['INVALID_SOURCE_URL']; } } $this->message_parser->message = $this->data['article_text']; } if (sizeof($error)) { $this->template->assign_vars(array('ERROR' => implode('<br />', $error))); $this->display_edit_form(false); } else { if ($preview) { $this->message_parser->parse($this->option['bbcode'], $this->option['url'], $this->option['smilies'], $this->option['img'], $this->option['flash'], $this->option['quote']); $this->message_parser->format_display($this->option['bbcode'], $this->option['url'], $this->option['smilies']); foreach ($sources_array as $source) { if (!empty($source)) { $this->template->assign_block_vars('article_sources', array('SOURCE' => $source)); } } $this->display_edit_form(true); } else { if ($submit) { $this->message_parser->parse($this->option['bbcode'], $this->option['url'], $this->option['smilies'], $this->option['img'], $this->option['flash'], $this->option['quote']); $sql_data = array('article_title' => $this->data['article_title'], 'article_url' => $article, 'article_text' => $this->message_parser->message, 'bbcode_uid' => $this->message_parser->bbcode_uid, 'bbcode_bitfield' => $this->message_parser->bbcode_bitfield, 'article_approved' => (int) $this->data['article_approved'], 'article_user_id' => (int) $this->user->data['user_id'], 'article_last_edit' => time(), 'article_time_created' => $this->data['article_time_created'], 'article_edit_reason' => $this->data['article_edit_reason'], 'article_topic_id' => (int) $this->data['article_topic_id'], 'article_sources' => $this->data['article_sources'], 'article_sticky' => (int) $this->data['article_sticky'], 'article_views' => (int) $this->data['article_views'], 'article_redirect' => $this->data['article_redirect'], 'article_description' => $this->data['article_description'], 'article_toc' => ''); $sql = 'INSERT INTO ' . $this->article_table . ' ' . $this->db->sql_build_array('INSERT', $sql_data); $this->db->sql_query($sql); $article_id = $this->db->sql_nextid(); if ($this->auth->acl_get('u_wiki_set_active') && $this->data['article_approved'] != 0) { $this->set_active_version($article_id); } else { $notify_data = array('article_id' => $article_id, 'article_title' => $this->data['article_title'], 'article_url' => $article, 'user_id' => $this->user->data['user_id']); $this->notification_manager->add_notifications('tas2580.wiki.notification.type.articke_edit', $notify_data); } $msg = $this->data['article_approved'] != 0 ? $this->user->lang['EDIT_ARTICLE_SUCCESS'] : $this->user->lang['EDIT_ARTICLE_SUCCESS_INACTIVE']; $back_url = empty($article) ? $this->helper->route('tas2580_wiki_index', array()) : $this->helper->route('tas2580_wiki_article', array('article' => $article)); trigger_error($msg . '<br /><br /><a href="' . $back_url . '">' . $this->user->lang['BACK_TO_ARTICLE'] . '</a>'); } else { $this->message_parser->message = $this->data['article_text']; $this->message_parser->decode_message($this->data['bbcode_uid']); $this->display_edit_form(false); } } } return $this->helper->render('article_edit.html', $this->user->lang['EDIT_WIKI']); }
/** * Notify users which watch categories * * @param $row Informations about website * @return null */ private function _notify_suscribers($row) { $notification_data = array('user_from' => (int) $row['link_user_id'], 'link_id' => (int) $row['link_id'], 'link_name' => $row['link_name'], 'link_url' => $row['link_url'], 'link_description' => preg_replace('/(\\[.*?\\])(.*?)(\\[\\/.*?\\])/si', '\\1', $row['link_description']), 'cat_name' => \ernadoo\phpbbdirectory\core\categorie::getname((int) $row['link_cat']), 'cat_id' => (int) $row['link_cat']); $this->notification->add_notifications('ernadoo.phpbbdirectory.notification.type.directory_website', $notification_data); }
/** * Notify user about reputation * * @param string $notification_type_name Notification type name * @param array $data Notification data * @access public * @return null */ public function add_notification($notification_type_name, $data) { $data = array_merge(array('reputation_id' => $this->reputation_id), $data); $this->notification_manager->add_notifications($notification_type_name, $data); }