+ $orig_record = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
+ intval($contact_id),
+ intval($_SESSION['uid'])
+ );
+
+ if(! count($orig_record)) {
+ notice("Could not access contact record." . EOL);
+ goaway($a->get_baseurl() . '/contacts');
+ return; // NOTREACHED
+ }
+
+ $profile_id = intval($_POST['profile-assign']);
+ if($profile_id) {
+ $r = q("SELECT `id` FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
+ intval($profile_id),
+ intval($_SESSION['uid'])
+ );
+ if(! count($r)) {
+ notice("Cannot locate selected profile." . EOL);
+ return;
+ }
+ }
+ $rating = intval($_POST['reputation']);
+ if($rating > 5 || $rating < 0)
+ $rating = 0;
+
+ $reason = notags(trim($_POST['reason']));