From 5d5e62380b4a5e1b92f3915f0c2e51b6d60eb038 Mon Sep 17 00:00:00 2001 From: James Finstrom Date: Thu, 20 Dec 2012 14:22:05 -0700 Subject: [PATCH] giving this it's own home --- README | 47 +++++++++++++++++++++++++++++++++++++++++++++ functions.inc.php | 37 +++++++++++++++++++++++++++++++++++ install.php | 29 ++++++++++++++++++++++++++++ module.xml | 26 +++++++++++++++++++++++++ page.HelloWorld.php | 25 ++++++++++++++++++++++++ uninstall.php | 20 +++++++++++++++++++ 6 files changed, 184 insertions(+) create mode 100644 README create mode 100644 functions.inc.php create mode 100644 install.php create mode 100644 module.xml create mode 100644 page.HelloWorld.php create mode 100644 uninstall.php diff --git a/README b/README new file mode 100644 index 0000000..b7282c6 --- /dev/null +++ b/README @@ -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 + diff --git a/functions.inc.php b/functions.inc.php new file mode 100644 index 0000000..7d2eaaa --- /dev/null +++ b/functions.inc.php @@ -0,0 +1,37 @@ +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 + +?> diff --git a/install.php b/install.php new file mode 100644 index 0000000..5e7c464 --- /dev/null +++ b/install.php @@ -0,0 +1,29 @@ +"; + } +} + +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"); +} + +?> diff --git a/module.xml b/module.xml new file mode 100644 index 0000000..604254f --- /dev/null +++ b/module.xml @@ -0,0 +1,26 @@ + + HelloWorld + Hello World + 0.1.0.0 + yes + yes + + *0.1.0.0* Original Release (beta) + + + provides a hello world example + + http://github.com/jfinstrom/ + + Hello World + + + core + ge2.2 + + setup + Basic + x + x + + diff --git a/page.HelloWorld.php b/page.HelloWorld.php new file mode 100644 index 0000000..eedce8e --- /dev/null +++ b/page.HelloWorld.php @@ -0,0 +1,25 @@ +escapeSimple($_REQUEST['itemid']):$itemid=''; + +switch ($action) { + case "add": + needreload(); + break; + case "delete": + needreload(); + redirect_standard(); + break; + case "edit": + needreload(); + redirect_standard(); + break; +echo "

"._("Hello World")."

"; + +} + +?> diff --git a/uninstall.php b/uninstall.php new file mode 100644 index 0000000..0aff90d --- /dev/null +++ b/uninstall.php @@ -0,0 +1,20 @@ +"; + } +} + +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); + +?>