Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions config/services.yml
Original file line number Diff line number Diff line change
@@ -302,24 +302,12 @@ services:
- '%core.root_path%'
- '%core.php_ext%'

phpbb.titania.mod.prevalidator:
class: phpbb\titania\contribution\mod\prevalidator
arguments:
- '@phpbb.titania.config'
- '@user'
- '@template'
- '@phpbb.titania.contribution.prevalidator_helper'
- '%core.root_path%'
- '%phpbb.titania.root_path%'
- '%core.php_ext%'

phpbb.titania.mod.type:
class: phpbb\titania\contribution\mod\type
arguments:
- '@phpbb.titania.config'
- '@user'
- '@auth'
- '@phpbb.titania.mod.prevalidator'
tags:
- { name: titania.contribution.type }

6 changes: 3 additions & 3 deletions contribution/bbcode/type.php
Original file line number Diff line number Diff line change
@@ -24,9 +24,9 @@ class type extends base
/** @var demo\demo */
protected $demo;

const ID = 7;
const NAME = 'bbcode';
const URL = 'bbcode';
public const ID = 7;
public const NAME = 'bbcode';
public const URL = 'bbcode';

/**
* Constructor
6 changes: 3 additions & 3 deletions contribution/bridge/type.php
Original file line number Diff line number Diff line change
@@ -17,9 +17,9 @@

class type extends base
{
const ID = 5;
const NAME = 'bridge';
const URL = 'bridge';
public const ID = 5;
public const NAME = 'bridge';
public const URL = 'bridge';

/**
* @{inheritDoc}
6 changes: 3 additions & 3 deletions contribution/converter/type.php
Original file line number Diff line number Diff line change
@@ -17,9 +17,9 @@

class type extends base
{
const ID = 3;
const NAME = 'converter';
const URL = 'converter';
public const ID = 3;
public const NAME = 'converter';
public const URL = 'converter';

/**
* @{inheritDoc}
6 changes: 3 additions & 3 deletions contribution/extension/type.php
Original file line number Diff line number Diff line change
@@ -26,9 +26,9 @@ class type extends base
/** @var prevalidator */
protected $prevalidator;

const ID = 8;
const NAME = 'extension';
const URL = 'extension';
public const ID = 8;
public const NAME = 'extension';
public const URL = 'extension';

/**
* Constructor
211 changes: 0 additions & 211 deletions contribution/mod/prevalidator.php

This file was deleted.

224 changes: 18 additions & 206 deletions contribution/mod/type.php
Original file line number Diff line number Diff line change
@@ -13,88 +13,43 @@

namespace phpbb\titania\contribution\mod;

use phpbb\auth\auth;
use phpbb\template\template;
use phpbb\titania\attachment\attachment;
use phpbb\titania\config\config as ext_config;
use phpbb\titania\contribution\type\base;
use phpbb\titania\entity\package;
use phpbb\user;

class type extends base
{
/** @var prevalidator */
protected $prevalidator;

const ID = 1;
const NAME = 'mod';
const URL = 'mod';

/**
* Constructor
*
* @param ext_config $ext_config
* @param user $user
* @param auth $auth
* @param prevalidator $prevalidator
*/
public function __construct(ext_config $ext_config, user $user, auth $auth, prevalidator $prevalidator)
{
parent::__construct($ext_config, $user, $auth);

$this->prevalidator = $prevalidator;
}
public const ID = 1;
public const NAME = 'mod';
public const URL = 'mod';

