本文整理汇总了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;
}
示例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();
}