private static function PreSync($sync_data) { self::PrintDebugTrace(); // some syncing/updating self::UpdateItemsPath($sync_data->files, $sync_data->cats); WPFB_Admin::SyncCustomFields(); }
function process_bulk_action() { if (!$this->current_action() || empty($_REQUEST['file']) && empty($_REQUEST['action2'])) { return; } // filter files current user can edit $files = isset($_REQUEST['file']) ? array_filter(array_map(array('WPFB_File', 'GetFile'), $_REQUEST['file']), create_function('$file', 'return ($file && $file->CurUserCan' . 'Edit' . '());')) : array(); $message = null; switch ($this->current_action()) { case 'delete': foreach ($files as $file) { $file->Remove(true); } WPFB_Admin::SyncCustomFields(); $message = sprintf(__("%d File(s) deleted.", WPFB), count($files)); break; case 'edit': if (isset($_REQUEST['action2']) && $_REQUEST['action2'] == 'apply') { $message = wpfb_call('AdminGuiBulkEdit', 'Process'); } else { wpfb_call('AdminGuiBulkEdit', 'Display'); exit; } break; case 'set_off': foreach ($files as $file) { $file->file_offline = 1; $file->DbSave(); } $message = sprintf(__("%d File(s) were set offline.", WPFB), count($files)); break; case 'set_on': foreach ($files as $file) { $file->file_offline = 0; $file->DbSave(); } $message = sprintf(__("%d File(s) were set online.", WPFB), count($files)); break; } if (!empty($message)) { ?> <div id="message" class="updated fade"><p><?php echo $message; ?> </p></div><?php } }
/** * @param WPFB_SyncData $sync_data */ private static function PreSync($sync_data) { self::PrintDebugTrace(); // some syncing/updating if ($sync_data->num_db_files < self::MANY_FILES) { self::UpdateItemsPath(); } WPFB_Admin::SyncCustomFields(); }
public static function SettingsUpdated($old, &$new) { $messages = array(); wpfb_call('Setup', 'ProtectUploadPath'); // custom fields: $messages = array_merge($messages, WPFB_Admin::SyncCustomFields()); if ($old['thumbnail_path'] != $new['thumbnail_path']) { update_option(WPFB_OPT_NAME, $old); // temporaly restore old settings WPFB_Core::$settings = (object) $old; $items = array_merge(WPFB_File::GetFiles2(), WPFB_Category::GetCats()); $old_thumbs = array(); foreach ($items as $i => $item) { $old_thumbs[$i] = $item->GetThumbPath(true); } update_option(WPFB_OPT_NAME, $new); // restore new settings WPFB_Core::$settings = (object) $new; $n = 0; foreach ($items as $i => $item) { if (!empty($old_thumbs[$i]) && is_file($old_thumbs[$i])) { $new_path = $item->GetThumbPath(true); $dir = dirname($new_path); if (!is_dir($dir)) { self::Mkdir($dir); } if (rename($old_thumbs[$i], $new_path)) { $n++; } else { $messages[] = sprintf(__('Could not move thumnail %s to %s.', WPFB), $old_thumbs[$i], $new_path); } } } if (count($n > 0)) { $messages[] = sprintf(__('%d Thumbnails moved.', WPFB), $n); } } flush_rewrite_rules(); return $messages; }