Created
November 24, 2022 07:22
-
-
Save lianglee/e57513ae6c288a6b050a32da564a0522 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Open Source Social Network | |
* @link https://www.opensource-socialnetwork.org/ | |
* @package Restrict Group Creation | |
* @author Michael Zülsdorff <[email protected]> | |
* @copyright (C) Michael Zülsdorff | |
* @license GNU General Public License https://www.gnu.de/documents/gpl-2.0.en.html | |
*/ | |
function com_restrict_group_creation_init() { | |
ossn_register_callback('action', 'load', 'com_restrict_group_creation_disable_unauthorized_action'); | |
//Because group menus are registered in callback so unregistering in initilize callback of component | |
//didn't work , changes were made in OSSN #2072 | |
ossn_register_callback('menu', 'section:before:view', 'com_restrict_group_creation_sidemenus'); | |
} | |
function com_restrict_group_creation_sidemenus() { | |
if(ossn_isLoggedin()) { | |
if(!ossn_loggedin_user()->isAdmin()) { | |
ossn_unregister_menu_item('addgroup', 'groups', 'newsfeed'); | |
} | |
} | |
} | |
function com_restrict_group_creation_disable_unauthorized_action($callback, $type, $params) { | |
if(ossn_isLoggedin()) { | |
if(!ossn_loggedin_user()->isAdmin() && $params['action'] == 'group/add') { | |
redirect('home'); | |
} | |
} | |
} | |
ossn_register_callback('ossn', 'init', 'com_restrict_group_creation_init'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment