diff --git a/database/database.mysql b/database/database.mysql index 686a8c968e6..874bde898b0 100644 --- a/database/database.mysql +++ b/database/database.mysql @@ -322,6 +322,7 @@ CREATE TABLE profile_fields ( name varchar(128) default NULL, explanation TEXT default NULL, category varchar(255) default NULL, + page varchar(255) default NULL, type varchar(128) default NULL, weight tinyint(1) DEFAULT '0' NOT NULL, overview tinyint(1) DEFAULT '0' NOT NULL, diff --git a/database/updates.inc b/database/updates.inc index 79b2573524e..371606ba326 100644 --- a/database/updates.inc +++ b/database/updates.inc @@ -51,7 +51,8 @@ $sql_updates = array( "2004-01-13" => "update_77", "2004-02-03" => "update_78", "2004-02-21" => "update_79", - "2004-03-11: first update since Drupal 4.4.0 release" => "update_80" + "2004-03-11: first update since Drupal 4.4.0 release" => "update_80", + "2004-02-20" => "update_81" ); function update_32() { @@ -764,15 +765,15 @@ function update_79() { function update_80() { // Add a 'created' field to the users table: - update_sql('ALTER TABLE {users} ADD created INT(11) NOT NULL'); - update_sql('ALTER TABLE {users} CHANGE timestamp changed INT(11) NOT NULL'); + $ret[] = update_sql('ALTER TABLE {users} ADD created INT(11) NOT NULL'); + $ret[] = update_sql('ALTER TABLE {users} CHANGE timestamp changed INT(11) NOT NULL'); // Add some indices to speed up the update process: - update_sql('ALTER TABLE {comments} ADD index (timestamp)'); - update_sql('ALTER TABLE {node} ADD index (created)'); + $ret[] = update_sql('ALTER TABLE {comments} ADD index (timestamp)'); + $ret[] = update_sql('ALTER TABLE {node} ADD index (created)'); // Assign everyone a created timestamp to begin with: - update_sql("UPDATE {users} SET created = changed WHERE created = ''"); + $ret[] = update_sql("UPDATE {users} SET created = changed WHERE created = ''"); // Print a status message:" print '
Note: this might take a while ...
'; @@ -798,7 +799,7 @@ function update_80() { } // Add profile module related tables: - update_sql("CREATE TABLE {profile_fields} ( + $ret[] = update_sql("CREATE TABLE {profile_fields} ( fid int(10) NOT NULL auto_increment, title varchar(255) default NULL, name varchar(128) default NULL, @@ -813,7 +814,7 @@ function update_80() { PRIMARY KEY (fid) );"); - update_sql("CREATE TABLE {profile_values} ( + $ret[] = update_sql("CREATE TABLE {profile_values} ( fid int(11) unsigned default '0', uid int(11) unsigned default '0', value text, @@ -879,8 +880,16 @@ function update_80() { // Save the update record: user_save($account, $edit); } + + return $ret; } +function update_81() { + $ret[] = update_sql('ALTER TABLE {profile_fields} ADD page varchar(255) default NULL'); + + return $ret; +} + function update_sql($sql) { $edit = $_POST["edit"]; $result = db_query($sql); diff --git a/modules/profile.module b/modules/profile.module index b50678001b2..68676923bfd 100644 --- a/modules/profile.module +++ b/modules/profile.module @@ -32,7 +32,7 @@ function profile_browse() { $value = arg(2) ? arg(2) : 1; // Determine the field to group users by: - $field = db_fetch_object(db_query("SELECT DISTINCT(f.fid), f.type, f.title FROM {profile_fields} f INNER JOIN {profile_values} v ON f.fid = v.fid WHERE f.name = '%s' AND v.value = '%s' ORDER BY f.category, f.weight", arg(1), $value)); + $field = db_fetch_object(db_query("SELECT DISTINCT(f.fid), f.type, f.title, f.page FROM {profile_fields} f INNER JOIN {profile_values} v ON f.fid = v.fid WHERE f.name = '%s' AND v.value = '%s' ORDER BY f.category, f.weight", arg(1), $value)); if ($field->fid) { // Compile a list of fields to show: @@ -45,18 +45,19 @@ function profile_browse() { // Extract the affected users: $result = pager_query("SELECT u.uid FROM {users} u INNER JOIN {profile_values} v ON u.uid = v.uid WHERE v.fid = $field->fid AND v.value = '". check_query($value) ."' ORDER BY u.changed DESC", 20); - $output = ''; + $output = 'profile_
to avoid name clashes with other fields. Spaces or any other special characters except dash (-) and underscore (_) are not allowed. An example name is 'profile_favorite_color' or perhaps just 'profile_color'."));
- $output .= form_textarea(t('Explanation'), 'explanation', $edit['explanation'], 70, 3, t("An optional explanation to go with the new field. The explanation will be shown to the user."));
- $output .= form_textfield(t('Category'), 'category', $edit['category'], 70, 128, t("The category the new field should be part of. Categories are used to group fields logically. An example category is 'Personal information'."));
- $output .= form_weight(t('Weight'), 'weight', $edit['weight'], 5, t("The weights define the order in which the form fields are shown. Lighter fields \"float up\" towards the top of the category."));
- $output .= form_checkbox(t('Display this field in member lists'), 'overview', 1, $edit['overview']);
-
+ $group .= form_textarea(t('Explanation'), 'explanation', $edit['explanation'], 70, 3, t("An optional explanation to go with the new field. The explanation will be shown to the user."));
if ($type == 'selection') {
- $output .= form_textarea(t('Selection options'), 'options', $edit['options'], 70, 8, t("A list of all options. Put each option on a separate line. Example options are 'red', 'blue', 'green', etc."));
+ $group .= form_textarea(t('Selection options'), 'options', $edit['options'], 70, 8, t("A list of all options. Put each option on a separate line. Example options are 'red', 'blue', 'green', etc."));
}
+ $group .= form_weight(t('Weight'), 'weight', $edit['weight'], 5, t("The weights define the order in which the form fields are shown. Lighter fields \"float up\" towards the top of the category."));
+ $output = form_group(t('Field settings'), $group);
+ $group = '';
+ if ($type == 'selection') {
+ $group .= form_textfield(t('Page title'), 'page', $edit['page'], 70, 128, t("The title of the page showing all users with the specified field. The word %value
will be substituted with the corresponding value. An example page title is 'People whose favorite color is %value'."));
+ }
+ else {
+ $group .= form_textfield(t('Page title'), 'page', $edit['page'], 70, 128, t("The title of the page showing all users with the specified field."));
+ }
+ $group .= form_checkbox(t('Should this field be shown on the member listing pages.'), 'overview', 1, $edit['overview']);
+
+ $output .= form_group(t('Browsability'), $group);
$output .= form_submit(t('Save field'));
return form($output);
@@ -280,10 +290,10 @@ function theme_profile_profile($user, $fields = array()) {
foreach ($fields as $field) {
if ($user->{$field->name}) {
if ($field->type == 'checkbox') {
- $output .= "profile_
to avoid name clashes with other fields. Spaces or any other special characters except dash (-) and underscore (_) are not allowed. An example name is 'profile_favorite_color' or perhaps just 'profile_color'."));
- $output .= form_textarea(t('Explanation'), 'explanation', $edit['explanation'], 70, 3, t("An optional explanation to go with the new field. The explanation will be shown to the user."));
- $output .= form_textfield(t('Category'), 'category', $edit['category'], 70, 128, t("The category the new field should be part of. Categories are used to group fields logically. An example category is 'Personal information'."));
- $output .= form_weight(t('Weight'), 'weight', $edit['weight'], 5, t("The weights define the order in which the form fields are shown. Lighter fields \"float up\" towards the top of the category."));
- $output .= form_checkbox(t('Display this field in member lists'), 'overview', 1, $edit['overview']);
-
+ $group .= form_textarea(t('Explanation'), 'explanation', $edit['explanation'], 70, 3, t("An optional explanation to go with the new field. The explanation will be shown to the user."));
if ($type == 'selection') {
- $output .= form_textarea(t('Selection options'), 'options', $edit['options'], 70, 8, t("A list of all options. Put each option on a separate line. Example options are 'red', 'blue', 'green', etc."));
+ $group .= form_textarea(t('Selection options'), 'options', $edit['options'], 70, 8, t("A list of all options. Put each option on a separate line. Example options are 'red', 'blue', 'green', etc."));
}
+ $group .= form_weight(t('Weight'), 'weight', $edit['weight'], 5, t("The weights define the order in which the form fields are shown. Lighter fields \"float up\" towards the top of the category."));
+ $output = form_group(t('Field settings'), $group);
+ $group = '';
+ if ($type == 'selection') {
+ $group .= form_textfield(t('Page title'), 'page', $edit['page'], 70, 128, t("The title of the page showing all users with the specified field. The word %value
will be substituted with the corresponding value. An example page title is 'People whose favorite color is %value'."));
+ }
+ else {
+ $group .= form_textfield(t('Page title'), 'page', $edit['page'], 70, 128, t("The title of the page showing all users with the specified field."));
+ }
+ $group .= form_checkbox(t('Should this field be shown on the member listing pages.'), 'overview', 1, $edit['overview']);
+
+ $output .= form_group(t('Browsability'), $group);
$output .= form_submit(t('Save field'));
return form($output);
@@ -280,10 +290,10 @@ function theme_profile_profile($user, $fields = array()) {
foreach ($fields as $field) {
if ($user->{$field->name}) {
if ($field->type == 'checkbox') {
- $output .= "