mirror of
https://github.com/e107inc/e107.git
synced 2025-07-31 11:50:30 +02:00
content: bugfix #3815 : renewed function for updating preferences
This commit is contained in:
@@ -12,8 +12,8 @@
|
|||||||
| GNU General Public License (http://gnu.org).
|
| GNU General Public License (http://gnu.org).
|
||||||
|
|
|
|
||||||
| $Source: /cvs_backup/e107_0.8/e107_plugins/content/handlers/content_class.php,v $
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/content/handlers/content_class.php,v $
|
||||||
| $Revision: 1.8 $
|
| $Revision: 1.9 $
|
||||||
| $Date: 2007-03-01 09:32:28 $
|
| $Date: 2007-03-01 09:35:17 $
|
||||||
| $Author: lisa_ $
|
| $Author: lisa_ $
|
||||||
+---------------------------------------------------------------+
|
+---------------------------------------------------------------+
|
||||||
*/
|
*/
|
||||||
@@ -446,8 +446,6 @@ class content{
|
|||||||
|
|
||||||
if(!is_object($sql)){ $sql = new db; }
|
if(!is_object($sql)){ $sql = new db; }
|
||||||
|
|
||||||
//echo "update content pref : ".$id."<br />";
|
|
||||||
|
|
||||||
//insert default preferences into core
|
//insert default preferences into core
|
||||||
if($id == "0"){
|
if($id == "0"){
|
||||||
$num_rows = $sql -> db_Select("core", "*", "e107_name='$plugintable' ");
|
$num_rows = $sql -> db_Select("core", "*", "e107_name='$plugintable' ");
|
||||||
@@ -457,52 +455,53 @@ class content{
|
|||||||
$row = $sql -> db_Fetch();
|
$row = $sql -> db_Fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//prepare custom tags: use the posted value
|
||||||
|
$cp = $_POST['content_custom_preset_key'];
|
||||||
|
|
||||||
//insert category preferences into plugintable
|
//insert category preferences into plugintable
|
||||||
}else{
|
}else{
|
||||||
$sql -> db_Select($plugintable, "content_pref", "content_id='".intval($id)."' ");
|
//first get the existing prefs and parent
|
||||||
|
$sql -> db_Select($plugintable, "content_pref, content_parent", "content_id='".intval($id)."' ");
|
||||||
$row = $sql -> db_Fetch();
|
$row = $sql -> db_Fetch();
|
||||||
$current = $eArrayStorage->ReadArray($row['content_pref']);
|
$current = $eArrayStorage->ReadArray($row['content_pref']);
|
||||||
foreach($current as $k => $v){
|
$currentparent = $row['content_parent'];
|
||||||
if(isset($qs[0]) && $qs[0] == 'option' ){
|
|
||||||
|
//if we are updating options
|
||||||
|
if(isset($qs[0]) && $qs[0] == 'option' ){
|
||||||
|
//only use the manager prefs from the existing set
|
||||||
|
foreach($current as $k => $v){
|
||||||
if( strpos($k, "content_manager_") === 0 || strpos($k, "content_restrict_") === 0 ){
|
if( strpos($k, "content_manager_") === 0 || strpos($k, "content_restrict_") === 0 ){
|
||||||
$content_pref[$k] = $tp->toDB($v);
|
$content_pref[$k] = $tp->toDB($v);
|
||||||
}
|
}
|
||||||
}elseif(isset($qs[0]) && ($qs[0] == 'manager' || $qs[0] == 'restrict')){
|
|
||||||
if( strpos($k, "content_") === 0 ){
|
|
||||||
$content_pref[$k] = $tp->toDB($v);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//prepare custom tags: use the posted values
|
||||||
|
$cp = $_POST['content_custom_preset_key'];
|
||||||
|
|
||||||
|
//if we are updating manager
|
||||||
|
}elseif(isset($qs[0]) && ($qs[0] == 'manager' || $qs[0] == 'restrict')){
|
||||||
|
//if this is a top level category we need to keep all existing options
|
||||||
|
if($currentparent=='0'){
|
||||||
|
$content_pref = $current;
|
||||||
|
}
|
||||||
|
|
||||||
|
//prepare custom tags: use the existing content_pref values
|
||||||
|
$cp = $content_pref['content_custom_preset_key'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
//parse custom tags and covert them in $_POST values ($cp is derived above)
|
||||||
//create array of custom preset tags
|
$string = array();
|
||||||
foreach($_POST['content_custom_preset_key'] as $ck => $cv){
|
foreach($cp as $ck => $cv){
|
||||||
if(!empty($cv)){
|
if(!empty($cv)){
|
||||||
$string[] = $cv;
|
$string[] = $cv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
if(is_array($string) && !empty($string[0])){
|
||||||
|
$_POST['content_custom_preset_key'] = $string;
|
||||||
//create array of custom preset tags
|
|
||||||
asort($_POST['content_custom_preset_key_order']);
|
|
||||||
$corder = array_keys($_POST['content_custom_preset_key_order']);
|
|
||||||
foreach($_POST['content_custom_preset_key'] as $ck => $cv){
|
|
||||||
if(!empty($cv)){
|
|
||||||
//next routine to keep 'order' of preset tags
|
|
||||||
if(isset($_POST['content_custom_preset_key_order'][$ck])){
|
|
||||||
$k = intval($corder[$ck]);
|
|
||||||
$string[$k] = $cv;
|
|
||||||
}else{
|
|
||||||
$string[] = $cv;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$_POST['content_custom_preset_key'] = $string;
|
//convert all $_POST to $content_pref for storage, and renew the existing stored prefs
|
||||||
|
|
||||||
//echo "<pre>"; print_r($_POST); echo "</pre>";
|
|
||||||
|
|
||||||
foreach($_POST as $k => $v){
|
foreach($_POST as $k => $v){
|
||||||
if(strpos($k, "content_") === 0){
|
if(strpos($k, "content_") === 0){
|
||||||
$content_pref[$k] = $tp->toDB($v);
|
$content_pref[$k] = $tp->toDB($v);
|
||||||
@@ -511,8 +510,11 @@ class content{
|
|||||||
|
|
||||||
//create new array of preferences
|
//create new array of preferences
|
||||||
$tmp = $eArrayStorage->WriteArray($content_pref);
|
$tmp = $eArrayStorage->WriteArray($content_pref);
|
||||||
|
|
||||||
|
//update core table
|
||||||
if($id == "0"){
|
if($id == "0"){
|
||||||
$sql -> db_Update("core", "e107_value = '{$tmp}' WHERE e107_name = '$plugintable' ");
|
$sql -> db_Update("core", "e107_value = '{$tmp}' WHERE e107_name = '$plugintable' ");
|
||||||
|
//update plugin table
|
||||||
}else{
|
}else{
|
||||||
$sql -> db_Update($plugintable, "content_pref='{$tmp}' WHERE content_id='".intval($id)."' ");
|
$sql -> db_Update($plugintable, "content_pref='{$tmp}' WHERE content_id='".intval($id)."' ");
|
||||||
}
|
}
|
||||||
@@ -520,6 +522,7 @@ class content{
|
|||||||
return $content_pref;
|
return $content_pref;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function CONTENTREGEXP($var){
|
function CONTENTREGEXP($var){
|
||||||
return "(^|,)(".str_replace(",", "|", $var).")(,|$)";
|
return "(^|,)(".str_replace(",", "|", $var).")(,|$)";
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user