aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Bottomley <JBottomley@Parallels.com>2013-04-26 17:17:45 -0700
committerJames Bottomley <JBottomley@Parallels.com>2013-04-26 17:40:08 -0700
commit2cdc6582217c2719ee31d251432792a10f2d7bf7 (patch)
tree75acca4bcd1a934e6e963ddd72f96e7820f516e6
parente6e67f707e2e6f571931043b39546eefbd5d1da2 (diff)
downloadasterisk-aastra-2cdc6582217c2719ee31d251432792a10f2d7bf7.tar.gz
BaseAastra: add base abstract class from which all the actions build
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
-rw-r--r--include/BaseAastra.class.php80
1 files changed, 80 insertions, 0 deletions
diff --git a/include/BaseAastra.class.php b/include/BaseAastra.class.php
new file mode 100644
index 0000000..50f21e7
--- /dev/null
+++ b/include/BaseAastra.class.php
@@ -0,0 +1,80 @@
+<?php
+##
+# Copyright 2013 by James Bottomley
+##
+# Base abstract class for building up XML actions
+##
+require_once('AastraAsterisk.class.php');
+
+abstract class BaseAastra {
+ var $asm;
+ var $user;
+ var $url; /* without query strings */
+ var $fullurl;
+ var $title;
+ var $do = null;
+ var $back = null;
+
+ static final function exception_handler($e) {
+ require_once('AastraIPPhoneTextScreen.class.php');
+
+ $object=new AastraIPPhoneTextScreen();
+ $object->setDestroyOnExit();
+ $object->SetTitle("Error");
+ $object->SetText($e->getMessage());
+ $object->output();
+ }
+
+ function __construct() {
+ header('Content-type: text/xml');
+ set_exception_handler('BaseAastra::exception_handler');
+ $this->asm=new AGI_AsteriskManager();
+ $this->asm->connect();
+ $this->url = 'http';
+ if (isset($_SERVER['HTTPS'])) {$this->url .= 's';}
+ $this->url .= '://'.$_SERVER["SERVER_NAME"];
+ $pos = strpos($_SERVER["REQUEST_URI"], '?');
+ if ($pos !== false) {
+ $baseurl = substr($_SERVER['REQUEST_URI'], 0, $pos);
+ } else {
+ $baseurl = $_SERVER['REQUEST_URI'];
+ }
+ if ($_SERVER["SERVER_PORT"] != "80") {
+ $this->url .= ":".$_SERVER["SERVER_PORT"];
+ }
+ $this->fullurl = $this->url . $_SERVER['REQUEST_URI'];
+ $this->url .= $baseurl;
+ $this->user = $this->asm->get_user();
+ }
+
+ function init() {
+ if (isset($_GET['action'])) {
+ $this->$_GET['action']();
+ } else {
+ $this->start();
+ }
+ if (!$this->do) {
+ require_once('AastraIPPhoneExecute.class.php');
+ $this->do = new AastraIPPhoneExecute();
+ $this->do->addEntry('');
+ $this->do->setTriggerDestroyOnExit();
+ }
+ $this->do->output();
+ }
+
+ function yesno() {
+ $this->do->addSoftkey('1', 'Yes', $this->fullurl.'&yesno=yes');
+ $this->do->addSoftkey('2', 'No', $this->fullurl.'&yesno=no');
+ }
+
+ function displayObject($o) {
+ $this->do = $o;
+ $o->setTitle($this->title);
+ $o->setDestroyOnExit();
+ if($this->back) {
+ $o->setCancelAction($this->back);
+ }
+ }
+
+ abstract function start();
+}