Exemplo n.º 1
0
 public static function createExtension()
 {
     Event::$data += array('voicemail_password' => self::generatePin(), 'voicemail_timezone' => kohana::config('locale.timezone'), 'voicemail_email_all_messages' => empty(Event::$data['user']['email_address']) ? 0 : 1, 'voicemail_delete_file' => 0, 'voicemail_attach_audio_file' => 1, 'voicemail_email_address' => empty(Event::$data['user']['email_address']) ? '' : Event::$data['user']['email_address']);
     extract(Event::$data);
     Doctrine::getTable('Voicemail')->getRecordListener()->get('MultiTenant')->setOption('disabled', TRUE);
     $name_append = '';
     if (!empty($owner_name)) {
         $name_append = ' for ' . $owner_name;
     }
     try {
         $voicemail = new Voicemail();
         $voicemail['name'] = 'VM ' . $extension . $name_append;
         $voicemail['mailbox'] = $extension;
         $voicemail['password'] = $voicemail_password;
         $voicemail['account_id'] = $account_id;
         $voicemail['plugins'] = array('timezone' => array('timezone' => $voicemail_timezone));
         $voicemail['registry'] = array('email_all_messages' => $voicemail_email_all_messages, 'delete_file' => $voicemail_delete_file, 'attach_audio_file' => $voicemail_attach_audio_file, 'email_address' => $voicemail_email_address);
         $voicemail->save();
         $plugin = array('voicemail' => array('mwi_box' => $voicemail['voicemail_id']));
         $device['plugins'] = arr::merge($device['plugins'], $plugin);
     } catch (Exception $e) {
         Doctrine::getTable('Voicemail')->getRecordListener()->get('MultiTenant')->setOption('disabled', FALSE);
         kohana::log('error', 'Unable to generate voicemail for device: ' . $e->getMessage());
         throw $e;
     }
     Doctrine::getTable('Voicemail')->getRecordListener()->get('MultiTenant')->setOption('disabled', FALSE);
 }
Exemplo n.º 2
0
 public static function genericVoicemail($account_id, $location_id, $user_id)
 {
     if (!class_exists('Voicemail')) {
         return FALSE;
     }
     $voicemail = new Voicemail();
     $voicemail['name'] = 'General voicemail box';
     $voicemail['mailbox'] = '2098';
     $voicemail['password'] = '******';
     $voicemail->save();
     try {
         $number = new Number();
         $number['user_id'] = $user_id;
         $number['number'] = '2098';
         $number['location_id'] = $location_id;
         $number['registry'] = array('ignoreFWD' => '0', 'ringtype' => 'ringing', 'timeout' => 20);
         $dialplan = array('terminate' => array('transfer' => 0, 'voicemail' => 0, 'action' => 'hangup'));
         $number['dialplan'] = $dialplan;
         $number['class_type'] = 'VoicemailNumber';
         $number['foreign_id'] = $voicemail['voicemail_id'];
         $context = Doctrine::getTable('Context')->findOneByName('Outbound Routes');
         $number['NumberContext']->fromArray(array(0 => array('context_id' => $context['context_id'])));
         $vm_numberType = Doctrine::getTable('NumberType')->findOneByClass('VoicemailNumber');
         if (empty($vm_numberType['number_type_id'])) {
             return FALSE;
         }
         $number['NumberPool']->fromArray(array(0 => array('number_type_id' => $vm_numberType['number_type_id'])));
         $number->save();
         return $number['number_id'];
     } catch (Exception $e) {
         kohana::log('error', 'Unable to initialize voicemail for auto-attendant: ' . $e->getMessage());
         throw $e;
     }
 }