Exemple #1
0
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     $this->db->sql_return_on_error(true);
     $languages = $this->language_helper->get_available_languages();
     $installed_languages = array();
     foreach ($languages as $lang_info) {
         $lang_pack = array('lang_iso' => $lang_info['iso'], 'lang_dir' => $lang_info['iso'], 'lang_english_name' => htmlspecialchars($lang_info['name']), 'lang_local_name' => htmlspecialchars($lang_info['local_name'], ENT_COMPAT, 'UTF-8'), 'lang_author' => htmlspecialchars($lang_info['author'], ENT_COMPAT, 'UTF-8'));
         $this->db->sql_query('INSERT INTO ' . LANG_TABLE . ' ' . $this->db->sql_build_array('INSERT', $lang_pack));
         $installed_languages[] = (int) $this->db->sql_nextid();
         if ($this->db->get_sql_error_triggered()) {
             $error = $this->db->sql_error($this->db->get_sql_error_sql());
             $this->iohandler->add_error_message($error['message']);
         }
     }
     $sql = 'SELECT * FROM ' . PROFILE_FIELDS_TABLE;
     $result = $this->db->sql_query($sql);
     $insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, PROFILE_LANG_TABLE);
     while ($row = $this->db->sql_fetchrow($result)) {
         foreach ($installed_languages as $lang_id) {
             $insert_buffer->insert(array('field_id' => $row['field_id'], 'lang_id' => $lang_id, 'lang_name' => strtoupper(substr($row['field_name'], 6)), 'lang_explain' => '', 'lang_default_value' => ''));
         }
     }
     $this->db->sql_freeresult($result);
     $insert_buffer->flush();
 }
Exemple #2
0
 /**
  * Creates a report entity in the database
  *
  * @param	array	$report_data
  * @return	int	the ID of the created entity
  */
 protected function create_report(array $report_data)
 {
     $sql_ary = array('reason_id' => (int) $report_data['reason_id'], 'post_id' => $report_data['post_id'], 'pm_id' => $report_data['pm_id'], 'user_id' => (int) $this->user->data['user_id'], 'user_notify' => (int) $report_data['user_notify'], 'report_closed' => 0, 'report_time' => (int) time(), 'report_text' => (string) $report_data['report_text'], 'reported_post_text' => $report_data['reported_post_text'], 'reported_post_uid' => $report_data['reported_post_uid'], 'reported_post_bitfield' => $report_data['reported_post_bitfield'], 'reported_post_enable_bbcode' => $report_data['reported_post_enable_bbcode'], 'reported_post_enable_smilies' => $report_data['reported_post_enable_smilies'], 'reported_post_enable_magic_url' => $report_data['reported_post_enable_magic_url']);
     $sql = 'INSERT INTO ' . REPORTS_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary);
     $this->db->sql_query($sql);
     return $this->db->sql_nextid();
 }
Exemple #3
0
    /**
     * Get the notification type id from the name
     *
     * @param string $notification_type_name The name
     * @return int the notification_type_id
     * @throws \phpbb\notification\exception
     */
    public function get_notification_type_id($notification_type_name)
    {
        $notification_type_ids = $this->cache->get('notification_type_ids');
        $this->db->sql_transaction('begin');
        if ($notification_type_ids === false) {
            $notification_type_ids = array();
            $sql = 'SELECT notification_type_id, notification_type_name
				FROM ' . $this->notification_types_table;
            $result = $this->db->sql_query($sql);
            while ($row = $this->db->sql_fetchrow($result)) {
                $notification_type_ids[$row['notification_type_name']] = (int) $row['notification_type_id'];
            }
            $this->db->sql_freeresult($result);
            $this->cache->put('notification_type_ids', $notification_type_ids);
        }
        if (!isset($notification_type_ids[$notification_type_name])) {
            if (!isset($this->notification_types[$notification_type_name]) && !isset($this->notification_types['notification.type.' . $notification_type_name])) {
                throw new \phpbb\notification\exception('NOTIFICATION_TYPE_NOT_EXIST', array($notification_type_name));
            }
            $sql = 'INSERT INTO ' . $this->notification_types_table . ' ' . $this->db->sql_build_array('INSERT', array('notification_type_name' => $notification_type_name, 'notification_type_enabled' => 1));
            $this->db->sql_query($sql);
            $notification_type_ids[$notification_type_name] = (int) $this->db->sql_nextid();
            $this->cache->put('notification_type_ids', $notification_type_ids);
        }
        $this->db->sql_transaction('commit');
        return $notification_type_ids[$notification_type_name];
    }
 /**
  * Post a new message to the shoutbox.
  *
  * @return \Symfony\Component\HttpFoundation\JsonResponse
  */
 public function post()
 {
     // We always disallow guests to post in the shoutbox.
     if (!$this->auth->acl_get('u_shoutbox_post') || $this->user->data['user_id'] == ANONYMOUS) {
         return $this->error('AJAX_SHOUTBOX_ERROR', 'AJAX_SHOUTBOX_NO_PERMISSION', 403);
     }
     if ($this->request->is_ajax()) {
         $message = $msg = trim(utf8_normalize_nfc($this->request->variable('text_shoutbox', '', true)));
         if (empty($message)) {
             return $this->error('AJAX_SHOUTBOX_ERROR', 'AJAX_SHOUTBOX_MESSAGE_EMPTY', 500);
         }
         $uid = $bitfield = $options = '';
         $allow_bbcode = $this->auth->acl_get('u_shoutbox_bbcode');
         $allow_urls = $allow_smilies = true;
         if (!function_exists('generate_text_for_storage')) {
             include $this->root_path . 'includes/functions_content.' . $this->php_ext;
         }
         generate_text_for_storage($message, $uid, $bitfield, $options, $allow_bbcode, $allow_urls, $allow_smilies);
         $insert = array('post_message' => $message, 'post_time' => time(), 'user_id' => $this->user->data['user_id'], 'bbcode_options' => $options, 'bbcode_bitfield' => $bitfield, 'bbcode_uid' => $uid);
         $sql = 'INSERT INTO ' . $this->table . ' ' . $this->db->sql_build_array('INSERT', $insert);
         $this->db->sql_query($sql);
         if ($this->push->canPush()) {
             // User configured us to submit the shoutbox post to the iOS/Android app
             $this->push->post($msg, $insert['post_time'], $this->user->data['username'], $this->db->sql_nextid());
         }
         return new JsonResponse(array('OK'));
     } else {
         return $this->error('AJAX_SHOUTBOX_ERROR', 'AJAX_SHOUTBOX_ONLY_AJAX', 500);
     }
 }
    /**
     * Submit auto group rule form data
     *
     * @param int $autogroups_id An auto group identifier
     *                           A value of 0 is new, otherwise we're updating
     * @return null
     * @access protected
     */
    protected function submit_autogroup_rule($autogroups_id = 0)
    {
        $data = array('autogroups_type_id' => $this->request->variable('autogroups_type_id', 0), 'autogroups_min_value' => $this->request->variable('autogroups_min_value', 0), 'autogroups_max_value' => $this->request->variable('autogroups_max_value', 0), 'autogroups_group_id' => $this->request->variable('autogroups_group_id', 0), 'autogroups_default' => $this->request->variable('autogroups_default', false), 'autogroups_notify' => $this->request->variable('autogroups_notify', false));
        // Prevent form submit when no user groups are available or selected
        if (!$data['autogroups_group_id']) {
            trigger_error($this->user->lang('ACP_AUTOGROUPS_INVALID_GROUPS') . adm_back_link($this->u_action), E_USER_WARNING);
        }
        // Prevent form submit when min and max values are identical
        if ($data['autogroups_min_value'] == $data['autogroups_max_value']) {
            trigger_error($this->user->lang('ACP_AUTOGROUPS_INVALID_RANGE') . adm_back_link($this->u_action), E_USER_WARNING);
        }
        if ($autogroups_id != 0) {
            $sql = 'UPDATE ' . $this->autogroups_rules_table . '
				SET ' . $this->db->sql_build_array('UPDATE', $data) . '
				WHERE autogroups_id = ' . (int) $autogroups_id;
            $this->db->sql_query($sql);
        } else {
            $sql = 'INSERT INTO ' . $this->autogroups_rules_table . ' ' . $this->db->sql_build_array('INSERT', $data);
            $this->db->sql_query($sql);
            $autogroups_id = $this->db->sql_nextid();
        }
        // Apply the auto group to all users
        $this->manager->sync_autogroups($autogroups_id);
        // Log the action
        $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'ACP_AUTOGROUPS_SAVED_LOG', time());
        // Output message to user after submitting the form
        trigger_error($this->user->lang('ACP_AUTOGROUPS_SUBMIT_SUCCESS') . adm_back_link($this->u_action));
    }
 /**
  * {@inheritdoc}
  */
 public function insert(array $additional_data)
 {
     $item_data = $this->reset_nestedset_values($additional_data);
     $sql = 'INSERT INTO ' . $this->table_name . ' ' . $this->db->sql_build_array('INSERT', $item_data);
     $this->db->sql_query($sql);
     $item_data[$this->column_item_id] = (int) $this->db->sql_nextid();
     return array_merge($item_data, $this->add_item_to_nestedset($item_data[$this->column_item_id]));
 }
