cleanup
This commit is contained in:
parent
5d5e62380b
commit
2e1d048030
37
HelloWorld/HelloWorld/functions.inc.php
Normal file
37
HelloWorld/HelloWorld/functions.inc.php
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?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
|
||||||
|
|
||||||
|
?>
|
47
HelloWorld/README
Normal file
47
HelloWorld/README
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
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
|
||||||
|
|
37
HelloWorld/functions.inc.php
Normal file
37
HelloWorld/functions.inc.php
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?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
|
||||||
|
|
||||||
|
?>
|
29
HelloWorld/install.php
Normal file
29
HelloWorld/install.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?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");
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
26
HelloWorld/module.xml
Normal file
26
HelloWorld/module.xml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<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>
|
||||||
|
|
25
HelloWorld/page.HelloWorld.php
Normal file
25
HelloWorld/page.HelloWorld.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?
|
||||||
|
//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>";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
20
HelloWorld/uninstall.php
Normal file
20
HelloWorld/uninstall.php
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?
|
||||||
|
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);
|
||||||
|
|
||||||
|
?>
|
Loading…
Reference in New Issue
Block a user