/application/modules/Core/models/Installerold.php

https://github.com/ArchiCroc/Tower-Web-Platform · PHP · 232 lines · 170 code · 55 blank · 7 comment · 0 complexity · 9f425ca49addab624309287b256518bb MD5 · raw file

  1. <?php
  2. /**
  3. * Test class for Core_Model_User_Service.
  4. * Generated by PHPUnit on 2011-06-22 at 18:34:04.
  5. */
  6. require_once '../Installer.php';
  7. class Core_Model_Installer {
  8. public static function install() {
  9. //create groups
  10. $group_acls = array();
  11. $gService = new Core_Model_Group_Service();
  12. $everyone = array(
  13. 'parent' => null,
  14. 'type' => 0,
  15. 'title' => 'Everyone',
  16. 'description' => 'Privileges granted to every user',
  17. 'visible' => false,
  18. 'user_count' => 0,
  19. 'settings' => array());
  20. $result = $gService->create($everyone);
  21. Core_Installer::$groupEveryone = $result->id;
  22. $group_acls[] = array('group' => $result->id, 'module' => 'core', 'controller' => 'error', 'action' => null, 'permission' => 1);
  23. $group_acls[] = array('group' => $result->id, 'module' => 'core', 'controller' => 'login', 'action' => 'logout', 'permission' => 1);
  24. $owner = array(
  25. 'parent' => null,
  26. 'type' => 0,
  27. 'title' => 'Owner',
  28. 'description' => 'Privileges granted to the creator of a content item',
  29. 'visible' => false,
  30. 'user_count' => 0,
  31. 'settings' => array());
  32. $result = $gService->create($owner);
  33. Core_Installer::$groupOwner = $result->id;
  34. $group_acls[] = array('group' => $result->id, 'module' => null, 'controller' => null, 'action' => 'edit', 'permission' => 1);
  35. $group_acls[] = array('group' => $result->id, 'module' => null, 'controller' => null, 'action' => 'delete', 'permission' => 1);
  36. $guest = array(
  37. 'parent' => null,
  38. 'type' => 1,
  39. 'title' => 'Guests',
  40. 'description' => 'Users that have not been Authenticated',
  41. 'visible' => false,
  42. 'user_count' => 0,
  43. 'settings' => array());
  44. $result = $gService->create($guest);
  45. Core_Installer::$groupGuest = $result->id;
  46. $group_acls[] = array('group' => $result->id, 'module' => 'core', 'controller' => 'index', 'action' => null, 'permission' => 1);
  47. $group_acls[] = array('group' => $result->id, 'module' => 'core', 'controller' => 'login', 'action' => null, 'permission' => 1);
  48. $group_acls[] = array('group' => $result->id, 'module' => 'core', 'controller' => 'index', 'action' => null, 'permission' => 1);
  49. $group_acls[] = array('group' => $result->id, 'module' => 'core', 'controller' => 'user', 'action' => 'new', 'permission' => 1);
  50. $group_acls[] = array('group' => $result->id, 'module' => 'core', 'controller' => 'user', 'action' => 'next-steps', 'permission' => 1);
  51. $group_acls[] = array('group' => $result->id, 'module' => 'core', 'controller' => 'user', 'action' => 'send-activation', 'permission' => 1);
  52. $group_acls[] = array('group' => $result->id, 'module' => 'core', 'controller' => 'user', 'action' => 'activate', 'permission' => 1);
  53. $member = array(
  54. 'parent' => null,
  55. 'type' => 1,
  56. 'title' => 'Members',
  57. 'description' => 'Authenticated Users',
  58. 'visible' => true);
  59. $result = $gService->create($member);
  60. Core_Installer::$groupMember = $result->id;
  61. $group_acls[] = array('group' => $result->id, 'module' => 'core', 'controller' => 'index', 'action' => null, 'permission' => 1);
  62. $group_acls[] = array('group' => $result->id, 'module' => 'core', 'controller' => 'user', 'action' => null, 'permission' => 1);
  63. // $group_acls[] = array('group' => $result->id, 'module' => 'core', 'controller' => 'login', 'action' => null, 'permission' => 0);
  64. $group_acls[] = array('group' => $result->id, 'module' => 'core', 'controller' => 'gTest', 'action' => 'index', 'permission' => 1);
  65. $group_acls[] = array('group' => $result->id, 'module' => 'core', 'controller' => 'gTest', 'action' => 'add', 'permission' => 1);
  66. $group_acls[] = array('group' => $result->id, 'module' => 'core', 'controller' => 'gTest', 'action' => 'edit', 'permission' => 0);
  67. $group_acls[] = array('group' => $result->id, 'module' => 'core', 'controller' => 'gTest', 'action' => 'edit', 'object' => 1, 'permission' => 1);
  68. $group_acls[] = array('group' => $result->id, 'module' => 'core', 'controller' => 'gTest', 'action' => 'edit', 'object' => 2, 'permission' => 0);
  69. $contentAdmin = array(
  70. 'parent' => null,
  71. 'type' => 1,
  72. 'title' => 'Admins',
  73. 'description' => 'Admin Site Content',
  74. 'visible' => true);
  75. $result = $gService->create($contentAdmin);
  76. Core_Installer::$groupContentAdmin = $result->id;
  77. $siteAdmin = array(
  78. 'parent' => null,
  79. 'type' => 1,
  80. 'title' => 'Site Admins',
  81. 'description' => 'Full access to Site',
  82. 'visible' => false);
  83. $result = $gService->create($siteAdmin);
  84. Core_Installer::$groupAdmin = $result->id;
  85. $group_acls[] = array('group' => $result->id, 'module' => null, 'controller' => null, 'action' => null, 'permission' => 1);
  86. $agService = new Core_Model_Acl_Group_Service();
  87. foreach ($group_acls as $acl) {
  88. $agService->create($acl);
  89. }
  90. //create user
  91. $user_acls = array();
  92. $user_auth_internal = array();
  93. $uService = new Core_Model_User_Service();
  94. $guest = array(
  95. 'status' => 1,
  96. 'primary_group' => Core_Installer::$groupGuest,
  97. 'username' => 'Guest',
  98. 'name' => 'Guest',
  99. 'location' => 'Guest Location',
  100. 'email' => 'guest@mcdportal.com',
  101. 'settings' => array());
  102. $result = $uService->create($guest);
  103. Core_Installer::$userGuest = $result->id;
  104. $user = array(
  105. 'status' => 1,
  106. 'primary_group' => Core_Installer::$groupMember,
  107. 'username' => 'TestUser1',
  108. 'name' => 'Test User',
  109. 'location' => 'Random',
  110. 'email' => 'testuser1@mcdportal.com',
  111. 'settings' => array());
  112. $result = $uService->create($user);
  113. Core_Installer::$userMember = $result->id;
  114. $user_auth_internal[] = array('id' => $result->id, 'username' => 'TestUser1', 'password' => 'password');
  115. $user_acls[] = array('user' => $result->id, 'module' => 'core', 'controller' => 'uTest', 'action' => 'index', 'permission' => 1);
  116. $user_acls[] = array('user' => $result->id, 'module' => 'core', 'controller' => 'uTest', 'action' => 'add', 'permission' => 1);
  117. $user_acls[] = array('user' => $result->id, 'module' => 'core', 'controller' => 'uTest', 'action' => 'edit', 'permission' => 0);
  118. $user_acls[] = array('user' => $result->id, 'module' => 'core', 'controller' => 'uTest', 'action' => 'edit', 'object' => 1, 'permission' => 1);
  119. $user_acls[] = array('user' => $result->id, 'module' => 'core', 'controller' => 'uTest', 'action' => 'edit', 'object' => 2, 'permission' => 0);
  120. $user = array(
  121. 'status' => 1,
  122. 'primary_group' => Core_Installer::$groupMember,
  123. 'username' => 'TestUser2',
  124. 'name' => 'Test Special User ',
  125. 'location' => 'Random',
  126. 'email' => 'testuser2@mcdportal.com',
  127. 'settings' => array());
  128. $result = $uService->create($user);
  129. Core_Installer::$userSpecialMember = $result->id;
  130. $user_auth_internal[] = array('id' => $result->id, 'username' => 'TestUser2', 'password' => 'password');
  131. $user_acls[] = array('user' => $result->id, 'module' => 'core', 'controller' => 'test', 'action' => 'special', 'permission' => 1);
  132. $admin = array(
  133. 'status' => 1,
  134. 'primary_group' => Core_Installer::$groupContentAdmin,
  135. 'username' => 'TestAdmin',
  136. 'name' => 'Test User',
  137. 'location' => 'Random',
  138. 'email' => 'testadmin@mcdportal.com',
  139. 'settings' => array());
  140. $result = $uService->create($admin);
  141. Core_Installer::$userAdmin = $result->id;
  142. $user_auth_internal[] = array('id' => $result->id, 'username' => 'TestAdmin', 'password' => 'password');
  143. $superAdmin = array(
  144. 'status' => 1,
  145. 'primary_group' => Core_Installer::$groupAdmin,
  146. 'username' => 'TestSuperAdmin',
  147. 'name' => 'Test Super User',
  148. 'location' => 'Random',
  149. 'email' => 'testsuperadmin@mcdportal.com',
  150. 'settings' => array());
  151. $result = $uService->create($superAdmin);
  152. Core_Installer::$userSuperAdmin = $result->id;
  153. $user_auth_internal[] = array('id' => $result->id, 'username' => 'TestSuperAdmin', 'password' => 'password');
  154. $auService = new Core_Model_Acl_User_Service();
  155. foreach ($user_acls as $acl) {
  156. $auService->create($acl);
  157. }
  158. $aiService = new Core_Model_Auth_Internal();
  159. foreach ($user_auth_internal as $auth) {
  160. $aiService->add($auth);
  161. }
  162. }
  163. public static function uninstall() {
  164. $gService = new Core_Model_Group_Service();
  165. $gService->deleteAll();
  166. $agService = new Core_Model_Acl_Group_Service();
  167. $agService->deleteAll();
  168. $auService = new Core_Model_Acl_User_Service();
  169. $auService->deleteAll();
  170. $uService = new Core_Model_User_Service();
  171. $uService->deleteAll();
  172. $umService = new Core_Model_User_Membership_Service();
  173. $umService->deleteAll();
  174. $authInternal = new Core_Model_Auth_Internal();
  175. $authInternal->deleteAll();
  176. }
  177. }