Exemple #7
0
 /**
  * Add new condition type
  *
  * @param string $autogroups_type_name The name of the auto group type
  *
  * @return int The identifier of the new condition type
  * @access public
  */
 public function add_autogroups_type($autogroups_type_name)
 {
     // Insert the type name into the database
     $sql = 'INSERT INTO ' . $this->autogroups_types_table . ' ' . $this->db->sql_build_array('INSERT', array('autogroups_type_name' => (string) $autogroups_type_name));
     $this->db->sql_query($sql);
     // Return the id of the newly inserted condition type
     return (int) $this->db->sql_nextid();
 }
 /**
  * Insert a new row in the table corresponding to the specified entity
  */
 protected function _insert($entity)
 {
     if ($entity instanceof $this->_entity_class) {
         $this->db->sql_query('INSERT INTO ' . $this->_entity_table . ' ' . $this->db->sql_build_array('INSERT', $entity->to_db()));
         $mutator = 'set_' . $this->_entity_pkey;
         $entity->{$mutator}((int) $this->db->sql_nextid());
         return $entity;
     }
     throw new \blitze\sitemaker\exception\unexpected_value('INVALID_ENTITY');
 }
Exemple #9
0
    /**
     * Update/Add module
     *
     * @param array	&$module_data	The module data
     *
     * @throws \phpbb\module\exception\module_not_found_exception	When parent module or the category is not exist
     */
    public function update_module_data(&$module_data)
    {
        if (!isset($module_data['module_id'])) {
            // no module_id means we're creating a new category/module
            if ($module_data['parent_id']) {
                $sql = 'SELECT left_id, right_id
					FROM ' . $this->modules_table . "\n\t\t\t\t\tWHERE module_class = '" . $this->db->sql_escape($module_data['module_class']) . "'\n\t\t\t\t\t\tAND module_id = " . (int) $module_data['parent_id'];
                $result = $this->db->sql_query($sql);
                $row = $this->db->sql_fetchrow($result);
                $this->db->sql_freeresult($result);
                if (!$row) {
                    throw new module_not_found_exception('PARENT_NOT_EXIST');
                }
                // Workaround
                $row['left_id'] = (int) $row['left_id'];
                $row['right_id'] = (int) $row['right_id'];
                $sql = 'UPDATE ' . $this->modules_table . "\n\t\t\t\t\tSET left_id = left_id + 2, right_id = right_id + 2\n\t\t\t\t\tWHERE module_class = '" . $this->db->sql_escape($module_data['module_class']) . "'\n\t\t\t\t\t\tAND left_id > {$row['right_id']}";
                $this->db->sql_query($sql);
                $sql = 'UPDATE ' . $this->modules_table . "\n\t\t\t\t\tSET right_id = right_id + 2\n\t\t\t\t\tWHERE module_class = '" . $this->db->sql_escape($module_data['module_class']) . "'\n\t\t\t\t\t\tAND {$row['left_id']} BETWEEN left_id AND right_id";
                $this->db->sql_query($sql);
                $module_data['left_id'] = (int) $row['right_id'];
                $module_data['right_id'] = (int) $row['right_id'] + 1;
            } else {
                $sql = 'SELECT MAX(right_id) AS right_id
					FROM ' . $this->modules_table . "\n\t\t\t\t\tWHERE module_class = '" . $this->db->sql_escape($module_data['module_class']) . "'";
                $result = $this->db->sql_query($sql);
                $row = $this->db->sql_fetchrow($result);
                $this->db->sql_freeresult($result);
                $module_data['left_id'] = (int) $row['right_id'] + 1;
                $module_data['right_id'] = (int) $row['right_id'] + 2;
            }
            $sql = 'INSERT INTO ' . $this->modules_table . ' ' . $this->db->sql_build_array('INSERT', $module_data);
            $this->db->sql_query($sql);
            $module_data['module_id'] = $this->db->sql_nextid();
        } else {
            $row = $this->get_module_row($module_data['module_id'], $module_data['module_class']);
            if ($module_data['module_basename'] && !$row['module_basename']) {
                // we're turning a category into a module
                $branch = $this->get_module_branch($module_data['module_id'], $module_data['module_class'], 'children', false);
                if (sizeof($branch)) {
                    throw new module_not_found_exception('NO_CATEGORY_TO_MODULE');
                }
            }
            if ($row['parent_id'] != $module_data['parent_id']) {
                $this->move_module($module_data['module_id'], $module_data['parent_id'], $module_data['module_class']);
            }
            $update_ary = $module_data;
            unset($update_ary['module_id']);
            $sql = 'UPDATE ' . $this->modules_table . '
				SET ' . $this->db->sql_build_array('UPDATE', $update_ary) . "\n\t\t\t\tWHERE module_class = '" . $this->db->sql_escape($module_data['module_class']) . "'\n\t\t\t\t\tAND module_id = " . (int) $module_data['module_id'];
            $this->db->sql_query($sql);
        }
    }
