コード例 #1
0
ファイル: diff.php プロジェクト: Sajaki/customisation-db
 /**
  * constructor
  *
  * @param string $renderer_type Classname of the renderer to use
  */
 public function __construct($renderer_type = 'diff_renderer_unified')
 {
     $this->renderer_type = $renderer_type;
     $this->ext_root_path = \titania::$root_path;
     phpbb::_include('diff/diff', false, 'diff');
     phpbb::_include('diff/engine', false, 'diff');
     phpbb::_include('diff/renderer', false, 'diff');
     phpbb::_include('functions_compress', false, 'compress');
 }
コード例 #2
0
ファイル: phpbb.php プロジェクト: Sajaki/customisation-db
 /**
  * Static Constructor.
  */
 public static function initialise()
 {
     global $auth, $config, $db, $template, $user, $cache, $request;
     global $phpbb_container, $phpbb_dispatcher, $phpbb_root_path;
     self::$auth =& $auth;
     self::$config =& $config;
     self::$db =& $db;
     self::$template =& $template;
     self::$user =& $user;
     self::$cache =& $cache;
     self::$request =& $request;
     self::$container =& $phpbb_container;
     self::$dispatcher =& $phpbb_dispatcher;
     self::$root_path = $phpbb_root_path;
     self::$php_ext = self::$container->getParameter('core.php_ext');
 }
コード例 #3
0
/**
* Generate text for display
* Returns the result of generate_text_for_display() from phpBB's functions_content.php file, but has hacks in place to let us use our own bbcode.html file
*
* @param mixed $text
* @param mixed $uid
* @param mixed $bitfield
* @param mixed $flags
* @return mixed
*/
function titania_generate_text_for_display($text, $uid, $bitfield, $flags)
{
    if (titania::$hook->call_hook(__FUNCTION__, $text, $uid, $bitfield, $flags)) {
        if (titania::$hook->hook_return(__FUNCTION__)) {
            return titania::$hook->hook_return_result(__FUNCTION__);
        }
    }
    global $phpbb_root_path;
    phpbb::_include('bbcode', false, 'bbcode');
    // HAX
    $phpbb_root_path = TITANIA_ROOT;
    $return = generate_text_for_display($text, $uid, $bitfield, $flags);
    // UnHAX
    $phpbb_root_path = PHPBB_ROOT_PATH;
    return $return;
}
コード例 #4
0
ファイル: phpbb.php プロジェクト: kairion/customisation-db
 /**
  * Static Constructor.
  */
 public static function initialise()
 {
     global $auth, $config, $db, $template, $user, $cache;
     self::$auth =& $auth;
     self::$config =& $config;
     self::$db =& $db;
     self::$template =& $template;
     self::$user =& $user;
     self::$cache =& $cache;
     // Start session management
     if (!defined('PHPBB_INCLUDED')) {
         self::$user->session_begin();
         self::$auth->acl(self::$user->data);
         self::$user->setup();
     }
     self::$theme_data = self::$user->theme;
 }
コード例 #5
0
 function main($id, $mode)
 {
     global $phpbb_root_path;
     define('PHPBB_INCLUDED', true);
     define('USE_PHPBB_TEMPLATE', true);
     define('IN_TITANIA', true);
     if (!defined('PHP_EXT')) {
         define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
     }
     require TITANIA_ROOT . 'common.' . PHP_EXT;
     // Need a few hacks to be used from within phpBB
     titania_url::decode_url(titania::$config->phpbb_script_path);
     titania::$hook->register(array('titania_url', 'build_url'), 'titania_outside_build_url', 'standalone');
     titania::$hook->register(array('titania_url', 'append_url'), 'titania_outside_build_url', 'standalone');
     titania::$hook->register(array('titania', 'page_header'), 'titania_outside_page_header', 'standalone');
     titania::$hook->register(array('titania', 'page_footer'), 'titania_outside_page_footer', 'standalone');
     titania::$hook->register('titania_generate_text_for_display', 'titania_outside_generate_text_for_display', 'standalone');
     titania::add_lang('manage');
     $this->p_master->assign_tpl_vars(phpbb::append_sid('mcp'));
     phpbb::$template->assign_vars(array('L_TITLE' => phpbb::$user->lang['ATTENTION'], 'L_EXPLAIN' => ''));
     include TITANIA_ROOT . 'manage/attention.' . PHP_EXT;
 }
コード例 #6
0
ファイル: uploader.php プロジェクト: Gfksx/customisation-db
/**
*
* @package Titania
* @version $Id$
* @copyright (c) 2008 phpBB Customisation Database Team
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_TITANIA')) {
    exit;
}
phpbb::_include('functions_upload', false, 'fileupload');
/**
 * Handles uploading attachments for Titania.
 */
