summaryrefslogtreecommitdiffstats
path: root/wp-inst/wp-admin/invites.php
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2005-07-19 16:47:50 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2005-07-19 16:47:50 +0000
commit4dcf1b98ef1f7ea9fbaeffda363ed11c105c6fb2 (patch)
tree8d76dab67710303807a31e78a9a6da798db4a2c4 /wp-inst/wp-admin/invites.php
parent2d4088706f1e0c2e31260ffdacf378ec1323c0ce (diff)
Added user invites. WIP.
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@48 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-inst/wp-admin/invites.php')
-rw-r--r--wp-inst/wp-admin/invites.php109
1 files changed, 109 insertions, 0 deletions
diff --git a/wp-inst/wp-admin/invites.php b/wp-inst/wp-admin/invites.php
new file mode 100644
index 0000000..c2323b4
--- /dev/null
+++ b/wp-inst/wp-admin/invites.php
@@ -0,0 +1,109 @@
+<?php
+require_once('admin.php');
+
+$title = __('Invites');
+$parent_file = 'edit.php';
+
+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" );
+ $from = $cache_userdata[ $user_ID ]->user_email;
+
+ if( $msg == '' ) {
+ $msg =
+"Dear FIRSTNAME LASTNAME,
+---------------------------------------------
+PERSONALMESSAGE
+---------------------------------------------
+You have been invited to open a free WordPress weblog.
+
+To accept this invitation and register for your weblog, visit
+REGURL
+This invitation can only be used to set up one weblog.
+
+Regards,
+The WordPress Team
+
+(If clicking the URLs in this message does not work, copy and paste them
+into the address bar of your browser).";
+ update_site_settings( "invites_default_message", $msg );
+ }
+
+ if( $subject == '' ) {
+ $subject = "FIRSTNAME, USERNAME has invited you to use WordPress";
+ update_site_settings( "invites_default_subject", $subject );
+ }
+
+ $msg = str_replace( "FIRSTNAME", $_POST[ 'fname' ], $msg );
+ $msg = str_replace( "LASTNAME", $_POST[ 'lname' ], $msg );
+ $msg = str_replace( "PERSONALMESSAGE", $_POST[ 'personalmessage' ], $msg );
+ $msg = str_replace( "\\r\\n", "\n", stripslashes( str_replace( "REGURL", get_site_settings( "siteurl" ) . "/invite/".md5( $_POST[ 'email' ] ), $msg ) ) );
+
+ $subject = str_replace( "FIRSTNAME", $_POST[ 'fname' ], $subject );
+ if( $cache_userdata[ $user_ID ]->display_name != '' ) {
+ $username = $cache_userdata[ $user_ID ]->display_name;
+ } elseif( $cache_userdata[ $user_ID ]->first_name != '' ) {
+ $username = $cache_userdata[ $user_ID ]->first_name;
+ } elseif( $cache_userdata[ $user_ID ]->nickname != '' ) {
+ $username = $cache_userdata[ $user_ID ]->nickname;
+ } else {
+ $username = __( 'Someone' );
+ }
+ $subject = str_replace( "USERNAME", ucfirst( $username ), $subject );
+
+ $email = $wpdb->escape( $_POST[ 'email' ] );
+ $query = "INSERT INTO ".$wpdb->usermeta." ( `umeta_id` , `user_id` , `meta_key` , `meta_value` ) VALUES ( NULL, '0', 'invite' , '".md5( strtolower( $email ) )."')";
+ $wpdb->query( $query );
+ $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" );
+ $invites_left = $invites_left - 1;
+ update_usermeta( $user_ID, "invites_left", $invites_left );
+ header( "Location: ".get_settings( "siteurl" )."/wp-admin/invites.php?result=sent&to=" . urlencode( $email ) );
+ exit;
+ }
+ }
+} elseif( $_POST[ 'personalmessage' ] == '' ) {
+ $_POST[ 'personalmessage' ] = "I've been using WordPress and thought you might like to try it out. Here's an invitation to create an account.";
+}
+
+include('admin-header.php');
+if (isset($_GET['result'] ) == 'sent' ) {
+ ?><div class="updated"><p><strong><?php echo sprintf( __("Invite Sent to %s."), $wpdb->escape( $_GET[ 'to' ] ) ) ?></strong></p></div><?php
+}
+?>
+
+<div class="wrap">
+ <h2><?php _e('Invites') ?></h2>
+ <form name="form1" method="post" action="invites.php">
+ <input type="hidden" name="action" value="send" />
+ <fieldset class="options">
+ <legend><?php _e('Send Invite To') ?></legend>
+ <table width="100%" cellspacing="2" cellpadding="5" class="editform">
+ <tr valign="top">
+ <th width="33%" scope="row"><?php _e('First Name:') ?></th>
+ <td><input name="fname" type="text" id="fname" value="<?php echo stripslashes( $_POST[ 'fname' ] ) ?>" size="40" /></td>
+ </tr>
+ <tr valign="top">
+ <th width="33%" scope="row"><?php _e('Last Name:') ?></th>
+ <td><input name="lname" type="text" id="lname" value="<?php echo stripslashes( $_POST[ 'lname' ] ) ?>" size="40" /></td>
+ </tr>
+ <tr valign="top">
+ <th width="33%" scope="row"><?php _e('Email:') ?></th>
+ <td><input name="email" type="text" id="email" value="<?php echo stripslashes( $_POST[ 'email' ] ) ?>" size="40" /></td>
+ </tr>
+ <tr valign="top">
+ <th width="33%" scope="row"><?php _e('Personal Message:') ?></th>
+ <td><textarea rows="5" cols="40" name="personalmessage" tabindex="5" id="defaultmessage"><?php echo stripslashes( $_POST[ 'personalmessage' ] ) ?></textarea></td>
+ </tr>
+ </table>
+ </fieldset>
+ <p class="submit">
+ <input type="submit" name="Submit" value="<?php _e('Send Invite') ?> &raquo;" />
+ </p>
+ </form>
+</div>
+<?php include("admin-footer.php") ?>