예제 #1
0
 public function __construct($post_object)
 {
     titania::add_lang('posting');
     phpbb::$user->add_lang('posting');
     if (!function_exists('titania_access_select')) {
         include TITANIA_ROOT . 'includes/functions_posting.' . PHP_EXT;
     }
     $this->post_object = $post_object;
 }
예제 #2
0
 /**
  * Load the types into the $types array
  */
 public static function load_types()
 {
     $dh = @opendir(TITANIA_ROOT . 'includes/types/');
     if (!$dh) {
         trigger_error('Could not open the types directory');
     }
     while (($fname = readdir($dh)) !== false) {
         if (strpos($fname, '.' . PHP_EXT) && substr($fname, 0, 1) != '_' && $fname != 'base.' . PHP_EXT) {
             include TITANIA_ROOT . 'includes/types/' . $fname;
             $class_name = 'titania_type_' . substr($fname, 0, strpos($fname, '.' . PHP_EXT));
             titania::add_lang('types/' . substr($fname, 0, strpos($fname, '.' . PHP_EXT)));
             $class = new $class_name();
             $class->auto_install();
             self::$types[$class->id] = $class;
         }
     }
     closedir($dh);
     ksort(self::$types);
 }
예제 #3
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;
 }
예제 #4
0
/**
* Copy new posts for queue discussion, queue to the forum
*/
function phpbb_com_titania_queue_update_first_queue_post($hook, &$post_object, $queue_object)
{
    if ($queue_object->queue_status == TITANIA_QUEUE_HIDE || !$queue_object->queue_topic_id) {
        return;
    }
    // First we copy over the queue discussion topic if required
    $sql = 'SELECT topic_id, phpbb_topic_id, topic_category FROM ' . TITANIA_TOPICS_TABLE . '
		WHERE parent_id = ' . $queue_object->contrib_id . '
			AND topic_type = ' . TITANIA_QUEUE_DISCUSSION;
    $result = phpbb::$db->sql_query($sql);
    $topic_row = phpbb::$db->sql_fetchrow($result);
    phpbb::$db->sql_freeresult($result);
    // Do we need to create the queue discussion topic or not?
    if ($topic_row['topic_id'] && !$topic_row['phpbb_topic_id']) {
        $forum_id = phpbb_com_forum_id($post_object->topic->topic_category, TITANIA_QUEUE_DISCUSSION);
        $temp_post = new titania_post();
        // Go through any posts in the queue discussion topic and copy them
        $topic_id = false;
        $sql = 'SELECT * FROM ' . TITANIA_POSTS_TABLE . ' WHERE topic_id = ' . $topic_row['topic_id'];
        $result = phpbb::$db->sql_query($sql);
        while ($row = phpbb::$db->sql_fetchrow($result)) {
            $temp_post->__set_array($row);
            $post_text = $row['post_text'];
            titania_decode_message($post_text, $row['post_text_uid']);
            $post_text .= "\n\n" . titania_url::remove_sid($temp_post->get_url());
            $options = array('poster_id' => $row['post_user_id'], 'forum_id' => $forum_id, 'topic_title' => $row['post_subject'], 'post_text' => $post_text);
            titania::_include('functions_posting', 'phpbb_posting');
            if ($topic_id) {
                $options = array_merge($options, array('topic_id' => $topic_id));
                phpbb_posting('reply', $options);
            } else {
                switch ($topic_row['topic_category']) {
                    case TITANIA_TYPE_MOD:
                        $options['poster_id'] = titania::$config->forum_mod_robot;
                        break;
                    case TITANIA_TYPE_STYLE:
                        $options['poster_id'] = titania::$config->forum_style_robot;
                        break;
                }
                $topic_id = phpbb_posting('post', $options);
            }
        }
        phpbb::$db->sql_freeresult($result);
        if ($topic_id) {
            $sql = 'UPDATE ' . TITANIA_TOPICS_TABLE . '
				SET phpbb_topic_id = ' . $topic_id . '
				WHERE topic_id = ' . $topic_row['topic_id'];
            phpbb::$db->sql_query($sql);
        }
        unset($temp_post);
    }
    // Does a queue topic already exist?  If so, don't repost.
    $sql = 'SELECT phpbb_topic_id FROM ' . TITANIA_TOPICS_TABLE . '
		WHERE topic_id = ' . $queue_object->queue_topic_id;
    phpbb::$db->sql_query($sql);
    $phpbb_topic_id = phpbb::$db->sql_fetchfield('phpbb_topic_id');
    phpbb::$db->sql_freeresult();
    if ($phpbb_topic_id) {
        return;
    }
    $forum_id = phpbb_com_forum_id($post_object->topic->topic_category, $post_object->topic->topic_type);
    if (!$forum_id) {
        return;
    }
    $post_object->submit();
    titania::_include('functions_posting', 'phpbb_posting');
    // Need some stuff
    titania::add_lang('contributions');
    $contrib = new titania_contribution();
    $contrib->load((int) $queue_object->contrib_id);
    $revision = $queue_object->get_revision();
    $contrib->get_download($revision->revision_id);
    switch ($post_object->topic->topic_category) {
        case TITANIA_TYPE_MOD:
            $post_object->topic->topic_first_post_user_id = titania::$config->forum_mod_robot;
            $lang_var = 'MOD_QUEUE_TOPIC';
            break;
        case TITANIA_TYPE_STYLE:
            $post_object->topic->topic_first_post_user_id = titania::$config->forum_style_robot;
            $lang_var = 'STYLE_QUEUE_TOPIC';
            break;
        default:
            return;
            break;
    }
    $description = $contrib->contrib_desc;
    titania_decode_message($description, $contrib->contrib_desc_uid);
    $post_text = sprintf(phpbb::$user->lang[$lang_var], $contrib->contrib_name, $contrib->author->get_url(), users_overlord::get_user($contrib->author->user_id, '_username'), $description, $revision->revision_version, titania_url::build_url('download', array('id' => $revision->attachment_id)), $contrib->download['real_filename'], $contrib->download['filesize']);
    $post_text .= "\n\n" . $post_object->post_text;
    titania_decode_message($post_text, $post_object->post_text_uid);
    $post_text .= "\n\n" . titania_url::remove_sid($post_object->get_url());
    $options = array('poster_id' => $post_object->topic->topic_first_post_user_id, 'forum_id' => $forum_id, 'topic_title' => $post_object->topic->topic_subject, 'post_text' => $post_text);
    $topic_id = phpbb_posting('post', $options);
    $post_object->topic->phpbb_topic_id = $topic_id;
    $sql = 'UPDATE ' . TITANIA_TOPICS_TABLE . '
		SET phpbb_topic_id = ' . (int) $topic_id . '
		WHERE topic_id = ' . $post_object->topic->topic_id;
    phpbb::$db->sql_query($sql);
}
예제 #5
0
    /**
     * Repack a revision
     *
     * @param titania_revision $old_revision titania_revision object
     */
    public function repack($old_revision)
    {
        if (!$this->revision_id) {
            throw new exception('Submit the revision before repacking');
        }
        titania::add_lang('manage');
        // Get the old and new queue objects
        $old_queue = $old_revision->get_queue();
        $queue = $this->get_queue();
        if ($old_queue === false) {
            throw new exception('Old queue missing. Revision ID: ' . $old_revision->revision_id);
        }
        // Reply to the queue topic to say that it's been repacked and have the old mpv/automod results listed in it as well
        $repack_message = phpbb::$user->lang['REVISION_REPACKED'] . "\n\n";
        // Add the MPV results
        if ($old_queue->mpv_results) {
            $mpv_results = $old_queue->mpv_results;
            titania_decode_message($mpv_results, $old_queue->mpv_results_uid);
            $repack_message .= '[quote="' . phpbb::$user->lang['OLD_VALIDATION_MPV'] . '"]' . $mpv_results . "[/quote]\n";
        }
        // Add the Automod results
        if ($old_queue->automod_results) {
            $repack_message .= '[quote="' . phpbb::$user->lang['OLD_VALIDATION_AUTOMOD'] . '"]' . $old_queue->automod_results . "[/quote]\n";
        }
        // Reply
        $old_queue->topic_reply($repack_message);
        // Update the old queue with the new results
        $old_queue->revision_id = $queue->revision_id;
        $old_queue->mpv_results = $queue->mpv_results;
        $old_queue->mpv_results_bitfield = $queue->mpv_results_bitfield;
        $old_queue->mpv_results_uid = $queue->mpv_results_uid;
        $old_queue->automod_results = $queue->automod_results;
        $old_queue->submit();
        // Delete the new queue we made for this revision
        $queue->delete();
        // Unlink the old queue_id from the old revision and set it to repacked
        $old_revision->change_status(TITANIA_REVISION_REPACKED);
        $old_revision->revision_queue_id = 0;
        $old_revision->submit();
        // Update the queue_id for this revision to point to the old queue_id
        $this->revision_queue_id = $old_queue->queue_id;
        $this->submit();
        // Move any translations
        $sql = 'UPDATE ' . TITANIA_ATTACHMENTS_TABLE . '
			SET object_id = ' . $this->revision_id . '
			WHERE object_type = ' . TITANIA_TRANSLATION . '
				AND object_id = ' . $old_revision->revision_id;
        phpbb::$db->sql_query($sql);
        // Hooks
        titania::$hook->call_hook_ref(array(__CLASS__, __FUNCTION__), $this);
    }
