Esempio n. 1
0
 function get()
 {
     if (argc() > 2 && argv(2) === 'add') {
         $tpl = get_markup_template("settings_oauth_edit.tpl");
         $o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("settings_oauth"), '$title' => t('Add application'), '$submit' => t('Submit'), '$cancel' => t('Cancel'), '$name' => array('name', t('Name'), '', t('Name of application')), '$key' => array('key', t('Consumer Key'), random_string(16), t('Automatically generated - change if desired. Max length 20')), '$secret' => array('secret', t('Consumer Secret'), random_string(16), t('Automatically generated - change if desired. Max length 20')), '$redirect' => array('redirect', t('Redirect'), '', t('Redirect URI - leave blank unless your application specifically requires this')), '$icon' => array('icon', t('Icon url'), '', t('Optional'))));
         return $o;
     }
     if (argc() > 3 && argv(2) === 'edit') {
         $r = q("SELECT * FROM clients WHERE client_id='%s' AND uid=%d", dbesc(argv(3)), local_channel());
         if (!count($r)) {
             notice(t('Application not found.'));
             return;
         }
         $app = $r[0];
         $tpl = get_markup_template("settings_oauth_edit.tpl");
         $o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("settings_oauth"), '$title' => t('Add application'), '$submit' => t('Update'), '$cancel' => t('Cancel'), '$name' => array('name', t('Name'), $app['clname'], ''), '$key' => array('key', t('Consumer Key'), $app['client_id'], ''), '$secret' => array('secret', t('Consumer Secret'), $app['pw'], ''), '$redirect' => array('redirect', t('Redirect'), $app['redirect_uri'], ''), '$icon' => array('icon', t('Icon url'), $app['icon'], '')));
         return $o;
     }
     if (argc() > 3 && argv(2) === 'delete') {
         check_form_security_token_redirectOnErr('/settings/oauth', 'settings_oauth', 't');
         $r = q("DELETE FROM clients WHERE client_id='%s' AND uid=%d", dbesc(argv(3)), local_channel());
         goaway(z_root() . "/settings/oauth/");
         return;
     }
     $r = q("SELECT clients.*, tokens.id as oauth_token, (clients.uid=%d) AS my \n\t\t\t\tFROM clients\n\t\t\t\tLEFT JOIN tokens ON clients.client_id=tokens.client_id\n\t\t\t\tWHERE clients.uid IN (%d,0)", local_channel(), local_channel());
     $tpl = get_markup_template("settings_oauth.tpl");
     $o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("settings_oauth"), '$baseurl' => z_root(), '$title' => t('Connected Apps'), '$add' => t('Add application'), '$edit' => t('Edit'), '$delete' => t('Delete'), '$consumerkey' => t('Client key starts with'), '$noname' => t('No name'), '$remove' => t('Remove authorization'), '$apps' => $r));
     return $o;
 }
Esempio n. 2
0
/**
 * Display admin settings for this addon
 */
function libravatar_plugin_admin(&$a, &$o)
{
    $t = get_markup_template("admin.tpl", "addon/libravatar");
    $default_avatar = get_config('libravatar', 'default_img');
    // set default values for first configuration
    if (!$default_avatar) {
        $default_avatar = 'identicon';
    }
    // pseudo-random geometric pattern based on email hash
    // Available options for the select boxes
    $default_avatars = array('mm' => t('generic profile image'), 'identicon' => t('random geometric pattern'), 'monsterid' => t('monster face'), 'wavatar' => t('computer generated face'), 'retro' => t('retro arcade style face'));
    // Show warning if PHP version is too old
    if (!version_compare(PHP_VERSION, '5.3.0', '>=')) {
        $o = '<h5>' . t('Warning') . '</h5><p>';
        $o .= sprintf(t('Your PHP version %s is lower than the required PHP >= 5.3.'), PHP_VERSION);
        $o .= '<br>' . t('This addon is not functional on your server.') . '<p><br>';
        return;
    }
    // Libravatar falls back to gravatar, so show warning about gravatar addon if enabled
    $r = q("SELECT * FROM `addon` WHERE `name` = '%s' and `installed` = 1", dbesc('gravatar'));
    if (count($r)) {
        $o = '<h5>' . t('Information') . '</h5><p>' . t('Gravatar addon is installed. Please disable the Gravatar addon.<br>The Libravatar addon will fall back to Gravatar if nothing was found at Libravatar.') . '</p><br><br>';
    }
    // output Libravatar settings
    $o .= '<input type="hidden" name="form_security_token" value="' . get_form_security_token("libravatarsave") . '">';
    $o .= replace_macros($t, array('$submit' => t('Save Settings'), '$default_avatar' => array('avatar', t('Default avatar image'), $default_avatar, t('Select default avatar image if none was found. See README'), $default_avatars)));
}
Esempio n. 3
0
/**
 * Display admin settings for this addon
 */
function gravatar_plugin_admin(&$a, &$o)
{
    $t = get_markup_template("admin.tpl", "addon/gravatar/");
    $default_avatar = get_config('gravatar', 'default_img');
    $rating = get_config('gravatar', 'rating');
    // set default values for first configuration
    if (!$default_avatar) {
        $default_avatar = 'identicon';
    }
    // pseudo-random geometric pattern based on email hash
    if (!$rating) {
        $rating = 'g';
    }
    // suitable for display on all websites with any audience type
    // Available options for the select boxes
    $default_avatars = array('mm' => t('generic profile image'), 'identicon' => t('random geometric pattern'), 'monsterid' => t('monster face'), 'wavatar' => t('computer generated face'), 'retro' => t('retro arcade style face'));
    $ratings = array('g' => 'g', 'pg' => 'pg', 'r' => 'r', 'x' => 'x');
    // Check if Libravatar is enabled and show warning
    $r = q("SELECT * FROM `addon` WHERE `name` = '%s' and `installed` = 1", dbesc('libravatar'));
    if (count($r)) {
        $o = '<h5>' . t('Information') . '</h5><p>' . t('Libravatar addon is installed, too. Please disable Libravatar addon or this Gravatar addon.<br>The Libravatar addon will fall back to Gravatar if nothing was found at Libravatar.') . '</p><br><br>';
    }
    // output Gravatar settings
    $o .= '<input type="hidden" name="form_security_token" value="' . get_form_security_token("gravatarsave") . '">';
    $o .= replace_macros($t, array('$submit' => t('Save Settings'), '$default_avatar' => array('avatar', t('Default avatar image'), $default_avatar, t('Select default avatar image if none was found at Gravatar. See README'), $default_avatars), '$rating' => array('rating', t('Rating of images'), $rating, t('Select the appropriate avatar rating for your site. See README'), $ratings)));
}
Esempio n. 4
0
 /**
  * @brief Logs admin page.
  *
  * @return string
  */
 function get()
 {
     $log_choices = array(LOGGER_NORMAL => 'Normal', LOGGER_TRACE => 'Trace', LOGGER_DEBUG => 'Debug', LOGGER_DATA => 'Data', LOGGER_ALL => 'All');
     $t = get_markup_template('admin_logs.tpl');
     $f = get_config('system', 'logfile');
     $data = '';
     if (!file_exists($f)) {
         $data = t("Error trying to open <strong>{$f}</strong> log file.\r\n<br/>Check to see if file {$f} exist and is \n\treadable.");
     } else {
         $fp = fopen($f, 'r');
         if (!$fp) {
             $data = t("Couldn't open <strong>{$f}</strong> log file.\r\n<br/>Check to see if file {$f} is readable.");
         } else {
             $fstat = fstat($fp);
             $size = $fstat['size'];
             if ($size != 0) {
                 if ($size > 5000000 || $size < 0) {
                     $size = 5000000;
                 }
                 $seek = fseek($fp, 0 - $size, SEEK_END);
                 if ($seek === 0) {
                     $data = escape_tags(fread($fp, $size));
                     while (!feof($fp)) {
                         $data .= escape_tags(fread($fp, 4096));
                     }
                 }
             }
             fclose($fp);
         }
     }
     return replace_macros($t, array('$title' => t('Administration'), '$page' => t('Logs'), '$submit' => t('Submit'), '$clear' => t('Clear'), '$data' => $data, '$baseurl' => z_root(), '$logname' => get_config('system', 'logfile'), '$debugging' => array('debugging', t("Debugging"), get_config('system', 'debugging'), ""), '$logfile' => array('logfile', t("Log file"), get_config('system', 'logfile'), t("Must be writable by web server. Relative to your top-level webserver directory.")), '$loglevel' => array('loglevel', t("Log level"), get_config('system', 'loglevel'), "", $log_choices), '$form_security_token' => get_form_security_token('admin_logs')));
 }
Esempio n. 5
0
 function get()
 {
     $account_settings = "";
     call_hooks('account_settings', $account_settings);
     $email = \App::$account['account_email'];
     $techlevels = ['0' => t('Beginner/Basic'), '1' => t('Novice - not skilled but willing to learn'), '2' => t('Intermediate - somewhat comfortable'), '3' => t('Advanced - very comfortable'), '4' => t('Expert - I can write computer code'), '5' => t('Wizard - I probably know more than you do')];
     $def_techlevel = \App::$account['account_level'];
     $techlock = get_config('system', 'techlevel_lock');
     $tpl = get_markup_template("settings_account.tpl");
     $o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("settings_account"), '$title' => t('Account Settings'), '$origpass' => array('origpass', t('Current Password'), ' ', ''), '$password1' => array('npassword', t('Enter New Password'), '', ''), '$password2' => array('confirm', t('Confirm New Password'), '', t('Leave password fields blank unless changing')), '$techlevel' => ['techlevel', t('Your technical skill level'), $def_techlevel, t('Used to provide a member experience matched to your comfort level'), $techlevels], '$techlock' => $techlock, '$submit' => t('Submit'), '$email' => array('email', t('Email Address:'), $email, ''), '$removeme' => t('Remove Account'), '$removeaccount' => t('Remove this account including all its channels'), '$account_settings' => $account_settings));
     return $o;
 }
Esempio n. 6
0
 function get()
 {
     $settings_addons = "";
     $o = '';
     $r = q("SELECT * FROM `hook` WHERE `hook` = 'feature_settings' ");
     if (!$r) {
         $settings_addons = t('No feature settings configured');
     }
     call_hooks('feature_settings', $settings_addons);
     $tpl = get_markup_template("settings_addons.tpl");
     $o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("settings_featured"), '$title' => t('Feature/Addon Settings'), '$settings_addons' => $settings_addons));
     return $o;
 }
Esempio n. 7
0
 function get()
 {
     $arr = array();
     $features = get_features();
     foreach ($features as $fname => $fdata) {
         $arr[$fname] = array();
         $arr[$fname][0] = $fdata[0];
         foreach (array_slice($fdata, 1) as $f) {
             $arr[$fname][1][] = array('feature_' . $f[0], $f[1], intval(feature_enabled(local_channel(), $f[0])) ? "1" : '', $f[2], array(t('Off'), t('On')));
         }
     }
     $tpl = get_markup_template("settings_features.tpl");
     $o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("settings_features"), '$title' => t('Additional Features'), '$features' => $arr, '$submit' => t('Submit')));
     return $o;
 }
function defaultfeatures_plugin_admin(&$a, &$o)
{
    $t = get_markup_template("admin.tpl", "addon/defaultfeatures/");
    $token = get_form_security_token("defaultfeaturessave");
    $arr = array();
    $features = get_features();
    foreach ($features as $fname => $fdata) {
        $arr[$fname] = array();
        $arr[$fname][0] = $fdata[0];
        foreach (array_slice($fdata, 1) as $f) {
            $arr[$fname][1][] = array('feature_' . $f[0], $f[1], intval(get_config('defaultfeatures', $f[0])) ? "1" : "0", $f[2], array(t('Off'), t('On')));
        }
    }
    //logger("Features: " . print_r($arr,true));
    $o = replace_macros($t, array('$submit' => t('Save Settings'), '$features' => $arr, '$form_security_token' => $token));
}
Esempio n. 9
0
/**
 * Display admin settings for this addon
 */
function gravatar_plugin_admin(&$a, &$o)
{
    $t = file_get_contents(dirname(__FILE__) . "/admin.tpl");
    $default_avatar = get_config('gravatar', 'default_img');
    $rating = get_config('gravatar', 'rating');
    // set default values for first configuration
    if (!$default_avatar) {
        $default_avatar = 'identicon';
    }
    // pseudo-random geometric pattern based on email hash
    if (!$rating) {
        $rating = 'g';
    }
    // suitable for display on all websites with any audience type
    // Available options for the select boxes
    $default_avatars = array('mm' => t('generic profile image'), 'identicon' => t('random geometric pattern'), 'monsterid' => t('monster face'), 'wavatar' => t('computer generated face'), 'retro' => t('retro arcade style face'));
    $ratings = array('g' => 'g', 'pg' => 'pg', 'r' => 'r', 'x' => 'x');
    $o = '<input type="hidden" name="form_security_token" value="' . get_form_security_token("gravatarsave") . '">';
    $o .= replace_macros($t, array('$submit' => t('Submit'), '$default_avatar' => array('avatar', t('Default avatar image'), $default_avatar, t('Select default avatar image if none was found at Gravatar. See README'), $default_avatars), '$rating' => array('rating', t('Rating of images'), $rating, t('Select the appropriate avatar rating for your site. See README'), $ratings)));
}
Esempio n. 10
0
 function pconfig_form($cat, $k)
 {
     $o = '<form action="pconfig" method="post" >';
     $o .= '<input type="hidden" name="form_security_token" value="' . get_form_security_token('pconfig') . '" />';
     $v = get_pconfig(local_channel(), $cat, $k);
     if (strpos($k, 'password') !== false) {
         $v = z_unobscure($v);
     }
     $o .= '<input type="hidden" name="cat" value="' . $cat . '" />';
     $o .= '<input type="hidden" name="k" value="' . $k . '" />';
     if (strpos($v, "\n")) {
         $o .= '<textarea name="v" >' . escape_tags($v) . '</textarea>';
     } else {
         $o .= '<input type="text" name="v" value="' . escape_tags($v) . '" />';
     }
     $o .= EOL . EOL;
     $o .= '<input type="submit" name="submit" value="' . t('Submit') . '" />';
     $o .= '</form>';
     return $o;
 }
Esempio n. 11
0
 function get()
 {
     if (argc() > 1 && argv(1) === 'features') {
         $arr = array();
         $features = get_features(false);
         foreach ($features as $fname => $fdata) {
             $arr[$fname] = array();
             $arr[$fname][0] = $fdata[0];
             foreach (array_slice($fdata, 1) as $f) {
                 $set = get_config('feature', $f[0]);
                 if ($set === false) {
                     $set = $f[3];
                 }
                 $arr[$fname][1][] = array(array('feature_' . $f[0], $f[1], $set, $f[2], array(t('Off'), t('On'))), array('featurelock_' . $f[0], sprintf(t('Lock feature %s'), $f[1]), $f[4] !== false ? 1 : 0, '', array(t('Off'), t('On'))));
             }
         }
         $tpl = get_markup_template("admin_settings_features.tpl");
         $o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("admin_manage_features"), '$title' => t('Manage Additional Features'), '$features' => $arr, '$submit' => t('Submit')));
         return $o;
     }
 }
Esempio n. 12
0
 function get()
 {
     $whitesites = get_config('system', 'whitelisted_sites');
     $whitesites_str = is_array($whitesites) ? implode($whitesites, "\n") : '';
     $blacksites = get_config('system', 'blacklisted_sites');
     $blacksites_str = is_array($blacksites) ? implode($blacksites, "\n") : '';
     $whitechannels = get_config('system', 'whitelisted_channels');
     $whitechannels_str = is_array($whitechannels) ? implode($whitechannels, "\n") : '';
     $blackchannels = get_config('system', 'blacklisted_channels');
     $blackchannels_str = is_array($blackchannels) ? implode($blackchannels, "\n") : '';
     $whiteembeds = get_config('system', 'embed_allow');
     $whiteembeds_str = is_array($whiteembeds) ? implode($whiteembeds, "\n") : '';
     $blackembeds = get_config('system', 'embed_deny');
     $blackembeds_str = is_array($blackembeds) ? implode($blackembeds, "\n") : '';
     $embed_coop = intval(get_config('system', 'embed_coop'));
     if (!$whiteembeds && !$blackembeds) {
         $embedhelp1 = t("By default, unfiltered HTML is allowed in embedded media. This is inherently insecure.");
     }
     $embedhelp2 = t("The recommended setting is to only allow unfiltered HTML from the following sites:");
     $embedhelp3 = t("https://youtube.com/<br />https://www.youtube.com/<br />https://youtu.be/<br />https://vimeo.com/<br />https://soundcloud.com/<br />");
     $embedhelp4 = t("All other embedded content will be filtered, <strong>unless</strong> embedded content from that site is explicitly blocked.");
     $t = get_markup_template('admin_security.tpl');
     return replace_macros($t, array('$title' => t('Administration'), '$page' => t('Security'), '$form_security_token' => get_form_security_token('admin_security'), '$block_public' => array('block_public', t("Block public"), get_config('system', 'block_public'), t("Check to block public access to all otherwise public personal pages on this site unless you are currently authenticated.")), '$transport_security' => array('transport_security', t('Set "Transport Security" HTTP header'), intval(get_config('system', 'transport_security_header')), ''), '$content_security' => array('content_security', t('Set "Content Security Policy" HTTP header'), intval(get_config('system', 'content_security_policy')), ''), '$allowed_email' => array('allowed_email', t("Allowed email domains"), get_config('system', 'allowed_email'), t("Comma separated list of domains which are allowed in email addresses for registrations to this site. Wildcards are accepted. Empty to allow any domains")), '$not_allowed_email' => array('not_allowed_email', t("Not allowed email domains"), get_config('system', 'not_allowed_email'), t("Comma separated list of domains which are not allowed in email addresses for registrations to this site. Wildcards are accepted. Empty to allow any domains, unless allowed domains have been defined.")), '$whitelisted_sites' => array('whitelisted_sites', t('Allow communications only from these sites'), $whitesites_str, t('One site per line. Leave empty to allow communication from anywhere by default')), '$blacklisted_sites' => array('blacklisted_sites', t('Block communications from these sites'), $blacksites_str, ''), '$whitelisted_channels' => array('whitelisted_channels', t('Allow communications only from these channels'), $whitechannels_str, t('One channel (hash) per line. Leave empty to allow from any channel by default')), '$blacklisted_channels' => array('blacklisted_channels', t('Block communications from these channels'), $blackchannels_str, ''), '$embed_sslonly' => array('embed_sslonly', t('Only allow embeds from secure (SSL) websites and links.'), intval(get_config('system', 'embed_sslonly')), ''), '$embed_allow' => array('embed_allow', t('Allow unfiltered embedded HTML content only from these domains'), $whiteembeds_str, t('One site per line. By default embedded content is filtered.')), '$embed_deny' => array('embed_deny', t('Block embedded HTML from these domains'), $blackembeds_str, ''), '$submit' => t('Submit')));
 }
