本文整理汇总了PHP中entity::user_can_edit_field方法的典型用法代码示例。如果您正苦于以下问题:PHP entity::user_can_edit_field方法的具体用法?PHP entity::user_can_edit_field怎么用?PHP entity::user_can_edit_field使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类entity
的用法示例。
在下文中一共展示了entity::user_can_edit_field方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
function init()
{
$this->admin_page->set_show('leftbar', false);
if (empty($this->admin_page->id)) {
$this->_not_expungable_reason = 'no_id_provided';
return false;
}
if (!reason_user_has_privs($this->admin_page->user_id, 'expunge')) {
$this->_not_expungable_reason = 'insufficient_privileges';
return false;
}
$item = new entity($this->admin_page->id);
$user = new entity($this->admin_page->user_id);
if (!$item->user_can_edit_field('state', $user)) {
$this->_not_expungable_reason = 'state_field_locked';
return false;
}
if ($item->get_value('state') != 'Deleted') {
$this->_not_expungable_reason = 'not_deleted_yet';
return false;
}
$this->expungable = $this->admin_page->is_deletable();
if ($this->expungable) {
$this->_set_up_form();
} else {
$this->_not_expungable_reason = 'dependencies';
return false;
}
}
示例2: entity
/**
* Determines whether or not the user can inline edit. Only admin users may
* perform inline editing for the page title.
*
* @return boolean;
*/
function user_can_inline_edit()
{
if (!isset($this->_user_can_inline_edit)) {
// Additionally, check to see if the user has editing privileges for the 'name' field
$page_entity = new entity($this->page_id);
if ($netid = reason_check_authentication()) {
if ($user_id = get_user_id($netid)) {
$user = new entity($user_id);
$field_check = $page_entity->user_can_edit_field('name', $user);
}
}
$this->_user_can_inline_edit = $netid && reason_check_access_to_site($this->site_id) && $field_check;
}
return $this->_user_can_inline_edit;
}
示例3: init
function init()
{
$this->admin_page->set_show('leftbar', false);
if (empty($this->admin_page->id)) {
$this->_not_undeletable_reason = 'no_id_provided';
return false;
}
if (!reason_user_has_privs($this->admin_page->user_id, 'publish')) {
$this->_not_undeletable_reason = 'insufficient_privileges';
return false;
}
$item = new entity($this->admin_page->id);
$user = new entity($this->admin_page->user_id);
if (!$item->user_can_edit_field('state', $user)) {
$this->_not_undeletable_reason = 'state_field_locked';
return false;
}
if ($item->get_value('state') != 'Deleted') {
$this->_not_undeletable_reason = 'not_deleted_yet';
return false;
}
reason_update_entity($this->admin_page->id, $this->admin_page->user_id, array('state' => 'Live'), false);
if ($this->admin_page->type_id == id_of('minisite_page')) {
// zap nav cache so it reappears.
reason_include_once('classes/object_cache.php');
$cache = new ReasonObjectCache($this->admin_page->site_id . '_navigation_cache');
$cache->clear();
}
$manager_site_id = $this->admin_page->site_id;
if ($item->get_value('type') == id_of('site')) {
$manager_site_id = $item->id();
}
//Updates the rewrites to prevent infinite redirection loop.
reason_include_once('classes/url_manager.php');
$urlm = new url_manager($manager_site_id);
$urlm->update_rewrites();
$link = unhtmlentities($this->admin_page->make_link(array('cur_module' => 'Lister', 'id' => '', 'state' => 'deleted')));
header('Location: ' . $link);
die;
}
示例4: run
function run()
{
$type = new entity($this->admin_page->type_id);
$entity = new entity($this->admin_page->id);
$user = new entity($this->admin_page->user_id);
$text = array('root_node' => 'This is a root ' . $type->get_value('name') . ', so you may not delete it. If you wish to delete this item, please contact the <a href="' . $this->admin_page->make_link(array("cur_module" => "about_reason")) . '">web team</a>.', 'default' => 'You cannot currently delete this item because following items, which
are associated with it, must be associated with a ' . $type->get_value('name') . '. If
you wish to delete this item, you must first select a different ' . $type->get_value('name') . ' for each of the following items.<br /><br />', id_of('minisite_page') => 'This page has children. In order to delete it, you must first either:
<ul>
<li>delete its children</li>
<li>Select a different parent page for its children</li>
</ul>If you wish to delete this item, please select a different parent for the pages listed below.<br /><br />', 'borrowed' => '<p>This item is currently borrowed by one or more sites. Deleting it might break their sites. If you still want to delete it, contact the sites\' maintainers to ask if they can stop borrowing the item.</p>', 'locks' => 'This ' . $type->get_value('name') . ' has had a lock applied to it that keeps it from being deleted. A reason administrator may have applied this lock in order to ensure that a site was not inadventently broken. Please contact a Reason administrator if you have any questions about the rationale for placing this lock on this ' . $type->get_value('name') . '.');
if (!empty($this->borrowed_by)) {
echo $text['borrowed'];
echo '<h4>Sites borrowing this item</h4>' . "\n";
echo '<ul>' . "\n";
foreach ($this->borrowed_by as $site) {
echo '<li><a href="' . $site->get_value('base_url') . '">' . $site->get_value('name') . '</a>' . "\n";
echo '<div>Primary maintainer: ' . $site->get_value('name_cache') . ', <a href="mailto:' . $site->get_value('email_cache') . '" title="send email">' . $site->get_value('email_cache') . '</a></div></li>' . "\n";
}
echo '</ul>' . "\n";
} elseif ($this->is_root_node()) {
echo $text['root_node'];
} elseif (!$entity->user_can_edit_field('state', $user)) {
echo $text['locks'];
} else {
if (!empty($text[$this->admin_page->type_id])) {
echo $text[$this->admin_page->type_id];
} else {
echo $text['default'];
}
foreach ($this->values as $v) {
$link = $this->admin_page->make_link(array('cur_module' => 'Preview', 'id' => $v['e_id'], 'type_id' => $v['relationship_a']));
echo '<a href="' . $link . '" target="' . $v['e_id'] . '">' . $v['e_name'] . '</a><span class="smallText"> (' . prettify_string($v['name']) . ')</span><br />';
}
}
}
示例5: entity
function is_deletable($id = 0)
{
$id = (int) $id;
if (empty($id)) {
$id = $this->id;
}
if (empty($id)) {
return false;
}
//get all one-to-many required relationships that the current item is a part of
$entity = new entity($id);
$user = new entity($this->user_id);
$subject_of_required_rels = array();
$dbq = $this->get_required_ar_dbq($id);
if (!empty($dbq)) {
$subject_of_required_rels = $dbq->run();
}
$sites = get_sites_that_are_borrowing_entity($id);
if ($subject_of_required_rels || !empty($sites) || !$entity->user_can_edit_field('state', $user)) {
return false;
} else {
return true;
}
}