/** * Module activation hook */ function cloudprime_activate() { try { $db = cloudprime_getDatabase(); // Check if the main table exists $stmt = $db->prepare("SHOW TABLES LIKE 'tenants'"); $stmt->execute(); if ($stmt->rowCount() == 0) { // Tables don't exist, run migration cloudprime_run_simple_migration($db); } return [ 'status' => 'success', 'description' => 'CloudPrime module activated successfully' ]; } catch (Exception $e) { return [ 'status' => 'error', 'description' => 'Module activation failed: ' . $e->getMessage() ]; } } register_hook('ModuleActivated', 1, function($vars) { if ($vars['module'] == 'cloudprime') { return cloudprime_activate(); } });