当前位置: 首页>>代码示例>>PHP>>正文


PHP ElggGroup::getType方法代码示例

本文整理汇总了PHP中ElggGroup::getType方法的典型用法代码示例。如果您正苦于以下问题:PHP ElggGroup::getType方法的具体用法?PHP ElggGroup::getType怎么用?PHP ElggGroup::getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ElggGroup的用法示例。


在下文中一共展示了ElggGroup::getType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getAccessToken

 /**
  * Get an access token for signing API requests
  */
 public function getAccessToken()
 {
     if (!elgg_instanceof($this->entity)) {
         return false;
     }
     switch ($this->entity->getType()) {
         case 'site':
             return StripeClientFactory::getSecretKey();
             break;
         default:
             return $this->entity->getPrivateSetting('stripe_access_token');
             break;
     }
 }
开发者ID:Daltonmedia,项目名称:stripe,代码行数:17,代码来源:StripeMerchant.php

示例2: group_subtypes_get_identifier

/**
 * Returns page identifier for a group entity
 *
 * @param ElggGroup $entity Group entity
 * @return string
 */
function group_subtypes_get_identifier(ElggGroup $entity)
{
    $type = $entity->getType();
    $subtype = $entity->getSubtype();
    return elgg_trigger_plugin_hook('page_identifier', "{$type}:{$subtype}", ['entity' => $entity], 'groups');
}
开发者ID:hypeJunction,项目名称:Elgg-group_subtypes,代码行数:12,代码来源:start.php

示例3: group_tools_transfer_group_ownership

/**
 * Helper function to transfer the ownership of a group to a new user
 *
 * @param ElggGroup $group     the group to transfer
 * @param ElggUser  $new_owner the new owner
 *
 * @return bool
 */
function group_tools_transfer_group_ownership(ElggGroup $group, ElggUser $new_owner)
{
    if (!$group instanceof ElggGroup || !$group->canEdit()) {
        return false;
    }
    if (!$new_owner instanceof ElggUser) {
        return false;
    }
    $loggedin_user = elgg_get_logged_in_user_entity();
    // register plugin hook to make sure transfer can complete
    elgg_register_plugin_hook_handler('permissions_check', 'group', '\\ColdTrick\\GroupTools\\Access::allowGroupOwnerTransfer');
    $old_owner = $group->getOwnerEntity();
    // transfer ownership
    $group->owner_guid = $new_owner->getGUID();
    $group->container_guid = $new_owner->getGUID();
    if (!$group->save()) {
        return false;
    }
    // make sure user is added to the group
    $group->join($new_owner);
    // remove existing group administrator role for new owner
    remove_entity_relationship($new_owner->getGUID(), 'group_admin', $group->getGUID());
    // check for group icon
    if (!empty($group->icontime)) {
        $prefix = "groups/{$group->getGUID()}";
        $sizes = elgg_get_icon_sizes($group->getType());
        $ofh = new ElggFile();
        $ofh->owner_guid = $old_owner->getGUID();
        $nfh = new ElggFile();
        $nfh->owner_guid = $group->getOwnerGUID();
        foreach ($sizes as $size => $info) {
            // set correct file to handle
            $ofh->setFilename("{$prefix}{$size}.jpg");
            if (!$ofh->exists()) {
                // file doesn't exist
                continue;
            }
            $nfh->setFilename("{$prefix}{$size}.jpg");
            // open files
            $ofh->open('read');
            $nfh->open('write');
            // copy file
            $nfh->write($ofh->grabFile());
            // close file
            $ofh->close();
            $nfh->close();
            // cleanup old file
            $ofh->delete();
        }
        $group->icontime = time();
    }
    // move metadata of the group to the new owner
    $options = ['guid' => $group->getGUID(), 'limit' => false];
    $metadata = elgg_get_metadata($options);
    if (!empty($metadata)) {
        foreach ($metadata as $md) {
            if ($md->owner_guid == $old_owner->getGUID()) {
                $md->owner_guid = $new_owner->getGUID();
                $md->save();
            }
        }
    }
    // notify new owner
    if ($new_owner->getGUID() !== $loggedin_user->getGUID()) {
        $subject = elgg_echo('group_tools:notify:transfer:subject', [$group->name]);
        $message = elgg_echo('group_tools:notify:transfer:message', [$new_owner->name, $loggedin_user->name, $group->name, $group->getURL()]);
        notify_user($new_owner->getGUID(), $group->getGUID(), $subject, $message);
    }
    // unregister plugin hook to make sure transfer can complete
    elgg_unregister_plugin_hook_handler('permissions_check', 'group', '\\ColdTrick\\GroupTools\\Access::allowGroupOwnerTransfer');
    return true;
}
开发者ID:coldtrick,项目名称:group_tools,代码行数:80,代码来源:functions.php


注:本文中的ElggGroup::getType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。