Пример #1
0
 protected function prepareUpdateView($baseModel = NULL)
 {
     $route_types = array();
     $trunkList = array();
     $interfaceList = array();
     if (class_exists('Trunk')) {
         $trunks = Doctrine::getTable('Trunk')->findAll(Doctrine::HYDRATE_ARRAY);
         foreach ($trunks as $trunk) {
             $trunkList[$trunk['trunk_id']] = $trunk['name'];
         }
         if (!empty($trunkList)) {
             $route_types[ExternalXfer::TYPE_TRUNK] = 'via Trunk';
         }
     }
     if (class_exists('SipInterface')) {
         $interfaces = Doctrine::getTable('SipInterface')->findAll(Doctrine::HYDRATE_ARRAY);
         foreach ($interfaces as $interface) {
             $interfaceList[$interface['sipinterface_id']] = $interface['name'];
         }
         if (!empty($interfaceList)) {
             $route_types[ExternalXfer::TYPE_SIP] = 'via SIP URI';
         }
     }
     if (empty($route_types)) {
         message::set('No Trunk or Sip Interfaces avaliable to route external destinations through!');
         $this->returnQtipAjaxForm(NULL);
         url::redirect(Router_Core::$controller);
     }
     $this->view->trunks = $trunkList;
     $this->view->interfaces = $interfaceList;
     $this->view->route_types = $route_types;
     parent::prepareUpdateView($baseModel);
 }
Пример #2
0
 public function __construct()
 {
     parent::__construct();
     if (users::getAttr('user_type') != User::TYPE_SYSTEM_ADMIN) {
         message::set('You are not authorized to manage sip interfaces!');
         $this->returnQtipAjaxForm(NULL);
         url::redirect('/');
     }
 }
Пример #3
0
 protected function loadBaseModel($id = NULL, $baseModel = NULL)
 {
     parent::loadBaseModel($id, $baseModel);
     if (!empty($this->netlist['system_list']) and $this->netlist['system_list'] != 'trunks.auto') {
         message::set($this->netlist['name'] . ' is generated by FreeSwitch and can not be edited!', 'alert');
         $this->returnQtipAjaxForm(NULL);
         url::redirect(Router::$controller);
     }
 }
Пример #4
0
 protected function submitReport($report)
 {
     $valid = TRUE;
     $validation = Bluebox_Controller::$validation;
     if (empty($report['issue'])) {
         $validation->add_error('report[issue]', 'Please describe the issue');
         $valid = FALSE;
     }
     if (empty($report['while'])) {
         $validation->add_error('report[while]', 'Please describe the cause');
         $valid = FALSE;
     }
     if (empty($report['contact'])) {
         $validation->add_error('report[contact]', 'Please provide a method to contact you');
         $valid = FALSE;
     }
     if (empty($report['error'])) {
         $validation->add_error('report[error]', 'Please provide the error message');
         $valid = FALSE;
     }
     if (!$valid) {
         return FALSE;
     }
     if (!empty($report['log'])) {
         $filename = Kohana::log_directory() . date('Y-m-d') . '.log' . EXT;
         $offset = -150 * 120;
         $rs = @fopen($filename, 'r');
         $report['log'] = '';
         if ($rs !== FALSE) {
             fseek($rs, $offset, SEEK_END);
             fgets($rs);
             while (!feof($rs)) {
                 $buffer = fgets($rs);
                 $report['log'] .= htmlspecialchars($buffer . "\n");
             }
             fclose($rs);
         }
     }
     $allowStats = Kohana::config('core.anonymous_statistics');
     if (!empty($allowStats)) {
         $report['anonymous_id'] = Kohana::config('core.anonymous_id');
         Package_Catalog::disableRemote();
         Package_Catalog::buildCatalog();
         $report['catalog'] = Package_Catalog::getPackageList();
     }
     try {
         $errorCollector = Kohana::config('errorreporter.collector');
         $this->do_post_request($errorCollector, $report);
     } catch (Exception $e) {
         message::set($e->getMessage());
         $this->returnQtipAjaxForm(NULL);
         return FALSE;
     }
     return TRUE;
 }
