array_push($errorArr, "Please enter setting name "); } if ($settingName != '') { $settingObj->name = $settingName; } break; default: $settingObj->{$postVar} = filter_input(INPUT_POST, $postVar) ? mysqli_real_escape_string($dbObj->connection, filter_input(INPUT_POST, $postVar)) : ''; if ($settingObj->{$postVar} === "") { array_push($errorArr, "Please enter {$postVar} "); } break; } } if (count($errorArr) < 1) { echo $settingObj->add(); } else { $json = array("status" => 0, "msg" => $errorArr); $dbObj->close(); //Close Database Connection header('Content-type: application/json'); echo json_encode($json); } } if (filter_input(INPUT_POST, "fetchSettings") != NULL) { $requestData = $_REQUEST; $columns = array(0 => 'name', 1 => 'value'); // getting total number records without any search $query = $dbObj->query("SELECT * FROM setting "); $totalData = mysqli_num_rows($query); $totalFiltered = $totalData;
/** * Write link permissions method * */ protected function _writeLinkPermissions() { $acos = array(); $privileges = $this->find('all', array('conditions' => array('Privilege._create' => 1, 'Privilege._read' => 1, 'Privilege._update' => 1, 'Privilege._delete' => 1))); foreach ($privileges as $privilege) { if (!empty($acos[$privilege['Privilege']['aco_id']])) { $acos[$privilege['Privilege']['aco_id']] = $acos[$privilege['Privilege']['aco_id']] . ',' . $privilege['Privilege']['aro_id']; } else { $acos[$privilege['Privilege']['aco_id']] = $privilege['Privilege']['aro_id']; } } $settings = ''; foreach ($acos as $aco => $aros) { $path = $this->Section->getPath($aco); // all of the acos parents if ($path === null) { // if path is null we need to delete the aros_acos that use that aco because it doesn't exist $this->deleteAll(array('Privilege.aco_id' => $aco)); } else { $url = str_replace('controllers', '', Inflector::singularize(Inflector::tableize(ZuhaInflector::flatten(Set::extract('/Section/alias', $path), array('separator' => '/'))))); $settings .= $url . ' = ' . $aros . PHP_EOL; } } App::uses('Setting', 'Model'); $Setting = new Setting(); $data['Setting']['type'] = 'APP'; $data['Setting']['name'] = 'LINK_PERMISSIONS'; $data['Setting']['value'] = trim($settings); $Setting->add($data); }
<?php $timezones = function () { return collect(\DateTimeZone::listIdentifiers())->map(function ($timezone) { $key = 'timezones.' . Str::lower($timezone); return [$timezone => trans($key)]; })->flatten(1); }; Setting::add('enter_send', 'checkbox', ['default' => 'false']); Setting::add('homepage_subscribed', 'checkbox', ['default' => false]); Setting::add('contents_per_page', 'select', ['default' => 25, 'options' => [10 => 10, 20 => 20, 25 => 25, 50 => 50, 100 => 100]]); Setting::add('entries_per_page', 'select', ['default' => 25, 'options' => [10 => 10, 20 => 20, 25 => 25, 50 => 50, 100 => 100]]); Setting::add('timezone', 'select', ['default' => 'Europe/Warsaw', 'options' => $timezones]); Setting::add('notifications.auto_read', 'checkbox', ['default' => false]); Setting::add('notifications_sound', 'checkbox', ['default' => false]); Setting::add('pin_navbar', 'checkbox', ['default' => false]); Setting::add('disable_groupstyles', 'checkbox', ['default' => false]); Setting::add('css_style', 'text', ['default' => '']);
/** * Update settings method * */ protected function _updateSettings() { App::import('Model', 'Setting'); $Setting = new Setting(); // find all of the dynamic js files $jsFiles = $this->find('all', array('conditions' => array('WebpageJs.is_requested' => 0))); if (!empty($jsFiles)) { // write the settings using all js files in existence $data['Setting']['type'] = 'Webpages'; $data['Setting']['name'] = 'DEFAULT_JS_FILENAMES'; $data['Setting']['value'] = ''; foreach ($jsFiles as $js) { if (!empty($js['WebpageJs']['webpage_id'])) { $data['Setting']['value'] .= @$js['WebpageJs']['type'] . 'text/javascript[] = ' . $js['WebpageJs']['webpage_id'] . ',' . $js['WebpageJs']['name'] . PHP_EOL; } else { $data['Setting']['value'] .= 'text/javascript[] = ' . $js['WebpageJs']['name'] . PHP_EOL; } } if ($Setting->add($data)) { return true; } else { return false; } } else { // if its empty then just delete the setting $setting = $Setting->find('first', array('conditions' => array('Setting.name' => 'DEFAULT_JS_FILENAMES'))); if ($Setting->delete($setting['Setting']['id'])) { if ($Setting->writeSettingsIniData()) { return true; } else { return false; } } else { return false; } } }
protected function _plugin($plugin) { if (!empty($plugin) && defined('__SYSTEM_LOAD_PLUGINS')) { CakePlugin::load($plugin); if ($this->_installPluginSchema($plugin, $plugin)) { $plugins = unserialize(__SYSTEM_LOAD_PLUGINS); $sqlData = ''; foreach ($plugins['plugins'] as $sql) { $sqlData .= 'plugins[] = ' . $sql . PHP_EOL; } $sqlData = $sqlData . "plugins[] = {$plugin}"; // "UPDATE `settings` SET `value` = 'plugins[] = Users\r\nplugins[] = Webpages\r\nplugins[] = Contacts\r\nplugins[] = Galleries\r\nplugins[] = Privileges' WHERE `name` = 'LOAD_PLUGINS';"; App::uses('Setting', 'Model'); $Setting = new Setting(); $data['Setting']['type'] = 'System'; $data['Setting']['name'] = 'LOAD_PLUGINS'; $data['Setting']['value'] = $sqlData; if ($Setting->add($data)) { return true; } else { throw new Exception('Settings update failed.'); } } else { throw new Exception('Plugin install failed.'); } } else { throw new Exception('Current plugin setup not valid.'); } }