public function __construct() { parent::__construct(); javascript::add('editarea/edit_area_full.js'); javascript::add('featurecode.js'); stylesheet::add('featurecode.css'); }
protected function pre_save(&$object) { $errors = array(); libxml_use_internal_errors(TRUE); $cleaned = array(); foreach ($object['registry'] as $section => $xml) { $dom = new DOMDocument('1.0'); $dom->formatOutput = FALSE; if (strlen(trim($xml)) == 0) { kohana::log('debug', 'Section: ' . $section . ' Empty XML'); unset($cleaned[$section]); continue; } try { if ($dom->loadXML('<root>' . trim($xml) . '</root>')) { $cleaned[$section] = trim(str_replace('<?xml version="1.0"?>', '', $dom->saveXML())); kohana::log('debug', 'Section: ' . $section . ' Cleaned XML: ' . $dom->saveXML()); continue; } else { $errors[] = ucfirst($section); } } catch (Exception $e) { $errors[] = ucfirst($section); } } if (count($errors) > 0) { throw new Exception('Please correct the XML errors in these sections: ' . implode(', ', $errors)); } $object['registry'] = $cleaned; kohana::log('debug', 'Successfully validated XML'); parent::pre_save($object); }
/** * This constructor sets up session, pulls the current install wizard step and initializes the template * * @return void */ public function __construct() { if (!Kohana::config('config.installer_enabled')) { throw new Exception('The installer has been administratively disabled. (You can re-enable it in Bluebox/config/config.php)'); } Kohana::config_set('core.site_domain', Bluebox_Installer::guess_site_domain()); skins::setSkin($this->template); parent::__construct(); /** * TODO: Remove me when i18n is more stable */ $this->session->set('lang', 'en'); // Attempt to retrieve the current Step $this->currentStepKey = $this->session->get('installer.currentStepKey', 0); $this->currentStep = $this->steps[$this->currentStepKey]; // If this step is before the environment test the disable logging because we dont know if // kohana has write permissions on logs/ if ($this->currentStepKey > 1 && Kohana::config('core.log_threshold') == 0) { Kohana::config_set('core.log_threshold', $this->log_threshold); } // This is the default list of steps to run, modified to work with the wizard $this->pluginEvents = array('core' => Router::$controller, 'coreAction' => Router::$controller . '.' . $this->currentStep); if ($this->currentStep != 'finalize') { $this->_loadAllModules(); } else { Bluebox_Core::bootstrapPackages(TRUE); } }
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); }
public function qtipAjaxReturn($data) { if (!empty($data['time_of_day_id'])) { $object['numbermanager'] = array('object_name' => $data['name'], 'object_description' => 'Time Of Day', 'object_number_type' => 'TimeOfDayNumber', 'object_id' => $data['time_of_day_id'], 'short_name' => 'timeofday'); Event::run('ajax.updateobject', $object); } parent::qtipAjaxReturn($data); }
public function qtipAjaxReturn($data) { if (!empty($data['conference_id'])) { $object['numbermanager'] = array('object_name' => $data['name'], 'object_description' => 'Conference Bridge', 'object_number_type' => 'ConferenceNumber', 'object_id' => $data['conference_id'], 'short_name' => 'conference'); Event::run('ajax.updateobject', $object); } parent::qtipAjaxReturn($data); }
public function qtipAjaxReturn($data) { if (!empty($data['auto_attendant_id'])) { $object['numbermanager'] = array('object_name' => $data['name'], 'object_description' => 'Auto Attendant', 'object_number_type' => 'AutoAttendantNumber', 'object_id' => $data['auto_attendant_id'], 'short_name' => 'autoattendant'); Event::run('ajax.updateobject', $object); } parent::qtipAjaxReturn($data); }
public function qtipAjaxReturn($data) { if (!empty($data['device_id'])) { $object['numbermanager'] = array('object_name' => $data['name'], 'object_description' => str_replace('Device', ' Phone', $data['type']), 'object_number_type' => 'DeviceNumber', 'object_id' => $data['device_id'], 'short_name' => 'device'); Event::run('ajax.updateobject', $object); } parent::qtipAjaxReturn($data); }
public function qtipAjaxReturn($data) { if (!empty($data['external_xfer_id'])) { $object['numbermanager'] = array('object_name' => $data['name'], 'object_description' => 'External Transfer', 'object_number_type' => 'ExternalXferNumber', 'object_id' => $data['external_xfer_id'], 'short_name' => 'externalxfer'); Event::run('ajax.updateobject', $object); } parent::qtipAjaxReturn($data); }
public function prepareUpdateView() { $featurecodes = array(); foreach (Doctrine::getTable('CustomFeatureCode')->findAll(Doctrine::HYDRATE_ARRAY) as $customfeature) { $featurecodes[$customfeature['custom_feature_code_id']] = $customfeature['name']; } $this->view->featurecodes = $featurecodes; return parent::prepareUpdateView(); }
protected function deleteOnSubmit($base) { $currentuser = users::getCurrentUser(); if ($currentuser['user_type'] < $this->feature['ftr_edit_user_type']) { message::set('You do not have rights to delete this feature', 'alert'); url::redirect(Router_Core::$controller); } parent::deleteOnSubmit($base); }
public function prepareUpdateView() { $this->view->behind_nat = FALSE; if (!empty($this->sipinterface['nat_type'])) { $this->view->behind_nat = TRUE; } // This is not the best way to to do this but I am mimicing the // behavior that was already here if (Router::$method == 'add') { $this->sipinterface['nat_net_list_id'] = netlists::getSystemListId('nat.auto'); } parent::prepareUpdateView(); }
protected function save_succeeded(&$object) { $numbers = Doctrine::getTable('Number')->findAll(); foreach ($numbers as $number) { if (empty($number['dialplan']['terminate']['voicemail'])) { continue; } if ($number['dialplan']['terminate']['voicemail'] != $object['voicemail_id']) { continue; } $number->save(); } parent::save_succeeded($object); }
public function post_save($object) { foreach (Doctrine::getTable('FeatureCode')->findBy('custom_feature_code_id', $object['custom_feature_code_id']) as $featurecode) { print "feature code id = " . $featurecode['feature_code_id'] . "\n\n"; foreach (Doctrine::getTable('Number')->findBy('foreign_id', $featurecode['feature_code_id']) as $number) { if ($number['class_type'] == 'FeatureCodeNumber') { print "Number = " . $number['number'] . "\n\n"; $number->markModified('number'); $number->save(); } } } parent::post_save($object); }
public function number($number_id) { $this->loadBaseModel($number_id, 'Number'); $this->number->markModified('number'); try { $this->number->save(); message::set('Number "' . $this->number['number'] . '" rebuild complete!', 'success'); parent::save_succeeded($this->number); } catch (Exception $e) { message::set($e->getMessage()); } $this->returnQtipAjaxForm(); url::redirect(Router_Core::$controller); }
protected function delete_succeeded(&$object) { parent::delete_succeeded($object); $identifier = $object->identifier(); if (empty($identifier['simple_route_id'])) { return; } // One of those nasty but functionaly things... $trunks = Doctrine::getTable('Trunk')->findAll(); foreach ($trunks as $trunk) { if (empty($trunk['plugins']['simpleroute']['patterns'])) { continue; } if (!isset($trunk['plugins']['simpleroute']['patterns'][$identifier['simple_route_id']])) { $patterns = $trunk['plugins']['simpleroute']['patterns']; unset($patterns[$identifier['simple_route_id']]); $trunk['plugins']['simpleroute']['patterns'] = $patterns; } kohana::log('debug', 'Rebuilding trunk ' . $trunk['trunk_id'] . ' to remove simple route ' . $identifier['simple_route_id']); $trunk->save(); } }
protected function save_prepare(&$object) { $avaliableMemebers = array(); Event::run('ringgroup.avaliablemembers', $avaliableMemebers); $members = array(); foreach ($object['members'] as $key => $type) { Kohana::log('debug', 'Processing ' . $key . ' type members'); foreach ($type as $member) { if (empty($member['id'])) { continue; } $idFilter = create_function('$array', 'return ( $array[\'id\'] == ' . $member['id'] . ' && !strcmp($array[\'type\'],\'' . $key . '\'));'); $memberDetails = array_filter($avaliableMemebers, $idFilter); $memberDetails = reset($memberDetails); if (empty($memberDetails['bridge'])) { continue; } $members[] = array('bridge' => $memberDetails['bridge'], 'id' => $memberDetails['id'], 'type' => $memberDetails['type'], 'options' => array('ignore_early_media' => 'true')); } } $object['members'] = $members; parent::save_prepare($object); }
public function delete_succeeded(&$object) { Event::run('freeswitch.reload.dingaling'); parent::delete_succeeded($object); }
protected function delete_succeeded(&$object) { netlists::removeTrunkFromAuto($object); parent::delete_succeeded($object); }
protected function save_prepare(&$object) { $avaliableMemebers = array(); Event::run('ringgroup.avaliablemembers', $avaliableMemebers); $members = array(); foreach ($object['members'] as $key => $member) { if (empty($member['id'])) { continue; } $idFilter = create_function('$array', 'return ( $array[\'id\'] == ' .$member['id'] .');'); $memberDetails = array_filter($avaliableMemebers, $idFilter); $memberDetails = reset($memberDetails); if (empty($memberDetails['bridge'])) { continue; } $members[] = array( 'bridge' => $memberDetails['bridge'], 'id' => $memberDetails['id'], 'type' => $memberDetails['type'], 'options' => array( //'group_confirm_file' => '/path/to/prompt.wav', //'group_confirm_key' => 4, //'leg_timeout' => 60, 'ignore_early_media' => 'true' ) ); } $object['members'] = $members; parent::save_prepare($object); }
public function __construct() { parent::__construct(); $this->uploadPath = Kohana::config('upload.directory') . "/" . $this->session->get('user_id') . "/"; }
public function qtipAjaxReturn($data) { if ($data instanceof MediaFile) { $hide_rate = kohana::config('mediafile.hide_rate_folders'); $id = $data->filepath(TRUE, !$hide_rate); $catalog = MediaFile::catalog(); $value = $catalog[$id]; jquery::addPlugin('growl'); Session::instance()->get_once('bluebox_message', array()); javascript::codeBlock(' $(\'#media_widget_file_list\') .prepend($("<option></option>") .attr("selected", "selected") .attr("value", "' . $id . '") .text("' . $value . '")) .trigger("change"); '); } parent::qtipAjaxReturn($data); }
public function __construct() { parent::__construct(); stylesheet::add('callcenter_agents', 50); }
public function __construct() { /***************** * GENERAL SETUP * *****************/ // Guess at the baseModel name if none has been set. Use the controller's basename as the guess if (!$this->baseModel) { $this->baseModel = ucfirst(str_replace('_Controller', '', get_class())); } // Instantiate sessions $this->session = Session::instance(); if (!request::is_ajax()) { $this->session->set('ajax.base_controller', strtolower(Router::$controller)); $this->session->set('ajax.base_method', strtolower(Router::$method)); } // Instantiate internationalization $this->i18n = i18n::instance(); /** * TODO: This is so nasty... */ if (!empty($_POST['lang'])) { if (empty(i18n::$langs[$_POST['lang']])) { die; } $this->session->set('lang', $_POST['lang']); echo i18n::$langs[$_POST['lang']]; die; } // Create a static validator, if one does not already exist. By default we populate it with post variables // This will hold all errors that occur within Doctrine and provides easy access for the controller to grab those errors // Note carefully that this is intentionally a singleton - Doctrine does not otherwise know which controller is associated // with which record. This implies that your errors will get stacked up on top of each other, but since it's one controller // per run of Kohana, we should be OK here. You can also use Kohana's validation class methods here, too. // FIXME: This should be moved!!! self::$validation = new Validation($_POST); // Setup anything related to this website's pages rendering Event::run('bluebox.setup', $this); // Setup anything related to authenticating the user Event::run('bluebox.authenticate', $this); // Setup anything related to authorizing the user Event::run('bluebox.authorize', $this); /******************* * RENDERING SETUP * *******************/ // For safety, fail back to HTML if this is not set if (!defined('CONTENT_TYPE')) { // take all the URL elements used for routing and explode on / $pathParts = explode('/', Router::$current_uri); $content_type = 'html'; foreach ($pathParts as $part) { // see if there is an extension on each part $extension = pathinfo($part, PATHINFO_EXTENSION); // if we find a html, json, xml extension then save it, keeping the last found extension if (!empty($extension) && in_array(strtolower($extension), array('html', 'json', 'xml'))) { $content_type = strtolower($extension); } } define('CONTENT_TYPE', $content_type); } // Set the default template, viewName and failback view to use, based on the content type. // NOTE: It's perfectly fine to override this in the template setup hooks switch (CONTENT_TYPE) { case 'json': $this->viewParams['template'] = 'json/layout'; $this->viewParams['name'] = Router::$controller . '/json/' . Router::$method; $this->viewParams['fallback'] = 'NO CONTENT'; break; case 'xml': $this->viewParams['template'] = 'xml/layout'; $this->viewParams['name'] = Router::$controller . '/xml/' . Router::$method; $this->viewParams['fallback'] = '<xml><error>No Content</error></xml>'; break; default: if (request::is_ajax() or !empty($_REQUEST['qtipAjaxForm'])) { $this->viewParams['template'] = 'ajax'; } else { $this->viewParams['template'] = 'layout'; } $this->viewParams['name'] = Router::$controller . '/' . Router::$method; $this->viewParams['fallback'] = 'ERROR: There is no viewable content for this page'; break; } // NOTE: You can optionally set $viewFolder here to try an alternate folder for all views. // If the view doesn't exist, $viewFolder is ignored $this->viewParams['folder'] = ''; // Call all setup hooks related to content type. Event::run('bluebox.createtemplate.' . CONTENT_TYPE, $this); /******************** * PREPARE TEMPLATE * ********************/ $this->template = $this->viewParams['folder'] . $this->viewParams['template']; // Call our parent controller's constructor // NOTE: This prepares our view and converts $this->template into an object. // Changes to $this->viewParams['template'] are ignored past this point parent::__construct(); /******************* * PREPARE CONTENT * *******************/ if (CONTENT_TYPE == 'html') { // Initialize default HTML content $this->template->css = ''; $this->template->js = ''; $this->template->meta = ''; $this->template->header = ''; $this->template->footer = ''; // Set the page title $this->template->title = ucfirst(Router::$controller); if (Router::$method != 'index') { // Index is always a boring name, don't use it (but use everything else) $this->template->title .= ' -> ' . ucfirst(Router::$method); } } try { $this->template->content = new View($this->viewParams['folder'] . $this->viewParams['name']); } catch (Exception $e) { try { $this->template->content = new View($this->viewParams['name']); } catch (Exception $e) { $this->template->content = new View(); $this->template->body = $this->viewParams['fallback']; } } /******************** * FINALIZE CONTENT * ********************/ // Make it easier to get to and remember how to access the core view by setting up a reference to the template, called view $this->view =& $this->template->content; // Call the constructor's for all plugins registered plugins::construct(); // Setup anything related to authorizing the user Event::run('bluebox.ready', $this); }
public function prepareUpdateView() { $this->view->behind_nat = FALSE; if (!empty($this->sipinterface['nat_type'])) { $this->view->behind_nat = TRUE; } // This is not the best way to to do this but I am mimicing the // behavior that was already here if (Router::$method == 'add') { $this->sipinterface['nat_net_list_id'] = netlists::getSystemListId('nat.auto'); } $result = Doctrine::getTable('SipInterface')->findAll(Doctrine::HYDRATE_ARRAY); $options = array(); foreach ($result as $row) { if (!$row['auth']) { $options[$row['sipinterface_id']] = $row['name']; } } foreach ($result as $row) { if ($row['auth']) { $options[$row['sipinterface_id']] = $row['name']; } } $this->view->options = $options; parent::prepareUpdateView(); }
protected function pre_save(&$object) { if (get_class($object) == 'Endpoint') { $mac = strtolower(str_replace(array(' ', ':', '_', '\\', '/'), array(), $object['mac'])); if (strlen($mac) != 12) { throw new Exception("Invalid mac address - it should be 12 characters long, optionally with colons."); } if (preg_match('/^[0-9a-f]{12}$/', $mac) !== 1) { throw new Exception("Invalid mac address - it should contain only digits (0-9), letters a-f, and optionally colons."); } $object['mac'] = $mac; if (array_key_exists('lines', $_POST)) { $object['lines'] = serialize($_POST['lines']); } if (array_key_exists('buttons', $_POST)) { $settings = unserialize($object['settings']); if (!is_array($settings)) { $settings = array(); } $settings['buttons'] = $_POST['buttons']; $object->settings = serialize($settings); } } parent::pre_save($object); }
protected function save_prepare(&$object) { if (!empty($_POST['number']['class_type'])) { $registryVar = 'number_' . strtolower(str_replace('Number', '', $_POST['number']['class_type'])); if (!empty($_POST[$registryVar]['registry'])) { $object['registry'] = $_POST[$registryVar]['registry']; } } parent::save_prepare($object); }
protected function prepareUpdateView($baseModel = NULL) { $this->view->password = isset($_POST['user']['create_password']) ? $_POST['user']['create_password'] : ''; $this->view->confirm_password = isset($_POST['user']['confirm_password']) ? $_POST['user']['confirm_password'] : ''; parent::prepareUpdateView($baseModel); }
public function __construct() { parent::__construct(); stylesheet::add("directory.css"); }
protected function prepareUpdateView($baseModel = NULL) { if (!empty($_POST['pdnsdomain']['soa']['primary'])) { $this->view->primary = $_POST['pdnsdomain']['soa']['primary']; } else { $this->view->primary = ''; } if (!empty($_POST['pdnsdomain']['soa']['hostmaster'])) { $this->view->hostmaster = $_POST['pdnsdomain']['soa']['hostmaster']; } else { $this->view->hostmaster = ''; } // populate the keys $records = array(); foreach ($this->pdnsdomain->PdnsRecord as $record) { $record = $record->toArray(); $record['name'] = str_replace('.' . $this->pdnsdomain['name'], '', $record['name']); $records[$record['id']] = $record; } $this->view->records = $records; $this->view->recordTypes = $this->recordTypes; parent::prepareUpdateView($baseModel); }