Skip to content

Commit

Permalink
MDL-38509 Implement the plugin ZIP package validator
Browse files Browse the repository at this point in the history
The validator code contains (modified) fragments of the
local_plugins_archive_validator class copyrighted by Marina Glancy that
is part of the local_plugins plugin. It operates over an extracted
copy of the ZIP file.
  • Loading branch information
mudrd8mz committed Mar 28, 2013
1 parent ddab904 commit a4fcf56
Show file tree
Hide file tree
Showing 26 changed files with 1,015 additions and 0 deletions.
575 changes: 575 additions & 0 deletions admin/tool/installaddon/classes/validator.php

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Plugin must have more than one file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php

$plugin->component = 'repository_mahara';
$plugin->version = 2014010100;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

echo 'One, my little hobbit, never installs malicisous add-ons';
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

$string['pluginname'] = 'Foo bar!';
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php

$plugin->version = 2013031900;
$plugin->component = 'local_greenbar';
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

$plugin->component = 'local_one';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Only one dir is allowed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

$string['pluginnname'] = 'Root directory mismatch';
3 changes: 3 additions & 0 deletions admin/tool/installaddon/tests/fixtures/nolang/bah/lib.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php


4 changes: 4 additions & 0 deletions admin/tool/installaddon/tests/fixtures/nolang/bah/version.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php

$module->version = 2014122455;
$plugin->version = 2014122455;
3 changes: 3 additions & 0 deletions admin/tool/installaddon/tests/fixtures/nolang/bah/view.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

echo 'Do not use hardcoded strings, provide the language pack';
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

$string['pluginversion'] = 'Activity module with no version.php';
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

$string['pluginversion'] = 'A theme with no version.php';
3 changes: 3 additions & 0 deletions admin/tool/installaddon/tests/fixtures/nowrapdir/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

// index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

$string['pluginname'] = 'Foo!';
3 changes: 3 additions & 0 deletions admin/tool/installaddon/tests/fixtures/nowrapdir/version.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php // $Id$

// I don't miss CVS, do you?
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

echo 'One, my little hobbit, never installs malicisous add-ons';
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

$string['pluginname'] = 'Foo bar!';
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

$module->version = 10; // Ignored, this should use $plugin
$plugin->version = 2013031900;
$plugin->component = 'local_foobar';
$plugin->requires = 2013031200;
$module->release = 'We are not an activity module!';
$plugin->maturity = MATURITY_ALPHA;
//$plugin->release = 'And this is commented';
52 changes: 52 additions & 0 deletions admin/tool/installaddon/tests/fixtures/versionphp/version1.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<h1>Example version.php file</h1>

<p>version.php is required for all plugins but themes.</p>

<h2>Example of values</h2>

<pre>
$plugin->version = 2011051000;
$plugin->requires = 2010112400;
$plugin->cron = 0;
$plugin->component = 'plugintype_pluginname';
$plugin->maturity = MATURITY_STABLE;
$plugin->release = '2.x (Build: 2011051000)';
$plugin->dependencies = array('mod_forum' => ANY_VERSION, 'mod_data' => 2010020300);
</pre>

Replace $plugin with $module for activity modules, as in

<pre>
$module->version = 2012122400;
</pre><?php // $Id$ $module->version = 1;

$plugin->component
= 'old_foobar';//$plugin->component='commented';

$plugin->component =
'block_foobar';

$plugin->version = 2013010100;
////////$plugin->version = 0;
/* for activity
modules use:
$module->version = 2014131300;
***/
$plugin->version = "2010091855"; // Do not use quotes here.
$plugin->version = '2010091856.9'; // Do not use quotes here.


$plugin->requires = /* 2012010100 */ 2012122401 ;

$module->maturity = MATURITY_STABLE;
$module->maturity = 50; // If both present, the constant wins (on contrary to what PHP would do)
$module->maturity = 'MATURITY_BETA'; // Do not use quotes here.

$plugin->maturity = 10;
$plugin->maturity = MATURITY_ALPHA;



$module->release = 2.3; $plugin->release = 'v2.4';
$module->release = "v2.3"; $plugin->release = 2.4;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Existing
Loading

0 comments on commit a4fcf56

Please sign in to comment.