Beispiel #1
0
 public static function dropdownUserType($data, $selected = NULL, $extra = '')
 {
     // standardize the $data as an array, strings default to the class_type
     if (!is_array($data)) {
         $data = array('name' => $data);
     }
     // add in all the defaults if they are not provided
     $data += array('nullOption' => FALSE);
     // append or insert the class
     $data = arr::update($data, 'class', 'user_type_dropdown');
     // render a null option if its been set in data
     if (!empty($data['nullOption'])) {
         $options = array(0 => $data['nullOption']);
     } else {
         $options = array();
     }
     unset($data['nullOption']);
     $userTypes = self::getUserTypes();
     foreach ($userTypes as $userType => $displayName) {
         if ($userType <= users::getAttr('user_type')) {
             $options[$userType] = $displayName;
         }
     }
     // use kohana helper to generate the markup
     return form::dropdown($data, $options, $selected, $extra);
 }
Beispiel #2
0
 public static function echo_test()
 {
     $featureCode = new FeatureCode();
     $featureCode['name'] = 'Echo Test';
     $featureCode['registry'] = array('feature' => 'echo');
     $featureCode->save();
     try {
         $location = Doctrine::getTable('Location')->findAll();
         if (!$location->count()) {
             throw Exception('Could not find location id');
         }
         $location_id = arr::get($location, 0, 'location_id');
         $number = new Number();
         $number['user_id'] = users::getAttr('user_id');
         $number['number'] = '9999';
         $number['location_id'] = $location_id;
         $number['registry'] = array('ignoreFWD' => '0', 'ringtype' => 'ringing', 'timeout' => 20);
         $dialplan = array('terminate' => array('transfer' => 0, 'voicemail' => 0, 'action' => 'hangup'));
         $number['dialplan'] = $dialplan;
         $number['class_type'] = 'FeatureCodeNumber';
         $number['foreign_id'] = $featureCode['feature_code_id'];
         $context = Doctrine::getTable('Context')->findOneByName('Outbound Routes');
         $number['NumberContext']->fromArray(array(0 => array('context_id' => $context['context_id'])));
         $numberType = Doctrine::getTable('NumberType')->findOneByClass('FeatureCodeNumber');
         if (empty($numberType['number_type_id'])) {
             return FALSE;
         }
         $number['NumberPool']->fromArray(array(0 => array('number_type_id' => $numberType['number_type_id'])));
         $number->save();
         return $number['number_id'];
     } catch (Exception $e) {
         kohana::log('error', 'Unable to initialize device number: ' . $e->getMessage());
         throw $e;
     }
 }
Beispiel #3
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('/');
     }
 }
Beispiel #4
0
 public function login($userId)
 {
     if (users::getAttr('user_type') == User::TYPE_SYSTEM_ADMIN) {
         users::masqueradeUser($userId);
         url::redirect('/');
     } else {
         Event::run('system.404');
         die;
     }
 }
Beispiel #5
0
 public function index()
 {
     stylesheet::add('callcenter');
     javascript::add('callcenter');
     javascript::add('jquery-ui-1-7-2-custom');
     // Prepare device info for use
     $device_info = array();
     $location_id = users::getAttr('location_id');
     $location = Doctrine::getTable('Location')->findOneBy('location_id', $location_id);
     foreach ($location['User'] as $user) {
         foreach ($user['Device'] as $device) {
             $device_info[] = array('name' => $device['name'], 'id' => $device['device_id']);
         }
     }
     $this->view->devices = $device_info;
     $this->view->domain = $location['domain'];
 }
Beispiel #6
0
 public static function maintenance()
 {
     kohana::log('debug', 'Preforming maintenance on the media files');
     $accountId = users::getAttr('account_id');
     if (!empty($accountId)) {
         $records = Doctrine::getTable('MediaFile')->findAll();
         foreach ($records as $record) {
             kohana::log('debug', 'the path is ' . $record->filepath(TRUE) . ' and does it exists? ' . is_file($record->filepath(TRUE)));
             //if (!file_exists($record->filepath(TRUE)))
             if (!is_file($record->filepath(TRUE))) {
                 //kohana::log('debug', 'mediafile_id to be deleted :'.$record->filepath(TRUE));
                 kohana::log('debug', 'The mediafile_id ' . $record['mediafile_id'] . ' no longer exists...');
                 $record->delete();
             }
         }
     } else {
         kohana::log('debug', 'Account_ID Empty or Invalid, canceling the maintenance on the media files');
     }
 }