Пример #5
0
 public static function lookupPort($type)
 {
     switch ($type) {
         case 'mysql':
             return 3306;
             break;
         case 'pgsql':
             return 5432;
             break;
         default:
             message::set("Unable to resolve port for {$type}");
     }
 }
Пример #6
0
 public function rebuild($number_id)
 {
     $this->loadBaseModel($number_id);
     $this->number->markModified('number');
     try {
         $this->number->save();
         message::set('Number ' . $this->number['number'] . ' dialplan rebuild complete!', 'success');
         parent::save_succeeded($this->number);
     } catch (Exception $e) {
         message::set($e->getMessage());
     }
     $this->returnQtipAjaxForm();
     url::redirect(Router_Core::$controller);
 }
Пример #7
0
 public function delete($id = NULL)
 {
     if (users::getAttr('user_type') != User::TYPE_SYSTEM_ADMIN) {
         if (users::getAttr('account_id') != $id) {
             message::set('You are not authorized to delete that account!');
             $this->returnQtipAjaxForm(NULL);
             url::redirect(Router::$controller);
         }
     } else {
         users::masqueradeAccount($id);
     }
     Session::instance()->set('bluebox.delete.unlimit', TRUE);
     parent::delete($id);
     Session::instance()->set('bluebox.delete.unlimit', FALSE);
 }
Пример #8
0
 /**
  * Initialize the ESL connection.  This must be called first
  * @access public
  * @static
  * @return bool
  */
 public function __construct()
 {
     $host = Kohana::config('freeswitch.ESLHost');
     $port = Kohana::config('freeswitch.ESLPort');
     $password = Kohana::config('freeswitch.ESLAuth');
     if (!extension_loaded("ESL")) {
         $this->esl = new ESLconnection($host, $port, $password);
         // socket connection
         $this->extension = FALSE;
     } else {
         include_once MODPATH . 'esl-1.0/assets/ESL.php';
         $this->esl = new ESLconnection($host, $port, $password);
         // FreeSWITCH ESL Swigged class
         $this->extension = TRUE;
     }
     if (!$this->esl->connected()) {
         message::set('Failed to connect to ESL. Make sure FreeSWITCH is running...', 'alert');
         return FALSE;
     }
     return TRUE;
 }
Пример #9
0
 public function save()
 {
     // This array maps the telephony returns to the telephony file
     $telephonyOptions = array('cfg_root' => rtrim($this->session->get('installer.ast_root'), '/'), 'AmiHost' => $this->session->get('installer.ami_host'), 'AmiPort' => $this->session->get('installer.ami_port'), 'AmiUser' => $this->session->get('installer.ami_user'), 'AmiPass' => $this->session->get('installer.ami_pass'));
     if (!is_dir($telephonyOptions['cfg_root'])) {
         message::set('Unable to access directory <pre>' . $telephonyOptions['cfg_root'] . '</pre>');
         return false;
     }
     // Write $telephonyOptions to asterisk.php
     if (!Installer_Controller::updateConfig($telephonyOptions, 'asterisk')) {
         return false;
     }
     // Set the driver name in telephony.php
     if (!Installer_Controller::updateConfig(array('driver' => 'Asterisk'), 'telephony')) {
         return false;
     }
     // Reload the new asterisk options
     Kohana::config_clear('asterisk');
     Kohana::config_load('asterisk');
     $this->session->set('installer.default_packages', kohana::config('asterisk.default_packages'));
     return true;
 }
