adding delete email and required reason if owner is not deleter
authorToby Elliott <telliott@mozilla.com>
Mon, 18 May 2009 15:42:35 -0700
changeset 952 6d930b1e2f9c9beddc5bc309e8dbf0a94b1c84f3
parent 951 46abc72796ffde94641558ad02d5a6718d6fa2c9
child 953 190250c60c752c61806e3b563b3f94d5b494a202
push id588
push usertelliott@mozilla.com
push dateMon, 18 May 2009 22:43:03 +0000
adding delete email and required reason if owner is not deleter
server/delete_persona.php
server/templates/delete_persona_tmpl.php
--- a/server/delete_persona.php
+++ b/server/delete_persona.php
@@ -38,16 +38,28 @@
 # ***** END LICENSE BLOCK *****
 	
 	require_once 'lib/personas_constants.php';
 	require_once 'lib/personas_functions.php';
 	require_once 'lib/storage.php';
 	require_once 'lib/user.php';
 
 	
+	function send_delete_email($address, $reason, $name)
+	{
+		$message = "We have had to remove your persona '$name' from the gallery for the following reason: $reason.\n\n"; 
+		$message .= "If you have any questions about this decision, please contact us at personas@mozilla.com. We look forward to seeing your contributions to the community in the future\n\n";
+		$message .= "Best Wishes,\n";
+		$message .= "The Personas Team\n";
+		
+		$header = "From: personas@mozilla.com\r\n";
+		return mail($address, 'Removing a persona', $message, $header);
+	}
+
+
 	$path = array_key_exists('PATH_INFO', $_SERVER) ? $_SERVER['PATH_INFO'] : '/';
 	$path = substr($path, 1); #chop the lead slash
 	list($id) = explode('/', $path);
 	
 	$user = new PersonaUser();
 
 	$auth_user = $user->authenticate();
 	$user->force_signin();
@@ -68,17 +80,19 @@
 		include 'templates/delete_persona_tmpl.php';
 		exit;
 	}
 	
 	if (array_key_exists('confirm', $_POST))
 	{
 		rename (make_persona_storage_path($persona['id']), make_persona_pending_path($persona['id']));
 		$db->reject_persona($persona['id']);
-		$db->log_action($user->get_username(), $persona['id'], "Pulled");
+		if ($persona['author'] != $auth_user)
+			send_delete_email($user->get_email($persona['author']), $_POST['dreason'], $persona['name']);
+		$db->log_action($user->get_username(), $persona['id'], "Pulled" . (array_key_exists('dreason', $_POST) ? " - " . $_POST['dreason'] : ""));
 		include 'templates/delete_persona_success_tmpl.php';
 	}
 	else
 	{
 		$persona['json'] = htmlentities(json_encode(extract_record_data($persona)));
 		include 'templates/delete_persona_tmpl.php';
 	}
 	
--- a/server/templates/delete_persona_tmpl.php
+++ b/server/templates/delete_persona_tmpl.php
@@ -1,26 +1,36 @@
-<?php $title = "Delete your Persona"; include 'header.php'; ?>
+<?php 
+	error_log($persona['author']);
+	error_log($auth_user);
+	$delete_require = $persona['author'] != $auth_user ? "onsubmit=\"if ($('#formreason').val() == '') {alert('Please provide a reason for deletion'); return false;}\"" : "";
+	$title = "Delete your Persona"; include 'header.php'; 
+?>
 <body>
     <div id="outer-wrapper">
         <div id="inner-wrapper">
 <?php include 'nav.php'; ?>
             <div id="header">
                 <h2>Delete Your Persona</h2>
                 <h3>Thanks for sharing your persona with us.</h3>
             </div>
             <div id="maincontent">
                 <p id="breadcrumbs"><a href="http://www.getpersonas.com">Personas Home</a> : Delete Your Persona</p>
                 
 <?php include 'persona_detail.php' ?>
 <?php if(!$override_error && $persona) { ?>
-                <form method="POST" action="/delete/<?= $persona['id'] ?>" enctype='multipart/form-data'>
+                <form method="POST" action="/delete/<?= $persona['id'] ?>" enctype='multipart/form-data' <?= $delete_require ?>>
 					<input type="hidden" name="id" value="<?= htmlspecialchars($persona['id']) ?>">
 					<input type="hidden" name="confirm" value="1">
-					<p class="continue"><button type="submit" class="button"><span>confirm deletion</span><span class="arrow">&nbsp;</span></button></p>
+					<p class="continue">
+<?php 	if($persona['author'] != $auth_user) { ?>
+						Delete Reason: <input type="text" name="dreason" id=formreason> 
+<?php 	} ?>
+						<button type="submit" class="button"><span>confirm deletion</span><span class="arrow">&nbsp;</span></button>
+					</p>
             	</form>
 <?php } ?>
             </div>
             <div id="secondary-content">
               <ol id="upload-steps">
                 <li class="current">
                     <div class="wrapper">
                         <h3>Step 1:</h3>