/**
* {@inheritDoc}
*/
protected function configure()
{
$this->allowed_branches = array('<=', 30);
$this->allowed_branches = ['<=', 30];

$this->mpv_test = true;
$this->automod_test = true;
$this->restore_root = true;
$this->clean_package = true;
$this->root_search = array(
'files' => array(
$this->root_search = [
'files' => [
'required' => 'install*.xml',
),
);
],
];

$this->forum_database = $this->ext_config->forum_mod_database;
$this->forum_robot = $this->ext_config->forum_mod_robot;

if ($this->ext_config->use_queue && $this->use_queue)
{
if ($this->mpv_test)
{
$this->upload_steps[] = array(
'name' => 'MPV_TEST',
'function' => array($this, 'mpv_test'),
);
}

if ($this->automod_test)
{
$this->upload_steps[] = array(
'name' => 'AUTOMOD_TEST',
'function' => array($this, 'automod_test'),
);
}
}

$this->author_count = 'author_mods';

// Language strings
$this->lang = array(
'lang' => $this->user->lang('MODIFICATION'),
'langs' => $this->user->lang('MODIFICATIONS'),
'new' => $this->user->lang('MOD_CONTRIB_NEW'),
'cleaned' => $this->user->lang('MOD_CONTRIB_CLEANED'),
'hidden' => $this->user->lang('MOD_CONTRIB_HIDDEN'),
'disabled' => $this->user->lang('MOD_CONTRIB_DISABLED'),
);
$this->lang = [
'lang' => $this->user->lang('MODIFICATION'),
'langs' => $this->user->lang('MODIFICATIONS'),
'new' => $this->user->lang('MOD_CONTRIB_NEW'),
'cleaned' => $this->user->lang('MOD_CONTRIB_CLEANED'),
'hidden' => $this->user->lang('MOD_CONTRIB_HIDDEN'),
'disabled' => $this->user->lang('MOD_CONTRIB_DISABLED'),
];
$this->validation_subject = 'MOD_VALIDATION';
$this->validation_message_approve = 'MOD_VALIDATION_MESSAGE_APPROVE';
$this->validation_message_deny = 'MOD_VALIDATION_MESSAGE_DENY';
@@ -133,156 +88,13 @@ public function acl_get($action)

// Can moderate mods
case 'moderate' :
return $this->auth->acl_gets(array(
return $this->auth->acl_gets([
'u_titania_mod_modification_moderate',
'u_titania_mod_contrib_mod',
));
]);
break;
}

return false;
}

/**
* Prevalidator test.
*
* @param \titania_contribution $contrib
* @param \titania_revision $revision
* @param attachment $attachment
* @param string $download_package
* @param package $package
* @param template $template
* @return array
*/
public function mpv_test(\titania_contribution $contrib, \titania_revision $revision, attachment $attachment, $download_package, package $package, template $template)
{
// Run MPV
$prevalidator = $this->get_prevalidator();
$mpv_results = $prevalidator->run_mpv($download_package);

if ($mpv_results === false)
{
return array(
'notice' => $prevalidator->get_errors(),
);
}
else
{
$uid = $bitfield = $flags = false;
generate_text_for_storage($mpv_results, $uid, $bitfield, $flags, true, true, true);

// Add the MPV Results to the queue
$queue = $revision->get_queue();
$queue->mpv_results = $mpv_results;
$queue->mpv_results_bitfield = $bitfield;
$queue->mpv_results_uid = $uid;
$queue->submit();

$mpv_results = generate_text_for_display($mpv_results, $uid, $bitfield, $flags);
$template->assign_var('PV_RESULTS', $mpv_results);

$template->assign_var('S_AUTOMOD_TEST', $this->automod_test);
}
}

