<?php # Check user & validate data switch (true) { # Not logged in case !is_loggedin(): JSON::parse(100, 'negative', '<i class="fa fa-exclamation-triangle"></i> Access denied: you\'re not logged in.', null, true); break; # No post data # No post data case !is_form_data(): JSON::parse(100, 'negative', '<i class="fa fa-exclamation-triangle"></i> There was a problem saving your changes. (Error: No data received)', null, true); break; } # Saved Posts $saved = 0; # Unsaved $unsaved = 0; # New GUMP Object $form = new GUMP(); # Get Input $data = form_data(); # Run GUMP $response = $form->run($data); # Get Response if ($response === false) { JSON::parse(100, 'negative', $form->get_readable_errors(true)); } else { # Loop through each of the submitted fields and # if a an html file exists, then we will update # the file with the newly uploaded content.
<?php use CCK\Helpers; use CCK\Content; # Check Method is Post if (!is_form_data()) { JSON::parse(100, 'negative', 'Invalid request. Requests to ' . $path . ' must be POST', null, true); } # Actions $actions = array(1, 0, -1); # Sanitize form data $data = Helpers::sanitizeInput(form_data()); # Check for post IDs if (!isset($data['posts']) || !isset($data['action'])) { JSON::parse(100, 'negative', 'Missing data.', $data, true); } # Get Post IDs $posts = json_decode($data['posts'], true); # Typecast Action $action = (int) $data['action']; # Check Action is Valid if (!in_array($action, $actions)) { JSON::parse(100, 'negative', 'Invalid action.', null, true); } # Create new Content Object $content = new Content($_cck_types, $_cck_config); # Update each post foreach ($posts as $post) { if (!$content->update($post, array('status' => $action))) { JSON::parse(100, 'negative', 'Post ID: ' . $post . ' was not updated.', null, true); }