user_access
modules/user/user.module, строка 361
- Версии
- 5
user_access($string, $account = NULL)
- 6
user_access($string, $account = NULL, $reset = FALSE)
Определяет, имеет ли пользователь необходимое право доступа.
Все проверки прав доступа, должны осуществляться при помощи этой функции. Таким образом гарантируется целостность системы доступа, а также то, что суперпользователь сможет выполнять любые действия.
Параметры
$string
Разрешение (например, 'administer nodes'
), которое следует проверить.
$account
(опционально) Пользователь, у которого нужно проверить резрешение. По-умолчанию, текущий пользователь.
Возвращаемое значение
TRUE
, если пользователь имеет необходимое разрешение.
Determine whether the user has a given privilege.
All permission checks in Drupal should go through this function. This way, we guarantee consistent behavior, and ensure that the superuser can perform all actions.
Parameters
$string The permission, such as "administer nodes", being checked for.
$account (optional) The account to check, if not given use currently logged in user.
Return value
boolean TRUE if the current user has the requested permission.
▾ 133 функции вызывают user_access()
- aggregator_block in modules/aggregator/aggregator.module
- Реализация hook_block().
- aggregator_menu in modules/aggregator/aggregator.module
- Реализация hook_menu().
- aggregator_page_list_validate in modules/aggregator/aggregator.module
- block_admin_configure in modules/block/block.module
- Коллбэк меню. Отображает форму настройки блока.
- block_menu in modules/block/block.module
- Реализация hook_menu().
- blogapi_blogger_edit_post in modules/blogapi/blogapi.module
- Коллбэк Blogging API. Модифицирует указанную ноду блога.
- blogapi_blogger_new_post in modules/blogapi/blogapi.module
- Коллбэк Blogging API. Вставляет новую запись блога как ноду.
- blogapi_menu in modules/blogapi/blogapi.module
- blogapi_mt_publish_post in modules/blogapi/blogapi.module
- Коллбэк Blogging API. Публикует данную ноду.
- blogapi_status_error_check in modules/blogapi/blogapi.module
- Check that the user has permission to save the node with the chosen status.
- blogapi_validate_user in modules/blogapi/blogapi.module
- Проверяет, имеет ли указанный пользователь право редактировать блог.
- blog_access in modules/blog/blog.module
- Реализация метода hook_access()
- blog_block in modules/blog/blog.module
- Реализация hook_block().
- blog_menu in modules/blog/blog.module
- Реализация hook_menu().
- blog_page_user in modules/blog/blog.module
- Показывает страницу Друпал с последними записями в блоге данного пользователя.
- blog_user in modules/blog/blog.module
- Реализация hook_user().
- book_access in modules/book/book.module
- Реализация метода hook_access()
- book_export_html in modules/book/book.module
- This function is called by book_export() to generate HTML for export.
- book_form in modules/book/book.module
- Реализация hook_form().
- book_link in modules/book/book.module
- Реализация hook_link().
- book_menu in modules/book/book.module
- Реализация hook_menu().
- book_submit in modules/book/book.module
- Implementation of hook_submit().
- book_toc in modules/book/book.module
- Returns an array of titles and nid entries of book pages in table of contents order.
- comment_access in modules/comment/comment.module
- This is *not* a hook_access() implementation. This function is called to determine whether the current user has access to a particular comment.
- comment_admin_settings in modules/comment/comment.module
- Menu callback; presents the comment settings page.
- comment_block in modules/comment/comment.module
- Реализация hook_block().
- comment_form in modules/comment/comment.module
- comment_form_alter in modules/comment/comment.module
- comment_link in modules/comment/comment.module
- Реализация hook_link().
- comment_links in modules/comment/comment.module
- comment_menu in modules/comment/comment.module
- Реализация hook_menu().
- comment_render in modules/comment/comment.module
- Отображает комментарии.
- comment_reply in modules/comment/comment.module
- This function is responsible for generating a comment reply form. There are several cases that have to be handled, including: replies to comments replies to nodes attempts to reply to nodes that can no longer accept comments respecting access...
- comment_save in modules/comment/comment.module
- Сохраняет новый или измененный комментарий.
- contact_menu in modules/contact/contact.module
- Реализация hook_menu().
- drupal_menu in modules/drupal/drupal.module
- Реализация hook_menu().
- example_element_menu in developer/examples/example_element.module
- Реализация hook_menu().
- fileupload_access in developer/examples/fileupload.module
- Implementation of hook_access.
- fileupload_file_download in developer/examples/fileupload.module
- Implementation of hook_file_download.
- fileupload_menu in developer/examples/fileupload.module
- Implementation of hook_menu.
- filter_access in modules/filter/filter.module
- Returns TRUE if the user is allowed to access this format.
- filter_formats in modules/filter/filter.module
- Retrieve a list of input formats.
- filter_menu in modules/filter/filter.module
- Реализация hook_menu().
- forum_access in modules/forum/forum.module
- Реализация метода hook_access()
- forum_block in modules/forum/forum.module
- Реализация hook_block().
- forum_menu in modules/forum/forum.module
- Реализация hook_menu().
- help_menu in modules/help/help.module
- Реализация hook_menu().
- hook_access in developer/hooks/node.php
- Определяет ограничения доступа.
- hook_file_download in developer/hooks/core.php
- Позволяет загружать файлы.
- hook_link in developer/hooks/core.php
- Определяет внутренние ссылки Drupal.
- hook_menu in developer/hooks/core.php
- Определяет пункты меню и обратный вызов страниц.
- hook_nodeapi in developer/hooks/core.php
- Выполняет действия над нодами.
- hook_node_grants in developer/hooks/core.php
- Inform the node access system what permissions the user has.
- locale_menu in modules/locale/locale.module
- Реализация hook_menu().
- menu_form_alter in modules/menu/menu.module
- Implementation of hook_form_alter(). Add menu item fields to the node form.
- menu_menu in modules/menu/menu.module
- Реализация hook_menu().
- menu_nodeapi in modules/menu/menu.module
- Implementation of hook_nodeapi().
- menu_primary_links in includes/menu.inc
- Returns an array containing the primary links. Can optionally descend from the root of the Primary links menu towards the current node for a specified number of levels and return that submenu. Used to generate a primary/secondary menu from different...
- node_access in modules/node/node.module
- Устанавливает может ли текущий пользователь выполнять заданные действия на определённом ноде.
- node_access_example_node_grants in developer/examples/node_access_example.module
- Реализация hook_node_grants().
- node_content_access in modules/node/node.module
- Реализация метода hook_access()
- node_example_access in developer/examples/node_example.module
- Реализация метода hook_access()
- node_form in modules/node/node.module
- Generate the node add/edit form array.
- node_form_alter in modules/node/node.module
- Implementation of hook_form_alter().
- node_menu in modules/node/node.module
- Реализация hook_menu().
- node_revisions in modules/node/node.module
- Menu callback for revisions related activities.
- node_revision_delete in modules/node/node.module
- Delete the revision with specified revision number. A 'delete revision' nodeapi event is invoked when a revision is deleted.
- node_revision_overview in modules/node/node.module
- Generate an overview table of older revisions of a node.
- node_revision_revert in modules/node/node.module
- Revert to the revision with the specified revision number. A node and nodeapi 'update' event is triggered (via the node_save() call) when a revision is reverted.
- node_submit in modules/node/node.module
- Подготавливает ноду к записи и делает возможным вносить изменния другими модулями.
- node_validate in modules/node/node.module
- Perform validation checks on the given node.
- page_example_menu in developer/examples/page_example.module
- Реализация hook_menu().
- path_admin_delete_confirm in modules/path/path.module
- Menu callback; confirms deleting an URL alias
- path_form_alter in modules/path/path.module
- Implementation of hook_form_alter().
- path_menu in modules/path/path.module
- Реализация hook_menu().
- path_nodeapi in modules/path/path.module
- Implementation of hook_nodeapi().
- poll_access in modules/poll/poll.module
- Реализация метода hook_access()
- poll_block in modules/poll/poll.module
- Реализация hook_block().
- poll_form in modules/poll/poll.module
- Реализация hook_form().
- poll_insert in modules/poll/poll.module
- poll_load in modules/poll/poll.module
- Implementation of hook_load().
- poll_menu in modules/poll/poll.module
- Реализация hook_menu().
- profile_block in modules/profile/profile.module
- Реализация hook_block().
- profile_browse in modules/profile/profile.module
- Menu callback; display a list of user information.
- profile_categories in modules/profile/profile.module
- profile_menu in modules/profile/profile.module
- Реализация hook_menu().
- profile_validate_profile in modules/profile/profile.module
- profile_view_field in modules/profile/profile.module
- profile_view_profile in modules/profile/profile.module
- search_block in modules/search/search.module
- Реализация hook_block().
- search_menu in modules/search/search.module
- Реализация hook_menu().
- statistics_block in modules/statistics/statistics.module
- Реализация hook_block().
- statistics_link in modules/statistics/statistics.module
- Реализация hook_link().
- statistics_menu in modules/statistics/statistics.module
- Реализация hook_menu().
- system_get_module_admin_tasks in modules/system/system.module
- system_menu in modules/system/system.module
- Реализация hook_menu().
- system_theme_select_form in modules/system/system.module
- Returns a fieldset containing the theme select form.
- taxonomy_menu in modules/taxonomy/taxonomy.module
- Реализация hook_menu().
- theme_aggregator_block_item in modules/aggregator/aggregator.module
- Format an individual feed item for display in the block.
- theme_aggregator_feed in modules/aggregator/aggregator.module
- Format a news feed.
- theme_forum_display in modules/forum/forum.module
- Format the forum body.
- theme_get_settings in includes/theme.inc
- Retrieve an associative array containing the settings for a theme.
- theme_poll_results in modules/poll/poll.module
- theme_username in includes/theme.inc
- Форматирует имя пользователя.
- theme_user_picture in modules/user/user.module
- throttle_menu in modules/throttle/throttle.module
- tracker_menu in modules/tracker/tracker.module
- Реализация hook_menu().
- tracker_track_user in modules/tracker/tracker.module
- Menu callback. Prints a listing of active nodes on the site.
- upload_file_download in modules/upload/upload.module
- upload_form_alter in modules/upload/upload.module
- upload_link in modules/upload/upload.module
- Реализация hook_link().
- upload_menu in modules/upload/upload.module
- Реализация hook_menu().
- upload_nodeapi in modules/upload/upload.module
- Implementation of hook_nodeapi().
- user_block in modules/user/user.module
- Реализация hook_block().
- user_build_filter_query in modules/user/user.module
- Build query for user administration filters based on session.
- user_edit in modules/user/user.module
- user_edit_form in modules/user/user.module
- user_edit_validate in modules/user/user.module
- user_menu in modules/user/user.module
- Реализация hook_menu().
- user_register in modules/user/user.module
- user_register_submit in modules/user/user.module
- user_save in modules/user/user.module
- Save changes to a user account or add a new user.
- user_search in modules/user/user.module
- Реализация hook_search().
- user_user_operations in modules/user/user.module
- Implementation of hook_user_operations().
- user_view in modules/user/user.module
- _aggregator_page_list in modules/aggregator/aggregator.module
- Prints an aggregator page listing a number of feed items. Various menu callbacks use this function to print their feeds.
- _menu_site_is_offline in includes/menu.inc
- Возвращает TRUE, если сайт находится в автономном режиме "на обслуживании".
- _node_access_join_sql in modules/node/node.module
- Generate an SQL join clause for use in fetching a node listing.
- _node_access_where_sql in modules/node/node.module
- Generate an SQL where clause for use in fetching a node listing.
- _profile_get_fields in modules/profile/profile.module
- _upload_form in modules/upload/upload.module
- _upload_prepare in modules/upload/upload.module
- Save new uploads and attach them to the node object. append file_previews to the node object as well.
- _user_edit_validate in modules/user/user.module
Код
<?php
function user_access($string, $account = NULL) {
global $user;
static $perm = array();
if (is_null($account)) {
$account = $user;
}
// User #1 has all privileges:
if ($account->uid == 1) {
return TRUE;
}
// To reduce the number of SQL queries, we cache the user's permissions
// in a static variable.
if (!isset($perm[$account->uid])) {
$rids = array_keys($account->roles);
$placeholders = implode(',', array_fill(0, count($rids), '%d'));
$result = db_query("SELECT DISTINCT(p.perm) FROM {role} r INNER JOIN {permission} p ON p.rid = r.rid WHERE r.rid IN ($placeholders)", $rids);
$perm[$account->uid] = '';
while ($row = db_fetch_object($result)) {
$perm[$account->uid] .= "$row->perm, ";
}
}
if (isset($perm[$account->uid])) {
return strpos($perm[$account->uid], "$string, ") !== FALSE;
}
return FALSE;
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии