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


PHP ElggObject::canAnnotate方法代码示例

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


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

示例1: hypefaker_add_page

function hypefaker_add_page($owner, $container, $parent = null)
{
    $locale = elgg_get_plugin_setting('locale', 'hypeFaker', 'en_US');
    $faker = Factory::create($locale);
    $access_array = get_write_access_array($owner->guid);
    $access_id = array_rand($access_array, 1);
    $write_access_array = get_write_access_array($owner->guid);
    unset($write_access_array[ACCESS_PUBLIC]);
    $write_access_id = array_rand($write_access_array, 1);
    $page = new ElggObject();
    $page->subtype = $parent ? 'page' : 'page_top';
    $page->owner_guid = $owner->guid;
    $page->container_guid = $container->guid;
    $page->title = $faker->sentence(6);
    $page->description = $faker->text(500);
    $page->tags = $faker->words(5);
    $page->access_id = $access_id;
    $page->write_access_id = $write_access_id;
    $page->__faker = true;
    if ($parent) {
        $page->parent_guid = $parent->guid;
    }
    if ($page->save()) {
        $page->annotate('page', $page->description, $page->access_id, $page->owner_guid);
        elgg_create_river_item(array('view' => 'river/object/page/create', 'action_type' => 'create', 'subject_guid' => $page->owner_guid, 'object_guid' => $page->getGUID()));
        // add some revisions
        $users = elgg_get_entities_from_metadata(array('types' => 'user', 'limit' => rand(1, 10), 'order_by' => 'RAND()', 'metadata_names' => '__faker'));
        foreach ($users as $user) {
            if ($page->canAnnotate($user->guid, 'page')) {
                $last_revision = $faker->text(500);
                $page->annotate('page', $last_annotation, $page->access_id, $user->guid);
            }
        }
        if (!empty($last_revision)) {
            $page->description = $last_revision;
            $page->save();
        }
        return $page;
    }
    return false;
}
开发者ID:hypejunction,项目名称:hypefaker,代码行数:41,代码来源:gen_pages.php

示例2: testCanAnnotateDoesntCallSpecificThenGenericHookForEmptyString

 public function testCanAnnotateDoesntCallSpecificThenGenericHookForEmptyString()
 {
     $object = new \ElggObject();
     $object->subtype = 'test_1389988642';
     $object->save();
     elgg_register_plugin_hook_handler('permissions_check:annotate:', 'object', 'Elgg\\Values::getFalse');
     $this->assertTrue($object->canAnnotate());
     elgg_unregister_plugin_hook_handler('permissions_check:annotate:', 'object', 'Elgg\\Values::getFalse');
     $object->delete();
 }
开发者ID:epsylon,项目名称:Hydra-dev,代码行数:10,代码来源:ElggEntityTest.php


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