class titania_uploader extends fileupload
{
    /**
     * Some vars we need
     *
     * @var mix
     */
    public $form_name = '';
    public $ext_group = '';
    /**
     * Array of data holding informatiom about the file being uploaded.
     *
コード例 #7
0
ファイル: message.php プロジェクト: kairion/customisation-db
 /**
  * Set the options in the template
  */
 public function set_in_template()
 {
     // Assign some variables to the template parser
     phpbb::$template->assign_vars(array('S_BBCODE_CHECKED' => $this->enable_bbcode ? '' : ' checked="checked"', 'S_SMILIES_CHECKED' => $this->enable_smilies ? '' : ' checked="checked"', 'S_MAGIC_URL_CHECKED' => $this->enable_magic_url ? '' : ' checked="checked"', 'BBCODE_STATUS' => sprintf(phpbb::$user->lang[$this->bbcode_status ? 'BBCODE_IS_ON' : 'BBCODE_IS_OFF'], '<a href="' . phpbb::append_sid('faq', 'mode=bbcode') . '">', '</a>'), 'IMG_STATUS' => $this->img_status ? phpbb::$user->lang['IMAGES_ARE_ON'] : phpbb::$user->lang['IMAGES_ARE_OFF'], 'FLASH_STATUS' => $this->flash_status ? phpbb::$user->lang['FLASH_IS_ON'] : phpbb::$user->lang['FLASH_IS_OFF'], 'SMILIES_STATUS' => $this->smilies_status ? phpbb::$user->lang['SMILIES_ARE_ON'] : phpbb::$user->lang['SMILIES_ARE_OFF'], 'URL_STATUS' => $this->url_status ? phpbb::$user->lang['URL_IS_ON'] : phpbb::$user->lang['URL_IS_OFF'], 'S_BBCODE_ALLOWED' => $this->bbcode_status, 'S_SMILIES_ALLOWED' => $this->smilies_status, 'S_LINKS_ALLOWED' => $this->url_status, 'S_BBCODE_IMG' => $this->img_status, 'S_BBCODE_URL' => $this->url_status, 'S_BBCODE_FLASH' => $this->flash_status, 'S_BBCODE_QUOTE' => true));
 }
コード例 #8
0
ファイル: post.php プロジェクト: Gfksx/customisation-db
    /**
     * Hard delete a post
     */
    public function hard_delete()
    {
        if (!$this->topic->topic_posts) {
            if (!$this->topic->load($this->topic_id)) {
                return false;
            }
        }
        // Update the postcount for the topic
        $this->update_topic_postcount(true);
        // Set the visibility appropriately if no posts are visibile to the public/authors
        $flags = titania_count::get_flags(TITANIA_ACCESS_PUBLIC);
        if (titania_count::from_db($this->topic->topic_posts, $flags) <= 0) {
            // There are no posts visible to the public, change it to authors level access
            $this->topic->topic_access = TITANIA_ACCESS_AUTHORS;
            $flags = titania_count::get_flags(TITANIA_ACCESS_AUTHORS);
            if (titania_count::from_db($this->topic->topic_posts, $flags) <= 0) {
                // There are no posts visible to authors, change it to teams level access
                $this->topic->topic_access = TITANIA_ACCESS_TEAMS;
            }
        }
        // Sync the first topic post if required
        if ($this->post_id == $this->topic->topic_first_post_id) {
            $this->topic->sync_first_post($this->post_id);
        }
        // Sync the last topic post if required
        if ($this->post_id == $this->topic->topic_last_post_id) {
            $this->topic->sync_last_post($this->post_id);
        }
        // Submit the topic to store the updated information
        $this->topic->submit();
        // Remove from the search index
        titania_search::delete($this->post_type, $this->post_id);
        // @todo remove attachments and other things
        // Remove any attention items
        $sql = 'DELETE FROM ' . TITANIA_ATTENTION_TABLE . '
			WHERE attention_object_type = ' . TITANIA_POST . '
				AND attention_object_id = ' . $this->post_id;
        phpbb::$db->sql_query($sql);
        // Decrement the user's postcount if we must
        if (!$this->post_deleted && $this->post_approved && in_array($this->post_type, titania::$config->increment_postcount)) {
            phpbb::update_user_postcount($this->post_user_id, '-');
        }
        // Hooks
        titania::$hook->call_hook_ref(array(__CLASS__, __FUNCTION__), $this);
        // Initiate self-destruct mode
        parent::delete();
        // Check if the topic is empty
        $flags = titania_count::get_flags(TITANIA_ACCESS_TEAMS, true, true);
        if (titania_count::from_db($this->topic->topic_posts, $flags) <= 0) {
            // Remove any subscriptions to this topic
            $sql = 'DELETE FROM ' . TITANIA_WATCH_TABLE . '
				WHERE watch_object_type = ' . TITANIA_TOPIC . '
					AND watch_object_id = ' . $this->topic->topic_id;
            phpbb::$db->sql_query($sql);
            // Remove any tracking for this topic
            titania_tracking::clear_item(TITANIA_TOPIC, $this->topic->topic_id);
            // Delete the now empty topic
            $sql = 'DELETE FROM ' . TITANIA_TOPICS_TABLE . '
				WHERE topic_id = ' . $this->topic->topic_id;
            phpbb::$db->sql_query($sql);
        }
    }
コード例 #9
0
ファイル: topic.php プロジェクト: Sajaki/customisation-db
 /**
  * Assign details
  *
  * A little different from those in other classes, this one only returns the info ready for output
  */
 public function assign_details()
 {
     // Tracking check
     $last_read_mark = $this->tracking->get_track(TITANIA_TOPIC, $this->topic_id, true);
     $last_read_mark = max($last_read_mark, $this->tracking->find_last_read_mark($this->additional_unread_fields, $this->topic_type, $this->parent_id));
     $this->unread = $this->topic_last_post_time > $last_read_mark ? true : false;
     $folder_img = $folder_alt = '';
     $this->topic_folder_img($folder_img, $folder_alt);
     // To find out if we have any posts that need approval
     $approved = count::from_db($this->topic_posts, count::get_flags(access::PUBLIC_LEVEL, false, false));
     $total = count::from_db($this->topic_posts, count::get_flags(access::PUBLIC_LEVEL, false, true));
     $u_new_post = '';
     if ($this->unread) {
         $u_new_post = $this->get_url(false, array('view' => 'unread', '#' => 'unread'));
     }
     $details = array('TOPIC_ID' => $this->topic_id, 'TOPIC_TYPE' => $this->topic_type, 'TOPIC_ACCESS' => $this->topic_access, 'TOPIC_STATUS' => $this->topic_status, 'TOPIC_STICKY' => $this->topic_sticky, 'TOPIC_LOCKED' => $this->topic_locked, 'POSTS_APPROVED' => phpbb::$auth->acl_get('u_titania_mod_post_mod') && $total > $approved ? false : true, 'TOPIC_APPROVED' => phpbb::$auth->acl_get('u_titania_mod_post_mod') ? $this->topic_approved : true, 'TOPIC_REPORTED' => phpbb::$auth->acl_get('u_titania_mod_post_mod') ? $this->topic_reported : false, 'TOPIC_ASSIGNED' => $this->topic_assigned, 'TOPIC_REPLIES' => $this->get_postcount() - 1, 'TOPIC_VIEWS' => $this->topic_views, 'TOPIC_SUBJECT' => censor_text($this->topic_subject), 'TOPIC_FIRST_POST_ID' => $this->topic_first_post_id, 'TOPIC_FIRST_POST_USER_ID' => $this->topic_first_post_user_id, 'TOPIC_FIRST_POST_USER_COLOUR' => $this->topic_first_post_user_colour, 'TOPIC_FIRST_POST_USER_FULL' => get_username_string('full', $this->topic_first_post_user_id, $this->topic_first_post_username, $this->topic_first_post_user_colour, false, phpbb::append_sid('memberlist', 'mode=viewprofile')), 'TOPIC_FIRST_POST_TIME' => phpbb::$user->format_date($this->topic_first_post_time), 'TOPIC_LAST_POST_ID' => $this->topic_last_post_id, 'TOPIC_LAST_POST_USER_ID' => $this->topic_last_post_user_id, 'TOPIC_LAST_POST_USER_COLOUR' => $this->topic_last_post_user_colour, 'TOPIC_LAST_POST_USER_FULL' => get_username_string('full', $this->topic_last_post_user_id, $this->topic_last_post_username, $this->topic_last_post_user_colour, false, phpbb::append_sid('memberlist', 'mode=viewprofile')), 'TOPIC_LAST_POST_TIME' => phpbb::$user->format_date($this->topic_last_post_time), 'TOPIC_LAST_POST_SUBJECT' => censor_text($this->topic_last_post_subject), 'U_NEWEST_POST' => $u_new_post, 'U_VIEW_TOPIC' => $this->get_url(), 'U_VIEW_LAST_POST' => $this->get_url(false, array('p' => $this->topic_last_post_id, '#' => 'p' . $this->topic_last_post_id)), 'S_UNREAD_TOPIC' => $this->unread ? true : false, 'S_ACCESS_TEAMS' => $this->topic_access == access::TEAM_LEVEL ? true : false, 'S_ACCESS_AUTHORS' => $this->topic_access == access::AUTHOR_LEVEL ? true : false, 'FOLDER_STYLE' => $folder_img, 'FOLDER_IMG' => phpbb::$user->img($folder_img, $folder_alt), 'FOLDER_IMG_SRC' => phpbb::$user->img($folder_img, $folder_alt, false, '', 'src'), 'FOLDER_IMG_ALT' => phpbb::$user->lang[$folder_alt], 'FOLDER_IMG_WIDTH' => phpbb::$user->img($folder_img, '', false, '', 'width'), 'FOLDER_IMG_HEIGHT' => phpbb::$user->img($folder_img, '', false, '', 'height'));
     // Hooks
     titania::$hook->call_hook_ref(array(__CLASS__, __FUNCTION__), $details, $this);
     return $details;
 }
コード例 #10
0
ファイル: attachment.php プロジェクト: Gfksx/customisation-db
    /**
     * Upload any files we attempted to attach
     *
     * @param bool|int $max_thumbnail_width The maximum thumbnail width (if we create one)
     */
    public function upload($max_thumbnail_width = false)
    {
        // First, we shall handle the items already attached
        $attached_ids = request_var($this->form_name . '_attachments', array(0));
        // Query the ones we must
        $to_query = array_diff($attached_ids, array_keys($this->attachments));
        if (sizeof($to_query)) {
            $sql = 'SELECT * FROM ' . $this->sql_table . '
				WHERE ' . phpbb::$db->sql_in_set('attachment_id', array_map('intval', $to_query)) . '
					AND object_type = ' . (int) $this->object_type . '
					AND object_id = ' . (int) $this->object_id;
            // Don't let them be messin with us
            $result = phpbb::$db->sql_query($sql);
            while ($row = phpbb::$db->sql_fetchrow($result)) {
                $this->attachments[$row['attachment_id']] = $row;
            }
            phpbb::$db->sql_freeresult($result);
        }
        // Next, delete those requested
        $delete = request_var('delete_file', array(0));
        foreach ($delete as $attach_id => $null) {
            $this->delete($attach_id);
            $this->deleted = true;
            // Sometime I'll look into this again; having it setup to only delete attachments after the form is submitted
            /*if (isset($this->attachments[$attach_id]))
            		{
            			$this->attachments[$attach_id]['deleted'] = true;
            		}*/
        }
        // And undelete any
        /*$undelete = request_var('undelete_file', array(0));
        		foreach ($delete as $attach_id => $null)
        		{
        			if (isset($this->attachments[$attach_id]))
        			{
        				$this->attachments[$attach_id]['deleted'] = false;
        			}
        		}*/
        if (isset($_FILES[$this->form_name])) {
            // In order to save ourselves from rewriting the phpBB uploader to support multi-uploads, we have to do some hacking
            $uploaded_files = array();
            if (is_array($_FILES[$this->form_name]['name'])) {
                // Store the files in our own data array
                foreach ($_FILES[$this->form_name]['name'] as $id => $name) {
                    $uploaded_files[] = array('name' => $name, 'type' => $_FILES[$this->form_name]['type'][$id], 'tmp_name' => $_FILES[$this->form_name]['tmp_name'][$id], 'error' => $_FILES[$this->form_name]['error'][$id], 'size' => $_FILES[$this->form_name]['size'][$id]);
                }
            } else {
                // Compatibility with non-multi-upload forms
                $uploaded_files[] = $_FILES[$this->form_name];
            }
            // Finally upload new items if required
            foreach ($uploaded_files as $uploaded_file) {
                // Hack time
                $_FILES[$this->form_name] = $uploaded_file;
                if ($_FILES[$this->form_name]['name'] != 'none' && trim($_FILES[$this->form_name]['name'])) {
                    // Setup uploader tool.
                    $this->uploader = new titania_uploader($this->form_name, $this->object_type);
                    // Try uploading the file.
                    $this->uploader->upload_file();
                    // Store for easier access
                    $this->error = array_merge($this->error, $this->uploader->filedata['error']);
                    // If we had no problems we can submit the data to the database.
                    if (!sizeof($this->uploader->filedata['error'])) {
                        // Create thumbnail
                        $has_thumbnail = false;
                        if ($this->uploader->filedata['is_image']) {
                            phpbb::_include('functions_posting', 'create_thumbnail');
                            $src = titania::$config->upload_path . utf8_basename($this->uploader->filedata['attachment_directory']) . '/' . utf8_basename($this->uploader->filedata['physical_filename']);
                            $dst = titania::$config->upload_path . utf8_basename($this->uploader->filedata['attachment_directory']) . '/thumb_' . utf8_basename($this->uploader->filedata['physical_filename']);
                            $has_thumbnail = $this->create_thumbnail($src, $dst, $this->uploader->filedata['mimetype'], $max_thumbnail_width, $max_thumbnail_width === false ? false : 0);
                        }
                        $this->__set_array(array('attachment_id' => 0, 'physical_filename' => $this->uploader->filedata['physical_filename'], 'attachment_directory' => $this->uploader->filedata['attachment_directory'], 'real_filename' => $this->uploader->filedata['real_filename'], 'extension' => $this->uploader->filedata['extension'], 'mimetype' => $this->uploader->filedata['mimetype'], 'filesize' => $this->uploader->filedata['filesize'], 'filetime' => $this->uploader->filedata['filetime'], 'hash' => $this->uploader->filedata['md5_checksum'], 'thumbnail' => $has_thumbnail, 'attachment_comment' => utf8_normalize_nfc(request_var('filecomment', '', true))));
                        parent::submit();
                        // Store in $this->attachments[]
                        $this->attachments[$this->attachment_id] = $this->__get_array();
                        // Additional fields
                        foreach ($this->additional_fields as $output_key => $row_key) {
                            $this->attachments[$this->attachment_id][$row_key] = utf8_normalize_nfc(request_var($row_key, '', true));
                        }
                    }
                    $this->uploaded = true;
                }
            }
            // We do not want to upload it again if this function is called again.
            unset($_FILES[$this->form_name]);
        }
    }
コード例 #11
0
ファイル: email.php プロジェクト: Gfksx/customisation-db
    /**
     * Ignore this for now!
     * Moving it to the side for later...
     */
    public function email_friend()
    {
        phpbb::$user->add_lang('memberlist');
        if (!phpbb::$config['email_enable']) {
            titania::error_box('ERROR', 'EMAIL_DISABLED', TITANIA_ERROR, HEADER_SERVICE_UNAVAILABLE);
            return false;
        }
        if (!phpbb::$user->data['is_registered'] || phpbb::$user->data['is_bot'] || !phpbb::$auth->acl_get('u_sendemail')) {
            if (phpbb::$user->data['user_id'] == ANONYMOUS) {
                login_box(titania::$page, phpbb::$user->lang['ERROR_CONTRIB_EMAIL_FRIEND']);
            }
            titania::error_box('ERROR', 'ERROR_CONTRIB_EMAIL_FRIEND', TITANIA_ERROR, HEADER_FORBIDDEN);
            return false;
        }
        // Are we trying to abuse the facility?
        if (titania::$time - phpbb::$user->data['user_emailtime'] < phpbb::$config['flood_interval']) {
            trigger_error('FLOOD_EMAIL_LIMIT', E_USER_NOTICE);
        }
        $name = utf8_normalize_nfc(request_var('name', '', true));
        $email = request_var('email', '');
        $email_lang = request_var('lang', phpbb::$config['default_lang']);
        $message = utf8_normalize_nfc(request_var('message', '', true));
        $cc = isset($_POST['cc_email']) ? true : false;
        $submit = isset($_POST['submit']) ? true : false;
        add_form_key('contrib_email');
        phpbb::$template->assign_vars(array('S_LANG_OPTIONS' => language_select($email_lang), 'S_POST_ACTION' => phpbb::append_sid(titania::$page, array('id' => 'email', 'contrib_id' => $this->contrib_id))));
        $error = array();
        if ($submit) {
            if (!check_form_key('contrib_email')) {
                $error[] = 'FORM_INVALID';
            }
            if (!$email || !preg_match('/^' . get_preg_expression('email') . '$/i', $email)) {
                $error[] = 'EMPTY_ADDRESS_EMAIL';
            }
            if (!$name) {
                $error[] = 'EMPTY_NAME_EMAIL';
            }
            if (!empty($error)) {
                titania::error_box('ERROR', $error, TITANIA_ERROR);
                return false;
            }
            phpbb::_include('functions_messenger', false, 'messenger');
            $sql = 'UPDATE ' . USERS_TABLE . '
				SET user_emailtime = ' . titania::$time . '
				WHERE user_id = ' . (int) phpbb::$user->data['user_id'];
            $result = phpbb::$db->sql_query($sql);
            $mail_to_users = array();
            $mail_to_users[] = array('email_lang' => $email_lang, 'email' => $email, 'name' => $name);
            // Ok, now the same email if CC specified, but without exposing the users email address
            if ($cc) {
                $mail_to_users[] = array('email_lang' => phpbb::$user->data['user_lang'], 'email' => phpbb::$user->data['user_email'], 'name' => phpbb::$user->data['username']);
            }
            $lang_path = phpbb::$user->lang_path;
            phpbb::$user->set_custom_lang_path(titania::$config->language_path);
            $messenger = new messenger(false);
            foreach ($mail_to_users as $row) {
                $messenger->template('contrib_recommend', $row['email_lang']);
                $messenger->replyto(phpbb::$user->data['user_email']);
                $messenger->to($row['email'], $row['name']);
                $messenger->headers('X-AntiAbuse: Board servername - ' . phpbb::$config['server_name']);
                $messenger->headers('X-AntiAbuse: User_id - ' . (int) phpbb::$user->data['user_id']);
                $messenger->headers('X-AntiAbuse: Username - ' . phpbb::$user->data['username']);
                $messenger->headers('X-AntiAbuse: User IP - ' . phpbb::$user->ip);
                $messenger->assign_vars(array('BOARD_CONTACT' => phpbb::$config['board_contact'], 'TO_USERNAME' => htmlspecialchars_decode($name), 'FROM_USERNAME' => htmlspecialchars_decode(phpbb::$user->data['username']), 'MESSAGE' => htmlspecialchars_decode($message), 'CONTRIB_NAME' => htmlspecialchars_decode($this->contrib_name), 'U_CONTRIB' => phpbb::append_sid(titania::$page, array('contrib_id' => $this->contrib_id, 'id' => 'details'), true, '')));
                $messenger->send(NOTIFY_EMAIL);
            }
            phpbb::$user->set_custom_lang_path($lang_path);
            titania::error_box('SUCCESS', 'EMAIL_SENT', TITANIA_SUCCESS);
            return true;
        }
        return false;
    }
コード例 #12
0
if (!defined('TITANIA_ROOT')) {
    define('TITANIA_ROOT', './');
}
if (!defined('PHP_EXT')) {
    define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
}
require TITANIA_ROOT . 'common.' . PHP_EXT;
titania::add_lang('manage');
// Give founders access to run this
if (phpbb::$user->data['user_type'] != USER_FOUNDER) {
    titania::needs_auth();
}
// Hopefully this helps
@set_time_limit(0);
if (!isset(phpbb::$config['titania_hook_phpbb_com'])) {
    phpbb::_include('../umil/umil', false, 'umil');
    $umil = new umil(true, phpbb::$db);
    $umil->run_actions('update', array('1.0.0' => array('table_column_add' => array(array(TITANIA_TOPICS_TABLE, 'phpbb_topic_id', array('UINT', 0))))), 'titania_hook_phpbb_com');
    unset($umil);
}
// Hack for local
phpbb::$config['site_upload_dir'] = !isset(phpbb::$config['site_upload_dir']) ? '../phpBB3_titania/files/contribdb' : '../../' . phpbb::$config['site_upload_dir'];
$screenshots_dir = phpbb::$config['site_upload_dir'] . '/demo/';
// Table prefix
$ariel_prefix = 'community_site_';
$limit = 1000;
$mod_validation_trash_forum = 28;
$style_validation_trash_forum = 83;
$step = request_var('step', 0);
$start = request_var('start', 0);
// Populated later
コード例 #13
0
ファイル: posts.php プロジェクト: Noxwizard/customisation-db
    /**
     * Display topic section for support/tracker/etc
     *
     * @param object $topic The topic object
     * @param titania_sort $sort The sort object (includes/tools/sort.php)
     */
    public static function display_topic($topic, $sort = false)
    {
        if ($sort === false) {
            // Setup the sort tool
            $sort = self::build_sort();
        }
        $sort->request();
        $sql_ary = array('SELECT' => 'p.*', 'FROM' => array(TITANIA_POSTS_TABLE => 'p'), 'WHERE' => 'p.topic_id = ' . (int) $topic->topic_id . self::sql_permissions('p.'), 'ORDER_BY' => $sort->get_order_by());
        // Main SQL Query
        $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary);
        // Handle pagination
        if (!$sort->sql_count($sql_ary, 'p.post_id')) {
            // No results...no need to query more...
            return;
        }
        $sort->build_pagination($topic->get_url());
        // Get the data
        $post_ids = $user_ids = array();
        $last_post_time = 0;
        // tracking
        $result = phpbb::$db->sql_query_limit($sql, $sort->limit, $sort->start);
        while ($row = phpbb::$db->sql_fetchrow($result)) {
            self::$posts[$row['post_id']] = $row;
            self::$posts[$row['post_id']]['attachments'] = array();
            $post_ids[] = $row['post_id'];
            $user_ids[] = $row['post_user_id'];
            $user_ids[] = $row['post_edit_user'];
            $user_ids[] = $row['post_delete_user'];
            $last_post_time = $row['post_time'];
            // to set tracking
        }
        phpbb::$db->sql_freeresult($result);
        // Grab the tracking data
        $last_mark_time = titania_tracking::get_track(TITANIA_TOPIC, $topic->topic_id);
        // Store tracking data
        titania_tracking::track(TITANIA_TOPIC, $topic->topic_id, $last_post_time);
        // load the user data
        users_overlord::load($user_ids);
        phpbb::_include('functions_profile_fields', false, 'custom_profile');
        $cp = new custom_profile();
        $post = new titania_post($topic->topic_type, $topic);
        $attachments = new titania_attachment($topic->topic_type, false);
        // Grab all attachments
        $attachments_set = $attachments->load_attachments_set($post_ids);
        // Loop de loop
        $prev_post_time = 0;
        foreach ($post_ids as $post_id) {
            $post->__set_array(self::$posts[$post_id]);
            $attachments->clear_attachments();
            if (isset($attachments_set[$post_id])) {
                $attachments->store_attachments($attachments_set[$post_id]);
            }
            // Parse attachments before outputting the message
            $message = $post->generate_text_for_display();
            $parsed_attachments = $attachments->parse_attachments($message);
            // Prepare message text for use in javascript
            $message_decoded = censor_text($post->post_text);
            titania_decode_message($message_decoded, $post->post_text_uid);
            $message_decoded = bbcode_nl2br($message_decoded);
            // Build CP Fields
            $cp_row = array();
            if (isset(users_overlord::$cp_fields[$post->post_user_id])) {
                $cp_row = $cp->generate_profile_fields_template('show', false, users_overlord::$cp_fields[$post->post_user_id]);
            }
            $cp_row['row'] = isset($cp_row['row']) && sizeof($cp_row['row']) ? $cp_row['row'] : array();
            // Display edit info
            $display_username = get_username_string('full', $post->post_user_id, users_overlord::get_user($post->post_user_id, 'username'), users_overlord::get_user($post->post_user_id, 'user_colour'), false, phpbb::append_sid('memberlist', 'mode=viewprofile'));
            $l_edited_by = $post->post_edit_time ? sprintf(phpbb::$user->lang['EDITED_MESSAGE'], $display_username, phpbb::$user->format_date($post->post_edit_time)) : '';
            phpbb::$template->assign_block_vars('posts', array_merge($post->assign_details(false), users_overlord::assign_details($post->post_user_id), $cp_row['row'], array('POST_TEXT' => $message, 'POST_TEXT_DECODED' => $message_decoded, 'EDITED_MESSAGE' => $l_edited_by, 'U_MINI_POST' => titania_url::append_url($topic->get_url(), array('p' => $post_id, '#p' => $post_id)), 'MINI_POST_IMG' => $post->post_time > $last_mark_time ? phpbb::$user->img('icon_post_target_unread', 'NEW_POST') : phpbb::$user->img('icon_post_target', 'POST'), 'S_FIRST_UNREAD' => $post->post_time > $last_mark_time && $prev_post_time <= $last_mark_time ? true : false)));
            // Output CP Fields
            if (!empty($cp_row['blockrow'])) {
                foreach ($cp_row['blockrow'] as $field_data) {
                    phpbb::$template->assign_block_vars('posts.custom_fields', $field_data);
                }
            }
            //S_IGNORE_POST
            //POST_ICON_IMG
            //MINI_POST_IMG
            foreach ($parsed_attachments as $attachment) {
                phpbb::$template->assign_block_vars('posts.attachment', array('DISPLAY_ATTACHMENT' => $attachment));
            }
            $prev_post_time = $post->post_time;
        }
        unset($post, $attachments);
        // Increment the topic view count
        $sql = 'UPDATE ' . TITANIA_TOPICS_TABLE . '
			SET topic_views = topic_views + 1
			WHERE topic_id = ' . (int) $topic->topic_id;
        phpbb::$db->sql_query($sql);
    }