Esempio n. 13
0
 function get()
 {
     require_once 'include/acl_selectors.php';
     require_once 'include/permissions.php';
     $yes_no = array(t('No'), t('Yes'));
     $p = q("SELECT * FROM `profile` WHERE `is_default` = 1 AND `uid` = %d LIMIT 1", intval(local_channel()));
     if (count($p)) {
         $profile = $p[0];
     }
     load_pconfig(local_channel(), 'expire');
     $channel = \App::get_channel();
     $global_perms = \Zotlabs\Access\Permissions::Perms();
     $permiss = array();
     $perm_opts = array(array(t('Nobody except yourself'), 0), array(t('Only those you specifically allow'), PERMS_SPECIFIC), array(t('Approved connections'), PERMS_CONTACTS), array(t('Any connections'), PERMS_PENDING), array(t('Anybody on this website'), PERMS_SITE), array(t('Anybody in this network'), PERMS_NETWORK), array(t('Anybody authenticated'), PERMS_AUTHED), array(t('Anybody on the internet'), PERMS_PUBLIC));
     $limits = \Zotlabs\Access\PermissionLimits::Get(local_channel());
     foreach ($global_perms as $k => $perm) {
         $options = array();
         foreach ($perm_opts as $opt) {
             if (!strstr($k, 'view') && $opt[1] == PERMS_PUBLIC) {
                 continue;
             }
             $options[$opt[1]] = $opt[0];
         }
         $permiss[] = array($k, $perm, $limits[$k], '', $options);
     }
     $username = $channel['channel_name'];
     $nickname = $channel['channel_address'];
     $timezone = $channel['channel_timezone'];
     $notify = $channel['channel_notifyflags'];
     $defloc = $channel['channel_location'];
     $maxreq = $channel['channel_max_friend_req'];
     $expire = $channel['channel_expire_days'];
     $adult_flag = intval($channel['channel_pageflags'] & PAGE_ADULT);
     $sys_expire = get_config('system', 'default_expire_days');
     //		$unkmail    = \App::$user['unkmail'];
     //		$cntunkmail = \App::$user['cntunkmail'];
     $hide_presence = intval(get_pconfig(local_channel(), 'system', 'hide_online_status'));
     $expire_items = get_pconfig(local_channel(), 'expire', 'items');
     $expire_items = $expire_items === false ? '1' : $expire_items;
     // default if not set: 1
     $expire_notes = get_pconfig(local_channel(), 'expire', 'notes');
     $expire_notes = $expire_notes === false ? '1' : $expire_notes;
     // default if not set: 1
     $expire_starred = get_pconfig(local_channel(), 'expire', 'starred');
     $expire_starred = $expire_starred === false ? '1' : $expire_starred;
     // default if not set: 1
     $expire_photos = get_pconfig(local_channel(), 'expire', 'photos');
     $expire_photos = $expire_photos === false ? '0' : $expire_photos;
     // default if not set: 0
     $expire_network_only = get_pconfig(local_channel(), 'expire', 'network_only');
     $expire_network_only = $expire_network_only === false ? '0' : $expire_network_only;
     // default if not set: 0
     $suggestme = get_pconfig(local_channel(), 'system', 'suggestme');
     $suggestme = $suggestme === false ? '0' : $suggestme;
     // default if not set: 0
     $post_newfriend = get_pconfig(local_channel(), 'system', 'post_newfriend');
     $post_newfriend = $post_newfriend === false ? '0' : $post_newfriend;
     // default if not set: 0
     $post_joingroup = get_pconfig(local_channel(), 'system', 'post_joingroup');
     $post_joingroup = $post_joingroup === false ? '0' : $post_joingroup;
     // default if not set: 0
     $post_profilechange = get_pconfig(local_channel(), 'system', 'post_profilechange');
     $post_profilechange = $post_profilechange === false ? '0' : $post_profilechange;
     // default if not set: 0
     $blocktags = get_pconfig(local_channel(), 'system', 'blocktags');
     $blocktags = $blocktags === false ? '0' : $blocktags;
     $timezone = date_default_timezone_get();
     $opt_tpl = get_markup_template("field_checkbox.tpl");
     if (get_config('system', 'publish_all')) {
         $profile_in_dir = '<input type="hidden" name="profile_in_directory" value="1" />';
     } else {
         $profile_in_dir = replace_macros($opt_tpl, array('$field' => array('profile_in_directory', t('Publish your default profile in the network directory'), $profile['publish'], '', $yes_no)));
     }
     $suggestme = replace_macros($opt_tpl, array('$field' => array('suggestme', t('Allow us to suggest you as a potential friend to new members?'), $suggestme, '', $yes_no)));
     $subdir = strlen(\App::get_path()) ? '<br />' . t('or') . ' ' . z_root() . '/channel/' . $nickname : '';
     $tpl_addr = get_markup_template("settings_nick_set.tpl");
     $prof_addr = replace_macros($tpl_addr, array('$desc' => t('Your channel address is'), '$nickname' => $nickname, '$subdir' => $subdir, '$basepath' => \App::get_hostname()));
     $stpl = get_markup_template('settings.tpl');
     $acl = new \Zotlabs\Access\AccessList($channel);
     $perm_defaults = $acl->get();
     require_once 'include/group.php';
     $group_select = mini_group_select(local_channel(), $channel['channel_default_group']);
     require_once 'include/menu.php';
     $m1 = menu_list(local_channel());
     $menu = false;
     if ($m1) {
         $menu = array();
         $current = get_pconfig(local_channel(), 'system', 'channel_menu');
         $menu[] = array('name' => '', 'selected' => !$current ? true : false);
         foreach ($m1 as $m) {
             $menu[] = array('name' => htmlspecialchars($m['menu_name'], ENT_COMPAT, 'UTF-8'), 'selected' => $m['menu_name'] === $current ? ' selected="selected" ' : false);
         }
     }
     $evdays = get_pconfig(local_channel(), 'system', 'evdays');
     if (!$evdays) {
         $evdays = 3;
     }
     $permissions_role = get_pconfig(local_channel(), 'system', 'permissions_role');
     if (!$permissions_role) {
         $permissions_role = 'custom';
     }
     $permissions_set = $permissions_role != 'custom' ? true : false;
     $perm_roles = \Zotlabs\Access\PermissionRoles::roles();
     if (get_account_techlevel() < 4 && $permissions_role !== 'custom') {
         unset($perm_roles[t('Other')]);
     }
     $vnotify = get_pconfig(local_channel(), 'system', 'vnotify');
     $always_show_in_notices = get_pconfig(local_channel(), 'system', 'always_show_in_notices');
     if ($vnotify === false) {
         $vnotify = -1;
     }
     $o .= replace_macros($stpl, array('$ptitle' => t('Channel Settings'), '$submit' => t('Submit'), '$baseurl' => z_root(), '$uid' => local_channel(), '$form_security_token' => get_form_security_token("settings"), '$nickname_block' => $prof_addr, '$h_basic' => t('Basic Settings'), '$username' => array('username', t('Full Name:'), $username, ''), '$email' => array('email', t('Email Address:'), $email, ''), '$timezone' => array('timezone_select', t('Your Timezone:'), $timezone, '', get_timezones()), '$defloc' => array('defloc', t('Default Post Location:'), $defloc, t('Geographical location to display on your posts')), '$allowloc' => array('allow_location', t('Use Browser Location:'), get_pconfig(local_channel(), 'system', 'use_browser_location') ? 1 : '', '', $yes_no), '$adult' => array('adult', t('Adult Content'), $adult_flag, t('This channel frequently or regularly publishes adult content. (Please tag any adult material and/or nudity with #NSFW)'), $yes_no), '$h_prv' => t('Security and Privacy Settings'), '$permissions_set' => $permissions_set, '$server_role' => \Zotlabs\Lib\System::get_server_role(), '$perms_set_msg' => t('Your permissions are already configured. Click to view/adjust'), '$hide_presence' => array('hide_presence', t('Hide my online presence'), $hide_presence, t('Prevents displaying in your profile that you are online'), $yes_no), '$lbl_pmacro' => t('Simple Privacy Settings:'), '$pmacro3' => t('Very Public - <em>extremely permissive (should be used with caution)</em>'), '$pmacro2' => t('Typical - <em>default public, privacy when desired (similar to social network permissions but with improved privacy)</em>'), '$pmacro1' => t('Private - <em>default private, never open or public</em>'), '$pmacro0' => t('Blocked - <em>default blocked to/from everybody</em>'), '$permiss_arr' => $permiss, '$blocktags' => array('blocktags', t('Allow others to tag your posts'), 1 - $blocktags, t('Often used by the community to retro-actively flag inappropriate content'), $yes_no), '$lbl_p2macro' => t('Channel Permission Limits'), '$expire' => array('expire', t('Expire other channel content after this many days'), $expire, t('0 or blank to use the website limit.') . ' ' . (intval($sys_expire) ? sprintf(t('This website expires after %d days.'), intval($sys_expire)) : t('This website does not expire imported content.')) . ' ' . t('The website limit takes precedence if lower than your limit.')), '$maxreq' => array('maxreq', t('Maximum Friend Requests/Day:'), intval($channel['channel_max_friend_req']), t('May reduce spam activity')), '$permissions' => t('Default Access Control List (ACL)'), '$permdesc' => t("(click to open/close)"), '$aclselect' => populate_acl($perm_defaults, false, \Zotlabs\Lib\PermissionDescription::fromDescription(t('Use my default audience setting for the type of object published'))), '$allow_cid' => acl2json($perm_defaults['allow_cid']), '$allow_gid' => acl2json($perm_defaults['allow_gid']), '$deny_cid' => acl2json($perm_defaults['deny_cid']), '$deny_gid' => acl2json($perm_defaults['deny_gid']), '$suggestme' => $suggestme, '$group_select' => $group_select, '$role' => array('permissions_role', t('Channel permissions category:'), $permissions_role, '', $perm_roles), '$profile_in_dir' => $profile_in_dir, '$hide_friends' => $hide_friends, '$hide_wall' => $hide_wall, '$unkmail' => $unkmail, '$cntunkmail' => array('cntunkmail', t('Maximum private messages per day from unknown people:'), intval($channel['channel_max_anon_mail']), t("Useful to reduce spamming")), '$h_not' => t('Notification Settings'), '$activity_options' => t('By default post a status message when:'), '$post_newfriend' => array('post_newfriend', t('accepting a friend request'), $post_newfriend, '', $yes_no), '$post_joingroup' => array('post_joingroup', t('joining a forum/community'), $post_joingroup, '', $yes_no), '$post_profilechange' => array('post_profilechange', t('making an <em>interesting</em> profile change'), $post_profilechange, '', $yes_no), '$lbl_not' => t('Send a notification email when:'), '$notify1' => array('notify1', t('You receive a connection request'), $notify & NOTIFY_INTRO, NOTIFY_INTRO, '', $yes_no), '$notify2' => array('notify2', t('Your connections are confirmed'), $notify & NOTIFY_CONFIRM, NOTIFY_CONFIRM, '', $yes_no), '$notify3' => array('notify3', t('Someone writes on your profile wall'), $notify & NOTIFY_WALL, NOTIFY_WALL, '', $yes_no), '$notify4' => array('notify4', t('Someone writes a followup comment'), $notify & NOTIFY_COMMENT, NOTIFY_COMMENT, '', $yes_no), '$notify5' => array('notify5', t('You receive a private message'), $notify & NOTIFY_MAIL, NOTIFY_MAIL, '', $yes_no), '$notify6' => array('notify6', t('You receive a friend suggestion'), $notify & NOTIFY_SUGGEST, NOTIFY_SUGGEST, '', $yes_no), '$notify7' => array('notify7', t('You are tagged in a post'), $notify & NOTIFY_TAGSELF, NOTIFY_TAGSELF, '', $yes_no), '$notify8' => array('notify8', t('You are poked/prodded/etc. in a post'), $notify & NOTIFY_POKE, NOTIFY_POKE, '', $yes_no), '$lbl_vnot' => t('Show visual notifications including:'), '$vnotify1' => array('vnotify1', t('Unseen grid activity'), $vnotify & VNOTIFY_NETWORK, VNOTIFY_NETWORK, '', $yes_no), '$vnotify2' => array('vnotify2', t('Unseen channel activity'), $vnotify & VNOTIFY_CHANNEL, VNOTIFY_CHANNEL, '', $yes_no), '$vnotify3' => array('vnotify3', t('Unseen private messages'), $vnotify & VNOTIFY_MAIL, VNOTIFY_MAIL, t('Recommended'), $yes_no), '$vnotify4' => array('vnotify4', t('Upcoming events'), $vnotify & VNOTIFY_EVENT, VNOTIFY_EVENT, '', $yes_no), '$vnotify5' => array('vnotify5', t('Events today'), $vnotify & VNOTIFY_EVENTTODAY, VNOTIFY_EVENTTODAY, '', $yes_no), '$vnotify6' => array('vnotify6', t('Upcoming birthdays'), $vnotify & VNOTIFY_BIRTHDAY, VNOTIFY_BIRTHDAY, t('Not available in all themes'), $yes_no), '$vnotify7' => array('vnotify7', t('System (personal) notifications'), $vnotify & VNOTIFY_SYSTEM, VNOTIFY_SYSTEM, '', $yes_no), '$vnotify8' => array('vnotify8', t('System info messages'), $vnotify & VNOTIFY_INFO, VNOTIFY_INFO, t('Recommended'), $yes_no), '$vnotify9' => array('vnotify9', t('System critical alerts'), $vnotify & VNOTIFY_ALERT, VNOTIFY_ALERT, t('Recommended'), $yes_no), '$vnotify10' => array('vnotify10', t('New connections'), $vnotify & VNOTIFY_INTRO, VNOTIFY_INTRO, t('Recommended'), $yes_no), '$vnotify11' => array('vnotify11', t('System Registrations'), $vnotify & VNOTIFY_REGISTER, VNOTIFY_REGISTER, '', $yes_no), '$always_show_in_notices' => array('always_show_in_notices', t('Also show new wall posts, private messages and connections under Notices'), $always_show_in_notices, 1, '', $yes_no), '$evdays' => array('evdays', t('Notify me of events this many days in advance'), $evdays, t('Must be greater than 0')), '$h_advn' => t('Advanced Account/Page Type Settings'), '$h_descadvn' => t('Change the behaviour of this account for special situations'), '$pagetype' => $pagetype, '$lbl_misc' => t('Miscellaneous Settings'), '$photo_path' => array('photo_path', t('Default photo upload folder'), get_pconfig(local_channel(), 'system', 'photo_path'), t('%Y - current year, %m -  current month')), '$attach_path' => array('attach_path', t('Default file upload folder'), get_pconfig(local_channel(), 'system', 'attach_path'), t('%Y - current year, %m -  current month')), '$menus' => $menu, '$menu_desc' => t('Personal menu to display in your channel pages'), '$removeme' => t('Remove Channel'), '$removechannel' => t('Remove this channel.'), '$firefoxshare' => t('Firefox Share $Projectname provider'), '$cal_first_day' => array('first_day', t('Start calendar week on monday'), get_pconfig(local_channel(), 'system', 'cal_first_day') ? 1 : '', '', $yes_no)));
     call_hooks('settings_form', $o);
     //$o .= '</form>' . "\r\n";
     return $o;
 }
