mirror of
https://github.com/e107inc/e107.git
synced 2025-07-31 03:40:37 +02:00
Flexpanel and infopanel behavior now depends on "Apply dashboard preferences to all administrators" setting.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* Flexpanel dashboard style.
|
||||
*/
|
||||
|
||||
if(!defined('e107_INIT'))
|
||||
@@ -10,13 +10,38 @@ if(!defined('e107_INIT'))
|
||||
exit;
|
||||
}
|
||||
|
||||
// Get "Apply dashboard preferences to all administrators" setting.
|
||||
$adminPref = e107::getConfig()->get('adminpref', 0);
|
||||
$flepanelEnabled = true;
|
||||
|
||||
// If not Main Admin and "Apply dashboard preferences to all administrators" is checked.
|
||||
if(!getperms('1') && $adminPref == 1)
|
||||
{
|
||||
$flepanelEnabled = false;
|
||||
}
|
||||
|
||||
define('FLEXPANEL_ENABLED', $flepanelEnabled);
|
||||
|
||||
|
||||
// Save rearranged menus to user.
|
||||
if(e_AJAX_REQUEST)
|
||||
{
|
||||
if(varset($_POST['core-flexpanel-order'], false))
|
||||
if(FLEXPANEL_ENABLED && varset($_POST['core-flexpanel-order'], false))
|
||||
{
|
||||
global $user_pref;
|
||||
$user_pref['core-flexpanel-order'] = $_POST['core-flexpanel-order'];
|
||||
save_prefs('user');
|
||||
// If "Apply dashboard preferences to all administrators" is checked.
|
||||
if($adminPref == 1)
|
||||
{
|
||||
e107::getConfig()
|
||||
->setPosted('core-flexpanel-order', $_POST['core-flexpanel-order'])
|
||||
->save();
|
||||
}
|
||||
else
|
||||
{
|
||||
e107::getUser()
|
||||
->getConfig()
|
||||
->set('core-flexpanel-order', $_POST['core-flexpanel-order'])
|
||||
->save();
|
||||
}
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -42,30 +67,33 @@ class adminstyle_flexpanel extends adminstyle_infopanel
|
||||
|
||||
$this->iconlist = $this->getIconList();
|
||||
|
||||
e107::js('core', 'core/admin.flexpanel.js', 'jquery', 4);
|
||||
|
||||
if(varset($_GET['mode']) == 'customize')
|
||||
if(FLEXPANEL_ENABLED)
|
||||
{
|
||||
e107::css('inline', '.layout-container { display: table; margin-left: auto; margin-right: auto; }');
|
||||
e107::css('inline', '.layout-container label.radio { float: left; padding: 0; width: 120px; margin: 7px; cursor: pointer; text-align: center; }');
|
||||
e107::css('inline', '.layout-container label.radio img { margin-left: auto; margin-right: auto; display: block; }');
|
||||
e107::css('inline', '.layout-container label.radio input { width: 100%; margin-left: auto; margin-right: auto; display: block; }');
|
||||
e107::css('inline', '.layout-container label.radio p { width: 100%; text-align: center; display: block; margin: 20px 0 0 0; }');
|
||||
}
|
||||
e107::css('inline', '.draggable-panels .panel-heading { cursor: move; }');
|
||||
e107::js('core', 'core/admin.flexpanel.js', 'jquery', 4);
|
||||
|
||||
// Save posted Layout type.
|
||||
if(varset($_POST['e-flexpanel-layout']))
|
||||
{
|
||||
global $user_pref;
|
||||
|
||||
// If Layout has been changed, we clear previous arrangement in order to use defaults.
|
||||
if($user_pref['core-flexpanel-layout'] != $_POST['e-flexpanel-layout'])
|
||||
if(varset($_GET['mode']) == 'customize')
|
||||
{
|
||||
$user_pref['core-flexpanel-order'] = array();
|
||||
e107::css('inline', '.layout-container { display: table; margin-left: auto; margin-right: auto; }');
|
||||
e107::css('inline', '.layout-container label.radio { float: left; padding: 0; width: 120px; margin: 7px; cursor: pointer; text-align: center; }');
|
||||
e107::css('inline', '.layout-container label.radio img { margin-left: auto; margin-right: auto; display: block; }');
|
||||
e107::css('inline', '.layout-container label.radio input { width: 100%; margin-left: auto; margin-right: auto; display: block; }');
|
||||
e107::css('inline', '.layout-container label.radio p { width: 100%; text-align: center; display: block; margin: 20px 0 0 0; }');
|
||||
}
|
||||
|
||||
$user_pref['core-flexpanel-layout'] = $_POST['e-flexpanel-layout'];
|
||||
save_prefs('user');
|
||||
// Save posted Layout type.
|
||||
if(varset($_POST['e-flexpanel-layout']))
|
||||
{
|
||||
$user_pref = $this->getUserPref();
|
||||
|
||||
// If Layout has been changed, we clear previous arrangement in order to use defaults.
|
||||
if($user_pref['core-flexpanel-layout'] != $_POST['e-flexpanel-layout'])
|
||||
{
|
||||
$this->savePref('core-flexpanel-order', array());
|
||||
}
|
||||
|
||||
$this->savePref('core-flexpanel-layout', $_POST['e-flexpanel-layout']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,6 +109,8 @@ class adminstyle_flexpanel extends adminstyle_infopanel
|
||||
$pref = e107::getPref();
|
||||
$frm = e107::getForm();
|
||||
|
||||
$user_pref = $this->getUserPref();
|
||||
|
||||
if(varset($_GET['mode']) == 'customize')
|
||||
{
|
||||
echo $frm->open('infopanel', 'post', e_SELF);
|
||||
@@ -91,8 +121,6 @@ class adminstyle_flexpanel extends adminstyle_infopanel
|
||||
return;
|
||||
}
|
||||
|
||||
global $user_pref;
|
||||
|
||||
// Default menu areas.
|
||||
$panels = array(
|
||||
'menu-area-01' => array(), // Sidebar.
|
||||
@@ -129,7 +157,7 @@ class adminstyle_flexpanel extends adminstyle_infopanel
|
||||
|
||||
|
||||
// --------------------- Personalized Panel -----------------------
|
||||
if(getperms('0') && !vartrue($user_pref['core-infopanel-mye107'])) // Set default icons.
|
||||
if(empty(varset($user_pref['core-infopanel-mye107'], array()))) // Set default icons.
|
||||
{
|
||||
$defArray = array(
|
||||
0 => 'e-administrator',
|
||||
@@ -148,7 +176,7 @@ class adminstyle_flexpanel extends adminstyle_infopanel
|
||||
13 => 'e-users',
|
||||
14 => 'e-wmessage'
|
||||
);
|
||||
$user_pref['core-infopanel-mye107'] = vartrue($pref['core-infopanel-default'], $defArray);
|
||||
$user_pref['core-infopanel-mye107'] = $defArray;
|
||||
}
|
||||
$tp->parseTemplate("{SETSTYLE=flexpanel}");
|
||||
$mainPanel = "<div id='core-infopanel_mye107'>";
|
||||
@@ -253,7 +281,7 @@ class adminstyle_flexpanel extends adminstyle_infopanel
|
||||
*/
|
||||
function getMenuPosition($id)
|
||||
{
|
||||
global $user_pref;
|
||||
$user_pref = $this->getUserPref();
|
||||
|
||||
if(varset($user_pref['core-flexpanel-order'][$id]))
|
||||
{
|
||||
@@ -304,7 +332,7 @@ class adminstyle_flexpanel extends adminstyle_infopanel
|
||||
$default['weight'] = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 'two_col_stacked':
|
||||
if($id == 'core-infopanel_help')
|
||||
{
|
||||
@@ -512,7 +540,8 @@ class adminstyle_flexpanel extends adminstyle_infopanel
|
||||
$fr = e107::getForm();
|
||||
$fl = e107::getFile();
|
||||
|
||||
global $user_pref;
|
||||
$user_pref = $this->getUserPref();
|
||||
|
||||
$default = varset($user_pref['core-flexpanel-layout'], 'default');
|
||||
|
||||
$html = '<div class="layout-container">';
|
||||
|
@@ -31,45 +31,78 @@ class adminstyle_infopanel
|
||||
|
||||
function __construct()
|
||||
{
|
||||
// e107::js('core','zrssfeed/jquery.zrssfeed.min.js'); // http://www.zazar.net/developers/jquery/zrssfeed/
|
||||
|
||||
$code = "
|
||||
|
||||
|
||||
jQuery(function($){
|
||||
|
||||
$('#e-adminfeed').load('".e_ADMIN."admin.php?mode=core&type=feed');
|
||||
|
||||
$('#e-adminfeed-plugin').load('".e_ADMIN."admin.php?mode=addons&type=plugin');
|
||||
|
||||
$('#e-adminfeed-theme').load('".e_ADMIN."admin.php?mode=addons&type=theme');
|
||||
|
||||
});
|
||||
";
|
||||
|
||||
global $user_pref; // quick fix.
|
||||
$pref = e107::getPref();
|
||||
";
|
||||
|
||||
e107::js('inline',$code,'jquery');
|
||||
|
||||
|
||||
if (isset($_POST['submit-mye107']) || varset($_POST['submit-mymenus']))
|
||||
{
|
||||
|
||||
$user_pref['core-infopanel-mye107'] = $_POST['e-mye107'];
|
||||
$user_pref['core-infopanel-menus'] = $_POST['e-mymenus'];
|
||||
|
||||
save_prefs('user');
|
||||
$this->savePref('core-infopanel-mye107', $_POST['e-mye107']);
|
||||
$this->savePref('core-infopanel-menus', $_POST['e-mymenus']);
|
||||
}
|
||||
|
||||
|
||||
// $array_functions_assoc = e107::getNav()->adminLinks('assoc');
|
||||
|
||||
// $this->iconlist = array_merge($array_functions_assoc, e107::getNav()->pluginLinks(E_16_PLUGMANAGER, "array"));
|
||||
|
||||
$this->iconlist = e107::getNav()->adminLinks();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Save preferences.
|
||||
*
|
||||
* @param $key
|
||||
* @param $value
|
||||
*/
|
||||
public function savePref($key, $value)
|
||||
{
|
||||
// Get "Apply dashboard preferences to all administrators" setting.
|
||||
$adminPref = e107::getConfig()->get('adminpref', 0);
|
||||
|
||||
// If "Apply dashboard preferences to all administrators" is checked.
|
||||
// Save as $pref.
|
||||
if($adminPref == 1)
|
||||
{
|
||||
e107::getConfig()
|
||||
->setPosted($key, $value)
|
||||
->save();
|
||||
}
|
||||
// Save as $user_pref.
|
||||
else
|
||||
{
|
||||
e107::getUser()
|
||||
->getConfig()
|
||||
->set($key, $value)
|
||||
->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get preferences.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getUserPref()
|
||||
{
|
||||
// Get "Apply dashboard preferences to all administrators" setting.
|
||||
$adminPref = e107::getConfig()->get('adminpref', 0);
|
||||
|
||||
// If "Apply dashboard preferences to all administrators" is checked.
|
||||
// Get $pref.
|
||||
if($adminPref == 1)
|
||||
{
|
||||
$user_pref = e107::getPref();
|
||||
}
|
||||
// Get $user_pref.
|
||||
else
|
||||
{
|
||||
$user_pref = e107::getUser()->getPref();
|
||||
}
|
||||
|
||||
return $user_pref;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow to get Icon List.
|
||||
@@ -79,7 +112,6 @@ class adminstyle_infopanel
|
||||
return $this->iconlist;
|
||||
}
|
||||
|
||||
|
||||
function render()
|
||||
{
|
||||
$tp = e107::getParser();
|
||||
@@ -129,33 +161,32 @@ class adminstyle_infopanel
|
||||
';
|
||||
*/
|
||||
//TODO LANs throughout.
|
||||
|
||||
global $style, $user_pref;
|
||||
|
||||
$user_pref = $this->getUserPref();
|
||||
|
||||
// ---------------------- Start Panel --------------------------------
|
||||
|
||||
// $text = "<div >";
|
||||
if (getperms('0') && !vartrue($user_pref['core-infopanel-mye107'])) // Set default icons.
|
||||
if(empty(varset($user_pref['core-infopanel-mye107'], array()))) // Set default icons.
|
||||
{
|
||||
$defArray = array (
|
||||
0 => 'e-administrator',
|
||||
1 => 'e-cpage',
|
||||
2 => 'e-frontpage',
|
||||
3 => 'e-mailout',
|
||||
4 => 'e-image',
|
||||
5 => 'e-menus',
|
||||
6 => 'e-meta',
|
||||
7 => 'e-newspost',
|
||||
8 => 'e-plugin',
|
||||
9 => 'e-prefs',
|
||||
10 => 'e-links',
|
||||
11 => 'e-theme',
|
||||
12 => 'e-userclass2',
|
||||
13 => 'e-users',
|
||||
14 => 'e-wmessage'
|
||||
);
|
||||
$user_pref['core-infopanel-mye107'] = vartrue($pref['core-infopanel-default'],$defArray);
|
||||
|
||||
$defArray = array(
|
||||
0 => 'e-administrator',
|
||||
1 => 'e-cpage',
|
||||
2 => 'e-frontpage',
|
||||
3 => 'e-mailout',
|
||||
4 => 'e-image',
|
||||
5 => 'e-menus',
|
||||
6 => 'e-meta',
|
||||
7 => 'e-newspost',
|
||||
8 => 'e-plugin',
|
||||
9 => 'e-prefs',
|
||||
10 => 'e-links',
|
||||
11 => 'e-theme',
|
||||
12 => 'e-userclass2',
|
||||
13 => 'e-users',
|
||||
14 => 'e-wmessage'
|
||||
);
|
||||
$user_pref['core-infopanel-mye107'] = $defArray;
|
||||
}
|
||||
|
||||
|
||||
@@ -314,7 +345,7 @@ class adminstyle_infopanel
|
||||
}
|
||||
else
|
||||
{
|
||||
echo $frm->open('infopanel','post',e_SELF);
|
||||
echo $frm->open('infopanel','post', e_SELF);
|
||||
echo $this->render_infopanel_options(true);
|
||||
echo $frm->close();
|
||||
}
|
||||
@@ -616,11 +647,32 @@ class adminstyle_infopanel
|
||||
{
|
||||
|
||||
$frm = e107::getForm();
|
||||
global $user_pref;
|
||||
$user_pref = $this->getUserPref();
|
||||
|
||||
$text = "<div style='padding-left:20px'>";
|
||||
|
||||
|
||||
|
||||
|
||||
if(empty(varset($user_pref['core-infopanel-mye107'], array()))) // Set default icons.
|
||||
{
|
||||
$defArray = array(
|
||||
0 => 'e-administrator',
|
||||
1 => 'e-cpage',
|
||||
2 => 'e-frontpage',
|
||||
3 => 'e-mailout',
|
||||
4 => 'e-image',
|
||||
5 => 'e-menus',
|
||||
6 => 'e-meta',
|
||||
7 => 'e-newspost',
|
||||
8 => 'e-plugin',
|
||||
9 => 'e-prefs',
|
||||
10 => 'e-links',
|
||||
11 => 'e-theme',
|
||||
12 => 'e-userclass2',
|
||||
13 => 'e-users',
|
||||
14 => 'e-wmessage'
|
||||
);
|
||||
$user_pref['core-infopanel-mye107'] = $defArray;
|
||||
}
|
||||
|
||||
|
||||
foreach ($this->iconlist as $key=>$icon)
|
||||
@@ -634,7 +686,7 @@ class adminstyle_infopanel
|
||||
}
|
||||
}
|
||||
|
||||
if (is_array($pluglist))
|
||||
if (isset($pluglist) && is_array($pluglist))
|
||||
{
|
||||
foreach ($pluglist as $key=>$icon)
|
||||
{
|
||||
@@ -661,7 +713,7 @@ class adminstyle_infopanel
|
||||
}
|
||||
|
||||
$frm = e107::getForm();
|
||||
global $user_pref;
|
||||
$user_pref = $this->getUserPref();
|
||||
|
||||
|
||||
$text = "<div style='padding-left:20px'>";
|
||||
|
Reference in New Issue
Block a user