コード例 #14
0
ファイル: diff.php プロジェクト: Gfksx/customisation-db
* @package Titania
* @version $Id$
* @copyright (c) 2008 phpBB Customisation Database Team
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_TITANIA')) {
    exit;
}
phpbb::_include('diff/diff', false, 'diff');
phpbb::_include('diff/engine', false, 'diff');
phpbb::_include('diff/renderer', false, 'diff');
phpbb::_include('functions_compress', false, 'compress');
/**
* Class to create diffs for updated versions
* @package Titania
*/
class titania_diff
{
    /**
     * Classname of the diff renderer to use
     *
     * @var string
     */
    private $renderer_type;
    /**
     * Identification for old and new
     * This is used by from_dir to add an identification to the diff file
コード例 #15
0
/**
 * Allow to create a new topic, to reply to a topic, to edit a post or the first_post of a topic in database
 * @param $mode post/reply/edit/edit_first_post/edit_last_post
 * @param $options array Array with post data, see our documentation for exact required items
 * @param $poll array Array with poll options.
 *
 * @return mixed false if there was an error, else topic_id when $mode is post, post_id when $mode is reply, true when mode is edit
 */
function phpbb_posting($mode, &$options, $poll = array())
{
    if (!in_array($mode, array('post', 'reply', 'edit', 'edit_first_post', 'edit_last_post'))) {
        return false;
    }
    phpbb::_include('bbcode', false, 'bbcode');
    phpbb::_include('message_parser', false, 'parse_message');
    phpbb::_include('functions_posting', 'submit_post', false);
    // Set some defaults
    $options = array_merge($options, array('enable_bbcode' => true, 'enable_urls' => true, 'enable_smilies' => true, 'topic_type' => POST_NORMAL));
    $message_parser = new parse_message($options['post_text']);
    // Get the data we need
    if ($mode == 'reply') {
        $sql = 'SELECT f.*, t.*
			FROM ' . FORUMS_TABLE . ' f, ' . TOPICS_TABLE . ' t
			WHERE t.topic_id = ' . (int) $options['topic_id'] . '
				AND f.forum_id = t.forum_id';
        $result = phpbb::$db->sql_query($sql);
        $post_data = phpbb::$db->sql_fetchrow($result);
        phpbb::$db->sql_freeresult($result);
    } else {
        if ($mode == 'edit') {
            $sql = 'SELECT f.*, t.*, p.*
			FROM ' . FORUMS_TABLE . ' f, ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p
			WHERE p.post_id = ' . (int) $options['post_id'] . '
				AND t.topic_id = p.topic_id
				AND f.forum_id = t.forum_id';
            $result = phpbb::$db->sql_query($sql);
            $post_data = phpbb::$db->sql_fetchrow($result);
            phpbb::$db->sql_freeresult($result);
        } else {
            if ($mode == 'edit_first_post') {
                $sql = 'SELECT f.*, t.*, p.*
			FROM ' . FORUMS_TABLE . ' f, ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p
			WHERE t.topic_id = ' . (int) $options['topic_id'] . '
				AND p.post_id = t.topic_first_post_id
				AND f.forum_id = t.forum_id';
                $result = phpbb::$db->sql_query($sql);
                $post_data = phpbb::$db->sql_fetchrow($result);
                phpbb::$db->sql_freeresult($result);
                //http://tracker.phpbb.com/browse/PHPBB3-9644
                $mode = 'edit';
            } else {
                if ($mode == 'edit_last_post') {
                    $sql = 'SELECT f.*, t.*, p.*
			FROM ' . FORUMS_TABLE . ' f, ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p
			WHERE t.topic_id = ' . (int) $options['topic_id'] . '
				AND p.post_id = t.topic_last_post_id
				AND f.forum_id = t.forum_id';
                    $result = phpbb::$db->sql_query($sql);
                    $post_data = phpbb::$db->sql_fetchrow($result);
                    phpbb::$db->sql_freeresult($result);
                    //http://tracker.phpbb.com/browse/PHPBB3-9644
                    $mode = 'edit';
                } else {
                    $sql = 'SELECT *
			FROM ' . FORUMS_TABLE . '
			WHERE forum_id = ' . (int) $options['forum_id'];
                    $result = phpbb::$db->sql_query($sql);
                    $post_data = phpbb::$db->sql_fetchrow($result);
                    phpbb::$db->sql_freeresult($result);
                }
            }
        }
    }
    if (!$post_data) {
        return false;
    }
    // If we need to post the message as a different user other than the one logged in
    if (isset($options['poster_id']) && $options['poster_id']) {
        // Some data for the ugly fix below :P
        $sql = 'SELECT username, user_colour, user_permissions, user_type
			FROM ' . USERS_TABLE . '
			WHERE user_id = ' . (int) $options['poster_id'];
        $result = phpbb::$db->sql_query($sql);
        $user_data = phpbb::$db->sql_fetchrow($result);
        phpbb::$db->sql_freeresult($result);
        if (!$user_data) {
            return false;
        }
        // Ugly fix, to be sure it is posted for the right user ;)
        $old_user_data = phpbb::$user->data;
        phpbb::$user->data['user_id'] = $options['poster_id'];
        phpbb::$user->data['username'] = $user_data['username'];
        phpbb::$user->data['user_colour'] = $user_data['user_colour'];
        phpbb::$user->data['user_permissions'] = $user_data['user_permissions'];
        phpbb::$user->data['user_type'] = $user_data['user_type'];
        // Same for auth, be sure its posted with correct permissions :)
        $old_auth = phpbb::$auth;
        phpbb::$auth = new auth();
        phpbb::$auth->acl(phpbb::$user->data);
    }
    // When editing a post, submit post does not update the bbcode uid, we have to specify the old one.
    if (in_array($mode, array('edit', 'edit_first_post', 'edit_last_post'))) {
        $message_parser->bbcode_uid = $post_data['bbcode_uid'];
    }
    // Parse the BBCode
    if ($options['enable_bbcode']) {
        $message_parser->parse($options['enable_bbcode'], $options['enable_urls'], $options['enable_smilies'], (bool) phpbb::$auth->acl_get('f_img', $post_data['forum_id']), (bool) phpbb::$auth->acl_get('f_flash', $post_data['forum_id']), true, phpbb::$config['allow_post_links']);
    }
    // Setup the settings we need to send to submit_post
    $data = array('topic_title' => $options['topic_title'], 'enable_bbcode' => (bool) $options['enable_bbcode'], 'enable_smilies' => (bool) $options['enable_smilies'], 'enable_urls' => (bool) $options['enable_urls'], 'message_md5' => (string) md5($message_parser->message), 'bbcode_bitfield' => $message_parser->bbcode_bitfield, 'bbcode_uid' => $message_parser->bbcode_uid, 'message' => $message_parser->message, 'force_approved_state' => true, 'post_time' => time(), 'notify_set' => false, 'notify' => false);
    switch ($mode) {
        case 'post':
            $data = array_merge(array('icon_id' => isset($options['icon_id']) ? $options['icon_id'] : 0, 'poster_id' => isset($options['poster_id']) && $options['poster_id'] ? (int) $options['poster_id'] : phpbb::$user->data['user_id'], 'enable_sig' => isset($options['enable_sig']) ? (bool) $options['enable_sig'] : true, 'post_edit_locked' => isset($options['post_edit_locked']) ? $options['post_edit_locked'] : false), $data);
            break;
        case 'reply':
            $data = array_merge(array('poster_id' => isset($options['poster_id']) && $options['poster_id'] ? (int) $options['poster_id'] : phpbb::$user->data['user_id'], 'enable_sig' => isset($options['enable_sig']) ? (bool) $options['enable_sig'] : true, 'post_edit_locked' => isset($options['post_edit_locked']) ? $options['post_edit_locked'] : false), $data);
            break;
    }
    // Merge the data we grabbed from the forums/topics/posts tables
    $data = array_merge($data, $post_data);
    // Aaaand, submit it.
    switch ($mode) {
        case 'post':
        case 'reply':
            submit_post($mode, $options['topic_title'], isset($options['poster_id']) && $options['poster_id'] ? $user_data['username'] : phpbb::$user->data['username'], $options['topic_type'], $poll, $data);
            break;
        default:
            submit_post($mode, $options['topic_title'], phpbb::$user->data['username'], $options['topic_type'], $poll, $data);
            break;
    }
    // Change the status?  submit_post does not support setting this
    if (isset($options['topic_status'])) {
        $sql = 'UPDATE ' . TOPICS_TABLE . '
			SET topic_status = ' . (int) $options['topic_status'] . '
			WHERE topic_id = ' . $data['topic_id'] . '
				AND topic_moved_id = 0';
        phpbb::$db->sql_query($sql);
    }
    // Restore the user data
    if (isset($options['poster_id']) && $options['poster_id']) {
        phpbb::$user->data = $old_user_data;
        $auth = $old_auth;
    }
    // Add the new data to the options (to grab post/topic id/etc if we want it later)
    $options = array_merge($data, $options);
    if ($mode == 'post') {
        return $data['topic_id'];
    } else {
        if ($mode == 'reply') {
            return $data['post_id'];
        }
    }
    return true;
}
コード例 #16
0
ファイル: post.php プロジェクト: Sajaki/customisation-db
    /**
     * Hard delete a post
     */
    public function hard_delete()
    {
        if (!$this->topic->topic_posts) {
            if (!$this->topic->load($this->topic_id)) {
                return false;
            }
        }
        // Update the postcount for the topic
        $this->update_topic_postcount(true);
        // Set the visibility appropriately if no posts are visibile to the public/authors
        $flags = count::get_flags(access::PUBLIC_LEVEL);
        if (count::from_db($this->topic->topic_posts, $flags) <= 0) {
            // There are no posts visible to the public, change it to authors level access
            $this->topic->topic_access = access::AUTHOR_LEVEL;
            $flags = count::get_flags(access::AUTHOR_LEVEL);
            if (count::from_db($this->topic->topic_posts, $flags) <= 0) {
                // There are no posts visible to authors, change it to teams level access
                $this->topic->topic_access = access::TEAM_LEVEL;
            }
        }
        // Sync the first topic post if required
        if ($this->post_id == $this->topic->topic_first_post_id) {
            $this->topic->sync_first_post($this->post_id);
        }
        // Sync the last topic post if required
        if ($this->post_id == $this->topic->topic_last_post_id) {
            $this->topic->sync_last_post($this->post_id);
        }
        // Submit the topic to store the updated information
        $this->topic->submit();
        // Remove from the search index
        $this->search_manager->delete($this->post_type, $this->post_id);
        // @todo remove attachments and other things
        // Remove any attention items
        $sql = 'DELETE FROM ' . TITANIA_ATTENTION_TABLE . '
			WHERE attention_object_type = ' . TITANIA_POST . '
				AND attention_object_id = ' . $this->post_id;
        phpbb::$db->sql_query($sql);
        // Decrement the user's postcount if we must
        if (!$this->post_deleted && $this->post_approved && in_array($this->post_type, titania::$config->increment_postcount)) {
            phpbb::update_user_postcount($this->post_user_id, '-');
        }
        // Hooks
        titania::$hook->call_hook_ref(array(__CLASS__, __FUNCTION__), $this);
        // Initiate self-destruct mode
        parent::delete();
        // Update topics posted table
        $this->topic->update_posted_status('remove', $this->post_user_id);
        // Check if the topic is empty
        $flags = count::get_flags(access::TEAM_LEVEL, true, true);
        if (count::from_db($this->topic->topic_posts, $flags) <= 0) {
            $this->topic->delete();
        }
    }
コード例 #17
0
 private function addUserToPhpbb($forum_group_id = 0, $user_id = 0)
 {
     // Initial checks
     if (!$forum_group_id > 0 || !$user_id > 0) {
         return false;
     }
     // Setup the phpBB-class
     $phpbb_class = JPATH_ADMINISTRATOR . '/components/com_ssrrn_msc/phpbb/phpbb.php';
     if (!file_exists($phpbb_class)) {
         return false;
     }
     require_once $phpbb_class;
     $phpbb = new phpbb();
     // Fetch the right php_bbuser_id from JFusion
     $query = 'SELECT `userid` FROM `#__jfusion_users_plugin` WHERE `id`="' . (int) $user_id . '" AND `jname`="phpbb3"';
     $db = JFactory::getDBO();
     $db->setQuery($query);
     $forum_user_id = $db->loadResult();
     // Connect to phpBB
     $check = $phpbb->connect_phpbb();
     if ($check == '0') {
         return false;
     }
     // If we are connected and we have proper IDs
     if ($forum_user_id > 0 && $forum_group_id > 0) {
         try {
             $query = 'SELECT * FROM `#__user_group` WHERE `group_id`="' . $forum_group_id . '" AND `user_id`="' . $forum_user_id . '"';
             $phpbb->setQuery($query);
             $result = $phpbb->loadObjectList();
         } catch (Exception $e) {
         }
         if (empty($result)) {
             try {
                 $query = 'INSERT INTO `#__user_group` SET `group_id`="' . $forum_group_id . '", `user_id`="' . $forum_user_id . '",
                 `user_pending`="0"';
                 $phpbb->setQuery($query);
                 $phpbb->query();
             } catch (Exception $e) {
             }
         }
     }
 }
コード例 #18
0
ファイル: common.php プロジェクト: Sajaki/customisation-db
*
* This file is part of the phpBB Customisation Database package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
/**
 * @ignore
 */
if (!defined('IN_PHPBB')) {
    exit;
}
global $phpbb_container;
$ext_root_path = $phpbb_container->getParameter('phpbb.titania.root_path');
$php_ext = $phpbb_container->getParameter('core.php_ext');
// Include core classes
require $ext_root_path . 'includes/core/phpbb.' . $php_ext;
require $ext_root_path . 'includes/core/titania.' . $php_ext;
titania::configure($phpbb_container->get('phpbb.titania.config'), $ext_root_path, $php_ext);
// Set up our auto-loader
spl_autoload_register(array('titania', 'autoload'));
// Include the dynamic constants (after reading the Titania config file, but before loading the phpBB common file)
titania::_include('dynamic_constants');
// Initialise phpBB
phpbb::initialise();
// Initialise Titania
titania::initialise();
コード例 #19
0
ファイル: manage.php プロジェクト: Elsensee/customisation-db
 /**
  * Trigger author change confirmation.
  *
  * @param string $username		New author's username.
  * @param int $user_id			New author's user id.
  *
  * @return null
  */
 protected function confirm_author_change($username, $user_id)
 {
     $s_hidden_fields = array('submit' => true, 'change_owner_id' => $user_id);
     $author_profile = '<a href="' . \phpbb::append_sid('memberlist', 'mode=viewprofile&amp;u=' . $user_id) . '">' . $username . '</a>';
     confirm_box(false, $this->user->lang('CONTRIB_CONFIRM_OWNER_CHANGE', $author_profile), build_hidden_fields($s_hidden_fields));
 }
コード例 #20
0
ファイル: manage.php プロジェクト: Gfksx/customisation-db
                    titania::$contrib->change_permalink($permalink);
                }
            }
            // Submit the changes
            titania::$contrib->submit();
            // Set the coauthors
            titania::$contrib->set_coauthors($active_coauthors_list, $nonactive_coauthors_list, true);
            // Create relations
            titania::$contrib->put_contrib_in_categories($contrib_categories);
            // Update the release topic
            titania::$contrib->update_release_topic();
            if ($change_owner == '') {
                redirect(titania::$contrib->get_url());
            } else {
                $s_hidden_fields = array('submit' => true, 'change_owner' => $change_owner, 'change_owner_id' => $change_owner_id);
                titania::confirm_box(false, sprintf(phpbb::$user->lang['CONTRIB_CONFIRM_OWNER_CHANGE'], '<a href="' . phpbb::append_sid('memberlist', 'mode=viewprofile&amp;u=' . $change_owner_id) . '">' . $change_owner . '</a>'), titania_url::append_url(titania_url::$current_page), $s_hidden_fields);
            }
        }
    } else {
        $sql = 'SELECT category_id
		FROM ' . TITANIA_CONTRIB_IN_CATEGORIES_TABLE . '
		WHERE contrib_id = ' . titania::$contrib->contrib_id;
        $result = phpbb::$db->sql_query($sql);
        while ($row = phpbb::$db->sql_fetchrow($result)) {
            $contrib_categories[] = $row['category_id'];
        }
        phpbb::$db->sql_freeresult($result);
        $active_coauthors = $nonactive_coauthors = array();
        foreach (titania::$contrib->coauthors as $row) {
            // User does not exist anymore...
            if (users_overlord::get_user($row['user_id'], 'user_id') != $row['user_id']) {
コード例 #21
0
ファイル: queue.php プロジェクト: Sajaki/customisation-db
    /**
     * Send the approve/deny notification
     */
    private function send_approve_deny_notification($approve = true)
    {
        $this->user->add_lang_ext('phpbb/titania', 'manage');
        phpbb::_include('functions_privmsgs', 'submit_pm');
        // Need some stuff
        $contrib = new titania_contribution();
        $contrib->load((int) $this->contrib_id);
        $revision = new titania_revision($contrib, $this->revision_id);
        $revision->load();
        // Generate the authors list to send it to
        $authors = array($contrib->contrib_user_id => 'to');
        $sql = 'SELECT user_id FROM ' . TITANIA_CONTRIB_COAUTHORS_TABLE . '
			WHERE contrib_id = ' . (int) $this->contrib_id . '
				AND active = 1';
        $result = phpbb::$db->sql_query($sql);
        while ($row = phpbb::$db->sql_fetchrow($result)) {
            $authors[$row['user_id']] = 'to';
        }
        phpbb::$db->sql_freeresult($result);
        // Subject
        $subject = sprintf(phpbb::$user->lang[$contrib->type->validation_subject], $contrib->contrib_name, $revision->revision_version);
        // Message
        $notes = $this->validation_notes;
        message::decode($notes, $this->validation_notes_uid);
        if ($approve) {
            $message = $contrib->type->validation_message_approve;
        } else {
            $message = $contrib->type->validation_message_deny;
        }
        $message = sprintf(phpbb::$user->lang[$message], $notes);
        // Replace empty quotes if there are no notes
        if (!$notes) {
            $message = str_replace('[quote][/quote]', phpbb::$user->lang['NO_NOTES'], $message);
        }
        // Parse the message
        $message_uid = $message_bitfield = $message_options = false;
        generate_text_for_storage($message, $message_uid, $message_bitfield, $message_options, true, true, true);
        $data = array('address_list' => array('u' => $authors), 'from_user_id' => phpbb::$user->data['user_id'], 'from_username' => phpbb::$user->data['username'], 'icon_id' => 0, 'from_user_ip' => phpbb::$user->ip, 'enable_bbcode' => true, 'enable_smilies' => true, 'enable_urls' => true, 'enable_sig' => true, 'message' => $message, 'bbcode_bitfield' => $message_bitfield, 'bbcode_uid' => $message_uid);
        // Hooks
        titania::$hook->call_hook_ref(array(__CLASS__, __FUNCTION__), $data, $this);
        // Submit Plz
        submit_pm('post', $subject, $data, true);
    }
コード例 #22
0
                 continue;
             }
             $type = explode(':', $vars['type']);
             $l_explain = '';
             if ($vars['explain'] && isset($vars['lang_explain'])) {
                 $l_explain = isset(phpbb::$user->lang[$vars['lang_explain']]) ? phpbb::$user->lang[$vars['lang_explain']] : $vars['lang_explain'];
             } else {
                 if ($vars['explain']) {
                     $l_explain = isset(phpbb::$user->lang[$vars['lang'] . '_EXPLAIN']) ? phpbb::$user->lang[$vars['lang'] . '_EXPLAIN'] : '';
                 }
             }
             $content = build_cfg_template($type, $name, $vars);
             if (empty($content)) {
                 continue;
             }
             phpbb::$template->assign_block_vars('options', array('KEY' => $name, 'TITLE' => isset(phpbb::$user->lang[$vars['lang']]) ? phpbb::$user->lang[$vars['lang']] : $vars['lang'], 'S_EXPLAIN' => $vars['explain'], 'TITLE_EXPLAIN' => $l_explain, 'CONTENT' => $content['tpl'], 'S_FIND_USER' => isset($content['find_user']) ? true : false, 'U_FIND_USER' => isset($content['find_user']) ? phpbb::append_sid('memberlist', array('mode' => 'searchuser', 'form' => 'select_user', 'field' => 'username', 'select_single' => 'true', 'form' => 'stk', 'field' => $content['find_user_field'])) : ''));
         }
         titania::page_footer(true, 'manage/tool_options.html');
     } else {
         if (is_string($options)) {
             if (titania::confirm_box(true) || isset($_GET['submit']) && check_link_hash(request_var('hash', ''), 'manage')) {
                 $tool->run_tool();
             } else {
                 titania::confirm_box(false, $options, titania_url::build_url('manage/administration', array('t' => $plugin->tool_id)));
             }
         } else {
             // The page should have been setup by the tool.  We will exit to prevent the redirect from below.
             exit;
         }
     }
 }
