Exemplo n.º 1
0
 function post_processor_images()
 {
     global $wpdb, $flag, $flagdb;
     do_action('flag_manage_post_processor_images');
     // bulk update in a single gallery
     if (isset($_POST['bulkaction']) && isset($_POST['doaction'])) {
         check_admin_referer('flag_updategallery');
         switch ($_POST['bulkaction']) {
             case 'no_action':
                 break;
             case 'delete_images':
                 if (is_array($_POST['doaction'])) {
                     $delete_pic = false;
                     foreach ($_POST['doaction'] as $imageID) {
                         $image = $flagdb->find_image($imageID);
                         if ($image) {
                             if ($flag->options['deleteImg']) {
                                 @unlink($image->imagePath);
                                 @unlink($image->webimagePath);
                                 @unlink($image->thumbPath);
                             }
                             $delete_pic = flagdb::delete_image($image->pid);
                         }
                     }
                     if ($delete_pic) {
                         flagGallery::show_message(__('Pictures deleted successfully ', 'flash-album-gallery'));
                     }
                 }
                 break;
             case 'import_meta':
                 flagAdmin::do_ajax_operation('import_metadata', $_POST['doaction'], __('Import metadata', 'flash-album-gallery'));
                 break;
             case 'copy_meta':
                 flagAdmin::do_ajax_operation('copy_metadata', $_POST['doaction'], __('Copy metadata to image Description', 'flash-album-gallery'));
                 break;
             case 'webview_images':
                 flagAdmin::do_ajax_operation('webview_image', $_POST['doaction'], __('Creating images optimized for web', 'flash-album-gallery'));
                 break;
             case 'reset_counters':
                 if (is_array($_POST['doaction'])) {
                     $images = $flagdb->find_images_in_list($_POST['doaction']);
                     foreach ($images as $image) {
                         $img_id = $image->pid;
                         $wpdb->query("UPDATE {$wpdb->flagpictures} SET hitcounter = '0', total_votes = '0' WHERE pid = {$img_id}");
                     }
                 }
                 break;
         }
     }
     if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_ResizeImages'])) {
         check_admin_referer('flag_thickbox_form');
         //save the new values for the next operation
         $flag->options['imgWidth'] = (int) $_POST['imgWidth'];
         $flag->options['imgHeight'] = (int) $_POST['imgHeight'];
         update_option('flag_options', $flag->options);
         $pic_ids = explode(',', $_POST['TB_imagelist']);
         flagAdmin::do_ajax_operation('resize_image', $pic_ids, __('Resize images', 'flash-album-gallery'));
     }
     if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_NewThumbnail'])) {
         check_admin_referer('flag_thickbox_form');
         //save the new values for the next operation
         $flag->options['thumbWidth'] = (int) $_POST['thumbWidth'];
         $flag->options['thumbHeight'] = (int) $_POST['thumbHeight'];
         $flag->options['thumbFix'] = (bool) $_POST['thumbFix'];
         update_option('flag_options', $flag->options);
         $pic_ids = explode(',', $_POST['TB_imagelist']);
         flagAdmin::do_ajax_operation('create_thumbnail', $pic_ids, __('Create new thumbnails', 'flash-album-gallery'));
     }
     if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_SelectGallery'])) {
         check_admin_referer('flag_thickbox_form');
         $pic_ids = explode(',', $_POST['TB_imagelist']);
         $pic_ids = array_filter($pic_ids, 'intval');
         $dest_gid = (int) $_POST['dest_gid'];
         switch ($_POST['TB_bulkaction']) {
             case 'copy_to':
                 // Copy images
                 flagAdmin::copy_images($pic_ids, $dest_gid);
                 break;
             case 'move_to':
                 // Move images
                 flagAdmin::move_images($pic_ids, $dest_gid);
                 break;
         }
     }
     if (isset($_POST['updatepictures'])) {
         // Update pictures
         check_admin_referer('flag_updategallery');
         $gallery_title = esc_html($_POST['title']);
         $gallery_path = esc_attr(str_replace('..', '', $_POST['path']));
         $gallery_desc = esc_html($_POST['gallerydesc']);
         $gallery_preview = (int) $_POST['previewpic'];
         $wpdb->query("UPDATE {$wpdb->flaggallery} SET title= '{$gallery_title}', path= '{$gallery_path}', galdesc = '{$gallery_desc}', previewpic = '{$gallery_preview}' WHERE gid = '{$this->gid}'");
         if (isset($_POST['author'])) {
             $gallery_author = (int) $_POST['author'];
             $wpdb->query("UPDATE {$wpdb->flaggallery} SET author = '{$gallery_author}' WHERE gid = '{$this->gid}'");
         }
         $this->update_pictures();
         //hook for other plugin to update the fields
         do_action('flag_update_gallery', $this->gid, $_POST);
         flagGallery::show_message(__('Update successful', "flash-album-gallery"));
     }
     if (isset($_POST['scanfolder'])) {
         // Rescan folder
         check_admin_referer('flag_updategallery');
         $gallerypath = $wpdb->get_var("SELECT path FROM {$wpdb->flaggallery} WHERE gid = '{$this->gid}' ");
         flagAdmin::import_gallery($gallerypath);
     }
 }