Beispiel #7
0
 public function createSubGrid()
 {
     $subview = new View('generic/grid');
     $subview->tab = 'main';
     $subview->section = 'general';
     // Setup the base grid object
     $grid = jgrid::grid('User', array('caption' => 'Users'));
     // If there is a base model that contains an account_id,
     // then we want to show locations only that relate to this account
     $base = $this->getBaseModelObject();
     if ($base and !empty($base['location_id'])) {
         // Set a where clause, if we're playing plug-in to someone else
         $grid->where('location_id = ', $base['location_id']);
     } else {
         if ($base and !empty($base['account_id'])) {
             // Set a where clause, if we're playing plug-in to someone else
             $grid->where('account_id = ', $base['account_id']);
         }
     }
     // Add the base model columns to the grid
     $grid->add('user_id', 'ID', array('hidden' => TRUE, 'key' => TRUE));
     $grid->add('email_address', 'Email Address');
     $grid->add('first_name', 'First Name', array('width' => '100', 'search' => TRUE));
     $grid->add('last_name', 'Last Name', array('width' => '100', 'search' => TRUE));
     $grid->add('Location/name', 'Location', array('hidden' => empty($base['location_id']) ? TRUE : FALSE, 'width' => '100', 'search' => TRUE, 'sortable' => TRUE));
     $grid->add('user_type', 'User Type', array('callback' => array('function' => array($this, 'userType'), 'arguments' => array('user_type'))));
     $grid->add('logins', 'Logins', array('hidden' => TRUE));
     $grid->add('last_login', 'Last Login', array('hidden' => TRUE));
     $grid->add('last_logged_ip', 'Last Logged IP', array('hidden' => TRUE));
     $grid->add('debug_level', 'Debug Level', array('hidden' => TRUE));
     // Add the actions to the grid
     $grid->addAction('usermanager/edit', 'Edit', array('arguments' => 'user_id', 'attributes' => array('class' => 'qtipAjaxForm')));
     $grid->addAction('usermanager/delete', 'Delete', array('arguments' => 'user_id', 'attributes' => array('class' => 'qtipAjaxForm')));
     if (users::getAttr('user_type') == User::TYPE_SYSTEM_ADMIN) {
         $grid->addAction('usermanager/login', 'Login', array('arguments' => 'user_id'));
     }
     // Produces the grid markup or JSON
     $subview->grid = $grid->produce();
     $subview->gridMenu = html::anchor('/usermanager/create', '<span>Add New User</span>', array('class' => 'qtipAjaxForm'));
     // Add our view to the main application
     $this->views[] = $subview;
 }
Beispiel #8
0
 public function allow($controller, $method, $options = array())
 {
     $userID = users::getAttr('user_id');
     $permission = Doctrine_Query::create()->select('p.permission')->from('Permission p')->where('p.user_id = ?', array($userID))->andWhere('p.controller = ?', array($controller))->andWhere('p.method = ?', array($method))->execute(array(), Doctrine::HYDRATE_SINGLE_SCALAR);
     if (empty($permission)) {
         $permission = Doctrine_Query::create()->select('p.permission')->from('Permission p')->where('p.user_id = ?', array($userID))->andWhere('p.controller = ?', array($controller))->execute(array(), Doctrine::HYDRATE_SINGLE_SCALAR);
     }
     switch ($permission) {
         case 'location':
         case 'owner':
             return $permission;
             break;
         case 'custom':
         case 'disabled':
             return FALSE;
             break;
         default:
             return TRUE;
             break;
     }
 }
