Ejemplo n.º 1
0
 public function executeSave()
 {
     $settings = $this->post('setting', 'ARRAY', []);
     $oms = \Setting::findAll('setting_key');
     foreach ($this->form_cfg as $gk => $group) {
         foreach ($group['settings'] as $key => $options) {
             if (isset($settings[$key])) {
                 //form was set
                 if (isset($oms[$key])) {
                     $om = $oms[$key];
                 } else {
                     $om = new \Setting();
                     $om->setSettingKey($key);
                 }
                 $om->setSettingValue($settings[$key]);
                 $om->save();
             } else {
                 if ($options['control'] == 'checkbox') {
                     if (isset($oms[$key])) {
                         $om = $oms[$key];
                     } else {
                         $om = new \Setting();
                         $om->setSettingKey($key);
                     }
                     $om->setSettingValue('');
                     $om->save();
                 }
             }
             $this->dispatch('onAfterChangeSetting', new CMSBackendEvent($this, ['setting' => $om]));
         }
     }
     Session::getInstance()->setFlash('setting.message', t('Site\'s settings was saved!'));
     $this->redirect($this->createUrl('system_setting'));
 }
Ejemplo n.º 2
0
 public static function getSetting($type = 'system', $setting_name = NULL, $user_id = NULL)
 {
     if (!is_null($setting_name)) {
         if (is_numeric($user_id) && $type == 'user') {
             $setting = Setting::findAll(array('type' => $type, 'name' => $setting_name, 'owner_id' => $user_id));
             //$value = $setting->getValue();
         } elseif ($type == 'system') {
             $setting = Setting::findAll(array('type=' => $type, 'name=' => $setting_name, 'owner_id=' => '0'));
             // $value = $setting->getValue();
         }
         return $setting;
     } else {
         return false;
     }
 }
Ejemplo n.º 3
0
    } else {
        $setting->setOwnerId(0);
    }
    if (fRequest::isPost()) {
        try {
            $setting->populate();
            fRequest::validateCSRFToken(fRequest::get('token'));
            $setting->store();
            $setting_url = Setting::makeUrl('list', $setting_type);
            fMessaging::create('affected', fURL::get());
            fMessaging::create('success', fURL::get(), 'The setting ' . $setting->getFriendlyName() . ' was successfully created');
            fURL::redirect($setting_url);
        } catch (fExpectedException $e) {
            fMessaging::create('error', fURL::get(), $e->getMessage());
        }
    } else {
        $setting->setValue($list_plugin_settings[$setting_name]['default']);
    }
    include VIEW_PATH . '/add_edit_setting.php';
} else {
    if ('user' == $setting_type) {
        $current_plugin_user_settings = Setting::findAll(array('type=' => 'user', 'owner_id=' => $owner_id));
        foreach ($current_plugin_user_settings as $user_setting) {
            $plugin_user_settings[$user_setting->getName()]['value'] = $user_setting->getValue();
        }
        $list_plugin_settings = $plugin_user_settings;
    } else {
        $list_plugin_settings = $plugin_settings;
    }
    include VIEW_PATH . '/list_settings.php';
}
Ejemplo n.º 4
0
try {
    //Set DB connection (using flourish it isn't actually connected to until the first use)
    $mysql_db = new fDatabase('mysql', $GLOBALS['DATABASE_NAME'], $GLOBALS['DATABASE_USER'], $GLOBALS['DATABASE_PASS'], $GLOBALS['DATABASE_HOST']);
    // Please note that calling this method is not required, and simply
    // causes an exception to be thrown if the connection can not be made
    $mysql_db->connect();
} catch (fAuthorizationException $e) {
    $config_error = "DB error : " . $e->getMessage();
    $config_exit = true;
}
//Connect the db to the ORM functions
fORMDatabase::attach($mysql_db);
$default_plugin_settings = plugin_hook('plugin_settings');
$default_plugin_user_settings = plugin_hook('plugin_user_settings');
$send_methods = plugin_hook('send_methods');
$current_plugin_settings = Setting::findAll(array('type=' => 'system'));
$plugin_settings = $default_plugin_settings;
$plugin_user_settings = $default_plugin_user_settings;
foreach ($current_plugin_settings as $setting) {
    $plugin_settings[$setting->getName()]['value'] = $setting->getValue();
}
if (!is_dir(JS_CACHE)) {
    $config_error .= "<br/>Tattle Error <br />" . "Can't write to the js cache folder : " . JS_CACHE;
}
if (!is_dir($GLOBALS['SESSION_FILES']) || !is_writable($GLOBALS['SESSION_FILES'])) {
    $config_error .= "<br/>Tattle Error <br />" . "Flourishlib Session path is not write-able. Path at : " . $GLOBALS['SESSION_FILES'];
    $config_error = true;
}
if ($config_exit) {
    print $config_error;
    exit;