Esempio n. 14
0
function settings_content(&$a)
{
    $o = '';
    nav_set_selected('settings');
    if (!local_channel() || $_SESSION['delegate']) {
        notice(t('Permission denied.') . EOL);
        return login();
    }
    $channel = $a->get_channel();
    if ($channel) {
        head_set_icon($channel['xchan_photo_s']);
    }
    $yes_no = array(t('No'), t('Yes'));
    if (argc() > 1 && argv(1) === 'oauth') {
        if (argc() > 2 && argv(2) === 'add') {
            $tpl = get_markup_template("settings_oauth_edit.tpl");
            $o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("settings_oauth"), '$title' => t('Add application'), '$submit' => t('Submit'), '$cancel' => t('Cancel'), '$name' => array('name', t('Name'), '', t('Name of application')), '$key' => array('key', t('Consumer Key'), random_string(16), t('Automatically generated - change if desired. Max length 20')), '$secret' => array('secret', t('Consumer Secret'), random_string(16), t('Automatically generated - change if desired. Max length 20')), '$redirect' => array('redirect', t('Redirect'), '', t('Redirect URI - leave blank unless your application specifically requires this')), '$icon' => array('icon', t('Icon url'), '', t('Optional'))));
            return $o;
        }
        if (argc() > 3 && argv(2) === 'edit') {
            $r = q("SELECT * FROM clients WHERE client_id='%s' AND uid=%d", dbesc(argv(3)), local_channel());
            if (!count($r)) {
                notice(t("You can't edit this application."));
                return;
            }
            $app = $r[0];
            $tpl = get_markup_template("settings_oauth_edit.tpl");
            $o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("settings_oauth"), '$title' => t('Add application'), '$submit' => t('Update'), '$cancel' => t('Cancel'), '$name' => array('name', t('Name'), $app['name'], ''), '$key' => array('key', t('Consumer Key'), $app['client_id'], ''), '$secret' => array('secret', t('Consumer Secret'), $app['pw'], ''), '$redirect' => array('redirect', t('Redirect'), $app['redirect_uri'], ''), '$icon' => array('icon', t('Icon url'), $app['icon'], '')));
            return $o;
        }
        if (argc() > 3 && argv(2) === 'delete') {
            check_form_security_token_redirectOnErr('/settings/oauth', 'settings_oauth', 't');
            $r = q("DELETE FROM clients WHERE client_id='%s' AND uid=%d", dbesc(argv(3)), local_channel());
            goaway($a->get_baseurl(true) . "/settings/oauth/");
            return;
        }
        $r = q("SELECT clients.*, tokens.id as oauth_token, (clients.uid=%d) AS my \n\t\t\t\tFROM clients\n\t\t\t\tLEFT JOIN tokens ON clients.client_id=tokens.client_id\n\t\t\t\tWHERE clients.uid IN (%d,0)", local_channel(), local_channel());
        $tpl = get_markup_template("settings_oauth.tpl");
        $o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("settings_oauth"), '$baseurl' => $a->get_baseurl(true), '$title' => t('Connected Apps'), '$add' => t('Add application'), '$edit' => t('Edit'), '$delete' => t('Delete'), '$consumerkey' => t('Client key starts with'), '$noname' => t('No name'), '$remove' => t('Remove authorization'), '$apps' => $r));
        return $o;
    }
    if (argc() > 1 && argv(1) === 'featured') {
        $settings_addons = "";
        $o = '';
        $r = q("SELECT * FROM `hook` WHERE `hook` = 'feature_settings' ");
        if (!$r) {
            $settings_addons = t('No feature settings configured');
        }
        call_hooks('feature_settings', $settings_addons);
        $tpl = get_markup_template("settings_addons.tpl");
        $o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("settings_featured"), '$title' => t('Feature/Addon Settings'), '$settings_addons' => $settings_addons));
        return $o;
    }
    /*
     * ACCOUNT SETTINGS
     */
    if (argc() > 1 && argv(1) === 'account') {
        $account_settings = "";
        call_hooks('account_settings', $account_settings);
        $email = $a->account['account_email'];
        $tpl = get_markup_template("settings_account.tpl");
        $o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("settings_account"), '$title' => t('Account Settings'), '$password1' => array('npassword', t('Enter New Password:'******'', ''), '$password2' => array('confirm', t('Confirm New Password:'******'', t('Leave password fields blank unless changing')), '$submit' => t('Submit'), '$email' => array('email', t('Email Address:'), $email, ''), '$removeme' => t('Remove Account'), '$removeaccount' => t('Remove this account including all its channels'), '$account_settings' => $account_settings));
        return $o;
    }
    if (argc() > 1 && argv(1) === 'features') {
        $arr = array();
        $features = get_features();
        foreach ($features as $fname => $fdata) {
            $arr[$fname] = array();
            $arr[$fname][0] = $fdata[0];
            foreach (array_slice($fdata, 1) as $f) {
                $arr[$fname][1][] = array('feature_' . $f[0], $f[1], intval(feature_enabled(local_channel(), $f[0])) ? "1" : '', $f[2], array(t('Off'), t('On')));
            }
        }
        $tpl = get_markup_template("settings_features.tpl");
        $o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("settings_features"), '$title' => t('Additional Features'), '$features' => $arr, '$submit' => t('Submit')));
        return $o;
    }
    if (argc() > 1 && argv(1) === 'connectors') {
        $settings_connectors = "";
        call_hooks('connector_settings', $settings_connectors);
        $r = null;
        $tpl = get_markup_template("settings_connectors.tpl");
        $o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("settings_connectors"), '$title' => t('Connector Settings'), '$submit' => t('Submit'), '$settings_connectors' => $settings_connectors));
        call_hooks('display_settings', $o);
        return $o;
    }
    /*
     * DISPLAY SETTINGS
     */
    if (argc() > 1 && argv(1) === 'display') {
        $default_theme = get_config('system', 'theme');
        if (!$default_theme) {
            $default_theme = 'default';
        }
        $default_mobile_theme = get_config('system', 'mobile_theme');
        if (!$mobile_default_theme) {
            $mobile_default_theme = 'none';
        }
        $allowed_themes_str = get_config('system', 'allowed_themes');
        $allowed_themes_raw = explode(',', $allowed_themes_str);
        $allowed_themes = array();
        if (count($allowed_themes_raw)) {
            foreach ($allowed_themes_raw as $x) {
                if (strlen(trim($x)) && is_dir("view/theme/{$x}")) {
                    $allowed_themes[] = trim($x);
                }
            }
        }
        $themes = array();
        $files = glob('view/theme/*');
        if ($allowed_themes) {
            foreach ($allowed_themes as $th) {
                $f = $th;
                $is_experimental = file_exists('view/theme/' . $th . '/experimental');
                $unsupported = file_exists('view/theme/' . $th . '/unsupported');
                $is_mobile = file_exists('view/theme/' . $th . '/mobile');
                $is_library = file_exists('view/theme/' . $th . '/library');
                $mobile_themes["---"] = t("No special theme for mobile devices");
                if (!$is_experimental or $is_experimental && (get_config('experimentals', 'exp_themes') == 1 or get_config('experimentals', 'exp_themes') === false)) {
                    $theme_name = $is_experimental ? sprintf(t('%s - (Experimental)'), $f) : $f;
                    if (!$is_library) {
                        if ($is_mobile) {
                            $mobile_themes[$f] = $themes[$f] = $theme_name . ' (' . t('mobile') . ')';
                        } else {
                            $mobile_themes[$f] = $themes[$f] = $theme_name;
                        }
                    }
                }
            }
        }
        $theme_selected = !x($_SESSION, 'theme') ? $default_theme : $_SESSION['theme'];
        $mobile_theme_selected = !x($_SESSION, 'mobile_theme') ? $default_mobile_theme : $_SESSION['mobile_theme'];
        $user_scalable = get_pconfig(local_channel(), 'system', 'user_scalable');
        $user_scalable = $user_scalable === false ? '1' : $user_scalable;
        // default if not set: 1
        $browser_update = intval(get_pconfig(local_channel(), 'system', 'update_interval'));
        $browser_update = $browser_update == 0 ? 80 : $browser_update / 1000;
        // default if not set: 40 seconds
        $itemspage = intval(get_pconfig(local_channel(), 'system', 'itemspage'));
        $itemspage = $itemspage > 0 && $itemspage < 101 ? $itemspage : 20;
        // default if not set: 20 items
        $nosmile = get_pconfig(local_channel(), 'system', 'no_smilies');
        $nosmile = $nosmile === false ? '0' : $nosmile;
        // default if not set: 0
        $title_tosource = get_pconfig(local_channel(), 'system', 'title_tosource');
        $title_tosource = $title_tosource === false ? '0' : $title_tosource;
        // default if not set: 0
        $theme_config = "";
        if (($themeconfigfile = get_theme_config_file($theme_selected)) != null) {
            require_once $themeconfigfile;
            $theme_config = theme_content($a);
        }
        $tpl = get_markup_template("settings_display.tpl");
        $o = replace_macros($tpl, array('$ptitle' => t('Display Settings'), '$d_tset' => t('Theme Settings'), '$d_ctset' => t('Custom Theme Settings'), '$d_cset' => t('Content Settings'), '$form_security_token' => get_form_security_token("settings_display"), '$submit' => t('Submit'), '$baseurl' => $a->get_baseurl(true), '$uid' => local_channel(), '$theme' => $themes ? array('theme', t('Display Theme:'), $theme_selected, '', $themes, 'preview') : false, '$mobile_theme' => $mobile_themes ? array('mobile_theme', t('Mobile Theme:'), $mobile_theme_selected, '', $mobile_themes, '') : false, '$user_scalable' => array('user_scalable', t("Enable user zoom on mobile devices"), $user_scalable, '', $yes_no), '$ajaxint' => array('browser_update', t("Update browser every xx seconds"), $browser_update, t('Minimum of 10 seconds, no maximum')), '$itemspage' => array('itemspage', t("Maximum number of conversations to load at any time:"), $itemspage, t('Maximum of 100 items')), '$nosmile' => array('nosmile', t("Show emoticons (smilies) as images"), 1 - intval($nosmile), '', $yes_no), '$title_tosource' => array('title_tosource', t("Link post titles to source"), $title_tosource, '', $yes_no), '$layout_editor' => t('System Page Layout Editor - (advanced)'), '$theme_config' => $theme_config, '$expert' => feature_enabled(local_channel(), 'expert'), '$channel_list_mode' => array('channel_list_mode', t('Use blog/list mode on channel page'), get_pconfig(local_channel(), 'system', 'channel_list_mode'), t('(comments displayed separately)'), $yes_no), '$network_list_mode' => array('network_list_mode', t('Use blog/list mode on grid page'), get_pconfig(local_channel(), 'system', 'network_list_mode'), t('(comments displayed separately)'), $yes_no), '$channel_divmore_height' => array('channel_divmore_height', t('Channel page max height of content (in pixels)'), get_pconfig(local_channel(), 'system', 'channel_divmore_height') ? get_pconfig(local_channel(), 'system', 'channel_divmore_height') : 400, t('click to expand content exceeding this height')), '$network_divmore_height' => array('network_divmore_height', t('Grid page max height of content (in pixels)'), get_pconfig(local_channel(), 'system', 'network_divmore_height') ? get_pconfig(local_channel(), 'system', 'network_divmore_height') : 400, t('click to expand content exceeding this height'))));
        return $o;
    }
    if (argv(1) === 'channel') {
        require_once 'include/acl_selectors.php';
        require_once 'include/permissions.php';
        $p = q("SELECT * FROM `profile` WHERE `is_default` = 1 AND `uid` = %d LIMIT 1", intval(local_channel()));
        if (count($p)) {
            $profile = $p[0];
        }
        load_pconfig(local_channel(), 'expire');
        $channel = $a->get_channel();
        $global_perms = get_perms();
        $permiss = array();
        $perm_opts = array(array(t('Nobody except yourself'), 0), array(t('Only those you specifically allow'), PERMS_SPECIFIC), array(t('Approved connections'), PERMS_CONTACTS), array(t('Any connections'), PERMS_PENDING), array(t('Anybody on this website'), PERMS_SITE), array(t('Anybody in this network'), PERMS_NETWORK), array(t('Anybody authenticated'), PERMS_AUTHED), array(t('Anybody on the internet'), PERMS_PUBLIC));
        foreach ($global_perms as $k => $perm) {
            $options = array();
            foreach ($perm_opts as $opt) {
                if (!$perm[2] && $opt[1] == PERMS_PUBLIC) {
                    continue;
                }
                $options[$opt[1]] = $opt[0];
            }
            $permiss[] = array($k, $perm[3], $channel[$perm[0]], $perm[4], $options);
        }
        //		logger('permiss: ' . print_r($permiss,true));
        $username = $channel['channel_name'];
        $nickname = $channel['channel_address'];
        $timezone = $channel['channel_timezone'];
        $notify = $channel['channel_notifyflags'];
        $defloc = $channel['channel_location'];
        $maxreq = $channel['channel_max_friend_req'];
        $expire = $channel['channel_expire_days'];
        $adult_flag = intval($channel['channel_pageflags'] & PAGE_ADULT);
        $sys_expire = get_config('system', 'default_expire_days');
        //		$unkmail    = $a->user['unkmail'];
        //		$cntunkmail = $a->user['cntunkmail'];
        $hide_presence = intval(get_pconfig(local_channel(), 'system', 'hide_online_status'));
        $expire_items = get_pconfig(local_channel(), 'expire', 'items');
        $expire_items = $expire_items === false ? '1' : $expire_items;
        // default if not set: 1
        $expire_notes = get_pconfig(local_channel(), 'expire', 'notes');
        $expire_notes = $expire_notes === false ? '1' : $expire_notes;
        // default if not set: 1
        $expire_starred = get_pconfig(local_channel(), 'expire', 'starred');
        $expire_starred = $expire_starred === false ? '1' : $expire_starred;
        // default if not set: 1
        $expire_photos = get_pconfig(local_channel(), 'expire', 'photos');
        $expire_photos = $expire_photos === false ? '0' : $expire_photos;
        // default if not set: 0
        $expire_network_only = get_pconfig(local_channel(), 'expire', 'network_only');
        $expire_network_only = $expire_network_only === false ? '0' : $expire_network_only;
        // default if not set: 0
        $suggestme = get_pconfig(local_channel(), 'system', 'suggestme');
        $suggestme = $suggestme === false ? '0' : $suggestme;
        // default if not set: 0
        $post_newfriend = get_pconfig(local_channel(), 'system', 'post_newfriend');
        $post_newfriend = $post_newfriend === false ? '0' : $post_newfriend;
        // default if not set: 0
        $post_joingroup = get_pconfig(local_channel(), 'system', 'post_joingroup');
        $post_joingroup = $post_joingroup === false ? '0' : $post_joingroup;
        // default if not set: 0
        $post_profilechange = get_pconfig(local_channel(), 'system', 'post_profilechange');
        $post_profilechange = $post_profilechange === false ? '0' : $post_profilechange;
        // default if not set: 0
        $blocktags = get_pconfig(local_channel(), 'system', 'blocktags');
        $blocktags = $blocktags === false ? '0' : $blocktags;
        $timezone = date_default_timezone_get();
        $opt_tpl = get_markup_template("field_checkbox.tpl");
        if (get_config('system', 'publish_all')) {
            $profile_in_dir = '<input type="hidden" name="profile_in_directory" value="1" />';
        } else {
            $profile_in_dir = replace_macros($opt_tpl, array('$field' => array('profile_in_directory', t('Publish your default profile in the network directory'), $profile['publish'], '', $yes_no)));
        }
        $suggestme = replace_macros($opt_tpl, array('$field' => array('suggestme', t('Allow us to suggest you as a potential friend to new members?'), $suggestme, '', $yes_no)));
        $subdir = strlen($a->get_path()) ? '<br />' . t('or') . ' ' . $a->get_baseurl(true) . '/channel/' . $nickname : '';
        $tpl_addr = get_markup_template("settings_nick_set.tpl");
        $prof_addr = replace_macros($tpl_addr, array('$desc' => t('Your channel address is'), '$nickname' => $nickname, '$subdir' => $subdir, '$basepath' => $a->get_hostname()));
        $stpl = get_markup_template('settings.tpl');
        $acl = new AccessList($channel);
        $perm_defaults = $acl->get();
        require_once 'include/group.php';
        $group_select = mini_group_select(local_channel(), $channel['channel_default_group']);
        require_once 'include/menu.php';
        $m1 = menu_list(local_channel());
        $menu = false;
        if ($m1) {
            $menu = array();
            $current = get_pconfig(local_channel(), 'system', 'channel_menu');
            $menu[] = array('name' => '', 'selected' => !$current ? true : false);
            foreach ($m1 as $m) {
                $menu[] = array('name' => htmlspecialchars($m['menu_name'], ENT_COMPAT, 'UTF-8'), 'selected' => $m['menu_name'] === $current ? ' selected="selected" ' : false);
            }
        }
        $evdays = get_pconfig(local_channel(), 'system', 'evdays');
        if (!$evdays) {
            $evdays = 3;
        }
        $permissions_role = get_pconfig(local_channel(), 'system', 'permissions_role');
        if (!$permissions_role) {
            $permissions_role = 'custom';
        }
        $permissions_set = $permissions_role != 'custom' ? true : false;
        $vnotify = get_pconfig(local_channel(), 'system', 'vnotify');
        $always_show_in_notices = get_pconfig(local_channel(), 'system', 'always_show_in_notices');
        if ($vnotify === false) {
            $vnotify = -1;
        }
        $o .= replace_macros($stpl, array('$ptitle' => t('Channel Settings'), '$submit' => t('Submit'), '$baseurl' => $a->get_baseurl(true), '$uid' => local_channel(), '$form_security_token' => get_form_security_token("settings"), '$nickname_block' => $prof_addr, '$h_basic' => t('Basic Settings'), '$username' => array('username', t('Full Name:'), $username, ''), '$email' => array('email', t('Email Address:'), $email, ''), '$timezone' => array('timezone_select', t('Your Timezone:'), $timezone, '', get_timezones()), '$defloc' => array('defloc', t('Default Post Location:'), $defloc, t('Geographical location to display on your posts')), '$allowloc' => array('allow_location', t('Use Browser Location:'), get_pconfig(local_channel(), 'system', 'use_browser_location') ? 1 : '', '', $yes_no), '$adult' => array('adult', t('Adult Content'), $adult_flag, t('This channel frequently or regularly publishes adult content. (Please tag any adult material and/or nudity with #NSFW)'), $yes_no), '$h_prv' => t('Security and Privacy Settings'), '$permissions_set' => $permissions_set, '$perms_set_msg' => t('Your permissions are already configured. Click to view/adjust'), '$hide_presence' => array('hide_presence', t('Hide my online presence'), $hide_presence, t('Prevents displaying in your profile that you are online'), $yes_no), '$lbl_pmacro' => t('Simple Privacy Settings:'), '$pmacro3' => t('Very Public - <em>extremely permissive (should be used with caution)</em>'), '$pmacro2' => t('Typical - <em>default public, privacy when desired (similar to social network permissions but with improved privacy)</em>'), '$pmacro1' => t('Private - <em>default private, never open or public</em>'), '$pmacro0' => t('Blocked - <em>default blocked to/from everybody</em>'), '$permiss_arr' => $permiss, '$blocktags' => array('blocktags', t('Allow others to tag your posts'), 1 - $blocktags, t('Often used by the community to retro-actively flag inappropriate content'), $yes_no), '$lbl_p2macro' => t('Advanced Privacy Settings'), '$expire' => array('expire', t('Expire other channel content after this many days'), $expire, sprintf(t('0 or blank to use the website limit. The website expires after %d days.'), intval($sys_expire))), '$maxreq' => array('maxreq', t('Maximum Friend Requests/Day:'), intval($channel['channel_max_friend_req']), t('May reduce spam activity')), '$permissions' => t('Default Post Permissions'), '$permdesc' => t("(click to open/close)"), '$aclselect' => populate_acl($perm_defaults, false), '$suggestme' => $suggestme, '$group_select' => $group_select, '$role' => array('permissions_role', t('Channel permissions category:'), $permissions_role, '', get_roles()), '$profile_in_dir' => $profile_in_dir, '$hide_friends' => $hide_friends, '$hide_wall' => $hide_wall, '$unkmail' => $unkmail, '$cntunkmail' => array('cntunkmail', t('Maximum private messages per day from unknown people:'), intval($channel['channel_max_anon_mail']), t("Useful to reduce spamming")), '$h_not' => t('Notification Settings'), '$activity_options' => t('By default post a status message when:'), '$post_newfriend' => array('post_newfriend', t('accepting a friend request'), $post_newfriend, '', $yes_no), '$post_joingroup' => array('post_joingroup', t('joining a forum/community'), $post_joingroup, '', $yes_no), '$post_profilechange' => array('post_profilechange', t('making an <em>interesting</em> profile change'), $post_profilechange, '', $yes_no), '$lbl_not' => t('Send a notification email when:'), '$notify1' => array('notify1', t('You receive a connection request'), $notify & NOTIFY_INTRO, NOTIFY_INTRO, '', $yes_no), '$notify2' => array('notify2', t('Your connections are confirmed'), $notify & NOTIFY_CONFIRM, NOTIFY_CONFIRM, '', $yes_no), '$notify3' => array('notify3', t('Someone writes on your profile wall'), $notify & NOTIFY_WALL, NOTIFY_WALL, '', $yes_no), '$notify4' => array('notify4', t('Someone writes a followup comment'), $notify & NOTIFY_COMMENT, NOTIFY_COMMENT, '', $yes_no), '$notify5' => array('notify5', t('You receive a private message'), $notify & NOTIFY_MAIL, NOTIFY_MAIL, '', $yes_no), '$notify6' => array('notify6', t('You receive a friend suggestion'), $notify & NOTIFY_SUGGEST, NOTIFY_SUGGEST, '', $yes_no), '$notify7' => array('notify7', t('You are tagged in a post'), $notify & NOTIFY_TAGSELF, NOTIFY_TAGSELF, '', $yes_no), '$notify8' => array('notify8', t('You are poked/prodded/etc. in a post'), $notify & NOTIFY_POKE, NOTIFY_POKE, '', $yes_no), '$lbl_vnot' => t('Show visual notifications including:'), '$vnotify1' => array('vnotify1', t('Unseen grid activity'), $vnotify & VNOTIFY_NETWORK, VNOTIFY_NETWORK, '', $yes_no), '$vnotify2' => array('vnotify2', t('Unseen channel activity'), $vnotify & VNOTIFY_CHANNEL, VNOTIFY_CHANNEL, '', $yes_no), '$vnotify3' => array('vnotify3', t('Unseen private messages'), $vnotify & VNOTIFY_MAIL, VNOTIFY_MAIL, t('Recommended'), $yes_no), '$vnotify4' => array('vnotify4', t('Upcoming events'), $vnotify & VNOTIFY_EVENT, VNOTIFY_EVENT, '', $yes_no), '$vnotify5' => array('vnotify5', t('Events today'), $vnotify & VNOTIFY_EVENTTODAY, VNOTIFY_EVENTTODAY, '', $yes_no), '$vnotify6' => array('vnotify6', t('Upcoming birthdays'), $vnotify & VNOTIFY_BIRTHDAY, VNOTIFY_BIRTHDAY, t('Not available in all themes'), $yes_no), '$vnotify7' => array('vnotify7', t('System (personal) notifications'), $vnotify & VNOTIFY_SYSTEM, VNOTIFY_SYSTEM, '', $yes_no), '$vnotify8' => array('vnotify8', t('System info messages'), $vnotify & VNOTIFY_INFO, VNOTIFY_INFO, t('Recommended'), $yes_no), '$vnotify9' => array('vnotify9', t('System critical alerts'), $vnotify & VNOTIFY_ALERT, VNOTIFY_ALERT, t('Recommended'), $yes_no), '$vnotify10' => array('vnotify10', t('New connections'), $vnotify & VNOTIFY_INTRO, VNOTIFY_INTRO, t('Recommended'), $yes_no), '$vnotify11' => array('vnotify11', t('System Registrations'), $vnotify & VNOTIFY_REGISTER, VNOTIFY_REGISTER, '', $yes_no), '$always_show_in_notices' => array('always_show_in_notices', t('Also show new wall posts, private messages and connections under Notices'), $always_show_in_notices, 1, '', $yes_no), '$evdays' => array('evdays', t('Notify me of events this many days in advance'), $evdays, t('Must be greater than 0')), '$h_advn' => t('Advanced Account/Page Type Settings'), '$h_descadvn' => t('Change the behaviour of this account for special situations'), '$pagetype' => $pagetype, '$expert' => feature_enabled(local_channel(), 'expert'), '$hint' => t('Please enable expert mode (in <a href="settings/features">Settings > Additional features</a>) to adjust!'), '$lbl_misc' => t('Miscellaneous Settings'), '$photo_path' => array('photo_path', t('Default photo upload folder'), get_pconfig(local_channel(), 'system', 'photo_path'), t('%Y - current year, %m -  current month')), '$attach_path' => array('attach_path', t('Default file upload folder'), get_pconfig(local_channel(), 'system', 'attach_path'), t('%Y - current year, %m -  current month')), '$menus' => $menu, '$menu_desc' => t('Personal menu to display in your channel pages'), '$removeme' => t('Remove Channel'), '$removechannel' => t('Remove this channel.'), '$firefoxshare' => t('Firefox Share $Projectname provider'), '$cal_first_day' => array('first_day', t('Start calendar week on monday'), get_pconfig(local_channel(), 'system', 'cal_first_day') ? 1 : '', '', $yes_no)));
        call_hooks('settings_form', $o);
        $o .= '</form>' . "\r\n";
        return $o;
    }
}
Esempio n. 15
0
 function profile_photo_content(&$a)
 {
     if (!local_user()) {
         notice(t('Permission denied.') . EOL);
         return;
     }
     $newuser = false;
     if ($a->argc == 2 && $a->argv[1] === 'new') {
         $newuser = true;
     }
     if ($a->argv[1] == 'use') {
         if ($a->argc < 3) {
             notice(t('Permission denied.') . EOL);
             return;
         }
         //		check_form_security_token_redirectOnErr('/profile_photo', 'profile_photo');
         $resource_id = $a->argv[2];
         //die(":".local_user());
         $r = q("SELECT * FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s' ORDER BY `scale` ASC", intval(local_user()), dbesc($resource_id));
         if (!count($r)) {
             notice(t('Permission denied.') . EOL);
             return;
         }
         $havescale = false;
         foreach ($r as $rr) {
             if ($rr['scale'] == 5) {
                 $havescale = true;
             }
         }
         // set an already uloaded photo as profile photo
         // if photo is in 'Profile Photos', change it in db
         if ($r[0]['album'] == t('Profile Photos') && $havescale) {
             $r = q("UPDATE `photo` SET `profile`=0 WHERE `profile`=1 AND `uid`=%d", intval(local_user()));
             $r = q("UPDATE `photo` SET `profile`=1 WHERE `uid` = %d AND `resource-id` = '%s'", intval(local_user()), dbesc($resource_id));
             $r = q("UPDATE `contact` SET `avatar-date` = '%s' WHERE `self` = 1 AND `uid` = %d", dbesc(datetime_convert()), intval(local_user()));
             // Update global directory in background
             $url = $_SESSION['my_url'];
             if ($url && strlen(get_config('system', 'directory'))) {
                 proc_run('php', "include/directory.php", "{$url}");
             }
             goaway($a->get_baseurl() . '/profiles');
             return;
             // NOTREACHED
         }
         $ph = new Photo($r[0]['data'], $r[0]['type']);
         profile_photo_crop_ui_head($a, $ph);
         // go ahead as we have jus uploaded a new photo to crop
     }
     $profiles = q("select `id`,`profile-name` as `name`,`is-default` as `default` from profile where uid = %d", intval(local_user()));
     if (!x($a->config, 'imagecrop')) {
         $tpl = get_markup_template('profile_photo.tpl');
         $o .= replace_macros($tpl, array('$user' => $a->user['nickname'], '$lbl_upfile' => t('Upload File:'), '$lbl_profiles' => t('Select a profile:'), '$title' => t('Upload Profile Photo'), '$submit' => t('Upload'), '$profiles' => $profiles, '$form_security_token' => get_form_security_token("profile_photo"), '$select' => sprintf('%s %s', t('or'), $newuser ? '<a href="' . $a->get_baseurl() . '">' . t('skip this step') . '</a>' : '<a href="' . $a->get_baseurl() . '/photos/' . $a->user['nickname'] . '">' . t('select a photo from your photo albums') . '</a>')));
         return $o;
     } else {
         $filename = $a->config['imagecrop'] . '-' . $a->config['imagecrop_resolution'] . '.' . $a->config['imagecrop_ext'];
         $resolution = $a->config['imagecrop_resolution'];
         $tpl = get_markup_template("cropbody.tpl");
         $o .= replace_macros($tpl, array('$filename' => $filename, '$profile' => intval($_REQUEST['profile']), '$resource' => $a->config['imagecrop'] . '-' . $a->config['imagecrop_resolution'], '$image_url' => $a->get_baseurl() . '/photo/' . $filename, '$title' => t('Crop Image'), '$desc' => t('Please adjust the image cropping for optimum viewing.'), '$form_security_token' => get_form_security_token("profile_photo"), '$done' => t('Done Editing')));
         return $o;
     }
     return;
     // NOTREACHED
 }
/**
 * @param wdcal_local $localization
 * @param string $baseurl
 * @param int $calendar_id
 * @param int $uri
 * @return string
 */
