Commit 3568ed57 authored by Dries's avatar Dries

- Moving the title.module from core to contrib as discussed on the mailing list.

parent bddcee53
......@@ -181,12 +181,9 @@ function archive_block($op = 'list', $delta = 0) {
return $blocks;
}
else if (user_access('access content')) {
switch ($delta) {
case 0:
$block['subject'] = t('Browse archives');
$block['content'] = archive_calendar();
return $block;
}
$block['subject'] = t('Browse archives');
$block['content'] = archive_calendar();
return $block;
}
}
......
......@@ -181,12 +181,9 @@ function archive_block($op = 'list', $delta = 0) {
return $blocks;
}
else if (user_access('access content')) {
switch ($delta) {
case 0:
$block['subject'] = t('Browse archives');
$block['content'] = archive_calendar();
return $block;
}
$block['subject'] = t('Browse archives');
$block['content'] = archive_calendar();
return $block;
}
}
......
......@@ -167,6 +167,29 @@ function comment_access($op, $comment) {
}
}
/**
* Implementation of hook_block().
*
* Generates a block with the most recent comments.
*/
function comment_block($op = 'list', $delta = 0) {
if ($op == 'list') {
$blocks[0]['info'] = t('Recent comments');
return $blocks;
}
else if (user_access('access comments')) {
$result = db_query_range('SELECT * FROM {comments} WHERE status = 0 ORDER BY timestamp DESC', 0, 10);
$items = array();
while ($comment = db_fetch_object($result)) {
$items[] = l($comment->subject, "node/$comment->nid", NULL, NULL, "comment-$comment->cid") .'<br />'. format_interval(time() - $comment->timestamp) .' '. t('ago');
}
$block['subject'] = t('Recent comments');
$block['content'] = theme('item_list', $items);
return $block;
}
}
function comment_node_url() {
return arg(0) .'/'. arg(1) .'/'. arg(2);
}
......
......@@ -167,6 +167,29 @@ function comment_access($op, $comment) {
}
}
/**
* Implementation of hook_block().
*
* Generates a block with the most recent comments.
*/
function comment_block($op = 'list', $delta = 0) {
if ($op == 'list') {
$blocks[0]['info'] = t('Recent comments');
return $blocks;
}
else if (user_access('access comments')) {
$result = db_query_range('SELECT * FROM {comments} WHERE status = 0 ORDER BY timestamp DESC', 0, 10);
$items = array();
while ($comment = db_fetch_object($result)) {
$items[] = l($comment->subject, "node/$comment->nid", NULL, NULL, "comment-$comment->cid") .'<br />'. format_interval(time() - $comment->timestamp) .' '. t('ago');
}
$block['subject'] = t('Recent comments');
$block['content'] = theme('item_list', $items);
return $block;
}
}
function comment_node_url() {
return arg(0) .'/'. arg(1) .'/'. arg(2);
}
......
......@@ -78,7 +78,7 @@ function forum_settings() {
$group .= form_radios(t('Default order'), 'forum_order', variable_get('forum_order', '1'), $forder, t('The default display order for topics.'));
$output .= form_group(t('Forum viewing options'), $group);
$group = form_textfield(t('Number of topics in block'), 'forum_block_num', variable_get('forum_block_num', '5'), 5, 5, t('The number of topics to show in the "Forum topics" block. To enable the block, go to the <a href="%block-administration">block administration</a> page.', array('%block-administration' => url('admin/block'))));
$group = form_select(t('Number of topics in block'), 'forum_block_num', variable_get('forum_block_num', '5'), drupal_map_assoc(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)), t('The number of topics to show in the "Forum topics" block. To enable the block, go to the <a href="%block-administration">block administration</a> page.', array('%block-administration' => url('admin/block'))));
$output .= form_group(t('"Forum topic" block settings'), $group);
}
}
......
......@@ -78,7 +78,7 @@ function forum_settings() {
$group .= form_radios(t('Default order'), 'forum_order', variable_get('forum_order', '1'), $forder, t('The default display order for topics.'));
$output .= form_group(t('Forum viewing options'), $group);
$group = form_textfield(t('Number of topics in block'), 'forum_block_num', variable_get('forum_block_num', '5'), 5, 5, t('The number of topics to show in the "Forum topics" block. To enable the block, go to the <a href="%block-administration">block administration</a> page.', array('%block-administration' => url('admin/block'))));
$group = form_select(t('Number of topics in block'), 'forum_block_num', variable_get('forum_block_num', '5'), drupal_map_assoc(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)), t('The number of topics to show in the "Forum topics" block. To enable the block, go to the <a href="%block-administration">block administration</a> page.', array('%block-administration' => url('admin/block'))));
$output .= form_group(t('"Forum topic" block settings'), $group);
}
}
......
......@@ -135,7 +135,7 @@ function page_form(&$node) {
}
if (($node->format == 1) && (!user_access('create php content'))) {
drupal_set_message(t('Note: The body contents of this page are written in PHP and you do not have sufficient permissions to make changes to the body. You can edit the other elements of the page.'));
drupal_set_message(t('the body contents of this page are written in PHP and you do not have sufficient permissions to make changes to the body. You can edit the other elements of the page.'));
$output .= form_hidden('format', $node->format);
$hide_types = true;
}
......
......@@ -135,7 +135,7 @@ function page_form(&$node) {
}
if (($node->format == 1) && (!user_access('create php content'))) {
drupal_set_message(t('Note: The body contents of this page are written in PHP and you do not have sufficient permissions to make changes to the body. You can edit the other elements of the page.'));
drupal_set_message(t('the body contents of this page are written in PHP and you do not have sufficient permissions to make changes to the body. You can edit the other elements of the page.'));
$output .= form_hidden('format', $node->format);
$hide_types = true;
}
......
......@@ -389,14 +389,14 @@ function poll_vote(&$node) {
db_query("UPDATE {poll_choices} SET chvotes = chvotes + 1 WHERE nid = %d AND chorder = %d", $node->nid, $choice);
$node->allowvotes = false;
$node->choice[$choice]['chvotes']++;
drupal_set_message(t('Your vote was recorded.'));
drupal_set_message(t('your vote was recorded.'));
}
else {
drupal_set_message(t("You're not allowed to vote on this poll."), 'error');
drupal_set_message(t("you're not allowed to vote on this poll."), 'error');
}
}
else {
drupal_set_message(t("You didn't specify a valid poll choice."), 'error');
drupal_set_message(t("you didn't specify a valid poll choice."), 'error');
}
drupal_goto('node/'. $nid);
......
......@@ -389,14 +389,14 @@ function poll_vote(&$node) {
db_query("UPDATE {poll_choices} SET chvotes = chvotes + 1 WHERE nid = %d AND chorder = %d", $node->nid, $choice);
$node->allowvotes = false;
$node->choice[$choice]['chvotes']++;
drupal_set_message(t('Your vote was recorded.'));
drupal_set_message(t('your vote was recorded.'));
}
else {
drupal_set_message(t("You're not allowed to vote on this poll."), 'error');
drupal_set_message(t("you're not allowed to vote on this poll."), 'error');
}
}
else {
drupal_set_message(t("You didn't specify a valid poll choice."), 'error');
drupal_set_message(t("you didn't specify a valid poll choice."), 'error');
}
drupal_goto('node/'. $nid);
......
......@@ -253,13 +253,13 @@ function queue_nodeapi(&$node, $op) {
case 'insert':
case 'update':
if ($node->moderate && user_access('access submission queue')) {
drupal_set_message(t('The post is queued for approval. You can check the votes in the <a href="%queue">submission queue</a>.', array('%queue' => url('queue'))));
drupal_set_message(t('the post is queued for approval. You can check the votes in the <a href="%queue">submission queue</a>.', array('%queue' => url('queue'))));
}
else if ($node->moderate) {
drupal_set_message(t('The post is queued for approval. The editors will decide whether it should be published.'));
drupal_set_message(t('the post is queued for approval. The editors will decide whether it should be published.'));
}
else {
drupal_set_message(t('The post is published.'));
drupal_set_message(t('the post is published.'));
}
break;
}
......
......@@ -146,10 +146,10 @@ function system_view_general() {
// file system:
if (!file_check_directory(variable_get('file_directory_path', 'files'))) {
form_set_error('file_directory_path', t('Directory does not exist, or is not writable.'));
form_set_error('file_directory_path', t('the directory does not exist, or is not writable.'));
}
if (!file_check_directory(variable_get('file_directory_temp', (PHP_OS == 'WINNT' ? 'c:\\windows\\temp' : '/tmp')))) {
form_set_error('file_directory_temp', t('Directory does not exist, or is not writable.'));
form_set_error('file_directory_temp', t('the directory does not exist, or is not writable.'));
}
$group = form_textfield(t('File system path'), 'file_directory_path', variable_get('file_directory_path', 'files'), 70, 255, t('A file system path where the files will be stored. This directory has to exist and be writable by Drupal. If the download method is set to public this directory has to be relative to Drupal installation directory, and be accessible over the web. When download method is set to private this directory should not be accessible over the web. Changing this location after the site has been in use will cause problems so only change this setting on an existing site if you know what you are doing.'));
$group .= form_textfield(t('Temporary directory'), 'file_directory_temp', variable_get('file_directory_temp', (PHP_OS == 'WINNT' ? 'c:\\windows\\temp' : '/tmp')), 70, 255, t('Location where files can be saved temporarily. This directory should not be accessible from the web.'));
......
......@@ -146,10 +146,10 @@ function system_view_general() {
// file system:
if (!file_check_directory(variable_get('file_directory_path', 'files'))) {
form_set_error('file_directory_path', t('Directory does not exist, or is not writable.'));
form_set_error('file_directory_path', t('the directory does not exist, or is not writable.'));
}
if (!file_check_directory(variable_get('file_directory_temp', (PHP_OS == 'WINNT' ? 'c:\\windows\\temp' : '/tmp')))) {
form_set_error('file_directory_temp', t('Directory does not exist, or is not writable.'));
form_set_error('file_directory_temp', t('the directory does not exist, or is not writable.'));
}
$group = form_textfield(t('File system path'), 'file_directory_path', variable_get('file_directory_path', 'files'), 70, 255, t('A file system path where the files will be stored. This directory has to exist and be writable by Drupal. If the download method is set to public this directory has to be relative to Drupal installation directory, and be accessible over the web. When download method is set to private this directory should not be accessible over the web. Changing this location after the site has been in use will cause problems so only change this setting on an existing site if you know what you are doing.'));
$group .= form_textfield(t('Temporary directory'), 'file_directory_temp', variable_get('file_directory_temp', (PHP_OS == 'WINNT' ? 'c:\\windows\\temp' : '/tmp')), 70, 255, t('Location where files can be saved temporarily. This directory should not be accessible from the web.'));
......
......@@ -74,6 +74,29 @@ function taxonomy_menu() {
return $items;
}
/**
* Implementation of hook_block().
*
* Generates a block with all categories.
*/
function taxonomy_block($op = 'list', $delta = 0) {
if ($op == 'list') {
$blocks[0]['info'] = t('Categories');
return $blocks;
}
else if (user_access('access content')) {
$result = db_query("SELECT d.tid, d.name, MAX(n.created) AS updated, COUNT(*) AS count FROM {term_data} d INNER JOIN {term_node} USING (tid) INNER JOIN {node} n USING (nid) WHERE n.status = 1 GROUP BY d.tid ORDER BY updated DESC, d.name");
$items = array();
while ($category = db_fetch_object($result)) {
$items[] = l("$category->name ($category->count)", "taxonomy/page/or/$category->tid") .'<br />'. format_interval(time() - $category->updated) .' '. t('ago');
}
$block['subject'] = t('Categories');
$block['content'] = theme('item_list', $items);
return $block;
}
}
function taxonomy_form_vocabulary($edit = array()) {
foreach (node_list() as $type) {
$nodetypes[$type] = node_invoke($type, 'node_name');
......
......@@ -74,6 +74,29 @@ function taxonomy_menu() {
return $items;
}
/**
* Implementation of hook_block().
*
* Generates a block with all categories.
*/
function taxonomy_block($op = 'list', $delta = 0) {
if ($op == 'list') {
$blocks[0]['info'] = t('Categories');
return $blocks;
}
else if (user_access('access content')) {
$result = db_query("SELECT d.tid, d.name, MAX(n.created) AS updated, COUNT(*) AS count FROM {term_data} d INNER JOIN {term_node} USING (tid) INNER JOIN {node} n USING (nid) WHERE n.status = 1 GROUP BY d.tid ORDER BY updated DESC, d.name");
$items = array();
while ($category = db_fetch_object($result)) {
$items[] = l("$category->name ($category->count)", "taxonomy/page/or/$category->tid") .'<br />'. format_interval(time() - $category->updated) .' '. t('ago');
}
$block['subject'] = t('Categories');
$block['content'] = theme('item_list', $items);
return $block;
}
}
function taxonomy_form_vocabulary($edit = array()) {
foreach (node_list() as $type) {
$nodetypes[$type] = node_invoke($type, 'node_name');
......
<?php
// $Id$
/**
* Implementation of hook_help().
*/
function title_help($section) {
switch ($section) {
case 'admin/modules#description':
return t('Enables users to link to stories, articles or similar content by title.');
case 'filter#short-tip' :
return t('<a href=\"%title-help\">Link to content</a> on this site using <em>[title|text]</em>.', array("%title-help" => url('filter/tips', NULL, 'filter-title')));
case 'filter#long-tip' :
return '<p>' . t('You may quickly link to content on the site using this syntax: <em>[title|text]</em>. This will generate a link labeled "text" to the content with the title "title". If you omit "|text", the label becomes "title".') . '</p>';
}
}
/**
* Implementation of hook_menu().
*/
function title_menu() {
$items = array();
$items[] = array('path' => 'title', 'title' => t('search'),
'callback' => 'title_page',
'access' => user_access('access content'),
'type' => MENU_CALLBACK);
return $items;
}
/**
* Menu callback; displays the matching node or a list of search results.
*/
function title_page($query) {
$title = urldecode($query);
$result = db_query("SELECT n.*, u.name, u.uid FROM {node} n INNER JOIN {users} u ON n.uid = u.uid WHERE n.title = '%s' AND n.status = 1 ORDER BY n.created DESC", $title);
$title = trim(str_replace(array('_', '%', '*'), ' ', $title));
if (db_num_rows($result) == 0) {
// No node with exact title found; try a substring.
$result = db_query("SELECT n.*, u.name, u.uid FROM {node} n INNER JOIN {users} u ON n.uid = u.uid WHERE n.title LIKE '%%%s%%' AND n.status = 1 ORDER BY n.created DESC", $title);
}
if (db_num_rows($result) == 0 && module_exist('search')) {
// Still no matches, so return a full-text search.
search_view($title);
}
else if (db_num_rows($result) == 1) {
$node = db_fetch_object($result);
$node = node_load(array('nid' => $node->nid));
print theme('page', node_show($node, NULL), $node->title);
}
else {
$header = array(t('Type'), t('Title'), t('Author'));
while ($node = db_fetch_object($result)) {
$type = ucfirst(module_invoke($node->type, 'node', 'name'));
$title = l($node->title, "node/$node->nid");
$author = format_name($node);
$rows[] = array(array('data' => $type, 'class' => 'type'), array('data' => $title, 'class' => 'content'), array('data' => $author, 'class' => 'author'));
}
$output = '<div id="title">';
$output .= theme('table', $header, $rows);
$output .= '</div>';
drupal_set_title(t('Matching Posts'));
print theme('page', $output);
}
}
/**
* Implementation of hook_filter().
*/
function title_filter($op, $text = '', $node = NULL) {
switch ($op) {
case 'name':
return t('Title filter');
case 'process':
return _title_filter_process($text);
case 'settings':
return _title_filter_settings($text);
default:
return $text;
}
}
/**
* Filter [Node title|Description] links. '|Description' is optional.
*/
function _title_filter_process($text) {
$pattern = '\[([^\|\]\n]+)(?>\|?)([^\]\n]*)\]';
// $1 == title: matches at least 1 char up to the first '|' or ']'.
// $2 == text: matches all after a following '|' (if there is) up to the next ']'.
// May include '|'s.
$replacement = 'l(\'$2\' ? \'$2\' : \'$1\', \'title/\'. urlencode(\'$1\'))';
return preg_replace("/$pattern/e", $replacement, $text);
}
function _title_filter_settings() {
return form_group(t('Title filter'), t('Wiki-like [node title|text] links are enabled. These shortcuts generate a link labeled "text" to the node with the title "node title". If you omit "|text", the label becomes "node title". You may use a substring of a node title if desired. When multiple matching titles are found, a list of matching nodes will be displayed. If no matching titles are found, a full-text search is returned.'));
}
?>
......@@ -366,7 +366,7 @@ function user_fields() {
* Implementation of hook_perm().
*/
function user_perm() {
return array('administer users', 'access users');
return array('administer users');
}
/**
......@@ -532,25 +532,23 @@ function user_block($op = 'list', $delta = 0) {
$output = t('There are currently %members and %visitors online.', array('%members' => format_plural($total_users, '1 user', '%count users'), '%visitors' => format_plural($guests->count, '1 guest', '%count guests')));
}
if (user_access('access users') && $total_users) {
// Display a list of currently online users.
$max_users = variable_get('user_block_max_list_count', 10);
if ($max_users) {
$items = array();
// Display a list of currently online users.
$max_users = variable_get('user_block_max_list_count', 10);
if ($max_users) {
$items = array();
while ($max_users-- && $uid = db_fetch_object($users)) {
$items[] = format_name(user_load(array('uid' => $uid->uid)));
}
while ($max_users-- && $uid = db_fetch_object($users)) {
$items[] = format_name(user_load(array('uid' => $uid->uid)));
}
if ($items) {
if (db_fetch_object($users)) {
$items[] = '...';
}
$output .= theme('item_list', $items, t('Online users:'));
if ($items) {
if (db_fetch_object($users)) {
$items[] = '...';
}
$output .= theme('item_list', $items, t('Online users:'));
}
}
$block['subject'] = t('Who\'s online');
$block['content'] = $output;
}
......@@ -1003,9 +1001,9 @@ function user_register($edit = array()) {
function user_edit_form($uid, $edit) {
// Account information:
$group = form_textfield(t('Username'), 'name', $edit['name'], 30, 55, t('Your full name or your preferred username: only letters, numbers and spaces are allowed.'));
$group .= form_textfield(t('E-mail address'), 'mail', $edit['mail'], 30, 55, t('Insert a valid e-mail address. All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail.'));
$group .= form_item(t('Password'), '<input type="password" name="edit[pass1]" size="12" maxlength="24" /> <input type="password" name="edit[pass2]" size="12" maxlength="24" />', t('Enter your new password twice if you want to change your current password, or leave it blank if you are happy with your current password.'));
$group = form_textfield(t('Username'), 'name', $edit['name'], 30, 55, t('Your full name or your preferred username: only letters, numbers and spaces are allowed.'), NULL, TRUE);
$group .= form_textfield(t('E-mail address'), 'mail', $edit['mail'], 30, 55, t('Insert a valid e-mail address. All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail.'), NULL, TRUE);
$group .= form_item(t('Password'), '<input type="password" name="edit[pass1]" size="12" maxlength="24" /> <input type="password" name="edit[pass2]" size="12" maxlength="24" />', t('Enter your new password twice if you want to change your current password, or leave it blank if you are happy with your current password.'), NULL, TRUE);
if (user_access('administer users')) {
$group .= form_radios(t('Status'), 'status', $edit['status'], array(t('Blocked'), t('Active')));
......@@ -1247,7 +1245,7 @@ function user_configure_settings() {
// Picture settings.
if (!file_check_directory(file_create_path(variable_get('user_picture_path', 'pictures')))) {
form_set_error('user_picture_path', t('The picture directory does not exist, or is not writable.'));
form_set_error('user_picture_path', t('the picture directory does not exist, or is not writable.'));
}
$group = form_radios(t('Picture support'), 'user_pictures', variable_get('user_pictures', 0), array(t('Disabled'), t('Enabled')), t('Enable picture support.'));
......@@ -1284,9 +1282,9 @@ function user_admin_create($edit = array()) {
}
}
$output = form_textfield(t('Username'), 'name', $edit['name'], 30, 55, t('Provide the username of the new account.'));
$output .= form_textfield(t('E-mail address'), 'mail', $edit['mail'], 30, 55, t('Provide the e-mail address associated with the new account.'));
$output .= form_textfield(t('Password'), 'pass', $edit['pass'], 30, 55, t('Provide a password for the new account.'));
$output = form_textfield(t('Username'), 'name', $edit['name'], 30, 55, t('Provide the username of the new account.'), NULL, TRUE);
$output .= form_textfield(t('E-mail address'), 'mail', $edit['mail'], 30, 55, t('Provide the e-mail address associated with the new account.'), NULL, TRUE);
$output .= form_password(t('Password'), 'pass', $edit['pass'], 30, 55, t('Provide a password for the new account.'), NULL, TRUE);
$output .= form_submit(t('Create account'));
$output = form_group(t('Create new user account'), $output);
......@@ -1416,7 +1414,7 @@ function user_admin_perm($edit = array()) {
function user_admin_role($edit = array()) {
$op = $_POST['op'];
$id = arg(3);
$id = arg(4);
if ($op == t('Save role')) {
db_query("UPDATE {role} SET name = '%s' WHERE rid = %d", $edit['name'], $id);
......@@ -1425,8 +1423,7 @@ function user_admin_role($edit = array()) {
db_query('DELETE FROM {role} WHERE rid = %d', $id);
db_query('DELETE FROM {permission} WHERE rid = %d', $id);
// Users with only the deleted role are put back in the authenticated users pool.
$aid = _user_authenticated_id();
// Update the users who have this role set:
$result = db_query('SELECT DISTINCT ur1.uid FROM {users_roles} ur1 LEFT JOIN {users_roles} ur2 ON ur2.uid = ur1.uid WHERE ur1.rid = %d AND ur2.rid != ur1.rid', $id);
$uid = array();
......@@ -1434,8 +1431,12 @@ function user_admin_role($edit = array()) {
$uid[] = $u->uid;
}
db_query('DELETE FROM {users_roles} WHERE rid = %d AND uid IN (%s)', $id, implode(', ', $uid));
db_query('UPDATE {users_roles} SET rid = %d WHERE rid = %d', $aid, $id);
if ($uid) {
db_query('DELETE FROM {users_roles} WHERE rid = %d AND uid IN (%s)', $id, implode(', ', $uid));
}
// Users with only the deleted role are put back in the authenticated users pool.
db_query('UPDATE {users_roles} SET rid = %d WHERE rid = %d', _user_authenticated_id(), $id);
}
else if ($op == t('Add role')) {
db_query("INSERT INTO {role} (name) VALUES ('%s')", $edit['name']);
......@@ -1458,7 +1459,7 @@ function user_admin_role($edit = array()) {
$header = array(t('name'), t('operations'));
while ($role = db_fetch_object($result)) {
if ($role->name != 'anonymous user' && $role->name != 'authenticated user') {
$rows[] = array($role->name, array('data' => l(t('edit role'), "admin/user/role/$role->rid"), 'align' => 'center'));
$rows[] = array($role->name, array('data' => l(t('edit role'), "admin/user/configure/role/$role->rid"), 'align' => 'center'));
}
else {
$rows[] = array($role->name, array('data' => '<span class="disabled">'. t('locked') .'</span>', 'align' => 'center'));
......
......@@ -366,7 +366,7 @@ function user_fields() {
* Implementation of hook_perm().
*/
function user_perm() {
return array('administer users', 'access users');
return array('administer users');
}
/**
......@@ -532,25 +532,23 @@ function user_block($op = 'list', $delta = 0) {
$output = t('There are currently %members and %visitors online.', array('%members' => format_plural($total_users, '1 user', '%count users'), '%visitors' => format_plural($guests->count, '1 guest', '%count guests')));
}
if (user_access('access users') && $total_users) {
// Display a list of currently online users.
$max_users = variable_get('user_block_max_list_count', 10);
if ($max_users) {
$items = array();
// Display a list of currently online users.
$max_users = variable_get('user_block_max_list_count', 10);
if ($max_users) {
$items = array();
while ($max_users-- && $uid = db_fetch_object($users)) {
$items[] = format_name(user_load(array('uid' => $uid->uid)));
}
while ($max_users-- && $uid = db_fetch_object($users)) {
$items[] = format_name(user_load(array('uid' => $uid->uid)));
}
if ($items) {
if (db_fetch_object($users)) {
$items[] = '...';
}
$output .= theme('item_list', $items, t('Online users:'));
if ($items) {
if (db_fetch_object($users)) {
$items[] = '...';
}
$output .= theme('item_list', $items, t('Online users:'));
}
}
$block['subject'] = t('Who\'s online');
$block['content'] = $output;
}
......@@ -1003,9 +1001,9 @@ function user_register($edit = array()) {
function user_edit_form($uid, $edit) {
// Account information:
$group = form_textfield(t('Username'), 'name', $edit['name'], 30, 55, t('Your full name or your preferred username: only letters, numbers and spaces are allowed.'));
$group .= form_textfield(t('E-mail address'), 'mail', $edit['mail'], 30, 55, t('Insert a valid e-mail address. All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail.'));
$group .= form_item(t('Password'), '<input type="password" name="edit[pass1]" size="12" maxlength="24" /> <input type="password" name="edit[pass2]" size="12" maxlength="24" />', t('Enter your new password twice if you want to change your current password, or leave it blank if you are happy with your current password.'));
$group = form_textfield(t('Username'), 'name', $edit['name'], 30, 55, t('Your full name or your preferred username: only letters, numbers and spaces are allowed.'), NULL, TRUE);
$group .= form_textfield(t('E-mail address'), 'mail', $edit['mail'], 30, 55, t('Insert a valid e-mail address. All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail.'), NULL, TRUE);
$group .= form_item(t('Password'), '<input type="password" name="edit[pass1]" size="12" maxlength="24" /> <input type="password" name="edit[pass2]" size="12" maxlength="24" />', t('Enter your new password twice if you want to change your current password, or leave it blank if you are happy with your current password.'), NULL, TRUE);
if (user_access('administer users')) {
$group .= form_radios(t('Status'), 'status', $edit['status'], array(t('Blocked'), t('Active')));
......@@ -1247,7 +1245,7 @@ function user_configure_settings() {
// Picture settings.
if (!file_check_directory(file_create_path(variable_get('user_picture_path', 'pictures')))) {
form_set_error('user_picture_path', t('The picture directory does not exist, or is not writable.'));
form_set_error('user_picture_path', t('the picture directory does not exist, or is not writable.'));
}
$group = form_radios(t('Picture support'), 'user_pictures', variable_get('user_pictures', 0), array(t('Disabled'), t('Enabled')), t('Enable picture support.'));
......@@ -1284,9 +1282,9 @@ function user_admin_create($edit = array()) {
}
}
$output = form_textfield(t('Username'), 'name', $edit['name'], 30, 55, t('Provide the username of the new account.'));
$output .= form_textfield(t('E-mail address'), 'mail', $edit['mail'], 30, 55, t('Provide the e-mail address associated with the new account.'));
$output .= form_textfield(t('Password'), 'pass', $edit['pass'], 30, 55, t('Provide a password for the new account.'));
$output = form_textfield(t('Username'), 'name', $edit['name'], 30, 55, t('Provide the username of the new account.'), NULL, TRUE);
$output .= form_textfield(t('E-mail address'), 'mail', $edit['mail'], 30, 55, t('Provide the e-mail address associated with the new account.'), NULL, TRUE);
$output .= form_password(t('Password'), 'pass', $edit['pass'], 30, 55, t('Provide a password for the new account.'), NULL, TRUE);
$output .= form_submit(t('Create account'));
$output = form_group(t('Create new user account'), $output);
......@@ -1416,7 +1414,7 @@ function user_admin_perm($edit = array()) {
function user_admin_role($edit = array()) {
$op = $_POST['op'];
$id = arg(3);
$id = arg(4);
if ($op == t('Save role')) {
db_query("UPDATE {role} SET name = '%s' WHERE rid = %d", $edit['name'], $id);
......@@ -1425,8 +1423,7 @@ function user_admin_role($edit = array()) {
db_query('DELETE FROM {role} WHERE rid = %d', $id);
db_query('DELETE FROM {permission} WHERE rid = %d', $id);
// Users with only the deleted role are put back in the authenticated users pool.
$aid = _user_authenticated_id();
// Update the users who have this role set:
$result = db_query('SELECT DISTINCT ur1.uid FROM {users_roles} ur1 LEFT JOIN {users_roles} ur2 ON ur2.uid = ur1.uid WHERE ur1.rid = %d AND ur2.rid != ur1.rid', $id);
$uid = array();
......@@ -1434,8 +1431,12 @@ function user_admin_role($edit = array()) {
$uid[] = $u->uid;
}
db_query('DELETE FROM {users_roles} WHERE rid = %d AND uid IN (%s)', $id, implode(', ', $uid));
db_query('UPDATE {users_roles} SET rid = %d WHERE rid = %d', $aid, $id);
if ($uid) {
db_query('DELETE FROM {users_roles} WHERE rid = %d AND uid IN (%s)', $id, implode(', ', $uid));
}
// Users with only the deleted role are put back in the authenticated users pool.
db_query('UPDATE {users_roles} SET rid = %d WHERE rid = %d', _user_authenticated_id(), $id);
}
else if ($op == t('Add role')) {
db_query("INSERT INTO {role} (name) VALUES ('%s')", $edit['name']);
......@@ -1458,7 +1459,7 @@ function user_admin_role($edit = array()) {
$header = array(t('name'), t('operations'));
while ($role = db_fetch_object($result)) {
if ($role->name != 'anonymous user' && $role->name != 'authenticated user') {
$rows[] = array($role->name, array('data' => l(t('edit role'), "admin/user/role/$role->rid"), 'align' => 'center'));
$rows[] = array($role->name, array('data' => l(t('edit role'), "admin/user/configure/role/$role->rid"), 'align' => 'center'));
}
else {
$rows[] = array($role->name, array('data' => '<span class="disabled">'. t('locked') .'</span>', 'align' => 'center'));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment