Przykładowy plugin:
<?php
/*
* LMS version 1.11-git
*
* Copyright (C) 2001-2013 LMS Developers
*
* Please, see the doc/AUTHORS for more information about authors!
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License Version 2 as
* published by the Free Software Foundation.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id$
*/
/**
* PluginExample
*
* @author Maciej Lew <
maciej.lew.1987@gmail.com>
*/
class RedirectorsPlugin extends LMSPlugin
{
public $LMS;
public function __construct(&$LMS)
{
$this->LMS = &$LMS;
$this->registerHandlers();
}
//first things first
public function registerHandlers()
{
$this->handlers = array(
'menu_initialized' => array(
'class' => 'PluginMenuHandler',
'method' => 'drawMenu'
),
'modules_dir_initialized' => array(
'class' => 'PluginDirHandler',
'method' => 'addModulesDir'
),
'smarty_initialized' => array(
'class' => 'PluginDirHandler',
'method' => 'addTemplatesDir'
),
'lms_initialized' => array(
'class' => 'PluginMethodsHandler',
'method' => 'addPluginMethods'
),
);
}
//define plugin methods here
public function DeleteRedirector($id)
{
return $this->LMS->DB->Execute('DELETE FROM _redirectors WHERE id=?', array($id));
}
public function GetRedirectorList() {
$retval = array();
$idx = 0;
$redirector_list = $this->LMS->DB->GetAll('SELECT
r.id id, r.enabled redirector_enabled, name, duration, period, message, (SELECT COUNT(
n.id) FROM _redirectorassignments ra, nodes n WHERE
n.id = ra.node_id AND ra.redirector_id =
r.id AND n.warning=1 ) enabled, target_url, (SELECT COUNT(id) FROM _redirectorassignments ra WHERE ra.redirector_id =
r.id) `set` FROM _redirectors r');
if (!$redirector_list) {
return false;
}
foreach ($redirector_list as $redirector) {
$redirector['active'] = count($this->GetRedirectorAffectedCustomers($redirector['id']));
$retval[$idx++] = $redirector;
}
return $retval;
}
public function GetRedirector($id) {
return $this->LMS->DB->GetRow('SELECT id, name, duration, period, block_traffic, interactive, enabled, append_customer_message, message, target_url, trigger_min, trigger_max, last_payment_min, last_payment_max, last_liability_min, last_liability_max, skip_addresslist FROM _redirectors WHERE id = ?', array($id));
}
(...)
}
Pozdrawiam.