Cleanup
This commit is contained in:
parent
2e1d048030
commit
b231ee1cbb
@ -1,37 +0,0 @@
|
||||
<?php
|
||||
/* $Id$ */
|
||||
class HelloWorld_conf {
|
||||
function get_filename() {
|
||||
$files = array(
|
||||
'extensions_additional.conf'
|
||||
);
|
||||
return $files;
|
||||
}//get_filename()
|
||||
//This function is called for every file defined in 'get_filename()' function above
|
||||
function generateConf($file) {
|
||||
global $version,$amp_conf,$astman;
|
||||
foreach ($this->get_filename() as $f){
|
||||
if(!file_exists($amp_conf['ASTETCDIR'] . "/$f")) {
|
||||
touch($amp_conf['ASTETCDIR'] . "/$f");
|
||||
}//if
|
||||
}//foreach
|
||||
switch($file) {
|
||||
case extensions_additional.conf:
|
||||
return $this->generate_extensions_conf($version);
|
||||
break;
|
||||
}//switch
|
||||
}//generateConf
|
||||
function generate_extensions_conf($ast_version) {
|
||||
global $ext
|
||||
//create a dialplan
|
||||
//www.freepbx.org/trac/wiki/ApiExtensions
|
||||
$id = 'app-HelloWorld';
|
||||
$dial = '*42';
|
||||
$ext->add($id, $dial, '', new ext_answer(''));
|
||||
$ext->add($id, $dial, '', new ext_playback('hello-world'));
|
||||
$ext->add($id, $dial, '', new ext_macro('hangupcall'));
|
||||
return $ext->generateConf();
|
||||
}//generate_extensions_conf()
|
||||
}//class HelloWorld
|
||||
|
||||
?>
|
@ -1,47 +0,0 @@
|
||||
Copyright (c) 2012/2013, James Finstrom
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
------------------------------------------------------------------------------
|
||||
Now that that's is out of the way....
|
||||
|
||||
Hello world, FreePBX module edition.
|
||||
|
||||
THE GOAL
|
||||
---------
|
||||
Create a skeliton people (mainly me but probably you) can build off of.
|
||||
This will be losely documented and should serve as an example.
|
||||
This is setup for those who learn by example code.
|
||||
|
||||
SPAM
|
||||
--------
|
||||
Please note that my contributions and what I do is made possible because
|
||||
of my awesome employer. Please consider buying stuff from them to keep me
|
||||
employed. I like paying my bills they make that possible too. If anything
|
||||
I do helps you please consider buying a Rhino Card or server to show my
|
||||
time diung this stuff makes the company money.
|
||||
|
||||
TODO:
|
||||
-------
|
||||
page
|
||||
function
|
||||
module xml <-- Done
|
||||
|
@ -1,37 +0,0 @@
|
||||
<?php
|
||||
/* $Id$ */
|
||||
class HelloWorld_conf {
|
||||
function get_filename() {
|
||||
$files = array(
|
||||
'extensions_additional.conf'
|
||||
);
|
||||
return $files;
|
||||
}//get_filename()
|
||||
//This function is called for every file defined in 'get_filename()' function above
|
||||
function generateConf($file) {
|
||||
global $version,$amp_conf,$astman;
|
||||
foreach ($this->get_filename() as $f){
|
||||
if(!file_exists($amp_conf['ASTETCDIR'] . "/$f")) {
|
||||
touch($amp_conf['ASTETCDIR'] . "/$f");
|
||||
}//if
|
||||
}//foreach
|
||||
switch($file) {
|
||||
case extensions_additional.conf:
|
||||
return $this->generate_extensions_conf($version);
|
||||
break;
|
||||
}//switch
|
||||
}//generateConf
|
||||
function generate_extensions_conf($ast_version) {
|
||||
global $ext
|
||||
//create a dialplan
|
||||
//www.freepbx.org/trac/wiki/ApiExtensions
|
||||
$id = 'app-HelloWorld';
|
||||
$dial = '*42';
|
||||
$ext->add($id, $dial, '', new ext_answer(''));
|
||||
$ext->add($id, $dial, '', new ext_playback('hello-world'));
|
||||
$ext->add($id, $dial, '', new ext_macro('hangupcall'));
|
||||
return $ext->generateConf();
|
||||
}//generate_extensions_conf()
|
||||
}//class HelloWorld
|
||||
|
||||
?>
|
@ -1,29 +0,0 @@
|
||||
<?php
|
||||
/* $Id$ */
|
||||
global $db;
|
||||
global $amp_conf;
|
||||
|
||||
if (! function_exists("out")) {
|
||||
function out($text) {
|
||||
echo $text."<br />";
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists("outn")) {
|
||||
function outn($text) {
|
||||
echo $text;
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "CREATE TABLE IF NOT EXISTS HelloWorld_settings (
|
||||
hwid varchar(32) NOT NULL default '',
|
||||
hwset varchar(32) NOT NULL default '',
|
||||
PRIMARY KEY (hwid)
|
||||
);";
|
||||
|
||||
$check = $db->query($sql);
|
||||
if (DB::IsError($check)) {
|
||||
die_freepbx( "Can not create `HelloWorld` table: " . $check->getMessage() . "\n");
|
||||
}
|
||||
|
||||
?>
|
@ -1,26 +0,0 @@
|
||||
<module>
|
||||
<rawname>HelloWorld</rawname>
|
||||
<name>Hello World</name>
|
||||
<version>0.1.0.0</version>
|
||||
<candisable>yes</candisable>
|
||||
<canuninstall>yes</canuninstall>
|
||||
<changelog>
|
||||
*0.1.0.0* Original Release (beta)
|
||||
</changelog>
|
||||
<description>
|
||||
provides a hello world example
|
||||
</description>
|
||||
<info>http://github.com/jfinstrom/</info>
|
||||
<menuitems>
|
||||
<HelloWorld>Hello World</HelloWorld>
|
||||
</menuitems>
|
||||
<depends>
|
||||
<module>core</module>
|
||||
<version>ge2.2</version>
|
||||
</depends>
|
||||
<type>setup</type>
|
||||
<category>Basic</category>
|
||||
<location>x</location>
|
||||
<md5sum>x</md5sum>
|
||||
</module>
|
||||
|
@ -1,25 +0,0 @@
|
||||
<?
|
||||
//Check if user is "logged in"
|
||||
if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); }
|
||||
//Handling form stuff....
|
||||
isset($_REQUEST['action'])?$action = $_REQUEST['action']:$action='';
|
||||
//the item we are currently displaying
|
||||
isset($_REQUEST['itemid'])?$itemid=$db->escapeSimple($_REQUEST['itemid']):$itemid='';
|
||||
|
||||
switch ($action) {
|
||||
case "add":
|
||||
needreload();
|
||||
break;
|
||||
case "delete":
|
||||
needreload();
|
||||
redirect_standard();
|
||||
break;
|
||||
case "edit":
|
||||
needreload();
|
||||
redirect_standard();
|
||||
break;
|
||||
echo "<h2>"._("Hello World")."</h2>";
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -1,20 +0,0 @@
|
||||
<?
|
||||
global $db;
|
||||
|
||||
if (! function_exists("out")) {
|
||||
function out($text) {
|
||||
echo $text."<br />";
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists("outn")) {
|
||||
function outn($text) {
|
||||
echo $text;
|
||||
}
|
||||
}
|
||||
//Johnny Drop Tables
|
||||
out("Dropping all relevant tables");
|
||||
$sql = "DROP TABLE `HelloWorld_settings`";
|
||||
$result = $db->query($sql);
|
||||
|
||||
?>
|
@ -1,37 +1,54 @@
|
||||
<?php
|
||||
/* $Id$ */
|
||||
class HelloWorld_conf {
|
||||
function get_filename() {
|
||||
$files = array(
|
||||
'extensions_additional.conf'
|
||||
);
|
||||
return $files;
|
||||
}//get_filename()
|
||||
//This function is called for every file defined in 'get_filename()' function above
|
||||
function generateConf($file) {
|
||||
global $version,$amp_conf,$astman;
|
||||
foreach ($this->get_filename() as $f){
|
||||
if(!file_exists($amp_conf['ASTETCDIR'] . "/$f")) {
|
||||
touch($amp_conf['ASTETCDIR'] . "/$f");
|
||||
}//if
|
||||
}//foreach
|
||||
switch($file) {
|
||||
case extensions_additional.conf:
|
||||
return $this->generate_extensions_conf($version);
|
||||
break;
|
||||
}//switch
|
||||
}//generateConf
|
||||
function generate_extensions_conf($ast_version) {
|
||||
global $ext
|
||||
//create a dialplan
|
||||
//www.freepbx.org/trac/wiki/ApiExtensions
|
||||
$id = 'app-HelloWorld';
|
||||
$dial = '*42';
|
||||
$ext->add($id, $dial, '', new ext_answer(''));
|
||||
$ext->add($id, $dial, '', new ext_playback('hello-world'));
|
||||
$ext->add($id, $dial, '', new ext_macro('hangupcall'));
|
||||
return $ext->generateConf();
|
||||
}//generate_extensions_conf()
|
||||
}//class HelloWorld
|
||||
|
||||
?>
|
||||
|
||||
/**
|
||||
* <this raw module name>_hook_<hooked raw module name>
|
||||
*
|
||||
* This function allows one to hook html into many different modules' pages to display html/information
|
||||
* In this example we have hooked into blacklist
|
||||
*
|
||||
* @return string The return HTML to send back
|
||||
*/
|
||||
function helloworld_hook_blacklist() {
|
||||
$html = '';
|
||||
$html = '<tr><td colspan="2"><h5>';
|
||||
$html .= _("Hello World Hook");
|
||||
$html .= '<hr></h5></td></tr>';
|
||||
$html .= '<tr><td><a href="#" class="info">';
|
||||
$html .= _("This is the Text for the item").'<span>'._("Popup Help Descriptions").'.</span></a>';
|
||||
$html .= '</td><td>';
|
||||
$html .= 'This is the item';
|
||||
$html .= '</td></tr>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* <this raw module name>_hookProcess_<hooked raw module name>
|
||||
*
|
||||
* This function allows one to process data that was saved on the hooked raw module page
|
||||
*
|
||||
* @param $viewing_itemid string the id of the item being viewed
|
||||
* @param $request array php's $_REQUEST array
|
||||
* @return bool true successful or false if not
|
||||
*/
|
||||
function helloworld_hookProcess_blacklist($viewing_itemid, $request) {
|
||||
}
|
||||
|
||||
function helloworld_configpageinit($pagename) {
|
||||
helloworld_applyhooks();
|
||||
}
|
||||
|
||||
function helloworld_applyhooks() {
|
||||
global $currentcomponent;
|
||||
|
||||
// Add the 'process' function - this gets called when the page is loaded, to hook into
|
||||
// displaying stuff on the page.
|
||||
$currentcomponent->addguifunc('helloworld_configpageload');
|
||||
}
|
||||
|
||||
|
||||
function helloworld_configpageload() {
|
||||
global $currentcomponent, $endpoint, $db;
|
||||
$section = _('Hooker');
|
||||
$currentcomponent->addguielem($section, new gui_drawselects('hooker_box', 50, '', 'GUI Item Name', 'Gui Item Help Text'), 9);
|
||||
}
|
||||
|
38
install.php
38
install.php
@ -1,29 +1,21 @@
|
||||
<?php
|
||||
/* $Id$ */
|
||||
global $db;
|
||||
global $amp_conf;
|
||||
|
||||
if (! function_exists("out")) {
|
||||
function out($text) {
|
||||
echo $text."<br />";
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists("outn")) {
|
||||
function outn($text) {
|
||||
echo $text;
|
||||
}
|
||||
}
|
||||
|
||||
/* FreePBX installer file
|
||||
* This file is run when the module is installed through module admin
|
||||
*
|
||||
* Note: install.sql is depreciated and may not work. Its recommended to use this file instead.
|
||||
*
|
||||
* If this file returns false then the module will not install
|
||||
* EX:
|
||||
* return false;
|
||||
*
|
||||
*/
|
||||
$sql = "CREATE TABLE IF NOT EXISTS HelloWorld_settings (
|
||||
hwid varchar(32) NOT NULL default '',
|
||||
hwset varchar(32) NOT NULL default '',
|
||||
PRIMARY KEY (hwid)
|
||||
`key` varchar(255) NOT NULL default '',
|
||||
`value` varchar(255) NOT NULL default '',
|
||||
PRIMARY KEY (`key`)
|
||||
);";
|
||||
|
||||
$check = $db->query($sql);
|
||||
$check = sql($sql);
|
||||
if (DB::IsError($check)) {
|
||||
die_freepbx( "Can not create `HelloWorld` table: " . $check->getMessage() . "\n");
|
||||
}
|
||||
|
||||
?>
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
<module>
|
||||
<rawname>HelloWorld</rawname>
|
||||
<rawname>helloworld</rawname>
|
||||
<name>Hello World</name>
|
||||
<version>0.1.0.0</version>
|
||||
<candisable>yes</candisable>
|
||||
@ -18,9 +18,6 @@
|
||||
<module>core</module>
|
||||
<version>ge2.2</version>
|
||||
</depends>
|
||||
<type>setup</type>
|
||||
<category>Basic</category>
|
||||
<location>x</location>
|
||||
<md5sum>x</md5sum>
|
||||
<category>Settings</category>
|
||||
</module>
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?
|
||||
<?php
|
||||
//Check if user is "logged in"
|
||||
if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); }
|
||||
//Handling form stuff....
|
||||
@ -18,8 +18,17 @@ switch ($action) {
|
||||
needreload();
|
||||
redirect_standard();
|
||||
break;
|
||||
echo "<h2>"._("Hello World")."</h2>";
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
$variables = array(
|
||||
'astmanconnected' => $astman->connected(),
|
||||
'listcommands' => $astman->ListCommands(),
|
||||
'astdatabase' => $astman->database_show(),
|
||||
'ds' => drawselects('',1,false,false)
|
||||
);
|
||||
$html = load_view(dirname(__FILE__).'/views/main.tpl', $variables);
|
||||
echo $html;
|
||||
|
||||
$astman->database_put('family','key','valuer');
|
||||
$out = $astman->database_get('family','key');
|
||||
echo $out;
|
@ -1,20 +1,5 @@
|
||||
<?
|
||||
global $db;
|
||||
|
||||
if (! function_exists("out")) {
|
||||
function out($text) {
|
||||
echo $text."<br />";
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists("outn")) {
|
||||
function outn($text) {
|
||||
echo $text;
|
||||
}
|
||||
}
|
||||
<?php
|
||||
//Johnny Drop Tables
|
||||
out("Dropping all relevant tables");
|
||||
$sql = "DROP TABLE `HelloWorld_settings`";
|
||||
$result = $db->query($sql);
|
||||
|
||||
?>
|
||||
$result = sql($sql);
|
17
views/main.tpl
Normal file
17
views/main.tpl
Normal file
@ -0,0 +1,17 @@
|
||||
<h2>Hello World Module</h2>
|
||||
|
||||
<h5>Is Asterisk Manager Connected? <?php echo ($astmanconnected) ? 'Yes' : 'No';?></h5>
|
||||
|
||||
<h5>Available Asterisk Manager Commands?<hr></h5>
|
||||
<textarea rows="20" cols="180">
|
||||
<?php foreach($listcommands as $command => $description) {?>
|
||||
<?php echo $command?>=><?php echo $description . "\n"?>
|
||||
<?php } ?>
|
||||
</textarea>
|
||||
|
||||
<h5>Full Asterisk Internal Database?<hr></h5>
|
||||
<textarea rows="20" cols="180">
|
||||
<?php foreach($astdatabase as $family => $value) {?>
|
||||
<?php echo $family?>=><?php echo $value . "\n"?>
|
||||
<?php } ?>
|
||||
</textarea>
|
Loading…
Reference in New Issue
Block a user