summaryrefslogtreecommitdiff
path: root/src/web/_model/apps/people.php
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2024-12-23 11:13:27 -0500
committerFreya Murphy <freya@freyacat.org>2024-12-23 11:13:27 -0500
commit5a2ba9c2e7605bb788bc406184547d22c6436867 (patch)
treecbd988d534e8a8593a31d70571222443f80da0b3 /src/web/_model/apps/people.php
parentfix about modal (diff)
downloadxssbook2-5a2ba9c2e7605bb788bc406184547d22c6436867.tar.gz
xssbook2-5a2ba9c2e7605bb788bc406184547d22c6436867.tar.bz2
xssbook2-5a2ba9c2e7605bb788bc406184547d22c6436867.zip
v2.1.0, refactor w/ crimson
Diffstat (limited to 'src/web/_model/apps/people.php')
-rw-r--r--src/web/_model/apps/people.php90
1 files changed, 0 insertions, 90 deletions
diff --git a/src/web/_model/apps/people.php b/src/web/_model/apps/people.php
deleted file mode 100644
index 08366a7..0000000
--- a/src/web/_model/apps/people.php
+++ /dev/null
@@ -1,90 +0,0 @@
-<?php /* Copyright (c) 2024 Freya Murphy */
-class People_model extends Model {
-
- private $request_model;
-
- function __construct($load) {
- parent::__construct($load);
- $this->request_model = $this->load->model('request');
- }
- /**
- * @param mixed $select
- */
- private function get_filted_query($select): DatabaseQuery {
- $filter_type = $this->request_model->get_str('filter', FALSE);
- $filter_uid = $this->request_model->get_int('uid', FALSE);
- $max = $this->request_model->get_int('max', FALSE);
-
- $query = $this->db
- ->select($select)
- ->from('api.user u');
-
- if ($filter_type && $filter_uid) {
- switch ($filter_type) {
- case 'follower': {
- $query = $query
- ->join('xssbook.follow f', 'f.follower_id = u.id AND f.followee_id', 'INNER')
- ->eq($filter_uid)
- ->where('f.value = TRUE');
- } break;
-
- case 'followee': {
- $query = $query
- ->join('xssbook.follow f', 'f.followee_id = u.id AND f.follower_id', 'INNER')
- ->eq($filter_uid)
- ->where('f.value = TRUE');
- } break;
- }
- }
-
- if ($max) {
- $query = $query
- ->where('u.id')
- ->le($max);
- }
-
- return $query;
- }
-
- /**
- * @return array<string,mixed>
- */
- public function get_users(): array {
- $page = $this->request_model->get_int('page', 0);
- $page_size = 24;
- $offset = $page_size * $page;
-
- $users = $this->get_filted_query('u.*')
- ->order_by('u.id', 'DESC')
- ->offset($offset)
- ->limit($page_size)
- ->rows();
-
- $count = $this->get_filted_query('COUNT(u.id) AS count')
- ->row()['count'];
-
- $max = 0;
-
- foreach ($users as $user) {
- $max = max($max, $user['id']);
- }
-
- $filter_type = $this->request_model->get_str('filter', FALSE);
- $filter_uid = $this->request_model->get_int('uid', FALSE);
-
- return array(
- 'users' => $users,
- 'count' => $count,
- 'page_size' => $page_size,
- 'max_id' => $max,
- 'filter_type' => $filter_type || '',
- 'filter_uid' => $filter_uid || ''
- );
- }
-
- public function get_data(): ?array {
- $data = parent::get_data();
- $data['title'] = ucfirst(lang('title'));
- return $data;
- }
-}