From b231ee1cbbb3348a1a20f55ffaf3409ab35a501b Mon Sep 17 00:00:00 2001 From: Andrew Nagy Date: Fri, 3 May 2013 14:44:25 -0400 Subject: [PATCH] Cleanup --- HelloWorld/HelloWorld/functions.inc.php | 37 --------- HelloWorld/README | 47 ------------ HelloWorld/functions.inc.php | 37 --------- HelloWorld/install.php | 29 ------- HelloWorld/module.xml | 26 ------- HelloWorld/page.HelloWorld.php | 25 ------ HelloWorld/uninstall.php | 20 ----- functions.inc.php | 89 +++++++++++++--------- install.php | 38 ++++----- module.xml | 7 +- page.HelloWorld.php => page.helloworld.php | 17 ++++- uninstall.php | 19 +---- views/main.tpl | 17 +++++ 13 files changed, 102 insertions(+), 306 deletions(-) delete mode 100644 HelloWorld/HelloWorld/functions.inc.php delete mode 100644 HelloWorld/README delete mode 100644 HelloWorld/functions.inc.php delete mode 100644 HelloWorld/install.php delete mode 100644 HelloWorld/module.xml delete mode 100644 HelloWorld/page.HelloWorld.php delete mode 100644 HelloWorld/uninstall.php rename page.HelloWorld.php => page.helloworld.php (57%) create mode 100644 views/main.tpl diff --git a/HelloWorld/HelloWorld/functions.inc.php b/HelloWorld/HelloWorld/functions.inc.php deleted file mode 100644 index 7d2eaaa..0000000 --- a/HelloWorld/HelloWorld/functions.inc.php +++ /dev/null @@ -1,37 +0,0 @@ -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/HelloWorld/README b/HelloWorld/README deleted file mode 100644 index b7282c6..0000000 --- a/HelloWorld/README +++ /dev/null @@ -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 - diff --git a/HelloWorld/functions.inc.php b/HelloWorld/functions.inc.php deleted file mode 100644 index 7d2eaaa..0000000 --- a/HelloWorld/functions.inc.php +++ /dev/null @@ -1,37 +0,0 @@ -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/HelloWorld/install.php b/HelloWorld/install.php deleted file mode 100644 index 5e7c464..0000000 --- a/HelloWorld/install.php +++ /dev/null @@ -1,29 +0,0 @@ -"; - } -} - -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/HelloWorld/module.xml b/HelloWorld/module.xml deleted file mode 100644 index 604254f..0000000 --- a/HelloWorld/module.xml +++ /dev/null @@ -1,26 +0,0 @@ - - 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/HelloWorld/page.HelloWorld.php b/HelloWorld/page.HelloWorld.php deleted file mode 100644 index eedce8e..0000000 --- a/HelloWorld/page.HelloWorld.php +++ /dev/null @@ -1,25 +0,0 @@ -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/HelloWorld/uninstall.php b/HelloWorld/uninstall.php deleted file mode 100644 index 0aff90d..0000000 --- a/HelloWorld/uninstall.php +++ /dev/null @@ -1,20 +0,0 @@ -"; - } -} - -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); - -?> diff --git a/functions.inc.php b/functions.inc.php index 7d2eaaa..1d04ccd 100644 --- a/functions.inc.php +++ b/functions.inc.php @@ -1,37 +1,54 @@ 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 - -?> + +/** + * _hook_ + * + * 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 = '
'; + $html .= _("Hello World Hook"); + $html .= '
'; + $html .= ''; + $html .= _("This is the Text for the item").''._("Popup Help Descriptions").'.'; + $html .= ''; + $html .= 'This is the item'; + $html .= ''; + + return $html; +} + +/** + * _hookProcess_ + * + * 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); +} diff --git a/install.php b/install.php index 5e7c464..264071c 100644 --- a/install.php +++ b/install.php @@ -1,29 +1,21 @@ "; - } -} - -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"); -} - -?> +} \ No newline at end of file diff --git a/module.xml b/module.xml index 604254f..1fd14af 100644 --- a/module.xml +++ b/module.xml @@ -1,5 +1,5 @@ - HelloWorld + helloworld Hello World 0.1.0.0 yes @@ -18,9 +18,6 @@ core ge2.2 - setup - Basic - x - x + Settings diff --git a/page.HelloWorld.php b/page.helloworld.php similarity index 57% rename from page.HelloWorld.php rename to page.helloworld.php index eedce8e..474d895 100644 --- a/page.HelloWorld.php +++ b/page.helloworld.php @@ -1,4 +1,4 @@ -"._("Hello World").""; - } -?> +$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; \ No newline at end of file diff --git a/uninstall.php b/uninstall.php index 0aff90d..39d8d46 100644 --- a/uninstall.php +++ b/uninstall.php @@ -1,20 +1,5 @@ -"; - } -} - -if (! function_exists("outn")) { - function outn($text) { - echo $text; - } -} +query($sql); - -?> +$result = sql($sql); \ No newline at end of file diff --git a/views/main.tpl b/views/main.tpl new file mode 100644 index 0000000..3acd6e4 --- /dev/null +++ b/views/main.tpl @@ -0,0 +1,17 @@ +

Hello World Module

+ +
Is Asterisk Manager Connected?
+ +
Available Asterisk Manager Commands?
+ + +
Full Asterisk Internal Database?
+ \ No newline at end of file