Example #1
0
 protected function save_prepare(&$object)
 {
     if (!empty($_POST['pdnsdomain']['soa']['primary']) && !empty($_POST['pdnsdomain']['soa']['hostmaster'])) {
         $soaRecord = array();
         $soaRecord['name'] = $_POST['pdnsdomain']['name'];
         $soaRecord['type'] = 'SOA';
         $soaRecord['content'] = $_POST['pdnsdomain']['soa']['primary'] . ' ' . $_POST['pdnsdomain']['soa']['hostmaster'] . ' 0';
         $records = array('PdnsRecord' => array($soaRecord));
         $object->synchronizeWithArray($records);
     } else {
         $records = $this->input->post('pdnsrecord', array());
         foreach ($records as $key => $record) {
             if ($record['type'] == 'SOA') {
                 $records[$key]['name'] = $_POST['pdnsdomain']['name'];
             } else {
                 if (empty($record['name'])) {
                     unset($records[$key]);
                     continue;
                 }
                 $records[$key]['name'] .= '.' . $_POST['pdnsdomain']['name'];
             }
             if (empty($record['prio'])) {
                 $records[$key]['prio'] = 0;
             }
             if (empty($record['ttl'])) {
                 $records[$key]['ttl'] = 600;
             }
         }
         // sync the group members with the group
         $object->PdnsRecord->synchronizeWithArray($records);
     }
     parent::save_prepare($object);
 }
Example #2
0
 protected function save_prepare(&$object)
 {
     $object['user_type'] = User::TYPE_NORMAL_USER;
     $object['location_id'] = $_POST['number']['location_id'];
     Doctrine_Manager::connection()->beginTransaction();
     parent::save_prepare($object);
 }
Example #3
0
 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);
 }
Example #4
0
    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);
    }
Example #5
0
 protected function save_prepare(&$mediafile)
 {
     if (!strcasecmp(Router::$method, 'create')) {
         if ($error = $mediafile->prepare_upload()) {
             Bluebox_Controller::$validation->add_error('mediafile[upload]', $error);
             throw new Bluebox_Exception('Upload error ' . $error);
         }
     }
     parent::save_prepare($object);
 }
Example #6
0
 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);
 }
Example #7
0
    protected function save_prepare(&$object)
    {
        // get a unique list of networks
        $netListItems = $this->input->post('ips', array());

        if (!empty($netListItems))
        {
            $netListItems += array(
                'allow' => array(),
                'deny' => array()
            );

            // make each value a subarray with record and allow keys
            array_walk($netListItems['allow'], create_function('&$v,$k', '$v = array("record" => $v, "allow" => TRUE);'));

            array_walk($netListItems['deny'], create_function('&$v,$k', '$v = array("record" => $v, "allow" => FALSE);'));

            $netListItems = array_merge($netListItems['allow'], $netListItems['deny']);
        }

        $netListItems = array('NetListItem' => $netListItems);

        // incorporate the array into the the netlist
        $this->netlist->markModified('name');

        $this->netlist->synchronizeWithArray($netListItems);

        parent::save_prepare($object);
    }
Example #8
0
 protected function save_prepare(&$object)
 {
     Kohana::log('debug', print_r($_REQUEST, true));
     if (!empty($_REQUEST['create_class_type'])) {
         $object['class_type'] = $_REQUEST['create_class_type'];
     }
     if (!empty($_REQUEST['create_foreign_id'])) {
         $object['foreign_id'] = $_REQUEST['create_foreign_id'];
     }
     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'];
         }
     }
     Kohana::log('debug', $object->class_type);
     parent::save_prepare($object);
 }
Example #9
0
 protected function save_prepare(&$mediafile)
 {
     $eslManager = EslManager::getInstance();
     $result = $eslManager->api('module_exists mod_shout');
     $text = $eslManager->getResponse($result);
     if ($text == "false") {
         EslManager::getInstance()->reload('mod_shout');
     }
     if (!strcasecmp(Router::$method, 'create')) {
         if ($error = $mediafile->prepare_upload()) {
             Bluebox_Controller::$validation->add_error('mediafile[upload]', $error);
             throw new Bluebox_Exception('Upload error ' . $error);
         }
     }
     parent::save_prepare($object);
 }
Example #10
0
 protected function save_prepare(&$object)
 {
     if (!strcasecmp(Router::$method, 'create')) {
         Doctrine::getTable('Location')->getRecordListener()->get('MultiTenant')->setOption('disabled', TRUE);
         Doctrine::getTable('User')->getRecordListener()->get('MultiTenant')->setOption('disabled', TRUE);
         Doctrine::getTable('Context')->getRecordListener()->get('MultiTenant')->setOption('disabled', TRUE);
         // Skip this stuff if just an edit.
         if (!$object->account_id) {
             // TODO: This should be done by the plugins but there is no way to ensure
             // execution order and location must come first....
             $location = $this->input->post('location', array());
             $object['Location']->fromArray(array($location));
             $user = $this->input->post('user', array());
             $object['Location'][0]['User']->fromArray(array($user));
             $object['Location'][0]['User'][0]['user_type'] = User::TYPE_ACCOUNT_ADMIN;
             // TODO: This could be done by the plugin but since the others are here
             // we will put this here too...
             $contexts = array();
             if (!empty($_POST['context']['private'])) {
                 $contexts[] = array('name' => empty($_POST['context']['private_name']) ? 'Outbound Routes' : $_POST['context']['private_name'], 'locked' => FALSE, 'registry' => array('type' => 'private'));
             }
             if (!empty($_POST['context']['public'])) {
                 $contexts[] = array('name' => empty($_POST['context']['public_name']) ? 'Inbound Routes' : $_POST['context']['public_name'], 'locked' => FALSE, 'registry' => array('type' => 'public'));
             }
             if (!empty($contexts)) {
                 $object['Context']->fromArray($contexts);
             }
         }
     }
     parent::save_prepare($object);
 }