diff --git a/addons/userrights/userrightsmatrix.class.inc.php b/addons/userrights/userrightsmatrix.class.inc.php index 710f741b8..a5d18f2c7 100644 --- a/addons/userrights/userrightsmatrix.class.inc.php +++ b/addons/userrights/userrightsmatrix.class.inc.php @@ -270,6 +270,29 @@ class UserRightsMatrix extends UserRightsAddOnAPI } } } + // Create the "My Bookmarks" menu item (parent_id = 0, rank = 6) + if ($bNewUser) + { + $bAddMenu = true; + } + else + { + $oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT menuNode WHERE type = 'user' AND parent_id = 0 AND user_id = $iUserId")); + $bAddMenu = ($oSet->Count() < 1); + } + if ($bAddMenu) + { + $oMenu = MetaModel::NewObject('menuNode'); + $oMenu->Set('type', 'user'); + $oMenu->Set('parent_id', 0); // It's a toplevel entry + $oMenu->Set('rank', 6); // Located just above the Admin Tools section (=7) + $oMenu->Set('name', 'My Bookmarks'); + $oMenu->Set('label', 'My Favorite Items'); + $oMenu->Set('hyperlink', 'UI.php'); + $oMenu->Set('template', '
My bookmarks
This section contains my most favorite search results
'); + $oMenu->Set('user_id', $iUserId); + $oMenu->DBInsert(); + } } diff --git a/application/menunode.class.inc.php b/application/menunode.class.inc.php index f571f40f3..e0b72ec62 100644 --- a/application/menunode.class.inc.php +++ b/application/menunode.class.inc.php @@ -89,14 +89,17 @@ class menuNode extends DBObject return $this->Get('hyperlink')."?".implode("&", $aParams); } - public function GetChildNodesSet($sType) + public function GetChildNodesSet($sType = null) { $oSearchFilter = new DBObjectSearch("menuNode"); $oSearchFilter->AddCondition('parent_id', $this->GetKey(), '='); - $oSearchFilter->AddCondition('type', $sType, '='); - if ($sType == 'user') + if ($sType != null) { - $oSearchFilter->AddCondition('user_id', UserRights::GetUserId(), '='); + $oSearchFilter->AddCondition('type', $sType, '='); + if ($sType == 'user') + { + $oSearchFilter->AddCondition('user_id', UserRights::GetUserId(), '='); + } } $oSet = new CMDBObjectSet($oSearchFilter, array('rank' => true)); return $oSet; @@ -184,10 +187,13 @@ class menuNode extends DBObject { $oSearchFilter = new DbObjectSearch("menuNode"); $oSearchFilter->AddCondition('parent_id', 0, '='); - $oSearchFilter->AddCondition('type', $sType, '='); - if ($sType == 'user') + if ($sType != null) { - $oSearchFilter->AddCondition('user_id', UserRights::GetUserId(), '='); + $oSearchFilter->AddCondition('type', $sType, '='); + if ($sType == 'user') + { + $oSearchFilter->AddCondition('user_id', UserRights::GetUserId(), '='); + } } $oRootSet = new CMDBObjectSet($oSearchFilter, array('rank' => true)); while($oNode = $oRootSet->Fetch()) @@ -207,10 +213,13 @@ class menuNode extends DBObject $oSearchFilter = new DBObjectSearch("menuNode"); $oSearchFilter->AddCondition('parent_id', $this->Get('parent_id')); $oSearchFilter->AddCondition('rank', $this->Get('rank'), '>'); - $oSearchFilter->AddCondition('type', $sType, '='); - if ($sType == 'user') + if ($sType != null) { - $oSearchFilter->AddCondition('user_id', UserRights::GetUserId(), '='); + $oSearchFilter->AddCondition('type', $sType, '='); + if ($sType == 'user') + { + $oSearchFilter->AddCondition('user_id', UserRights::GetUserId(), '='); + } } $oSet = new DBObjectSet($oSearchFilter, array('rank'=> true)); // Order by rank (true means ascending) return $oSet; diff --git a/pages/UniversalSearch.php b/pages/UniversalSearch.php index ebe762fb3..e649f8d2b 100644 --- a/pages/UniversalSearch.php +++ b/pages/UniversalSearch.php @@ -58,14 +58,14 @@ if ($oFilter != null) $oResultBlock->RenderContent($oP); // Menu node - $sFilter = $oFilter->ToSibusQL(); + $sFilter = $oFilter->ToOQL(); $sMenuNodeContent = <<No session information
\n"; } $oPage = new ajax_page("");