bug fix: install plugins

This commit is contained in:
Diego Najar 2018-08-09 23:15:52 +02:00
parent 5deb5020b7
commit 39d409ccc7
4 changed files with 29 additions and 9 deletions

View File

@ -59,7 +59,7 @@ class Plugin {
$this->metadata = json_decode($metadataString, true);
// If the plugin is installed then get the database
if($this->installed()) {
if ($this->installed()) {
$Tmp = new dbJSON($this->filenameDb);
$this->db = $Tmp->db;
}
@ -124,11 +124,10 @@ class Plugin {
// (boolean) $html, TRUE returns the value sanitized, FALSE unsanitized
public function getValue($field, $html=true)
{
if( isset($this->db[$field]) ) {
if($html) {
if (isset($this->db[$field])) {
if ($html) {
return $this->db[$field];
}
else {
} else {
return Sanitize::htmlDecode($this->db[$field]);
}
}
@ -220,9 +219,15 @@ class Plugin {
// Create database
$this->dbFields['position'] = $position;
$this->db = $this->dbFields;
return true;
// Sanitize default values to store in the file
foreach ($this->dbFields as $key=>$value) {
$value = Sanitize::html($value);
settype($value, gettype($this->dbFields[$key]));
$this->db[$key] = $value;
}
return $this->save();
}
public function uninstall()

View File

@ -22,7 +22,9 @@ checkRole(array('admin'));
// Main after POST
// ============================================================================
$pluginClassName = $layout['parameters'];
activatePlugin($pluginClassName);
if (activatePlugin($pluginClassName)===false) {
Log::set('Fail when try to activate the plugin.', LOG_TYPE_ERROR);
}
if (isset($plugins['all'][$pluginClassName])) {
$plugin = $plugins['all'][$pluginClassName];

View File

@ -23,6 +23,11 @@ class pluginAPI extends Plugin {
$html .= $this->description();
$html .= '</div>';
$html .= '<div>';
$html .= '<label>'.$L->get('URL').'</label>';
$html .= '<p class="text-muted">'.DOMAIN.'/api/{endpoint}</p>';
$html .= '</div>';
$html .= '<div>';
$html .= '<label>'.$L->get('API Token').'</label>';
$html .= '<input name="token" type="text" value="'.$this->getValue('token').'">';

View File

@ -33,3 +33,11 @@ Things to do:
- pagex.class.php
-- improve tags methods, compare with category
----
curl -vvv \
-X GET \
-G "http://localhost:8000/api/pages" \
-d "token=80a09ba055b73f68e3c9e7c9ea12b432"