CC-2646: Set a calendar view default (Day/week/month) that's remembered
1. If the preference is not user-specific, or if id is null, set subjid to null 2. Rewrote the code for the setValue logic, added comments. Should be easier to read and understand
This commit is contained in:
parent
6237a199af
commit
4db6636b06
1 changed files with 24 additions and 22 deletions
|
@ -29,30 +29,32 @@ class Application_Model_Preference
|
||||||
|
|
||||||
$result = $CC_DBC->GetOne($sql);
|
$result = $CC_DBC->GetOne($sql);
|
||||||
|
|
||||||
if ($result == 1 && is_null($id)){
|
if($result == 1) {
|
||||||
|
// result found
|
||||||
|
if(is_null($id) || !$isUserValue) {
|
||||||
|
// system pref
|
||||||
$sql = "UPDATE cc_pref"
|
$sql = "UPDATE cc_pref"
|
||||||
." SET subjid = NULL, valstr = '$value'"
|
." SET subjid = NULL, valstr = '$value'"
|
||||||
." WHERE keystr = '$key'";
|
." WHERE keystr = '$key'";
|
||||||
}
|
} else {
|
||||||
else if ($result == 1 && !is_null($id)){
|
// user pref
|
||||||
if($isUserValue) {
|
|
||||||
$sql = "UPDATE cc_pref"
|
$sql = "UPDATE cc_pref"
|
||||||
. " SET valstr = '$value'"
|
. " SET valstr = '$value'"
|
||||||
. " WHERE keystr = '$key' AND subjid = $id";
|
. " WHERE keystr = '$key' AND subjid = $id";
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$sql = "UPDATE cc_pref"
|
// result not found
|
||||||
." SET subjid = $id, valstr = '$value'"
|
if(is_null($id) || !$isUserValue) {
|
||||||
." WHERE keystr = '$key'";
|
// system pref
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(is_null($id)) {
|
|
||||||
$sql = "INSERT INTO cc_pref (keystr, valstr)"
|
$sql = "INSERT INTO cc_pref (keystr, valstr)"
|
||||||
." VALUES ('$key', '$value')";
|
." VALUES ('$key', '$value')";
|
||||||
}
|
} else {
|
||||||
else {
|
// user pref
|
||||||
$sql = "INSERT INTO cc_pref (subjid, keystr, valstr)"
|
$sql = "INSERT INTO cc_pref (subjid, keystr, valstr)"
|
||||||
." VALUES ($id, '$key', '$value')";
|
." VALUES ($id, '$key', '$value')";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $CC_DBC->query($sql);
|
return $CC_DBC->query($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue