/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
- <?php
- /**
- * Test class for Core_Model_User_Service.
- * Generated by PHPUnit on 2011-06-22 at 18:34:04.
- */
- require_once '../Installer.php';
- class Core_Model_Installer {
- public static function install() {
- //create groups
- $group_acls = array();
- $gService = new Core_Model_Group_Service();
-
-
- $everyone = array(
- 'parent' => null,
- 'type' => 0,
- 'title' => 'Everyone',
- 'description' => 'Privileges granted to every user',
- 'visible' => false,
- 'user_count' => 0,
- 'settings' => array());
- $result = $gService->create($everyone);
- Core_Installer::$groupEveryone = $result->id;
- $group_acls[] = array('group' => $result->id, 'module' => 'core', 'controller' => 'error', 'action' => null, 'permission' => 1);
- $group_acls[] = array('group' => $result->id, 'module' => 'core', 'controller' => 'login', 'action' => 'logout', 'permission' => 1);
-
- $owner = array(
- 'parent' => null,
- 'type' => 0,
- 'title' => 'Owner',
- 'description' => 'Privileges granted to the creator of a content item',
- 'visible' => false,
- 'user_count' => 0,
- 'settings' => array());
- $result = $gService->create($owner);
- Core_Installer::$groupOwner = $result->id;
- $group_acls[] = array('group' => $result->id, 'module' => null, 'controller' => null, 'action' => 'edit', 'permission' => 1);
- $group_acls[] = array('group' => $result->id, 'module' => null, 'controller' => null, 'action' => 'delete', 'permission' => 1);
- $guest = array(
- 'parent' => null,
- 'type' => 1,
- 'title' => 'Guests',
- 'description' => 'Users that have not been Authenticated',
- 'visible' => false,
- 'user_count' => 0,
- 'settings' => array());
- $result = $gService->create($guest);
- Core_Installer::$groupGuest = $result->id;
- $group_acls[] = array('group' => $result->id, 'module' => 'core', 'controller' => 'index', 'action' => null, 'permission' => 1);
- $group_acls[] = array('group' => $result->id, 'module' => 'core', 'controller' => 'login', 'action' => null, 'permission' => 1);
- $group_acls[] = array('group' => $result->id, 'module' => 'core', 'controller' => 'index', 'action' => null, 'permission' => 1);
-
-
- $group_acls[] = array('group' => $result->id, 'module' => 'core', 'controller' => 'user', 'action' => 'new', 'permission' => 1);
- $group_acls[] = array('group' => $result->id, 'module' => 'core', 'controller' => 'user', 'action' => 'next-steps', 'permission' => 1);
- $group_acls[] = array('group' => $result->id, 'module' => 'core', 'controller' => 'user', 'action' => 'send-activation', 'permission' => 1);
- $group_acls[] = array('group' => $result->id, 'module' => 'core', 'controller' => 'user', 'action' => 'activate', 'permission' => 1);
- $member = array(
- 'parent' => null,
- 'type' => 1,
- 'title' => 'Members',
- 'description' => 'Authenticated Users',
- 'visible' => true);
- $result = $gService->create($member);
- Core_Installer::$groupMember = $result->id;
- $group_acls[] = array('group' => $result->id, 'module' => 'core', 'controller' => 'index', 'action' => null, 'permission' => 1);
- $group_acls[] = array('group' => $result->id, 'module' => 'core', 'controller' => 'user', 'action' => null, 'permission' => 1);
- // $group_acls[] = array('group' => $result->id, 'module' => 'core', 'controller' => 'login', 'action' => null, 'permission' => 0);
-
- $group_acls[] = array('group' => $result->id, 'module' => 'core', 'controller' => 'gTest', 'action' => 'index', 'permission' => 1);
- $group_acls[] = array('group' => $result->id, 'module' => 'core', 'controller' => 'gTest', 'action' => 'add', 'permission' => 1);
- $group_acls[] = array('group' => $result->id, 'module' => 'core', 'controller' => 'gTest', 'action' => 'edit', 'permission' => 0);
- $group_acls[] = array('group' => $result->id, 'module' => 'core', 'controller' => 'gTest', 'action' => 'edit', 'object' => 1, 'permission' => 1);
- $group_acls[] = array('group' => $result->id, 'module' => 'core', 'controller' => 'gTest', 'action' => 'edit', 'object' => 2, 'permission' => 0);
-
- $contentAdmin = array(
- 'parent' => null,
- 'type' => 1,
- 'title' => 'Admins',
- 'description' => 'Admin Site Content',
- 'visible' => true);
- $result = $gService->create($contentAdmin);
- Core_Installer::$groupContentAdmin = $result->id;
- $siteAdmin = array(
- 'parent' => null,
- 'type' => 1,
- 'title' => 'Site Admins',
- 'description' => 'Full access to Site',
- 'visible' => false);
- $result = $gService->create($siteAdmin);
- Core_Installer::$groupAdmin = $result->id;
- $group_acls[] = array('group' => $result->id, 'module' => null, 'controller' => null, 'action' => null, 'permission' => 1);
- $agService = new Core_Model_Acl_Group_Service();
- foreach ($group_acls as $acl) {
- $agService->create($acl);
- }
- //create user
- $user_acls = array();
-
- $user_auth_internal = array();
- $uService = new Core_Model_User_Service();
- $guest = array(
- 'status' => 1,
- 'primary_group' => Core_Installer::$groupGuest,
- 'username' => 'Guest',
- 'name' => 'Guest',
- 'location' => 'Guest Location',
- 'email' => 'guest@mcdportal.com',
- 'settings' => array());
- $result = $uService->create($guest);
- Core_Installer::$userGuest = $result->id;
- $user = array(
- 'status' => 1,
- 'primary_group' => Core_Installer::$groupMember,
- 'username' => 'TestUser1',
- 'name' => 'Test User',
- 'location' => 'Random',
- 'email' => 'testuser1@mcdportal.com',
- 'settings' => array());
- $result = $uService->create($user);
- Core_Installer::$userMember = $result->id;
-
- $user_auth_internal[] = array('id' => $result->id, 'username' => 'TestUser1', 'password' => 'password');
-
- $user_acls[] = array('user' => $result->id, 'module' => 'core', 'controller' => 'uTest', 'action' => 'index', 'permission' => 1);
- $user_acls[] = array('user' => $result->id, 'module' => 'core', 'controller' => 'uTest', 'action' => 'add', 'permission' => 1);
- $user_acls[] = array('user' => $result->id, 'module' => 'core', 'controller' => 'uTest', 'action' => 'edit', 'permission' => 0);
- $user_acls[] = array('user' => $result->id, 'module' => 'core', 'controller' => 'uTest', 'action' => 'edit', 'object' => 1, 'permission' => 1);
- $user_acls[] = array('user' => $result->id, 'module' => 'core', 'controller' => 'uTest', 'action' => 'edit', 'object' => 2, 'permission' => 0);
- $user = array(
- 'status' => 1,
- 'primary_group' => Core_Installer::$groupMember,
- 'username' => 'TestUser2',
- 'name' => 'Test Special User ',
- 'location' => 'Random',
- 'email' => 'testuser2@mcdportal.com',
- 'settings' => array());
- $result = $uService->create($user);
- Core_Installer::$userSpecialMember = $result->id;
-
- $user_auth_internal[] = array('id' => $result->id, 'username' => 'TestUser2', 'password' => 'password');
-
- $user_acls[] = array('user' => $result->id, 'module' => 'core', 'controller' => 'test', 'action' => 'special', 'permission' => 1);
- $admin = array(
- 'status' => 1,
- 'primary_group' => Core_Installer::$groupContentAdmin,
- 'username' => 'TestAdmin',
- 'name' => 'Test User',
- 'location' => 'Random',
- 'email' => 'testadmin@mcdportal.com',
- 'settings' => array());
- $result = $uService->create($admin);
- Core_Installer::$userAdmin = $result->id;
-
- $user_auth_internal[] = array('id' => $result->id, 'username' => 'TestAdmin', 'password' => 'password');
- $superAdmin = array(
- 'status' => 1,
- 'primary_group' => Core_Installer::$groupAdmin,
- 'username' => 'TestSuperAdmin',
- 'name' => 'Test Super User',
- 'location' => 'Random',
- 'email' => 'testsuperadmin@mcdportal.com',
- 'settings' => array());
- $result = $uService->create($superAdmin);
- Core_Installer::$userSuperAdmin = $result->id;
- $user_auth_internal[] = array('id' => $result->id, 'username' => 'TestSuperAdmin', 'password' => 'password');
- $auService = new Core_Model_Acl_User_Service();
- foreach ($user_acls as $acl) {
- $auService->create($acl);
- }
-
- $aiService = new Core_Model_Auth_Internal();
- foreach ($user_auth_internal as $auth) {
- $aiService->add($auth);
- }
- }
- public static function uninstall() {
- $gService = new Core_Model_Group_Service();
- $gService->deleteAll();
- $agService = new Core_Model_Acl_Group_Service();
- $agService->deleteAll();
- $auService = new Core_Model_Acl_User_Service();
- $auService->deleteAll();
- $uService = new Core_Model_User_Service();
- $uService->deleteAll();
- $umService = new Core_Model_User_Membership_Service();
- $umService->deleteAll();
-
- $authInternal = new Core_Model_Auth_Internal();
- $authInternal->deleteAll();
-
- }
- }