function wdcal_getEditPage_str(&$localization, $baseurl, $calendar_id, $uri)
{
    $server = dav_create_server(true, true, false);
    if ($uri > 0) {
        $calendar = dav_get_current_user_calendar_by_id($server, $calendar_id, DAV_ACL_WRITE);
        if (!$calendar) {
            $calendar = dav_get_current_user_calendar_by_id($server, $calendar_id, DAV_ACL_READ);
            $calendars = array();
        } else {
            $calendars = dav_get_current_user_calendars($server, DAV_ACL_WRITE);
        }
        if ($calendar == null) {
            return "Calendar not found";
        }
        $obj_uri = Sabre_CalDAV_Backend_Common::loadCalendarobjectById($uri);
        $vObject = dav_get_current_user_calendarobject($server, $calendar, $obj_uri["uri"], DAV_ACL_WRITE);
        $component = dav_get_eventComponent($vObject);
        if ($component == null) {
            return t('Could not open component for editing');
        }
        /** @var Sabre\VObject\Property\DateTime $dtstart  */
        $dtstart = $component->__get("DTSTART");
        $event = array("id" => IntVal($uri), "Summary" => $component->__get("SUMMARY") ? $component->__get("SUMMARY")->value : null, "StartTime" => $dtstart->getDateTime()->getTimeStamp(), "EndTime" => Sabre_CalDAV_Backend_Common::getDtEndTimeStamp($component), "IsAllDayEvent" => strlen($dtstart->value) == 8, "Description" => $component->__get("DESCRIPTION") ? $component->__get("DESCRIPTION")->value : null, "Location" => $component->__get("LOCATION") ? $component->__get("LOCATION")->value : null, "Color" => $component->__get("X-ANIMEXX-COLOR") ? $component->__get("X-ANIMEXX-COLOR")->value : null);
        $exdates = $component->select("EXDATE");
        $recurrentce_exdates = array();
        /** @var Sabre\VObject\Property\MultiDateTime $x */
        foreach ($exdates as $x) {
            /** @var DateTime $y */
            $z = $x->getDateTimes();
            foreach ($z as $y) {
                $recurrentce_exdates[] = $y->getTimeStamp();
            }
        }
        $notifications = array();
        $alarms = $component->select("VALARM");
        foreach ($alarms as $alarm) {
            /** @var Sabre_VObject_Component_VAlarm $alarm */
            $action = $alarm->__get("ACTION")->value;
            $trigger = $alarm->__get("TRIGGER");
            if (isset($trigger['VALUE']) && strtoupper($trigger['VALUE']) !== 'DURATION') {
                notice("The notification of this event cannot be parsed");
                continue;
            }
            /** @var DateInterval $triggerDuration  */
            $triggerDuration = Sabre_VObject_DateTimeParser::parseDuration($trigger);
            $unit = "hour";
            $value = 1;
            if ($triggerDuration->s > 0) {
                $unit = "second";
                $value = $triggerDuration->s + $triggerDuration->i * 60 + $triggerDuration->h * 3600 + $triggerDuration->d * 3600 * 24;
                // @TODO support more than days?
            } elseif ($triggerDuration->i) {
                $unit = "minute";
                $value = $triggerDuration->i + $triggerDuration->h * 60 + $triggerDuration->d * 60 * 24;
            } elseif ($triggerDuration->h) {
                $unit = "hour";
                $value = $triggerDuration->h + $triggerDuration->d * 24;
            } elseif ($triggerDuration->d > 0) {
                $unit = "day";
                $value = $triggerDuration->d;
            }
            $rel = isset($trigger['RELATED']) && strtoupper($trigger['RELATED']) == 'END' ? 'end' : 'start';
            $notifications[] = array("action" => strtolower($action), "rel" => $rel, "trigger_unit" => $unit, "trigger_value" => $value);
        }
        if ($component->select("RRULE")) {
            $recurrence = new Sabre_VObject_RecurrenceIterator($vObject, (string) $component->__get("UID"));
        } else {
            $recurrence = null;
        }
    } elseif (isset($_REQUEST["start"]) && $_REQUEST["start"] > 0) {
        $calendars = dav_get_current_user_calendars($server, DAV_ACL_WRITE);
        //$calendar  = dav_get_current_user_calendar_by_id($server, $calendar_id, DAV_ACL_WRITE);
        $event = array("id" => 0, "Summary" => $_REQUEST["title"], "StartTime" => InTVal($_REQUEST["start"]), "EndTime" => IntVal($_REQUEST["end"]), "IsAllDayEvent" => $_REQUEST["isallday"], "Description" => "", "Location" => "", "Color" => null);
        if ($_REQUEST["isallday"]) {
            $notifications = array();
        } else {
            $notifications = array(array("action" => "email", "rel" => "start", "trigger_unit" => "hour", "trigger_value" => 1));
        }
        $recurrence = null;
        $recurrentce_exdates = array();
    } else {
        $calendars = dav_get_current_user_calendars($server, DAV_ACL_WRITE);
        //$calendar  = dav_get_current_user_calendar_by_id($server, $calendar_id, DAV_ACL_WRITE);
        $event = array("id" => 0, "Summary" => "", "StartTime" => time(), "EndTime" => time() + 3600, "IsAllDayEvent" => "0", "Description" => "", "Location" => "", "Color" => null);
        $notifications = array(array("action" => "email", "rel" => "start", "trigger_unit" => "hour", "trigger_value" => 1));
        $recurrence = null;
        $recurrentce_exdates = array();
    }
    $postto = $baseurl . "/dav/wdcal/" . ($uri == 0 ? "new/" : $calendar_id . "/" . $uri . "/edit/");
    $out = "<a href='" . $baseurl . "/dav/wdcal/'>" . t("Go back to the calendar") . "</a><br><br>";
    $out .= "<form method='POST' action='{$postto}'>\n\t\t<input type='hidden' name='form_security_token' value='" . get_form_security_token('caledit') . "'>\n";
    $out .= "<h2>" . t("Event data") . "</h2>";
    $out .= "<label for='calendar' class='block'>" . t("Calendar") . ":</label><select id='calendar' name='calendar' size='1'>";
    $found = false;
    $cal_col = "aaaaaa";
    foreach ($calendars as $cal) {
        $prop = $cal->getProperties(array("id", DAV_DISPLAYNAME, DAV_CALENDARCOLOR));
        $out .= "<option value='" . $prop["id"] . "' ";
        if ($prop["id"] == $calendar_id) {
            $out .= "selected";
            $cal_col = $prop[DAV_CALENDARCOLOR];
            $found = true;
        } elseif (!$found) {
            $cal_col = $prop[DAV_CALENDARCOLOR];
        }
        $out .= ">" . escape_tags($prop[DAV_DISPLAYNAME]) . "</option>\n";
    }
    $out .= "</select>";
    $out .= "&nbsp; &nbsp; <label class='plain'><input type='checkbox' name='color_override' id='color_override' ";
    if (!is_null($event["Color"])) {
        $out .= "checked";
    }
    $out .= "> " . t("Special color") . ":</label>";
    $out .= "<span id='cal_color_holder' ";
    if (is_null($event["Color"])) {
        $out .= "style='display: none;'";
    }
    $out .= "><input name='color' id='cal_color' value='" . (is_null($event["Color"]) ? "#" . $cal_col : escape_tags($event["Color"])) . "'></span>";
    $out .= "<br>\n";
    $out .= "<label class='block' for='cal_summary'>" . t("Subject") . ":</label>\n\t\t<input name='summary' id='cal_summary' value=\"" . escape_tags($event["Summary"]) . "\"><br>\n";
    $out .= "<label class='block' for='cal_allday'>Is All-Day event:</label><input type='checkbox' name='allday' id='cal_allday' " . ($event["IsAllDayEvent"] ? "checked" : "") . "><br>\n";
    $out .= "<label class='block' for='cal_start_date'>" . t("Starts") . ":</label>";
    $out .= "<input name='start_date' value='" . $localization->dateformat_datepicker_php($event["StartTime"]) . "' id='cal_start_date'>";
    $out .= "<input name='start_time' value='" . date("H:i", $event["StartTime"]) . "' id='cal_start_time'>";
    $out .= "<br>\n";
    $out .= "<label class='block' for='cal_end_date'>" . t("Ends") . ":</label>";
    $out .= "<input name='end_date' value='" . $localization->dateformat_datepicker_php($event["EndTime"]) . "' id='cal_end_date'>";
    $out .= "<input name='end_time' value='" . date("H:i", $event["EndTime"]) . "' id='cal_end_time'>";
    $out .= "<br>\n";
    $out .= "<label class='block' for='cal_location'>" . t("Location") . ":</label><input name='location' id='cal_location' value=\"" . escape_tags($event["Location"]) . "\"><br>\n";
    $out .= "<label class='block' for='event-desc-textarea'>" . t("Description") . ":</label> <textarea id='event-desc-textarea' name='wdcal_desc' style='vertical-align: top; width: 400px; height: 100px;'>" . escape_tags($event["Description"]) . "</textarea>";
    $out .= "<br style='clear: both;'>";
    $out .= "<h2>" . t("Recurrence") . "</h2>";
    $out .= "<label class='block' for='rec_frequency'>" . t("Frequency") . ":</label> <select id='rec_frequency' name='rec_frequency' size='1'>";
    $out .= "<option value=''>" . t("None") . "</option>\n";
    $out .= "<option value='daily' ";
    if ($recurrence && $recurrence->frequency == "daily") {
        $out .= "selected";
    }
    $out .= ">" . t("Daily") . "</option>\n";
    $out .= "<option value='weekly' ";
    if ($recurrence && $recurrence->frequency == "weekly") {
        $out .= "selected";
    }
    $out .= ">" . t("Weekly") . "</option>\n";
    $out .= "<option value='monthly' ";
    if ($recurrence && $recurrence->frequency == "monthly") {
        $out .= "selected";
    }
    $out .= ">" . t("Monthly") . "</option>\n";
    $out .= "<option value='yearly' ";
    if ($recurrence && $recurrence->frequency == "yearly") {
        $out .= "selected";
    }
    $out .= ">" . t("Yearly") . "</option>\n";
    $out .= "</select><br>\n";
    $out .= "<div id='rec_details'>";
    $select = "<select id='rec_interval' name='rec_interval' size='1'>";
    for ($i = 1; $i < 50; $i++) {
        $select .= "<option value='{$i}' ";
        if ($recurrence && $i == $recurrence->interval) {
            $select .= "selected";
        }
        $select .= ">{$i}</option>\n";
    }
    $select .= "</select>";
    $time = "<span class='rec_daily'>" . t("days") . "</span>";
    $time .= "<span class='rec_weekly'>" . t("weeks") . "</span>";
    $time .= "<span class='rec_monthly'>" . t("months") . "</span>";
    $time .= "<span class='rec_yearly'>" . t("years") . "</span>";
    $out .= "<label class='block'>" . t("Interval") . ":</label> " . str_replace(array("%select%", "%time%"), array($select, $time), t("All %select% %time%")) . "<br>";
    $out .= "<div class='rec_daily'>";
    $out .= "<label class='block'>" . t("Days") . ":</label>";
    if ($recurrence && $recurrence->byDay) {
        $byday = $recurrence->byDay;
    } else {
        $byday = array("MO", "TU", "WE", "TH", "FR", "SA", "SU");
    }
    if ($localization->getFirstDayOfWeek() == 0) {
        $out .= "<label class='plain'><input class='rec_daily_byday' type='checkbox' name='rec_daily_byday[]' value='SU' ";
        if (in_array("SU", $byday)) {
            $out .= "checked";
        }
        $out .= ">" . t("Sunday") . "</label> &nbsp; ";
    }
    $out .= "<label class='plain'><input class='rec_daily_byday' type='checkbox' name='rec_daily_byday[]' value='MO' ";
    if (in_array("MO", $byday)) {
        $out .= "checked";
    }
    $out .= ">" . t("Monday") . "</label> &nbsp; ";
    $out .= "<label class='plain'><input class='rec_daily_byday' type='checkbox' name='rec_daily_byday[]' value='TU' ";
    if (in_array("TU", $byday)) {
        $out .= "checked";
    }
    $out .= ">" . t("Tuesday") . "</label> &nbsp; ";
    $out .= "<label class='plain'><input class='rec_daily_byday' type='checkbox' name='rec_daily_byday[]' value='WE' ";
    if (in_array("WE", $byday)) {
        $out .= "checked";
    }
    $out .= ">" . t("Wednesday") . "</label> &nbsp; ";
    $out .= "<label class='plain'><input class='rec_daily_byday' type='checkbox' name='rec_daily_byday[]' value='TH' ";
    if (in_array("TH", $byday)) {
        $out .= "checked";
    }
    $out .= ">" . t("Thursday") . "</label> &nbsp; ";
    $out .= "<label class='plain'><input class='rec_daily_byday' type='checkbox' name='rec_daily_byday[]' value='FR' ";
    if (in_array("FR", $byday)) {
        $out .= "checked";
    }
    $out .= ">" . t("Friday") . "</label> &nbsp; ";
    $out .= "<label class='plain'><input class='rec_daily_byday' type='checkbox' name='rec_daily_byday[]' value='SA' ";
    if (in_array("SA", $byday)) {
        $out .= "checked";
    }
    $out .= ">" . t("Saturday") . "</label> &nbsp; ";
    if ($localization->getFirstDayOfWeek() != 0) {
        $out .= "<label class='plain'><input class='rec_daily_byday' type='checkbox' name='rec_daily_byday[]' value='SU' ";
        if (in_array("SU", $byday)) {
            $out .= "checked";
        }
        $out .= ">" . t("Sunday") . "</label> &nbsp; ";
    }
    $out .= "</div>";
    $out .= "<div class='rec_weekly'>";
    $out .= "<label class='block'>" . t("Days") . ":</label>";
    if ($recurrence && $recurrence->byDay) {
        $byday = $recurrence->byDay;
    } else {
        $days = array("MO", "TU", "WE", "TH", "FR", "SA", "SU");
        $byday = array($days[date("N", $event["StartTime"]) - 1]);
    }
    if ($localization->getFirstDayOfWeek() == 0) {
        $out .= "<label class='plain'><input class='rec_weekly_byday' type='checkbox' name='rec_weekly_byday[]' value='SU' ";
        if (in_array("SU", $byday)) {
            $out .= "checked";
        }
        $out .= ">" . t("Sunday") . "</label> &nbsp; ";
    }
    $out .= "<label class='plain'><input class='rec_weekly_byday' type='checkbox' name='rec_weekly_byday[]' value='MO' ";
    if (in_array("MO", $byday)) {
        $out .= "checked";
    }
    $out .= ">" . t("Monday") . "</label> &nbsp; ";
    $out .= "<label class='plain'><input class='rec_weekly_byday' type='checkbox' name='rec_weekly_byday[]' value='TU' ";
    if (in_array("TU", $byday)) {
        $out .= "checked";
    }
    $out .= ">" . t("Tuesday") . "</label> &nbsp; ";
    $out .= "<label class='plain'><input class='rec_weekly_byday' type='checkbox' name='rec_weekly_byday[]' value='WE' ";
    if (in_array("WE", $byday)) {
        $out .= "checked";
    }
    $out .= ">" . t("Wednesday") . "</label> &nbsp; ";
    $out .= "<label class='plain'><input class='rec_weekly_byday' type='checkbox' name='rec_weekly_byday[]' value='TH' ";
    if (in_array("TH", $byday)) {
        $out .= "checked";
    }
    $out .= ">" . t("Thursday") . "</label> &nbsp; ";
    $out .= "<label class='plain'><input class='rec_weekly_byday' type='checkbox' name='rec_weekly_byday[]' value='FR' ";
    if (in_array("FR", $byday)) {
        $out .= "checked";
    }
    $out .= ">" . t("Friday") . "</label> &nbsp; ";
    $out .= "<label class='plain'><input class='rec_weekly_byday' type='checkbox' name='rec_weekly_byday[]' value='SA' ";
    if (in_array("SA", $byday)) {
        $out .= "checked";
    }
    $out .= ">" . t("Saturday") . "</label> &nbsp; ";
    if ($localization->getFirstDayOfWeek() != 0) {
        $out .= "<label class='plain'><input class='rec_weekly_byday' type='checkbox' name='rec_weekly_byday[]' value='SU' ";
        if (in_array("SU", $byday)) {
            $out .= "checked";
        }
        $out .= ">" . t("Sunday") . "</label> &nbsp; ";
    }
    $out .= "<br>";
    $out .= "<label class='block'>" . t("First day of week:") . "</label>";
    if ($recurrence && $recurrence->weekStart != "") {
        $wkst = $recurrence->weekStart;
    } else {
        if ($localization->getFirstDayOfWeek() == 0) {
            $wkst = "SU";
        } else {
            $wkst = "MO";
        }
    }
    $out .= "<label class='plain'><input type='radio' name='rec_weekly_wkst' value='SU' ";
    if ($wkst == "SU") {
        $out .= "checked";
    }
    $out .= ">" . t("Sunday") . "</label> &nbsp; ";
    $out .= "<label class='plain'><input type='radio' name='rec_weekly_wkst' value='MO' ";
    if ($wkst == "MO") {
        $out .= "checked";
    }
    $out .= ">" . t("Monday") . "</label><br>\n";
    $out .= "</div>";
    $monthly_rule = "";
    if ($recurrence && ($recurrence->frequency == "monthly" || $recurrence->frequency == "yearly")) {
        if (is_null($recurrence->byDay) && !is_null($recurrence->byMonthDay) && count($recurrence->byMonthDay) == 1) {
            $day = date("j", $event["StartTime"]);
            if ($recurrence->byMonthDay[0] == $day) {
                $monthly_rule = "bymonthday";
            } else {
                $lastday = date("t", $event["StartTime"]);
                if ($recurrence->byMonthDay[0] == -1 * ($lastday - $day + 1)) {
                    $monthly_rule = "bymonthday_neg";
                }
            }
        }
        if (is_null($recurrence->byMonthDay) && !is_null($recurrence->byDay) && count($recurrence->byDay) == 1) {
            $num = IntVal($recurrence->byDay[0]);
            /*
            $dayMap = array(
            	'SU' => 0,
            	'MO' => 1,
            	'TU' => 2,
            	'WE' => 3,
            	'TH' => 4,
            	'FR' => 5,
            	'SA' => 6,
            );
            if ($num == 0) {
            	$num = 1;
            	$weekday = $dayMap[$recurrence->byDay[0]];
            } else {
            	$weekday = $dayMap[substr($recurrence->byDay[0], strlen($num))];
            }
            
            echo $num . " - " . $weekday;
            */
            if ($num > 0) {
                $monthly_rule = "byday";
            }
            if ($num < 0) {
                $monthly_rule = "byday_neg";
            }
        }
        if ($monthly_rule == "") {
            notice("The recurrence of this event cannot be parsed");
        }
    }
    $out .= "<div class='rec_monthly'>";
    $out .= "<label class='block' for='rec_monthly_day'>" . t("Day of month") . ":</label>";
    $out .= "<select id='rec_monthly_day' name='rec_monthly_day' size='1'>";
    $out .= "<option value='bymonthday' ";
    if ($monthly_rule == "bymonthday") {
        $out .= "selected";
    }
    $out .= ">" . t("#num#th of each month") . "</option>\n";
    $out .= "<option value='bymonthday_neg' ";
    if ($monthly_rule == "bymonthday_neg") {
        $out .= "selected";
    }
    $out .= ">" . t("#num#th-last of each month") . "</option>\n";
    $out .= "<option value='byday' ";
    if ($monthly_rule == "byday") {
        $out .= "selected";
    }
    $out .= ">" . t("#num#th #wkday# of each month") . "</option>\n";
    $out .= "<option value='byday_neg' ";
    if ($monthly_rule == "byday_neg") {
        $out .= "selected";
    }
    $out .= ">" . t("#num#th-last #wkday# of each month") . "</option>\n";
    $out .= "</select>";
    $out .= "</div>\n";
    if ($recurrence && $recurrence->frequency == "yearly") {
        if (count($recurrence->byMonth) != 1 || $recurrence->byMonth[0] != date("n", $event["StartTime"])) {
            notice("The recurrence of this event cannot be parsed!");
        }
    }
    $out .= "<div class='rec_yearly'>";
    $out .= "<label class='block'>" . t("Month") . ":</label> <span class='rec_month_name'>#month#</span><br>\n";
    $out .= "<label class='block' for='rec_yearly_day'>" . t("Day of month") . ":</label>";
    $out .= "<select id='rec_yearly_day' name='rec_yearly_day' size='1'>";
    $out .= "<option value='bymonthday' ";
    if ($monthly_rule == "bymonthday") {
        $out .= "selected";
    }
    $out .= ">" . t("#num#th of the given month") . "</option>\n";
    $out .= "<option value='bymonthday_neg' ";
    if ($monthly_rule == "bymonthday_neg") {
        $out .= "selected";
    }
    $out .= ">" . t("#num#th-last of the given month") . "</option>\n";
    $out .= "<option value='byday' ";
    if ($monthly_rule == "byday") {
        $out .= "selected";
    }
    $out .= ">" . t("#num#th #wkday# of the given month") . "</option>\n";
    $out .= "<option value='byday_neg' ";
    if ($monthly_rule == "byday_neg") {
        $out .= "selected";
    }
    $out .= ">" . t("#num#th-last #wkday# of the given month") . "</option>\n";
    $out .= "</select>";
    $out .= "</div>\n";
    if ($recurrence) {
        $until = $recurrence->until;
        $count = $recurrence->count;
        if (is_a($until, "DateTime")) {
            /** @var DateTime $until */
            $rule_type = "date";
            $rule_until_date = $until->getTimestamp();
            $rule_until_count = 1;
        } elseif ($count > 0) {
            $rule_type = "count";
            $rule_until_date = time();
            $rule_until_count = $count;
        } else {
            $rule_type = "infinite";
            $rule_until_date = time();
            $rule_until_count = 1;
        }
    } else {
        $rule_type = "infinite";
        $rule_until_date = time();
        $rule_until_count = 1;
    }
    $out .= "<label class='block' for='rec_until_type'>" . t("Repeat until") . ":</label> ";
    $out .= "<select name='rec_until_type' id='rec_until_type' size='1'>";
    $out .= "<option value='infinite' ";
    if ($rule_type == "infinite") {
        $out .= "selected";
    }
    $out .= ">" . t("Infinite") . "</option>\n";
    $out .= "<option value='date' ";
    if ($rule_type == "date") {
        $out .= "selected";
    }
    $out .= ">" . t("Until the following date") . ":</option>\n";
    $out .= "<option value='count' ";
    if ($rule_type == "count") {
        $out .= "selected";
    }
    $out .= ">" . t("Number of times") . ":</option>\n";
    $out .= "</select>";
    $out .= "<input name='rec_until_date' value='" . $localization->dateformat_datepicker_php($rule_until_date) . "' id='rec_until_date'>";
    $out .= "<input name='rec_until_count' value='{$rule_until_count}' id='rec_until_count'><br>";
    $out .= "<label class='block'>" . t("Exceptions") . ":</label><div class='rec_exceptions'>";
    $out .= "<div class='rec_exceptions_none' ";
    if (count($recurrentce_exdates) > 0) {
        $out .= "style='display: none;'";
    }
    $out .= ">" . t("none") . "</div>";
    $out .= "<div class='rec_exceptions_holder' ";
    if (count($recurrentce_exdates) == 0) {
        $out .= "style='display: none;'";
    }
    $out .= ">";
    foreach ($recurrentce_exdates as $exdate) {
        $out .= "<div data-timestamp='{$exdate}' class='except'><input type='hidden' class='rec_exception' name='rec_exceptions[]' value='{$exdate}'>";
        $out .= "<a href='#' class='exception_remover'>[remove]</a> ";
        $out .= $localization->date_timestamp2localDate($exdate);
        $out .= "</div>\n";
    }
    $out .= "</div><div><a href='#' class='exception_adder'>[add]</a></div>";
    $out .= "</div>\n";
    $out .= "<br>\n";
    $out .= "</div><br>";
    $out .= "<h2>" . t("Notification") . "</h2>";
    if (!$notifications) {
        $notifications = array();
    }
    $notifications["new"] = array("action" => "email", "trigger_value" => 60, "trigger_unit" => "minute", "rel" => "start");
    foreach ($notifications as $index => $noti) {
        $unparsable = false;
        if (!in_array($noti["action"], array("email", "display"))) {
            $unparsable = true;
        }
        $out .= "<div class='noti_holder' ";
        if (!is_numeric($index) && $index == "new") {
            $out .= "style='display: none;' id='noti_new_row'";
        }
        $out .= "><label class='block' for='noti_type_" . $index . "'>" . t("Notify by") . ":</label>";
        $out .= "<select name='noti_type[{$index}]' size='1' id='noti_type_" . $index . "'>";
        $out .= "<option value=''>- " . t("Remove") . " -</option>\n";
        $out .= "<option value='email' ";
        if (!$unparsable && $noti["action"] == "email") {
            $out .= "selected";
        }
        $out .= ">" . t("E-Mail") . "</option>\n";
        $out .= "<option value='display' ";
        if (!$unparsable && $noti["action"] == "display") {
            $out .= "selected";
        }
        $out .= ">" . t("On Friendica / Display") . "</option>\n";
        //$out .= "<option value='other' "; if ($unparsable) $out .= "selected"; $out .= ">- " . t("other (leave it untouched)") . " -</option>\n"; // @TODO
        $out .= "</select><br>";
        $out .= "<label class='block'>" . t("Time") . ":</label>";
        $out .= "<input name='noti_value[{$index}]' size='5' style='width: 5em;' value='" . $noti["trigger_value"] . "'>";
        $out .= "<select name='noti_unit[{$index}]' size='1'>";
        $out .= "<option value='H' ";
        if ($noti["trigger_unit"] == "hour") {
            $out .= "selected";
        }
        $out .= ">" . t("Hours") . "</option>\n";
        $out .= "<option value='M' ";
        if ($noti["trigger_unit"] == "minute") {
            $out .= "selected";
        }
        $out .= ">" . t("Minutes") . "</option>\n";
        $out .= "<option value='S' ";
        if ($noti["trigger_unit"] == "second") {
            $out .= "selected";
        }
        $out .= ">" . t("Seconds") . "</option>\n";
        $out .= "<option value='D' ";
        if ($noti["trigger_unit"] == "day") {
            $out .= "selected";
        }
        $out .= ">" . t("Days") . "</option>\n";
        $out .= "<option value='W' ";
        if ($noti["trigger_unit"] == "week") {
            $out .= "selected";
        }
        $out .= ">" . t("Weeks") . "</option>\n";
        $out .= "</select>";
        $out .= " <label class='plain'>" . t("before the") . " <select name='noti_ref[{$index}]' size='1'>";
        $out .= "<option value='start' ";
        if ($noti["rel"] == "start") {
            $out .= "selected";
        }
        $out .= ">" . t("start of the event") . "</option>\n";
        $out .= "<option value='end' ";
        if ($noti["rel"] == "end") {
            $out .= "selected";
        }
        $out .= ">" . t("end of the event") . "</option>\n";
        $out .= "</select></label>\n";
        $out .= "</div>";
    }
    $out .= "<input type='hidden' name='new_alarm' id='new_alarm' value='0'><div id='new_alarm_adder'><a href='#'>" . t("Add a notification") . "</a></div>";
    $out .= "<script>\$(function() {\n\t\twdcal_edit_init('" . $localization->dateformat_datepicker_js() . "', '{$baseurl}/dav/');\n\t});</script>";
    $out .= "<br><input type='submit' name='save' value='Save'></form>";
    return $out;
}
Esempio n. 17
0
/**
 * @brief Create group sidebar widget
 * 
 * @param string $every
 * @param string $each
 * @param string $editmode
 *	'standard' => include link 'Edit groups'
 *	'extended' => include link 'Create new group'
 *	'full' => include link 'Create new group' and provide for each group a link to edit this group
 * @param int $group_id
 * @param int $cid
 * @return string
 */
