@@ -18,7 +18,7 @@ class UserHover {
1818 */
1919 public static function registerToggleExpert (\Elgg \Event $ event ): ?MenuItems {
2020 // are experts enabled
21- if (!questions_experts_enabled ()) {
21+ if (!questions_experts_enabled () || ! elgg_is_admin_logged_in () ) {
2222 return null ;
2323 }
2424
@@ -28,32 +28,22 @@ public static function registerToggleExpert(\Elgg\Event $event): ?MenuItems {
2828 return null ;
2929 }
3030
31- // get page owner
32- $ page_owner = elgg_get_page_owner_entity ();
33- if (!$ page_owner instanceof \ElggGroup) {
34- $ page_owner = elgg_get_site_entity ();
35- }
36-
37- // can the current person edit the page owner, to assign the role
38- // and is the current user not the owner of this page owner
39- if (!$ page_owner ->canEdit ()) {
40- return null ;
41- }
31+ $ site = elgg_get_site_entity ();
4232
4333 /* @var $items MenuItems */
4434 $ items = $ event ->getValue ();
4535
46- $ is_expert = $ user ->hasRelationship ($ page_owner ->guid , QUESTIONS_EXPERT_ROLE );
36+ $ is_expert = $ user ->hasRelationship ($ site ->guid , QUESTIONS_EXPERT_ROLE );
4737
4838 $ items [] = \ElggMenuItem::factory ([
4939 'name ' => 'questions_expert ' ,
5040 'icon ' => 'level-up-alt ' ,
5141 'text ' => elgg_echo ('questions:menu:user_hover:make_expert ' ),
5242 'href ' => elgg_generate_action_url ('questions/toggle_expert ' , [
5343 'user_guid ' => $ user ->guid ,
54- 'guid ' => $ page_owner ->guid ,
44+ 'guid ' => $ site ->guid ,
5545 ]),
56- 'section ' => ( $ page_owner instanceof \ElggSite) ? 'admin ' : ' action ' ,
46+ 'section ' => 'admin ' ,
5747 'data-toggle ' => 'questions-expert-undo ' ,
5848 'item_class ' => $ is_expert ? 'hidden ' : null ,
5949 ]);
@@ -64,9 +54,9 @@ public static function registerToggleExpert(\Elgg\Event $event): ?MenuItems {
6454 'text ' => elgg_echo ('questions:menu:user_hover:remove_expert ' ),
6555 'href ' => elgg_generate_action_url ('questions/toggle_expert ' , [
6656 'user_guid ' => $ user ->guid ,
67- 'guid ' => $ page_owner ->guid ,
57+ 'guid ' => $ site ->guid ,
6858 ]),
69- 'section ' => ( $ page_owner instanceof \ElggSite) ? 'admin ' : ' action ' ,
59+ 'section ' => 'admin ' ,
7060 'data-toggle ' => 'questions-expert ' ,
7161 'item_class ' => $ is_expert ? null : 'hidden ' ,
7262 ]);
0 commit comments