public function index() { $args = func_get_args(); $page = implode('/', $args); $this->section = '/p/' . $page; $data = $this->init_view_data(); $title = ''; /* Find Plugin matching page */ $plugins = Plugin::all(); foreach ($plugins as $plugin) { try { // First plugin wins $data['script'] = $plugin->getScript($page); if (!empty($data['script'])) { PluginData::setPluginId($plugin->getPluginId()); OpenVBX::$currentPlugin = $plugin; $plugin_info = $plugin->getInfo(); $page_title = $plugin->getPluginPageName($page); $title = !empty($page_title) ? $page_title : $plugin_info['name']; break; } } catch (PluginException $e) { error_log($e->getMessage()); $ci =& get_instance(); $ci->session->set_flashdata('error', $e->getMessage()); } } $this->respond($title, 'page/index', $data); }
function limit_exceeded($duration, $enabled, $instance_id, $limit) { if (!$enabled) { return false; } //throttling disabled $number = normalize_phone_to_E164($_REQUEST['From']); $data = PluginData::get($instance_id . "__" . $number); $duration = intval($duration) * 60; //convert it into seconds if (!$data) { PluginData::set($instance_id . "__" . $number, array('limit' => 1, 'added' => time())); return false; } //clean expired time if (!empty($data->added) && time() - $data->added > $duration) { PluginData::set($instance_id . "__" . $number, array('limit' => 0, 'added' => time())); $data = PluginData::get($instance_id . "__" . $number); } if ($data->limit >= $limit && time() - $data->added <= $duration) { PluginData::set($instance_id . "__" . $number, array('limit' => $data->limit + 1, 'added' => $data->added)); return true; } else { PluginData::set($instance_id . "__" . $number, array('limit' => $data->limit + 1, 'added' => $data->added)); return false; } }
/** * Returns an array containing the selected details of a single message * * @param array Message object from twilio api * @param string sid of message * @param string the contact associated with the message * * @return array */ function getMessageArray($message, $sid, $contact) { $result = PluginData::sqlQuery("SELECT * FROM messages WHERE call_sid='{$sid}'"); if (count($result) == 0) { $result = insertMissingMessage($message, $sid); } return array('id' => $result[0]["id"], 'sid' => $sid, 'contact' => $contact, 'num_media' => $message->num_media, 'media' => $message->media, 'caller' => $message->from, 'created' => $message->date_created, 'status' => $result[0]["status"], 'archived' => $result[0]["archived"], 'body' => $message->body); }
public static function getKeyValues() { error_log('Deprecating in 0.75: ' . __FUNCTION__); try { PluginData::getKeyValues(); } catch (PluginDataException $e) { throw new PluginStoreException($e->getMessage()); } }
public static function _find_current_plugindata($blog) { $keys = array('configuration:blog:' . $blog->id); if ($blog->parent_id) { array_push($keys, 'configuration:blog:' . $blog->parent_id); } array_push($keys, 'configuration'); require_once 'class.mt_plugindata.php'; $class = new PluginData(); $where = "plugindata_plugin = 'GoogleAnalytics' AND " . "plugindata_key IN ('" . join("','", $keys) . "')"; $tmp_objs = $class->Find($where); if (empty($tmp_objs)) { return null; } $objs = array(); foreach ($keys as $k) { foreach ($tmp_objs as $o) { if ($o->key == $k) { array_push($objs, $o); } } } $mt = MT::get_instance(); $db = $mt->db(); for ($i = 0; $i < sizeof($objs); $i++) { $o = $objs[$i]; $data = $o->data(); if ($data && $data['profile_id']) { if ($data['client_id'] && $data['client_secret']) { return $o; } else { if ($data['parent_client_id']) { for ($j = 0; $j < sizeof($objs); $j++) { $parent_data = $objs[$j]->data(); if ($parent_data && $parent_data['client_id'] && $parent_data['client_id'] == $data['parent_client_id'] && $parent_data['client_secret']) { return $o; } } } } } } }
public function index($plugin) { $this->admin_only('plugin config'); $data = $this->init_view_data(); $plugin = Plugin::get($plugin); PluginData::setPluginId($plugin->getPluginId()); OpenVBX::$currentPlugin = $plugin; try { $data['info'] = $plugin->getInfo(); $data['script'] = $plugin->getScript('config'); } catch (PluginException $e) { error_log($e->getMessage()); $data['script'] = null; } $this->respond('', 'page/config', $data); }
function login_signup_modal() { $login_signup_modal_custom_css = PluginData::where('plugin_slug', '=', 'login_signup_modal')->where('key', '=', 'css')->first(); if (empty($login_signup_modal_custom_css->value)) { $login_signup_modal_custom_css = ''; } else { //$login_signup_modal_custom_css = ''; $login_signup_modal_custom_css = trim($login_signup_modal_custom_css->value); } ?> <style type="text/css"> .form-signin{ padding-bottom:40px; margin-top:20px; }#loginSignupModal{ border:0; outline:none; } #loginSignupModal .modal-dialog{ margin-top:100px; } #loginSignupModal .close{ padding:20px; position:absolute; right:0px; z-index:99; border:0; outline:none; } #loginSignupModal .close:active{ border:0; outline:none; } #loginSignupModal .close:focus{ border:0; outline:none; } .dark #loginSignupModal .form-signin h2, a, a.reset_password{ color:#fff; } #loginSignupModal .form-signin h2, a, a.reset_password{ color:#777; } <?php echo $login_signup_modal_custom_css; ?> </style> <script src="/content/plugins/login_signup_modal/functions.js"></script> <?php }
function moveToS3($upload_folder, $filename, $folder, $month_year) { $s3_bucket = PluginData::where('plugin_slug', '=', 's3')->where('key', '=', 's3bucket')->first(); if (empty($s3_bucket->value)) { $s3_bucket = ''; } else { $s3_bucket = $s3_bucket->value; } $config_location = getcwd() . '/content/plugins/s3/s3config.php'; // Instantiate an S3 client $aws = Aws::factory($config_location); $s3 = $aws->get('s3'); $sourceFile = $upload_folder . $filename; $key = $folder . '/' . $month_year . $filename; // Upload a publicly accessible file. // The file size, file type, and MD5 hash are automatically calculated by the SDK try { $s3->putObject(array('Bucket' => $s3_bucket, 'Key' => $key, 'SourceFile' => $sourceFile, 'ACL' => 'public-read')); } catch (S3Exception $e) { echo "There was an error uploading the file.\n"; } }
public function index($page) { $this->section = '/p/' . $page; $data = $this->init_view_data(); /* Find Plugin matching page */ $plugins = Plugin::all(); foreach ($plugins as $plugin) { try { // First plugin wins $data['script'] = $plugin->getScript($page); if (!empty($data['script'])) { PluginData::setPluginId($plugin->getPluginId()); OpenVBX::$currentPlugin = $plugin; break; } } catch (PluginException $e) { error_log($e->getMessage()); $ci =& get_instance(); $ci->session->set_flashdata('error', $e->getMessage()); } } $this->respond('', 'page/index', $data); }
public function fetch_plugin_data($plugin, $key) { $plugin = $this->escape($plugin); $key = $this->escape($key); require_once 'class.mt_plugindata.php'; $class = new PluginData(); $where = "plugindata_plugin = '{$plugin}'\n and plugindata_key = '{$key}'"; $pdatas = $class->Find($where); if (!empty($pdatas)) { $data = $pdatas[0]->data; if ($data) { return $this->unserialize($data); } } return null; }
} if ($op == 'config') { $data = json_decode($app->request()->getBody(), true); // store custom config value $key = 'custom_config/' . $org->getId() . '/' . $data['key']; $q = PluginDataQuery::create()->filterByPlugin($plugin)->filterByKey($key)->findOne(); if (is_null($data['value'])) { // remove value if ($q) { $q->delete(); } ok(); } else { // udpate value if (!$q) { $q = new PluginData(); $q->setPlugin($plugin); $q->setKey($key); } $q->setData($data['value']); $q->setStoredAt(time()); $q->save(); ok($q->toArray()); } } else { // change plugin permission if ($org->hasPlugin($plugin)) { if ($op == 'remove' || $op == 'toggle') { $org->removePlugin($plugin); } } else {
<?php if (count($_POST)) { foreach ($_POST['keys'] as $k => $v) { if (empty($v)) { unset($_POST['keys'][$k]); unset($_POST['status'][$k]); } } PluginData::set('orders', array('keys' => $_POST['keys'], 'status' => $_POST['status'])); } $settings = PluginData::get('orders', array('keys' => array(), 'status' => array())); # print_r( $settings ); $statusArray = array('shipped' => 'Shipped', 'fullfillment' => 'Sent to Fullfillment', 'processing' => 'Processing'); OpenVBX::addJS('script.js'); ?> <div class="vbx-plugin orders-applet"> <form method="post"> <h2>Order Tracker</h2> <p>Enter an order ID, without spaces. For example, <code>1234</code> instead of <code>123 4</code>.</p> <table class="vbx-orders-grid options-table"> <thead> <tr> <td>Order ID</td> <td>Status</td> <td>Actions</td> </tr> </thead> <tbody> <?php foreach ($settings->keys as $i => $key) {
<?php $settings = PluginData::get('settings'); if (is_object($settings)) { $settings = get_object_vars($settings); } ?> <div class="vbx-applet"> <?php if (!empty($settings) && !empty($settings['api_key'])) { ?> <div class="vbx-full-pane"> <h3>Amount</h3> <p>A positive integer in cents representing much to charge the card.</p> <fieldset class="vbx-input-container"> <input type="text" name="amount" class="medium" value="<?php echo AppletInstance::getValue('amount', 50); ?> " /> </fieldset> <h3>Description</h3> <fieldset class="vbx-input-container"> <input type="text" name="description" class="medium" value="<?php echo AppletInstance::getValue('description'); ?> " /> </fieldset> </div> <h2>After the payment</h2> <div class="vbx-full-pane"> <?php
<?php if (count($_POST)) { PluginData::set('settings', array('api_key' => $_POST['api_key'], 'card_prompt' => $_POST['card_prompt'], 'month_prompt' => $_POST['month_prompt'], 'year_prompt' => $_POST['year_prompt'], 'require_cvc' => isset($_POST['require_cvc']), 'cvc_prompt' => $_POST['cvc_prompt'])); } $settings = PluginData::get('settings', array('api_key' => null, 'card_prompt' => "Please enter your credit card number followed by the pound sign.", 'month_prompt' => "Please enter the month of the card's expiration date followed by the pound sign.", 'year_prompt' => "Please enter the year of the expiration date followed by the pound sign.", 'require_cvc' => true, 'cvc_prompt' => "Please enter the card's security code followed by the pound sign.")); if (is_object($settings)) { $settings = get_object_vars($settings); } OpenVBX::addJS('stripe.js'); ?> <style> .vbx-stripe form { padding: 20px 5%; } .vbx-stripe form p { margin: 20px 0; } </style> <div class="vbx-content-main"> <div class="vbx-content-menu vbx-content-menu-top"> <h2 class="vbx-content-heading">Stripe Settings</h2> </div> <div class="vbx-table-section vbx-stripe"> <form method="post" action=""> <fieldset class="vbx-input-container"> <p> <label class="field-label">API Key<br/> <input type="password" name="api_key" class="medium" value="<?php echo htmlentities($settings['api_key']); ?>
<div class="vbx-content-main"> <?php if (!is_file($script)) { ?> <?php $store = PluginData::getKeyValues(); ?> <div class="vbx-content-menu vbx-content-menu-top"> <h2 class="vbx-content-heading">Plugin: <?php echo $info['name']; ?> </h2> </div> <h3>Details</h3> <table class="vbx-items-grid"> <tbody> <tr class="items-row"> <td style="width: 120px;">Plugin ID</td> <td><?php echo $info['plugin_id']; ?> </td> <tr> <tr class="items-row"> <td style="width: 120px;">Description</td> <td><?php echo $info['description']; ?> </td>
public static function setInstance($instance) { list($plugin_name, $applet_name) = explode('---', $instance->type); self::$instance = $instance->data; self::$id = $instance->id; self::$pluginName = $plugin_name; self::$appletName = $applet_name; self::$plugin = new Plugin(self::$pluginName); PluginData::setPluginId(self::$plugin->getPluginId()); }
<?php // File saved as /path/to/custom/config.php $s3_key = PluginData::where('plugin_slug', '=', 's3')->where('key', '=', 's3key')->first(); if (empty($s3_key->value)) { $s3_key = ''; } else { $s3_key = $s3_key->value; } $s3_secret = PluginData::where('plugin_slug', '=', 's3')->where('key', '=', 's3secret')->first(); if (empty($s3_secret->value)) { $s3_secret = ''; } else { $s3_secret = $s3_secret->value; } return array('includes' => array('_aws'), 'services' => array('default_settings' => array('params' => array('key' => $s3_key, 'secret' => $s3_secret, 'region' => 'us-east-1'))));
/** * allows the plugin to persistently store arbitrary data * * @param key string a key * @param data json_seriazable the data thats being stored. must be json serializable * @param single boolean if set, any existing value with the same key will be overwritten */ public function storeData($key, $data, $single = true) { if ($single) { // remove any existing value PluginDataQuery::create()->filterByPlugin($this->getPluginOM())->filterByKey($key)->delete(); } $pd = new PluginData(); $pd->setPlugin($this->getPluginOM()); $pd->setKey($key); $pd->setData($data); $pd->setStoredAt(time()); $pd->save(); }
public static function setPluginId($plugin_id) { self::$plugin_id = $plugin_id; }
<?php require_once dirname(__FILE__) . '/../../lib/dopplr.php'; $user = OpenVBX::getCurrentUser(); $dopplr_token = PluginData::get("dopplr_token_{$user->id}", ""); $dopplr = new Dopplr($dopplr_token); $response = new Response(); if ($dopplr->travel_today()) { $response->addRedirect(AppletInstance::GetDropZoneUrl('in_transit')); } else { if ($dopplr->at_home) { $response->addRedirect(AppletInstance::GetDropZoneUrl('at_home')); } else { $response->addRedirect(AppletInstance::GetDropZoneUrl('on_the_road')); } } $response->Respond();
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); }
/** * Filter the query by a related PluginData object * * @param PluginData|PropelObjectCollection $pluginData the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return PluginQuery The current query, for fluid interface * @throws PropelException - if the provided filter is invalid. */ public function filterByPluginData($pluginData, $comparison = null) { if ($pluginData instanceof PluginData) { return $this->addUsingAlias(PluginPeer::ID, $pluginData->getPluginId(), $comparison); } elseif ($pluginData instanceof PropelObjectCollection) { return $this->usePluginDataQuery()->filterByPrimaryKeys($pluginData->getPrimaryKeys())->endUse(); } else { throw new PropelException('filterByPluginData() only accepts arguments of type PluginData or PropelCollection'); } }
break; case 'SUCCESS': // If credentials are valid, store it to plugin store for this user PluginData::set('zendesk_user', array('url' => $url, 'email' => $email, 'password' => $password, 'timezone' => $timezone)); $results = array('msg' => 'Awesome! Your credentials are valid.', 'key' => 'SUCCESS', 'type' => 'success'); break; default: case 'EXCEPTION': $results = array('msg' => 'An unexpected error occurred.', 'key' => 'EXCEPTION', 'type' => 'error'); break; } } echo '<JSON_DATA>' . json_encode($results) . '</JSON_DATA>'; } elseif ($op == 'delete_credentials') { // {{{ PluginData::set('zendesk_user', ''); $results = array('msg' => 'Zendesk credentials erased.', 'key' => 'SUCCESS', 'type' => 'success'); echo '<JSON_DATA>' . json_encode($results) . '</JSON_DATA>'; } // }}} ?> <?php if (empty($op)) { ?> <style> span[class$="_err"] { color:red; } a.ajax_loader { background:url(<?php echo base_url(); ?> assets/i/ajax-loader.gif); display:inline-block; width:16px; height:11px; vertical-align:middle; }
/** * @param PluginData $pluginData The pluginData object to add. */ protected function doAddPluginData($pluginData) { $this->collPluginDatas[] = $pluginData; $pluginData->setPlugin($this); }
public function twiml($flow, $baseURI, $instance = null) { $path = $this->applet_dir . '/twiml.php'; if (!is_null($instance)) { AppletInstance::setInstance($instance); AppletInstance::setFlow($flow); AppletInstance::setBaseURI($baseURI); FlowStore::setFlowId($flow->id); // Plugin directory name is the natural key until a proper guid system is developed $plugin = new Plugin($this->plugin_dir_name); PluginData::setPluginId($plugin->getPluginId()); OpenVBX::$currentPlugin = $plugin; $instance = isset($instance->data) && is_array($instance->data) ? $instance->data : array(); } else { $instance = isset($this->data) && is_array($this->data) ? $this->data : array(); } AppletInstance::setFlowType($this->flow_type); if (!file_exists($path)) { return ''; } $output = '<?xml version="1.0" ?><Response />'; ob_start(); require_once APPPATH . 'libraries/twilio.php'; // require once was hampering our ability to run an applet multiple times (ie: in integration tests) require $path; $output = ob_get_contents(); ob_end_clean(); return $output; }
<?php $CI =& get_instance(); $plugin_info = $plugin->getInfo(); $zendesk_user = PluginData::get('zendesk_user'); $currentlyIsUser = AppletInstance::getUserGroupPickerValue('permissions') instanceof VBX_User; ?> <style> a.ajax_loader { background:url(<?php echo base_url(); ?> assets/i/ajax-loader.gif); display:inline-block; width:16px; height:11px; vertical-align:middle; } div.system_msg { display:inline-block; line-height:30px; vertical-align:center; } div.system_msg > * { vertical-align:middle; } div.vbx-applet div.section { margin-bottom:20px; } span[class$="err"] { color:red; } </style> <div class="vbx-applet zendesk_ticket_applet"> <?php if (empty($zendesk_user)) { ?> <div id="zendesk_api_access" class="section"> <h2>Zendesk API Access</h2> <p>It looks like you are setting up for the first time. Please enter your access credentials so we can connect to Zendesk.</p> <div class="vbx-input-container input" style="margin-bottom:10px;"> <label>Zendesk Url - the url to your Zendesk which is something like https or http://yoursite.zendesk.com.</label> <input name="zendesk_url" class="medium" type="text" value="" /> <span class="zendesk_url_err"></span> </div>
public function setup() { $json['success'] = true; $json['message'] = ''; try { $currentSchemaVersion = OpenVBX::schemaVersion(); $upgradingToSchemaVersion = OpenVBX::getLatestSchemaVersion(); $sqlPath = VBX_ROOT . '/sql-updates/'; $updates = scandir($sqlPath); $files = array(); foreach ($updates as $i => $update) { if (preg_match('/^(\\d+).sql$/', $update)) { $rev = intval(str_replace('.sql', '', $update)); $files[$rev] = $update; } } ksort($files); $files = array_slice($files, $currentSchemaVersion); $tplvars = array('originalVersion' => $currentSchemaVersion, 'version' => $upgradingToSchemaVersion, 'updates' => $files); foreach ($files as $file) { $sql = @file_get_contents($sqlPath . $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); } } } } catch (Exception $e) { $json['success'] = false; $json['message'] = $e->getMessage(); $json['step'] = $e->getCode(); } $json['tplvars'] = $tplvars; echo json_encode($json); }
public static function one($sql) { return PluginData::one($sql); }
/** * Exclude object from result * * @param PluginData $pluginData Object to remove from the list of results * * @return PluginDataQuery The current query, for fluid interface */ public function prune($pluginData = null) { if ($pluginData) { $this->addUsingAlias(PluginDataPeer::ID, $pluginData->getId(), Criteria::NOT_EQUAL); } return $this; }
var parts = phonenum.match(regexObj); var phone = ""; if (parts[1]) { phone += "(" + parts[1] + ") "; } phone += parts[2] + "-" + parts[3]; return phone; } </script> <h3>Complete Call Log</h3> <div style="width: 100%; height: auto; overflow: hidden;"> <br /> <form method="POST"> <label style="display: inline; float: left; margin-right: 20px; font-size: 16px; font-weight: bold; position: relative; top: 6px;">Set Your Timezone</label><?php echo timezone_menu(PluginData::get("timezone", 'UM8')); ?> <button class="submit-button ui-state-focus" style="margin-left: 4px; display: inline; float: left;" type="submit"><span>Set Timezone</span></button> </form> </div> <table> <thead> <tr> <th>Number</th> <th>Start Time</th> <th>Duration</th> <th>Called</th> <th>Status</th> </tr> </thead>