/**
* AutoMOD Test.
*
* @param \titania_contribution $contrib
* @param \titania_revision $revision
* @param attachment $attachment
* @param string $download_package
* @param package $package
* @param template $template
* @return array
*/
public function automod_test(\titania_contribution $contrib, \titania_revision $revision, attachment $attachment, $download_package, package $package, template $template)
{
$package->ensure_extracted();
$prevalidator = $this->get_prevalidator();

// Automod testing time
$details = '';
$error = $html_results = $bbcode_results = array();

if (!$revision->phpbb_versions)
{
$revision->load_phpbb_versions();
}

foreach ($revision->phpbb_versions as $row)
{
$version_string = $row['phpbb_version_branch'][0] . '.' . $row['phpbb_version_branch'][1] . '.' .$row['phpbb_version_revision'];
$phpbb_path = $prevalidator->get_helper()->prepare_phpbb_test_directory($version_string);

if ($phpbb_path === false)
{
$error = array_merge($error, $prevalidator->get_helper()->get_errors());
continue;
}

$template->assign_vars(array(
'PHPBB_VERSION' => $version_string,
'TEST_ID' => $row['row_id'],
));

$html_result = $bbcode_result = '';
$installed = $prevalidator->run_automod_test(
$package,
$phpbb_path,
$details,
$html_result,
$bbcode_result
);

$html_results[] = $html_result;
$bbcode_results[] = $bbcode_result;
}

if (is_array($details))
{
$revision->install_time = $details['INSTALLATION_TIME'];

switch ($details['INSTALLATION_LEVEL'])
{
case 'easy' :
$revision->install_level = 1;
break;

case 'intermediate' :
$revision->install_level = 2;
break;

case 'advanced' :
$revision->install_level = 3;
break;
}

$revision->submit();
}

$html_results = implode('<br /><br />', $html_results);
$bbcode_results = implode("\n\n", $bbcode_results);

// Update the queue with the results
$queue = $revision->get_queue();
$queue->automod_results = $bbcode_results;
$queue->submit();

$template->assign_var('AUTOMOD_RESULTS', $html_results);

return array(
'error' => $error,
);
}

/**
* Get prevalidator
*
* @return prevalidator
*/
public function get_prevalidator()
{
return $this->prevalidator;
}
}
6 changes: 3 additions & 3 deletions contribution/official_tool/type.php
Original file line number Diff line number Diff line change
@@ -17,9 +17,9 @@