예제 #6
0
    $search_types = array_merge($search_types, array(TITANIA_SUPPORT => 'CONTRIB_SUPPORT'));
}
$mode = request_var('mode', '');
$keywords = utf8_normalize_nfc(request_var('keywords', '', true));
$user_id = request_var('u', 0);
$contrib_id = request_var('contrib', 0);
$search_fields = request_var('sf', '');
$search_type = request_var('type', 0);
$categories = request_var('c', array(0));
$search_subcategories = request_var('sc', 0);
$phpbb_versions = request_var('versions', array(''));
// Display the advanced search page
if (!$keywords && !$user_id && !$contrib_id && !isset($_POST['submit'])) {
    if ($mode == 'find-contribution') {
        titania::_include('functions_posting', 'generate_category_select');
        titania::add_lang('contributions');
        phpbb::$template->assign_vars(array('S_SEARCH_ACTION' => titania_url::build_url('find-contribution')));
        // Display the list of phpBB versions available
        foreach (titania::$cache->get_phpbb_versions() as $version => $name) {
            $template->assign_block_vars('phpbb_versions', array('VERSION' => $name));
        }
        generate_category_select($categories, false, false);
        titania::page_header('SEARCH');
        titania::page_footer(true, 'find_contribution.html');
    }
    // Output search types
    foreach ($search_types as $value => $name) {
        phpbb::$template->assign_block_vars('types', array('NAME' => isset(phpbb::$user->lang[$name]) ? phpbb::$user->lang[$name] : $name, 'VALUE' => $value));
    }
    phpbb::$template->assign_vars(array('S_SEARCH_ACTION' => titania_url::build_url('search')));
    titania::page_header('SEARCH');
예제 #7
0
 * @copyright (c) 2008 phpBB Customisation Database Team
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
 *
 */
/**
* @ignore
*/
define('IN_TITANIA', true);
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('faq', false, true);
/**
* From phpBB faq.php
*/
// Pull the array data from the lang pack
$switch_column = $found_switch = false;
$help_blocks = array();
foreach (phpbb::$user->help as $help_ary) {
    if ($help_ary[0] == '--') {
        if ($help_ary[1] == '--') {
            $switch_column = true;
            $found_switch = true;
            continue;
        }
        phpbb::$template->assign_block_vars('faq_block', array('BLOCK_TITLE' => $help_ary[1], 'SWITCH_COLUMN' => $switch_column));
        if ($switch_column) {
예제 #8
0
    /**
     * Display a single queue item
     *
     * @param int $queue_id
     * @return array('row' => (sql selection), 'contrib' => $contrib, 'topic' => $topic)
     */
    public static function display_queue_item($queue_id)
    {
        titania::add_lang('contributions');
        $sql_ary = array('SELECT' => '*', 'FROM' => array(TITANIA_QUEUE_TABLE => 'q', TITANIA_REVISIONS_TABLE => 'r', TITANIA_TOPICS_TABLE => 't'), 'WHERE' => 'q.queue_id = ' . (int) $queue_id . '
				AND r.revision_id = q.revision_id
				AND t.topic_id = q.queue_topic_id');
        // Main SQL Query
        $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary);
        $result = phpbb::$db->sql_query($sql);
        $row = phpbb::$db->sql_fetchrow($result);
        phpbb::$db->sql_freeresult($result);
        if (!$row) {
            trigger_error('NO_QUEUE_ITEM');
        }
        self::$queue[$queue_id] = $row;
        // Load the contribution
        $contrib = new titania_contribution();
        $contrib->load((int) $row['contrib_id']);
        $contrib->get_download($row['revision_id']);
        $contrib->get_revisions();
        $contrib->get_screenshots();
        $contrib->assign_details();
        // Load the topic (with the already selected data)
        $topic = new titania_topic();
        $topic->__set_array($row);
        // Bit of a hack for the posting
        $_REQUEST['t'] = $topic->topic_id;
        // Some quick-actions
        $quick_actions = array();
        if ($row['queue_status'] > 0) {
            if ($row['queue_progress'] == phpbb::$user->data['user_id']) {
                $quick_actions['MARK_NO_PROGRESS'] = array('url' => titania_url::append_url(titania_url::$current_page_url, array('action' => 'no_progress')), 'class' => 'queue_progress');
            } else {
                if (!$row['queue_progress']) {
                    $quick_actions['MARK_IN_PROGRESS'] = array('url' => titania_url::append_url(titania_url::$current_page_url, array('action' => 'in_progress')), 'class' => 'queue_progress');
                }
            }
            $tags = titania::$cache->get_tags(TITANIA_QUEUE);
            unset($tags[$row['queue_status']]);
            $quick_actions['CHANGE_STATUS'] = array('url' => titania_url::append_url(titania_url::$current_page_url, array('action' => 'move')), 'class' => 'change_status', 'tags' => $tags);
            if (titania_types::$types[$contrib->contrib_type]->acl_get('moderate')) {
                $quick_actions['REPACK'] = array('url' => titania_url::append_url($contrib->get_url('revision'), array('repack' => $row['revision_id'])), 'class' => 'repack');
            }
            // This allows you to alter the author submitted notes to the validation team, not really useful as the field's purpose was changed, so commenting out
            /*$quick_actions['ALTER_NOTES'] = array(
            			'url'		=> titania_url::append_url(titania_url::$current_page_url, array('action' => 'notes')),
            		);*/
            // Misc actions
            $subactions = array();
            if (titania_types::$types[$contrib->contrib_type]->mpv_test) {
                $subactions['RETEST_MPV'] = array('url' => titania_url::build_url('', array('action' => 'mpv', 'revision' => $row['revision_id'])));
            }
            if (titania_types::$types[$contrib->contrib_type]->automod_test) {
                $subactions['RETEST_AUTOMOD'] = array('url' => titania_url::build_url('', array('action' => 'automod', 'revision' => $row['revision_id'])));
            }
            $subactions['REBUILD_FIRST_POST'] = array('url' => titania_url::append_url(titania_url::$current_page_url, array('action' => 'rebuild')));
            $quick_actions['CAT_MISC'] = array('subactions' => $subactions, 'class' => 'misc');
            // Validation
            if (titania_types::$types[$contrib->contrib_type]->acl_get('validate')) {
                $quick_actions['APPROVE'] = array('url' => titania_url::append_url(titania_url::$current_page_url, array('action' => 'approve', 'start' => '*destroy*')), 'class' => 'approve');
                $quick_actions['DENY'] = array('url' => titania_url::append_url(titania_url::$current_page_url, array('action' => 'deny', 'start' => '*destroy*')), 'class' => 'deny');
            }
        }
        foreach ($quick_actions as $lang_key => $data) {
            phpbb::$template->assign_block_vars('queue_actions', array('NAME' => isset(phpbb::$user->lang[$lang_key]) ? phpbb::$user->lang[$lang_key] : $lang_key, 'CLASS' => isset($data['class']) ? $data['class'] : '', 'U_VIEW' => isset($data['url']) ? $data['url'] : ''));
            if (isset($data['tags'])) {
                foreach ($data['tags'] as $tag_id => $tag_row) {
                    phpbb::$template->assign_block_vars('queue_actions.subactions', array('ID' => $tag_id, 'NAME' => isset(phpbb::$user->lang[$tag_row['tag_field_name']]) ? phpbb::$user->lang[$tag_row['tag_field_name']] : $tag_row['tag_field_name'], 'U_ACTION' => titania_url::append_url($data['url'], array('id' => $tag_id, 'hash' => generate_link_hash('quick_actions')))));
                }
            }
            if (isset($data['subactions'])) {
                foreach ($data['subactions'] as $sublang_key => $subdata) {
                    phpbb::$template->assign_block_vars('queue_actions.subactions', array('NAME' => isset(phpbb::$user->lang[$sublang_key]) ? phpbb::$user->lang[$sublang_key] : $sublang_key, 'U_ACTION' => $subdata['url']));
                }
            }
        }
        if ($row['queue_status'] == -2) {
            $current_status = phpbb::$user->lang['REVISION_DENIED'];
        } else {
            if ($row['queue_status'] == -1) {
                $current_status = phpbb::$user->lang['REVISION_APPROVED'];
            } else {
                $current_status = titania_tags::get_tag_name($row['queue_status']);
            }
        }
        phpbb::$template->assign_vars(array('CURRENT_STATUS' => $current_status, 'S_DISPLAY_CONTRIBUTION' => true, 'S_IN_QUEUE' => true, 'U_POST_REPLY' => titania_url::append_url(titania_url::$current_page_url, array('action' => 'reply', 't' => $topic->topic_id)), 'U_NEW_REVISION' => false));
        // Subscriptions
        titania_subscriptions::handle_subscriptions(TITANIA_TOPIC, $topic->topic_id, titania_url::$current_page_url);
        return compact('row', 'contrib', 'topic');
    }
예제 #9
0
 private function common_delete($post_id, $undelete = false)
 {
     titania::add_lang('posting');
     phpbb::$user->add_lang('posting');
     // Load the stuff we need
     $post_object = $this->load_post($post_id);
     // Check permissions
     if (!$undelete && !$post_object->acl_get('delete') || $undelete && !$post_object->acl_get('undelete')) {
         titania::needs_auth();
     }
     if (titania::confirm_box(true)) {
         if (!$undelete) {
             $redirect_post_id = false;
             // Delete the post
             if (isset($_POST['hard_delete']) || $post_object->post_deleted) {
                 if (!phpbb::$auth->acl_get('u_titania_post_hard_delete')) {
                     titania::needs_auth();
                 }
                 $post_object->hard_delete();
                 // Try to redirect to the next or previous post
                 $redirect_post_id = posts_overlord::next_prev_post_id($post_object->topic_id, $post_object->post_id);
                 if ($redirect_post_id) {
                     redirect(titania_url::append_url($post_object->topic->get_url(), array('p' => $redirect_post_id, '#p' => $redirect_post_id)));
                 }
                 redirect(titania_url::build_url($post_object->topic->topic_url));
             } else {
                 $post_object->soft_delete();
                 if (phpbb::$auth->acl_get('u_titania_mod_post_mod')) {
                     // They can see the post, redirect back to it
                     redirect($post_object->get_url());
                 } else {
                     // They cannot see the post, try to redirect to the next or previous post
                     $redirect_post_id = posts_overlord::next_prev_post_id($post_object->topic_id, $post_object->post_id);
                     if ($redirect_post_id) {
                         redirect(titania_url::append_url($post_object->topic->get_url(), array('p' => $redirect_post_id, '#p' => $redirect_post_id)));
                     }
                 }
             }
             redirect($post_object->topic->get_url());
         } else {
             $post_object->undelete();
             redirect($post_object->get_url());
         }
     } else {
         phpbb::$template->assign_var('S_HARD_DELETE', !$undelete && !$post_object->post_deleted && phpbb::$auth->acl_get('u_titania_post_hard_delete') ? true : false);
         titania::confirm_box(false, !$undelete ? 'DELETE_POST' : 'UNDELETE_POST', '', array(), 'posting/delete_confirm.html');
     }
     redirect($post_object->get_url());
 }
예제 #10
0
 */
/**
* @ignore
*/
if (!defined('IN_TITANIA')) {
    exit;
}
titania::add_lang('authors');
// Load the Contrib item
load_contrib();
if ($page == 'report') {
    // Check permissions
    if (!phpbb::$user->data['is_registered']) {
        titania::needs_auth();
    }
    titania::add_lang('posting');
    phpbb::$user->add_lang('mcp');
    if (titania::confirm_box(true)) {
        $message = utf8_normalize_nfc(request_var('report_text', '', true));
        titania::$contrib->report($message);
        // Notifications
        redirect(titania::$contrib->get_url());
    } else {
        //phpbb::$template->assign_var('S_CAN_NOTIFY', ((phpbb::$user->data['is_registered']) ? true : false));
        titania::confirm_box(false, 'REPORT_CONTRIBUTION', '', array(), 'posting/report_body.html');
    }
    redirect(titania::$contrib->get_url());
}
titania::$contrib->get_download();
titania::$contrib->get_revisions();
titania::$contrib->get_screenshots();
예제 #11
0
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
 *
 */
/**
* @ignore
*/
define('IN_TITANIA', true);
if (!defined('TITANIA_ROOT')) {
    define('TITANIA_ROOT', '../');
}
if (!defined('PHP_EXT')) {
    define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
}
include TITANIA_ROOT . 'common.' . PHP_EXT;
// Add common lang
titania::add_lang('authors');
// Load the author
$author = utf8_normalize_nfc(request_var('u', '', true));
titania::$author = new titania_author();
if (!titania::$author->load($author)) {
    trigger_error('AUTHOR_NOT_FOUND');
}
titania::$author->assign_details();
// Check to see if the currently accessing user is the author
if (titania::$access_level == TITANIA_ACCESS_PUBLIC && phpbb::$user->data['user_id'] == titania::$author->user_id) {
    titania::$access_level = TITANIA_ACCESS_AUTHORS;
}
/**
* Menu Array
*
* 'filename' => array(
예제 #12
0
/**
 *
 * @package titania
 * @version $Id$
 * @copyright (c) 2008 Customisation Database Team
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
 *
 */
/**
* @ignore
*/
if (!defined('IN_TITANIA')) {
    exit;
}
titania::add_lang('faq');
$faq_id = request_var('f', 0);
$action = request_var('action', '');
$error = array();
// Setup faq object
$faq = new titania_faq($faq_id);
if ($faq_id) {
    if (!$faq->contrib_id) {
        // Faq does not exist
        trigger_error('FAQ_NOT_FOUND');
    }
    load_contrib($faq->contrib_id);
} else {
    load_contrib();
}
// Output the simple info on the contrib
예제 #13
0
 *
 */
/**
 * @ignore
 */
define('IN_TITANIA', true);
define('IN_TITANIA_INSTALL', true);
define('UMIL_AUTO', true);
if (!defined('TITANIA_ROOT')) {
    define('TITANIA_ROOT', './');
}
if (!defined('PHP_EXT')) {
    define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
}
include TITANIA_ROOT . 'common.' . PHP_EXT;
titania::add_lang('install');
// Hopefully this helps
@set_time_limit(0);
include TITANIA_ROOT . 'includes/functions_install.' . PHP_EXT;
// Just to be on the safe side, add a php version check.
if (version_compare(PHP_VERSION, '5.2.0') < 0) {
    die('You are running an unsupported PHP version. Please upgrade to PHP 5.2.0 or higher before trying to install Titania');
}
if (!file_exists(PHPBB_ROOT_PATH . 'umil/umil_auto.' . PHP_EXT)) {
    trigger_error('Please download the latest UMIL (Unified MOD Install Library) from: <a href="http://www.phpbb.com/mods/umil/">phpBB.com/mods/umil</a>', E_USER_ERROR);
}
// Make sure we are not using the same table prefix as phpBB (will cause conflicts).
if (titania::$config->table_prefix == $GLOBALS['table_prefix']) {
    trigger_error('You can not use the same table prefix for Titania as you are using for phpBB.');
}
// Include the versions/data file
    /**
     * Run the tool
     */
    function run_tool()
    {
        // Define some vars that we'll need
        $start = request_var('start', 0);
        $limit = 100;
        // Create topic if it does not exist?
        $create_topic = true;
        titania::_include('functions_posting', 'phpbb_posting');
        titania::add_lang('contributions');
        $types = array();
        foreach (titania_types::$types as $id => $class) {
            if ($class->forum_robot && $class->forum_database) {
                $types[] = $id;
            }
        }
        if (!sizeof($types)) {
            trigger_back('UPDATE_RELEASE_TOPICS_COMPLETE');
        }
        $sql = 'SELECT COUNT(contrib_id) AS cnt FROM ' . TITANIA_CONTRIBS_TABLE . '
			WHERE ' . phpbb::$db->sql_in_set('contrib_status', array(TITANIA_CONTRIB_APPROVED, TITANIA_CONTRIB_DOWNLOAD_DISABLED)) . '
				AND ' . phpbb::$db->sql_in_set('contrib_type', $types);
        phpbb::$db->sql_query($sql);
        $total = phpbb::$db->sql_fetchfield('cnt');
        phpbb::$db->sql_freeresult();
        // Grab our batch
        $sql_ary = array('SELECT' => 'c.contrib_id, c.contrib_user_id, c.contrib_type, c.contrib_name, c.contrib_name_clean, c.contrib_desc, c.contrib_desc_uid, c.contrib_release_topic_id,
				t.topic_first_post_id,
				u.user_id, u.username, u.username_clean, u.user_colour', 'FROM' => array(TITANIA_CONTRIBS_TABLE => 'c', USERS_TABLE => 'u'), 'LEFT_JOIN' => array(array('FROM' => array(TOPICS_TABLE => 't'), 'ON' => 't.topic_id = c.contrib_release_topic_id')), 'GROUP_BY' => 'c.contrib_id', 'WHERE' => phpbb::$db->sql_in_set('c.contrib_status', array(TITANIA_CONTRIB_APPROVED, TITANIA_CONTRIB_DOWNLOAD_DISABLED)) . '
				AND u.user_id = c.contrib_user_id
				AND ' . phpbb::$db->sql_in_set('contrib_type', $types), 'ORDER_BY' => 'c.contrib_id DESC');
        $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary);
        $result = phpbb::$db->sql_query_limit($sql, $limit, $start);
        while ($row = phpbb::$db->sql_fetchrow($result)) {
            // Grab the revisions
            $revisions = array();
            $sql = 'SELECT r.revision_id, r.attachment_id, r.revision_version, a.real_filename, a.filesize
				FROM ' . TITANIA_REVISIONS_TABLE . ' r, ' . TITANIA_ATTACHMENTS_TABLE . ' a
				WHERE r.contrib_id = ' . $row['contrib_id'] . '
					AND r.revision_status = ' . TITANIA_REVISION_APPROVED . '
					AND a.attachment_id = r.attachment_id';
            $rev_result = phpbb::$db->sql_query($sql);
            while ($rev_row = phpbb::$db->sql_fetchrow($rev_result)) {
                $revisions[$rev_row['revision_version']] = $rev_row;
            }
            phpbb::$db->sql_freeresult($rev_result);
            // Sort the revisions by their version, put the newest one in $revision
            uksort($revisions, 'reverse_version_compare');
            if (!sizeof($revisions)) {
                continue;
            }
            $revision = array_shift($revisions);
            users_overlord::$users[$row['user_id']] = $row;
            $contrib = new titania_contribution();
            $contrib->__set_array($row);
            $contrib->download = $row;
            // Update the release topic
            $contrib->update_release_topic();
        }
        phpbb::$db->sql_freeresult($result);
        if ($start + $limit >= $total) {
            trigger_back('UPDATE_RELEASE_TOPICS_COMPLETE');
        } else {
            meta_refresh(0, titania_url::build_url('manage/administration', array('t' => 'update_release_topics', 'start' => $start + $limit, 'submit' => 1, 'hash' => generate_link_hash('manage'))));
            trigger_error(phpbb::$user->lang('UPDATE_RELEASE_TOPICS_PROGRESS', $start + $limit, $total));
        }
    }
예제 #15
0
 */
/**
* @ignore
*/
define('IN_TITANIA', true);
if (!defined('TITANIA_ROOT')) {
    define('TITANIA_ROOT', '../');
}
if (!defined('PHP_EXT')) {
    define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
}
include TITANIA_ROOT . 'common.' . PHP_EXT;
// Setup some vars
$page = basename(request_var('page', ''));
// Add common lang
titania::add_lang('manage');
// Count the number of open attention items
$sql = 'SELECT COUNT(attention_id) AS cnt FROM ' . TITANIA_ATTENTION_TABLE . '
	WHERE attention_close_time = 0';
phpbb::$db->sql_query($sql);
$attention_count = phpbb::$db->sql_fetchfield('cnt');
phpbb::$db->sql_freeresult();
/**
* Menu Array
*
* 'filename' => array(
*	'title'		=> 'nav menu title',
* 	'url'		=> $page_url,
*	'auth'		=> ($can_see_page) ? true : false, // Not required, always true if missing
* ),
*/
예제 #16
0
 /**
  * Copy the modx install file to the storage path (and edit it to use our xsl file)
  *
  * @param string $to Place to copy the modx file to
  */
 public function copy_modx_install($to)
 {
     // Find the main modx file
     $modx_root = $this->find_root();
     echo $modx_root;
     if ($modx_root === false) {
         titania::add_lang('contributions');
         $this->error[] = phpbb::$user->lang['COULD_NOT_FIND_ROOT'];
         return false;
     }
     $modx_root = $this->unzip_dir . $modx_root;
     $modx_file = false;
     if (file_exists($modx_root . 'install.xml')) {
         $modx_file = $modx_root . 'install.xml';
     } else {
         // Find the first item with install in the name
         foreach (scandir($modx_root) as $item) {
             if (strpos($item, 'install') !== false && strpos($item, '.xml')) {
                 $modx_file = $modx_root . $item;
                 break;
             }
         }
     }
     if (!$modx_file) {
         titania::add_lang('contributions');
         $this->error[] = phpbb::$user->lang['COULD_NOT_FIND_ROOT'];
         return false;
     }
     // Open the file
     if (!($file_contents = file_get_contents($modx_file))) {
         titania::add_lang('contributions');
         $this->error[] = phpbb::$user->lang['COULD_NOT_OPEN_MODX'];
         return false;
     }
     // Find the ModX version
     $version = array();
     preg_match('#<mod (.*)xmlns="(.*)"(.*)>#', $file_contents, $version);
     preg_match('#([0-9]\\.(.*))\\.xsd#', $version[2], $version);
     $modx_version = preg_replace('#[^a-zA-Z0-9\\.]#', '', $version[1]);
     // Replace the stylesheet path
     $file_contents = preg_replace('#<\\?xml\\-stylesheet (.*)\\?>#', '<?xml-stylesheet type="text/xsl" href="./modx/' . $modx_version . '.xsl" ?>', $file_contents);
     // Replace the link-group
     $file_contents = preg_replace('#<link\\-group>(.*)</link\\-group>#', '', $file_contents);
     // Output time
     file_put_contents($to, $file_contents);
     phpbb_chmod($to, CHMOD_READ | CHMOD_WRITE);
     return true;
 }
예제 #17
0
 /**
  * Load the requested tool
  *
  * @param String $tool_name The name of this tool
  * @param Boolean $return Specify whether an object of this tool will be returned
  * @return The object of the requested tool if $return is set to true else this method will return true
  */
 function load_tool($tool_name, $return = true)
 {
     global $user;
     static $tools_loaded = array();
     if (isset($tools_loaded[$tool_name])) {
         return $return ? $tools_loaded[$tool_name] : true;
     }
     $tool_path = $this->tool_box_path . $tool_name . '.' . PHP_EXT;
     if (false === @(include $tool_path)) {
         trigger_error(sprintf($user->lang['TOOL_INCLUTION_NOT_FOUND'], $tool_path), E_USER_ERROR);
     }
     if (!class_exists($tool_name)) {
         trigger_error(sprintf($user->lang['INCORRECT_CLASS'], $tool_name, PHP_EXT), E_USER_ERROR);
     }
     // Construct the class
     $tools_loaded[$tool_name] = new $tool_name();
     // Add the language file
     titania::add_lang('manage_tools/' . $tool_name);
     // Return
     return $return ? $tools_loaded[$tool_name] : true;
 }
예제 #18
0
    /**
     * Display contributions
     *
     * @param string $mode The mode (category, author)
     * @param int $id The parent id (only show contributions under this category, author, etc)
     * @param string $blockname The name of the template block to use (contribs by default)
     */
    function display_contribs($mode, $id, $sort = false, $blockname = 'contribs')
    {
        titania::add_lang('contributions');
        titania::_include('functions_display', 'titania_topic_folder_img');
        // Setup the sort tool if not sent, then request
        if ($sort === false) {
            $sort = self::build_sort();
        }
        $sort->request();
        $select = 'DISTINCT(c.contrib_id), c.contrib_name, c.contrib_name_clean, c.contrib_status, c.contrib_downloads, c.contrib_views, c.contrib_rating, c.contrib_rating_count, c.contrib_type, c.contrib_last_update, c.contrib_user_id';
        switch ($mode) {
            case 'author':
                // Get the contrib_ids this user is an author in (includes as a co-author)
                $contrib_ids = titania::$cache->get_author_contribs($id);
                if (!sizeof($contrib_ids)) {
                    return compact('sort');
                }
                $sql_ary = array('SELECT' => $select, 'FROM' => array(TITANIA_CONTRIBS_TABLE => 'c'), 'WHERE' => phpbb::$db->sql_in_set('c.contrib_id', $contrib_ids) . '
						AND c.contrib_visible = 1', 'ORDER_BY' => $sort->get_order_by());
                break;
            case 'category':
                $sql_ary = array('SELECT' => $select, 'FROM' => array(TITANIA_CONTRIB_IN_CATEGORIES_TABLE => 'cic'), 'LEFT_JOIN' => array(array('FROM' => array(TITANIA_CONTRIBS_TABLE => 'c'), 'ON' => 'cic.contrib_id = c.contrib_id')), 'WHERE' => (is_array($id) && sizeof($id) ? phpbb::$db->sql_in_set('cic.category_id', array_map('intval', $id)) : 'cic.category_id = ' . (int) $id) . '
						AND c.contrib_visible = 1', 'ORDER_BY' => $sort->get_order_by());
                break;
            case 'all':
                $sql_ary = array('SELECT' => $select, 'FROM' => array(TITANIA_CONTRIBS_TABLE => 'c'), 'WHERE' => 'c.contrib_visible = 1', 'ORDER_BY' => $sort->get_order_by());
                break;
        }
        titania_tracking::get_track_sql($sql_ary, TITANIA_CONTRIB, 'c.contrib_id');
        // Permissions
        if (titania::$config->require_validation && !phpbb::$auth->acl_get('u_titania_mod_contrib_mod')) {
            $sql_ary['LEFT_JOIN'][] = array('FROM' => array(TITANIA_CONTRIB_COAUTHORS_TABLE => 'cc'), 'ON' => 'cc.contrib_id = c.contrib_id AND cc.user_id = ' . phpbb::$user->data['user_id']);
            $view_unapproved = array();
            if (sizeof(titania_types::find_authed('moderate'))) {
                $view_unapproved = array_merge($view_unapproved, titania_types::find_authed('moderate'));
            }
            if (sizeof(titania_types::find_authed('view'))) {
                $view_unapproved = array_merge($view_unapproved, titania_types::find_authed('view'));
            }
            // Find the ones that do not require validation
            $view_unapproved = array_merge($view_unapproved, titania_types::find_validation_free());
            $view_unapproved = array_unique($view_unapproved);
            $sql_ary['WHERE'] .= ' AND (' . phpbb::$db->sql_in_set('c.contrib_status', array(TITANIA_CONTRIB_APPROVED, TITANIA_CONTRIB_DOWNLOAD_DISABLED)) . (sizeof($view_unapproved) ? ' OR ' . phpbb::$db->sql_in_set('c.contrib_type', array_map('intval', $view_unapproved)) : '') . '
				OR c.contrib_user_id = ' . phpbb::$user->data['user_id'] . '
				OR cc.active = 1)';
        }
        // Main SQL Query
        $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary);
        // Handle pagination
        if (!$sort->sql_count($sql_ary, 'DISTINCT(c.contrib_id)')) {
            // No results...no need to query more...
            return compact('sort');
        }
        $sort->build_pagination(titania_url::$current_page, titania_url::$params);
        $result = phpbb::$db->sql_query_limit($sql, $sort->limit, $sort->start);
        $contrib_ids = $user_ids = array();
        while ($row = phpbb::$db->sql_fetchrow($result)) {
            $user_ids[] = $row['contrib_user_id'];
            $contrib_ids[] = $row['contrib_id'];
            self::$contribs[$row['contrib_id']] = $row;
        }
        phpbb::$db->sql_freeresult($result);
        // Get user data
        users_overlord::load_users($user_ids);
        // Get phpBB versions
        if (sizeof($contrib_ids)) {
            $validation_free = titania_types::find_validation_free();
            if (sizeof($validation_free) && titania::$config->require_validation) {
                $sql = 'SELECT rp.contrib_id, rp.phpbb_version_branch, rp.phpbb_version_revision
					FROM ' . TITANIA_REVISIONS_PHPBB_TABLE . ' rp, ' . TITANIA_CONTRIBS_TABLE . ' c
					WHERE ' . phpbb::$db->sql_in_set('rp.contrib_id', array_map('intval', $contrib_ids)) . '
					AND c.contrib_id = rp.contrib_id
					AND (rp.revision_validated = 1
						OR ' . phpbb::$db->sql_in_set('c.contrib_type', $validation_free) . ')
					ORDER BY rp.row_id DESC';
            } else {
                $sql = 'SELECT contrib_id, phpbb_version_branch, phpbb_version_revision FROM ' . TITANIA_REVISIONS_PHPBB_TABLE . '
					WHERE ' . phpbb::$db->sql_in_set('contrib_id', array_map('intval', $contrib_ids)) . (titania::$config->require_validation ? ' AND revision_validated = 1' : '') . '
					ORDER BY row_id DESC';
            }
            $result = phpbb::$db->sql_query($sql);
            while ($row = phpbb::$db->sql_fetchrow($result)) {
                self::$contribs[$row['contrib_id']]['phpbb_versions'][] = $row;
            }
            phpbb::$db->sql_freeresult($result);
        }
        // Setup some objects we'll use for temps
        $contrib = new titania_contribution();
        $contrib->author = new titania_author();
        $versions = titania::$cache->get_phpbb_versions();
        $author_contribs = titania::$cache->get_author_contribs(phpbb::$user->data['user_id'], true);
        // Get the mark all tracking
        titania_tracking::get_track(TITANIA_CONTRIB, 0);
        foreach ($contrib_ids as $contrib_id) {
            $row = self::$contribs[$contrib_id];
            $contrib->__set_array($row);
            $contrib->author->user_id = $contrib->contrib_user_id;
            $contrib->author->__set_array($row);
            // Author contrib variables
            $contrib->is_author = $contrib->contrib_user_id == phpbb::$user->data['user_id'] ? true : false;
            $contrib->is_active_coauthor = in_array($contrib->contrib_id, $author_contribs) ? true : false;
            // Store the tracking info we grabbed from the DB
            titania_tracking::store_from_db($row);
            // Get the folder image
            $folder_img = $folder_alt = '';
            $last_read_mark = titania_tracking::get_track(TITANIA_CONTRIB, $contrib->contrib_id, true);
            $last_complete_mark = titania_tracking::get_track(TITANIA_CONTRIB, 0, true);
            $is_unread = $contrib->contrib_last_update > $last_read_mark && $contrib->contrib_last_update > $last_complete_mark ? true : false;
            titania_topic_folder_img($folder_img, $folder_alt, 0, $is_unread);
            // Only get unique phpBB versions supported
            if (isset($row['phpbb_versions'])) {
                titania::_include('functions_display', 'order_phpbb_version_list_from_db');
                $ordered_phpbb_versions = order_phpbb_version_list_from_db($row['phpbb_versions']);
            }
            phpbb::$template->assign_block_vars($blockname, array_merge($contrib->assign_details(true, true), 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_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'), 'PHPBB_VERSION' => isset($row['phpbb_versions']) && sizeof($ordered_phpbb_versions) == 1 ? $ordered_phpbb_versions[0] : '')));
            if (isset($row['phpbb_versions'])) {
                foreach ($ordered_phpbb_versions as $version_row) {
                    phpbb::$template->assign_block_vars($blockname . '.phpbb_versions', array('NAME' => $version_row));
                }
            }
            $contrib_type = $row['contrib_type'];
        }
        unset($contrib);
        return compact('sort');
    }
예제 #19
0
    /**
     * Get the queue discussion topic or create one if needed
     *
     * @return titania_topic object
     */
    public function get_queue_discussion_topic()
    {
        $sql = 'SELECT * FROM ' . TITANIA_TOPICS_TABLE . '
			WHERE parent_id = ' . $this->contrib_id . '
				AND topic_type = ' . TITANIA_QUEUE_DISCUSSION;
        $result = phpbb::$db->sql_query($sql);
        $row = phpbb::$db->sql_fetchrow($result);
        phpbb::$db->sql_freeresult($result);
        if ($row) {
            $topic = new titania_topic();
            $topic->__set_array($row);
            return $topic;
        }
        // No queue discussion topic...so we must create one
        titania::add_lang('posting');
        $contrib = contribs_overlord::get_contrib_object($this->contrib_id, true);
        $post = new titania_post(TITANIA_QUEUE_DISCUSSION);
        $post->topic->__set_array(array('parent_id' => $this->contrib_id, 'topic_category' => $contrib->contrib_type, 'topic_url' => titania_types::$types[$contrib->contrib_type]->url . '/' . $contrib->contrib_name_clean . '/support/', 'topic_sticky' => true));
        $post->__set_array(array('post_access' => TITANIA_ACCESS_AUTHORS, 'post_subject' => sprintf(phpbb::$user->lang['QUEUE_DISCUSSION_TOPIC_TITLE'], $contrib->contrib_name), 'post_text' => phpbb::$user->lang['QUEUE_DISCUSSION_TOPIC_MESSAGE']));
        $post->generate_text_for_storage(true, true, true);
        $post->submit();
        return $post->topic;
    }