Exemple #1
0
    protected function post_save(&$object)
    {
        $extension = $_POST['number']['number'];
        
        $context_id = $_POST['number']['context_id'];

        $location_id = $_POST['number']['location_id'];

        $external_cid = $_POST['callerid']['external_number'];

        $success = Bluebox_Tenant::createUserExtension($object['user_id'], $extension, $context_id, $location_id, array(
                'callerid_external_number' => $extension,
                'callerid_external_number' => $external_cid,
                'sip_password' => $_POST['user']['create_password']
            )
        );

        if (!$success)
        {
           Doctrine_Manager::connection()->rollback();           

           throw new Bluebox_Validation_Exception('Could not quick create!');
        }
        else
        {
            Doctrine_Manager::connection()->commit();
        }

        parent::post_save($object);
    }
Exemple #2
0
 public function add($data)
 {
     $this->auto_render = FALSE;
     self::authorize();
     switch ($data) {
         case 'extension':
             if (!($user_id = arr::get($_REQUEST, 'user_id'))) {
                 $user_id = 1;
             }
             $number = self::requireRequest('number');
             $extcid = self::requireRequest('ext_cid');
             $username = self::requireRequest('username');
             $password = self::requireRequest('password');
             $context_id = self::requireRequest('context_id');
             $user_id = self::requireRequest('user_id');
             $options = array('callerid_internal_number' => $number, 'callerid_external_number' => $extcid, 'sip_username' => $username, 'sip_password' => $password);
             Doctrine_Manager::connection()->beginTransaction();
             $success = Bluebox_Tenant::createUserExtension($user_id, $number, $context_id, NULL, $options);
             if (!$success) {
                 Doctrine_Manager::connection()->rollback();
                 self::throwErrorAndDie('Could not add extension');
             } else {
                 Doctrine_Manager::connection()->commit();
             }
             self::returnSuccessAndDie("Added extension");
             break;
         case 'trunk':
             $name = self::requireRequest('name');
             $server = self::requireRequest('server');
             $username = self::requireRequest('username');
             $password = self::requireRequest('password');
             $interface_id = self::requireRequest('interface_id');
             $contexts = array_fill_keys(explode(',', self::requireRequest('contexts')), '1');
             $register = self::requireRequest('register');
             $cid_name = self::requireRequest('cid_name');
             $cid_number = self::requireRequest('cid_number');
             $pattern_ids = explode(',', self::requireRequest('pattern_ids'));
             $prepends = explode(',', self::requireRequest('prepends'));
             $account_id = self::requireRequest('account_id');
             foreach ($pattern_ids as $index => $pattern_id) {
                 $patterns[$pattern_id]['enabled'] = 1;
                 if (($prepend = arr::get($prepends, $index)) === FALSE) {
                     $prepend = "";
                 }
                 $patterns[$pattern_id]['prepend'] = $prepend;
             }
             Doctrine_Manager::connection()->beginTransaction();
             $trunk = new Trunk();
             $trunk->synchronizeWithArray(array('name' => $name, 'type' => 'sip', 'server' => $server, 'plugins' => array('sip' => array('username' => $username, 'password' => $password, 'register' => $register, 'cid_format' => '1', 'caller_id_field' => 'rpid', 'sip_invite_format' => '1'), 'sipinterface' => array('sipinterface_id' => $interface_id), 'simpleroute' => array('patterns' => $patterns, 'contexts' => $contexts, 'caller_id_name' => $cid_name, 'caller_id_number' => $cid_number, 'continue_on_fail' => '1'))));
             $trunk->account_id = $account_id;
             $trunk->refreshRelated();
             $success = $trunk->save();
             if (!$success) {
                 Doctrine_Manager::connection()->rollback();
                 self::throwErrorAndDie('Could not add trunk');
             } else {
                 Doctrine_Manager::connection()->commit();
             }
             self::returnSuccessAndDie('Added trunk');
             break;
         default:
             self::throwErrorAndDie('Command not recognized');
             break;
     }
 }
Exemple #3
0
 /**
  * This step finalizes the installation (whatever that means)
  *
  * @return subview
  */
 private function finalize()
 {
     $subview = new View('installer/finalize');
     $this->template->title = __('Complete!');
     $this->template->allowPrev = FALSE;
     $this->template->allowNext = FALSE;
     // Force a login of the master/admin user for the remainder of the install
     Auth::instance()->force_login($this->session->get('installer.adminEmailAddress'));
     users::isUserAuthentic();
     users::getCurrentUser();
     $created = $this->session->get('Bluebox_installer.created');
     Bluebox_Tenant::createUserExtension($created['userId']);
     if (Session::instance()->get('installer.samples', FALSE)) {
         $sampleUsers = array(array('first' => 'Peter', 'last' => 'Gibbons', 'username' => '*****@*****.**', 'password' => inflector::generatePassword(), 'user_type' => User::TYPE_NORMAL_USER), array('first' => 'Michael', 'last' => 'Bolton', 'username' => '*****@*****.**', 'password' => inflector::generatePassword(), 'user_type' => User::TYPE_NORMAL_USER), array('first' => 'Samir', 'last' => 'Nagheenanajar', 'username' => '*****@*****.**', 'password' => inflector::generatePassword(), 'user_type' => User::TYPE_NORMAL_USER), array('first' => 'Bill', 'last' => 'Lumbergh', 'username' => '*****@*****.**', 'password' => inflector::generatePassword(), 'user_type' => User::TYPE_NORMAL_USER), array('first' => 'Milton', 'last' => 'Waddams', 'username' => '*****@*****.**', 'password' => inflector::generatePassword(), 'user_type' => User::TYPE_NORMAL_USER));
         foreach ($sampleUsers as $sampleUser) {
             $userId = Bluebox_Tenant::initializeUser($created['accountId'], $created['locationId'], $sampleUser);
             Bluebox_Tenant::createUserExtension($userId);
         }
     }
     if ($this->session->get('installer.tel_driver') == 'freeswitch') {
         Event::run('freeswitch.reload.xml');
         Event::run('freeswitch.reload.acl');
         Event::run('freeswitch.reload.sofia');
     }
     self::_resetWizard();
     $this->session->delete('Bluebox_message');
     // Disable the installer after a successful installtion
     self::updateConfig(array('installer_enabled' => 'FALSE'), 'config');
     Kohana::log('info', 'Installer wizard terminated');
     return $subview;
 }