function MaintainReattributePosts() { global $sourcedir, $context, $txt; checkSession(); // Find the member. require_once $sourcedir . '/Subs-Auth.php'; $members = findMembers($_POST['to']); if (empty($members)) { fatal_lang_error('reattribute_cannot_find_member'); } $memID = array_shift($members); $memID = $memID['id']; $email = $_POST['type'] == 'email' ? $_POST['from_email'] : ''; $membername = $_POST['type'] == 'name' ? $_POST['from_name'] : ''; // Now call the reattribute function. require_once $sourcedir . '/Subs-Members.php'; reattributePosts($memID, $email, $membername, !empty($_POST['posts'])); $context['maintenance_finished'] = $txt['maintain_reattribute_posts']; }
/** * Re-attribute posts to the user sent from the maintenance page. */ public function action_reattribute_display() { global $context, $txt; checkSession(); // Start by doing some data checking require_once SUBSDIR . '/DataValidator.class.php'; $validator = new Data_Validator(); $validator->sanitation_rules(array('posts' => 'empty', 'type' => 'trim', 'from_email' => 'trim', 'from_name' => 'trim', 'to' => 'trim')); $validator->validation_rules(array('from_email' => 'valid_email', 'from_name' => 'required', 'to' => 'required', 'type' => 'contains[name,email]')); $validator->validate($_POST); // Do we have a valid set of options to continue? if ($validator->type === 'name' && !empty($validator->from_name) || $validator->type === 'email' && !$validator->validation_errors('from_email')) { // Find the member. require_once SUBSDIR . '/Auth.subs.php'; $members = findMembers($validator->to); // No members, no further if (empty($members)) { fatal_lang_error('reattribute_cannot_find_member'); } $memID = array_shift($members); $memID = $memID['id']; $email = $validator->type == 'email' ? $validator->from_email : ''; $membername = $validator->type == 'name' ? $validator->from_name : ''; // Now call the reattribute function. require_once SUBSDIR . '/Members.subs.php'; reattributePosts($memID, $email, $membername, !$validator->posts); $context['maintenance_finished'] = array('errors' => array(sprintf($txt['maintain_done'], $txt['maintain_reattribute_posts']))); } else { // Show them the correct error if ($validator->type === 'name' && empty($validator->from_name)) { $error = $validator->validation_errors(array('from_name', 'to')); } else { $error = $validator->validation_errors(array('from_email', 'to')); } $context['maintenance_finished'] = array('errors' => $error, 'type' => 'minor'); } }