protected function checkUserInTest1(UserAccountModel $user)
 {
     $this->assertEquals("test", $user->getUsername());
     $this->assertEquals("*****@*****.**", $user->getEmail());
     $this->assertEquals(false, $user->checkPassword("1234"));
     $this->assertEquals(true, $user->checkPassword("password"));
     $this->assertEquals(false, $user->getIsEmailVerified());
     $this->assertEquals(false, $user->getIsSystemAdmin());
     $this->assertEquals(true, $user->getIsEditor());
 }
 function __construct(ExtensionManager $extensionManager, $permissions, \models\UserAccountModel $userAccountModel = null, $removeEditorPermissions = false, $includeChildrenPermissions = false)
 {
     if ($userAccountModel) {
         $this->has_user = true;
         $this->has_user_editor = $userAccountModel->getIsEditor();
         $this->has_user_verified = $userAccountModel->getIsEmailVerified();
         $this->has_user_system_administrator = $userAccountModel->getIsSystemAdmin();
     }
     $this->removeEditorPermissions = $removeEditorPermissions;
     $this->permissions = array();
     // Add direct permissions, checking user stats as we do so.
     foreach ($permissions as $permission) {
         $this->addPermission($permission);
     }
     // now add children
     if ($includeChildrenPermissions) {
         $loopCount = 0;
         do {
             $loopCount++;
             $addedAny = false;
             foreach ($extensionManager->getExtensionsIncludingCore() as $extension) {
                 foreach ($extension->getUserPermissions() as $possibleChildID) {
                     $possibleChildPermission = $extension->getUserPermission($possibleChildID);
                     if (!$this->hasPermission($extension->getId(), $possibleChildID)) {
                         $addThisOne = false;
                         foreach ($possibleChildPermission->getParentPermissionsIDs() as $parentData) {
                             if (!$addThisOne && $this->hasPermission($parentData[0], $parentData[1])) {
                                 $addThisOne = true;
                             }
                         }
                         if ($addThisOne) {
                             $this->addPermission($possibleChildPermission);
                             $addedAny = true;
                         }
                     }
                 }
             }
         } while ($addedAny && $loopCount < 100);
     }
 }
 public function getPermissionsForUserInSite(UserAccountModel $userAccountModel = null, SiteModel $siteModel, $removeEditorPermissions = false, $includeChildrenPermissions = false)
 {
     global $DB, $CONFIG;
     if ($userAccountModel) {
         $stat = $DB->prepare("SELECT permission_in_user_group.* FROM permission_in_user_group " . " JOIN user_group_information ON user_group_information.id = permission_in_user_group.user_group_id AND user_group_information.is_deleted = '0' AND user_group_information.is_in_index = '0' " . " JOIN user_group_in_site ON user_group_in_site.user_group_id = user_group_information.id AND user_group_in_site.site_id = :site_id AND user_group_in_site.removed_at IS NULL " . " LEFT JOIN user_in_user_group ON user_in_user_group.user_group_id = user_group_information.id AND user_in_user_group.removed_at IS NULL " . " WHERE permission_in_user_group.removed_at IS NULL AND " . " ( user_in_user_group.user_account_id = :user_account_id OR user_group_information.is_includes_anonymous = '1' OR user_group_information.is_includes_users = '1' " . ($userAccountModel->getIsEmailVerified() ? " OR user_group_information.is_includes_verified_users = '1'  " : "") . " ) ");
         $stat->execute(array('user_account_id' => $userAccountModel->getId(), 'site_id' => $siteModel->getId()));
     } else {
         $stat = $DB->prepare("SELECT permission_in_user_group.* FROM permission_in_user_group " . " JOIN user_group_information ON user_group_information.id = permission_in_user_group.user_group_id AND user_group_information.is_deleted = '0' AND user_group_information.is_in_index = '0' " . " JOIN user_group_in_site ON user_group_in_site.user_group_id = user_group_information.id AND user_group_in_site.site_id = :site_id AND user_group_in_site.removed_at IS NULL " . " WHERE permission_in_user_group.removed_at IS NULL AND user_group_information.is_includes_anonymous = '1' ");
         $stat->execute(array('site_id' => $siteModel->getId()));
     }
     $permissions = array();
     while ($data = $stat->fetch()) {
         $ext = $this->extensionsManager->getExtensionById($data['extension_id']);
         if ($ext) {
             $per = $ext->getUserPermission($data['permission_key']);
             if ($per) {
                 $permissions[] = $per;
             }
         }
     }
     return new \UserPermissionsList($this->extensionsManager, $permissions, $userAccountModel, $CONFIG->siteReadOnly || $removeEditorPermissions, $includeChildrenPermissions);
 }