/**
 * Perform activation
 *
 * @since	2.5.0.1
 * @return  void
 */
function gde_setup()
{
    if (GDE_DX_LOGGING > 0) {
        gde_dx_log("Dx log manually enabled in functions.php");
    }
    // clear any beta transient
    gde_dx_log("Clearing beta cache");
    delete_site_transient('gde_beta_version');
    delete_transient('gde_beta_version');
    delete_option('external_updates-google-document-embedder');
    gde_dx_log("Activating...");
    if (is_multisite()) {
        if (!($gdeglobals = get_site_option('gde_globals'))) {
            gde_dx_log("Writing multisite global options");
            $globalopts = gde_defaults('global');
            update_site_option('gde_globals', $globalopts);
        }
    }
    // check for existing or updated options
    $gdeoptions = gde_get_options();
    // check for existence of default profile (re-activation?)
    if (!gde_get_profiles(1)) {
        // new activation - write profile(s)
        $defpros = gde_defaults('profiles');
        foreach ($defpros as $key => $prodata) {
            if ($key == "default") {
                $id = 1;
                // default profile is always ID 1
            } else {
                $id = null;
                // assign next id
            }
            // prepare profile
            $desc = $prodata['desc'];
            unset($prodata['desc']);
            // write profile
            $data = serialize($prodata);
            $profile = array($key, $desc, $data);
            if (gde_write_profile($profile, $id) < 1) {
                gde_dx_log("Failed to write profile '{$key}'");
            }
        }
    } else {
        gde_dx_log("Profiles already exist");
        update_profiles();
    }
    gde_dx_log("Activation complete.");
}
Example #2
0
db_transaction();
// メールアドレスを取得
$users = select_users(array('select' => 'email', 'where' => array('id = :id', array('id' => $_SESSION['auth']['user']['id']))));
// メールアドレスの変更を確認
if ($_SESSION['post']['user']['email'] === $users[0]['email']) {
    $email_activated = 1;
} else {
    $email_activated = 0;
}
// ユーザを編集
$sets = array('username' => $_SESSION['post']['user']['username'], 'email' => $_SESSION['post']['user']['email'], 'email_activated' => $email_activated);
if (!empty($_SESSION['post']['user']['password'])) {
    $sets['password'] = hash_crypt($_SESSION['post']['user']['password'], $password_salt . ':' . $GLOBALS['config']['hash_salt']);
    $sets['password_salt'] = $password_salt;
}
$resource = update_users(array('set' => $sets, 'where' => array('id = :id', array('id' => $_SESSION['auth']['user']['id']))), array('id' => intval($_SESSION['auth']['user']['id']), 'update' => $_SESSION['update']['user']));
if (!$resource) {
    error('データを編集できません。');
}
// プロフィールを編集
$resource = update_profiles(array('set' => array('name' => $_SESSION['post']['profile']['name'], 'text' => $_SESSION['post']['profile']['text']), 'where' => array('user_id = :user_id', array('user_id' => $_SESSION['auth']['user']['id']))), array('id' => intval($_SESSION['auth']['user']['id']), 'update' => $_SESSION['update']['user']));
if (!$resource) {
    error('データを編集できません。');
}
// トランザクションを終了
db_commit();
// 投稿セッションを初期化
unset($_SESSION['post']);
unset($_SESSION['update']);
// リダイレクト
redirect('/user/modify_complete');