mysite_delete_item($uid, $mid, $dest = NULL)
mysite.module, line 2614
Delete an item from a form call or a url
$uid The $user->uid of the owner of this MySite page.
$mid The unique mysite_id (mid) of the content to be altered.
$dest The path to go after completing the deletion. Required if we are not using the confirm form.
function mysite_delete_item($uid, $mid, $dest = NULL) {
global $user;
// security check, since we do this through the url; also gets the sort value
if (is_numeric($mid) && ($user->uid == $uid || user_access('administer mysite'))) {
$sql = 'SELECT mid, sort FROM {mysite_data} WHERE mid = %d AND uid = %d';
$result = db_fetch_object(db_query($sql, $mid, $uid));
$mid = $result->mid;
$sort = $result->sort;
}
if ($mid > 0) {
$sql = 'DELETE FROM {mysite_data} WHERE mid = %d';
db_query($sql, $mid);
$sql = 'UPDATE {mysite_data} SET sort = (sort -1) WHERE uid = %d AND sort > %d';
db_query($sql, $uid, $sort);
mysite_updated($uid);
drupal_set_message(t('Item deleted.'), 'status');
}
else {
drupal_set_message(t('You are not authorized to delete this item.'), 'error');
}
if (empty($dest)) {
drupal_goto('mysite/'. $uid .'/content');
}
drupal_goto($dest);
}