Exemple #1
0
 public function postTransactionCommit(Doctrine_Event $event)
 {
     Event::run('telephony.postTransactionCommit', Bluebox_Record::getBaseTransactionObject());
     // A transaction just ended - we write out any configuration information set by the telephony driver now.
     // THIS IS WHERE WE UPDATE VIA THE SWITCH-SPECIFIC DRIVER!
     if (Kohana::config('telephony.driver') && Kohana::config('telephony.diskoutput')) {
         if (!empty(self::$changedModels)) {
             Kohana::log('debug', 'Telephony -> Creating config from saved models in memory.');
             foreach (self::$changedModels as $change) {
                 Kohana::log('debug', 'Telephony -> Preparing to generate configurartion from ' . $change['action'] . ' of ' . get_class($change['record']) . ' ' . implode(', ', $change['identifier']) . ' with OID ' . $change['record']->getOid() . ' on base model ' . get_class($change['baseModel']));
             }
             // Figure out what models were touched and either set or delete based on the action that was done to them
             // NOTE: Make sure this occurs in the same order it occurred via Doctrine's transaction
             foreach (self::$changedModels as $change) {
                 if (!empty($change['baseModel'])) {
                     Bluebox_Record::setBaseSaveObject($change['baseModel']);
                 } else {
                     Kohana::log('alert', 'Telephony -> The record ' . get_class($change['record']) . ' did not have the baseModel set!');
                     continue;
                 }
                 switch ($change['action']) {
                     case 'update':
                     case 'insert':
                         Telephony::set($change['record'], $change['identifier']);
                         break;
                     case 'delete':
                         Telephony::delete($change['record'], $change['identifier']);
                         break;
                     default:
                         Kohana::log('debug', 'An unknown action (' . $change['action'] . ') was performed on model ' . get_class($change['record']));
                         break;
                 }
             }
             self::$changedModels = array();
             Telephony::save();
             // If configured, tell the telephony engine to reload it's configs immediately
             Telephony::commit();
             // Clear the telephony info in memory. This is important, because if someone is doing a bulk add or otherwise, things get crazy
             Telephony::reset();
         }
     }
 }
Exemple #2
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);
     }
 }
Exemple #3
0
 public function index()
 {
     $loadedModels = Doctrine::getLoadedModels();
     $driver = Telephony::getDriver();
     $driverName = get_class($driver);
     // If no driver is set, just return w/ FALSE.
     if (!$driver) {
         return FALSE;
     }
     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();
 }