function flickr_backups_update(&$backup, $update) { $hash = array(); foreach ($update as $k => $v) { $hash[$k] = AddSlashes($v); } $enc_user = AddSlashes($backup['user_id']); $enc_type = AddSlashes($backup['type_id']); $where = "user_id='{$enc_user}' AND type_id='{$enc_type}'"; $rsp = db_update('FlickrBackups', $hash, $where); if ($rsp['ok'] && isset($update['disabled'])) { $backup = array_merge($backup, $update); $enabled = $update['disabled'] ? 0 : 1; $push_rsp = flickr_backups_toggle_push_subscription($backup, $enabled); $rsp['push_backup'] = $push_rsp; } return $rsp; }
$created[$type_id] = $rsp['ok'] || $rsp['error_code'] == 1062 ? 1 : 0; $rsp['type_id'] = $type_id; $details[] = $rsp; } $GLOBALS['smarty']->assign_by_ref("created", $created); $GLOBALS['smarty']->assign_by_ref("created_details", $details); $backups = flickr_backups_for_user($GLOBALS['cfg']['user']); } else { if ($type = post_str("type")) { if (isset($map[$type]) && isset($backups[$type])) { $backup = $backups[$type]; $action = post_str("action"); $context = post_str("context"); if ($context == "push") { $enabled = $action == 'start' ? 1 : 0; $rsp = flickr_backups_toggle_push_subscription($backup, $enabled); } else { $disabled = $action == 'stop' ? 1 : 0; $update = array('disabled' => $disabled); $rsp = flickr_backups_update($backup, $update); } if ($rsp['ok']) { $backups = flickr_backups_for_user($GLOBALS['cfg']['user']); } $rsp['action'] = $action; $rsp['context'] = $context; $GLOBALS['smarty']->assign_by_ref("update_rsp", $rsp); } } else { } }