public function create() { if (users::getAttr('user_type') != User::TYPE_SYSTEM_ADMIN) { message::set('You are not authorized to add an account!'); $this->returnQtipAjaxForm(NULL); url::redirect(Router::$controller); } else { users::restoreAccount(); } parent::create(); }
public static function cleanup() { if (users::isAuthentic('account_id')) { return; } if (!users::isAuthentic('user_id')) { return; } $baseController = Session::instance()->get('ajax.base_controller', ''); if (strcasecmp($baseController, 'accountmanager')) { kohana::log('debug', 'Account manager is restoring the account masquerade'); users::restoreAccount(); } }
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); } }