/** * 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(); }
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 { if ($op == '' || $op == 'toggle') { $org->addPlugin($plugin); } } $org->save(); ok(array('active' => $org->hasPlugin($plugin)));
$data = array('plugin_data' => PluginData::where('plugin_slug', '=', $plugin_name)->get()); return View::make('plugins.' . $plugin_name . '.index', $data); }); Route::post('admin/plugin/{plugin_name}', function ($plugin_name) { $input = Input::all(); foreach ($input as $key => $value) { $pluginData = PluginData::where('plugin_slug', '=', $plugin_name)->where('key', '=', $key)->first(); if (!empty($pluginData->id)) { $pluginData->value = $value; $pluginData->save(); } else { $pluginData = new PluginData(); $pluginData->plugin_slug = $plugin_name; $pluginData->key = $key; $pluginData->value = $value; $pluginData->save(); } } return Redirect::to('admin/plugin/' . $plugin_name)->with(array('note' => 'Successfully updated plugin information', 'note_type' => 'success')); }); Route::get('admin/plugin/{plugin_name}/{filename}', function ($plugin_name, $filename = 'settings') { return View::make('plugins' . $plugin_name . '.views.' . $filename); }); }); if (file_exists($include_file)) { include $include_file; } } } } } catch (Exception $e) {