本文整理汇总了PHP中ElggGroup::isPublicMembership方法的典型用法代码示例。如果您正苦于以下问题:PHP ElggGroup::isPublicMembership方法的具体用法?PHP ElggGroup::isPublicMembership怎么用?PHP ElggGroup::isPublicMembership使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ElggGroup
的用法示例。
在下文中一共展示了ElggGroup::isPublicMembership方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: groups_register_profile_buttons
/**
* Registers the buttons for title area of the group profile page
*
* @param ElggGroup $group
*/
function groups_register_profile_buttons($group)
{
$actions = array();
// group owners
if ($group->canEdit()) {
// edit and invite
$url = elgg_get_site_url() . "groups/edit/{$group->getGUID()}";
$actions[$url] = 'groups:edit';
$url = elgg_get_site_url() . "groups/invite/{$group->getGUID()}";
$actions[$url] = 'groups:invite';
}
// group members
if ($group->isMember(elgg_get_logged_in_user_entity())) {
if ($group->getOwnerGUID() != elgg_get_logged_in_user_guid()) {
// leave
$url = elgg_get_site_url() . "action/groups/leave?group_guid={$group->getGUID()}";
$url = elgg_add_action_tokens_to_url($url);
$actions[$url] = 'groups:leave';
}
} elseif (elgg_is_logged_in()) {
// join - admins can always join.
$url = elgg_get_site_url() . "action/groups/join?group_guid={$group->getGUID()}";
$url = elgg_add_action_tokens_to_url($url);
if ($group->isPublicMembership() || $group->canEdit()) {
$actions[$url] = 'groups:join';
} else {
// request membership
$actions[$url] = 'groups:joinrequest';
}
}
if ($actions) {
foreach ($actions as $url => $text) {
elgg_register_menu_item('title', array('name' => $text, 'href' => $url, 'text' => elgg_echo($text), 'link_class' => 'elgg-button elgg-button-action'));
}
}
}
示例2: groups_register_profile_buttons
/**
* Registers the buttons for title area of the group profile page
*
* @param ElggGroup $group
*/
function groups_register_profile_buttons($group)
{
$user = elgg_get_logged_in_user_entity();
$actions = array();
// group owners
if ($group->canEdit()) {
// local groups except town groups cannot be edited (except by admins)
if ($group->grouptype != 'local' || $group->grouptype == 'local' && $group->localtype == 'town' || $user->isAdmin()) {
$url = elgg_get_site_url() . "groups/edit/{$group->getGUID()}";
$actions[$url] = 'groups:edit';
}
// local groups except town groups cannot use invitation system
if ($group->grouptype != 'local' || $group->grouptype == 'local' && $group->localtype == 'town') {
$url = elgg_get_site_url() . "groups/invite/{$group->getGUID()}";
$actions[$url] = 'groups:invite';
}
}
// add a button to allow adding town groups (only for group members)
if ($group->grouptype == 'local' && $group->localtype == 'departemental' && $group->isMember(elgg_get_logged_in_user_entity())) {
$url = elgg_get_site_url() . "groups/local/add/{$group->getGUID()}";
$actions[$url] = 'localgroups:addtown';
}
// group members (not for local groups except town group)
if ($group->grouptype == 'local' && $group->localtype == 'town' || $group->grouptype != 'local') {
if ($group->isMember(elgg_get_logged_in_user_entity())) {
if ($group->getOwnerGUID() != elgg_get_logged_in_user_guid()) {
// leave
$url = elgg_get_site_url() . "action/groups/leave?group_guid={$group->getGUID()}";
$url = elgg_add_action_tokens_to_url($url);
$actions[$url] = 'groups:leave';
}
} elseif (elgg_is_logged_in()) {
// join - admins can always join.
$url = elgg_get_site_url() . "action/groups/join?group_guid={$group->getGUID()}";
$url = elgg_add_action_tokens_to_url($url);
if ($group->isPublicMembership() || $group->canEdit()) {
$actions[$url] = 'groups:join';
} else {
// request membership
$actions[$url] = 'groups:joinrequest';
}
}
}
if ($actions) {
foreach ($actions as $url => $text) {
elgg_register_menu_item('title', array('name' => $text, 'href' => $url, 'text' => elgg_echo($text), 'link_class' => 'elgg-button elgg-button-action'));
}
}
}
示例3: group_tools_join_motivation_required
/**
* Check the plugin/group setting if join motivation is needed
*
* @param ElggGroup $group (optional) the group to check for
*
* @return bool
*/
function group_tools_join_motivation_required(ElggGroup $group = null)
{
static $plugin_settings;
static $check_group = false;
// load plugin settings
if (!isset($plugin_settings)) {
$plugin_settings = false;
$setting = elgg_get_plugin_setting('join_motivation', 'group_tools', 'no');
switch ($setting) {
case 'yes_off':
$check_group = true;
break;
case 'yes_on':
$check_group = true;
$plugin_settings = true;
break;
case 'required':
$plugin_settings = true;
break;
}
}
// do we need to check the group settings?
if (!$group instanceof ElggGroup || !$check_group) {
return $plugin_settings || $check_group;
}
if ($group->isPublicMembership()) {
// open group, no motivation needed
return false;
}
// get group setting
$group_setting = $group->getPrivateSetting('join_motivation');
switch ($group_setting) {
case 'no':
return false;
break;
case 'yes':
return true;
break;
}
return $plugin_settings;
}