Exemple #10
0
    public function add_thing()
    {
        if (!$this->auth->acl_get('u_usermap_add_thing')) {
            trigger_error('NOT_AUTHORISED');
        }
        include $this->phpbb_root_path . 'includes/functions_posting.' . $this->php_ext;
        include $this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext;
        $bbcode_status = $this->config['tas2580_usermap_allow_bbcode'];
        $url_status = $this->config['tas2580_usermap_allow_urls'];
        $img_status = $this->config['tas2580_usermap_allow_img'];
        $flash_status = $this->config['tas2580_usermap_allow_flash'];
        $smilies_status = $this->config['tas2580_usermap_allow_smilies'];
        $marker = '';
        $this->user->add_lang('posting');
        $submit = $this->request->is_set_post('submit');
        if ($submit) {
            $title = $this->request->variable('title', '', true);
            $message = $this->request->variable('message', '', true);
            $marker = $this->request->variable('marker', '', true);
            $data = array('lon' => (double) substr($this->request->variable('lon', ''), 0, 10), 'lat' => (double) substr($this->request->variable('lat', ''), 0, 10));
            $validate_array = array('lon' => array('match', false, self::REGEX_LON), 'lat' => array('match', false, self::REGEX_LAT));
            if (!function_exists('validate_data')) {
                include $this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext;
            }
            $error = validate_data($data, $validate_array);
            if (utf8_clean_string($title) === '') {
                $error[] = $this->user->lang['EMPTY_SUBJECT'];
            }
            if (utf8_clean_string($message) === '') {
                $error[] = $this->user->lang['TOO_FEW_CHARS'];
            }
            if (empty($marker)) {
                $error[] = $this->user->lang['NEED_MARKER'];
            }
            if (sizeof($error)) {
                $this->template->assign_vars(array('ERROR' => implode('<br />', $error), 'TITLE' => $title, 'MESSAGE' => $message));
            } else {
                generate_text_for_storage($message, $uid, $bitfield, $options, $bbcode_status, $url_status, $smilies_status);
                $sql_data = array('thing_title' => $title, 'thing_text' => $message, 'bbcode_uid' => $uid, 'bbcode_bitfield' => $bitfield, 'thing_lat' => $data['lat'], 'thing_lon' => $data['lon'], 'thing_marker' => $marker, 'thing_user_id' => $this->user->data['user_id']);
                $sql = 'INSERT INTO ' . $this->things_table . '
					' . $this->db->sql_build_array('INSERT', $sql_data);
                $this->db->sql_query($sql);
                $thing_id = $this->db->sql_nextid();
                trigger_error($this->user->lang['THING_ADDED'] . '<br /><br />' . '<a href="' . $this->helper->route('tas2580_usermap_thing', array('id' => $thing_id)) . '">' . $this->user->lang['BACK_TO_THING'] . '</a><br /><br />' . '<a href="' . $this->helper->route('tas2580_usermap_index', array()) . '">' . $this->user->lang['BACK_TO_USERMAP'] . '</a>');
            }
        }
        $path = $this->path_helper->update_web_root_path($this->phpbb_extension_manager->get_extension_path('tas2580/usermap', true) . 'marker/things');
        generate_smilies('inline', 0);
        display_custom_bbcodes();
        $s_hidden_fields = build_hidden_fields(array('lon' => $this->request->variable('lon', ''), 'lat' => $this->request->variable('lat', '')));
        $this->template->assign_vars(array('TITLE' => $this->request->variable('title', '', true), 'MESSAGE' => $this->request->variable('message', '', true), 'MARKER_OPTIONS' => $this->marker_image_select($marker, 'marker/things/'), 'USERMAP_MARKER_PATH' => $path, 'S_BBCODE_ALLOWED' => $bbcode_status, 'S_LINKS_ALLOWED' => $url_status, 'S_BBCODE_IMG' => $img_status, 'S_BBCODE_FLASH' => $flash_status, 'S_BBCODE_QUOTE' => 1, 'BBCODE_STATUS' => $bbcode_status ? sprintf($this->user->lang['BBCODE_IS_ON'], '<a href="' . append_sid("{$this->phpbb_root_path}faq.{$this->php_ext}", 'mode=bbcode') . '">', '</a>') : sprintf($this->user->lang['BBCODE_IS_OFF'], '<a href="' . append_sid("{$this->phpbb_root_path}faq.{$this->php_ext}", 'mode=bbcode') . '">', '</a>'), 'IMG_STATUS' => $img_status ? $this->user->lang['IMAGES_ARE_ON'] : $this->user->lang['IMAGES_ARE_OFF'], 'FLASH_STATUS' => $flash_status ? $this->user->lang['FLASH_IS_ON'] : $this->user->lang['FLASH_IS_OFF'], 'SMILIES_STATUS' => $smilies_status ? $this->user->lang['SMILIES_ARE_ON'] : $this->user->lang['SMILIES_ARE_OFF'], 'URL_STATUS' => $bbcode_status && $url_status ? $this->user->lang['URL_IS_ON'] : $this->user->lang['URL_IS_OFF'], 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'FORM_TITLE' => $this->user->lang('ADD_THING', $this->user->lang($this->config['tas2580_usermap_thing_name']))));
        return $this->helper->render('usermap_thing_form.html', $this->user->lang('ADD_THING', $this->user->lang($this->config['tas2580_usermap_thing_name'])));
    }