コード例 #23
0
ファイル: author.php プロジェクト: Noxwizard/customisation-db
 /**
  * Get phpBB profile url
  *
  * @return string
  */
 public function get_phpbb_profile_url()
 {
     if ($this->user_id) {
         return phpbb::append_sid('memberlist', 'mode=viewprofile&amp;u=' . $this->user_id);
     }
     return '';
 }
コード例 #24
0
ファイル: hook.php プロジェクト: Sajaki/customisation-db
* This file is part of the phpBB Customisation Database package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
/**
 * @ignore
 */
if (!defined('IN_PHPBB')) {
    exit;
}
phpbb::_include('hooks/index', false, 'phpbb_hook');
/**
* Titania Hook Class
*
* Same as phpBB's hook class, but not requiring the hooks to be registered at class construction time
*/
class titania_hook extends phpbb_hook
{
    /**
     * Initialize hook class.
     */
    public function titania_hook()
    {
        if (function_exists('phpbb_hook_register')) {
            phpbb_hook_register($this);
        }
コード例 #25
0
function phpbb_com_move_queue_topic($queue_object)
{
    $sql = 'SELECT phpbb_topic_id, topic_category FROM ' . TITANIA_TOPICS_TABLE . '
		WHERE topic_id = ' . (int) $queue_object->queue_topic_id;
    $result = phpbb::$db->sql_query($sql);
    $row = phpbb::$db->sql_fetchrow($result);
    phpbb::$db->sql_freeresult($result);
    if (!$row['phpbb_topic_id']) {
        return;
    }
    phpbb::_include('functions_admin', 'move_topics');
    move_topics($row['phpbb_topic_id'], phpbb_com_forum_id($row['topic_category'], 'trash'));
}
コード例 #26
0
    /**
     * Send Notifications
     *
     * Using this function:
     * Call this function when you know the Object type, object id, and the email
     * template name.
     * Sample usage:
     *
     * <code>
     *
     * $object_type = SOME_OBJECT_CONSTANT_TYPE;
     * $obhect)id = 242974;
     *
     * titania_subscriptions::send_notifications($object_type, $object_id, 'mod_subscribe', array(
     * 		'OBJECT_NAME'	=> 'Some MOD',
     * ));
     *
     * </code>
     *
     * The vars parameter will be used in the messanger assign vars, which will act
     * as the common vars when sending out the notifications. Data such as the MOD's
     * or Style's name should go here, what action was taken, etc. The usernaeme and
     * emails of the recepiants will be personalised by the function. Ensure the
     * email template has the {USERNAME} var present.
     *
     * @param $exclude_user User_id of the one who posted the item to exclude them from the sending
     *
     */
    public static function send_notifications($object_type, $object_id, $email_tpl, $vars, $exclude_user = false)
    {
        $sql = 'SELECT w.watch_user_id, w.watch_type, u.user_id, u.username, u.user_email
				FROM ' . TITANIA_WATCH_TABLE . ' w, ' . USERS_TABLE . ' u
				WHERE w.watch_user_id = u.user_id ';
        if (is_array($object_type) || is_array($object_id)) {
            // Both needs to be arrays if one is and they need to have the same number of elements.
            if (!is_array($object_type) || !is_array($object_id) || sizeof($object_type) != sizeof($object_id)) {
                return;
            }
            $sql_objects = '';
            foreach ($object_type as $key => $value) {
                $sql_objects .= ($sql_objects == '' ? '' : ' OR ') . '(w.watch_object_type = ' . (int) $value . '
							AND w.watch_object_id = ' . (int) $object_id[$key] . ')';
            }
            $sql .= 'AND (' . $sql_objects . ')';
            unset($sql_objects);
        } else {
            $sql .= 'AND w.watch_object_type = ' . (int) $object_type . '
						AND w.watch_object_id = ' . (int) $object_id;
        }
        $sql .= $exclude_user ? ' AND w.watch_user_id <> ' . (int) $exclude_user : '';
        $result = phpbb::$db->sql_query($sql);
        // Throw everything here
        $user_data = array();
        while ($row = phpbb::$db->sql_fetchrow($result)) {
            // Use user_id for the keys to not send duplicates.
            $user_data[$row['user_id']] = array('username' => $row['username'], 'user_email' => $row['user_email'], 'watch_type' => $row['watch_type']);
        }
        // No one subscribed? We're done.
        if (!sizeof($user_data)) {
            return;
        }
        // You wanted the email template parsed? Well here you go.
        $template = file_get_contents(TITANIA_ROOT . 'language/en/email/' . $email_tpl);
        foreach ($vars as $var => $replace) {
            if (strtoupper($var) == 'SUBJECT') {
                continue;
            }
            $template = str_replace('{' . strtoupper($var) . '}', $replace, $template);
        }
        // Steal the subject if it exists
        $subject = '';
        if (($subject_start = strpos($template, 'Subject:')) !== false) {
            $subject_length = strpos($template, "\n", $subject_start) - $subject_start;
            $subject = substr($template, $subject_start, $subject_length);
            $template = substr($template, 0, $subject_start) . substr($template, $subject_start + $subject_length);
        }
        $subject = isset($vars['SUBJECT']) ? $vars['SUBJECT'] : $subject;
        $subject = $subject ? $subject : phpbb::$user->lang['SUBSCRIPTION_NOTIFICATION'];
        // Send to each user
        // Add a new case statment for each subscription type
        foreach ($user_data as $data) {
            // Generic messages that will be sent to each module individually
            $message = str_replace('{USERNAME}', $data['username'], $template);
            /*
             * Switch between the types.
             * ------------------------------------------
             * When adding a type, the final message will
             * be stored in $message, and the subject is
             * stored in $vars['SUBJECT'].
             */
            switch ($data['watch_type']) {
                case SUBSCRIPTION_EMAIL:
                    // Only make the object if we need it
                    phpbb::_include('functions_messenger', false, 'messenger');
                    $messenger = new messenger();
                    $messenger->headers('X-AntiAbuse: Board servername - ' . phpbb::$config['server_name']);
                    $messenger->headers('X-AntiAbuse: User_id - ' . phpbb::$user->data['user_id']);
                    $messenger->headers('X-AntiAbuse: Username - ' . phpbb::$user->data['username']);
                    // HAX
                    $user_lang_path = phpbb::$user->lang_path;
                    phpbb::$user->lang_path = TITANIA_ROOT . 'language/';
                    $messenger->template('subscribe_generic');
                    // Reverse HAX
                    phpbb::$user->lang_path = $user_lang_path;
                    $messenger->to($data['user_email'], $data['username']);
                    $messenger->assign_vars(array_merge($vars, array('SUBJECT' => $subject, 'MESSAGE' => $message)));
                    $messenger->send();
                    $messenger->save_queue();
                    break;
            }
        }
        return;
    }
コード例 #27
0
    /**
     * Install a style on the demo board.
     *
     * @param string $phpbb_root_path
     * @param mixed contrib object
     */
    public function install_demo_style($phpbb_root_path, $contrib)
    {
        phpbb::$user->add_lang('acp/styles');
        if ($phpbb_root_path[strlen($phpbb_root_path) - 1] != '/') {
            $phpbb_root_path .= '/';
        }
        if (!is_dir($phpbb_root_path) || !file_exists($phpbb_root_path . 'config.' . PHP_EXT)) {
            $this->error[] = 'PATH_INVALID';
            return false;
        }
        include $phpbb_root_path . 'config.' . PHP_EXT;
        $sql_db = !empty($dbms) ? 'dbal_' . basename($dbms) : 'dbal';
        // Is this DBAL loaded?
        phpbb::_include('db/' . $dbms, false, $sql_db);
        // Instantiate DBAL class
        $db = new $sql_db();
        // Connect to demo board DB
        $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport);
        // We do not need this any longer, unset for safety purposes
        unset($dbpasswd);
        if (empty($this->unzip_dir)) {
            // Extract zip.
            $this->unzip_dir = titania::$config->contrib_temp_path . basename($this->original_zip, 'zip') . '/';
            // Clear out old stuff if there is anything here...
            $this->rmdir_recursive($this->unzip_dir);
            // Unzip to our temp directory
            $this->extract($this->original_zip, $this->unzip_dir);
        }
        $package_root = $this->find_root(false, 'style.cfg');
        $stylecfg = parse_cfg_file($this->unzip_dir . $package_root . '/style.cfg');
        $style_root = $phpbb_root_path . 'styles/' . $contrib->contrib_id . '/';
        $this->mvdir_recursive($this->unzip_dir . $package_root, $style_root, false);
        $this->rmdir_recursive($this->unzip_dir);
        $variables = array('db', 'phpbb_root_path');
        // Let's get lazy.
        foreach ($variables as $variable) {
            ${'_' . $variable} = $GLOBALS[$variable];
            $GLOBALS[$variable] = ${$variable};
        }
        // Get the acp_styles class.
        phpbb::_include('acp/acp_styles', false, 'acp_styles');
        if (!defined('TEMPLATE_BITFIELD')) {
            // Hardcoded template bitfield to add for new templates
            $bitfield = new bitfield();
            $bitfield->set(0);
            $bitfield->set(1);
            $bitfield->set(2);
            $bitfield->set(3);
            $bitfield->set(4);
            $bitfield->set(8);
            $bitfield->set(9);
            $bitfield->set(11);
            $bitfield->set(12);
            define('TEMPLATE_BITFIELD', $bitfield->get_base64());
            unset($bitfield);
        }
        $styles = new acp_styles();
        // Fill the configuration variables
        $styles->style_cfg = $styles->template_cfg = $styles->theme_cfg = $styles->imageset_cfg = '
#
# phpBB {MODE} configuration file
#
# @package phpBB3
# @copyright (c) 2005 phpBB Group
# @license http://opensource.org/licenses/gpl-license.php GNU Public License
#
#
# At the left is the name, please do not change this
# At the right the value is entered
# For on/off options the valid values are on, off, 1, 0, true and false
#
# Values get trimmed, if you want to add a space in front or at the end of
# the value, then enclose the value with single or double quotes.
# Single and double quotes do not need to be escaped.
#
#

# General Information about this {MODE}
name = {NAME}
copyright = {COPYRIGHT}
version = {VERSION}
';
        $styles->theme_cfg .= '
# Some configuration options

#
# You have to turn this option on if you want to use the
# path template variables ({T_IMAGESET_PATH} for example) within
# your css file.
# This is mostly the case if you want to use language specific
# images within your css file.
#
parse_css_file = {PARSE_CSS_FILE}
';
        $styles->template_cfg .= '
# Some configuration options

#
# You can use this function to inherit templates from another template.
# The template of the given name has to be installed.
# Templates cannot inherit from inheriting templates.
#';
        $styles->imageset_keys = array('logos' => array('site_logo'), 'buttons' => array('icon_back_top', 'icon_contact_aim', 'icon_contact_email', 'icon_contact_icq', 'icon_contact_jabber', 'icon_contact_msnm', 'icon_contact_pm', 'icon_contact_yahoo', 'icon_contact_www', 'icon_post_delete', 'icon_post_edit', 'icon_post_info', 'icon_post_quote', 'icon_post_report', 'icon_user_online', 'icon_user_offline', 'icon_user_profile', 'icon_user_search', 'icon_user_warn', 'button_pm_forward', 'button_pm_new', 'button_pm_reply', 'button_topic_locked', 'button_topic_new', 'button_topic_reply'), 'icons' => array('icon_post_target', 'icon_post_target_unread', 'icon_topic_attach', 'icon_topic_latest', 'icon_topic_newest', 'icon_topic_reported', 'icon_topic_unapproved', 'icon_friend', 'icon_foe'), 'forums' => array('forum_link', 'forum_read', 'forum_read_locked', 'forum_read_subforum', 'forum_unread', 'forum_unread_locked', 'forum_unread_subforum', 'subforum_read', 'subforum_unread'), 'folders' => array('topic_moved', 'topic_read', 'topic_read_mine', 'topic_read_hot', 'topic_read_hot_mine', 'topic_read_locked', 'topic_read_locked_mine', 'topic_unread', 'topic_unread_mine', 'topic_unread_hot', 'topic_unread_hot_mine', 'topic_unread_locked', 'topic_unread_locked_mine', 'sticky_read', 'sticky_read_mine', 'sticky_read_locked', 'sticky_read_locked_mine', 'sticky_unread', 'sticky_unread_mine', 'sticky_unread_locked', 'sticky_unread_locked_mine', 'announce_read', 'announce_read_mine', 'announce_read_locked', 'announce_read_locked_mine', 'announce_unread', 'announce_unread_mine', 'announce_unread_locked', 'announce_unread_locked_mine', 'global_read', 'global_read_mine', 'global_read_locked', 'global_read_locked_mine', 'global_unread', 'global_unread_mine', 'global_unread_locked', 'global_unread_locked_mine', 'pm_read', 'pm_unread'), 'polls' => array('poll_left', 'poll_center', 'poll_right'), 'ui' => array('upload_bar'), 'user' => array('user_icon1', 'user_icon2', 'user_icon3', 'user_icon4', 'user_icon5', 'user_icon6', 'user_icon7', 'user_icon8', 'user_icon9', 'user_icon10'));
        // Define references.
        $error = array();
        $style_id = 0;
        $style_row = array('install_name' => $stylecfg['name'], 'install_copyright' => $stylecfg['copyright'], 'template_id' => 0, 'template_name' => $stylecfg['name'], 'template_copyright' => $stylecfg['copyright'], 'theme_id' => 0, 'theme_name' => $stylecfg['name'], 'theme_copyright' => $stylecfg['copyright'], 'imageset_id' => 0, 'imageset_name' => $stylecfg['name'], 'imageset_copyright' => $stylecfg['copyright'], 'store_db' => 0, 'style_active' => 1, 'style_default' => 0);
        // Install the style.
        // (&$error, $action, $root_path, &$id, $name, $path, $copyright, $active, $default, &$style_row, $template_root_path = false, $template_path = false, $theme_root_path = false, $theme_path = false, $imageset_root_path = false, $imageset_path = false)
        if (!$styles->install_style($error, 'install', $style_root, $style_id, $stylecfg['name'], $contrib->contrib_id, $stylecfg['copyright'], true, false, $style_row)) {
            if ($error != array(phpbb::$user->lang['STYLE_ERR_NAME_EXIST'])) {
                $this->error = array_merge($this->error, $error);
            } else {
                $sql = 'SELECT style_id
					FROM ' . STYLES_TABLE . "\n\t\t\t\t\tWHERE style_name = '" . $db->sql_escape(basename($stylecfg['name'])) . "'";
                $db->sql_query($sql);
                $style_id = $db->sql_fetchfield('style_id');
                $db->sql_freeresult();
            }
        }
        // Have UMIL refresh the template, theme, imageset
        phpbb::_include('../umil/umil', false, 'umil');
        $umil = new umil(true, $db);
        $umil->cache_purge('template', $style_id);
        $umil->cache_purge('theme', $style_id);
        $umil->cache_purge('imageset', $style_id);
        foreach ($variables as $variable) {
            $GLOBALS[$variable] = ${'_' . $variable};
        }
        return $style_id;
    }
