blob: 97114d18bf62a293022b3c87f40fc57ae79f1c06 [file] [log] [blame]
<?php
##
# Copyright 2013 by James Bottomley
##
# Blacklist handling class
##
require_once('BaseAastra.class.php');
require_once('AastraIPPhoneTextScreen.class.php');
require_once('AastraIPPhoneInputScreen.class.php');
class Blacklist extends BaseAastra {
var $lastnumber;
var $name;
var $blacklist;
var $whitelist;
private function __initvar() {
$this->lastnumber = $this->asm->database_get('lastnumber', '1');
$this->blacklist = $this->asm->database_get('blacklist', $this->lastnumber);
$this->whitelist = $this->asm->database_get('whitelist', $this->lastnumber);
}
function __construct() {
parent::__construct();
$this->title = 'Blacklist/Whitelist';
$this->__initvar();
}
function del_black() {
$this->back = $this->url;
if (isset($_GET['yesno'])) {
if ($_GET['yesno'] == 'yes') {
$this->asm->database_del('blacklist',$this->lastnumber);
}
return;
}
$this->displayObject(new AastraIPPhoneTextScreen());
$this->do->SetText('Are you sure you want to remove '.$this->lastnumber.' from the Blacklist?');
$this->yesno();
}
function black() {
$this->back = $this->url;
if (isset($_GET['yesno'])) {
if ($_GET['yesno'] == 'yes') {
$this->asm->database_del('whitelist',$this->lastnumber);
$this->asm->database_put('blacklist',$this->lastnumber,'1');
}
return;
}
$this->displayObject(new AastraIPPhoneTextScreen());
$this->do->SetText('Are you sure you want to blacklist '.$this->lastnumber.'?');
$this->yesno();
}
function newnum() {
if (isset($_GET['num'])) {
$this->asm->database_put('lastnumber','1',$_GET['num']);
$this->__initvar();
$this->start();
return;
}
$this->back = $this->url;
$this->displayObject(new AastraIPPhoneInputScreen());
$this->do->setParameter('num');
$this->do->setType('number');
$this->do->setPrompt('Enter number:');
$this->do->setURL($this->fullurl);
}
function del_white() {
$this->back = $this->url;
if (isset($_GET['yesno'])) {
if ($_GET['yesno'] == 'yes') {
$this->asm->database_del('whitelist',$this->lastnumber);
}
return;
}
$this->displayObject(new AastraIPPhoneTextScreen());
$this->do->SetText('Are you sure you want to remove '.$this->lastnumber.' "'.$this->whitelist.'" from the Whitelist?');
$this->yesno();
}
function white() {
if (isset($_GET['description'])) {
$this->asm->database_del('blacklist',$this->lastnumber);
$this->asm->database_put('whitelist',$this->lastnumber,'"'.$_GET['description'].'"');
return;
}
$this->back = $this->url;
$this->displayObject(new AastraIPPhoneInputScreen());
$this->do->setParameter('description');
$this->do->setType('string');
$this->do->setPrompt('Enter description for '.$this->lastnumber.':');
$this->do->setURL($this->fullurl);
}
function start() {
$this->displayObject(new AastraIPPhoneTextScreen());
$text = 'The last number was '.$this->lastnumber;
if ($this->blacklist) {
$text .= ' which is already blacklisted';
$this->do->addSoftkey('1', 'Remove Blacklist', $this->url.'?action=del_black');
} else {
$this->do->addSoftkey('1', 'Blacklist', $this->url.'?action=black');
}
if ($this->whitelist) {
$text .= ' which is already in the whitelist as "'.$this->whitelist.'"';
$this->do->addSoftkey('2', 'Remove Whitelist', $this->url.'?action=del_white');
} else {
$this->do->addSoftkey('2', 'Whitelist', $this->url.'?action=white');
}
$this->do->SetText($text);
$this->do->addSoftkey('3', 'New Number', $this->url.'?action=newnum');
}
}
?>