Beispiel #1
0
<?php

/**
 * Global site settings manager.
 */
// keep unauthorized users out
$this->require_acl('admin', 'settings');
// set the layout and page title
$page->layout = 'admin';
$page->title = __('Site Settings');
// create the form
$form = new Form('post', $this);
// set the form data from the global conf() settings, since they've already
// been rewritten with the Appconf::storyteller() ones in bootstrap.php
$form->data = array('site_name' => conf('General', 'site_name'), 'site_domain' => conf('General', 'site_domain') ? conf('General', 'site_domain') : $_SERVER['HTTP_HOST'], 'email_from' => conf('General', 'email_from'), 'timezone' => conf('General', 'timezone'), 'google_analytics_id' => conf('General', 'google_analytics_id'));
echo $form->handle(function ($form) {
    // merge the new values into the settings
    $merged = Appconf::merge('admin', array('Site Settings' => array('site_name' => $_POST['site_name'], 'site_domain' => $_POST['site_domain'], 'email_from' => $_POST['email_from'], 'timezone' => $_POST['timezone'], 'google_analytics_id' => $_POST['google_analytics_id'])));
    // save the settings to disk
    if (!Ini::write($merged, 'conf/app.admin.' . ELEFANT_ENV . '.php')) {
        printf('<p>%s</p>', __('Unable to save changes. Check your permissions and try again.'));
        return;
    }
    // redirect to the main admin page with a notification
    $form->controller->add_notification(__('Settings saved.'));
    $form->controller->redirect('/');
});
Beispiel #2
0
    }
    list($app, $section, $setting) = $parts;
    if (!preg_match($valid_app_name, $app) || !is_dir('apps/' . $app)) {
        Cli::out('Invalid app name: ' . $app, 'error');
        return;
    }
    if (!preg_match($valid_section_name, $section)) {
        Cli::out('Invalid section name: ' . $section, 'error');
        return;
    }
    if (!preg_match($valid_setting_name, $setting)) {
        Cli::out('Invalid setting name: ' . $setting, 'error');
        return;
    }
    // build an updated config to save
    $merged = Appconf::merge($app, array($section => array($setting => $value)));
    if (!Ini::write($merged, 'conf/app.' . $app . '.' . ELEFANT_ENV . '.php')) {
        Cli::out('Unable to save changes to: conf/app.' . $app . '.' . ELEFANT_ENV . '.php', 'error');
    }
    // show setting info
} else {
    // list sections
    if (count($parts) === 1) {
        $app = $parts[0];
        if (!preg_match($valid_app_name, $app) || !is_dir('apps/' . $app)) {
            Cli::out('Invalid app name: ' . $app, 'error');
            return;
        }
        $settings = Appconf::get($app);
        $sections = array_keys($settings);
        sort($sections);
Beispiel #3
0
<?php

// keep unauthorized users out
$this->require_admin();
// set the layout and page title
$page->layout = 'admin';
$page->title = __('Files - Settings');
// create the form
$form = new Form('post', $this);
// set the form data from the app settings
$form->data = array('aviary_key' => Appconf::filemanager('General', 'aviary_key'));
echo $form->handle(function ($form) {
    // merge the new values into the settings
    $merged = Appconf::merge('filemanager', array('General' => array('aviary_key' => $_POST['aviary_key'])));
    // save the settings to disk
    if (!Ini::write($merged, 'conf/app.filemanager.' . ELEFANT_ENV . '.php')) {
        printf('<p>%s</p>', __('Unable to save changes. Check your permissions and try again.'));
        return;
    }
    // redirect to the main admin page with a notification
    $form->controller->add_notification(__('Settings saved.'));
    $form->controller->redirect('/filemanager/index');
});
Beispiel #4
0
<?php

/**
 * This is the settings form for the blog app.
 */
$this->require_admin();
$page->layout = 'admin';
$page->title = __('Blog Settings');
$form = new Form('post', $this);
$form->data = array('title' => $appconf['Blog']['title'], 'layout' => $appconf['Blog']['layout'], 'post_layout' => $appconf['Blog']['post_layout'], 'comments' => $appconf['Blog']['comments'], 'preview_chars' => $appconf['Blog']['preview_chars'], 'post_format' => $appconf['Blog']['post_format'], 'post_footer' => $appconf['Blog']['post_footer'], 'show_related_posts' => $appconf['Blog']['show_related_posts'], 'disqus_shortname' => $appconf['Blog']['disqus_shortname'], 'social_twitter' => $appconf['Social Buttons']['twitter'], 'social_facebook' => $appconf['Social Buttons']['facebook'], 'social_google' => $appconf['Social Buttons']['google']);
echo $form->handle(function ($form) {
    $merged = Appconf::merge('blog', array('Blog' => array('title' => $_POST['title'], 'layout' => $_POST['layout'], 'post_layout' => $_POST['post_layout'], 'preview_chars' => !empty($_POST['preview_chars']) ? (int) $_POST['preview_chars'] : false, 'post_format' => $_POST['post_format'], 'post_footer' => $_POST['post_footer'], 'comments' => $_POST['comments'] === 'none' ? false : $_POST['comments'], 'show_related_posts' => $_POST['show_related_posts'] === 'yes' ? true : false, 'disqus_shortname' => $_POST['disqus_shortname']), 'Social Buttons' => array('twitter' => $_POST['social_twitter'] === 'yes' ? true : false, 'facebook' => $_POST['social_facebook'] === 'yes' ? true : false, 'google' => $_POST['social_google'] === 'yes' ? true : false)));
    if (!Ini::write($merged, 'conf/app.blog.' . ELEFANT_ENV . '.php')) {
        printf('<p>%s</p>', __('Unable to save changes. Check your folder permissions and try again.'));
        return;
    }
    $form->controller->run('navigation/hook/edit', array('page' => 'blog', 'id' => 'blog', 'title' => $_POST['title']));
    $form->controller->add_notification(__('Settings saved.'));
    $form->controller->redirect('/blog/admin');
});
Beispiel #5
0
$form = new Form('post', $this);
$appconf['User']['login_methods'] = is_array($appconf['User']['login_methods']) ? $appconf['User']['login_methods'] : array();
$form->data = array('facebook_app_id' => $appconf['Facebook']['application_id'], 'facebook_app_secret' => $appconf['Facebook']['application_secret'], 'twitter_id' => $appconf['Twitter']['twitter_id'], 'twitter_key' => $appconf['Twitter']['consumer_key'], 'twitter_secret' => $appconf['Twitter']['consumer_secret'], 'twitter_access_token' => $appconf['Twitter']['access_token'], 'twitter_access_token_secret' => $appconf['Twitter']['access_token_secret'], 'login_openid' => in_array('openid', $appconf['User']['login_methods']), 'login_google' => in_array('google', $appconf['User']['login_methods']), 'login_facebook' => in_array('facebook', $appconf['User']['login_methods']), 'login_twitter' => in_array('twitter', $appconf['User']['login_methods']), 'login_persona' => in_array('persona', $appconf['User']['login_methods']), 'default_role' => $appconf['User']['default_role'], 'roles' => array_keys(User::acl()->rules));
echo $form->handle(function ($form) {
    $login_methods = array();
    if ($_POST['login_openid'] === 'yes') {
        $login_methods[] = 'openid';
    }
    if ($_POST['login_google'] === 'yes') {
        $login_methods[] = 'google';
    }
    if ($_POST['login_facebook'] === 'yes') {
        $login_methods[] = 'facebook';
    }
    if ($_POST['login_twitter'] === 'yes') {
        $login_methods[] = 'twitter';
    }
    if ($_POST['login_persona'] === 'yes') {
        $login_methods[] = 'persona';
    }
    if (count($login_methods) === 0) {
        $login_methods = false;
    }
    $merged = Appconf::merge('user', array('User' => array('login_methods' => $login_methods, 'default_role' => $_POST['default_role']), 'Facebook' => array('application_id' => $_POST['facebook_app_id'], 'application_secret' => $_POST['facebook_app_secret']), 'Twitter' => array('twitter_id' => $_POST['twitter_id'], 'consumer_key' => $_POST['twitter_key'], 'consumer_secret' => $_POST['twitter_secret'], 'access_token' => $_POST['twitter_access_token'], 'access_token_secret' => $_POST['twitter_access_token_secret'])));
    if (!Ini::write($merged, 'conf/app.user.' . ELEFANT_ENV . '.php')) {
        printf('<p>%s</p>', __('Unable to save changes. Check your folder permissions and try again.'));
        return;
    }
    $form->controller->add_notification(__('Settings saved.'));
    $form->controller->redirect('/user/admin');
});