parent
0a966986b9
commit
877a5f35d4
@ -0,0 +1,10 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* Config the plugin |
||||
* @author Enrique Alcaraz Lopez |
||||
* @package chamilo.plugin.redirection |
||||
*/ |
||||
|
||||
require_once __DIR__.'/../../main/inc/global.inc.php'; |
||||
require_once __DIR__.'/lib/redirection.class.php'; |
||||
@ -0,0 +1,55 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* Config the plugin |
||||
* @author Enrique Alcaraz Lopez |
||||
* @package chamilo.plugin.redirection |
||||
*/ |
||||
|
||||
require_once __DIR__.'/config.php'; |
||||
$redirecciones = Redirection::get(); |
||||
|
||||
if (isset($_REQUEST["id"])) { |
||||
Redirection::delete($_REQUEST["id"]); |
||||
header ("Location: index.php"); |
||||
} |
||||
else if (isset($_POST["submit_button"])) { |
||||
Redirection::insert($_POST["user_id"], $_POST["url"]); |
||||
header ("Location: index.php"); |
||||
} |
||||
|
||||
|
||||
?> |
||||
|
||||
<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='Agregar' 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>Usuario</th> |
||||
<th>Url</th> |
||||
<th></th> |
||||
</tr> |
||||
<?php |
||||
foreach ($redirecciones as $redi) { |
||||
echo '<tr>'; |
||||
echo '<td>' . $redi["user_id"] . '</td>'; |
||||
echo '<td>' . $redi["url"] . '</td>'; |
||||
echo '<td><a href="index.php?id=' . $redi["id"] . '">Borrar</a></td>'; |
||||
echo '</tr>'; |
||||
} |
||||
?> |
||||
</table> |
||||
</div> |
||||
@ -0,0 +1,18 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* Config the plugin |
||||
* @author Enrique Alcaraz Lopez |
||||
* @package chamilo.plugin.redirection |
||||
*/ |
||||
|
||||
$table = Database::get_main_table('plugin_redirection'); |
||||
|
||||
$sql = "CREATE TABLE IF NOT EXISTS $table ( |
||||
id INT unsigned NOT NULL auto_increment PRIMARY KEY, |
||||
user_id INT unsigned NOT NULL DEFAULT 0, |
||||
url VARCHAR(255) NOT NULL DEFAULT '' |
||||
)"; |
||||
|
||||
Database::query($sql); |
||||
|
||||
@ -0,0 +1,8 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* Config the plugin |
||||
* @author Enrique Alcaraz Lopez |
||||
* @package chamilo.plugin.redirection |
||||
*/ |
||||
|
||||
@ -0,0 +1,3 @@ |
||||
<?php |
||||
|
||||
|
||||
@ -0,0 +1,8 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* Config the plugin |
||||
* @author Enrique Alcaraz Lopez |
||||
* @package chamilo.plugin.redirection |
||||
*/ |
||||
|
||||
@ -0,0 +1,8 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* Config the plugin |
||||
* @author Enrique Alcaraz Lopez |
||||
* @package chamilo.plugin.redirection |
||||
*/ |
||||
|
||||
@ -0,0 +1,33 @@ |
||||
<?php |
||||
|
||||
class Redireccion |
||||
{ |
||||
# Insertamos la redirección |
||||
public static function insert($user_id, $url) |
||||
{ |
||||
return Database::insert( |
||||
'plugin_redirection', |
||||
[ |
||||
'user_id' => $user_id, |
||||
'url' => $url |
||||
] |
||||
); |
||||
} |
||||
|
||||
# Borramos al redirección |
||||
public static function delete($id) |
||||
{ |
||||
Database::delete( |
||||
$this->table, |
||||
array('id = ?' => array($id)) |
||||
); |
||||
} |
||||
|
||||
# Devolemos las redirecciones |
||||
public static function get() |
||||
{ |
||||
$table = Database::get_main_table('plugin_redirection'); |
||||
return Database::select('*', $table); |
||||
} |
||||
} |
||||
|
||||
@ -0,0 +1,40 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* Config the plugin |
||||
* @author Enrique Alcaraz Lopez |
||||
* @package chamilo.plugin.redirection |
||||
*/ |
||||
|
||||
class Redirection |
||||
{ |
||||
# Insertamos la redirección |
||||
public static function insert($user_id, $url) |
||||
{ |
||||
return Database::insert( |
||||
'plugin_redirection', |
||||
[ |
||||
'user_id' => $user_id, |
||||
'url' => $url |
||||
] |
||||
); |
||||
} |
||||
|
||||
# Borramos al redirección |
||||
public static function delete($id) |
||||
{ |
||||
$table = Database::get_main_table('plugin_redirection'); |
||||
Database::delete( |
||||
$table, |
||||
array('id = ?' => array($id)) |
||||
); |
||||
} |
||||
|
||||
# Devolemos las redirecciones |
||||
public static function get() |
||||
{ |
||||
$table = Database::get_main_table('plugin_redirection'); |
||||
return Database::select('*', $table); |
||||
} |
||||
} |
||||
|
||||
@ -0,0 +1,6 @@ |
||||
copy.src.files=false |
||||
copy.src.on.open=false |
||||
copy.src.target= |
||||
index.file=index.php |
||||
run.as=LOCAL |
||||
url=http://localhost/redirection/ |
||||
@ -0,0 +1,15 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project-private xmlns="http://www.netbeans.org/ns/project-private/1"> |
||||
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/> |
||||
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2"> |
||||
<group> |
||||
<file>file:/C:/wamp64/www/redirection/readme.txt</file> |
||||
<file>file:/C:/wamp64/www/redirection/lib/redireccion.class.php</file> |
||||
<file>file:/C:/wamp64/www/redirection/install.php</file> |
||||
<file>file:/C:/wamp64/www/redirection/index.php</file> |
||||
<file>file:/C:/wamp64/www/redirection/uninstall.php</file> |
||||
<file>file:/C:/wamp64/www/redirection/lang/es.php</file> |
||||
<file>file:/C:/wamp64/www/redirection/plugin.php</file> |
||||
</group> |
||||
</open-files> |
||||
</project-private> |
||||
@ -0,0 +1,7 @@ |
||||
include.path=${php.global.include.path} |
||||
php.version=PHP_70 |
||||
source.encoding=UTF-8 |
||||
src.dir=. |
||||
tags.asp=false |
||||
tags.short=false |
||||
web.root=. |
||||
@ -0,0 +1,9 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project xmlns="http://www.netbeans.org/ns/project/1"> |
||||
<type>org.netbeans.modules.php.project</type> |
||||
<configuration> |
||||
<data xmlns="http://www.netbeans.org/ns/php-project/1"> |
||||
<name>redirection</name> |
||||
</data> |
||||
</configuration> |
||||
</project> |
||||
@ -0,0 +1,25 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* Config the plugin |
||||
* @author Enrique Alcaraz Lopez |
||||
* @package chamilo.plugin.redirection |
||||
*/ |
||||
require_once __DIR__.'/lib/redireccion.class.php'; |
||||
|
||||
/* Plugin config */ |
||||
//the plugin title |
||||
$plugin_info['title'] = 'Redireccion personalizada'; |
||||
//the comments that go with the plugin |
||||
$plugin_info['comment'] = "Redirecciona a una url personalizada a un usuario en concreto"; |
||||
//the plugin version |
||||
$plugin_info['version'] = '1'; |
||||
//the plugin author |
||||
$plugin_info['author'] = 'Enrique Alcaraz'; |
||||
|
||||
$form = new FormValidator('redirection_form'); |
||||
$form->addElement('text', 'user_id', get_lang('user_id')); |
||||
$form->addElement('text', 'url', get_lang('url')); |
||||
$form->addButtonSave(get_lang('Save'), 'submit_button'); |
||||
|
||||
$plugin_info['settings_form'] = $form; |
||||
@ -0,0 +1,2 @@ |
||||
# chamilo-plugin-redirection |
||||
Plugin chamilo para la redirección de usuarios. |
||||
@ -0,0 +1,8 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* Config the plugin |
||||
* @author Enrique Alcaraz Lopez |
||||
* @package chamilo.plugin.redirection |
||||
*/ |
||||
|
||||
Loading…
Reference in new issue