/** * @param $userId * @param int $pageNumber * * @return Gallery[] */ public static function galleries($userId, $pageNumber = 1) { $beans = R::findAll('gallery', ' user_id = :userId order by name limit :offset, :count', ['userId' => $userId, 'offset' => App::pageOffset($pageNumber), 'count' => App::$pagingSize]); $galleries = []; foreach ($beans as $bean) { $galleries[] = new Gallery($bean->id, $bean); } return $galleries; }
public static function users($pageNumber = 1) { $beans = R::findAll('user', ' order by email limit :offset, :count', ['offset' => App::pageOffset($pageNumber), 'count' => App::$pagingSize]); $users = []; foreach ($beans as $bean) { $users[] = new User($bean->email, $bean); } return $users; }
/** * @param User $user * @param int $pageNumber * @param bool|false $showAll * @return Post[] */ public static function userPosts(User $user, $pageNumber = 1, $showAll = false) { $beans = R::findAll('blog', ' where user_id = :user_id and ( true = :show_all or date(published_on) >= now() ) order by created limit :offset, :count', ['user_id' => $user->bean()->getID(), 'offset' => App::pageOffset($pageNumber), 'count' => App::$pagingSize, 'show_all' => $showAll]); $posts = []; foreach ($beans as $bean) { $posts[] = new Post($bean->name, $bean); } return $posts; }
public static function editableGroups($updatePerms = false, $excludeSuper = false, $pageNumber = 1) { $beans = null; $groups = []; if ($excludeSuper) { $beans = R::find('group', ' is_default_anonymous = 0 and is_default_registered = 0 and is_everyone = 0 and is_super = 0 order by name limit :offset, :count', ['offset' => App::pageOffset($pageNumber), 'count' => App::$pagingSize]); } else { $beans = R::find('group', ' is_default_anonymous = 0 and is_default_registered = 0 and is_everyone = 0 order by name limit :offset, :count', ['offset' => App::pageOffset($pageNumber), 'count' => App::$pagingSize]); } foreach ($beans as $groupBean) { $group = new Group($groupBean->name, $groupBean); $groups[] = $group; if ($updatePerms) { $group->updatePerms(); } } return $groups; }