コード例 #28
0
 /**
  * Private function strings have to pass before entering the database.
  * Ensures string length et cetera.
  *
  * @param	string	$value		The string we want to validate
  * @param	array	$config		The configuration array we're validating against
  *
  * @return	string				The validated string
  */
 private function validate_string($value, $config)
 {
     if (empty($value)) {
         return '';
     }
     // Check if multibyte characters are disallowed
     if (isset($config['multibyte']) && $config['multibyte'] === false) {
         // No multibyte, only allow ASCII (0-127)
         $value = preg_replace('/[\\x80-\\xFF]/', '', $value);
     } else {
         // Make sure multibyte characters are wellformed
         if (!preg_match('/^./u', $value)) {
             return '';
         }
     }
     // Truncate to the maximum length
     if (isset($config['max']) && $config['max']) {
         phpbb::_include('functions_content', 'truncate_string');
         truncate_string($value, $config['max']);
     }
     return $value;
 }
コード例 #29
0
    function main($id, $mode)
    {
        global $phpbb_root_path;
        define('PHPBB_INCLUDED', true);
        define('USE_PHPBB_TEMPLATE', true);
        define('IN_TITANIA', true);
        if (!defined('PHP_EXT')) {
            define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
        }
        require TITANIA_ROOT . 'common.' . PHP_EXT;
        // Need a few hacks to be used from within phpBB
        titania_url::decode_url(titania::$config->phpbb_script_path);
        titania::$hook->register(array('titania_url', 'build_url'), 'titania_outside_build_url', 'standalone');
        titania::$hook->register(array('titania_url', 'append_url'), 'titania_outside_build_url', 'standalone');
        titania::$hook->register(array('titania', 'page_header'), 'titania_outside_page_header', 'standalone');
        titania::$hook->register(array('titania', 'page_footer'), 'titania_outside_page_footer', 'standalone');
        $this->p_master->assign_tpl_vars(phpbb::append_sid('ucp'));
        // Include some files
        titania::_include('functions_display', 'titania_topic_folder_img');
        // Setup the sort tool
        $sort = new titania_sort();
        $sort->default_limit = phpbb::$config['topics_per_page'];
        $sort->request();
        // Start initial var setup
        $url = $this->u_action;
        add_form_key('ucp_front_subscription');
        // User wants to unsubscribe?
        if (isset($_POST['unsubscribe'])) {
            if (check_form_key('ucp_front_subscription')) {
                $sections = request_var('sections', array(0 => array(0 => 0)));
                $items = request_var('items', array(0 => array(0 => 0)));
                $subscriptions = $sections + $items;
                if (sizeof($subscriptions)) {
                    foreach ($subscriptions as $type => $type_id) {
                        $object_ids = array_keys($type_id);
                        foreach ($object_ids as $object_id) {
                            $sql = 'DELETE FROM ' . TITANIA_WATCH_TABLE . '
								WHERE watch_user_id = ' . phpbb::$user->data['user_id'] . '
								AND watch_object_type = ' . $type . '
								AND watch_object_id = ' . $object_id;
                            phpbb::$db->sql_query($sql);
                        }
                    }
                } else {
                    $msg = phpbb::$user->lang['NO_SUBSCRIPTIONS_SELECTED'];
                }
            } else {
                $msg = phpbb::$user->lang['FORM_INVALID'];
            }
            if (isset($msg)) {
                meta_refresh(3, $url);
                $message = $msg . '<br /><br />' . sprintf(phpbb::$user->lang['RETURN_UCP'], '<a href="' . $url . '">', '</a>');
                trigger_error($message);
            }
        }
        switch ($mode) {
            case 'subscription_items':
                $array_items = array(TITANIA_CONTRIB, TITANIA_TOPIC);
                // We prepare pagination stuff
                $sql = 'SELECT COUNT(*) AS subscription_count
					FROM ' . TITANIA_WATCH_TABLE . '
					WHERE ' . phpbb::$db->sql_in_set('watch_object_type', $array_items) . '
						AND watch_user_id = ' . phpbb::$user->data['user_id'];
                phpbb::$db->sql_query($sql);
                $subscription_count = phpbb::$db->sql_fetchfield('subscription_count');
                phpbb::$db->sql_freeresult();
                $sort->total = $subscription_count;
                $sort->build_pagination($url);
                $sql_ary = array('SELECT' => '*,
						CASE w.watch_object_type
							WHEN ' . TITANIA_CONTRIB . ' THEN c.contrib_last_update
							WHEN ' . TITANIA_TOPIC . ' THEN t.topic_last_post_time
						END AS time', 'FROM' => array(TITANIA_WATCH_TABLE => 'w'), 'LEFT_JOIN' => array(array('FROM' => array(TITANIA_CONTRIBS_TABLE => 'c'), 'ON' => '(w.watch_object_type = ' . TITANIA_CONTRIB . ')
								AND c.contrib_id = w.watch_object_id'), array('FROM' => array(TITANIA_TOPICS_TABLE => 't'), 'ON' => 'w.watch_object_type = ' . TITANIA_TOPIC . '
								AND t.topic_id = w.watch_object_id')), 'WHERE' => 'w.watch_user_id = ' . phpbb::$user->data['user_id'] . '
						AND ' . phpbb::$db->sql_in_set('watch_object_type', $array_items), 'ORDER_BY' => 'time DESC');
                // Additional tracking for support topics
                titania_tracking::get_track_sql($sql_ary, TITANIA_TOPIC, 't.topic_id');
                titania_tracking::get_track_sql($sql_ary, TITANIA_SUPPORT, 0, 'tsa');
                titania_tracking::get_track_sql($sql_ary, TITANIA_SUPPORT, 't.parent_id', 'tsc');
                titania_tracking::get_track_sql($sql_ary, TITANIA_QUEUE_DISCUSSION, 0, 'tqt');
                // Tracking for contributions
                titania_tracking::get_track_sql($sql_ary, TITANIA_CONTRIB, 'c.contrib_id', 'tc');
                $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary);
                // Get the data
                $result = phpbb::$db->sql_query_limit($sql, $sort->limit, $sort->start);
                $user_ids = $rows = array();
                while ($row = phpbb::$db->sql_fetchrow($result)) {
                    $rows[] = $row;
                    titania_tracking::store_from_db($row);
                    if ($row['watch_object_type'] == TITANIA_TOPIC) {
                        $user_ids[] = $row['topic_first_post_user_id'];
                        $user_ids[] = $row['topic_last_post_user_id'];
                    } else {
                        if ($row['watch_object_type'] == TITANIA_CONTRIB) {
                            $user_ids[] = $row['contrib_user_id'];
                        }
                    }
                }
                phpbb::$db->sql_freeresult($result);
                // Get user data
                users_overlord::load_users($user_ids);
                foreach ($rows as $row) {
                    $folder_img = $folder_alt = '';
                    if ($row['watch_object_type'] == TITANIA_TOPIC) {
                        if (!$row['topic_id']) {
                            // Topic was deleted
                            $sql = 'DELETE FROM ' . TITANIA_WATCH_TABLE . '
								WHERE watch_object_type = ' . (int) $row['watch_object_type'] . '
									AND watch_object_id = ' . (int) $row['watch_object_id'];
                            phpbb::$db->sql_query($sql);
                            continue;
                        }
                        $topic = new titania_topic();
                        $topic->__set_array($row);
                        $topic->additional_unread_fields[] = array('type' => TITANIA_SUPPORT, 'id' => 0);
                        $topic->additional_unread_fields[] = array('type' => TITANIA_SUPPORT, 'parent_match' => true);
                        $topic->additional_unread_fields[] = array('type' => TITANIA_QUEUE_DISCUSSION, 'id' => 0, 'type_match' => true);
                        $tpl_block = 'items';
                        $subscription_target = '';
                        if ($row['topic_type'] == TITANIA_QUEUE_DISCUSSION) {
                            $subscription_target = phpbb::$user->lang['SUBSCRIPTION_QUEUE_VALIDATION'];
                        }
                        if ($row['topic_type'] == TITANIA_QUEUE) {
                            $subscription_target = phpbb::$user->lang['SUBSCRIPTION_QUEUE'];
                        }
                        if ($row['topic_type'] == TITANIA_SUPPORT) {
                            $subscription_target = phpbb::$user->lang['SUBSCRIPTION_SUPPORT_TOPIC'];
                        }
                        // Tracking check
                        $last_read_mark = titania_tracking::get_track(TITANIA_TOPIC, $topic->topic_id, true);
                        $last_read_mark = max($last_read_mark, titania_tracking::find_last_read_mark($topic->additional_unread_fields, $topic->topic_type, $topic->parent_id));
                        $topic->unread = $topic->topic_last_post_time > $last_read_mark ? true : false;
                        // Get the folder image
                        $topic->topic_folder_img($folder_img, $folder_alt);
                        $vars = array('LAST_POST_IMG' => phpbb::$user->img('icon_topic_latest', 'VIEW_LATEST_POST'), 'SUBSCRIPTION_AUTHOR_FULL' => users_overlord::get_user($row['topic_first_post_user_id'], '_full'), 'SUBSCRIPTION_ID' => $row['topic_id'], 'SUBSCRIPTION_LAST_AUTHOR_FULL' => users_overlord::get_user($row['topic_last_post_user_id'], '_full'), 'SUBSCRIPTION_LAST_TIME' => phpbb::$user->format_date($row['topic_last_post_time']), 'SUBSCRIPTION_TIME' => phpbb::$user->format_date($row['topic_time']), 'SUBSCRIPTION_TARGET' => $subscription_target, 'SUBSCRIPTION_TITLE' => censor_text($row['topic_subject']), 'SUBSCRIPTION_TYPE' => $row['watch_object_type'], 'U_VIEW_SUBSCRIPTION' => $topic->get_url(), 'U_VIEW_LAST_POST' => titania_url::append_url($topic->get_url(), array('p' => $topic->topic_last_post_id, '#p' => $topic->topic_last_post_id)), 'S_ACCESS_TEAMS' => $row['topic_access'] == TITANIA_ACCESS_TEAMS || $row['topic_type'] == TITANIA_QUEUE ? true : false, 'S_ACCESS_AUTHORS' => $row['topic_access'] == TITANIA_ACCESS_AUTHORS ? true : false, 'S_TOPIC' => true);
                    } else {
                        if ($row['watch_object_type'] == TITANIA_CONTRIB) {
                            $tpl_block = 'items';
                            $contrib = new titania_contribution();
                            $contrib->__set_array($row);
                            titania_topic_folder_img($folder_img, $folder_alt, 0, titania_tracking::is_unread(TITANIA_CONTRIB, $contrib->contrib_id, $contrib->contrib_last_update));
                            $vars = array('SUBSCRIPTION_AUTHOR_FULL' => users_overlord::get_user($row['contrib_user_id'], '_full'), 'SUBSCRIPTION_CONTRIB_TYPE' => titania_types::$types[$contrib->contrib_type]->lang, 'SUBSCRIPTION_DOWNLOADS' => $row['contrib_downloads'], 'SUBSCRIPTION_ID' => $row['contrib_id'], 'SUBSCRIPTION_TARGET' => phpbb::$user->lang['SUBSCRIPTION_CONTRIB'], 'SUBSCRIPTION_TIME' => phpbb::$user->format_date($row['contrib_last_update']), 'SUBSCRIPTION_TITLE' => $row['contrib_name'], 'SUBSCRIPTION_TYPE' => $row['watch_object_type'], 'SUBSCRIPTION_VIEWS' => $row['contrib_views'], 'U_VIEW_SUBSCRIPTION' => $contrib->get_url(), 'S_CONTRIB' => true);
                        }
                    }
                    phpbb::$template->assign_block_vars($tpl_block, array_merge($vars, array('FOLDER_IMG' => phpbb::$user->img($folder_img, $folder_alt), 'FOLDER_IMG_SRC' => phpbb::$user->img($folder_img, $folder_alt, false, '', 'src'), 'FOLDER_IMG_ALT' => phpbb::$user->lang[$folder_alt], 'FOLDER_IMG_WIDTH' => phpbb::$user->img($folder_img, '', false, '', 'width'), 'FOLDER_IMG_HEIGHT' => phpbb::$user->img($folder_img, '', false, '', 'height'))));
                }
                break;
            case 'subscription_sections':
                $array_items = array(TITANIA_SUPPORT, TITANIA_QUEUE, TITANIA_ATTENTION);
                // We prepare pagination stuff
                $sql = 'SELECT COUNT(*) AS subscription_count
					FROM ' . TITANIA_WATCH_TABLE . '
					WHERE ' . phpbb::$db->sql_in_set('watch_object_type', $array_items) . '
					AND watch_user_id = ' . phpbb::$user->data['user_id'];
                phpbb::$db->sql_query($sql);
                $subscription_count = phpbb::$db->sql_fetchfield('subscription_count');
                phpbb::$db->sql_freeresult();
                $sort->total = $subscription_count;
                $sort->build_pagination($url);
                $sql_ary = array('SELECT' => '*,
						CASE w.watch_object_type
							WHEN ' . TITANIA_SUPPORT . ' THEN c.contrib_last_update
						END AS time', 'FROM' => array(TITANIA_WATCH_TABLE => 'w'), 'LEFT_JOIN' => array(array('FROM' => array(TITANIA_CONTRIBS_TABLE => 'c'), 'ON' => '(w.watch_object_type = ' . TITANIA_SUPPORT . ')
								AND c.contrib_id = w.watch_object_id')), 'WHERE' => 'w.watch_user_id = ' . phpbb::$user->data['user_id'] . '
						AND ' . phpbb::$db->sql_in_set('watch_object_type', $array_items), 'ORDER_BY' => 'time DESC');
                $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary);
                // Get the data
                $result = phpbb::$db->sql_query_limit($sql, $sort->limit, $sort->start);
                $user_ids = array();
                while ($row = phpbb::$db->sql_fetchrow($result)) {
                    $rows[] = $row;
                    $user_ids[] = $row['contrib_user_id'];
                }
                phpbb::$db->sql_freeresult($result);
                // Get user data
                users_overlord::load_users($user_ids);
                if (isset($rows)) {
                    foreach ($rows as $row) {
                        if ($row['watch_object_type'] == TITANIA_SUPPORT) {
                            $tpl_block = 'sections';
                            $contrib = new titania_contribution();
                            $contrib->__set_array($row);
                            $vars = array('SUBSCRIPTION_AUTHOR_FULL' => users_overlord::get_user($row['contrib_user_id'], '_full'), 'SUBSCRIPTION_ID' => $row['watch_object_id'], 'SUBSCRIPTION_TARGET' => phpbb::$user->lang['SUBSCRIPTION_SUPPORT'], 'SUBSCRIPTION_TIME' => phpbb::$user->format_date($row['contrib_last_update']), 'SUBSCRIPTION_TITLE' => $row['contrib_name'], 'SUBSCRIPTION_TYPE' => $row['watch_object_type'], 'U_VIEW_SUBSCRIPTION' => $contrib->get_url('support'));
                        } else {
                            if ($row['watch_object_type'] == TITANIA_ATTENTION) {
                                $tpl_block = 'sections';
                                $vars = array('SUBSCRIPTION_ID' => $row['watch_object_id'], 'SUBSCRIPTION_TIME' => phpbb::$user->format_date($row['watch_mark_time']), 'SUBSCRIPTION_TITLE' => phpbb::$user->lang['SUBSCRIPTION_ATTENTION'], 'SUBSCRIPTION_TYPE' => $row['watch_object_type'], 'S_ATTENTION' => true, 'S_ACCESS_TEAMS' => true, 'U_VIEW_SUBSCRIPTION' => titania_url::build_url('manage/attention'));
                            } else {
                                if ($row['watch_object_type'] == TITANIA_QUEUE) {
                                    $tpl_block = 'sections';
                                    $queue_id = $row['watch_object_id'];
                                    // Setup the base url we will use
                                    $base_url = titania_url::build_url('manage/queue');
                                    $vars = array('SUBSCRIPTION_ID' => $queue_id, 'SUBSCRIPTION_TARGET' => titania_types::$types[$queue_id]->lang, 'SUBSCRIPTION_TIME' => phpbb::$user->format_date($row['watch_mark_time']), 'SUBSCRIPTION_TITLE' => phpbb::$user->lang['SUBSCRIPTION_QUEUE'], 'SUBSCRIPTION_TYPE' => $row['watch_object_type'], 'S_QUEUE' => true, 'S_ACCESS_TEAMS' => true, 'U_VIEW_SUBSCRIPTION' => titania_url::append_url($base_url, array('queue' => titania_types::$types[$queue_id]->url)));
                                }
                            }
                        }
                        phpbb::$template->assign_block_vars($tpl_block, $vars);
                    }
                }
                break;
        }
        phpbb::$template->assign_vars(array('S_ACTION' => $url, 'TITANIA_THEME_PATH' => titania::$absolute_path . 'styles/' . titania::$config->style . '/theme/'));
        titania::page_header(phpbb::$user->lang['SUBSCRIPTION_TITANIA']);
        titania::page_footer(true, 'manage/' . $mode . '.html');
    }