Exemple #11
0
 /**
  * Add entry
  * The user with $user_id must exist
  *
  * @param int $entry_id
  * @param array $answers
  */
 public function add_entry($user_id, $answers)
 {
     $entry = array('s_id' => $this->settings['s_id'], 'user_id' => $user_id);
     $sql = "INSERT INTO {$this->tables['entries']} " . $this->db->sql_build_array('INSERT', $entry);
     $this->db->sql_query($sql);
     $entry_id = $this->db->sql_nextid();
     $entry['entry_id'] = $entry_id;
     $entry['entry_username'] = '';
     $this->entries[$entry_id] = $entry;
     foreach ($answers as $question_id => $answer) {
         $this->add_answer($question_id, $entry_id, $answer);
     }
 }
 /**
  * Insert a question
  * @param mixed $data An array as created from acp_get_question_input or acp_get_question_data
  */
 public function acp_insert_question($data)
 {
     $langs = $this->get_languages();
     $question_ary = $data;
     $question_ary['lang_id'] = $langs[$data['lang_iso']]['id'];
     unset($question_ary['options_left']);
     unset($question_ary['options_right']);
     $sql = 'INSERT INTO ' . $this->table_sortables_questions . $this->db->sql_build_array('INSERT', $question_ary);
     $this->db->sql_query($sql);
     $question_id = $this->db->sql_nextid();
     $this->acp_insert_answers($data, $question_id);
     $this->cache->destroy('sql', $this->table_sortables_questions);
 }
Exemple #13
0
 /**
  * Insert the page data for the first time
  *
  * Will throw an exception if the page was already inserted (call save() instead)
  *
  * @return page_interface $this object for chaining calls; load()->set()->save()
  * @access public
  * @throws \phpbb\pages\exception\out_of_bounds
  */
 public function insert()
 {
     if (!empty($this->data['page_id'])) {
         // The page already exists
         throw new \phpbb\pages\exception\out_of_bounds('page_id');
     }
     // Insert the page data to the database
     $sql = 'INSERT INTO ' . $this->pages_table . ' ' . $this->db->sql_build_array('INSERT', $this->data);
     $this->db->sql_query($sql);
     // Set the page_id using the id created by the SQL insert
     $this->data['page_id'] = (int) $this->db->sql_nextid();
     return $this;
 }
 /**
  * Performs add|edit|del|clean|prune actions
  */
 public function mchat_action($action, $sql_ary = null, $message_id = 0, $log_username = '')
 {
     switch ($action) {
         // User adds a message
         case 'add':
             $sql = 'INSERT INTO ' . $this->mchat_table . ' ' . $this->db->sql_build_array('INSERT', $sql_ary);
             $this->mchat_add_user_session();
             break;
             // User edits a message
         // User edits a message
         case 'edit':
             $sql = 'UPDATE ' . $this->mchat_table . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE message_id = ' . (int) $message_id;
             $this->mchat_add_user_session();
             $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_EDITED_MCHAT', false, array($log_username));
             break;
             // User deletes a message
         // User deletes a message
         case 'del':
             $sql = 'DELETE FROM ' . $this->mchat_table . ' WHERE message_id = ' . (int) $message_id;
             $this->mchat_add_user_session();
             $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_DELETED_MCHAT', false, array($log_username));
             $this->cache->destroy('sql', $this->mchat_table);
             break;
             // Founder purges all messages
         // Founder purges all messages
         case 'clean':
             $sql = 'TRUNCATE TABLE ' . $this->mchat_table;
             $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_MCHAT_TABLE_PRUNED');
             $this->cache->destroy('sql', $this->mchat_table);
             break;
             // User triggers messages to be pruned
         // User triggers messages to be pruned
         case 'prune':
             $sql = 'DELETE FROM ' . $this->mchat_table . ' WHERE message_id < ' . (int) $message_id;
             $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_MCHAT_TABLE_PRUNED');
             $this->cache->destroy('sql', $this->mchat_table);
             break;
         default:
             return;
     }
     $result = $this->db->sql_query($sql);
     if ($result !== false) {
         switch ($action) {
             case 'add':
                 if ($this->db->sql_nextid() == 1) {
                     $this->cache->destroy('sql', $this->mchat_table);
                 }
                 break;
         }
     }
 }
 /**
  * Inserts object data into $this->sql_table.
  * Sets the identifier property to the correct id.
  *
  * @return	bool		true on success, else false
  */
 public function insert()
 {
     $sql_array = array();
     foreach ($this->object_config as $name => $null) {
         $sql_array[$name] = $this->validate_property($this->{$name}, $this->object_config[$name]);
     }
     $sql = 'INSERT INTO ' . $this->sql_table . ' ' . $this->db->sql_build_array('INSERT', $sql_array);
     $this->db->sql_query($sql);
     if ($id = $this->db->sql_nextid()) {
         $this->{$this->sql_id_field} = $id;
         return true;
     }
     return false;
 }
    /**
     * Add a link into db
     *
     * @param	array	$data			Contains all data to insert in db
     * @param	bool	$need_approval	Links needs to be approved?
     * @return	null
     */
    public function add($data, $need_approval)
    {
        $notification_data = array();
        $this->db->sql_transaction('begin');
        $sql = 'INSERT INTO ' . DIR_LINK_TABLE . ' ' . $this->db->sql_build_array('INSERT', $data);
        $this->db->sql_query($sql);
        $notification_data['link_id'] = $this->db->sql_nextid();
        if (!$need_approval || $this->auth->acl_get('a_') || $this->auth->acl_get('m_')) {
            $sql = 'UPDATE ' . DIR_CAT_TABLE . '
				SET cat_links = cat_links + 1
				WHERE cat_id = ' . (int) $data['link_cat'];
            $this->db->sql_query($sql);
            $notification_type = 'ernadoo.phpbbdirectory.notification.type.directory_website';
        } else {
            if ($this->config['dir_mail']) {
                $notification_type = 'ernadoo.phpbbdirectory.notification.type.directory_website_in_queue';
            }
        }
        $this->db->sql_transaction('commit');
        if (isset($notification_type)) {
            $notification_data = array_merge($notification_data, array('user_from' => (int) $data['link_user_id'], 'link_name' => $data['link_name'], 'link_url' => $data['link_url'], 'link_description' => $data['link_description'], 'cat_id' => (int) $data['link_cat'], 'cat_name' => \ernadoo\phpbbdirectory\core\categorie::getname((int) $data['link_cat'])));
            $this->notification->add_notifications($notification_type, $notification_data);
        }
    }
