Esempio n. 1
0
 private function update_connect_app($connect_app_sid)
 {
     if (!empty($connect_app_sid) && $this->tenant->id == VBX_PARENT_TENANT) {
         $account = OpenVBX::getAccount();
         /** @var Services_Twilio_Rest_ConnectApp $connect_app */
         $connect_app = $account->connect_apps->get($connect_app_sid);
         $required_settings = array('HomepageUrl' => site_url(), 'AuthorizeRedirectUrl' => site_url('/auth/connect'), 'DeauthorizeCallbackUrl' => site_url('/auth/connect/deauthorize'), 'Permissions' => array('get-all', 'post-all'));
         $updated = false;
         foreach ($required_settings as $key => $setting) {
             $app_key = Services_Twilio::decamelize($key);
             if ($connect_app->{$app_key} != $setting) {
                 $connect_app->{$app_key} = $setting;
                 $updated = true;
             }
         }
         if ($updated) {
             $connect_app->update(array('FriendlyName' => $connect_app->friendly_name, 'Description' => $connect_app->description, 'CompanyName' => $connect_app->company_name, 'HomepageUrl' => $required_settings['HomepageUrl'], 'AuthorizeRedirectUrl' => $required_settings['AuthorizeRedirectUrl'], 'DeauthorizeCallbackUrl' => $required_settings['DeauthorizeCallbackUrl'], 'Permissions' => implode(',', $required_settings['Permissions'])));
         }
     }
 }
Esempio n. 2
0
 private function setup_connect_app($settings)
 {
     try {
         $account = OpenVBX::getAccount($settings['twilio_sid'], $settings['twilio_token']);
         $connect_application = $account->connect_apps->get($settings['connect_application_sid']);
         if ($connect_application->sid == $settings['connect_application_sid']) {
             $site_url = site_url();
             if ($settings['rewrite_enabled']) {
                 $site_url = str_replace('/index.php', '', $site_url);
             }
             $required_settings = array('HomepageUrl' => $site_url, 'AuthorizeRedirectUrl' => $site_url . '/auth/connect', 'DeauthorizeCallbackUrl' => $site_url . '/auth/connect/deauthorize', 'Permissions' => array('get-all', 'post-all'));
             $updated = false;
             foreach ($required_settings as $key => $setting) {
                 $app_key = Services_Twilio::decamelize($key);
                 if ($connect_application->{$app_key} != $setting) {
                     $connect_application->{$app_key} = $setting;
                     $updated = true;
                 }
             }
             if ($updated) {
                 $connect_application->update(array('FriendlyName' => $connect_application->friendly_name, 'Description' => $connect_application->description, 'CompanyName' => $connect_application->company_name, 'HomepageUrl' => $required_settings['HomepageUrl'], 'AuthorizeRedirectUrl' => $required_settings['AuthorizeRedirectUrl'], 'DeauthorizeCallbackUrl' => $required_settings['DeauthorizeCallbackUrl'], 'Permissions' => implode(',', $required_settings['Permissions'])));
             }
         }
     } catch (Exception $e) {
         throw new InstallException($e->getMessage(), $e->getCode());
     }
 }