Exemplo n.º 1
0
            $new_slide_ids = array();
            if (is_array($legacy_slides) && count($legacy_slides) > 0) {
                foreach ($legacy_slides as $legacy_slide) {
                    $title = $legacy_slide['title'];
                    $description = $legacy_slide['description'];
                    $background = $legacy_slide['background'];
                    $link = $legacy_slide['link'];
                    $title_pos_x = $legacy_slide['title_pos_x'];
                    $title_pos_y = $legacy_slide['title_pos_y'];
                    $new_slide_ids[] = $new_group->new_slide($title, $description, $background, $link, $title_pos_x, $title_pos_y, 'publish');
                }
            }
            // make sure we don't use this name again
            $legacy_slide_group_names[] = $legacy_group->name;
            // fix ordering by doing a reshuffle with the new array of slide ids returned
            $new_group->reshuffle($new_slide_ids);
        }
    }
}
// handle role assignments and add the new capabilities to roles that previous had TOTAL_SLIDER_REQUIRED_CAPABILITY
$all_roles = get_editable_roles();
$roles_to_set = array('administrator');
if (is_array($all_roles) && count($all_roles) > 0) {
    foreach ($all_roles as $role_name => $role_info) {
        if (in_array(TOTAL_SLIDER_REQUIRED_CAPABILITY, array_keys($role_info['capabilities']))) {
            $roles_to_set[] = $role_name;
        }
    }
}
$ts_class->set_capability_for_roles($roles_to_set, 'preserve_existing', 'upgrading');
// completed -- so update our data format version
Exemplo n.º 2
0
 if (!array_key_exists('slidesort', $_POST)) {
     header('HTTP/1.0 400 Bad Request');
     header('Content-Type: application/json');
     echo json_encode(array('error' => __('The new slide order was not specified, or there were no items within it.', 'total-slider')));
     die;
 }
 if (empty($_POST['slidesort']) || !is_array($_POST['slidesort']) || count($_POST['slidesort']) < 1) {
     header('HTTP/1.1 400 Bad Request');
     header('Content-Type: application/json');
     echo json_encode(array('error' => __('The new slide order was not specified, or there were no items within it.', 'total-slider')));
     die;
 }
 foreach ($_POST['slidesort'] as $key => $item) {
     $_POST['slidesort'][$key] = preg_replace('[^0-9a-zA-Z_]', '', $item);
 }
 $result = $g->reshuffle($_POST['slidesort']);
 if ('disparity' === $result) {
     header('HTTP/1.1 400 Bad Request');
     header('Content-Type: application/json');
     echo json_encode(array('error' => __('The new slide order is missing one or more current slides. Cannot save the new order, or slides would be lost. Please reload the page to ensure all current slides are in the sorting area and try sorting again.', 'total-slider')));
     die;
 } else {
     if ($result === true) {
         header('Content-Type: application/json');
         echo json_encode(array('success' => 'true'));
         die;
     } else {
         header('HTTP/1.0 500 Internal Server Error');
         header('Content-Type: application/json');
         echo json_encode(array('error' => __('The sort slide operation failed at the server.', 'total-slider')));
         die;