Exemple #17
0
 /**
  * Insert the Data for the first time
  *
  * Will throw an exception if the data was already inserted (call save() instead)
  *
  * @return Anniversary $this object for chaining calls; load()->set()->save()
  * @access public
  * @throws \consim\core\exception\out_of_bounds
  */
 public function insert()
 {
     if (!empty($this->data['anniversary_id'])) {
         // The data already exists
         throw new \consim\core\exception\out_of_bounds('id');
     }
     // Make extra sure there is no id set
     unset($this->data['anniversary_id']);
     // Insert the data to the database
     $sql = 'INSERT INTO ' . $this->consim_anniversary_table . $this->db->sql_build_array('INSERT', $this->data);
     $this->db->sql_query($sql);
     // Set the id using the id created by the SQL insert
     $this->data['anniversary_id'] = (int) $this->db->sql_nextid();
     return $this;
 }
 private function save_template()
 {
     $noty_parse_type = $this->request->variable('noty_parse_type', PARSE_AS_HTML);
     $noty_title = utf8_normalize_nfc($this->request->variable('noty_title', '', true));
     $noty_content = utf8_normalize_nfc($this->request->variable('noty_content', '', true));
     if ($noty_parse_type == PARSE_AS_HTML) {
         $noty_content = htmlspecialchars_decode($noty_content);
     }
     $noty_create_time = time();
     $save_data = array('noty_title' => utf8_normalize_nfc($this->request->variable('noty_title', '', true)), 'noty_content' => $noty_content, 'create_time' => $noty_create_time, 'parse_type' => $noty_parse_type);
     //add to DB
     $sql = 'INSERT INTO ' . $this->adminnotifications_table . ' ' . $this->db->sql_build_array('INSERT', $save_data);
     $this->db->sql_query($sql);
     $noty_id = $this->db->sql_nextid();
     $this->return = array('MESSAGE' => $this->user->lang['ACP_ADMINNOTIFICATIONS_SAVED'], 'noty_id' => $noty_id, 'noty_title' => $noty_title, 'noty_tooltip' => $this->character_limit($noty_content, 60), 'noty_content' => $noty_content, 'noty_create_time' => $this->user->format_date($noty_create_time, "d/m/Y H:i"), 'noty_parse_type' => $noty_parse_type);
 }
    /**
     * Install style
     *
     * @param array $style style data
     * @return int Style id
     */
    protected function install_style($style)
    {
        // Generate row
        $sql_ary = array();
        foreach ($style as $key => $value) {
            if ($key != 'style_id' && substr($key, 0, 1) != '_') {
                $sql_ary[$key] = $value;
            }
        }
        // Add to database
        $this->db->sql_transaction('begin');
        $sql = 'INSERT INTO ' . STYLES_TABLE . '
			' . $this->db->sql_build_array('INSERT', $sql_ary);
        $this->db->sql_query($sql);
        $id = $this->db->sql_nextid();
        $this->db->sql_transaction('commit');
        add_log('admin', 'LOG_STYLE_ADD', $sql_ary['style_name']);
        return $id;
    }
Exemple #20
0
 /**
  * Insert the rule for the first time
  *
  * Will throw an exception if the rule was already inserted (call save() instead)
  *
  * @param int $language The language identifier
  * @return rule_interface $this object for chaining calls; load()->set()->save()
  * @access public
  * @throws \phpbb\boardrules\exception\out_of_bounds
  */
 public function insert($language = 0)
 {
     if (!empty($this->data['rule_id'])) {
         // The rule already exists
         throw new \phpbb\boardrules\exception\out_of_bounds('rule_id');
     }
     // Resets values required for the nested set system
     $this->data['rule_parent_id'] = 0;
     $this->data['rule_left_id'] = 0;
     $this->data['rule_right_id'] = 0;
     $this->data['rule_parents'] = '';
     // Make extra sure there is no rule_id set
     unset($this->data['rule_id']);
     // Add the language identifier to the data array
     $this->data['rule_language'] = $language;
     // Insert the rule data to the database
     $sql = 'INSERT INTO ' . $this->boardrules_table . ' ' . $this->db->sql_build_array('INSERT', $this->data);
     $this->db->sql_query($sql);
     // Set the rule_id using the id created by the SQL insert
     $this->data['rule_id'] = (int) $this->db->sql_nextid();
     return $this;
 }
Exemple #21
0
    /**
     * Logs the daily stats.
     * NOTE: Currently not active, as there might be law conflicts in some states.
     */
    public function log()
    {
        if (!$this->config['wwh_version']) {
            // Logging not allowed for this mode.
            return;
        }
        $log_data = array('guest_users' => self::$count_guests, 'hidden_users' => self::$count_hidden, 'registered_users' => self::$count_reg, 'bots' => self::$count_bot, 'hidden_users_list' => implode(', ', self::$ids_hidden), 'registered_users_list' => implode(', ', self::$ids_reg), 'bots_list' => implode(', ', self::$ids_bot), 'start_time' => self::$prune_timestamp, 'end_time' => self::$prune_timestamp + 86400);
        $www_log_hash = self::$count_guests . '-' . self::$count_hidden . '-' . self::$count_reg . '-' . self::$count_bot;
        if (time() > $this->config['wwh_log_endtime'] || $this->config['wwh_log_hash'] != $www_log_hash) {
            if ($this->config['wwh_log_endtime'] > time()) {
                $sql = 'UPDATE ' . self::table('wwh_logs') . ' 
					SET ' . $this->db->sql_build_array('UPDATE', $log_data) . '
					WHERE log_id = ' . (int) $this->config['wwh_current_log_id'];
                $this->db->sql_query($sql);
            } else {
                $this->db->sql_query('INSERT INTO ' . self::table('wwh_logs') . ' ' . $this->db->sql_build_array('INSERT', $log_data));
                $this->config->set('wwh_current_log_id', (int) $this->db->sql_nextid());
                $this->config->set('wwh_log_endtime', $log_data['end_time']);
            }
            $this->config->set('wwh_log_hash', $www_log_hash);
        }
    }
