public function flush() { flush_minify_caches(); $this->cache->flush(); $this->api_cache->flush(); $this->session->set_flashdata('error', 'Caches Flushed'); redirect('/settings/site#about'); }
private function update_site() { $data = array('message' => '', 'error' => false); $site = $this->input->post('site'); $process_app = false; $process_connect_app = false; $notification_settings = array('email_notifications_voice', 'email_notifications_sms'); if (!empty($site)) { try { foreach ($site as $name => $value) { if (in_array($name, $notification_settings)) { continue; } if ($name == 'application_sid') { $app_sid = $value; $process_app = true; } if ($name == 'connect_application_sid') { $connect_app_sid = $value; $process_connect_app = true; } // add new settings if they don't already exist if (!$this->settings->set($name, trim($value), $this->tenant->id)) { $this->settings->add($name, trim($value), $this->tenant->id); } } if ($this->form_action == 'site') { foreach ($notification_settings as $name) { $value = !empty($site[$name]) ? 1 : 0; $this->settings->add($name, $value, $this->tenant->id); } } // Connect App (if applicable) if ($process_connect_app) { $this->update_connect_app($connect_app_sid); } // Client App if ($process_app) { $this->update_application($app_sid); } $this->session->set_flashdata('error', 'Settings have been saved'); } catch (Exception $e) { $data['error'] = true; switch ($e->getCode()) { case '0': $data['message'] = $message = 'Could not Authenticate with Twilio. ' . 'Please check your Sid & Token values.'; break; default: $data['message'] = $message = $e->getMessage(); } $this->session->set_flashdata('error', $message); } } flush_minify_caches(); $returnSection = ''; switch ($this->form_action) { case 'account': $returnSection = '#twilio-account'; break; case 'theme': $returnSection = '#theme'; break; default: $returnSection = '#system-config'; } if ($this->response_type == 'html') { redirect('settings/site' . $returnSection); } $this->respond('', 'settings/site' . $returnSection, $data); }
private function update_site() { $data = array('message' => '', 'error' => false); $site = $this->input->post('site'); $process_app = false; $process_connect_app = false; $notification_settings = array('email_notifications_voice', 'email_notifications_sms'); if (!empty($site)) { try { foreach ($site as $name => $value) { if (in_array($name, $notification_settings)) { continue; } if ($name == 'application_sid') { $app_sid = $value; $process_app = true; } if ($name == 'connect_application_sid') { $connect_app_sid = $value; $process_connect_app = true; } // add new settings if they don't already exist if (!$this->settings->set($name, trim($value), $this->tenant->id)) { $this->settings->add($name, trim($value), $this->tenant->id); } } // rewrite enabled is a marker to detect which group of settings // we're currently saving // @todo - include a 'section' or 'group' param in the submitted // data to do this instead and make it more clear to what's happening if (isset($site['rewrite_enabled'])) { foreach ($notification_settings as $name) { $value = !empty($site[$name]) ? 1 : 0; $this->settings->add($name, $value, $this->tenant->id); } } // Connect App (if applicable) if ($process_connect_app) { $this->update_connect_app($connect_app_sid); } // Client App if ($process_app) { $this->update_application($app_sid); } $this->session->set_flashdata('error', 'Settings have been saved'); } catch (Exception $e) { $data['error'] = true; switch ($e->getCode()) { case '0': $data['message'] = $message = 'Could not Authenticate with Twilio. ' . 'Please check your Sid & Token values.'; break; default: $data['message'] = $message = $e->getMessage(); } $this->session->set_flashdata('error', $message); } } flush_minify_caches(); if ($this->response_type == 'html') { redirect('settings/site'); } $this->respond('', 'settings/site', $data); }
private function update_site() { $data = array('message' => '', 'error' => false); $site = $this->input->post('site'); $process_app = false; $process_connect_app = false; if (!empty($site)) { try { foreach ($site as $name => $value) { if ($name == 'application_sid') { $app_sid = $value; $process_app = true; } if ($name == 'connect_application_sid') { $connect_app_sid = $value; $process_connect_app = true; } $this->settings->set($name, trim($value), $this->tenant->id); } // Connect App (if applicable) if ($process_connect_app) { $this->update_connect_app($connect_app_sid); } // Client App if ($process_app) { $this->update_application($app_sid); } $this->session->set_flashdata('error', 'Settings have been saved'); } catch (SiteException $e) { $data['error'] = true; switch ($e->getCode()) { case '0': $data['message'] = $message = 'Could not Authenticate with Twilio. ' . 'Please check your Sid & Token values.'; break; default: $data['message'] = $message = $e->getMessage(); } $this->session->set_flashdata('error', $message); } } flush_minify_caches(); if ($this->response_type == 'html') { redirect('settings/site'); } $this->respond('', 'settings/site', $data); }
public function setup() { $json['success'] = true; $json['message'] = ''; try { $currentSchemaVersion = OpenVBX::schemaVersion(); $upgradingToSchemaVersion = OpenVBX::getLatestSchemaVersion(); $upgradeScriptPath = VBX_ROOT . '/updates/'; $updates = scandir($upgradeScriptPath); $updatesToRun = array(); // Collect all files named numerically in /updates and key sort the list of updates foreach ($updates as $i => $update) { if (preg_match('/^(\\d+).(sql|php)$/', $update, $matches)) { $updateExtension = $matches[2]; $rev = $matches[1]; $updatesToRun[$rev] = array('type' => $updateExtension, 'filename' => $update, 'revision' => $rev); } } ksort($updatesToRun); // Cut the updates by the current schema version. $updatesToRun = array_slice($updatesToRun, $currentSchemaVersion); $tplvars = array('originalVersion' => $currentSchemaVersion, 'version' => $upgradingToSchemaVersion, 'updates' => $updatesToRun); foreach ($updatesToRun as $updateToRun) { $file = $updateToRun['filename']; $type = $updateToRun['type']; $revision = $updateToRun['revision']; switch ($type) { case 'php': require_once $upgradeScriptPath . $file; $runUpdateMethod = "runUpdate_{$revision}"; if (!function_exists($runUpdateMethod)) { throw new UpgradeException("runUpdate method missing from {$file}: {$runUpdateMethod}"); } call_user_func($runUpdateMethod); break; case 'sql': $sql = @file_get_contents($upgradeScriptPath . $file); if (empty($sql)) { throw new UpgradeException("Unable to read update: {$file}", 1); } foreach (explode(";", $sql) as $stmt) { $stmt = trim($stmt); if (!empty($stmt)) { PluginData::sqlQuery($stmt); } } break; } } flush_minify_caches(); } catch (Exception $e) { $json['success'] = false; $json['message'] = $e->getMessage(); $json['step'] = $e->getCode(); } $json['tplvars'] = $tplvars; echo json_encode($json); }