Skip to content

Commit

Permalink
Merge branch 'feature/client' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Gipetto committed Aug 2, 2011
2 parents bf4fcda + 5135226 commit d131118
Show file tree
Hide file tree
Showing 89 changed files with 7,768 additions and 511 deletions.
2 changes: 1 addition & 1 deletion .htaccess
Expand Up @@ -13,4 +13,4 @@ RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php?vbxsite=$1 [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L,QSA]
#RewriteRule ^(.*) index.php/$1 [L,QSA]

ErrorDocument 404 /fallback/rewrite.php
ErrorDocument 404 /fallback/rewrite.php
2 changes: 1 addition & 1 deletion OpenVBX/config/config.php 100644 → 100755
Expand Up @@ -27,7 +27,7 @@
| Used for js versioning.
|
*/
$config['site_rev'] = 1007;
$config['site_rev'] = 1009;

/*
|--------------------------------------------------------------------------
Expand Down
5 changes: 4 additions & 1 deletion OpenVBX/config/routes.php
Expand Up @@ -40,7 +40,8 @@
|
*/

$route['default_controller'] = "messages/message_index";
#$route['default_controller'] = "messages/message_index";
$route['default_controller'] = "iframe";
$route['scaffolding_trigger'] = "";

$route['install'] = "install";
Expand All @@ -55,6 +56,7 @@
$route['messages/details/(:any)'] = "messages/details/index/$1";
$route['messages/call/(:num)'] = 'messages/message_call/index/$1';
$route['messages/call'] = 'messages/message_call/index';
$route['messages/client'] = 'messages/message_call/client';
$route['messages/sms/(:num)'] = 'messages/message_text/index/$1';
$route['messages/sms'] = 'messages/message_text/index';
$route['accounts'] = "accounts";
Expand Down Expand Up @@ -94,6 +96,7 @@
$route['external'] = "external";
$route['iphone/messages/details/(:any)'] = 'iphone/message_details/$1';
$route['iphone'] = "iphone";
$route['iframe'] = "iframe";

/* End of file routes.php */
/* Location: ./system/application/config/routes.php */
32 changes: 22 additions & 10 deletions OpenVBX/controllers/account.php
Expand Up @@ -107,26 +107,38 @@ public function edit()
/* Disallow people from changing certain settings */
if(in_array($field, $user->admin_fields))
{
if($val && $is_admin) $params[$field] = $val;
if(($val || $val === '0') && $is_admin) $params[$field] = $val;
}
else
{
if($val) $params[$field] = $val;
if($val || $val === '0') $params[$field] = $val;
}

// The value for some fields should also be saved to the session
if ($field === 'email')
{
$this->session->set_userdata('email', trim($val));
}
}

if($user->update($this->user_id, $params)) {
$this->session->set_flashdata('message_edit', 'User data changed');
redirect('account');
} else {
$this->data['error_edit'] = '';
$this->index();

$success = $user->update($this->user_id, $params);

if ($this->response_type == 'json') {
$data = array(
'error' => !$success,
'message' => (!$success ? 'an error occurred while updating the user' : 'user status updated')
);
$this->respond('', null, $data);
}
else {
if ($success) {
$this->session->set_flashdata('message_edit', 'User data changed');
redirect('account');
}
else {
$this->data['error_edit'] = '';
$this->index();
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion OpenVBX/controllers/accounts.php
Expand Up @@ -244,6 +244,7 @@ private function save_user()
{
// It's a new user
$user = new VBX_User();
$user->online = 9;
$shouldSendWelcome = true;
}
}
Expand Down Expand Up @@ -359,7 +360,8 @@ private function save_user()
'auth_type' => isset($auth_type->description) ? $auth_type->description : 'openvbx',
'email' => $user->email,
'error' => false,
'message' => ''
'message' => '',
'online' => $user->online
);
}

Expand Down
16 changes: 11 additions & 5 deletions OpenVBX/controllers/auth/login.php
Expand Up @@ -131,7 +131,7 @@ private function login($redirect)
protected function after_login_completed($user, $redirect)
{
$last_seen = $user->last_seen;

/* Redirect to flows if this is an admin and his inbox is zero (but not if the caller is hitting the REST api)*/
if($this->response_type != 'json')
{
Expand All @@ -153,7 +153,9 @@ protected function after_login_completed($user, $redirect)
0,
'/'.(($this->tenant->id > 1)? $this->tenant->name : '')
);
return redirect('numbers');
setcookie('last_known_url', real_site_url('/numbers'), null, '/');
return redirect('');
// return redirect('numbers');
}
}
catch(VBX_IncomingNumberException $e)
Expand All @@ -166,10 +168,14 @@ protected function after_login_completed($user, $redirect)
$devices = VBX_Device::search(array('user_id' => $user->id));
if(empty($devices))
{
return redirect('devices');
setcookie('last_known_url', real_site_url('/devices'), null, '/');
return redirect('');
// return redirect('devices');
}
}

return $this->redirect($redirect);

setcookie('last_known_url', $redirect, null, '/');
return $this->redirect('');
// return $this->redirect($redirect);
}
}
57 changes: 57 additions & 0 deletions OpenVBX/controllers/iframe.php
@@ -0,0 +1,57 @@
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
* "The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
* The Original Code is OpenVBX, released June 15, 2010.
* The Initial Developer of the Original Code is Twilio Inc.
* Portions created by Twilio Inc. are Copyright (C) 2010.
* All Rights Reserved.
* Contributor(s):
**/

require_once(APPPATH.'libraries/twilio.php');

class Iframe extends User_Controller {

public function __construct() {
parent::__construct();
}

function index() {
$data = array(
'site_title' => 'OpenVBX',
'iframe_url' => site_url('/messages')
);

// if the 'last_known_url' cookie is set then we've been redirected IN to frames mode
if (!empty($_COOKIE['last_known_url'])) {
$data['iframe_url'] = $_COOKIE['last_known_url'];
setcookie('last_known_url', '', time() - 3600);
}

if (!empty($this->application_sid))
{
// look at protocol and serve the appropriate file, https comes from amazon aws
$tjs_baseurl = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ?
'https://s3.amazonaws.com/static.twilio.com' : 'http://static.twilio.com';
//$this->template->add_js($tjs_baseurl.'/libs/twiliojs/1.0/twilio.js', 'absolute');
$data['twilio_js'] = $tjs_baseurl.'/libs/twiliojs/1.0/twilio.js';
}

$data['client_capability'] = $this->capability->generateToken();
$data['capability'] = $this->capability;

$this->load->view('iframe', $data);
}

}

0 comments on commit d131118

Please sign in to comment.