GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — legacy/integrations.php at develop · projectsend/legacy Expand file tree/ Copy pathintegrations.phpMore file actions 234 lines (194 loc) · 10.4 KB / Copy pathintegrations.phpFile metadata and controls234 lines (194 loc) · 10.4 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 <?php /** * External Storage Integrations Management * Allows administrators to manage external storage connections (S3, Google Cloud, etc.) */ require_once 'bootstrap.php'; redirect_if_not_logged_in(); // Check for system administration permissions if (!current_user_can('edit_settings')) { exit_with_error_code(403); } $active_nav = 'integrations'; $page_title = __('External Storage Integrations', 'cftp_admin'); $page_id = 'integrations'; $integrations_handler = new \ProjectSend\Classes\Integrations(); $available_types = \ProjectSend\Classes\Integrations::getAvailableTypes(true); // Handle form submissions global $flash; // Delete integration if (isset($_POST['action']) && $_POST['action'] == 'delete' && !empty($_POST['id'])) { $integration_id = (int)$_POST['id']; $result = $integrations_handler->delete($integration_id); if ($result['status'] == 'success') { $flash->success($result['message']); } else { $flash->error($result['message']); } ps_redirect('integrations.php'); } // Toggle integration active status if (isset($_POST['action']) && $_POST['action'] == 'toggle' && !empty($_POST['id'])) { $integration_id = (int)$_POST['id']; $integration = $integrations_handler->getById($integration_id); if ($integration) { $new_status = $integration['active'] ? 0 : 1; $result = $integrations_handler->update($integration_id, ['active' => $new_status]); if ($result['status'] == 'success') { $status_text = $new_status ? __('enabled', 'cftp_admin') : __('disabled', 'cftp_admin'); $flash->success(sprintf(__('Integration %s successfully.', 'cftp_admin'), $status_text)); } else { $flash->error($result['message']); } } ps_redirect('integrations.php'); } // Test connection if (isset($_POST['action']) && $_POST['action'] == 'test' && !empty($_POST['id'])) { $integration_id = (int)$_POST['id']; $test_result = $integrations_handler->testIntegration($integration_id); if ($test_result['success']) { $flash->success(__('Connection test successful!', 'cftp_admin')); } else { $error_message = __('Connection test failed: ', 'cftp_admin') . $test_result['message']; // Show detailed error information if available if (isset($test_result['details']) && !empty($test_result['details'])) { $error_message .= '<br><small><strong>' . __('Details:', 'cftp_admin') . '</strong> ' . $test_result['details'] . '</small>'; } $flash->error($error_message); } ps_redirect('integrations.php'); } // Get all integrations for display $integrations = $integrations_handler->getAll(); // Header buttons $header_action_buttons = []; if (current_user_can('create_clients') || current_user_can('manage_clients')) { $header_action_buttons = [ [ 'url' => 'integrations-add.php', 'label' => __('Add Integration', 'cftp_admin'), ], ]; } include_once ADMIN_VIEWS_DIR . DS . 'header.php'; ?> <div class="row"> <div class="col-12"> <?php if (empty($integrations)): ?> <div class="alert alert-info"> <i class="fa fa-info-circle"></i> <?php _e('No integrations configured yet.', 'cftp_admin'); ?> <a href="integrations-add.php" class="alert-link"><?php _e('Add your first integration', 'cftp_admin'); ?></a> </div> <?php else: ?> <!-- Debug: Show count --> <!-- Found <?php echo count($integrations); ?> integrations --> <?php // Generate the table using the ProjectSend Table class $table = new \ProjectSend\Classes\Layout\Table([ 'id' => 'integrations_tbl', 'class' => 'footable table', 'origin' => basename(__FILE__), ]); $thead_columns = array( array( 'content' => __('Name', 'cftp_admin'), ), array( 'content' => __('Type', 'cftp_admin'), 'hide' => 'phone', ), array( 'content' => __('Status', 'cftp_admin'), ), array( 'content' => __('Created', 'cftp_admin'), 'hide' => 'phone', ), array( 'content' => __('Files', 'cftp_admin'), ), array( 'content' => __('Actions', 'cftp_admin'), 'hide' => 'phone', ), ); $table->thead($thead_columns); foreach ($integrations as $integration) { $table->addRow(); // Get file count for this integration $file_count_query = "SELECT COUNT(*) FROM " . TABLE_FILES . " WHERE integration_id = :id"; $file_count_stmt = $dbh->prepare($file_count_query); $file_count_stmt->bindParam(':id', $integration['id'], PDO::PARAM_INT); $file_count_stmt->execute(); $file_count = $file_count_stmt->fetchColumn(); $type_config = $available_types[$integration['type']] ?? null; // Name column $name_content = '<strong>' . html_output($integration['name']) . '</strong>'; // Type column $type_content = ''; if ($type_config) { $type_content = '<span class="badge bg-primary">' . html_output($type_config['name']) . '</span>'; if (isset($type_config['coming_soon']) && $type_config['coming_soon']) { $type_content .= ' <small class="text-muted">(' . __('Coming Soon', 'cftp_admin') . ')</small>'; } } else { $type_content = '<span class="badge bg-secondary">' . html_output($integration['type']) . '</span>'; } // Status column $status_badge = $integration['active'] ? '<span class="badge bg-success">' . __('Active', 'cftp_admin') . '</span>' : '<span class="badge bg-secondary">' . __('Inactive', 'cftp_admin') . '</span>'; // Created column $created_content = date(get_option('timeformat'), strtotime($integration['created_date'])); $created_by_display = $integration['created_by_name'] ? $integration['created_by_name'] : $integration['created_by_username']; if ($created_by_display) { $created_content .= '<br><small class="text-muted">' . __('by', 'cftp_admin') . ' ' . html_output($created_by_display) . '</small>'; } // Files column $files_content = $file_count > 0 ? '<span class="badge bg-info">' . $file_count . '</span>' : '<span class="text-muted">0</span>'; // Actions column $action_buttons = ''; $csrf = getCsrfToken(); $int_id = (int)$integration['id']; // Test Connection button (only for non-coming-soon types) if (!isset($type_config['coming_soon']) || !$type_config['coming_soon']) { $action_buttons .= '<form method="post" action="integrations.php" class="d-inline"><input type="hidden" name="action" value="test"><input type="hidden" name="id" value="' . $int_id . '"><input type="hidden" name="csrf_token" value="' . $csrf . '"><button type="submit" class="btn btn-pslight btn-sm"><i class="fa fa-plug"></i><span class="button_label">' . __('Test', 'cftp_admin') . '</span></button></form>' . "\n"; } // Edit button $action_buttons .= '<a href="integrations-edit.php?id=' . $int_id . '" class="btn btn-primary btn-sm"><i class="fa fa-edit"></i><span class="button_label">' . __('Edit', 'cftp_admin') . '</span></a>' . "\n"; // Toggle active/inactive button if ($integration['active']) { $action_buttons .= '<form method="post" action="integrations.php" class="d-inline"><input type="hidden" name="action" value="toggle"><input type="hidden" name="id" value="' . $int_id . '"><input type="hidden" name="csrf_token" value="' . $csrf . '"><button type="submit" class="btn btn-pslight btn-sm"><i class="fa fa-pause"></i><span class="button_label">' . __('Disable', 'cftp_admin') . '</span></button></form>' . "\n"; } else { $action_buttons .= '<form method="post" action="integrations.php" class="d-inline"><input type="hidden" name="action" value="toggle"><input type="hidden" name="id" value="' . $int_id . '"><input type="hidden" name="csrf_token" value="' . $csrf . '"><button type="submit" class="btn btn-success btn-sm"><i class="fa fa-play"></i><span class="button_label">' . __('Enable', 'cftp_admin') . '</span></button></form>' . "\n"; } // Delete button (only if no files are using this integration) if ($file_count == 0) { $action_buttons .= '<form method="post" action="integrations.php" class="d-inline"><input type="hidden" name="action" value="delete"><input type="hidden" name="id" value="' . $int_id . '"><input type="hidden" name="csrf_token" value="' . $csrf . '"><button type="submit" class="btn btn-danger btn-sm" onclick="return confirm(\'' . __('Are you sure you want to delete this integration?', 'cftp_admin') . '\')"><i class="fa fa-trash"></i><span class="button_label">' . __('Delete', 'cftp_admin') . '</span></button></form>' . "\n"; } // Create cells array with proper format $tbody_cells = array( array('content' => $name_content), array('content' => $type_content), array('content' => $status_badge), array('content' => $created_content), array('content' => $files_content), array('actions' => true, 'content' => $action_buttons), ); foreach ($tbody_cells as $cell) { $table->addCell($cell); } $table->end_row(); } echo $table->render(); ?> <?php endif; ?> </div> </div> <?php include_once ADMIN_VIEWS_DIR . DS . 'footer.php'; ?> |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |