Merge pull request #3882 from annando/config-null

Still some more places with config stuff
This commit is contained in:
Hypolite Petovan 2017-11-08 08:21:23 -05:00 committed by GitHub
commit 2a814623d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 72 additions and 93 deletions

View File

@ -79,7 +79,7 @@ class exAuth {
$this->writeLog(LOG_NOTICE, "start"); $this->writeLog(LOG_NOTICE, "start");
// We are connected to the SQL server. // We are connected to the SQL server.
do { while (!feof(STDIN)) {
// Quit if the database connection went down // Quit if the database connection went down
if (!dba::connected()) { if (!dba::connected()) {
$this->writeLog(LOG_ERR, "the database connection went down"); $this->writeLog(LOG_ERR, "the database connection went down");
@ -125,7 +125,7 @@ class exAuth {
$this->writeLog(LOG_NOTICE, "invalid command string ".$sData); $this->writeLog(LOG_NOTICE, "invalid command string ".$sData);
fwrite(STDOUT, pack("nn", 2, 0)); fwrite(STDOUT, pack("nn", 2, 0));
} }
} while (true); }
} }
/** /**

View File

@ -2021,22 +2021,16 @@ function item_expire($uid, $days, $network = "", $force = false) {
return; return;
} }
$expire_items = PConfig::get($uid, 'expire', 'items'); $expire_items = PConfig::get($uid, 'expire', 'items', 1);
$expire_items = (($expire_items === false) ? 1 : intval($expire_items)); // default if not set: 1
// Forcing expiring of items - but not notes and marked items // Forcing expiring of items - but not notes and marked items
if ($force) { if ($force) {
$expire_items = true; $expire_items = true;
} }
$expire_notes = PConfig::get($uid, 'expire', 'notes'); $expire_notes = PConfig::get($uid, 'expire', 'notes', 1);
$expire_notes = (($expire_notes === false) ? 1 : intval($expire_notes)); // default if not set: 1 $expire_starred = PConfig::get($uid, 'expire', 'starred', 1);
$expire_photos = PConfig::get($uid, 'expire', 'photos', 0);
$expire_starred = PConfig::get($uid, 'expire', 'starred');
$expire_starred = (($expire_starred === false) ? 1 : intval($expire_starred)); // default if not set: 1
$expire_photos = PConfig::get($uid, 'expire', 'photos');
$expire_photos = (($expire_photos === false) ? 0 : intval($expire_photos)); // default if not set: 0
logger('User '.$uid.': expire: # items=' . count($r). "; expire items: $expire_items, expire notes: $expire_notes, expire starred: $expire_starred, expire photos: $expire_photos"); logger('User '.$uid.': expire: # items=' . count($r). "; expire items: $expire_items, expire notes: $expire_notes, expire starred: $expire_starred, expire photos: $expire_photos");

View File

@ -2234,7 +2234,7 @@ function admin_page_features_post(App $a) {
} else { } else {
$val = 0; $val = 0;
} }
Config::set('feature',$feature,$val); Config::set('feature', $feature, $val);
if (x($_POST, $featurelock)) { if (x($_POST, $featurelock)) {
Config::set('feature_lock', $feature, $val); Config::set('feature_lock', $feature, $val);
@ -2273,10 +2273,7 @@ function admin_page_features(App $a) {
$arr[$fname][0] = $fdata[0]; $arr[$fname][0] = $fdata[0];
foreach (array_slice($fdata,1) as $f) { foreach (array_slice($fdata,1) as $f) {
$set = Config::get('feature',$f[0]); $set = Config::get('feature', $f[0], $f[3]);
if ($set === false) {
$set = $f[3];
}
$arr[$fname][1][] = array( $arr[$fname][1][] = array(
array('feature_' .$f[0],$f[1],$set,$f[2],array(t('Off'), t('On'))), 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" : ''),'',array(t('Off'), t('On'))) array('featurelock_' .$f[0],sprintf(t('Lock feature %s'),$f[1]),(($f[4] !== false) ? "1" : ''),'',array(t('Off'), t('On')))

View File

@ -73,8 +73,7 @@ function cal_content(App $a) {
nav_set_selected('events'); nav_set_selected('events');
// First day of the week (0 = Sunday) // First day of the week (0 = Sunday)
$firstDay = PConfig::get(local_user(),'system','first_day_of_week'); $firstDay = PConfig::get(local_user(),'system','first_day_of_week', 0);
if ($firstDay === false) $firstDay=0;
// get the translation strings for the callendar // get the translation strings for the callendar
$i18n = get_event_strings(); $i18n = get_event_strings();

View File

@ -84,11 +84,8 @@ function group_content(App $a) {
// Switch to text mode interface if we have more than 'n' contacts or group members // Switch to text mode interface if we have more than 'n' contacts or group members
$switchtotext = PConfig::get(local_user(), 'system', 'groupedit_image_limit'); $switchtotext = PConfig::get(local_user(), 'system', 'groupedit_image_limit');
if ($switchtotext === false) { if (is_null($switchtotext)) {
$switchtotext = Config::get('system', 'groupedit_image_limit'); $switchtotext = Config::get('system', 'groupedit_image_limit', 400);
}
if ($switchtotext === false) {
$switchtotext = 400;
} }
$tpl = get_markup_template('group_edit.tpl'); $tpl = get_markup_template('group_edit.tpl');

View File

@ -34,11 +34,9 @@ function profperm_content(App $a) {
// Switch to text mod interface if we have more than 'n' contacts or group members // Switch to text mod interface if we have more than 'n' contacts or group members
$switchtotext = PConfig::get(local_user(),'system','groupedit_image_limit'); $switchtotext = PConfig::get(local_user(),'system','groupedit_image_limit');
if($switchtotext === false) if (is_null($switchtotext)) {
$switchtotext = Config::get('system','groupedit_image_limit'); $switchtotext = Config::get('system','groupedit_image_limit', 400);
if($switchtotext === false) }
$switchtotext = 400;
if(($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) { if(($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) {
$r = q("SELECT `id` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `self` = 0 $r = q("SELECT `id` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `self` = 0

View File

@ -953,7 +953,7 @@ function settings_content(App $a) {
$is_experimental = file_exists('view/theme/' . $th . '/experimental'); $is_experimental = file_exists('view/theme/' . $th . '/experimental');
$unsupported = file_exists('view/theme/' . $th . '/unsupported'); $unsupported = file_exists('view/theme/' . $th . '/unsupported');
$is_mobile = file_exists('view/theme/' . $th . '/mobile'); $is_mobile = file_exists('view/theme/' . $th . '/mobile');
if (!$is_experimental || ($is_experimental && (Config::get('experimentals', 'exp_themes')==1 || Config::get('experimentals', 'exp_themes')===false))) { if (!$is_experimental || ($is_experimental && (Config::get('experimentals', 'exp_themes')==1 || is_null(Config::get('experimentals', 'exp_themes'))))) {
$theme_name = (($is_experimental) ? sprintf("%s - \x28Experimental\x29", $f) : $f); $theme_name = (($is_experimental) ? sprintf("%s - \x28Experimental\x29", $f) : $f);
if ($is_mobile) { if ($is_mobile) {
$mobile_themes[$f]=$theme_name; $mobile_themes[$f]=$theme_name;
@ -978,24 +978,14 @@ function settings_content(App $a) {
$itemspage_mobile_network = intval(PConfig::get(local_user(), 'system', 'itemspage_mobile_network')); $itemspage_mobile_network = intval(PConfig::get(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 $itemspage_mobile_network = (($itemspage_mobile_network > 0 && $itemspage_mobile_network < 101) ? $itemspage_mobile_network : 20); // default if not set: 20 items
$nosmile = PConfig::get(local_user(), 'system', 'no_smilies'); $nosmile = PConfig::get(local_user(), 'system', 'no_smilies', 0);
$nosmile = (($nosmile===false)? '0': $nosmile); // default if not set: 0 $first_day_of_week = PConfig::get(local_user(), 'system', 'first_day_of_week', 0);
$first_day_of_week = PConfig::get(local_user(), 'system', 'first_day_of_week');
$first_day_of_week = (($first_day_of_week===false)? '0': $first_day_of_week); // default if not set: 0
$weekdays = array(0 => t("Sunday"), 1 => t("Monday")); $weekdays = array(0 => t("Sunday"), 1 => t("Monday"));
$noinfo = PConfig::get(local_user(), 'system', 'ignore_info'); $noinfo = PConfig::get(local_user(), 'system', 'ignore_info', 0);
$noinfo = (($noinfo===false)? '0': $noinfo); // default if not set: 0 $infinite_scroll = PConfig::get(local_user(), 'system', 'infinite_scroll', 0);
$no_auto_update = PConfig::get(local_user(), 'system', 'no_auto_update', 0);
$infinite_scroll = PConfig::get(local_user(), 'system', 'infinite_scroll'); $bandwidth_saver = PConfig::get(local_user(), 'system', 'bandwidth_saver', 0);
$infinite_scroll = (($infinite_scroll===false)? '0': $infinite_scroll); // default if not set: 0
$no_auto_update = PConfig::get(local_user(), 'system', 'no_auto_update');
$no_auto_update = (($no_auto_update===false)? '0': $no_auto_update); // default if not set: 0
$bandwidth_saver = PConfig::get(local_user(), 'system', 'bandwidth_saver');
$bandwidth_saver = (($bandwidth_saver === false) ? '0' : $bandwidth_saver); // default if not set: 0
$theme_config = ""; $theme_config = "";
if (($themeconfigfile = get_theme_config_file($theme_selected)) != null) { if (($themeconfigfile = get_theme_config_file($theme_selected)) != null) {

View File

@ -161,13 +161,13 @@ class ParseUrl {
$oembed_data = oembed_fetch_url($url); $oembed_data = oembed_fetch_url($url);
if (!in_array($oembed_data->type, array("error", "rich"))) { if (!in_array($oembed_data->type, array("error", "rich", ""))) {
$siteinfo["type"] = $oembed_data->type; $siteinfo["type"] = $oembed_data->type;
} }
if (($oembed_data->type == "link") && ($siteinfo["type"] != "photo")) { if (($oembed_data->type == "link") && ($siteinfo["type"] != "photo")) {
if (isset($oembed_data->title)) { if (isset($oembed_data->title)) {
$siteinfo["title"] = $oembed_data->title; $siteinfo["title"] = trim($oembed_data->title);
} }
if (isset($oembed_data->description)) { if (isset($oembed_data->description)) {
$siteinfo["text"] = trim($oembed_data->description); $siteinfo["text"] = trim($oembed_data->description);
@ -240,7 +240,7 @@ class ParseUrl {
$list = $xpath->query("//title"); $list = $xpath->query("//title");
if ($list->length > 0) { if ($list->length > 0) {
$siteinfo["title"] = $list->item(0)->nodeValue; $siteinfo["title"] = trim($list->item(0)->nodeValue);
} }
//$list = $xpath->query("head/meta[@name]"); //$list = $xpath->query("head/meta[@name]");
@ -258,10 +258,10 @@ class ParseUrl {
if ($attr["content"] != "") { if ($attr["content"] != "") {
switch (strtolower($attr["name"])) { switch (strtolower($attr["name"])) {
case "fulltitle": case "fulltitle":
$siteinfo["title"] = $attr["content"]; $siteinfo["title"] = trim($attr["content"]);
break; break;
case "description": case "description":
$siteinfo["text"] = $attr["content"]; $siteinfo["text"] = trim($attr["content"]);
break; break;
case "thumbnail": case "thumbnail":
$siteinfo["image"] = $attr["content"]; $siteinfo["image"] = $attr["content"];
@ -278,16 +278,16 @@ class ParseUrl {
} }
break; break;
case "twitter:description": case "twitter:description":
$siteinfo["text"] = $attr["content"]; $siteinfo["text"] = trim($attr["content"]);
break; break;
case "twitter:title": case "twitter:title":
$siteinfo["title"] = $attr["content"]; $siteinfo["title"] = trim($attr["content"]);
break; break;
case "dc.title": case "dc.title":
$siteinfo["title"] = $attr["content"]; $siteinfo["title"] = trim($attr["content"]);
break; break;
case "dc.description": case "dc.description":
$siteinfo["text"] = $attr["content"]; $siteinfo["text"] = trim($attr["content"]);
break; break;
case "keywords": case "keywords":
$keywords = explode(",", $attr["content"]); $keywords = explode(",", $attr["content"]);
@ -329,10 +329,10 @@ class ParseUrl {
$siteinfo["image"] = $attr["content"]; $siteinfo["image"] = $attr["content"];
break; break;
case "og:title": case "og:title":
$siteinfo["title"] = $attr["content"]; $siteinfo["title"] = trim($attr["content"]);
break; break;
case "og:description": case "og:description":
$siteinfo["text"] = $attr["content"]; $siteinfo["text"] = trim($attr["content"]);
break; break;
} }
} }

View File

@ -5,27 +5,30 @@
$uid = get_theme_uid(); $uid = get_theme_uid();
$color=false; $color = false;
$quattro_align=false; $quattro_align = false;
$site_color = Config::get("quattro","color"); $site_color = Config::get("quattro", "color", "dark");
$site_quattro_align = Config::get("quattro", "align" ); $site_quattro_align = Config::get("quattro", "align", false);
if ($uid) { if ($uid) {
$color = PConfig::get( $uid, "quattro","color"); $color = PConfig::get($uid, "quattro", "color", false);
$quattro_align = PConfig::get( $uid, 'quattro', 'align' ); $quattro_align = PConfig::get($uid, 'quattro', 'align', false);
} }
if ($color===false) $color=$site_color; if ($color === false) {
if ($color===false) $color="dark"; $color = $site_color;
if ($quattro_align===false) $quattro_align=$site_quattro_align; }
if ($quattro_align === false) {
$quattro_align = $site_quattro_align;
}
if (file_exists("$THEMEPATH/$color/style.css")){ if (file_exists("$THEMEPATH/$color/style.css")){
echo file_get_contents("$THEMEPATH/$color/style.css"); echo file_get_contents("$THEMEPATH/$color/style.css");
} }
if($quattro_align=="center"){ if ($quattro_align == "center"){
echo " echo "
html { width: 100%; margin:0px; padding:0px; } html { width: 100%; margin:0px; padding:0px; }
body { body {
@ -35,27 +38,28 @@
"; ";
} }
$textarea_font_size = false; $textarea_font_size = false;
$post_font_size = false; $post_font_size = false;
$site_textarea_font_size = Config::get("quattro","tfs");
$site_post_font_size = Config::get("quattro","pfs");
if ($site_textarea_font_size===false) $site_textarea_font_size="20";
if ($site_post_font_size===false) $site_post_font_size="12";
if ($uid) {
$textarea_font_size = PConfig::get( $uid, "quattro","tfs");
$post_font_size = PConfig::get( $uid, "quattro","pfs");
}
if ($textarea_font_size===false) $textarea_font_size = $site_textarea_font_size;
if ($post_font_size===false) $post_font_size = $site_post_font_size;
echo " $site_textarea_font_size = Config::get("quattro", "tfs", "20");
textarea { font-size: ${textarea_font_size}px; } $site_post_font_size = Config::get("quattro", "pfs", "12");
.wall-item-comment-wrapper .comment-edit-text-full { font-size: ${textarea_font_size}px; }
#jot .profile-jot-text:focus { font-size: ${textarea_font_size}px; } if ($uid) {
.wall-item-container .wall-item-content { font-size: ${post_font_size}px; } $textarea_font_size = PConfig::get($uid, "quattro", "tfs", false);
"; $post_font_size = PConfig::get($uid, "quattro", "pfs", false);
}
if ($textarea_font_size === false) {
$textarea_font_size = $site_textarea_font_size;
}
if ($post_font_size === false) {
$post_font_size = $site_post_font_size;
}
echo "
textarea { font-size: ${textarea_font_size}px; }
.wall-item-comment-wrapper .comment-edit-text-full { font-size: ${textarea_font_size}px; }
#jot .profile-jot-text:focus { font-size: ${textarea_font_size}px; }
.wall-item-container .wall-item-content { font-size: ${post_font_size}px; }
";