function group_side($every = "contacts", $each = "group", $editmode = "standard", $group_id = 0, $cid = 0)
{
    $o = '';
    if (!local_user()) {
        return '';
    }
    $groups = array();
    $groups[] = array('text' => t('Everybody'), 'id' => 0, 'selected' => $group_id == 0 ? 'group-selected' : '', 'href' => $every);
    $r = q("SELECT * FROM `group` WHERE `deleted` = 0 AND `uid` = %d ORDER BY `name` ASC", intval($_SESSION['uid']));
    $member_of = array();
    if ($cid) {
        $member_of = groups_containing(local_user(), $cid);
    }
    if (count($r)) {
        foreach ($r as $rr) {
            $selected = $group_id == $rr['id'] ? ' group-selected' : '';
            if ($editmode == "full") {
                $groupedit = array('href' => "group/" . $rr['id'], 'title' => t('edit'));
            } else {
                $groupedit = null;
            }
            $groups[] = array('id' => $rr['id'], 'cid' => $cid, 'text' => $rr['name'], 'selected' => $selected, 'href' => $each . "/" . $rr['id'], 'edit' => $groupedit, 'ismember' => in_array($rr['id'], $member_of));
        }
    }
    $tpl = get_markup_template("group_side.tpl");
    $o = replace_macros($tpl, array('$title' => t('Groups'), 'newgroup' => $editmode == "extended" || $editmode == "full" ? 1 : '', '$editgroupstext' => t('Edit groups'), 'grouppage' => "group/", '$edittext' => t('Edit group'), '$createtext' => t('Create a new group'), '$creategroup' => t('Group Name: '), '$form_security_token' => get_form_security_token("group_edit"), '$ungrouped' => $every === 'contacts' ? t('Contacts not in any group') : '', '$groups' => $groups, '$add' => t('add')));
    return $o;
}
Esempio n. 18
0
 /**
  * @brief Themes admin page.
  *
  * @return string
  */
 function get()
 {
     $allowed_themes_str = get_config('system', 'allowed_themes');
     $allowed_themes_raw = explode(',', $allowed_themes_str);
     $allowed_themes = array();
     if (count($allowed_themes_raw)) {
         foreach ($allowed_themes_raw as $x) {
             if (strlen(trim($x))) {
                 $allowed_themes[] = trim($x);
             }
         }
     }
     $themes = array();
     $files = glob('view/theme/*');
     if ($files) {
         foreach ($files as $file) {
             $f = basename($file);
             $is_experimental = intval(file_exists($file . '/.experimental'));
             $is_supported = 1 - intval(file_exists($file . '/.unsupported'));
             // Is not used yet
             $is_allowed = intval(in_array($f, $allowed_themes));
             $themes[] = array('name' => $f, 'experimental' => $is_experimental, 'supported' => $is_supported, 'allowed' => $is_allowed);
         }
     }
     if (!count($themes)) {
         notice(t('No themes found.'));
         return '';
     }
     /*
      * Single theme
      */
     if (\App::$argc == 3) {
         $theme = \App::$argv[2];
         if (!is_dir("view/theme/{$theme}")) {
             notice(t("Item not found."));
             return '';
         }
         if (x($_GET, "a") && $_GET['a'] == "t") {
             check_form_security_token_redirectOnErr('/admin/themes', 'admin_themes', 't');
             // Toggle theme status
             $this->toggle_theme($themes, $theme, $result);
             $s = $this->rebuild_theme_table($themes);
             if ($result) {
                 info(sprintf('Theme %s enabled.', $theme));
             } else {
                 info(sprintf('Theme %s disabled.', $theme));
             }
             set_config('system', 'allowed_themes', $s);
             goaway(z_root() . '/admin/themes');
         }
         // display theme details
         require_once 'library/markdown.php';
         if ($this->theme_status($themes, $theme)) {
             $status = "on";
             $action = t("Disable");
         } else {
             $status = "off";
             $action = t("Enable");
         }
         $readme = Null;
         if (is_file("view/theme/{$theme}/README.md")) {
             $readme = file_get_contents("view/theme/{$theme}/README.md");
             $readme = Markdown($readme);
         } else {
             if (is_file("view/theme/{$theme}/README")) {
                 $readme = "<pre>" . file_get_contents("view/theme/{$theme}/README") . "</pre>";
             }
         }
         $admin_form = '';
         if (is_file("view/theme/{$theme}/php/config.php")) {
             require_once "view/theme/{$theme}/php/config.php";
             if (function_exists("theme_admin")) {
                 $admin_form = theme_admin($a);
             }
         }
         $screenshot = array(get_theme_screenshot($theme), t('Screenshot'));
         if (!stristr($screenshot[0], $theme)) {
             $screenshot = null;
         }
         $t = get_markup_template('admin_plugins_details.tpl');
         return replace_macros($t, array('$title' => t('Administration'), '$page' => t('Themes'), '$toggle' => t('Toggle'), '$settings' => t('Settings'), '$baseurl' => z_root(), '$plugin' => $theme, '$status' => $status, '$action' => $action, '$info' => get_theme_info($theme), '$function' => 'themes', '$admin_form' => $admin_form, '$str_author' => t('Author: '), '$str_maintainer' => t('Maintainer: '), '$screenshot' => $screenshot, '$readme' => $readme, '$form_security_token' => get_form_security_token('admin_themes')));
     }
     /*
      * List themes
      */
     $xthemes = array();
     if ($themes) {
         foreach ($themes as $th) {
             $xthemes[] = array($th['name'], $th['allowed'] ? "on" : "off", get_theme_info($th['name']));
         }
     }
     $t = get_markup_template('admin_plugins.tpl');
     return replace_macros($t, array('$title' => t('Administration'), '$page' => t('Themes'), '$submit' => t('Submit'), '$baseurl' => z_root(), '$function' => 'themes', '$plugins' => $xthemes, '$experimental' => t('[Experimental]'), '$unsupported' => t('[Unsupported]'), '$form_security_token' => get_form_security_token('admin_themes')));
 }
Esempio n. 19
0
function cover_photo_content(&$a)
{
    if (!local_channel()) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    $channel = App::get_channel();
    $newuser = false;
    if (argc() == 2 && argv(1) === 'new') {
        $newuser = true;
    }
    if (argv(1) === 'use') {
        if (argc() < 3) {
            notice(t('Permission denied.') . EOL);
            return;
        }
        //		check_form_security_token_redirectOnErr('/cover_photo', 'cover_photo');
        $resource_id = argv(2);
        $r = q("SELECT id, album, scale FROM photo WHERE uid = %d AND resource_id = '%s' ORDER BY scale ASC", intval(local_channel()), dbesc($resource_id));
        if (!$r) {
            notice(t('Photo not available.') . EOL);
            return;
        }
        $havescale = false;
        foreach ($r as $rr) {
            if ($rr['scale'] == 7) {
                $havescale = true;
            }
        }
        $r = q("SELECT `data`, `type`, resource_id, os_storage FROM photo WHERE id = %d and uid = %d limit 1", intval($r[0]['id']), intval(local_channel()));
        if (!$r) {
            notice(t('Photo not available.') . EOL);
            return;
        }
        if (intval($r[0]['os_storage'])) {
            $data = @file_get_contents($r[0]['data']);
        } else {
            $data = dbunescbin($r[0]['data']);
        }
        $ph = photo_factory($data, $r[0]['type']);
        $smallest = 0;
        if ($ph->is_valid()) {
            // go ahead as if we have just uploaded a new photo to crop
            $i = q("select resource_id, scale from photo where resource_id = '%s' and uid = %d and scale = 0", dbesc($r[0]['resource_id']), intval(local_channel()));
            if ($i) {
                $hash = $i[0]['resource_id'];
                foreach ($i as $ii) {
                    $smallest = intval($ii['scale']);
                }
            }
        }
        cover_photo_crop_ui_head($a, $ph, $hash, $smallest);
    }
    if (!x(App::$data, 'imagecrop')) {
        $tpl = get_markup_template('cover_photo.tpl');
        $o .= replace_macros($tpl, array('$user' => App::$channel['channel_address'], '$lbl_upfile' => t('Upload File:'), '$lbl_profiles' => t('Select a profile:'), '$title' => t('Upload Cover Photo'), '$submit' => t('Upload'), '$profiles' => $profiles, '$form_security_token' => get_form_security_token("cover_photo"), '$select' => sprintf('%s %s', t('or'), $newuser ? '<a href="' . z_root() . '">' . t('skip this step') . '</a>' : '<a href="' . z_root() . '/photos/' . App::$channel['channel_address'] . '">' . t('select a photo from your photo albums') . '</a>')));
        call_hooks('cover_photo_content_end', $o);
        return $o;
    } else {
        $filename = App::$data['imagecrop'] . '-3';
        $resolution = 3;
        $tpl = get_markup_template("cropcover.tpl");
        $o .= replace_macros($tpl, array('$filename' => $filename, '$profile' => intval($_REQUEST['profile']), '$resource' => App::$data['imagecrop'] . '-3', '$image_url' => z_root() . '/photo/' . $filename, '$title' => t('Crop Image'), '$desc' => t('Please adjust the image cropping for optimum viewing.'), '$form_security_token' => get_form_security_token("cover_photo"), '$done' => t('Done Editing')));
        return $o;
    }
    return;
    // NOTREACHED
}
Esempio n. 20
0
function profile_photo_content(&$a)
{
    if (!local_channel()) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    $channel = App::get_channel();
    $newuser = false;
    if (argc() == 2 && argv(1) === 'new') {
        $newuser = true;
    }
    if (argv(1) === 'use') {
        if (argc() < 3) {
            notice(t('Permission denied.') . EOL);
            return;
        }
        //		check_form_security_token_redirectOnErr('/profile_photo', 'profile_photo');
        $resource_id = argv(2);
        $r = q("SELECT id, album, scale FROM photo WHERE uid = %d AND resource_id = '%s' ORDER BY scale ASC", intval(local_channel()), dbesc($resource_id));
        if (!$r) {
            notice(t('Photo not available.') . EOL);
            return;
        }
        $havescale = false;
        foreach ($r as $rr) {
            if ($rr['scale'] == 5) {
                $havescale = true;
            }
        }
        // set an already loaded photo as profile photo
        if ($r[0]['album'] == t('Profile Photos') && $havescale) {
            // unset any existing profile photos
            $r = q("UPDATE photo SET photo_usage = %d WHERE photo_usage = %d AND uid = %d", intval(PHOTO_NORMAL), intval(PHOTO_PROFILE), intval(local_channel()));
            $r = q("UPDATE photo SET photo_usage = %d WHERE uid = %d AND resource_id = '%s'", intval(PHOTO_PROFILE), intval(local_channel()), dbesc($resource_id));
            $r = q("UPDATE xchan set xchan_photo_date = '%s' \n\t\t\t\twhere xchan_hash = '%s'", dbesc(datetime_convert()), dbesc($channel['xchan_hash']));
            profile_photo_set_profile_perms();
            //Reset default photo permissions to public
            proc_run('php', 'include/directory.php', local_channel());
            goaway(z_root() . '/profiles');
        }
        $r = q("SELECT `data`, `type`, resource_id, os_storage FROM photo WHERE id = %d and uid = %d limit 1", intval($r[0]['id']), intval(local_channel()));
        if (!$r) {
            notice(t('Photo not available.') . EOL);
            return;
        }
        if (intval($r[0]['os_storage'])) {
            $data = @file_get_contents($r[0]['data']);
        } else {
            $data = dbunescbin($r[0]['data']);
        }
        $ph = photo_factory($data, $r[0]['type']);
        $smallest = 0;
        if ($ph->is_valid()) {
            // go ahead as if we have just uploaded a new photo to crop
            $i = q("select resource_id, scale from photo where resource_id = '%s' and uid = %d order by scale", dbesc($r[0]['resource_id']), intval(local_channel()));
            if ($i) {
                $hash = $i[0]['resource_id'];
                foreach ($i as $ii) {
                    if (intval($ii['scale']) < 2) {
                        $smallest = intval($ii['scale']);
                    }
                }
            }
        }
        profile_photo_crop_ui_head($a, $ph, $hash, $smallest);
    }
    $profiles = q("select id, profile_name as name, is_default from profile where uid = %d", intval(local_channel()));
    if (!x(App::$data, 'imagecrop')) {
        $tpl = get_markup_template('profile_photo.tpl');
        $o .= replace_macros($tpl, array('$user' => App::$channel['channel_address'], '$lbl_upfile' => t('Upload File:'), '$lbl_profiles' => t('Select a profile:'), '$title' => t('Upload Profile Photo'), '$submit' => t('Upload'), '$profiles' => $profiles, '$single' => count($profiles) == 1 ? true : false, '$profile0' => $profiles[0], '$form_security_token' => get_form_security_token("profile_photo"), '$select' => sprintf('%s %s', t('or'), $newuser ? '<a href="' . z_root() . '">' . t('skip this step') . '</a>' : '<a href="' . z_root() . '/photos/' . App::$channel['channel_address'] . '">' . t('select a photo from your photo albums') . '</a>')));
        call_hooks('profile_photo_content_end', $o);
        return $o;
    } else {
        $filename = App::$data['imagecrop'] . '-' . App::$data['imagecrop_resolution'];
        $resolution = App::$data['imagecrop_resolution'];
        $tpl = get_markup_template("cropbody.tpl");
        $o .= replace_macros($tpl, array('$filename' => $filename, '$profile' => intval($_REQUEST['profile']), '$resource' => App::$data['imagecrop'] . '-' . App::$data['imagecrop_resolution'], '$image_url' => z_root() . '/photo/' . $filename, '$title' => t('Crop Image'), '$desc' => t('Please adjust the image cropping for optimum viewing.'), '$form_security_token' => get_form_security_token("profile_photo"), '$done' => t('Done Editing')));
        return $o;
    }
    return;
    // NOTREACHED
}
Esempio n. 21
0
 function get()
 {
     $yes_no = array(t('No'), t('Yes'));
     $default_theme = get_config('system', 'theme');
     if (!$default_theme) {
         $default_theme = 'redbasic';
     }
     $themespec = explode(':', \App::$channel['channel_theme']);
     $existing_theme = $themespec[0];
     $existing_schema = $themespec[1];
     $theme = $existing_theme ? $existing_theme : $default_theme;
     $default_mobile_theme = get_config('system', 'mobile_theme');
     if (!$mobile_default_theme) {
         $mobile_default_theme = 'none';
     }
     $allowed_themes_str = get_config('system', 'allowed_themes');
     $allowed_themes_raw = explode(',', $allowed_themes_str);
     $allowed_themes = array();
     if (count($allowed_themes_raw)) {
         foreach ($allowed_themes_raw as $x) {
             if (strlen(trim($x)) && is_dir("view/theme/{$x}")) {
                 $allowed_themes[] = trim($x);
             }
         }
     }
     $themes = array();
     $files = glob('view/theme/*');
     if ($allowed_themes) {
         foreach ($allowed_themes as $th) {
             $f = $th;
             $is_experimental = file_exists('view/theme/' . $th . '/experimental');
             $unsupported = file_exists('view/theme/' . $th . '/unsupported');
             $is_mobile = file_exists('view/theme/' . $th . '/mobile');
             $is_library = file_exists('view/theme/' . $th . '/library');
             $mobile_themes["---"] = t("No special theme for mobile devices");
             if (!$is_experimental or $is_experimental && (get_config('experimentals', 'exp_themes') == 1 or get_config('experimentals', 'exp_themes') === false)) {
                 $theme_name = $is_experimental ? sprintf(t('%s - (Experimental)'), $f) : $f;
                 if (!$is_library) {
                     if ($is_mobile) {
                         $mobile_themes[$f] = $themes[$f] = $theme_name . ' (' . t('mobile') . ')';
                     } else {
                         $mobile_themes[$f] = $themes[$f] = $theme_name;
                     }
                 }
             }
         }
     }
     $theme_selected = array_key_exists('theme', $_SESSION) && $_SESSION['theme'] ? $_SESSION['theme'] : $theme;
     $mobile_theme_selected = !x($_SESSION, 'mobile_theme') ? $default_mobile_theme : $_SESSION['mobile_theme'];
     $preload_images = get_pconfig(local_channel(), 'system', 'preload_images');
     $preload_images = $preload_images === false ? '0' : $preload_images;
     // default if not set: 0
     $user_scalable = get_pconfig(local_channel(), 'system', 'user_scalable');
     $user_scalable = $user_scalable === false ? '1' : $user_scalable;
     // default if not set: 1
     $browser_update = intval(get_pconfig(local_channel(), 'system', 'update_interval'));
     $browser_update = $browser_update == 0 ? 80 : $browser_update / 1000;
     // default if not set: 40 seconds
     $itemspage = intval(get_pconfig(local_channel(), 'system', 'itemspage'));
     $itemspage = $itemspage > 0 && $itemspage < 101 ? $itemspage : 20;
     // default if not set: 20 items
     $nosmile = get_pconfig(local_channel(), 'system', 'no_smilies');
     $nosmile = $nosmile === false ? '0' : $nosmile;
     // default if not set: 0
     $title_tosource = get_pconfig(local_channel(), 'system', 'title_tosource');
     $title_tosource = $title_tosource === false ? '0' : $title_tosource;
     // default if not set: 0
     $theme_config = "";
     if (($themeconfigfile = $this->get_theme_config_file($theme)) != null) {
         require_once $themeconfigfile;
         if (class_exists('\\Zotlabs\\Theme\\' . ucfirst($theme) . 'Config')) {
             $clsname = '\\Zotlabs\\Theme\\' . ucfirst($theme) . 'Config';
             $thm_config = new $clsname();
             $schemas = $thm_config->get_schemas();
             $theme_config = $thm_config->get();
         }
     }
     // logger('schemas: ' . print_r($schemas,true));
     $tpl = get_markup_template("settings_display.tpl");
     $o = replace_macros($tpl, array('$ptitle' => t('Display Settings'), '$d_tset' => t('Theme Settings'), '$d_ctset' => t('Custom Theme Settings'), '$d_cset' => t('Content Settings'), '$form_security_token' => get_form_security_token("settings_display"), '$submit' => t('Submit'), '$baseurl' => z_root(), '$uid' => local_channel(), '$theme' => $themes ? array('theme', t('Display Theme:'), $theme_selected, '', $themes, 'preview') : false, '$schema' => array('schema', t('Select scheme'), $existing_schema, '', $schemas), '$mobile_theme' => $mobile_themes ? array('mobile_theme', t('Mobile Theme:'), $mobile_theme_selected, '', $mobile_themes, '') : false, '$preload_images' => array('preload_images', t("Preload images before rendering the page"), $preload_images, t("The subjective page load time will be longer but the page will be ready when displayed"), $yes_no), '$user_scalable' => array('user_scalable', t("Enable user zoom on mobile devices"), $user_scalable, '', $yes_no), '$ajaxint' => array('browser_update', t("Update browser every xx seconds"), $browser_update, t('Minimum of 10 seconds, no maximum')), '$itemspage' => array('itemspage', t("Maximum number of conversations to load at any time:"), $itemspage, t('Maximum of 100 items')), '$nosmile' => array('nosmile', t("Show emoticons (smilies) as images"), 1 - intval($nosmile), '', $yes_no), '$title_tosource' => array('title_tosource', t("Link post titles to source"), $title_tosource, '', $yes_no), '$layout_editor' => t('System Page Layout Editor - (advanced)'), '$theme_config' => $theme_config, '$expert' => feature_enabled(local_channel(), 'advanced_theming'), '$channel_list_mode' => array('channel_list_mode', t('Use blog/list mode on channel page'), get_pconfig(local_channel(), 'system', 'channel_list_mode'), t('(comments displayed separately)'), $yes_no), '$network_list_mode' => array('network_list_mode', t('Use blog/list mode on grid page'), get_pconfig(local_channel(), 'system', 'network_list_mode'), t('(comments displayed separately)'), $yes_no), '$channel_divmore_height' => array('channel_divmore_height', t('Channel page max height of content (in pixels)'), get_pconfig(local_channel(), 'system', 'channel_divmore_height') ? get_pconfig(local_channel(), 'system', 'channel_divmore_height') : 400, t('click to expand content exceeding this height')), '$network_divmore_height' => array('network_divmore_height', t('Grid page max height of content (in pixels)'), get_pconfig(local_channel(), 'system', 'network_divmore_height') ? get_pconfig(local_channel(), 'system', 'network_divmore_height') : 400, t('click to expand content exceeding this height'))));
     call_hooks('display_settings', $o);
     return $o;
 }
