Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Based on @cproensa's suggestion, see #1565 (comment) Invalid Plugin classes changes: - Define a new InvalidDefinitionPlugin class for the case of missing required properties (name and version) - InvalidPlugin becomes a generic, base class for invalid plugins - Initialize with InvalidPlugin::setInvalidPlugin() method MantisPlugin base class changes: - New properties $status (with related STATUS_xxx constants) and $status_message to MantisPlugin class - Method isValid() returns a loaded plugin's actual validity status - Method getInvalidPlugin() creates an InvalidPlugin object from the current plugin and initializes it with setInvalidPlugin(). Plugin API, management and admin checks page have been modified to leverage the new class, properties and methods.
- Loading branch information
Showing
10 changed files
with
192 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
# MantisBT - A PHP based bugtracking system | ||
|
||
# MantisBT is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 2 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# MantisBT is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with MantisBT. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* MantisBT Invalid Incomplete Definition Plugin | ||
* @copyright Copyright 2020 MantisBT Team - mantisbt-dev@lists.sourceforge.net | ||
* @link http://www.mantisbt.org | ||
* @package MantisBT | ||
* @subpackage classes | ||
*/ | ||
|
||
/** | ||
* MantisBT Invalid Definition Plugin class | ||
* | ||
* The purpose of this class is to handle incomplete plugin definitions, i.e. | ||
* having undefined 'name' or 'version' properties. | ||
* | ||
* For Plugin API internal use only. | ||
*/ | ||
class InvalidDefinitionPlugin extends InvalidPlugin { | ||
|
||
function register() { | ||
$this->name = $this->basename; | ||
$this->description = lang_get( 'plugin_invalid_description' ); | ||
|
||
$this->status = self::STATUS_INCOMPLETE_DEFINITION; | ||
} | ||
|
||
public function setInvalidPlugin( MantisPlugin $p_plugin ) { | ||
parent::setInvalidPlugin( $p_plugin ); | ||
|
||
$t_missing = array(); | ||
|
||
# Add the reference plugin's name, if defined | ||
if( $p_plugin->name ) { | ||
$this->name .= " ($p_plugin->name)"; | ||
} else { | ||
$t_missing[] = 'name'; | ||
} | ||
|
||
if( !$p_plugin->version ) { | ||
$t_missing[] = 'version'; | ||
} | ||
|
||
if( !empty( $t_missing ) ) { | ||
$this->status_message = sprintf( | ||
lang_get( 'plugin_invalid_description_details' ), | ||
implode( ', ', $t_missing ) | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters