function epsacrop_ajax in EPSA Crop - Image Cropping 7.2
Same name and namespace in other branches
- 8.2 epsacrop.module \epsacrop_ajax()
epsacrop_ajax function.
@access public
Parameters
string $op:
string $fid:
Return value
void
1 string reference to 'epsacrop_ajax'
- epsacrop_menu in ./
epsacrop.module - Implements hook_menu.
File
- ./
epsacrop.module, line 172 - The main file of module
Code
function epsacrop_ajax($op, $fid) {
$return = NULL;
switch ($op) {
case 'get':
$return = _epsacrop_get_coords_from_fid($fid);
if ($return == FALSE) {
$return = array();
}
break;
case 'put':
if (isset($_POST) && (isset($_POST['coords']) && !empty($_POST['coords']))) {
// If the json_decode returns null that means we got an invalid JSON or
// it reaches the recursion limit.
if (($values = drupal_json_decode($_POST['coords'])) === NULL) {
drupal_access_denied();
drupal_exit();
}
$coords = drupal_json_encode($values);
_epsacrop_save_coords($fid, $coords);
}
break;
case 'del':
break;
}
drupal_json_output($return);
drupal_exit();
}