Exemple #22
0
    /**
     * 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']);
    }
Exemple #23
0
    public function advanced_profile_system($event)
    {
        $member = $event['member'];
        $user_id = (int) $member['user_id'];
        // Get user_id of user we are viewing
        $username = $member['username'];
        $user_extra_rank_data = array('title' => null, 'img' => null, 'img_src' => null);
        $ranks_sql = 'SELECT *
				FROM ' . RANKS_TABLE . '
				WHERE rank_special != 1';
        $normal_ranks = $this->db->sql_query($ranks_sql);
        $spec_sql = 'SELECT rank_special 
					FROM ' . RANKS_TABLE . '
					WHERE rank_id = ' . $member['user_rank'];
        $special = $this->db->sql_query($spec_sql);
        if ($special !== 1) {
            if ($member['user_posts'] !== false) {
                if (!empty($normal_ranks)) {
                    foreach ($normal_ranks as $rank) {
                        if ($member['user_posts'] >= $rank['rank_min']) {
                            $user_extra_rank_data['title'] = $rank['rank_title'];
                            $user_extra_rank_data['img_src'] = !empty($rank['rank_image']) ? $this->phpbb_root_path . $this->config['ranks_path'] . '/' . $rank['rank_image'] : '';
                            $user_extra_rank_data['img'] = !empty($rank['rank_image']) ? '<img src="' . $user_extra_rank_data['img_src'] . '" alt="' . $rank['rank_title'] . '" title="' . $rank['rank_title'] . '" />' : '';
                            break;
                        }
                    }
                }
            }
        }
        $this->template->assign_vars(array('EXTRA_RANK_TITLE' => $user_extra_rank_data['title'], 'EXTRA_RANK_IMG' => $user_extra_rank_data['img']));
        /****************
         * PROFILE VIEWS *
         ****************/
        //	Make sure we have a session			Make sure user is not a bot.	 Do not increase view count if viewing own profile.
        if (isset($this->user->data['session_page']) && !$this->user->data['is_bot'] && $this->user->data['user_id'] != $user_id) {
            $incr_profile_views = 'UPDATE ' . USERS_TABLE . '
									SET user_profile_views = user_profile_views + 1
									WHERE user_id = ' . $user_id;
            $this->db->sql_query($incr_profile_views);
        }
        /****************
         * ACTIVITY FEED *
         ****************/
        $activity_feed_ary = array('SELECT' => 'p.*, t.*, u.username, u.user_colour', 'FROM' => array(POSTS_TABLE => 'p'), 'LEFT_JOIN' => array(array('FROM' => array(USERS_TABLE => 'u'), 'ON' => 'u.user_id = p.poster_id'), array('FROM' => array(TOPICS_TABLE => 't'), 'ON' => 'p.topic_id = t.topic_id')), 'WHERE' => $this->db->sql_in_set('t.forum_id', array_keys($this->auth->acl_getf('f_read', true))) . ' 
							AND t.topic_status <> ' . ITEM_MOVED . '
							AND t.topic_visibility = 1
							AND p.poster_id = ' . $user_id, 'ORDER_BY' => 'p.post_time DESC');
        $activity_feed = $this->db->sql_build_query('SELECT', $activity_feed_ary);
        $activity_feed_result = $this->db->sql_query_limit($activity_feed, 5);
        // Only get last five posts
        while ($af_row = $this->db->sql_fetchrow($activity_feed_result)) {
            $topic_id = $af_row['topic_id'];
            $post_id = $af_row['post_id'];
            $post_date = $this->user->format_date($af_row['post_time']);
            $post_url = append_sid("{$this->phpbb_root_path}viewtopic.{$this->phpEx}", 't=' . $topic_id . '&amp;p=' . $post_id) . '#p' . $post_id;
            // Parse the posts
            $af_row['bbcode_options'] = ($af_row['enable_bbcode'] ? OPTION_FLAG_BBCODE : 0) + ($af_row['enable_smilies'] ? OPTION_FLAG_SMILIES : 0) + ($af_row['enable_magic_url'] ? OPTION_FLAG_LINKS : 0);
            $text = generate_text_for_display($af_row['post_text'], $af_row['bbcode_uid'], $af_row['bbcode_bitfield'], $af_row['bbcode_options']);
            // Set a max length for the post to display
            $cutoff = ' …';
            $text = strlen($text) > 200 ? mb_substr($text, 0, 200) . $cutoff : $text;
            // See if user is able to view posts..
            $this->template->assign_block_vars('af', array('SUBJECT' => $af_row['post_subject'], 'TEXT' => $text, 'TIME' => $post_date, 'URL' => $post_url));
        }
        $this->db->sql_freeresult($activity_feed_result);
        // Master gave Dobby a sock, now Dobby is free!
        /***************
         * TOTAL TOPICS *
         ***************/
        $tt = 'SELECT COUNT(topic_poster) AS topic_author_count
				FROM ' . TOPICS_TABLE . '
				WHERE topic_poster = ' . $user_id;
        $total_topics_result = $this->db->sql_query($tt);
        $total_topics = (int) $this->db->sql_fetchfield('topic_author_count');
        $this->db->sql_freeresult($total_topics_result);
        // Master gave Dobby a sock, now Dobby is free!
        /***************
         * FRIENDS LIST *
         ***************/
        $sql_friend = array('SELECT' => 'u.user_id, u.username, u.username_clean, u.user_colour, MAX(s.session_time) as online_time, MIN(s.session_viewonline) AS viewonline', 'FROM' => array(USERS_TABLE => 'u', ZEBRA_TABLE => 'z'), 'LEFT_JOIN' => array(array('FROM' => array(SESSIONS_TABLE => 's'), 'ON' => 's.session_user_id = z.zebra_id')), 'WHERE' => 'z.user_id = ' . $user_id . '
				AND z.friend = 1
				AND u.user_id = z.zebra_id', 'GROUP_BY' => 'z.zebra_id, u.user_id, u.username_clean, u.user_colour, u.username', 'ORDER_BY' => 'u.username_clean ASC');
        $sql_friend_list = $this->db->sql_build_query('SELECT_DISTINCT', $sql_friend);
        $friend_result = $this->db->sql_query($sql_friend_list);
        while ($friend_row = $this->db->sql_fetchrow($friend_result)) {
            $img = phpbb_get_user_avatar($friend_row);
            // Use phpBB's Built in Avatar creator, for all types
            $has_avatar = false;
            if ($img == '') {
                $has_avatar = false;
                // This friend has no avatar..
            } else {
                $has_avatar = true;
                // This friend has an avatar
                $offset = 25;
                //Start off the img src
                $end = strpos($img, '"', $offset);
                // Find end of img src
                $length = $end - $offset;
                // Determine src length
                $friend_avatar = substr($img, $offset, $length);
                // Grab just the src
            }
            $this->template->assign_block_vars('friends', array('USERNAME' => get_username_string('full', $friend_row['user_id'], $friend_row['username'], $friend_row['user_colour']), 'AVATAR' => $friend_avatar, 'HAS_AVATAR' => $has_avatar));
        }
        $this->db->sql_freeresult($friend_result);
        // Master gave Dobby a sock, now Dobby is free!
        /*******
         * WALL *
         *******/
        // INSERTING A WALL POST
        add_form_key('postwall');
        $sendwall = isset($_POST['sendwall']) ? true : false;
        if ($sendwall) {
            if (check_form_key('postwall') && $this->auth->acl_get('u_wall_post')) {
                $msg_text = $this->request->variable('msg_text', '', true);
                $uid = $bitfield = $options = '';
                // will be modified by generate_text_for_storage
                $allow_bbcode = $allow_urls = $allow_smilies = true;
                generate_text_for_storage($msg_text, $uid, $bitfield, $options, $allow_bbcode, $allow_urls, $allow_smilies);
                $msg_time = time();
                $wall_ary = array('user_id' => $user_id, 'poster_id' => $this->user->data['user_id'], 'msg' => $msg_text, 'msg_time' => (int) $msg_time, 'bbcode_uid' => $uid, 'bbcode_bitfield' => $bitfield, 'bbcode_options' => $options);
                $insertwall = 'INSERT INTO ' . $this->wall_table . ' ' . $this->db->sql_build_array('INSERT', $wall_ary);
                $this->db->sql_query($insertwall);
                if ($user_id != $this->user->data['user_id']) {
                    $msg_id = (int) $this->db->sql_nextid();
                    $poster_name = get_username_string('no_profile', $this->user->data['user_id'], $this->user->data['username'], $this->user->data['user_colour']);
                    $notification_msg = $msg_text;
                    strip_bbcode($notification_msg, $uid);
                    $wall_notification_data = array('msg_id' => $msg_id, 'user_id' => $user_id, 'poster_name' => $poster_name, 'notification_msg' => strlen($notification_msg) > 30 ? substr($notification_msg, 0, 30) . '...' : $notification_msg);
                    $phpbb_notifications = $this->container->get('notification_manager');
                    $phpbb_notifications->add_notifications('posey.aps.notification.type.wall', $wall_notification_data);
                }
            } else {
                trigger_error($this->user->lang['FORM_INVALID']);
            }
        }
        // DISPLAYING WALL POSTS
        $getwall_ary = array('SELECT' => 'w.*, u.username, u.user_colour, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height', 'FROM' => array($this->wall_table => 'w'), 'LEFT_JOIN' => array(array('FROM' => array(USERS_TABLE => 'u'), 'ON' => 'u.user_id = w.poster_id')), 'WHERE' => 'w.user_id = ' . $user_id, 'ORDER_BY' => 'w.msg_id DESC');
        $getwall = $this->db->sql_build_query('SELECT_DISTINCT', $getwall_ary);
        $wallresult = $this->db->sql_query_limit($getwall, 10);
        // Only get latest 10 wall posts
        while ($wall = $this->db->sql_fetchrow($wallresult)) {
            $wall_msg = generate_text_for_display($wall['msg'], $wall['bbcode_uid'], $wall['bbcode_bitfield'], $wall['bbcode_options']);
            // Parse wall message text
            $msg_id = $wall['msg_id'];
            $msg_time = $this->user->format_date($wall['msg_time']);
            $this->template->assign_block_vars('wall', array('MSG' => $wall_msg, 'ID' => $wall['msg_id'], 'MSG_TIME' => $msg_time, 'POSTER' => get_username_string('full', $wall['poster_id'], $wall['username'], $wall['user_colour']), 'POSTER_AVATAR' => phpbb_get_user_avatar($wall), 'S_HIDDEN_FIELDS' => build_hidden_fields(array('deletewallid' => $wall['msg_id']))));
        }
        $this->db->sql_freeresult($wallresult);
        // Master gave Dobby a sock, now Dobby is free!
        // DELETE WALL POST
        $deletewall = isset($_POST['deletewall']) ? true : false;
        if ($deletewall) {
            if (confirm_box(true)) {
                $deletewallid = request_var('deletewallid', 0);
                $delete_msg = 'DELETE FROM ' . $this->wall_table . '
								WHERE msg_id = ' . $deletewallid;
                $this->db->sql_query($delete_msg);
                $msg_deleted_redirect = append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", "mode=viewprofile&amp;u=" . $user_id . "#wall");
                $message = $this->user->lang['CONFIRM_WALL_DEL'] . '<br /><br />' . sprintf($this->user->lang['RETURN_WALL'], '<a href="' . $msg_deleted_redirect . '">', $username, '</a>');
                meta_refresh(3, $msg_deleted_redirect);
                trigger_error($message);
            } else {
                $s_hidden_fields = build_hidden_fields(array('deletewall' => true, 'deletewallid' => request_var('deletewallid', 0)));
                confirm_box(false, $this->user->lang['CONFIRM_WALL_DEL_EXPLAIN'], $s_hidden_fields);
            }
        }
        /***********************
         * Let's set some links *
         ***********************/
        $post_wall_action = append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", "mode=viewprofile&amp;u=" . $user_id);
        // Needed for wall form
        $total_topics_url = append_sid("{$this->phpbb_root_path}search.{$this->phpEx}", 'author_id=' . $user_id . '&amp;sr=topics');
        // Link to search URL for user's topics
        /****************************
         * ASSIGN TEMPLATE VARIABLES *
         ****************************/
        $this->template->assign_vars(array('TOTAL_TOPICS' => $total_topics, 'PROFILE_VIEWS' => $member['user_profile_views'], 'NO_WALL_POSTS' => sprintf($this->user->lang['FIRST_POST_WALL'], '<strong>' . $username . '</strong>'), 'USER_NO_POSTS' => sprintf($this->user->lang['USER_NO_POSTS'], '<strong>' . $username . '</strong>'), 'COVERPHOTO' => $member['user_coverphoto'], 'CP_PANEL_ID' => $this->config['cp_panel_id'] ? $this->config['cp_panel_id'] : 1, 'FL_ENABLED' => $this->config['fl_enabled'] ? true : false, 'CP_ENABLED' => $this->config['cp_enabled'] ? true : false, 'AF_ENABLED' => $this->config['af_enabled'] ? true : false, 'U_SEARCH_USER_TOPICS' => $total_topics_url, 'S_POST_WALL' => $post_wall_action, 'S_CAN_POST_WALL' => $this->auth->acl_get('u_wall_post') ? true : false, 'S_CAN_READ_WALL' => $this->auth->acl_get('u_wall_read') ? true : false, 'S_CAN_DEL_WALL' => $this->auth->acl_get('u_wall_del') ? true : false, 'S_MOD_DEL_WALL' => $this->auth->acl_get('m_wall_del') ? true : false));
    }
 public function activedate_set(\Symfony\Component\EventDispatcher\Event $event)
 {
     $topic_data = $event['topic_data'];
     $first_post = intval($topic_data['topic_first_post_id']);
     if (0 == $event['set_active']) {
         $sql = 'DELETE FROM ' . $this->cal_table . ' WHERE post_id = ' . $first_post;
         $this->db->sql_query($sql);
         $sql = 'DELETE FROM ' . $this->cal_participants_table . ' WHERE post_id = ' . $first_post;
         $this->db->sql_query($sql);
     } else {
         // Copy Date & entries
         if ($this->hookup->topic_id != $event['topic_id']) {
             if ($this->hookup->topic_id != 0) {
                 $this->hookup = new hookup();
             }
             $this->hookup->load_hookup($event['topic_id']);
         }
         $set_date = isset($this->hookup->hookup_dates[$event['set_active']]) ? isset($this->hookup->hookup_dates[$event['set_active']]['date_time']) ? $this->hookup->hookup_dates[$event['set_active']]['date_time'] : 0 : 0;
         if (!$set_date) {
             // We can't enter a text without date
             return;
         }
         // Quick & dirty: The event
         $sql = 'SELECT id FROM ' . $this->cal_event_table . ' WHERE event = \'hookup\'';
         $result = $this->db->sql_query_limit($sql, 1);
         $event_id = $this->db->sql_fetchfield('id');
         $this->db->sql_freeresult($result);
         if (!$event_id) {
             $sql_ary = array('event' => 'hookup', 'participants' => 1);
             $sql = 'INSERT INTO ' . $this->cal_event_table . ' ' . $this->db->sql_build_array('INSERT', $sql_ary);
             $this->db->sql_query($sql);
             $event_id = $this->db->sql_nextid();
         }
         $sql = 'SELECT count(*) as cnt FROM ' . $this->cal_table . ' WHERE post_id = ' . $topic_data['topic_first_post_id'];
         $result = $this->db->sql_query($sql);
         $cnt = $this->db->sql_fetchfield('cnt');
         $this->db->sql_freeresult($result);
         $sql_ary = array('post_id' => $topic_data['topic_first_post_id'], 'event_id' => $event_id, 'event_name' => $topic_data['topic_title'], 'date_from' => date('Y-m-d', $set_date));
         if ($cnt) {
             $sql = 'UPDATE ' . $this->cal_table . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE post_id = ' . $topic_data['topic_first_post_id'];
         } else {
             $sql = 'INSERT INTO ' . $this->cal_table . ' ' . $this->db->sql_build_array('INSERT', $sql_ary);
         }
         $this->db->sql_query($sql);
         // Participants
         $part_ary = $this->part_ary;
         // Already entered?
         $entered_users = array();
         if ($cnt) {
             $sql = 'SELECT user_id FROM ' . $this->cal_participants_table . ' WHERE ' . $this->db->sql_in_set('user_id', array_keys($this->hookup->hookup_users));
             $result = $this->db->sql_query($sql);
             $entered_users = $this->db->sql_fetchrowset($result);
             $this->db->sql_freeresult($result);
         }
         $sql_ary = array();
         foreach ($this->hookup->hookup_users as $user_id => $userdata) {
             // Did the user enter anything for this date?
             if (!isset($this->hookup->hookup_availables[$user_id][$event['set_active']]) || $this->hookup->hookup_availables[$user_id][$event['set_active']] == hookup::HOOKUP_UNSET) {
                 continue;
             }
             if (in_array($user_id, $entered_users)) {
                 // Update instead:
                 $sql = 'UPDATE ' . $this->cal_participants_table . ' SET ' . $this->db->sql_build_array('UPDATE', array('participants' => $part_ary[$this->hookup->hookup_availables[$user_id][$event['set_active']]], 'comment' => $userdata['comment'], 'date' => date('Y-m-d-H-i'))) . " WHERE user_id = {$user_id} AND post_id = {$topic_data['topic_first_post_id']}";
                 $this->db->sql_query($sql);
                 continue;
             }
             $sql_ary[] = array('post_id' => $topic_data['topic_first_post_id'], 'user_id' => $user_id, 'participants' => $part_ary[$this->hookup->hookup_availables[$user_id][$event['set_active']]], 'comments' => $userdata['comment'], 'date' => date('Y-m-d-H-i'));
         }
         $this->db->sql_multi_insert($this->cal_participants_table, $sql_ary);
     }
 }