diff options
| author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2005-07-29 15:40:01 +0000 |
|---|---|---|
| committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2005-07-29 15:40:01 +0000 |
| commit | 923f4aaf4fcf6374db5097a2ebed0d970a08f1f5 (patch) | |
| tree | 9e7ec301c88478eaedb108e2e5b95bbd872b9a17 | |
| parent | 3e32eff632ade6aa191a9feeb475bc7d0d7cae50 (diff) | |
Customizable dashboard feeds: allow site admin to change them.
Changed *_site_settings() to *_site_option()
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@103 7be80a69-a1ef-0310-a953-fb0f7c49ff36
| -rw-r--r-- | wp-inst/wp-admin/index.php | 27 | ||||
| -rw-r--r-- | wp-inst/wp-admin/invites.php | 6 | ||||
| -rw-r--r-- | wp-inst/wp-admin/menu.php | 2 | ||||
| -rw-r--r-- | wp-inst/wp-admin/themes.php | 2 | ||||
| -rw-r--r-- | wp-inst/wp-admin/upgrade-schema.php | 5 | ||||
| -rw-r--r-- | wp-inst/wp-admin/user-edit.php | 2 | ||||
| -rw-r--r-- | wp-inst/wp-admin/users.php | 4 | ||||
| -rw-r--r-- | wp-inst/wp-admin/wpmu-blogs.php | 4 | ||||
| -rw-r--r-- | wp-inst/wp-admin/wpmu-edit.php | 9 | ||||
| -rw-r--r-- | wp-inst/wp-includes/rss-functions.php | 10 | ||||
| -rw-r--r-- | wp-inst/wp-includes/wpmu-functions.php | 22 | ||||
| -rw-r--r-- | wp-inst/wp-newblog.php | 6 |
12 files changed, 68 insertions, 31 deletions
diff --git a/wp-inst/wp-admin/index.php b/wp-inst/wp-admin/index.php index 0aefd4f..d7a7620 100644 --- a/wp-inst/wp-admin/index.php +++ b/wp-inst/wp-admin/index.php @@ -106,15 +106,23 @@ foreach ($rss->items as $item ) { </div> <h2><?php _e('Dashboard'); ?></h2> -<p><?php _e('Below is the latest news from the official WordPress development blog, click on a title to read the full entry.'); ?></p> <?php -$rss = @fetch_rss('http://wordpress.org/development/feed/'); +if( get_site_option( 'customizefeed1' ) == 0 ) { + $rss = @fetch_rss(get_site_option( 'dashboardfeed1' )); + $custom = true; +} else { + $rss = @fetch_rss('http://wordpress.org/development/feed/'); + $custom = false; +} + if ( isset($rss->items) && 0 != count($rss->items) ) { -?> -<h3>WordPress Development Blog</h3> -<?php -$rss->items = array_slice($rss->items, 0, 3); -foreach ($rss->items as $item ) { + if( $custom == false ) { + print "<h3>WordPress Development Blog</h3>"; + } else { + print "<h3>Your Custom Feed</h3>"; + } + $rss->items = array_slice($rss->items, 0, 3); + foreach ($rss->items as $item ) { ?> <h4><a href='<?php echo wp_filter_kses($item['link']); ?>'><?php echo wp_specialchars($item['title']); ?></a> — <?php echo human_time_diff( strtotime($item['pubdate'], time() ) ); ?> <?php _e('ago'); ?></h4> <p><?php echo $item['description']; ?></p> @@ -125,6 +133,11 @@ foreach ($rss->items as $item ) { <?php +if( get_site_option( 'customizefeed2' ) == 0 ) { + $rss = @fetch_rss(get_site_option( 'dashboardfeed2' )); +} else { + $rss = @fetch_rss('http://wordpress.org/development/feed/'); +} $rss = @fetch_rss('http://planet.wordpress.org/feed/'); if ( isset($rss->items) && 0 != count($rss->items) ) { ?> diff --git a/wp-inst/wp-admin/invites.php b/wp-inst/wp-admin/invites.php index ab5188f..01b6b39 100644 --- a/wp-inst/wp-admin/invites.php +++ b/wp-inst/wp-admin/invites.php @@ -8,8 +8,8 @@ if( $_POST[ 'action' ] == 'send' ) { $invites_left = get_usermeta( $user_ID, 'invites_left' ); if( $invites_left != false ) { if( $_POST[ 'email' ] != '' && is_email( $_POST[ 'email' ] ) ) { - $msg = get_site_settings( "invites_default_message" ); - $subject = get_site_settings( "invites_default_subject" ); + $msg = get_site_option( "invites_default_message" ); + $subject = get_site_option( "invites_default_subject" ); $from = $cache_userdata[ $user_ID ]->user_email; $msg = str_replace( "FIRSTNAME", $_POST[ 'fname' ], $msg ); @@ -35,7 +35,7 @@ if( $_POST[ 'action' ] == 'send' ) { $query = "INSERT INTO ".$wpdb->usermeta." ( `umeta_id` , `user_id` , `meta_key` , `meta_value` ) VALUES ( NULL, '0', '".md5( strtolower( $email ) )."_invited_by' , '$user_ID')"; $wpdb->query( $query ); mail( $_POST[ 'email' ], $subject, $msg, "From: $from" ); - if( $user_ID != get_site_settings( "admin_user_id" ) ) { + if( $user_ID != get_site_option( "admin_user_id" ) ) { $invites_left = $invites_left - 1; update_usermeta( $user_ID, "invites_left", $invites_left ); } diff --git a/wp-inst/wp-admin/menu.php b/wp-inst/wp-admin/menu.php index 6d41593..ad2401f 100644 --- a/wp-inst/wp-admin/menu.php +++ b/wp-inst/wp-admin/menu.php @@ -28,7 +28,7 @@ $submenu['edit.php'][25] = array(sprintf(__("Awaiting Moderation (%s)"), $awaiti $submenu['edit.php'][30] = array(__('Files'), 'edit_files', 'templates.php'); $invites_left = get_usermeta( $user_ID, 'invites_left' ); if( $invites_left == '' ) { - $invites_left = get_site_settings( 'invites_per_user' ); + $invites_left = get_site_option( 'invites_per_user' ); update_usermeta( $user_ID, "invites_left", $invites_left ); } $submenu['edit.php'][35] = array(sprintf(__("Invites (%s)"), $invites_left ), 'edit_posts', 'invites.php'); // TODO: put somewhere else. diff --git a/wp-inst/wp-admin/themes.php b/wp-inst/wp-admin/themes.php index 7aed945..24a3dbd 100644 --- a/wp-inst/wp-admin/themes.php +++ b/wp-inst/wp-admin/themes.php @@ -31,7 +31,7 @@ require_once('admin-header.php'); <?php $themes = get_themes(); -$allowed_themes = get_site_settings( "allowed_themes" ); +$allowed_themes = get_site_option( "allowed_themes" ); if( $allowed_themes == false ) { $allowed_themes = $themes; } diff --git a/wp-inst/wp-admin/upgrade-schema.php b/wp-inst/wp-admin/upgrade-schema.php index 17f1f09..4f72562 100644 --- a/wp-inst/wp-admin/upgrade-schema.php +++ b/wp-inst/wp-admin/upgrade-schema.php @@ -255,6 +255,11 @@ function populate_options() { // 1.6 add_option('default_role', 'inactive'); + add_site_option( 'customizefeed1', '0' ); + add_site_option( 'customizefeed2', '0' ); + add_site_option( 'dashboardfeed1', 'http://wordpress.org/development/feed/' ); + add_site_option( 'dashboardfeed2', 'http://planet.wordpress.org/feed/' ); + populate_roles(); // Delete unused options diff --git a/wp-inst/wp-admin/user-edit.php b/wp-inst/wp-admin/user-edit.php index 28bb7e8..5cbc4cd 100644 --- a/wp-inst/wp-admin/user-edit.php +++ b/wp-inst/wp-admin/user-edit.php @@ -24,7 +24,7 @@ for ($i=0; $i<count($wpvarstoreset); $i += 1) { $errors = array(); // Only allow site admins to edit every user. -if( $user_ID != get_site_settings( "admin_user_id" ) ) +if( $user_ID != get_site_option( "admin_user_id" ) ) if( false == $wpdb->get_var("SELECT user_id FROM $wpdb->usermeta WHERE user_id = '$user_id' AND meta_key = '".$wpdb->prefix."capabilities'") ) $errors['head'] = __('You do not have permission to edit this user.'); switch ($action) { diff --git a/wp-inst/wp-admin/users.php b/wp-inst/wp-admin/users.php index 5cce96b..af79bc1 100644 --- a/wp-inst/wp-admin/users.php +++ b/wp-inst/wp-admin/users.php @@ -174,7 +174,7 @@ default: include ('admin-header.php'); - if( $user_ID == get_site_settings( "admin_user_id" ) ) { + if( $user_ID == get_site_option( "admin_user_id" ) ) { $userids = $wpdb->get_col("SELECT ID FROM $wpdb->users"); } else { $userids = $wpdb->get_col("SELECT ID FROM $wpdb->users, $wpdb->usermeta WHERE $wpdb->users.ID = $wpdb->usermeta.user_id AND meta_key = '".$wpdb->prefix."capabilities'"); @@ -250,7 +250,7 @@ default: $style = ''; foreach ($roleclass as $user_object) { $user_data = &$user_object->data; - if( $user_data->ID != get_site_settings( "admin_user_id" ) ) { + if( $user_data->ID != get_site_option( "admin_user_id" ) ) { $email = $user_data->user_email; $url = $user_data->user_url; $short_url = str_replace('http://', '', $url); diff --git a/wp-inst/wp-admin/wpmu-blogs.php b/wp-inst/wp-admin/wpmu-blogs.php index ba6b156..d9d7a3a 100644 --- a/wp-inst/wp-admin/wpmu-blogs.php +++ b/wp-inst/wp-admin/wpmu-blogs.php @@ -122,7 +122,7 @@ switch( $_GET[ 'action' ] ) { $blog_allowed_themes = $wpdb->get_var( $query ); if( $blog_allowed_themes != false ) $blog_allowed_themes = unserialize( $blog_allowed_themes ); - $allowed_themes = get_site_settings( "allowed_themes" ); + $allowed_themes = get_site_option( "allowed_themes" ); if( $allowed_themes == false ) { $allowed_themes = array_keys( $themes ); } @@ -297,7 +297,7 @@ print "</table>"; } // end if ($blogs) $themes = get_themes(); - $allowed_themes = get_site_settings( "allowed_themes" ); + $allowed_themes = get_site_option( "allowed_themes" ); if( $allowed_themes == false ) { $allowed_themes = array_keys( $themes ); } diff --git a/wp-inst/wp-admin/wpmu-edit.php b/wp-inst/wp-admin/wpmu-edit.php index db2a610..0753d01 100644 --- a/wp-inst/wp-admin/wpmu-edit.php +++ b/wp-inst/wp-admin/wpmu-edit.php @@ -4,6 +4,13 @@ require_once('admin.php'); do_action( "wpmuadminedit", "" ); switch( $_GET[ 'action' ] ) { + case "updatefeeds": + update_site_option( "customizefeed1", $_POST[ 'customizefeed1' ] ); + update_site_option( "customizefeed2", $_POST[ 'customizefeed2' ] ); + update_site_option( "dashboardfeed1", $_POST[ 'dashboardfeed1' ] ); + update_site_option( "dashboardfeed2", $_POST[ 'dashboardfeed2' ] ); + header( "Location: wpmu-feeds.php?updated=true" ); + break; case "updateblog": $options_table_name = $wpmuBaseTablePrefix . $_POST[ 'id' ] ."_options"; @@ -92,7 +99,7 @@ switch( $_GET[ 'action' ] ) { if( $_POST[ 'theme' ][ addslashes( $key ) ] == 'enabled' ) $allowed_themes[ $key ] = true; } - update_site_settings( 'allowed_themes', $allowed_themes ); + update_site_option( 'allowed_themes', $allowed_themes ); } header( "Location: wpmu-blogs.php?updated=true" ); break; diff --git a/wp-inst/wp-includes/rss-functions.php b/wp-inst/wp-includes/rss-functions.php index 960c273..25d1ced 100644 --- a/wp-inst/wp-includes/rss-functions.php +++ b/wp-inst/wp-includes/rss-functions.php @@ -662,8 +662,8 @@ class RSSCache { if ( !$wpdb->get_var("SELECT option_name FROM $wpdb->options WHERE option_name = '$cache_timestamp'") ) add_option($cache_timestamp, '', '', 'no'); - update_option($cache_option, $rss); - update_option($cache_timestamp, time() ); + update_site_option($cache_option, $rss); + update_site_option($cache_timestamp, time() ); return $cache_option; } @@ -678,14 +678,14 @@ class RSSCache { $this->ERROR = ""; $cache_option = 'rss_' . $this->file_name( $url ); - if ( ! get_option( $cache_option ) ) { + if ( ! get_site_option( $cache_option ) ) { $this->debug( "Cache doesn't contain: $url (cache option: $cache_option)" ); return 0; } - $rss = get_option( $cache_option ); + $rss = get_site_option( $cache_option ); return $rss; } @@ -847,4 +847,4 @@ function get_rss ($uri, $num = 5) { // Like get posts, but for RSS return false; } } -?>
\ No newline at end of file +?> diff --git a/wp-inst/wp-includes/wpmu-functions.php b/wp-inst/wp-includes/wpmu-functions.php index fc925f7..7e53820 100644 --- a/wp-inst/wp-includes/wpmu-functions.php +++ b/wp-inst/wp-includes/wpmu-functions.php @@ -685,6 +685,10 @@ function get_site_settings( $option ) { return $option; } +function get_site_option( $key, $value ) { + return get_site_settings( $key, $value ); +} + function add_site_settings( $key, $value ) { global $wpdb; if( $value != get_site_settings( $key ) ) { @@ -702,6 +706,10 @@ function add_site_settings( $key, $value ) { } } +function add_site_option( $key, $value ) { + return add_site_settings( $key, $value ); +} + function update_site_settings( $key, $value ) { global $wpdb; if( $value != get_site_settings( $key ) ) { @@ -714,7 +722,7 @@ function update_site_settings( $key, $value ) { WHERE meta_key = '$key' AND site_id = '".$wpdb->siteid."'"; if( $wpdb->get_var( $query ) == false ) { - add_site_settings( $key, $value ); + add_site_option( $key, $value ); } else { $query = "UPDATE ".$wpdb->sitemeta." SET meta_value = '".$wpdb->escape( $value )."' @@ -724,6 +732,10 @@ function update_site_settings( $key, $value ) { } } +function update_site_option( $key, $value ) { + return update_site_settings( $key, $value ); +} + function switch_to_blogid( $blog_id ) { global $tmpoldblogdetails, $wpdb, $wpmuBaseTablePrefix, $cache_settings; @@ -808,7 +820,7 @@ function get_last_updated( $display = false ) { function get_most_active( $num = 10, $display = true ) { global $wpdb; - $most_active = get_site_settings( "most_active" ); + $most_active = get_site_option( "most_active" ); $update = false; if( is_array( $most_active ) ) { if( ( $most_active[ 'time' ] + 60 ) < time() ) { // cache for 60 seconds. @@ -834,7 +846,7 @@ function get_most_active( $num = 10, $display = true ) { unset( $most_active ); $most_active = $t; } - update_site_settings( "most_active", $most_active ); + update_site_option( "most_active", $most_active ); } if( $display == true ) { @@ -852,7 +864,7 @@ function get_most_active( $num = 10, $display = true ) { function get_blog_list( $start = 0, $num = 10, $display = true ) { global $wpdb, $wpmuBaseTablePrefix; - $blogs = get_site_settings( "blog_list" ); + $blogs = get_site_option( "blog_list" ); $update = false; if( is_array( $blogs ) ) { if( ( $blogs[ 'time' ] + 60 ) < time() ) { // cache for 60 seconds. @@ -876,7 +888,7 @@ function get_blog_list( $start = 0, $num = 10, $display = true ) { unset( $blogs ); $blogs = $blog_list; } - update_site_settings( "blog_list", $blogs ); + update_site_option( "blog_list", $blogs ); } return $blogs; diff --git a/wp-inst/wp-newblog.php b/wp-inst/wp-newblog.php index 7bdd586..a169100 100644 --- a/wp-inst/wp-newblog.php +++ b/wp-inst/wp-newblog.php @@ -105,10 +105,10 @@ function determineDirPath() { switch( $_POST[ 'stage' ] ) { case "1": - $illegal_names = get_site_settings( "illegal_names" ); + $illegal_names = get_site_option( "illegal_names" ); if( $illegal_names == false ) { $illegal_names = array( "www", "web", "root", "admin", "main", "invite", "administrator" ); - add_site_settings( "illegal_names", $illegal_names ); + add_site_option( "illegal_names", $illegal_names ); } $newBlogID = sanitize_title($_POST['weblog_id']); @@ -165,7 +165,7 @@ switch( $_POST[ 'stage' ] ) $err = createBlog( $newBlogID.".".$domain, $scriptBaseName, $newBlogID, $weblog_title, $admin_email ); if( $err == 'ok' ) { displaySecondForm(); - $admin_email = get_site_settings( "admin_email" ); + $admin_email = get_site_option( "admin_email" ); $msg = "A new blog has been created on " . $current_site->domain . $current_site->path . "\n"; $msg .= "Address: http://" . $newBlogID . "." . $domain . $scriptBaseName . "\n"; $msg .= "Title: $weblog_title\n"; |
