function run()
 {
     $bypass_roles = array();
     if (!empty($this->_form)) {
         $privs_table = reason_get_privs_table();
         foreach ($privs_table as $role => $privs) {
             if (in_array('bypass_locks', $privs)) {
                 $role_ent = new entity(id_of($role));
                 $bypass_roles[] = $role_ent->get_value('name');
             }
         }
         if (count($bypass_roles) > 1) {
             end($bypass_roles);
             $i = key($bypass_roles);
             $bypass_roles[$i] = 'or ' . $bypass_roles[$i];
         }
         if (count($bypass_roles) > 2) {
             $roles_str = implode(', ', $bypass_roles);
         } else {
             $roles_str = implode(' ', $bypass_roles);
         }
         echo '<p>If you place a lock on a field or a relationship, it prevents site maintainers from changing that aspect of the item.</p><p>Note that users with the ' . $roles_str . ' role can bypass these locks.</p>' . "\n";
         echo '<p class="greyedOutNote">Greyed-out options are lockable, but are either currently hidden from normal users or are not available on this site.</p>' . "\n";
         $this->_form->run();
     } else {
         if (!defined('REASON_ENTITY_LOCKS_ENABLED') || !REASON_ENTITY_LOCKS_ENABLED) {
             echo 'Locking is not enabled in this instance of Reason. If you are an administrator you can turn locking on by adding or changing the setting REASON_ENTITY_LOCKS_ENABLED.';
         } else {
             echo 'You don\'t have the privilege to edit locks on this item.';
         }
     }
 }
示例#2
0
/**
 * Determine if a given role has a given privilege
 *
 * @param string $role_name The unique name of the role entity
 * @param string $privilege The priv identifier string
 * @return boolean
 */
function reason_role_has_privs($role_name, $privilege)
{
    $privs = reason_get_privs_table();
    if (isset($privs[$role_name]) && in_array($privilege, $privs[$role_name])) {
        return true;
    }
    return false;
}