Пример #10
0
 public function profile()
 {
     // We use a different base model and writable fields for this controller
     $this->writable = array('first_name', 'last_name', 'email_address');
     $this->baseModelObject = 'User';
     // Overload the update view
     $this->template->content = new View(Router::$controller . '/profile');
     $this->user = Doctrine::getTable('User')->findOneByUserId($this->user->user_id);
     $this->new_password = $this->confirm_password = '';
     // Was anything retrieved? If no, this may be an invalid request
     if (!$this->user) {
         message::set('Unable to locate User');
     }
     // Are we supposed to be saving stuff? (received a form post?)
     if ($this->submitted()) {
         $hashedPassword = Auth::instance()->hash_password($_POST['user']['old_password'], Auth::instance()->find_salt($this->user->password));
         if (empty($_POST['user']['old_password'])) {
             message::set('Old password is empty');
         } elseif (empty($_POST['user']['new_password'])) {
             message::set('new password is empty');
         } elseif (empty($_POST['user']['confirm_password'])) {
             message::set('You need to confirm your password');
         } elseif ($_POST['user']['confirm_password'] != $_POST['user']['new_password']) {
             message::set('Your passwords did not match.');
         } elseif ($hashedPassword != $this->user->password) {
             // Password mismatch
             message::set('Old password is wrong');
         } else {
             $this->new_password = $_POST['user']['new_password'];
             $this->confirm_password = $_POST['user']['confirm_password'];
             $rules = Bluebox_Controller::$validation;
             //$rules->add_callbacks('new_password', array($this, '_strong_pwd'));
             $this->formSave($this->user);
         }
     }
     $this->view->old_password = '';
     // Since the confirm_password doesnt exist in the table handle it specially
     $this->view->confirm_password = $this->confirm_password;
     // The password will returned hashed and we need plain text....
     $this->view->new_password = $this->new_password;
     // Set our own view variables from the DB records.
     $this->view->user = $this->user;
     // Execute plugin hooks here, after we've loaded the core data sets
     plugins::views($this);
 }
Пример #11
0
$validator = new Validator();
if (isset($_POST['submit'])) {
    $validator->add_rule('contactname', 'Name', 'required');
    $validator->add_rule('email', 'Email', 'required|email');
    $validator->add_rule('message', 'Message', 'required|min(5)');
    $validator->custom_message('email', 'required', "Please enter your email, this will only be used to respond to your message");
    $validator->custom_message('email', 'email', "Please enter a valid email, this will only be used to respond to your message");
    if ($validator->run() == true) {
        $email = new Email(array('to' => c::get('site_email'), 'from' => 'Aurer emailer <*****@*****.**>', 'subject' => $validator->get_value('subject', 'Response from the Aurer site'), 'body' => $validator->get_value('contactname') . " sent you a message\n\n" . $validator->get_value('message') . "\n\n" . $validator->get_value('email'), 'service' => 'mailgun', 'options' => array('key' => c::get('mailgun_key'), 'domain' => c::get('mailgun_domain'))));
        if ($email->send()) {
            s::set('email_sent', true);
            go($page->url());
        } else {
            s::set('email_sent', false);
            message::set('mail_error', 'It appears your message cannot be sent right now, many appologies.', 'error');
            go($page->url());
        }
    }
}
?>

<?php 
echo snippet('header');
?>

<div class="section section--contact">
	<div class="section-inner">
		<h1><?php 
echo html($page->title());
?>
Пример #12
0
 /**
  * This function preforms the default restful delete,
  * extend this class and redefine if you need different behavoir.
  *
  * @return void
  */
 public function restfulDelete()
 {
     $errorOccured = FALSE;
     kohana::log('debug', 'Attempting a RESTful delete');
     if (empty($_POST['id'])) {
         message::set('No rows where specified for delete', array('type' => 'alert'));
         return;
     }
     $delIDs = explode(',', $_POST['id']);
     $conn = Doctrine_Manager::connection();
     foreach ($delIDs as $delID) {
         $row = Doctrine::getTable($this->baseModel)->find($delID);
         if (!$row) {
             $errorOccured = TRUE;
             message::set('Unable to locate row ' . strtolower($this->baseModel) . ' id ' . $delID . '!');
             continue;
         }
         try {
             Bluebox_Record::setBaseSaveObject($row);
             $conn->beginTransaction();
             plugins::delete($row);
             $row->delete();
             $conn->commit();
             plugins::delete($row, array('custom' => Router::$controller . '.success', 'coreAction' => FALSE, 'core' => FALSE));
             Bluebox_Record::setBaseSaveObject(NULL);
         } catch (Exception $e) {
             $errorOccured = TRUE;
             message::set('Unable to delete ' . strtolower($this->baseModel) . ' id ' . $delID . '! ' . $e->getMessage());
         }
     }
     if (empty($errorOccured)) {
         message::set('Selected record(s) deleted.', array('type' => 'success'));
     }
 }
Пример #13
0
<?php

