setActiveUser($admin); return true; } static function version() { $core = g2(GalleryCoreApi::loadPlugin("module", "core")); $versions = $core->getInstalledVersions(); return $versions["gallery"]; } static function stats() { GalleryCoreApi::requireOnce("modules/comment/classes/GalleryCommentHelper.class"); $root_album_id = g2(GalleryCoreApi::getDefaultAlbumId()); $stats["users"] = g2(GalleryCoreApi::fetchUserCount()); $stats["groups"] = g2(GalleryCoreApi::fetchGroupCount()); $stats["albums"] = g2(GalleryCoreApi::fetchItemIdCount("GalleryAlbumItem")); $stats["photos"] = g2(GalleryCoreApi::fetchItemIdCount("GalleryPhotoItem")); list (, $stats["comments"]) = g2(GalleryCommentHelper::fetchAllComments($root_album_id, 1)); return $stats; } static function import_group($i) { $map = g2(GalleryCoreApi::fetchGroupNames(1, $i - 1)); $g2_group_id = current(array_keys($map)); $g2_group = g2(GalleryCoreApi::loadEntitiesById($g2_group_id)); if ($g2_group->getGroupType() != GROUP_NORMAL) { return; } try { $group = group::create($g2_group->getGroupName()); } catch (Exception $e) { // @todo For now we assume this is a "duplicate group" exception // which we will ignore. } } static function import_user($i) { $map = g2(GalleryCoreApi::fetchUsersForGroup(GROUP_EVERYBODY, 1, $i - 1)); $g2_user_id = current(array_keys($map)); if (g2(GalleryCoreApi::isAnonymousUser($g2_user_id))) { return; } $g2_user = g2(GalleryCoreApi::loadEntitiesById($g2_user_id)); try { $user = user::create($g2_user->getUserName(), $g2_user->getFullName(), ""); $user->hashed_password = $g2_user->getHashedPassword(); $user->email = $g2_user->getEmail(); $user->language = $g2_user->getLanguage(); $user->save(); } catch (Exception $e) { // @todo For now we assume this is a "duplicate user" exception // which we will ignore. } } }