fix notification msgs

This commit is contained in:
Mike Macgirvin 2010-08-15 22:43:42 -07:00
parent 35e29e10e6
commit 4bcf380296
2 changed files with 55 additions and 27 deletions

View file

@ -167,19 +167,17 @@ function system_unavailable() {
if(! function_exists('check_config')) { if(! function_exists('check_config')) {
function check_config(&$a) { function check_config(&$a) {
$r = q("SELECT * FROM `config` WHERE `cat` = 'system' AND `k` IN ('url','build')");
if(! count($r)) { $build = get_config('system','build');
q("INSERT INTO `config` (`cat`,`k`,`v`) VALUES ( 'system', 'url', '%s' )", if(! x($build))
dbesc($a->get_baseurl()) $build = set_config('system','build',BUILD_ID);
);
q("INSERT INTO `config` (`cat`,`k`,`v`) VALUES ( 'system', 'build', '%s' )", $url = get_config('system','url');
dbesc(BUILD_ID) if(! x($url))
); $url = set_config('system','url',$a->get_baseurl());
return;
} if($build != BUILD_ID) {
foreach($r as $rr) { $stored = intval($build);
if($rr['k'] == 'build') {
$stored = intval($rr['v']);
$current = intval(BUILD_ID); $current = intval(BUILD_ID);
if(($stored < $current) && file_exists('update.php')) { if(($stored < $current) && file_exists('update.php')) {
@ -193,10 +191,7 @@ function check_config(&$a) {
$func($a); $func($a);
} }
} }
q("UPDATE `config` SET `v` = '%s' WHERE `cat` = 'system' AND `k` = 'build' LIMIT 1", set_config('system','build', BUILD_ID);
dbesc(BUILD_ID)
);
}
} }
} }
return; return;
@ -546,3 +541,36 @@ function sanitise_acl(&$item) {
else else
unset($item); unset($item);
}} }}
if(! function_exists('get_config')) {
function get_config($family,$key) {
$ret = q("SELECT `v` FROM `config` WHERE `cat` = '%s' AND `k` = '%s' LIMIT 1",
dbesc($family),
dbesc($key)
);
if(count($ret))
return $ret[0]['v'];
return false;
}}
if(! function_exists('set_config')) {
function set_config($family,$key,$value) {
if(get_config($family,$key) === false) {
$ret = q("INSERT INTO `config` ( `cat`, `k`, `v` ) VALUES ( '%s', '%s', '%s' ) ",
dbesc($family),
dbesc($key),
dbesc($value)
);
if($ret)
return $value;
return $ret;
}
$ret = q("SUPDATE `config` SET `v` = '%s' WHERE `cat` = '%s' AND `k` = '%s' LIMIT 1",
dbesc($value),
dbesc($family),
dbesc($key)
);
if($ret)
return $value;
return $ret;
}}

View file

@ -27,7 +27,7 @@ function notifications_post(&$a) {
notice( t('Invalid request identifier.') . EOL); notice( t('Invalid request identifier.') . EOL);
return; return;
} }
if($_POST['submit'] == t('Discard'() { if($_POST['submit'] == t('Discard')) {
$r = q("DELETE FROM `intro` WHERE `id` = %d LIMIT 1", intval($intro_id)); $r = q("DELETE FROM `intro` WHERE `id` = %d LIMIT 1", intval($intro_id));
$r = q("DELETE `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = q("DELETE `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($request_id), intval($request_id),