message::set('hello', 'Hello, World!');
message::set('fox', 'The quick brown fox jumps over the lazy dog.');
Пример #14
0
 protected function prepareUpdateView($baseModel = NULL)
 {
     $route_types = array();
     $trunkList = array();
     $interfaceList = array();
     $numbers = Doctrine_Query::Create()->select("Number.number_id,Number.number,Number.foreign_id")->from("Number,NumberPool,NumberType")->where("NumberType.class='ExternalXferNumber'")->andWhere("NumberType.number_type_id=NumberPool.number_type_id")->andWhere("NumberPool.number_id=Number.number_id");
     if ($this->externalxfer->external_xfer_id) {
         $numbers = $numbers->andWhere("(Number.class_type='' or Number.class_type IS NULL or Number.foreign_id=?)", $this->externalxfer->external_xfer_id);
     } else {
         $numbers = $numbers->andWhere("(Number.class_type='' or Number.class_type IS NULL )");
     }
     $numbers = $numbers->orderBy('Number.number')->execute(array(), Doctrine::HYDRATE_SCALAR);
     $this->view->numbers = array();
     $this->view->numberdefault = NULL;
     $matchcount = 0;
     foreach ($numbers as $number) {
         $this->view->numbers[$number['Number_number_id']] = $number['Number_number'];
         if ($this->externalxfer->external_xfer_id == $number['Number_foreign_id']) {
             $this->view->numberdefault = $number['Number_number_id'];
             $matchcount++;
         }
     }
     if ($matchcount > 1) {
         message::set('This record cannot be edited, due to having multiple numbers');
         $this->returnQtipAjaxForm(NULL);
         url::redirect(Router_Core::$controller);
     }
     if (class_exists('Trunk')) {
         $trunks = Doctrine::getTable('Trunk')->findAll(Doctrine::HYDRATE_ARRAY);
         foreach ($trunks as $trunk) {
             $trunkList[$trunk['trunk_id']] = $trunk['name'];
         }
         if (!empty($trunkList)) {
             $route_types[ExternalXfer::TYPE_TRUNK] = 'via Trunk';
         }
     }
     if (class_exists('SipInterface')) {
         $interfaces = Doctrine::getTable('SipInterface')->findAll(Doctrine::HYDRATE_ARRAY);
         foreach ($interfaces as $interface) {
             $interfaceList[$interface['sipinterface_id']] = $interface['name'];
         }
         if (!empty($interfaceList)) {
             $route_types[ExternalXfer::TYPE_SIP] = 'via SIP URI';
         }
     }
     if (empty($route_types)) {
         message::set('No Trunk or Sip Interfaces avaliable to route external destinations through!');
         $this->returnQtipAjaxForm(NULL);
         url::redirect(Router_Core::$controller);
     }
     if (empty($numbers)) {
         message::set('No extensions available!');
         $this->returnQtipAjaxForm(NULL);
         url::redirect(Router_Core::$controller);
     }
     $this->view->trunks = $trunkList;
     $this->view->interfaces = $interfaceList;
     $this->view->route_types = $route_types;
     parent::prepareUpdateView($baseModel);
 }
Пример #15
0
 public function create()
 {
     $reqPath = '';
     if (isset($_POST['path']) and isset($_POST['newfolder'])) {
         $reqPath = $_POST['path'];
         $path = Media::getMediaPath() . $reqPath;
         kohana::log('debug', 'Creating ' . $path . DIRECTORY_SEPARATOR . $_POST['newfolder']);
         if ($this->createFolder($path . DIRECTORY_SEPARATOR . $_POST['newfolder'])) {
             message::set('Folder created.');
             url::redirect(Router_Core::$controller . '/index');
         } else {
             message::set('The path ' . $_POST['path'] . ' does not exist or could not be created! Does your web user have write access?');
         }
     }
     plugins::views($this);
     $this->view->soundPath = Media::getMediaPath();
     $this->view->reqPath = $reqPath;
 }