Beispiel #9
0
 public function inform($hash = NULL)
 {
     $error = $this->session->get($hash, '');
     $report['issue'] = empty($_POST['report']['issue']) ? '' : $_POST['report']['issue'];
     $report['while'] = empty($_POST['report']['while']) ? '' : $_POST['report']['while'];
     $report['contact'] = empty($_POST['report']['contact']) ? users::getAttr('email_address') : $_POST['report']['contact'];
     $report['error'] = empty($_POST['report']['error']) ? $error : $_POST['report']['error'];
     $report['log'] = isset($_POST['report']['log']) ? $_POST['report']['log'] : TRUE;
     if ($action = $this->submitted(array('submitString' => 'Send'))) {
         if ($action == self::SUBMIT_CONFIRM and $this->submitReport($report)) {
             message::set('Request was submitted, you will receive emails as we update your support request.  Thank you.', 'success');
             $this->returnQtipAjaxForm(NULL);
             url::redirect(Router_Core::$controller . '/thankYou');
         } else {
             if ($action == self::SUBMIT_DENY) {
                 $this->exitQtipAjaxForm();
             }
         }
     }
     $this->view->report = $report;
 }
Beispiel #10
0
 public function account($account_id = NULL, $redirect = TRUE)
 {
     if ($account_id && users::masqueradeAccount($account_id)) {
         $masquerade_account = TRUE;
     }
     $loadedModels = Doctrine::getLoadedModels();
     $driver = Telephony::getDriver();
     $driverName = get_class($driver);
     if (!$driver) {
         message::set('Can not rebuild configuration, no telephony driver active');
     } else {
         try {
             foreach ($loadedModels as $model) {
                 $modelDriverName = $driverName . '_' . $model . '_Driver';
                 if (!class_exists($modelDriverName, TRUE)) {
                     continue;
                 }
                 $outputRows = Doctrine::getTable($model)->findAll();
                 foreach ($outputRows as $outputRow) {
                     Telephony::set($outputRow, $outputRow->identifier());
                 }
             }
             Telephony::save();
             Telephony::commit();
             $account = Doctrine::getTable('Account')->find(users::getAttr('account_id'));
             parent::save_succeeded($account);
             message::set(users::getAttr('Account', 'name') . ' configuration rebuild complete!', 'success');
         } catch (Exception $e) {
             message::set($e->getMessage());
         }
     }
     if (!empty($masquerade_account)) {
         users::restoreAccount();
     }
     $this->returnQtipAjaxForm();
     if ($redirect) {
         url::redirect(Router_Core::$controller);
     }
 }