Esempio n. 22
0
 function get()
 {
     if (!local_channel()) {
         notice(t('Permission denied.') . EOL);
         return;
     }
     $channel = \App::get_channel();
     $newuser = false;
     if (argc() == 2 && argv(1) === 'new') {
         $newuser = true;
     }
     if (argv(1) === 'use') {
         if (argc() < 3) {
             notice(t('Permission denied.') . EOL);
             return;
         }
         $resource_id = argv(2);
         // When using an existing photo, we don't have a dialogue to offer a choice of profiles,
         // so it gets attached to the default
         $p = q("select id from profile where is_default = 1 and uid = %d", intval(local_channel()));
         if ($p) {
             $_REQUEST['profile'] = $p[0]['id'];
         }
         $r = q("SELECT id, album, imgscale FROM photo WHERE uid = %d AND resource_id = '%s' ORDER BY imgscale ASC", intval(local_channel()), dbesc($resource_id));
         if (!$r) {
             notice(t('Photo not available.') . EOL);
             return;
         }
         $havescale = false;
         foreach ($r as $rr) {
             if ($rr['imgscale'] == PHOTO_RES_PROFILE_80) {
                 $havescale = true;
             }
         }
         // set an already loaded and cropped photo as profile photo
         if ($r[0]['album'] == t('Profile Photos') && $havescale) {
             // unset any existing profile photos
             $r = q("UPDATE photo SET photo_usage = %d WHERE photo_usage = %d AND uid = %d", intval(PHOTO_NORMAL), intval(PHOTO_PROFILE), intval(local_channel()));
             $r = q("UPDATE photo SET photo_usage = %d WHERE uid = %d AND resource_id = '%s'", intval(PHOTO_PROFILE), intval(local_channel()), dbesc($resource_id));
             $r = q("UPDATE xchan set xchan_photo_date = '%s' \n\t\t\t\t\twhere xchan_hash = '%s'", dbesc(datetime_convert()), dbesc($channel['xchan_hash']));
             profile_photo_set_profile_perms(local_channel());
             // Reset default photo permissions to public
             \Zotlabs\Daemon\Master::Summon(array('Directory', local_channel()));
             goaway(z_root() . '/profiles');
         }
         $r = q("SELECT content, mimetype, resource_id, os_storage FROM photo WHERE id = %d and uid = %d limit 1", intval($r[0]['id']), intval(local_channel()));
         if (!$r) {
             notice(t('Photo not available.') . EOL);
             return;
         }
         if (intval($r[0]['os_storage'])) {
             $data = @file_get_contents($r[0]['content']);
         } else {
             $data = dbunescbin($r[0]['content']);
         }
         $ph = photo_factory($data, $r[0]['mimetype']);
         $smallest = 0;
         if ($ph->is_valid()) {
             // go ahead as if we have just uploaded a new photo to crop
             $i = q("select resource_id, imgscale from photo where resource_id = '%s' and uid = %d order by imgscale", dbesc($r[0]['resource_id']), intval(local_channel()));
             if ($i) {
                 $hash = $i[0]['resource_id'];
                 foreach ($i as $ii) {
                     if (intval($ii['imgscale']) < PHOTO_RES_640) {
                         $smallest = intval($ii['imgscale']);
                     }
                 }
             }
         }
         $this->profile_photo_crop_ui_head($a, $ph, $hash, $smallest);
         // falls through with App::$data['imagecrop'] set so we go straight to the cropping section
     }
     // present an upload form
     $profiles = q("select id, profile_name as name, is_default from profile where uid = %d order by id asc", intval(local_channel()));
     if (!x(\App::$data, 'imagecrop')) {
         $tpl = get_markup_template('profile_photo.tpl');
         $o .= replace_macros($tpl, array('$user' => \App::$channel['channel_address'], '$lbl_upfile' => t('Upload File:'), '$lbl_profiles' => t('Select a profile:'), '$title' => t('Upload Profile Photo'), '$submit' => t('Upload'), '$profiles' => $profiles, '$single' => count($profiles) == 1 ? true : false, '$profile0' => $profiles[0], '$form_security_token' => get_form_security_token("profile_photo"), '$select' => sprintf('%s %s', t('or'), $newuser ? '<a href="' . z_root() . '">' . t('skip this step') . '</a>' : '<a href="' . z_root() . '/photos/' . \App::$channel['channel_address'] . '">' . t('select a photo from your photo albums') . '</a>')));
         call_hooks('profile_photo_content_end', $o);
         return $o;
     } else {
         // present a cropping form
         $filename = \App::$data['imagecrop'] . '-' . \App::$data['imagecrop_resolution'];
         $resolution = \App::$data['imagecrop_resolution'];
         $tpl = get_markup_template("cropbody.tpl");
         $o .= replace_macros($tpl, array('$filename' => $filename, '$profile' => intval($_REQUEST['profile']), '$resource' => \App::$data['imagecrop'] . '-' . \App::$data['imagecrop_resolution'], '$image_url' => z_root() . '/photo/' . $filename, '$title' => t('Crop Image'), '$desc' => t('Please adjust the image cropping for optimum viewing.'), '$form_security_token' => get_form_security_token("profile_photo"), '$done' => t('Done Editing')));
         return $o;
     }
     return;
     // NOTREACHED
 }
