Skip to content

Commit

Permalink
Fixes #4959 - Banner (e_menu) saving issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
CaMer0n committed Nov 20, 2023
1 parent dcd1745 commit d5d40b9
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 34 deletions.
58 changes: 43 additions & 15 deletions e107_handlers/menu_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,9 @@ public function setParms($plugin, $menu, $parms=array(), $location = 'all')


/**
* Saving of parms from e_menu.php configuration.
* @param int $id menu_id
* @param array $parms
* @param array $parms posted values.
* @return mixed
*/
public function updateParms($id, $parms)
Expand All @@ -275,35 +276,62 @@ public function updateParms($id, $parms)
$model->setFieldIdName("menu_id");
$model->setDataFields(array('menu_parms'=>'json'));


$model->load($id, true);

$d = $model->get('menu_parms');
$menu_path = $model->get('menu_path');
$menu_path = rtrim($menu_path, '/');

$model->setPostedData('menu_parms', e107::unserialize($d));
$menu_name = $model->get('menu_name');
$menu_name = substr($menu_name,0,-5);

foreach($parms as $key=>$value)
if(!$obj = e107::getAddon($menu_path,'e_menu'))
{
if(!is_array($value))
{
$model->setPostedData('menu_parms/'.$key, $value);
}
else
return false;
}

if(!$fields = e107::callMethod($obj,'config',$menu_name))
{
return false;
}

if($d = $model->get('menu_parms'))
{
$prev = e107::unserialize($d);
}
else
{
$prev = [];
}

foreach($fields as $fld => $var)
{
if(isset($parms[$fld]))
{
foreach($value as $lang => $val)
if(!empty($var['multilan']))
{
if(!empty($prev[$fld])) // load previous language values.
{
$model->setPostedData('menu_parms/'.$fld, $prev[$fld]);
}

foreach($parms[$fld] as $lang => $val) // add posted language values.
{
$model->setPostedData('menu_parms/'.$fld.'/'.$lang, $val);
}
}
else
{
$model->setPostedData('menu_parms/'.$key.'/'.$lang, $val);
$model->setPostedData('menu_parms/'.$fld, $parms[$fld]);
}

}

}

// file_put_contents(e_LOG."menuParmsAjax.log", print_r($parms,true));


return $model->save();

// return $model;

}


Expand Down
21 changes: 2 additions & 19 deletions e107_handlers/menumanager_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1071,28 +1071,11 @@ function menuSaveParameters()
$parms = $sql->escape(strip_tags($parms));
$check = $sql->update("menus", "menu_parms=\"".$parms."\" WHERE menu_id=".$id."");
}
else // e_menu.php
else // Save e_menu.php parameters.
{
unset($_POST['menu_id'], $_POST['mode'], $_POST['menuActivate'], $_POST['menuSetCustomPages'], $_POST['e-token']);

/* $tmp = $sql->retrieve("menus", "menu_parms", " menu_id=".$id);
$parms = !empty($tmp) ? e107::unserialize($tmp) : array();
foreach($_POST as $k=>$v)
{
$parms[$k] = $tp->filter($v);
}
$parms = e107::serialize($parms, 'json');*/

// if(e_DEBUG == true)
{
// return array('msg'=>print_r($parms,true),'error'=>true);
}

$parms = $_POST;

$check = e107::getMenu()->updateParms($id,$parms); //
$check = e107::getMenu()->updateParms($id,$parms);
}


Expand Down

0 comments on commit d5d40b9

Please sign in to comment.