Beispiel #11
0
 public function filepath($full = FALSE, $actual = TRUE)
 {
     $basepath = kohana::config('upload.directory');
     $basepath = rtrim($basepath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . users::getAttr('account_id');
     Event::run('mediafile.basepath', $basepath);
     $filepath = rtrim($basepath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
     if ($this->get('path')) {
         $filepath .= rtrim($this->get('path'), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
     }
     if (!$actual and kohana::config('mediafile.hide_rate_folders')) {
         $default_rates = kohana::config('mediafile.default_rates');
         $default_rates[] = trim(kohana::config('mediafile.unknown_rate_folder'), DIRECTORY_SEPARATOR);
         foreach ($default_rates as &$value) {
             $value = DIRECTORY_SEPARATOR . $value . DIRECTORY_SEPARATOR;
         }
         $filepath = str_replace($default_rates, DIRECTORY_SEPARATOR, $filepath);
     }
     if ($full) {
         $filepath .= $this->get('file');
     }
     return $filepath;
 }
Beispiel #12
0
echo form::input('user[confirm_password]', isset($confirm_password) ? $confirm_password : NULL);
?>
        </div>

    <?php 
echo form::close_section();
?>

    <?php 
if (isset($views)) {
    echo subview::render($views);
}
?>

    <?php 
if (users::getAttr('user_type') == User::TYPE_SYSTEM_ADMIN) {
    ?>

        <?php 
    jquery::addPlugin('spinner');
    ?>
    
        <?php 
    echo form::open_section('Debug');
    ?>

            <div class="field">
            <?php 
    echo form::label('user[debug_level]', 'UI Level:');
    echo form::input('user[debug_level]');
    javascript::codeBlock('$("#user_debug_level").spinner({max: 4, min: 0});');
Beispiel #13
0
                    </div>

                </div>

            </div>
            <!-- END OF CONTENT -->

            <div class="footer">

            </div>
            <!-- END OF FOOTER -->

        </div>
        <?php 
if (class_exists('DashManager', TRUE) && users::getAttr('user_id')) {
    echo DashManager::renderDialogs();
}
?>
        <?php 
javascript::renderCodeBlocks();
?>
    </body>
</html>

<?php 
if (Kohana::config('core.render_stats') === TRUE) {
    ?>
<!-- Kohana Version: {kohana_version} -->
<!-- Kohana Codename: {kohana_codename} -->
<!-- Execution Time: {execution_time} -->
Beispiel #14
0
    <body id="bluebox-com">
    <?php 
echo $header;
?>
    <div class="container">

        <div class="header">

            <div class="topbar">

                <?php 
if (users::getAttr('user_id')) {
    ?>
                    <div>
                        Welcome <?php 
    echo users::getAttr('full_name');
    ?>
!
                    </div>
                                        <div class="quiet"><?php 
    echo html::anchor('user/logout', 'logout');
    ?>
</div>
                <?php 
}
?>
            </div>


            <div class="bottom hide">&nbsp;</div>
Beispiel #15
0
javascript::renderCodeBlocks();
?>
    </body>
</html>

<?php 
if (Kohana::config('core.render_stats') === TRUE) {
    ?>
<!-- Kohana Version: {kohana_version} -->
<!-- Kohana Codename: {kohana_codename} -->
<!-- Execution Time: {execution_time} -->
<!-- Memory Usage: {memory_usage} -->
<!-- Included Files: {included_files} -->
<!-- User ID: <?php 
    echo users::getAuthenticAttr('user_id');
    ?>
 -->
<!-- Account ID: <?php 
    echo users::getAuthenticAttr('account_id');
    ?>
 -->
<!-- Masq User ID: <?php 
    echo users::getAttr('user_id');
    ?>
 -->
<!-- Masq Accoutn ID: <?php 
    echo users::getAttr('user_id');
    ?>
 -->
<?php 
}
 public function getUserId()
 {
     return users::getAttr('Account', 'account_id');
 }
Beispiel #17
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')));
             }
         }
     }
 }
Beispiel #18
0
    <?php 
echo $header;
?>
    <div class="container">

        <div class="header">

            <div class="topbar">

                <?php 
if (users::getAttr('user_id')) {
    ?>

                    <?php 
    echo __('Welcome') . ' ' . users::getAttr('full_name');
    ?>
                    <?php 
    echo html::anchor('user/logout', __('Logout'));
    ?>

                <?php 
}
?>
                
            </div>


            <div class="bottom">&nbsp;</div>

        </div>
Beispiel #19
0
$swdb->where('account_id', users::getAttr('account_id'));
$result = $swdb->get();
$DeviceRows = $result->as_array();
$swdb->from('trunk');
$swdb->select('name,trunk_id,server,plugins');
$swdb->where('account_id', users::getAttr('account_id'));
$result = $swdb->get();
$TrunkRows = $result->as_array();
$swdb->from('voicemail');
$swdb->select('name,voicemail_id,mailbox');
$swdb->where('account_id', users::getAttr('account_id'));
$result = $swdb->get();
$VoircemailRows = $result->as_array();
$swdb->from('context');
$swdb->select('context_id,account_id');
$swdb->where('account_id', users::getAttr('account_id'));
$result = $swdb->get();
$ContextRows = $result->as_array();
$DevListHeight = count($DeviceRows) * 80;
if ($DevListHeight < 500) {
    $DevListHeight = 500;
}
?>
<style>

.calldividercall{background: url('<?php 
echo url::base();
?>
modules/switchboard-1.0/assets/images/connectgreen.gif');float:left;height:100px;width: 26px;}
.calldividertrunk{
	background: url('<?php 
Beispiel #20
0
 protected function post_save(&$object)
 {
     if (!strcasecmp(Router::$method, 'create')) {
         $object['Location'][0]['User'][0]['account_id'] = $object['account_id'];
         $object['Location'][0]['User'][0]->save();
         Doctrine::getTable('Location')->getRecordListener()->get('MultiTenant')->setOption('disabled', FALSE);
         Doctrine::getTable('User')->getRecordListener()->get('MultiTenant')->setOption('disabled', FALSE);
         Doctrine::getTable('Context')->getRecordListener()->get('MultiTenant')->setOption('disabled', FALSE);
         if (!empty($object['account_id'])) {
             $users_account_id = users::getAttr('account_id');
             users::masqueradeAccount($object['account_id']);
             // Initialize sample data
             Event::run('bluebox.account.initialize', $object);
             users::masqueradeAccount($users_account_id);
         }
     }
     parent::post_save($object);
 }