Esempio n. 23
0
function profiles_content(&$a)
{
    if (!local_user()) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    $o = '';
    if ($a->argc > 1 && intval($a->argv[1])) {
        $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($a->argv[1]), intval(local_user()));
        if (!count($r)) {
            notice(t('Profile not found.') . EOL);
            return;
        }
        require_once 'include/profile_selectors.php';
        /*		$editselect = 'textareas';
        		if( intval(get_pconfig(local_user(),'system','plaintext')) || !feature_enabled(local_user(),'richtext') )
        			$editselect = 'none';*/
        $editselect = 'none';
        if (feature_enabled(local_user(), 'richtext')) {
            $editselect = 'textareas';
        }
        $a->page['htmlhead'] .= replace_macros(get_markup_template('profed_head.tpl'), array('$baseurl' => $a->get_baseurl(true), '$editselect' => $editselect));
        $a->page['end'] .= replace_macros(get_markup_template('profed_end.tpl'), array('$baseurl' => $a->get_baseurl(true), '$editselect' => $editselect));
        $opt_tpl = get_markup_template("profile-hide-friends.tpl");
        $hide_friends = replace_macros($opt_tpl, array('$yesno' => array('hide-friends', t('Hide contacts and friends:'), !!$r[0]['hide-friends'], '', array(t('No'), t('Yes'))), '$desc' => t('Hide your contact/friend list from viewers of this profile?'), '$yes_str' => t('Yes'), '$no_str' => t('No'), '$yes_selected' => $r[0]['hide-friends'] ? " checked=\"checked\" " : "", '$no_selected' => $r[0]['hide-friends'] == 0 ? " checked=\"checked\" " : ""));
        $f = get_config('system', 'birthday_input_format');
        if (!$f) {
            $f = 'ymd';
        }
        $is_default = $r[0]['is-default'] ? 1 : 0;
        $tpl = get_markup_template("profile_edit.tpl");
        $o .= replace_macros($tpl, array('$multi_profiles' => feature_enabled(local_user(), 'multi_profiles'), '$form_security_token' => get_form_security_token("profile_edit"), '$form_security_token_photo' => get_form_security_token("profile_photo"), '$profile_clone_link' => 'profiles/clone/' . $r[0]['id'] . '?t=' . get_form_security_token("profile_clone"), '$profile_drop_link' => 'profiles/drop/' . $r[0]['id'] . '?t=' . get_form_security_token("profile_drop"), '$banner' => t('Edit Profile Details'), '$submit' => t('Submit'), '$profpic' => t('Change Profile Photo'), '$viewprof' => t('View this profile'), '$cr_prof' => t('Create a new profile using these settings'), '$cl_prof' => t('Clone this profile'), '$del_prof' => t('Delete this profile'), '$lbl_basic_section' => t('Basic information'), '$lbl_picture_section' => t('Profile picture'), '$lbl_location_section' => t('Location'), '$lbl_preferences_section' => t('Preferences'), '$lbl_status_section' => t('Status information'), '$lbl_about_section' => t('Additional information'), '$lbl_interests_section' => t('Interests'), '$lbl_profile_photo' => t('Upload Profile Photo'), '$lbl_profname' => t('Profile Name:'), '$lbl_fullname' => t('Your Full Name:'), '$lbl_title' => t('Title/Description:'), '$lbl_gender' => t('Your Gender:'), '$lbl_bd' => t("Birthday :"), '$lbl_address' => t('Street Address:'), '$lbl_city' => t('Locality/City:'), '$lbl_zip' => t('Postal/Zip Code:'), '$lbl_country' => t('Country:'), '$lbl_region' => t('Region/State:'), '$lbl_marital' => t('<span class="heart">&hearts;</span> Marital Status:'), '$lbl_with' => t("Who: (if applicable)"), '$lbl_ex1' => t('Examples: cathy123, Cathy Williams, cathy@example.com'), '$lbl_howlong' => t('Since [date]:'), '$lbl_sexual' => t('Sexual Preference:'), '$lbl_homepage' => t('Homepage URL:'), '$lbl_hometown' => t('Hometown:'), '$lbl_politic' => t('Political Views:'), '$lbl_religion' => t('Religious Views:'), '$lbl_pubkey' => t('Public Keywords:'), '$lbl_prvkey' => t('Private Keywords:'), '$lbl_likes' => t('Likes:'), '$lbl_dislikes' => t('Dislikes:'), '$lbl_ex2' => t('Example: fishing photography software'), '$lbl_pubdsc' => t("(Used for suggesting potential friends, can be seen by others)"), '$lbl_prvdsc' => t("(Used for searching profiles, never shown to others)"), '$lbl_about' => t('Tell us about yourself...'), '$lbl_hobbies' => t('Hobbies/Interests'), '$lbl_social' => t('Contact information and Social Networks'), '$lbl_music' => t('Musical interests'), '$lbl_book' => t('Books, literature'), '$lbl_tv' => t('Television'), '$lbl_film' => t('Film/dance/culture/entertainment'), '$lbl_love' => t('Love/romance'), '$lbl_work' => t('Work/employment'), '$lbl_school' => t('School/education'), '$disabled' => $is_default ? 'onclick="return false;" style="color: #BBBBFF;"' : '', '$baseurl' => $a->get_baseurl(true), '$profile_id' => $r[0]['id'], '$profile_name' => $r[0]['profile-name'], '$default' => $is_default ? '<p id="profile-edit-default-desc">' . t('This is your <strong>public</strong> profile.<br />It <strong>may</strong> be visible to anybody using the internet.') . '</p>' : "", '$name' => $r[0]['name'], '$pdesc' => $r[0]['pdesc'], '$dob' => dob($r[0]['dob']), '$hide_friends' => $hide_friends, '$address' => $r[0]['address'], '$locality' => $r[0]['locality'], '$region' => $r[0]['region'], '$postal_code' => $r[0]['postal-code'], '$country_name' => $r[0]['country-name'], '$age' => intval($r[0]['dob']) ? '(' . t('Age: ') . age($r[0]['dob'], $a->user['timezone'], $a->user['timezone']) . ')' : '', '$gender' => gender_selector($r[0]['gender']), '$marital' => marital_selector($r[0]['marital']), '$with' => strip_tags($r[0]['with']), '$howlong' => $r[0]['howlong'] === '0000-00-00 00:00:00' ? '' : datetime_convert('UTC', date_default_timezone_get(), $r[0]['howlong']), '$sexual' => sexpref_selector($r[0]['sexual']), '$about' => $r[0]['about'], '$homepage' => $r[0]['homepage'], '$hometown' => $r[0]['hometown'], '$politic' => $r[0]['politic'], '$religion' => $r[0]['religion'], '$pub_keywords' => $r[0]['pub_keywords'], '$prv_keywords' => $r[0]['prv_keywords'], '$likes' => $r[0]['likes'], '$dislikes' => $r[0]['dislikes'], '$music' => $r[0]['music'], '$book' => $r[0]['book'], '$tv' => $r[0]['tv'], '$film' => $r[0]['film'], '$interest' => $r[0]['interest'], '$romance' => $r[0]['romance'], '$work' => $r[0]['work'], '$education' => $r[0]['education'], '$contact' => $r[0]['contact']));
        $arr = array('profile' => $r[0], 'entry' => $o);
        call_hooks('profile_edit', $arr);
        return $o;
    } else {
        //If we don't support multi profiles, don't display this list.
        if (!feature_enabled(local_user(), 'multi_profiles')) {
            $r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default`=1", local_user());
            if (count($r)) {
                //Go to the default profile.
                goaway($a->get_baseurl(true) . '/profiles/' . $r[0]['id']);
            }
        }
        $r = q("SELECT * FROM `profile` WHERE `uid` = %d", local_user());
        if (count($r)) {
            $tpl_header = get_markup_template('profile_listing_header.tpl');
            $o .= replace_macros($tpl_header, array('$header' => t('Edit/Manage Profiles'), '$chg_photo' => t('Change profile photo'), '$cr_new' => t('Create New Profile'), '$cr_new_link' => 'profiles/new?t=' . get_form_security_token("profile_new")));
            $tpl = get_markup_template('profile_entry.tpl');
            foreach ($r as $rr) {
                $o .= replace_macros($tpl, array('$photo' => $a->get_cached_avatar_image($rr['thumb']), '$id' => $rr['id'], '$alt' => t('Profile Image'), '$profile_name' => $rr['profile-name'], '$visible' => $rr['is-default'] ? '<strong>' . t('visible to everybody') . '</strong>' : '<a href="' . $a->get_baseurl(true) . '/profperm/' . $rr['id'] . '" />' . t('Edit visibility') . '</a>'));
            }
        }
        return $o;
    }
}
Esempio n. 24
0
/**
 * @param App $a
 * @param null|object $o
 */
function fbpost_plugin_admin(&$a, &$o)
{
    $o = '<input type="hidden" name="form_security_token" value="' . get_form_security_token("fbsave") . '">';
    $o .= '<h4>' . t('Facebook API Key') . '</h4>';
    $appid = get_config('facebook', 'appid');
    $appsecret = get_config('facebook', 'appsecret');
    $ret1 = q("SELECT `v` FROM `config` WHERE `cat` = 'facebook' AND `k` = 'appid' LIMIT 1");
    $ret2 = q("SELECT `v` FROM `config` WHERE `cat` = 'facebook' AND `k` = 'appsecret' LIMIT 1");
    if (count($ret1) > 0 && $ret1[0]['v'] != $appid || count($ret2) > 0 && $ret2[0]['v'] != $appsecret) {
        $o .= t('Error: it appears that you have specified the App-ID and -Secret in your .htconfig.php file. As long as they are specified there, they cannot be set using this form.<br><br>');
    }
    $o .= '<label for="fb_appid">' . t('App-ID / API-Key') . '</label><input id="fb_appid" name="appid" type="text" value="' . escape_tags($appid ? $appid : "") . '"><br style="clear: both;">';
    $o .= '<label for="fb_appsecret">' . t('Application secret') . '</label><input id="fb_appsecret" name="appsecret" type="text" value="' . escape_tags($appsecret ? $appsecret : "") . '"><br style="clear: both;">';
    $o .= '<input type="submit" name="fb_save_keys" value="' . t('Save') . '">';
}
Esempio n. 25
0
 function get()
 {
     if (!local_channel()) {
         notice(t('Permission denied.') . EOL);
         return;
     }
     $tpl = get_markup_template('invite.tpl');
     $invonly = false;
     if (get_config('system', 'invitation_only')) {
         $invonly = true;
         $x = get_pconfig(local_channel(), 'system', 'invites_remaining');
         if (!$x && !is_site_admin()) {
             notice(t('You have no more invitations available') . EOL);
             return '';
         }
     }
     if ($invonly && ($x || is_site_admin())) {
         $invite_code = autoname(8) . rand(1000, 9999);
         $nmessage = str_replace('$invite_code', $invite_code, $message);
         $r = q("INSERT INTO `register` (`hash`,`created`) VALUES ('%s', '%s') ", dbesc($invite_code), dbesc(datetime_convert()));
         if (!is_site_admin()) {
             $x--;
             if ($x >= 0) {
                 set_pconfig(local_channel(), 'system', 'invites_remaining', $x);
             } else {
                 return;
             }
         }
     }
     $ob = \App::get_observer();
     if (!$ob) {
         return $o;
     }
     $channel = \App::get_channel();
     $o = replace_macros($tpl, array('$form_security_token' => get_form_security_token("send_invite"), '$invite' => t('Send invitations'), '$addr_text' => t('Enter email addresses, one per line:'), '$msg_text' => t('Your message:'), '$default_message' => t('Please join my community on $Projectname.') . "\r\n" . "\r\n" . $linktxt . ($invonly ? "\r\n" . "\r\n" . t('You will need to supply this invitation code:') . " " . $invite_code . "\r\n" . "\r\n" : '') . t('1. Register at any $Projectname location (they are all inter-connected)') . "\r\n" . "\r\n" . z_root() . '/register' . "\r\n" . "\r\n" . t('2. Enter my $Projectname network address into the site searchbar.') . "\r\n" . "\r\n" . $ob['xchan_addr'] . ' (' . t('or visit') . " " . z_root() . '/channel/' . $channel['channel_address'] . ')' . "\r\n" . "\r\n" . t('3. Click [Connect]') . "\r\n" . "\r\n", '$submit' => t('Submit')));
     return $o;
 }
Esempio n. 26
0
function invite_content(&$a)
{
    if (!local_channel()) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    $tpl = get_markup_template('invite.tpl');
    $invonly = false;
    if (get_config('system', 'invitation_only')) {
        $invonly = true;
        $x = get_pconfig(local_channel(), 'system', 'invites_remaining');
        if (!$x && !is_site_admin()) {
            notice(t('You have no more invitations available') . EOL);
            return '';
        }
    }
    $ob = $a->get_observer();
    if (!$ob) {
        return $o;
    }
    $channel = $a->get_channel();
    $o = replace_macros($tpl, array('$form_security_token' => get_form_security_token("send_invite"), '$invite' => t('Send invitations'), '$addr_text' => t('Enter email addresses, one per line:'), '$msg_text' => t('Your message:'), '$default_message' => t('Please join my community on RedMatrix.') . "\r\n" . "\r\n" . $linktxt . ($invonly ? "\r\n" . "\r\n" . t('You will need to supply this invitation code: ') . $invite_code . "\r\n" . "\r\n" : '') . t('1. Register at any RedMatrix location (they are all inter-connected)') . "\r\n" . "\r\n" . z_root() . '/register' . "\r\n" . "\r\n" . t('2. Enter my RedMatrix network address into the site searchbar.') . "\r\n" . "\r\n" . $ob['xchan_addr'] . ' (' . t('or visit ') . z_root() . '/channel/' . $channel['channel_address'] . ')' . "\r\n" . "\r\n" . t('3. Click [Connect]') . "\r\n" . "\r\n", '$submit' => t('Submit')));
    return $o;
}
Esempio n. 27
0
 function get()
 {
     $change = false;
     logger('mod_group: ' . \App::$cmd, LOGGER_DEBUG);
     if (!local_channel()) {
         notice(t('Permission denied') . EOL);
         return;
     }
     // Switch to text mode interface if we have more than 'n' contacts or group members
     $switchtotext = get_pconfig(local_channel(), 'system', 'groupedit_image_limit');
     if ($switchtotext === false) {
         $switchtotext = get_config('system', 'groupedit_image_limit');
     }
     if ($switchtotext === false) {
         $switchtotext = 400;
     }
     $tpl = get_markup_template('group_edit.tpl');
     $context = array('$submit' => t('Submit'));
     if (argc() == 2 && argv(1) === 'new') {
         return replace_macros($tpl, $context + array('$title' => t('Create a group of channels.'), '$gname' => array('groupname', t('Privacy group name: '), '', ''), '$gid' => 'new', '$public' => array('public', t('Members are visible to other channels'), false, ''), '$form_security_token' => get_form_security_token("group_edit")));
     }
     if (argc() == 3 && argv(1) === 'drop') {
         check_form_security_token_redirectOnErr('/group', 'group_drop', 't');
         if (intval(argv(2))) {
             $r = q("SELECT `name` FROM `groups` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval(argv(2)), intval(local_channel()));
             if ($r) {
                 $result = group_rmv(local_channel(), $r[0]['gname']);
             }
             if ($result) {
                 info(t('Privacy group removed.') . EOL);
             } else {
                 notice(t('Unable to remove privacy group.') . EOL);
             }
         }
         goaway(z_root() . '/group');
         // NOTREACHED
     }
     if (argc() > 2 && intval(argv(1)) && argv(2)) {
         check_form_security_token_ForbiddenOnErr('group_member_change', 't');
         $r = q("SELECT abook_xchan from abook left join xchan on abook_xchan = xchan_hash where abook_xchan = '%s' and abook_channel = %d and xchan_deleted = 0 and abook_self = 0 and abook_blocked = 0 and abook_pending = 0 limit 1", dbesc(base64url_decode(argv(2))), intval(local_channel()));
         if (count($r)) {
             $change = base64url_decode(argv(2));
         }
     }
     if (argc() > 1 && intval(argv(1))) {
         require_once 'include/acl_selectors.php';
         $r = q("SELECT * FROM `groups` WHERE `id` = %d AND `uid` = %d AND `deleted` = 0 LIMIT 1", intval(argv(1)), intval(local_channel()));
         if (!$r) {
             notice(t('Privacy group not found.') . EOL);
             goaway(z_root() . '/connections');
         }
         $group = $r[0];
         $members = group_get_members($group['id']);
         $preselected = array();
         if (count($members)) {
             foreach ($members as $member) {
                 if (!in_array($member['xchan_hash'], $preselected)) {
                     $preselected[] = $member['xchan_hash'];
                 }
             }
         }
         if ($change) {
             if (in_array($change, $preselected)) {
                 group_rmv_member(local_channel(), $group['gname'], $change);
             } else {
                 group_add_member(local_channel(), $group['gname'], $change);
             }
             $members = group_get_members($group['id']);
             $preselected = array();
             if (count($members)) {
                 foreach ($members as $member) {
                     $preselected[] = $member['xchan_hash'];
                 }
             }
         }
         $drop_tpl = get_markup_template('group_drop.tpl');
         $drop_txt = replace_macros($drop_tpl, array('$id' => $group['id'], '$delete' => t('Delete'), '$form_security_token' => get_form_security_token("group_drop")));
         $context = $context + array('$title' => t('Privacy group editor'), '$gname' => array('groupname', t('Privacy group name: '), $group['gname'], ''), '$gid' => $group['id'], '$drop' => $drop_txt, '$public' => array('public', t('Members are visible to other channels'), $group['visible'], ''), '$form_security_token' => get_form_security_token('group_edit'));
     }
     if (!isset($group)) {
         return;
     }
     $groupeditor = array('label_members' => t('Members'), 'members' => array(), 'label_contacts' => t('All Connected Channels'), 'contacts' => array());
     $sec_token = addslashes(get_form_security_token('group_member_change'));
     $textmode = $switchtotext && count($members) > $switchtotext ? true : false;
     foreach ($members as $member) {
         if ($member['xchan_url']) {
             $member['archived'] = intval($member['abook_archived']) ? true : false;
             $member['click'] = 'groupChangeMember(' . $group['id'] . ',\'' . base64url_encode($member['xchan_hash']) . '\',\'' . $sec_token . '\'); return false;';
             $groupeditor['members'][] = micropro($member, true, 'mpgroup', $textmode);
         } else {
             group_rmv_member(local_channel(), $group['gname'], $member['xchan_hash']);
         }
     }
     $r = q("SELECT abook.*, xchan.* FROM `abook` left join xchan on abook_xchan = xchan_hash WHERE `abook_channel` = %d AND abook_self = 0 and abook_blocked = 0 and abook_pending = 0 and xchan_deleted = 0 order by xchan_name asc", intval(local_channel()));
     if (count($r)) {
         $textmode = $switchtotext && count($r) > $switchtotext ? true : false;
         foreach ($r as $member) {
             if (!in_array($member['xchan_hash'], $preselected)) {
                 $member['archived'] = intval($member['abook_archived']) ? true : false;
                 $member['click'] = 'groupChangeMember(' . $group['id'] . ',\'' . base64url_encode($member['xchan_hash']) . '\',\'' . $sec_token . '\'); return false;';
                 $groupeditor['contacts'][] = micropro($member, true, 'mpall', $textmode);
             }
         }
     }
     $context['$groupeditor'] = $groupeditor;
     $context['$desc'] = t('Click on a channel to add or remove.');
     if ($change) {
         $tpl = get_markup_template('groupeditor.tpl');
         echo replace_macros($tpl, $context);
         killme();
     }
     return replace_macros($tpl, $context);
 }
Esempio n. 28
0
 function get()
 {
     $o = '';
     $channel = \App::get_channel();
     if (!local_channel()) {
         notice(t('Permission denied.') . EOL);
         return;
     }
     require_once 'include/channel.php';
     $profile_fields_basic = get_profile_fields_basic();
     $profile_fields_advanced = get_profile_fields_advanced();
     if (argc() > 1 && intval(argv(1)) || !feature_enabled(local_channel(), 'multi_profiles')) {
         if (feature_enabled(local_channel(), 'multi_profiles')) {
             $id = \App::$argv[1];
         } else {
             $x = q("select id from profile where uid = %d and is_default = 1", intval(local_channel()));
             if ($x) {
                 $id = $x[0]['id'];
             }
         }
         $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($id), intval(local_channel()));
         if (!count($r)) {
             notice(t('Profile not found.') . EOL);
             return;
         }
         $editselect = 'none';
         \App::$page['htmlhead'] .= replace_macros(get_markup_template('profed_head.tpl'), array('$baseurl' => z_root(), '$editselect' => $editselect));
         $advanced = feature_enabled(local_channel(), 'advanced_profiles') ? true : false;
         if ($advanced) {
             $fields = $profile_fields_advanced;
         } else {
             $fields = $profile_fields_basic;
         }
         $hide_friends = array('hide_friends', t('Hide your connections list from viewers of this profile'), $r[0]['hide_friends'], '', array(t('No'), t('Yes')));
         $q = q("select * from profdef where true");
         if ($q) {
             $extra_fields = array();
             foreach ($q as $qq) {
                 $mine = q("select v from profext where k = '%s' and hash = '%s' and channel_id = %d limit 1", dbesc($qq['field_name']), dbesc($r[0]['profile_guid']), intval(local_channel()));
                 if (array_key_exists($qq['field_name'], $fields)) {
                     $extra_fields[] = array($qq['field_name'], $qq['field_desc'], $mine ? $mine[0]['v'] : '', $qq['field_help']);
                 }
             }
         }
         //logger('extra_fields: ' . print_r($extra_fields,true));
         $f = get_config('system', 'birthday_input_format');
         if (!$f) {
             $f = 'ymd';
         }
         $is_default = $r[0]['is_default'] ? 1 : 0;
         $tpl = get_markup_template("profile_edit.tpl");
         $o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("profile_edit"), '$profile_clone_link' => feature_enabled(local_channel(), 'multi_profiles') ? 'profiles/clone/' . $r[0]['id'] . '?t=' . get_form_security_token("profile_clone") : '', '$profile_drop_link' => 'profiles/drop/' . $r[0]['id'] . '?t=' . get_form_security_token("profile_drop"), '$fields' => $fields, '$guid' => $r[0]['profile_guid'], '$banner' => t('Edit Profile Details'), '$submit' => t('Submit'), '$viewprof' => t('View this profile'), '$editvis' => t('Edit visibility'), '$tools_label' => t('Profile Tools'), '$coverpic' => t('Change cover photo'), '$profpic' => t('Change profile photo'), '$cr_prof' => t('Create a new profile using these settings'), '$cl_prof' => t('Clone this profile'), '$del_prof' => t('Delete this profile'), '$addthing' => t('Add profile things'), '$personal' => t('Personal'), '$location' => t('Location'), '$relation' => t('Relation'), '$miscellaneous' => t('Miscellaneous'), '$exportable' => feature_enabled(local_channel(), 'profile_export'), '$lbl_import' => t('Import profile from file'), '$lbl_export' => t('Export profile to file'), '$lbl_gender' => t('Your gender'), '$lbl_marital' => t('Marital status'), '$lbl_sexual' => t('Sexual preference'), '$baseurl' => z_root(), '$profile_id' => $r[0]['id'], '$profile_name' => array('profile_name', t('Profile name'), $r[0]['profile_name'], t('Required'), '*'), '$is_default' => $is_default, '$default' => t('This is your default profile.') . EOL . translate_scope(map_scope($channel['channel_r_profile'])), '$advanced' => $advanced, '$name' => array('name', t('Your full name'), $r[0]['fullname'], t('Required'), '*'), '$pdesc' => array('pdesc', t('Title/Description'), $r[0]['pdesc']), '$dob' => dob($r[0]['dob']), '$hide_friends' => $hide_friends, '$address' => array('address', t('Street address'), $r[0]['address']), '$locality' => array('locality', t('Locality/City'), $r[0]['locality']), '$region' => array('region', t('Region/State'), $r[0]['region']), '$postal_code' => array('postal_code', t('Postal/Zip code'), $r[0]['postal_code']), '$country_name' => array('country_name', t('Country'), $r[0]['country_name']), '$gender' => gender_selector($r[0]['gender']), '$gender_min' => gender_selector_min($r[0]['gender']), '$marital' => marital_selector($r[0]['marital']), '$marital_min' => marital_selector_min($r[0]['marital']), '$with' => array('with', t("Who (if applicable)"), $r[0]['partner'], t('Examples: cathy123, Cathy Williams, cathy@example.com')), '$howlong' => array('howlong', t('Since (date)'), $r[0]['howlong'] === NULL_DATE ? '' : datetime_convert('UTC', date_default_timezone_get(), $r[0]['howlong'])), '$sexual' => sexpref_selector($r[0]['sexual']), '$sexual_min' => sexpref_selector_min($r[0]['sexual']), '$about' => array('about', t('Tell us about yourself'), $r[0]['about']), '$homepage' => array('homepage', t('Homepage URL'), $r[0]['homepage']), '$hometown' => array('hometown', t('Hometown'), $r[0]['hometown']), '$politic' => array('politic', t('Political views'), $r[0]['politic']), '$religion' => array('religion', t('Religious views'), $r[0]['religion']), '$keywords' => array('keywords', t('Keywords used in directory listings'), $r[0]['keywords'], t('Example: fishing photography software')), '$likes' => array('likes', t('Likes'), $r[0]['likes']), '$dislikes' => array('dislikes', t('Dislikes'), $r[0]['dislikes']), '$music' => array('music', t('Musical interests'), $r[0]['music']), '$book' => array('book', t('Books, literature'), $r[0]['book']), '$tv' => array('tv', t('Television'), $r[0]['tv']), '$film' => array('film', t('Film/Dance/Culture/Entertainment'), $r[0]['film']), '$interest' => array('interest', t('Hobbies/Interests'), $r[0]['interest']), '$romance' => array('romance', t('Love/Romance'), $r[0]['romance']), '$work' => array('work', t('Work/Employment'), $r[0]['employment']), '$education' => array('education', t('School/Education'), $r[0]['education']), '$contact' => array('contact', t('Contact information and social networks'), $r[0]['contact']), '$channels' => array('channels', t('My other channels'), $r[0]['channels']), '$extra_fields' => $extra_fields));
         $arr = array('profile' => $r[0], 'entry' => $o);
         call_hooks('profile_edit', $arr);
         return $o;
     } else {
         $r = q("SELECT * FROM `profile` WHERE `uid` = %d", local_channel());
         if ($r) {
             $tpl = get_markup_template('profile_entry.tpl');
             foreach ($r as $rr) {
                 $profiles .= replace_macros($tpl, array('$photo' => $rr['thumb'], '$id' => $rr['id'], '$alt' => t('Profile Image'), '$profile_name' => $rr['profile_name'], '$visible' => $rr['is_default'] ? '<strong>' . translate_scope(map_scope($channel['channel_r_profile'])) . '</strong>' : '<a href="' . z_root() . '/profperm/' . $rr['id'] . '" />' . t('Edit visibility') . '</a>'));
             }
             $tpl_header = get_markup_template('profile_listing_header.tpl');
             $o .= replace_macros($tpl_header, array('$header' => t('Edit Profiles'), '$cr_new' => t('Create New'), '$cr_new_link' => 'profiles/new?t=' . get_form_security_token("profile_new"), '$profiles' => $profiles));
         }
         return $o;
     }
 }
Esempio n. 29
0
/**
 * @param App $a
 * @param null|object $o
 */
function dav_plugin_admin(&$a, &$o)
{
    require_once __DIR__ . "/database-init.inc.php";
    $dbstatus = dav_check_tables();
    $o = '<input type="hidden" name="form_security_token" value="' . get_form_security_token("dav_admin_save") . '">';
    $o .= '<i>' . t("No system-wide settings yet.") . '</i><br><br>';
    $o .= '<h3>' . t('Database status') . '</h3>';
    switch ($dbstatus) {
        case 0:
            $o .= t('Installed');
            break;
        case 1:
            $o .= t('Upgrade needed') . "<br><br><input type='submit' name='upgrade' value='" . t('Upgrade') . "'>";
            break;
        case -1:
            $o .= t('Not installed') . "<br><br><input type='submit' name='install' value='" . t('Install') . "'>";
            break;
    }
    $o .= "<br><br>";
    $o .= "<h3>" . t("Troubleshooting") . "</h3>";
    $o .= "<h4>" . t("Manual creation of the database tables:") . "</h4>";
    $o .= "<a href='#' onClick='\$(\"#sqlstatements\").show(); return false;'>" . t("Show SQL-statements") . "</a><blockquote style='display: none;' id='sqlstatements'><pre>";
    $tables = dav_get_create_statements();
    foreach ($tables as $t) {
        $o .= escape_tags($t . "\n\n");
    }
    $o .= "</pre></blockquote>";
}
Esempio n. 30
0
 function settings_content(&$a)
 {
     $o = '';
     nav_set_selected('settings');
     if (!local_user()) {
         #notice( t('Permission denied.') . EOL );
         return;
     }
     if (x($_SESSION, 'submanage') && intval($_SESSION['submanage'])) {
         notice(t('Permission denied.') . EOL);
         return;
     }
     if ($a->argc > 1 && $a->argv[1] === 'oauth') {
         if ($a->argc > 2 && $a->argv[2] === 'add') {
             $tpl = get_markup_template("settings_oauth_edit.tpl");
             $o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("settings_oauth"), '$title' => t('Add application'), '$submit' => t('Save Settings'), '$cancel' => t('Cancel'), '$name' => array('name', t('Name'), '', ''), '$key' => array('key', t('Consumer Key'), '', ''), '$secret' => array('secret', t('Consumer Secret'), '', ''), '$redirect' => array('redirect', t('Redirect'), '', ''), '$icon' => array('icon', t('Icon url'), '', '')));
             return $o;
         }
         if ($a->argc > 3 && $a->argv[2] === 'edit') {
             $r = q("SELECT * FROM clients WHERE client_id='%s' AND uid=%d", dbesc($a->argv[3]), local_user());
             if (!count($r)) {
                 notice(t("You can't edit this application."));
                 return;
             }
             $app = $r[0];
             $tpl = get_markup_template("settings_oauth_edit.tpl");
             $o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("settings_oauth"), '$title' => t('Add application'), '$submit' => t('Update'), '$cancel' => t('Cancel'), '$name' => array('name', t('Name'), $app['name'], ''), '$key' => array('key', t('Consumer Key'), $app['client_id'], ''), '$secret' => array('secret', t('Consumer Secret'), $app['pw'], ''), '$redirect' => array('redirect', t('Redirect'), $app['redirect_uri'], ''), '$icon' => array('icon', t('Icon url'), $app['icon'], '')));
             return $o;
         }
         if ($a->argc > 3 && $a->argv[2] === 'delete') {
             check_form_security_token_redirectOnErr('/settings/oauth', 'settings_oauth', 't');
             $r = q("DELETE FROM clients WHERE client_id='%s' AND uid=%d", dbesc($a->argv[3]), local_user());
             goaway($a->get_baseurl(true) . "/settings/oauth/");
             return;
         }
         $r = q("SELECT clients.*, tokens.id as oauth_token, (clients.uid=%d) AS my\n\t\t\t\tFROM clients\n\t\t\t\tLEFT JOIN tokens ON clients.client_id=tokens.client_id\n\t\t\t\tWHERE clients.uid IN (%d,0)", local_user(), local_user());
         $tpl = get_markup_template("settings_oauth.tpl");
         $o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("settings_oauth"), '$baseurl' => $a->get_baseurl(true), '$title' => t('Connected Apps'), '$add' => t('Add application'), '$edit' => t('Edit'), '$delete' => t('Delete'), '$consumerkey' => t('Client key starts with'), '$noname' => t('No name'), '$remove' => t('Remove authorization'), '$apps' => $r));
         return $o;
     }
     if ($a->argc > 1 && $a->argv[1] === 'addon') {
         $settings_addons = "";
         $r = q("SELECT * FROM `hook` WHERE `hook` = 'plugin_settings' ");
         if (!count($r)) {
             $settings_addons = t('No Plugin settings configured');
         }
         call_hooks('plugin_settings', $settings_addons);
         $tpl = get_markup_template("settings_addons.tpl");
         $o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("settings_addon"), '$title' => t('Plugin Settings'), '$settings_addons' => $settings_addons));
         return $o;
     }
     if ($a->argc > 1 && $a->argv[1] === 'features') {
         $arr = array();
         $features = get_features();
         foreach ($features as $fname => $fdata) {
             $arr[$fname] = array();
             $arr[$fname][0] = $fdata[0];
             foreach (array_slice($fdata, 1) as $f) {
                 $arr[$fname][1][] = array('feature_' . $f[0], $f[1], intval(get_pconfig(local_user(), 'feature', $f[0])) ? "1" : '', $f[2], array(t('Off'), t('On')));
             }
         }
         $tpl = get_markup_template("settings_features.tpl");
         $o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("settings_features"), '$title' => t('Additional Features'), '$features' => $arr, '$submit' => t('Save Settings')));
         return $o;
     }
     if ($a->argc > 1 && $a->argv[1] === 'connectors') {
         $settings_connectors = "";
         call_hooks('connector_settings', $settings_connectors);
         if (is_site_admin()) {
             $diasp_enabled = sprintf(t('Built-in support for %s connectivity is %s'), t('Diaspora'), get_config('system', 'diaspora_enabled') ? t('enabled') : t('disabled'));
             $ostat_enabled = sprintf(t('Built-in support for %s connectivity is %s'), t('StatusNet'), get_config('system', 'ostatus_disabled') ? t('disabled') : t('enabled'));
         } else {
             $diasp_enabled = "";
             $ostat_enabled = "";
         }
         $mail_disabled = function_exists('imap_open') && !get_config('system', 'imap_disabled') ? 0 : 1;
         if (get_config('system', 'dfrn_only')) {
             $mail_disabled = 1;
         }
         if (!$mail_disabled) {
             $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1", local_user());
         } else {
             $r = null;
         }
         $mail_server = count($r) ? $r[0]['server'] : '';
         $mail_port = count($r) && intval($r[0]['port']) ? intval($r[0]['port']) : '';
         $mail_ssl = count($r) ? $r[0]['ssltype'] : '';
         $mail_user = count($r) ? $r[0]['user'] : '';
         $mail_replyto = count($r) ? $r[0]['reply_to'] : '';
         $mail_pubmail = count($r) ? $r[0]['pubmail'] : 0;
         $mail_action = count($r) ? $r[0]['action'] : 0;
         $mail_movetofolder = count($r) ? $r[0]['movetofolder'] : '';
         $mail_chk = count($r) ? $r[0]['last_check'] : '0000-00-00 00:00:00';
         $tpl = get_markup_template("settings_connectors.tpl");
         if (!service_class_allows(local_user(), 'email_connect')) {
             $mail_disabled_message = upgrade_bool_message();
         } else {
             $mail_disabled_message = $mail_disabled ? t('Email access is disabled on this site.') : '';
         }
         $o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("settings_connectors"), '$title' => t('Social Networks'), '$diasp_enabled' => $diasp_enabled, '$ostat_enabled' => $ostat_enabled, '$h_imap' => t('Email/Mailbox Setup'), '$imap_desc' => t("If you wish to communicate with email contacts using this service (optional), please specify how to connect to your mailbox."), '$imap_lastcheck' => array('imap_lastcheck', t('Last successful email check:'), $mail_chk, ''), '$mail_disabled' => $mail_disabled_message, '$mail_server' => array('mail_server', t('IMAP server name:'), $mail_server, ''), '$mail_port' => array('mail_port', t('IMAP port:'), $mail_port, ''), '$mail_ssl' => array('mail_ssl', t('Security:'), strtoupper($mail_ssl), '', array('notls' => t('None'), 'TLS' => 'TLS', 'SSL' => 'SSL')), '$mail_user' => array('mail_user', t('Email login name:'), $mail_user, ''), '$mail_pass' => array('mail_pass', t('Email password:'******'', ''), '$mail_replyto' => array('mail_replyto', t('Reply-to address:'), $mail_replyto, 'Optional'), '$mail_pubmail' => array('mail_pubmail', t('Send public posts to all email contacts:'), $mail_pubmail, ''), '$mail_action' => array('mail_action', t('Action after import:'), $mail_action, '', array(0 => t('None'), 2 => t('Mark as seen'), 3 => t('Move to folder'))), '$mail_movetofolder' => array('mail_movetofolder', t('Move to folder:'), $mail_movetofolder, ''), '$submit' => t('Save Settings'), '$settings_connectors' => $settings_connectors));
         call_hooks('display_settings', $o);
         return $o;
     }
     /*
      * DISPLAY SETTINGS
      */
     if ($a->argc > 1 && $a->argv[1] === 'display') {
         $default_theme = get_config('system', 'theme');
         if (!$default_theme) {
             $default_theme = 'default';
         }
         $default_mobile_theme = get_config('system', 'mobile-theme');
         if (!$mobile_default_theme) {
             $mobile_default_theme = 'none';
         }
         $allowed_themes_str = get_config('system', 'allowed_themes');
         $allowed_themes_raw = explode(',', $allowed_themes_str);
         $allowed_themes = array();
         if (count($allowed_themes_raw)) {
             foreach ($allowed_themes_raw as $x) {
                 if (strlen(trim($x)) && is_dir("view/theme/{$x}")) {
                     $allowed_themes[] = trim($x);
                 }
             }
         }
         $themes = array();
         $mobile_themes = array("---" => t('No special theme for mobile devices'));
         $files = glob('view/theme/*');
         /* */
         if ($allowed_themes) {
             foreach ($allowed_themes as $th) {
                 $f = $th;
                 $is_experimental = file_exists('view/theme/' . $th . '/experimental');
                 $unsupported = file_exists('view/theme/' . $th . '/unsupported');
                 $is_mobile = file_exists('view/theme/' . $th . '/mobile');
                 if (!$is_experimental or $is_experimental && (get_config('experimentals', 'exp_themes') == 1 or get_config('experimentals', 'exp_themes') === false)) {
                     $theme_name = $is_experimental ? sprintf("%s - (Experimental)", $f) : $f;
                     if ($is_mobile) {
                         $mobile_themes[$f] = $theme_name;
                     } else {
                         $themes[$f] = $theme_name;
                     }
                 }
             }
         }
         $theme_selected = !x($_SESSION, 'theme') ? $default_theme : $_SESSION['theme'];
         $mobile_theme_selected = !x($_SESSION, 'mobile-theme') ? $default_mobile_theme : $_SESSION['mobile-theme'];
         $browser_update = intval(get_pconfig(local_user(), 'system', 'update_interval'));
         $browser_update = $browser_update == 0 ? 40 : $browser_update / 1000;
         // default if not set: 40 seconds
         $itemspage_network = intval(get_pconfig(local_user(), 'system', 'itemspage_network'));
         $itemspage_network = $itemspage_network > 0 && $itemspage_network < 101 ? $itemspage_network : 40;
         // default if not set: 40 items
         $itemspage_mobile_network = intval(get_pconfig(local_user(), 'system', 'itemspage_mobile_network'));
         $itemspage_mobile_network = $itemspage_mobile_network > 0 && $itemspage_mobile_network < 101 ? $itemspage_mobile_network : 20;
         // default if not set: 20 items
         $nosmile = get_pconfig(local_user(), 'system', 'no_smilies');
         $nosmile = $nosmile === false ? '0' : $nosmile;
         // default if not set: 0
         $noinfo = get_pconfig(local_user(), 'system', 'ignore_info');
         $noinfo = $noinfo === false ? '0' : $noinfo;
         // default if not set: 0
         $infinite_scroll = get_pconfig(local_user(), 'system', 'infinite_scroll');
         $infinite_scroll = $infinite_scroll === false ? '0' : $infinite_scroll;
         // default if not set: 0
         $no_auto_update = get_pconfig(local_user(), 'system', 'no_auto_update');
         $no_auto_update = $no_auto_update === false ? '0' : $no_auto_update;
         // default if not set: 0
         $theme_config = "";
         if (($themeconfigfile = get_theme_config_file($theme_selected)) != null) {
             require_once $themeconfigfile;
             $theme_config = theme_content($a);
         }
         $tpl = get_markup_template("settings_display.tpl");
         $o = replace_macros($tpl, array('$ptitle' => t('Display Settings'), '$form_security_token' => get_form_security_token("settings_display"), '$submit' => t('Save Settings'), '$baseurl' => $a->get_baseurl(true), '$uid' => local_user(), '$theme' => array('theme', t('Display Theme:'), $theme_selected, '', $themes, true), '$mobile_theme' => array('mobile_theme', t('Mobile Theme:'), $mobile_theme_selected, '', $mobile_themes, false), '$ajaxint' => array('browser_update', t("Update browser every xx seconds"), $browser_update, t('Minimum of 10 seconds, no maximum')), '$itemspage_network' => array('itemspage_network', t("Number of items to display per page:"), $itemspage_network, t('Maximum of 100 items')), '$itemspage_mobile_network' => array('itemspage_mobile_network', t("Number of items to display per page when viewed from mobile device:"), $itemspage_mobile_network, t('Maximum of 100 items')), '$nosmile' => array('nosmile', t("Don't show emoticons"), $nosmile, ''), '$noinfo' => array('noinfo', t("Don't show notices"), $noinfo, ''), '$infinite_scroll' => array('infinite_scroll', t("Infinite scroll"), $infinite_scroll, ''), '$no_auto_update' => array('no_auto_update', t("Automatic updates only at the top of the network page"), $no_auto_update, 'When disabled, the network page is updated all the time, which could be confusing while reading.'), '$theme_config' => $theme_config));
         $tpl = get_markup_template("settings_display_end.tpl");
         $a->page['end'] .= replace_macros($tpl, array('$theme' => array('theme', t('Display Theme:'), $theme_selected, '', $themes)));
         return $o;
     }
     /*
      * ACCOUNT SETTINGS
      */
     require_once 'include/acl_selectors.php';
     $p = q("SELECT * FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1", intval(local_user()));
     if (count($p)) {
         $profile = $p[0];
     }
     $username = $a->user['username'];
     $email = $a->user['email'];
     $nickname = $a->user['nickname'];
     $timezone = $a->user['timezone'];
     $notify = $a->user['notify-flags'];
     $defloc = $a->user['default-location'];
     $openid = $a->user['openid'];
     $maxreq = $a->user['maxreq'];
     $expire = intval($a->user['expire']) ? $a->user['expire'] : '';
     $blockwall = $a->user['blockwall'];
     $blocktags = $a->user['blocktags'];
     $unkmail = $a->user['unkmail'];
     $cntunkmail = $a->user['cntunkmail'];
     $expire_items = get_pconfig(local_user(), 'expire', 'items');
     $expire_items = $expire_items === false ? '1' : $expire_items;
     // default if not set: 1
     $expire_notes = get_pconfig(local_user(), 'expire', 'notes');
     $expire_notes = $expire_notes === false ? '1' : $expire_notes;
     // default if not set: 1
     $expire_starred = get_pconfig(local_user(), 'expire', 'starred');
     $expire_starred = $expire_starred === false ? '1' : $expire_starred;
     // default if not set: 1
     $expire_photos = get_pconfig(local_user(), 'expire', 'photos');
     $expire_photos = $expire_photos === false ? '0' : $expire_photos;
     // default if not set: 0
     $expire_network_only = get_pconfig(local_user(), 'expire', 'network_only');
     $expire_network_only = $expire_network_only === false ? '0' : $expire_network_only;
     // default if not set: 0
     $suggestme = get_pconfig(local_user(), 'system', 'suggestme');
     $suggestme = $suggestme === false ? '0' : $suggestme;
     // default if not set: 0
     $post_newfriend = get_pconfig(local_user(), 'system', 'post_newfriend');
     $post_newfriend = $post_newfriend === false ? '0' : $post_newfriend;
     // default if not set: 0
     $post_joingroup = get_pconfig(local_user(), 'system', 'post_joingroup');
     $post_joingroup = $post_joingroup === false ? '0' : $post_joingroup;
     // default if not set: 0
     $post_profilechange = get_pconfig(local_user(), 'system', 'post_profilechange');
     $post_profilechange = $post_profilechange === false ? '0' : $post_profilechange;
     // default if not set: 0
     // nowarn_insecure
     if (!strlen($a->user['timezone'])) {
         $timezone = date_default_timezone_get();
     }
     $pageset_tpl = get_markup_template('pagetypes.tpl');
     $pagetype = replace_macros($pageset_tpl, array('$user' => t("User Types"), '$community' => t("Community Types"), '$page_normal' => array('page-flags', t('Normal Account Page'), PAGE_NORMAL, t('This account is a normal personal profile'), $a->user['page-flags'] == PAGE_NORMAL), '$page_soapbox' => array('page-flags', t('Soapbox Page'), PAGE_SOAPBOX, t('Automatically approve all connection/friend requests as read-only fans'), $a->user['page-flags'] == PAGE_SOAPBOX), '$page_community' => array('page-flags', t('Community Forum/Celebrity Account'), PAGE_COMMUNITY, t('Automatically approve all connection/friend requests as read-write fans'), $a->user['page-flags'] == PAGE_COMMUNITY), '$page_freelove' => array('page-flags', t('Automatic Friend Page'), PAGE_FREELOVE, t('Automatically approve all connection/friend requests as friends'), $a->user['page-flags'] == PAGE_FREELOVE), '$page_prvgroup' => array('page-flags', t('Private Forum [Experimental]'), PAGE_PRVGROUP, t('Private forum - approved members only'), $a->user['page-flags'] == PAGE_PRVGROUP)));
     $noid = get_config('system', 'no_openid');
     if ($noid) {
         $openid_field = false;
     } else {
         $openid_field = array('openid_url', t('OpenID:'), $openid, t("(Optional) Allow this OpenID to login to this account."));
     }
     $opt_tpl = get_markup_template("field_yesno.tpl");
     if (get_config('system', 'publish_all')) {
         $profile_in_dir = '<input type="hidden" name="profile_in_directory" value="1" />';
     } else {
         $profile_in_dir = replace_macros($opt_tpl, array('$field' => array('profile_in_directory', t('Publish your default profile in your local site directory?'), $profile['publish'], '', array(t('No'), t('Yes')))));
     }
     if (strlen(get_config('system', 'directory_submit_url'))) {
         $profile_in_net_dir = replace_macros($opt_tpl, array('$field' => array('profile_in_netdirectory', t('Publish your default profile in the global social directory?'), $profile['net-publish'], '', array(t('No'), t('Yes')))));
     } else {
         $profile_in_net_dir = '';
     }
     $hide_friends = replace_macros($opt_tpl, array('$field' => array('hide-friends', t('Hide your contact/friend list from viewers of your default profile?'), $profile['hide-friends'], '', array(t('No'), t('Yes')))));
     $hide_wall = replace_macros($opt_tpl, array('$field' => array('hidewall', t('Hide your profile details from unknown viewers?'), $a->user['hidewall'], t("If enabled, posting public messages to Diaspora and other networks isn't possible."), array(t('No'), t('Yes')))));
     $blockwall = replace_macros($opt_tpl, array('$field' => array('blockwall', t('Allow friends to post to your profile page?'), intval($a->user['blockwall']) ? '0' : '1', '', array(t('No'), t('Yes')))));
     $blocktags = replace_macros($opt_tpl, array('$field' => array('blocktags', t('Allow friends to tag your posts?'), intval($a->user['blocktags']) ? '0' : '1', '', array(t('No'), t('Yes')))));
     $suggestme = replace_macros($opt_tpl, array('$field' => array('suggestme', t('Allow us to suggest you as a potential friend to new members?'), $suggestme, '', array(t('No'), t('Yes')))));
     $unkmail = replace_macros($opt_tpl, array('$field' => array('unkmail', t('Permit unknown people to send you private mail?'), $unkmail, '', array(t('No'), t('Yes')))));
     $invisible = !$profile['publish'] && !$profile['net-publish'] ? true : false;
     if ($invisible) {
         info(t('Profile is <strong>not published</strong>.') . EOL);
     }
     $subdir = strlen($a->get_path()) ? '<br />' . t('or') . ' ' . $a->get_baseurl(true) . '/profile/' . $nickname : '';
     $tpl_addr = get_markup_template("settings_nick_set.tpl");
     $prof_addr = replace_macros($tpl_addr, array('$desc' => t('Your Identity Address is'), '$nickname' => $nickname, '$subdir' => $subdir, '$basepath' => $a->get_hostname()));
     $stpl = get_markup_template('settings.tpl');
     $celeb = $a->user['page-flags'] == PAGE_SOAPBOX || $a->user['page-flags'] == PAGE_COMMUNITY ? true : false;
     $expire_arr = array('days' => array('expire', t("Automatically expire posts after this many days:"), $expire, t('If empty, posts will not expire. Expired posts will be deleted')), 'advanced' => t('Advanced expiration settings'), 'label' => t('Advanced Expiration'), 'items' => array('expire_items', t("Expire posts:"), $expire_items, '', array(t('No'), t('Yes'))), 'notes' => array('expire_notes', t("Expire personal notes:"), $expire_notes, '', array(t('No'), t('Yes'))), 'starred' => array('expire_starred', t("Expire starred posts:"), $expire_starred, '', array(t('No'), t('Yes'))), 'photos' => array('expire_photos', t("Expire photos:"), $expire_photos, '', array(t('No'), t('Yes'))), 'network_only' => array('expire_network_only', t("Only expire posts by others:"), $expire_network_only, '', array(t('No'), t('Yes'))));
     require_once 'include/group.php';
     $group_select = mini_group_select(local_user(), $a->user['def_gid']);
     // Private/public post links for the non-JS ACL form
     $private_post = 1;
     if ($_REQUEST['public']) {
         $private_post = 0;
     }
     $query_str = $a->query_string;
     if (strpos($query_str, 'public=1') !== false) {
         $query_str = str_replace(array('?public=1', '&public=1'), array('', ''), $query_str);
     }
     // I think $a->query_string may never have ? in it, but I could be wrong
     // It looks like it's from the index.php?q=[etc] rewrite that the web
     // server does, which converts any ? to &, e.g. suggest&ignore=61 for suggest?ignore=61
     if (strpos($query_str, '?') === false) {
         $public_post_link = '?public=1';
     } else {
         $public_post_link = '&public=1';
     }
     $o .= replace_macros($stpl, array('$ptitle' => t('Account Settings'), '$submit' => t('Save Settings'), '$baseurl' => $a->get_baseurl(true), '$uid' => local_user(), '$form_security_token' => get_form_security_token("settings"), '$nickname_block' => $prof_addr, '$h_pass' => t('Password Settings'), '$password1' => array('password', t('New Password:'******'', ''), '$password2' => array('confirm', t('Confirm:'), '', t('Leave password fields blank unless changing')), '$password3' => array('opassword', t('Current Password:'******'', t('Your current password to confirm the changes')), '$password4' => array('mpassword', t('Password:'******'', t('Your current password to confirm the changes')), '$oid_enable' => !get_config('system', 'no_openid'), '$openid' => $openid_field, '$h_basic' => t('Basic Settings'), '$username' => array('username', t('Full Name:'), $username, ''), '$email' => array('email', t('Email Address:'), $email, '', '', '', 'email'), '$timezone' => array('timezone_select', t('Your Timezone:'), select_timezone($timezone), ''), '$defloc' => array('defloc', t('Default Post Location:'), $defloc, ''), '$allowloc' => array('allow_location', t('Use Browser Location:'), $a->user['allow_location'] == 1, ''), '$h_prv' => t('Security and Privacy Settings'), '$maxreq' => array('maxreq', t('Maximum Friend Requests/Day:'), $maxreq, t("(to prevent spam abuse)")), '$permissions' => t('Default Post Permissions'), '$permdesc' => t("(click to open/close)"), '$visibility' => $profile['net-publish'], '$aclselect' => populate_acl($a->user, $celeb), '$suggestme' => $suggestme, '$blockwall' => $blockwall, '$blocktags' => $blocktags, '$acl_data' => construct_acl_data($a, $a->user), '$group_perms' => t('Show to Groups'), '$contact_perms' => t('Show to Contacts'), '$private' => t('Default Private Post'), '$public' => t('Default Public Post'), '$is_private' => $private_post, '$return_path' => $query_str, '$public_link' => $public_post_link, '$settings_perms' => t('Default Permissions for New Posts'), '$group_select' => $group_select, '$expire' => $expire_arr, '$profile_in_dir' => $profile_in_dir, '$profile_in_net_dir' => $profile_in_net_dir, '$hide_friends' => $hide_friends, '$hide_wall' => $hide_wall, '$unkmail' => $unkmail, '$cntunkmail' => array('cntunkmail', t('Maximum private messages per day from unknown people:'), $cntunkmail, t("(to prevent spam abuse)")), '$h_not' => t('Notification Settings'), '$activity_options' => t('By default post a status message when:'), '$post_newfriend' => array('post_newfriend', t('accepting a friend request'), $post_newfriend, ''), '$post_joingroup' => array('post_joingroup', t('joining a forum/community'), $post_joingroup, ''), '$post_profilechange' => array('post_profilechange', t('making an <em>interesting</em> profile change'), $post_profilechange, ''), '$lbl_not' => t('Send a notification email when:'), '$notify1' => array('notify1', t('You receive an introduction'), $notify & NOTIFY_INTRO, NOTIFY_INTRO, ''), '$notify2' => array('notify2', t('Your introductions are confirmed'), $notify & NOTIFY_CONFIRM, NOTIFY_CONFIRM, ''), '$notify3' => array('notify3', t('Someone writes on your profile wall'), $notify & NOTIFY_WALL, NOTIFY_WALL, ''), '$notify4' => array('notify4', t('Someone writes a followup comment'), $notify & NOTIFY_COMMENT, NOTIFY_COMMENT, ''), '$notify5' => array('notify5', t('You receive a private message'), $notify & NOTIFY_MAIL, NOTIFY_MAIL, ''), '$notify6' => array('notify6', t('You receive a friend suggestion'), $notify & NOTIFY_SUGGEST, NOTIFY_SUGGEST, ''), '$notify7' => array('notify7', t('You are tagged in a post'), $notify & NOTIFY_TAGSELF, NOTIFY_TAGSELF, ''), '$notify8' => array('notify8', t('You are poked/prodded/etc. in a post'), $notify & NOTIFY_POKE, NOTIFY_POKE, ''), '$email_textonly' => array('email_textonly', t('Text-only notification emails'), get_pconfig(local_user(), 'system', 'email_textonly'), t('Send text only notification emails, without the html part')), '$h_advn' => t('Advanced Account/Page Type Settings'), '$h_descadvn' => t('Change the behaviour of this account for special situations'), '$pagetype' => $pagetype, '$relocate' => t('Relocate'), '$relocate_text' => t("If you have moved this profile from another server, and some of your contacts don't receive your updates, try pushing this button."), '$relocate_button' => t("Resend relocate message to contacts")));
     call_hooks('settings_form', $o);
     $o .= '</form>' . "\r\n";
     return $o;
 }