本文整理匯總了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();
}