From ba313c558c2df4932dafcbdfbdaa0fef88469f37 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sun, 17 Jan 2021 20:31:25 -0800 Subject: [PATCH] Option to filter navigation links in admin area by 'owner' ie. the plugin who installed it. --- e107_admin/links.php | 41 ++++++++++++++++++++++++-- e107_handlers/plugin_class.php | 15 ++++++++-- e107_themes/bootstrap3/admin_style.css | 2 +- 3 files changed, 52 insertions(+), 6 deletions(-) diff --git a/e107_admin/links.php b/e107_admin/links.php index 727b50704..bb10ab004 100644 --- a/e107_admin/links.php +++ b/e107_admin/links.php @@ -84,7 +84,7 @@ class links_admin_ui extends e_admin_ui 'link_order' => array('title'=> LAN_ORDER, 'type' => 'number', 'width' => 'auto', 'nolist'=>false, 'inline' => true), 'link_open' => array('title'=> LCLAN_19, 'type' => 'dropdown', 'inline'=>true, 'width' => 'auto', 'batch'=>true, 'filter'=>true, 'thclass' => 'left first', 'writeParms'=>array('size'=>'xlarge')), 'link_function' => array('title'=> LCLAN_105, 'type' => 'method', 'data'=>'str', 'width' => 'auto', 'thclass' => 'left first'), - 'link_owner' => array('title'=> LCLAN_106, 'type' => 'hidden', 'data'=>'str'), + 'link_owner' => array('title'=> LCLAN_106, 'type' => 'hidden', 'filter'=>true, 'data'=>'str'), 'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'forced'=>TRUE, 'width' => '10%', 'thclass' => 'center last', 'class'=>'center','readParms'=>'sort=1') // quick workaround ); @@ -181,9 +181,16 @@ class links_admin_ui extends e_admin_ui $this->getTreeModel()->current_id = intval($searchFilter[1]); $this->current_parent = intval($searchFilter[1]); } + + $this->fields['link_owner']['type'] = 'method'; + parent::ListObserver(); } + + + + public function ListAjaxObserver() { $searchFilter = $this->_parseFilterRequest($this->getRequest()->getQuery('filter_options', '')); @@ -595,6 +602,8 @@ class links_admin_form_ui extends e_admin_form_ui private $linkFunctions; + private $link_owner = array(); + function init() { @@ -642,8 +651,21 @@ class links_admin_form_ui extends e_admin_form_ui $this->linkFunctions[$cat][$newkey] = str_replace('sc_','',$func); } + if($tmp = e107::getDb()->retrieve('links', 'link_owner', "GROUP BY link_owner ORDER BY link_owner", true)) + { + foreach($tmp as $arr) + { + if(empty($arr['link_owner'])) + { + continue; + } - // var_dump($methods ); + $plug = $arr['link_owner']; + // $def = 'LAN_PLUGIN_'.strtoupper($plug).'_NAME'; + + $this->link_owner[$plug] = $plug; + } + } } @@ -726,6 +748,21 @@ class links_admin_form_ui extends e_admin_form_ui } + function link_owner($curVal,$mode) + { + if($mode == 'read') + { + return $curVal; + } + + if($mode === 'filter') + { + return $this->link_owner; + + } + } + + function link_sefurl($curVal,$mode) { if($mode == 'read') diff --git a/e107_handlers/plugin_class.php b/e107_handlers/plugin_class.php index 518b37e9c..b1ac31424 100644 --- a/e107_handlers/plugin_class.php +++ b/e107_handlers/plugin_class.php @@ -2266,7 +2266,10 @@ class e107plugin if ($action == 'add') { $link_t = $sql->count('links'); - if (!$sql->count('links', '(*)', "WHERE link_url = '{$path}' OR link_name = '{$link_name}'")) + + $countQry = !empty($options['link_owner']) ? "link_owner = '".$options['link_owner']."' AND link_url = '".$path."'" : "link_url = '{$path}' OR link_name = '".$link_name."'"; + + if (!$sql->count('links', '(*)', "WHERE ".$countQry)) { $linkData = array( 'link_name' => $link_name, @@ -2286,6 +2289,7 @@ class e107plugin } else { + e107::getMessage()->addDebug("Skipped inserting of sitelink. Count Qry: ".$countQry); return null; } } @@ -3494,6 +3498,7 @@ class e107plugin */ function XmlSiteLinks($function, $plug_vars) { + $this->log("Running ".__FUNCTION__); $status = false; @@ -3505,6 +3510,8 @@ class e107plugin return null; } + + if($function == 'refresh') { $mes->addDebug("Checking Plugin Site-links"); @@ -3512,7 +3519,9 @@ class e107plugin } - $array = $plug_vars['siteLinks']; + $array = $plug_vars['siteLinks']; + + foreach ($array['link'] as $link) { @@ -4251,7 +4260,7 @@ class e107plugin $plug = e107plugin::getPluginRecord($dir); - $this->options = array('nolinks'=>true); + // $this->options = array('nolinks'=>true); if(!is_array($plug)) { diff --git a/e107_themes/bootstrap3/admin_style.css b/e107_themes/bootstrap3/admin_style.css index 50d93ba9b..abeefc14e 100644 --- a/e107_themes/bootstrap3/admin_style.css +++ b/e107_themes/bootstrap3/admin_style.css @@ -1632,7 +1632,7 @@ form#simplesef h4 { margin: 4px } .admin-icon-debug i { margin-right:5px; cursor:help} .admin-icon-debug > li.dropdown > a.dropdown-toggle { border-left: 0 !important } -.admin-icon-debug .dropdown-menu > .active > a { font-weight:500 } +.admin-icon-debug .dropdown-menu > .active > a { color: orange } .admin-icon-debug .dropdown-menu > .active > a:after { font-family: FontAwesome; content: '\f0d9'; position: absolute; padding-left: 5px; }