Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 421

Přidáno uživatelem Roman Ševčík před asi 15 roky(ů)

Integrace asterisku do freentisu - přidána tabulka voip_voicemail_users a operace nad ni.

Zobrazit rozdíly:

freenetis/trunk/kohana/application/models/voip_voicemail_user.php
<?php
class Voip_voicemail_user_Model extends ORM
{
}
?>
freenetis/trunk/kohana/application/controllers/voip.php
//$text = "příliš žluťoučký kůň úpěl ďábelské ódy"
//echo(StrTr($text, "ÁÄČÇĎÉĚËÍŇÓÖŘŠŤÚŮÜÝŽáäčçďéěëíňóöřšťúůüýž", "AACCDEEEINOORSTUUUYZaaccdeeeinoorstuuuyz"));
$voicemail_model = new Voip_voicemail_user_Model();
$voicemail = $voicemail_model->find_by_customer_id($voip->mailbox);
if(( $voip->regseconds - time()) > 1)
$link_status = true;
else
......
$view->content->link_status = $link_status;
$view->content->ipaddr = $voip->ipaddr;
$view->content->port = $voip->port;
$view->content->regseconds = $voip->regseconds - time();
$view->content->regseconds = ($voip->regseconds - time()< 0 )?'0':$voip->regseconds - time();
$view->content->voicemail = $voicemail;
$view->footer = new View('base/footer');
$view->render(TRUE);
......
if ($voip->count() == 0)
Controller::error(4);
$voip = $voip_sip->get_record_by_user($user_id);
$voip = $voip_sip->find_by_user_id($user_id);
$voip = $voip->current();
$this->user_id = $user_id;
$form = new Forge(url_lang::base()."voip/change_password/".$user_id, '', 'POST', array('id' => 'article_form'));
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
......
$view->content = new View('voip/change_password');
$view->footer = new View('base/footer');
$view->header->menu = Controller::render_menu();
$view->header->title = url_lang::lang('texts.Change application password');
$view->header->title = url_lang::lang('texts.Change VoIP password');
$view->content->form = $form->html();
$view->content->user_id = $user_id;
$view->content->message = $this->session->get_once('message');
......
}
function edit_voicemail($user_id = NULL)
{
if (!isset($user_id))
Controller::warning(1);
$voip_sip = new Voip_sip_Model();
$voip = $voip_sip->get_record_by_user_limited($user_id);
if ($voip->count() == 0)
Controller::error(4);
$voip = $voip_sip->find_by_user_id($user_id);
$voicemail_model = new Voip_voicemail_user_Model();
$voicemail = $voicemail_model->find_by_customer_id($voip->mailbox);
$form = new Forge(url_lang::base()."voip/edit_voicemail/".$user_id, '', 'POST', array('id' => 'article_form'));
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
$form->password('password')->label(url_lang::lang('texts.New password').':')->rules('required|length[4,4]');
$form->password('confirm_password')->label(url_lang::lang('texts.Confirm new password').':')->rules('required|length[4,4]')->matches($form->password);
$form->input('email')->label(url_lang::lang('texts.email').':')->rules('length[6,50]|required')->value($voicemail->email);
$form->submit('submit')->value(url_lang::lang('texts.Change'));
if($form->validate())
{
$form_data = $form->as_array();
$voip_sip = new Voip_sip_Model();
$voip = $voip_sip->find_by_user_id($user_id);
$voicemail_model = new Voip_voicemail_user_Model();
$voicemail = $voicemail_model->find_by_customer_id($voip->mailbox);
$voicemail->password = $form_data['password'];
$voicemail->email = $form_data['email'];
if ($voicemail->save())
{
$this->session->set_flash('message', url_lang::lang('texts.Password has been successfully changed.'));
}
else
{
$this->session->set_flash('message', url_lang::lang('texts.Error - cant change password.'));
}
url::redirect(url_lang::base().'voip/edit_voicemail/'.$user_id);
}
else
{
$view = new View('template');
$view->header = new View('base/header');
$view->content = new View('voip/edit_voicemail');
$view->footer = new View('base/footer');
$view->header->menu = Controller::render_menu();
$view->header->title = url_lang::lang('texts.Edit VoIP voicemail');
$view->content->form = $form->html();
$view->content->user_id = $user_id;
$view->content->message = $this->session->get_once('message');
$view->render(TRUE);
}
}
function edit($user_id = NULL)
{
if (!isset($user_id))
freenetis/trunk/kohana/application/upgrade_sql/upgrade_sql_418.php
<?php
$upgrade_sql[418] = array(
"CREATE TABLE `bank_templates` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`bank_name` VARCHAR( 50 ) NOT NULL ,
`bank_code` VARCHAR( 10 ) NULL DEFAULT NULL ,
`account_name` VARCHAR( 50 ) NULL DEFAULT NULL ,
`account_number` VARCHAR( 30 ) NOT NULL ,
`constant_symbol` BIGINT NULL DEFAULT NULL ,
`variable_symbol` BIGINT NOT NULL ,
`specific_symbol` BIGINT NULL DEFAULT NULL ,
`counteraccount_name` VARCHAR( 50 ) NULL DEFAULT NULL ,
`counteraccount_number` VARCHAR( 30 ) NOT NULL ,
`counteraccount_bank_code` VARCHAR( 10 ) NULL DEFAULT NULL ,
`text` VARCHAR( 100 ) NOT NULL ,
`amount` DOUBLE NOT NULL ,
`datetime` DATETIME NOT NULL
) ENGINE = InnoDB CHARACTER SET utf8 COLLATE utf8_czech_ci;"
);
?>
freenetis/trunk/kohana/application/upgrade_sql/upgrade_sql.php
}
// array of sql queries that upgrade database
$upgrade_sql[get_SVN_rev()] = array(
"CREATE TABLE `bank_templates` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`bank_name` VARCHAR( 50 ) NOT NULL ,
`bank_code` VARCHAR( 10 ) NULL DEFAULT NULL ,
`account_name` VARCHAR( 50 ) NULL DEFAULT NULL ,
`account_number` VARCHAR( 30 ) NOT NULL ,
`constant_symbol` BIGINT NULL DEFAULT NULL ,
`variable_symbol` BIGINT NOT NULL ,
`specific_symbol` BIGINT NULL DEFAULT NULL ,
`counteraccount_name` VARCHAR( 50 ) NULL DEFAULT NULL ,
`counteraccount_number` VARCHAR( 30 ) NOT NULL ,
`counteraccount_bank_code` VARCHAR( 10 ) NULL DEFAULT NULL ,
`text` VARCHAR( 100 ) NOT NULL ,
`amount` DOUBLE NOT NULL ,
`datetime` DATETIME NOT NULL
) ENGINE = InnoDB CHARACTER SET utf8 COLLATE utf8_czech_ci;"
$upgrade_sql[get_SVN_rev()] = array("
DROP TABLE IF EXISTS `voip_sips`;
CREATE TABLE `voip_sips` (
`id` int(11) NOT NULL auto_increment,
`user_id` int(11) NOT NULL,
`name` varchar(80) collate utf8_czech_ci NOT NULL,
`accountcode` varchar(20) collate utf8_czech_ci default NULL,
`amaflags` varchar(13) collate utf8_czech_ci default NULL,
`callgroup` varchar(10) collate utf8_czech_ci default NULL,
`callerid` varchar(80) collate utf8_czech_ci NOT NULL,
`canreinvite` char(3) collate utf8_czech_ci default 'no',
`context` varchar(80) collate utf8_czech_ci default 'internal',
`defaultip` varchar(15) collate utf8_czech_ci default NULL,
`dtmfmode` varchar(7) collate utf8_czech_ci default NULL,
`fromuser` varchar(80) collate utf8_czech_ci default NULL,
`fromdomain` varchar(80) collate utf8_czech_ci default NULL,
`fullcontact` varchar(80) collate utf8_czech_ci default NULL,
`host` varchar(31) collate utf8_czech_ci NOT NULL default 'dynamic',
`insecure` varchar(4) collate utf8_czech_ci default NULL,
`language` char(2) collate utf8_czech_ci default 'cz',
`mailbox` varchar(50) collate utf8_czech_ci NOT NULL,
`md5secret` varchar(80) collate utf8_czech_ci default NULL,
`nat` varchar(5) collate utf8_czech_ci NOT NULL default 'yes',
`deny` varchar(95) collate utf8_czech_ci default NULL,
`permit` varchar(95) collate utf8_czech_ci default NULL,
`mask` varchar(95) collate utf8_czech_ci default NULL,
`pickupgroup` varchar(10) collate utf8_czech_ci default NULL,
`port` varchar(5) collate utf8_czech_ci default NULL,
`qualify` char(3) collate utf8_czech_ci default NULL,
`restrictcid` char(1) collate utf8_czech_ci default NULL,
`rtptimeout` char(3) collate utf8_czech_ci default NULL,
`rtpholdtimeout` char(3) collate utf8_czech_ci default NULL,
`secret` varchar(80) collate utf8_czech_ci NOT NULL,
`type` varchar(6) collate utf8_czech_ci NOT NULL default 'friend',
`username` varchar(80) collate utf8_czech_ci NOT NULL,
`disallow` varchar(100) collate utf8_czech_ci default NULL,
`allow` varchar(100) collate utf8_czech_ci default NULL,
`musiconhold` varchar(100) collate utf8_czech_ci default NULL,
`regseconds` int(11) NOT NULL default '0',
`ipaddr` varchar(15) collate utf8_czech_ci NOT NULL,
`regexten` varchar(80) collate utf8_czech_ci NOT NULL,
`cancallforward` char(3) collate utf8_czech_ci default 'yes',
`setvar` varchar(100) collate utf8_czech_ci NOT NULL,
`auth` varchar(10) collate utf8_czech_ci default NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci ROW_FORMAT=DYNAMIC AUTO_INCREMENT=1 ;",
"CREATE TABLE IF NOT EXISTS `voip_voicemail_users` (
`id` int(11) NOT NULL auto_increment,
`customer_id` int(11) NOT NULL,
`context` varchar(50) collate utf8_czech_ci NOT NULL,
`mailbox` varchar(10) collate utf8_czech_ci NOT NULL default '0',
`password` varchar(4) collate utf8_czech_ci NOT NULL default '0',
`fullname` varchar(50) collate utf8_czech_ci NOT NULL,
`email` varchar(50) collate utf8_czech_ci NOT NULL,
`pager` varchar(50) collate utf8_czech_ci NOT NULL,
`stamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `customer_id` (`customer_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1 ;"
);
?>
freenetis/trunk/kohana/application/views/voip/edit_voicemail.php
<h2><?php echo url_lang::lang('texts.Edit VoIP voicemail') ?></h2><br />
<?php echo $message ? '<div class="message">'.$message.'</div>' : '' ?>
<?php
$links = array();
$links[] = html::anchor(url_lang::base().'voip/show/'.$user_id, url_lang::lang('texts.Back to VoIP account'));
echo implode (' | ', $links)
?>
<br /><br />
<?php echo $form?>
freenetis/trunk/kohana/application/views/voip/show.php
<?php
$links[] = html::anchor(url_lang::base().'users/show/'.$voip->user_id, url_lang::lang('texts.Back to the user'));
//$links[] = html::anchor(url_lang::base().'voip/edit/'.$voip->user_id, url_lang::lang('texts.Edit'));
$links[] = html::anchor(url_lang::base().'voip/change_password/'.$voip->user_id, url_lang::lang('texts.Change password'));
$links[] = html::anchor(url_lang::base().'voip/edit_voicemail/'.$voip->user_id, url_lang::lang('texts.Edit voicemail'));
echo implode (' | ', $links);?>
<br />
<br />
<table class="extended" style="float:left; width:360px;">
<table class="extended" style="margin-right:10px; float:left; width:360px;">
<tr>
<th colspan="2"><?php echo url_lang::lang('texts.Login information') ?></th>
</tr>
......
</tr>
</table>
<table class="extended" cellspacing="0" style="float:left; margin-left:10px; width:360px;">
<table class="extended" cellspacing="0" style="width:360px;">
<tr>
<th colspan="2"><?php echo url_lang::lang('texts.Link status') ?></th>
</tr>
......
<td><?php echo $link_status?'<b style="color:green;">'.url_lang::lang('texts.Registered').'</b>':'<b style="color:red;">'.url_lang::lang('texts.Not registered').'</b>'; ?></td>
</tr>
<?php if ($link_status == true ){?>
<tr>
<th><?php echo url_lang::lang('texts.IP address') ?></th>
<td><?php echo $ipaddr ?></td>
......
<th><?php echo url_lang::lang('texts.Registration expires') ?></th>
<td><?php echo $regseconds.' s' ?></td>
</tr>
<?php }?>
</table>
<br />
<br />
<table class="extended" style="float:left; width:360px;">
<tr>
<table class="extended" style="width:360px;">
<tr>
<th colspan="2"><?php echo url_lang::lang('texts.Voicemail information') ?></th>
</tr>
</tr>
<tr>
<th><?php echo url_lang::lang('texts.username') ?></th>
<td><?php echo $voip->name ?></td>
</tr>
<th><?php echo url_lang::lang('texts.heslo') ?></th>
<td><?php echo $voicemail->password ?></td>
</tr>
<tr>
<th><?php echo url_lang::lang('texts.password') ?></th>
<td><?php echo '<b>********</b>'.' &nbsp;&nbsp;&nbsp;&nbsp; '.html::anchor(url_lang::base().'voip/change_password/'.$voip->user_id, url_lang::lang('texts.Change')); ?></td>
</tr>
<tr>
<th><?php echo url_lang::lang('texts.Display name') ?></th>
<td><?php echo $voip->callerid ?></td>
</tr>
<tr>
<th><?php echo url_lang::lang('texts.Domain') ?></th>
<td><?php echo $sip_server ?></td>
</tr>
<th><?php echo url_lang::lang('texts.email') ?></th>
<td><?php echo $voicemail->email ?></td>
</tr>
</table>

Také k dispozici: Unified diff