app_defaults.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. if ($domains_processed == 1) {
  3. //add the permissions
  4. $sql = "delete from v_permissions";
  5. $database = new database;
  6. $database->execute($sql, null);
  7. //get the $apps array from the installed apps from the core and mod directories
  8. $config_list = glob($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/*/*/app_config.php");
  9. $x = 0;
  10. foreach ($config_list as &$config_path) {
  11. include($config_path);
  12. $x++;
  13. }
  14. //restore default permissions
  15. $x = 0;
  16. foreach ($apps as $row) {
  17. if (is_array($row['permissions']) && @sizeof($row['permissions']) != 0) {
  18. foreach ($row['permissions'] as $permission) {
  19. $array['permissions'][$x]['permission_uuid'] = uuid();
  20. $array['permissions'][$x]['permission_name'] = $permission['name'];
  21. $array['permissions'][$x]['application_name'] = $row['name'];
  22. $array['permissions'][$x]['application_uuid'] = $row['uuid'];
  23. $x++;
  24. }
  25. }
  26. }
  27. //save the data to the database
  28. if (is_array($array) && @sizeof($array)) {
  29. //grant temporary permissions
  30. $p = new permissions;
  31. $p->add('permission_add', 'temp');
  32. //execute insert
  33. $database = new database;
  34. $database->app_name = 'permissions';
  35. $database->app_uuid = 'ce1498a0-46e2-487d-85de-4eec7122a984';
  36. $database->save($array);
  37. unset($array);
  38. //revoke temporary permissions
  39. $p->delete('permission_add', 'temp');
  40. }
  41. }
  42. ?>