コード例 #30
0
                    phpbb::update_user_postcount($post->post_user_id);
                }
                $post->submit();
                // Load z topic
                $post->topic->topic_id = $post->topic_id;
                $post->topic->load();
                // Update first/last post?
                if ($post->topic->topic_first_post_time > $post->post_time) {
                    $post->topic->sync_first_post();
                }
                if ($post->topic->topic_last_post_time < $post->post_time) {
                    $post->topic->sync_last_post();
                }
                // Subscriptions?
                if ($post->topic->topic_last_post_id == $post->post_id) {
                    phpbb::_include('functions_messenger', false, 'messenger');
                    $email_vars = array('NAME' => $post->topic->topic_subject, 'U_VIEW' => titania_url::append_url($post->topic->get_url(), array('view' => 'unread', '#' => 'unread')));
                    titania_subscriptions::send_notifications(TITANIA_TOPIC, $post->topic_id, 'subscribe_notify.txt', $email_vars, $post->post_user_id);
                }
                $sql = 'SELECT COUNT(post_id) AS cnt FROM ' . TITANIA_POSTS_TABLE . '
					WHERE topic_id = ' . $post->topic_id . '
						AND post_approved = 0';
                phpbb::$db->sql_query($sql);
                $cnt = phpbb::$db->sql_fetchfield('cnt');
                if (!$cnt) {
                    $sql = 'UPDATE ' . TITANIA_TOPICS_TABLE . '
						SET topic_approved = 1
						WHERE topic_id = ' . $post->topic_id;
                    phpbb::$db->sql_query($sql);
                    // Subscriptions
                    if ($post->topic->topic_last_post_id == $post->post_id) {