Fix error when setting a plugin to a region

- Fix set plugin to menu_administration region.
- see BT#13461
pull/2487/head
jmontoyaa 8 years ago
parent 2b698c6842
commit a26eeb6cb4
  1. 6
      main/admin/index.php
  2. 2
      main/inc/lib/api.lib.php
  3. 6
      main/inc/lib/plugin.class.php
  4. 1
      main/inc/lib/plugin.lib.php
  5. 8
      plugin/redirection/RedirectionPlugin.php
  6. 5
      plugin/redirection/admin.php
  7. 56
      plugin/redirection/index.php

@ -502,12 +502,12 @@ if (api_is_platform_admin()) {
$items = array();
foreach ($menuAdministratorItems as $pluginName) {
$pluginInfo = $plugin_obj->getPluginInfo($pluginName);
$pluginInfo = $plugin_obj->getPluginInfo($pluginName, true);
/** @var \Plugin $plugin */
$plugin = $pluginInfo['obj'];
$pluginUrl = $plugin->getAdminUrl();
if (!$pluginUrl) {
if (empty($pluginUrl)) {
continue;
}
@ -518,7 +518,7 @@ if (api_is_platform_admin()) {
}
$blocks['plugins']['items'] = $items;
$blocks['plugins']['extra'] = null;
$blocks['plugins']['extra'] = '';
}
}

@ -3371,7 +3371,7 @@ function api_not_allowed(
$show_headers = 1;
}
$tpl = new Template(null, $show_headers, $show_headers);
$tpl = new Template(null, $show_headers, $show_headers, false, true, false);
$tpl->assign('hide_login_link', 1);
$tpl->assign('content', $msg);

@ -897,12 +897,12 @@ class Plugin
/**
* Get the admin URL for the plugin if Plugin::isAdminPlugin is true
* @return null|string
* @return string
*/
public function getAdminUrl()
{
if (!$this->isAdminPlugin) {
return null;
return '';
}
$name = $this->get_name();
@ -917,6 +917,6 @@ class Plugin
return "$webPath/start.php";
}
return null;
return '';
}
}

@ -411,7 +411,6 @@ class AppPlugin
public function getPluginInfo($plugin_name, $forced = false)
{
$pluginData = Session::read('plugin_data');
if (isset($pluginData[$plugin_name]) && $forced == false) {
return $pluginData[$plugin_name];
} else {

@ -8,6 +8,8 @@
*/
class RedirectionPlugin extends Plugin
{
public $isAdminPlugin = true;
/**
* Class constructor
*/
@ -15,11 +17,13 @@ class RedirectionPlugin extends Plugin
{
$version = '1.0';
$author = 'Enrique Alcaraz, Julio Montoya';
parent::__construct($version, $author, ['enabled' => 'boolean']);
$this->isAdminPlugin = true;
}
/**
* @return RedirectionPlugin
*/
public static function create()
{
static $result = null;

@ -0,0 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
header('Location: index.php');
exit;

@ -29,45 +29,51 @@ if (isset($_REQUEST['id'])) {
exit;
}
Display::display_header();
?>
$content = '
<form action="./index.php" method="post">
<div class="table-responsive well">
<table class="table table-condensed">
<thead>
<td><input type="text" class="form-control" placeholder="User Id" name="user_id"/></td>
<td><input type="text" class="form-control" placeholder="URL" name="url"/></td>
<td><input type='submit' value='Add' name="submit_button" class='btn btn-primary'/></td>
<td><input type=\'submit\' value=\'Add\' name="submit_button" class=\'btn btn-primary\'/></td>
</thead>
</table>
</div>
</form>
<div class="table-responsive">
<table class="table table-bordered table-condensed">
<tr>
<th>User</th>
<th>URL</th>
<th></th>
</tr>
<?php
foreach ($list as $item) {
$userInfo = api_get_user_info($item['user_id']);
$userName = get_lang('Unknown');
if (!empty($userInfo)) {
$userName = $userInfo['complete_name_with_username'].' - '.$item['user_id'];
}
echo '<tr>';
echo '<td>'.$userName.'</td>';
echo '<td>'.$item['url'].'</td>';
echo '<td><a class="btn btn-danger" href="index.php?id='.$item['id'].'">Delete</a></td>';
echo '</tr>';
}
?>
</table>
</div>
<?php
</tr>
';
foreach ($list as $item) {
$userInfo = api_get_user_info($item['user_id']);
$userName = get_lang('Unknown');
if (!empty($userInfo)) {
$userName = $userInfo['complete_name_with_username'].' - '.$item['user_id'];
}
$content.= '<tr>';
$content.= '<td>'.$userName.'</td>';
$content.= '<td>'.$item['url'].'</td>';
$content.= '<td><a class="btn btn-danger" href="index.php?id='.$item['id'].'">Delete</a></td>';
$content.= '</tr>';
}
$content.= '
</table>
</div>';
Display::display_footer();
$tpl = new Template(
'',
true,
true,
false,
false,
false
);
$tpl->assign('content', $content);
$tpl->display_one_col_template();

Loading…
Cancel
Save