function homebox_save_user_open in Homebox 6
Saves open status for a box Always an Ajax call
Return value
A Boolean JSON formated
1 string reference to 'homebox_save_user_open'
- homebox_menu in ./
homebox.module - Implementation of hook_menu().
File
- ./
homebox.module, line 679 - Home box main file, takes care of global functions settings constants, etc.
Code
function homebox_save_user_open() {
global $user;
if ($user->uid == 0) {
drupal_json(TRUE);
exit;
}
// Retrieve values from POST
$bid = (int) trim($_POST['box']);
$pid = (int) trim($_POST['pid']);
$open = (bool) trim($_POST['open']);
// Build a block object
$block = new stdClass();
$block->uid = $user->uid;
$block->bid = $bid;
$block->pid = $pid;
$block->open = (bool) $open;
// Update record in the database
if (drupal_write_record('homebox_users', $block, array(
'uid',
'bid',
'pid',
)) != FALSE) {
drupal_json(TRUE);
}
else {
drupal_json(FALSE);
}
exit;
}