class type extends base
{
const ID = 4;
const NAME = 'official_tool';
const URL = 'official_tool';
public const ID = 4;
public const NAME = 'official_tool';
public const URL = 'official_tool';

/**
* @{inheritDoc}
6 changes: 3 additions & 3 deletions contribution/style/type.php
Original file line number Diff line number Diff line change
@@ -30,9 +30,9 @@ class type extends base
/** @var demo\manager */
protected $demo_manager;

const ID = 2;
const NAME = 'style';
const URL = 'style';
public const ID = 2;
public const NAME = 'style';
public const URL = 'style';

/**
* Constructor
8 changes: 4 additions & 4 deletions contribution/translation/type.php
Original file line number Diff line number Diff line change
@@ -26,11 +26,11 @@ class type extends base
/** @var prevalidator */
protected $prevalidator;

const ID = 6;
const NAME = 'translation';
const URL = 'translation';
public const ID = 6;
public const NAME = 'translation';
public const URL = 'translation';

const PHPBB_LATEST_VERSION = '3.2';
public const PHPBB_LATEST_VERSION = '3.2';

/**
* Constructor
10 changes: 4 additions & 6 deletions contribution/type/base.php
Original file line number Diff line number Diff line change
@@ -129,12 +129,10 @@ class base implements type_interface
public $extra_upload = true;

/**
* Run MPV/Automod Test for this type?
* Run prevalidator Test for this type?
*
* @var bool
*/
public $mpv_test = false;
public $automod_test = false;
public $epv_test = false;

/**
@@ -223,9 +221,9 @@ class base implements type_interface
*/
public $contribution_fields = array();

const ID = 0;
const NAME = 'contribution';
const URL = 'contribution';
public const ID = 0;
public const NAME = 'contribution';
public const URL = 'contribution';

/**
* Constructor
104 changes: 6 additions & 98 deletions controller/manage/queue/tools.php
Original file line number Diff line number Diff line change
@@ -86,7 +86,7 @@ public function __construct(\phpbb\user $user, \phpbb\template\template $templat
*/
public function run_tool($tool, $id)
{
if (!in_array($tool, array('automod', 'mpv', 'epv')))
if ($tool != 'epv')
{
return $this->helper->error('INVALID_TOOL', 404);
}
@@ -131,103 +131,11 @@ protected function epv()
redirect($post->get_url());
}

/**
* Run MOD PreValidator.
*
* @return \Symfony\Component\HttpFoundation\Response
*/
protected function mpv()
{
if (!$this->contrib->type->mpv_test)
{
return $this->helper->error('INVALID_TOOl');
}

// Run MPV
$prevalidator = $this->contrib->type->get_prevalidator();
$results = $prevalidator->run_mpv($this->attachment->get_url());
$errors = $prevalidator->get_errors();

if ($results === false)
{
return $this->helper->error('MPV_TEST_FAILED');
}
else
{
$results = $this->get_result_post('VALIDATION_PV', $results);
$post = $this->queue->topic_reply($results);
}

if (!empty($errors))
{
return $this->helper->error(implode('<br />', $errors));
}

redirect($post->get_url());
}

/**
* Run AutoMOD Tests.
*
* @return \Symfony\Component\HttpFoundation\Response
*/
protected function automod()
{
if (!$this->contrib->type->automod_test)
{
return $this->helper->error('INVALID_TOOl');
}
$this->package->ensure_extracted();

// Start up the machine
$prevalidator = $this->contrib->type->get_prevalidator();

// Automod testing time
$details = '';
$html_results = $bbcode_results = array();
$this->revision->load_phpbb_versions();

foreach ($this->revision->phpbb_versions as $row)
{
$version_string = $row['phpbb_version_branch'][0] . '.' . $row['phpbb_version_branch'][1] . '.' . $row['phpbb_version_revision'];
$phpbb_path = $prevalidator->get_helper()->prepare_phpbb_test_directory($version_string);

if ($phpbb_path === false)
{
continue;
}

$this->template->assign_vars(array(
'PHPBB_VERSION' => $version_string,
'TEST_ID' => $row['row_id'],
));

$html_result = $bbcode_result = '';
$prevalidator->run_automod_test(
$this->package,
$phpbb_path,
$details,
$html_result,
$bbcode_result
);

$bbcode_results[] = $bbcode_result;
}

$bbcode_results = $this->get_result_post('VALIDATION_AUTOMOD', implode("\n\n", $bbcode_results));

// Update the queue with the results
$post = $this->queue->topic_reply($bbcode_results);
$this->package->cleanup();

redirect($post->get_url());
}

/**
* Load objects needed to run a tool.
*
* @param int $id Revision id.
* @return null
* @return void
*/
protected function load_objects($id)
{
@@ -242,7 +150,7 @@ protected function load_objects($id)
* Load revision.
*
* @throws \Exception Throws exception if no revision found.
* @return null
* @return void
*/
protected function load_revision($id)
{
@@ -259,7 +167,7 @@ protected function load_revision($id)
* Load revision's parent contribution.
*
* @throws \Exception Throws exception if no contrib found.
* @return null
* @return void
*/
protected function load_contrib()
{
@@ -275,7 +183,7 @@ protected function load_contrib()
/**
* Load revision's corresponding queue item.
*
* @return null
* @return void
*/
protected function load_queue()
{
@@ -286,7 +194,7 @@ protected function load_queue()
* Load revision attachment.
*
* @throws \Exception Throws exception if no attachment found.
* @return null
* @return void
*/
protected function load_attachment()
{
2,955 changes: 0 additions & 2,955 deletions includes/library/automod/acp_mods.php

This file was deleted.

258 changes: 0 additions & 258 deletions includes/library/automod/automod.diff

This file was deleted.

1,442 changes: 0 additions & 1,442 deletions includes/library/automod/editor.php

This file was deleted.

580 changes: 0 additions & 580 deletions includes/library/automod/functions_mods.php

This file was deleted.

855 changes: 0 additions & 855 deletions includes/library/automod/mod_parser.php

This file was deleted.

8 changes: 1 addition & 7 deletions includes/objects/queue.php
Original file line number Diff line number Diff line change
@@ -212,12 +212,6 @@ public function update_first_queue_post($post_subject = false)
$post->post_text .= '[quote=&quot;' . phpbb::$user->lang['VALIDATION_TV'] . '&quot;][code]' . $this->tv_results . "[/code][/quote]\n";
}

// Add the Automod results
if ($this->automod_results)
{
$post->post_text .= '[quote=&quot;' . phpbb::$user->lang['VALIDATION_AUTOMOD'] . '&quot;]' . $this->automod_results . "[/quote]\n";
}

// Prevent errors from different configurations
phpbb::$config['min_post_chars'] = 1;
phpbb::$config['max_post_chars'] = 0;
@@ -688,7 +682,7 @@ public function get_url($action = false, $params = array(), $tag = false)
}
}

else
else
{
// Link back to the correct type if the tag is shown
$type_name = array_key_first($tag);
8 changes: 1 addition & 7 deletions includes/objects/revision.php
Original file line number Diff line number Diff line change
@@ -516,7 +516,7 @@ public function repack($old_revision, $old_queue)
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
// Reply to the queue topic to say that it's been repacked
$repack_message = phpbb::$user->lang['REVISION_REPACKED'] . "\n\n";

// Add the MPV results
@@ -526,12 +526,6 @@ public function repack($old_revision, $old_queue)
$repack_message .= '[quote=&quot;' . $this->user->lang['VALIDATION_PV'] . '&quot;]' . $queue->mpv_results . "[/quote]\n";
}

// Add the Automod results
if ($queue->automod_results)
{
$repack_message .= '[quote=&quot;' . phpbb::$user->lang['VALIDATION_AUTOMOD'] . '&quot;]' . $queue->automod_results . "[/quote]\n";
}

// Repack diff
titania::_include('tools/diff', false, 'titania_diff');

10 changes: 0 additions & 10 deletions includes/overlords/queue.php
Original file line number Diff line number Diff line change
@@ -286,21 +286,11 @@ public static function display_queue_item($queue_id)

// Misc actions
$misc_actions = array(
array(
'RETEST_PV',
$queue->get_tool_url('mpv', $row['revision_id'], $hash),
$contrib->type->mpv_test,
),
array(
'RETEST_PV',
$queue->get_tool_url('epv', $row['revision_id'], $hash),
$contrib->type->epv_test,
),
array(
'RETEST_AUTOMOD',
$queue->get_tool_url('automod', $row['revision_id'], $hash),
$contrib->type->automod_test,
),
);

// Some quick-actions
222 changes: 0 additions & 222 deletions language/en/automod.php

This file was deleted.

5 changes: 0 additions & 5 deletions language/en/contributions.php
Original file line number Diff line number Diff line change
@@ -44,8 +44,6 @@
'ATTENTION_CONTRIB_CATEGORIES_CHANGED' => 'Contribution categories changed',
'ATTENTION_CONTRIB_DESC_CHANGED' => 'Contribution description changed',
'ATTENTION_CONTRIB_NAME_CHANGED' => 'Contribution name changed',
'AUTOMOD_RESULTS' => '<strong>Please check over the AutoMod install results and make sure that nothing needs to be fixed.<br /><br />If an error comes up and you are certain that the error is incorrect, just hit continue below.</strong>',
'AUTOMOD_TEST' => 'The Mod will be tested against AutoMod and results will be shown (this may take a few moments, so please be patient).<br /><br />Please hit continue when you are ready.',

'BAD_VERSION_SELECTED' => '%s is not a proper phpBB version.',
'BRANCH_ALREADY_IN_QUEUE' => 'There is already a revision in the queue in the process of being validated for %s.',
@@ -145,9 +143,6 @@
'LOGIN_EXPLAIN_CONTRIB' => 'In order to create a new contribution you need to be registered',

'MANAGE_CONTRIBUTION' => 'Manage Contribution',
'MPV_TEST' => 'The Mod will be tested against MPV and results will be shown (this may take a few moments, so please be patient).<br /><br />Please hit continue when you are ready.',
'MPV_TEST_FAILED' => 'Sorry, the automatic MPV test failed and your MPV test results are not available. Please continue.',
'MPV_TEST_FAILED_QUEUE_MSG' => 'Automated MPV test failed. [url=%s]Click here to attempt running MPV automatically again[/url]',
'MUST_SELECT_ONE_VERSION' => 'You must select at least one phpBB version.',

'NEW_CONTRIBUTION' => 'New Contribution',
4 changes: 0 additions & 4 deletions language/en/manage.php
Original file line number Diff line number Diff line change
@@ -81,8 +81,6 @@
'NO_NOTES' => 'No Notes',
'NO_QUEUE_ITEM' => 'Queue item does not exist.',

'OLD_VALIDATION_AUTOMOD' => 'Automod Test from pre-repack',
'OLD_VALIDATION_MPV' => 'MPV Notes from pre-repack',
'OPEN_ITEMS' => 'Open Items',

'PLEASE_WAIT_FOR_TOOL' => 'Please wait for the tool to finish running.',
@@ -111,7 +109,6 @@
'REBUILD_FIRST_POST' => 'Rebuild first post',
'REPACK' => 'Repack',
'REPORTED' => 'Reported',
'RETEST_AUTOMOD' => 'Re-test Automod',
'RETEST_PV' => 'Re-test prevalidator',
'REVISION_REPACKED' => 'This revision has been repacked.',

@@ -123,7 +120,6 @@
'UNKNOWN' => 'Unknown',

'VALIDATION' => 'Validation',
'VALIDATION_AUTOMOD' => 'Automod Test',
'VALIDATION_MESSAGE' => 'Validation Message/Reason',
'VALIDATION_NOTES' => 'Validation Notes',
'VALIDATION_PV' => 'Prevalidator Notes',
3 changes: 0 additions & 3 deletions language/en/types/mod.php
Original file line number Diff line number Diff line change
@@ -41,7 +41,6 @@
//

$lang = array_merge($lang, array(
'AUTOMOD_TEST' => 'AutoMOD Test',
'MODIFICATION' => 'Modification',
'MODIFICATIONS' => 'Modifications',
'MOD_CONTRIB_CLEANED' => 'Cleaned',
@@ -129,6 +128,4 @@
Thank you,
phpBB Extension Customisations Team',

'MPV_TEST' => 'MOD Prevalidator Test',
));
62 changes: 0 additions & 62 deletions styles/prosilver/template/contributions/automod.html

This file was deleted.

46 changes: 0 additions & 46 deletions styles/prosilver/template/contributions/automod_bbcode.html

This file was deleted.

13 changes: 0 additions & 13 deletions styles/prosilver/template/contributions/contribution_revision.html
Original file line number Diff line number Diff line change
@@ -132,25 +132,12 @@ <h3>{{ lang('AGREEMENT') }}</h3>
{{ STEP_MESSAGE }}
</div>
{% endif %}
{% if MPV_TEST_WARNING %}
<br /><br />{{ lang('MPV_TEST') }}
{% endif %}
{% if PV_RESULTS %}
<p class="error">{{ lang('PV_RESULTS') }}</p>
<hr class="dashed" />
<div style="font-size:12px;">
{{ PV_RESULTS }}
</div>
{% if S_AUTOMOD_TEST %}
<br /><br />
<hr class="dashed" />
<strong>{{ lang('AUTOMOD_TEST') }}</strong>
{% endif %}
{% endif %}
{% if AUTOMOD_RESULTS %}
<p class="error">{{ lang('AUTOMOD_RESULTS') }}</p>
<hr class="dashed" />
{{ AUTOMOD_RESULTS }}
{% endif %}
{% if S_PASSED_TRANSLATION_VALIDATION %}
<div class="translation-validation">