Пример #16
0
     if (in_array($key, array('page', 'messageId'))) {
         $_GET[$key] = misc::clean($value, 'numeric');
     } else {
         $_GET[$key] = misc::clean($value);
     }
 }
 switch ($_GET['action']) {
     case 'get':
         if (isset($_GET['messageId'])) {
             $msg = new message();
             $status = $msg->get($_GET['messageId']);
             if ($status == 'done') {
                 if ($msg->data['recipient'] == $_SESSION[$shortTitle . 'User']['id']) {
                     if (!$msg->data['viewed']) {
                         $msg->data['viewed'] = 1;
                         $msg->set();
                     }
                     $user = new user();
                     $status = $user->get('id', $msg->data['sender']);
                     if ($status == 'done') {
                         $msg->data['senderName'] = $user->data['name'];
                     } else {
                         $msg->data['senderName'] = $ui['game'];
                     }
                     $msg->data['body'] = str_replace("\r\n", "<br>", $msg->data['body']);
                     $msg->data['body'] = str_replace("\n", "<br>", $msg->data['body']);
                 } else {
                     $message = $ui['accessDenied'];
                 }
             } else {
                 $message = $ui[$status];
Пример #17
0
 public function finalizeInstall($identifier)
 {
     CallCenterManager::installFeatures();
     message::set('Default Features Installed', 'alert');
 }
Пример #18
0
 public function finalizeInstall()
 {
     callManager::installDefaultFunctions();
     message::set('Default Functions Installed', 'alert');
 }
Пример #19
0
 /**
  *
  *  blast
  * 	<user>@<domain> <sound_file> [<cid_num>] [<cid_name>]
  *  voicemail_inject is used to add an arbitrary sound file to a users voicemail mailbox.
  */
 public function blast()
 {
     $account_id = users::getAttr('account_id');
     $domain = VoicemailManager::getDomain($account_id);
     $this->view->mailboxes = VoicemailManager::getAllMailboxes();
     if ($this->input->post()) {
         if ($this->input->post('file_id') == 0) {
             message::set('Select a file to to use in the voicemail message');
         } else {
             foreach ($this->input->post('blast') as $mailbox) {
                 echo VoicemailManager::blast($mailbox, $domain, Media::getMediaFile($this->input->post('file_id')));
             }
         }
     }
 }
Пример #20
0
 public function save()
 {
     if (!class_exists('DOMDocument')) {
         message::set('This driver requires ' . html::anchor('http://us3.php.net/manual/en/class.domdocument.php', 'DOMDocument', array('target' => '_new')) . ' to be installed and active');
         return false;
     }
     // This array maps the telephony returns to the telephony file
     $telephonyOptions = array('cfg_root' => rtrim($this->session->get('installer.cfg_root'), '/'), 'audio_root' => rtrim($this->session->get('installer.audio_root'), '/'), 'ESLHost' => $this->session->get('installer.esl_host'), 'ESLPort' => $this->session->get('installer.esl_port'), 'ESLAuth' => $this->session->get('installer.esl_auth'));
     if (!is_dir($telephonyOptions['cfg_root'])) {
         message::set('Unable to access directory <pre>' . $telephonyOptions['cfg_root'] . '</pre>');
         return false;
     }
     if (!is_dir($telephonyOptions['audio_root'])) {
         message::set('Unable to access directory <pre>' . $telephonyOptions['audio_root'] . '</pre>');
         return false;
     }
     // Write $telephonyOptions to freeswitch.php
     if (!Installer_Controller::updateConfig($telephonyOptions, 'freeswitch')) {
         return false;
     }
     // Set the driver name in telephony.php
     if (!Installer_Controller::updateConfig(array('driver' => 'FreeSwitch'), 'telephony')) {
         return false;
     }
     // Reload the new telephony options so we can use the filemap
     Kohana::config_clear('freeswitch');
     Kohana::config_load('freeswitch');
     $filemaps = Kohana::config('freeswitch.filemap');
     $notWritable = array();
     foreach ($filemaps as $filemap) {
         if (!filesystem::is_writable($filemap['filename'])) {
             $notWritable[] = $filemap['filename'];
         }
     }
     if (!empty($notWritable)) {
         $notWritable = array_unique($notWritable);
         if (empty($this->template->error)) {
             message::set('Ensure the web server has write permission on these files, and SELINUX allows this action.' . '<div class="write_help">Unable to write to the following file(s):</div>' . '<div>' . arr::arrayToUL($notWritable, array(), array('class' => 'error_details', 'style' => 'text-align:left;')) . '</div>');
         }
         return false;
     }
     // Make sure that if the user changed the directory and any conflicts were found that the user
     // knows these will be deleted
     $existingProfiles = glob(rtrim($telephonyOptions['cfg_root'], '/') . '/sip_profiles/*.xml', GLOB_MARK);
     $oldXmlFiles = array();
     foreach ($filemaps as $filemap) {
         if (file_exists($filemap['filename'])) {
             $oldXmlFiles[] = $filemap['filename'];
         }
     }
     $conflictXmlFiles = $this->session->get('installer.conflictXmlFiles');
     foreach (array_unique(array_merge($existingProfiles, $oldXmlFiles)) as $existingFile) {
         if (!in_array($existingFile, $conflictXmlFiles)) {
             message::set('Conflicting configuration files will be permanently erased if you continue!');
             message::set('Click continue again to proceed...', 'alert');
             // This session var lets the user continue the second time around (after the warning)
             $this->session->set('installer.confirm_delete', true);
             return false;
         }
     }
     // If there are conflictXmlFile in the session then the user has seen this list
     // so they SHOULD be aware we are about to delete them... should
     $conflictXmlFiles = $this->session->get('installer.conflictXmlFiles');
     if (!empty($conflictXmlFiles) && is_array($conflictXmlFiles)) {
         $confirmDelete = $this->session->get('installer.confirm_delete', false);
         if (empty($confirmDelete)) {
             message::set('Conflicting configuration files will be permanently erased if you continue!');
             message::set('Click continue again to proceed...', 'alert');
             // This session var lets the user continue the second time around (after the warning)
             $this->session->set('installer.confirm_delete', true);
             return false;
         }
         foreach ($conflictXmlFiles as $conflictXmlFile) {
             if (!filesystem::delete($conflictXmlFile)) {
                 Kohana::log('error', 'Unable to unlink ' . $conflictXmlFile);
                 $unlinkErrors[] = $conflictXmlFile;
             }
         }
     }
     // If there are files that could not be deleted, inform the user
     if (!empty($unlinkErrors)) {
         message::set('Manually remove these files or change the file permissions.' . '<div class="write_help">Unable to delete incompatible file(s):</div>' . '<div>' . arr::arrayToUL($unlinkErrors, array(), array('class' => 'error_details', 'style' => 'text-align:left;')) . '</div>');
         return false;
     }
     $this->session->set('installer.default_packages', kohana::config('freeswitch.default_packages'));
     return true;
 }
Пример #21
0
 /**
  * Use this function to create a new account, location and user all in one shot. You will get an associative array back containing
  * the new account, location and user IDs, respectively
  * @param string $username
  * @param string $password
  * @param string $accountName
  * @param string $locationName
  * @return array
  *
  * TODO: Should we just pass in a list of options, and then pass it around accordingly?
  */
 public static function initializeTenant($options, $users = array())
 {
     // Add the core admin user to the system
     // TODO: Should check for errors here...
     Kohana::log('debug', 'Initializing account...');
     try {
         $accountId = self::initializeAccount($options['account']);
         self::$accountName = $options['account']['name'];
     } catch (Exception $e) {
         Kohana::log('error', 'Creating account failed: ' . $e->getMessage());
         // Bubble up
         throw $e;
     }
     Kohana::log('debug', 'Initializing location...');
     try {
         $locationId = self::initializeLocation($accountId, $options['location']);
     } catch (Exception $e) {
         Kohana::log('error', 'Creating location failed (rolling back tenant): ' . $e->getMessage());
         $account = Doctrine::getTable('Account')->find($accountId);
         $account->delete();
         self::$accountName = NULL;
         // Bubble up
         throw $e;
     }
     Kohana::log('debug', 'Initializing user...');
     try {
         $userId = self::initializeUser($accountId, $locationId, $options['user']);
     } catch (Exception $e) {
         Kohana::log('error', 'Creating user failed (rolling back tenant: ' . $e->getMessage());
         $location = Doctrine::getTable('Location')->find($locationId);
         $location->delete();
         $account = Doctrine::getTable('Account')->find($accountId);
         $account->delete();
         self::$accountName = NULL;
         // Bubble up
         throw $e;
     }
     Kohana::log('debug', 'Initializing contexts...');
     self::initializeContext($accountId);
     Kohana::log('debug', 'Scanning packages for tenant-setup routines.');
     Package_Catalog::buildCatalog();
     $packagelist = Package_Catalog::getPackageList();
     foreach ($packagelist as $name => $packages) {
         if (empty($packages[Package_Manager::STATUS_INSTALLED])) {
             continue;
         }
         $installed = reset($packages[Package_Manager::STATUS_INSTALLED]);
         try {
             $configureInstance = Package_Catalog::getPackageConfigureInstance($installed['identifier']);
             if (method_exists($configureInstance, 'createTenant')) {
                 $configureInstance->createTenant($package);
                 Kohana::log('debug', 'Multi-tenant initialization routine for ' . $package['packageName'] . ' complete');
             }
         } catch (Exception $e) {
             Kohana::log('error', 'Multi-tenant initialization routine createTenant failed on ' . $package['packageName'] . ': ' . $e->getMessage());
             message::set('Unable to initialize tenant!' . '<div class="error_details">' . $e->getMessage() . '</div>');
             self::$accountName = NULL;
             return false;
         }
     }
     Kohana::log('debug', 'Done creating tenant.');
     self::$accountName = NULL;
     self::$created = array('userId' => $userId, 'locationId' => $locationId, 'accountId' => $accountId);
     // You can get everything you need from here
     return array('userId' => $userId, 'locationId' => $locationId, 'accountId' => $accountId);
 }
Пример #22
0
 private function _freshInstall()
 {
     $defaultModules = Kohana::config('config.modules');
     Kohana::config_set('core.modules', $defaultModules);
     // Get the doctrine overlord
     $manager = Doctrine_Manager::getInstance();
     $conn = $manager->getCurrentConnection();
     try {
         // See if we can connect to the DB
         $conn->connect();
     } catch (Doctrine_Connection_Exception $e) {
         // We could connect earlier, hmmm....
         try {
             Doctrine::createDatabases();
         } catch (Exception $e) {
             // We cant resolve this issue without the user
             message::set('Unable to establish a connection to ' . $this->session->get('installer.dbName') . '! <div class="error_details">' . $e->getMessage() . '</div>');
             return FALSE;
         }
     }
     // See if the DB has any tables in it
     $tables = $conn->import->listTables();
     if (!empty($tables)) {
         // Yup, there are tables in our soon to be fresh install db, remove them
         try {
             $dsn = $conn->getOption('dsn');
             $dsn = $manager->parsePdoDsn($dsn);
             $tmpConn = $conn->getTmpConnection($dsn);
             $conn->close();
             $tmpConn->export->dropDatabase($dsn['dbname']);
             $tmpConn->export->createDatabase($dsn['dbname']);
             $manager->closeConnection($tmpConn);
             $conn->connect();
         } catch (Exception $e) {
             // We cant resolve this issue without the user
             message::set('Unable to recreate database ' . $this->session->get('installer.dbName') . '! <div class="error_details">' . $e->getMessage() . '</div>');
             return FALSE;
         }
     }
     $driver = $this->session->get('installer.tel_driver', 'none');
     kohana::log('debug', 'Installer running for driver ' . $driver);
     $packages = $this->session->get('installer.default_packages', array());
     $packages = arr::merge($this->minimumPackages, $packages, array($driver));
     try {
         $transaction = Package_Transaction::beginTransaction();
         foreach ($packages as $package) {
             try {
                 $identifier = Package_Catalog::getFirstAvaliablePackage($package);
                 $transaction->install($identifier);
             } catch (Exception $e) {
                 kohana::log('error', 'Error during initial install package selection: ' . $e->getMessage());
             }
         }
         $transaction->commit();
         Session::instance()->set('Bluebox_installer.created', Bluebox_Tenant::$created);
         return TRUE;
     } catch (Exception $e) {
         message::set('Installer Error!' . '<div class="error_details">' . $e->getMessage() . '</div>');
         return FALSE;
     }
 }
Пример #23
0
 protected function loadBaseModel($id = NULL, $baseModel = NULL)
 {
     if (is_null($baseModel)) {
         $baseModel = $this->baseModel;
     }
     // Short hand for the baseModel
     $base = strtolower($baseModel);
     if (is_null($id)) {
         $this->{$base} = new $baseModel();
     } else {
         $this->{$base} = Doctrine::getTable($baseModel)->find($id);
         // Was anything retrieved? If no, this may be an invalid request
         if (!$this->{$base}) {
             // Send any errors back to the index
             message::set('Unable to locate ' . ucfirst($baseModel) . ' id ' . $id . '!');
             $this->returnQtipAjaxForm(NULL);
             url::redirect(Router_Core::$controller);
         }
     }
     $this->view->set_global('base', $base);
     Event::run('bluebox.load_base_model', $this->{$base});
 }
Пример #24
0
    protected function prepareUpdateView($baseModel = NULL)
    {
        $route_types = array();

        $trunkList = array();

        $interfaceList = array();

	$xmppList = array();

        if (class_exists('Trunk'))
        {
            $trunks = Doctrine::getTable('Trunk')->findAll(Doctrine::HYDRATE_ARRAY);

            foreach($trunks as $trunk)
            {
                $trunkList[$trunk['trunk_id']] = $trunk['name'];
            }

            if (!empty($trunkList))
            {
                $route_types[ExternalXfer::TYPE_TRUNK] = 'via Trunk';
            }
        }

        if (class_exists('SipInterface'))
        {
            $interfaces = Doctrine::getTable('SipInterface')->findAll(Doctrine::HYDRATE_ARRAY);

            foreach($interfaces as $interface)
            {
                $interfaceList[$interface['sipinterface_id']] = $interface['name'];
            }

            if (!empty($interfaceList))
            {
                $route_types[ExternalXfer::TYPE_SIP] = 'via SIP URI';
            }
        }
	
	if (class_exists('Xmpp'))
	{
           $xmpp = Package_Catalog::getPackageByName('xmpp');
           if(isset($xmpp['installed']) && !empty($xmpp['installed']))// == Package_Manager::STATUS_INSTALLED)		
           {
	   	$xmpps = Doctrine::getTable('Xmpp')->findAll(Doctrine::HYDRATE_ARRAY);
	  
		   foreach($xmpps as $xmpp)
		   {
			$xmppList[$xmpp['xmpp_id']] = $xmpp['name'];
		   }

		   if(!empty($xmppList))
		   {
			$route_types[ExternalXfer::TYPE_XMPP] = 'via XMPP';
		   }
	   }
	}
        if (empty($route_types))
        {
            message::set('No Trunk, XMPP or Sip Interfaces avaliable to route external destinations through!');

            $this->returnQtipAjaxForm(NULL);

            url::redirect(Router_Core::$controller);
        }

        $this->view->trunks = $trunkList;

        $this->view->interfaces = $interfaceList;

	$this->view->xmpps = $xmppList;

        $this->view->route_types = $route_types;

        parent::prepareUpdateView($baseModel);
    }
Пример #25
0
 /**
  * Throws an error
  *
  * @return void
  */
 private function _throwError($errorMessage)
 {
     message::set("ESL {$errorMessage}", 'alert');
     throw new ESLException("ESL {$errorMessage}");
 }
Пример #26
0
 public function repair_all()
 {
     $this->template->content = new View('generic/blank');
     $catalog = Package_Manager::getDisplayList();
     if (empty($catalog['Installed'])) {
         return;
     }
     try {
         $transaction = Package_Transaction::beginTransaction();
         foreach ($catalog['Installed'] as $package) {
             $transaction->repair($package['identifier']);
         }
         $transaction->commit();
         message::set('Repair all operation completed', 'success');
     } catch (Exception $e) {
         message::set($e->getMessage());
     }
     url::redirect(Router::$controller);
 }
Пример #27
0
 public function finalizeInstall()
 {
     FeatureManager::installDefaultFeatures();
     message::set('Default Features Installed', 'alert');
 }
Пример #28
0
 function installFeatures()
 {
     CallCenterManager::installFeatures();
     message::set('Default Features Installed', 'alert');
     url::redirect(Router_Core::$controller);
 }