Ejemplo n.º 1
0
 /**
  * Gets all user limited with page and limit
  *
  * @param  int  $page
  * @param  into $limit
  * @return object
  */
 public function getAll($page = 1, $limit = 40)
 {
     $users = $this->dc->qb()->select('*')->from($this->dc->p($this->config->get('foolz/foolframe', 'foolauth', 'table_name')), 't')->setMaxResults($limit)->setFirstResult($page * $limit - $limit)->execute()->fetchAll();
     $users = User::forge($this->getContext(), $users);
     $count = $this->dc->qb()->select('COUNT(*) as count')->from($this->dc->p($this->config->get('foolz/foolframe', 'foolauth', 'table_name')), 't')->execute()->fetch();
     return ['result' => $users, 'count' => $count['count']];
 }
Ejemplo n.º 2
0
 public function save(array $data = [])
 {
     foreach ($data as $key => $item) {
         $this->{$key} = $item;
     }
     $set = [];
     foreach ($this->editable_fields as $filter) {
         $set[$filter] = $this->{$filter};
     }
     if (!is_null($set['password']) && $set['password'] !== '') {
         $set['password'] = password_hash($set['password'], PASSWORD_BCRYPT, ['cost' => 10]);
     } else {
         unset($set['password']);
     }
     $query = $this->dc->qb()->update($this->dc->p($this->config->get('foolz/foolframe', 'foolauth', 'table_name')))->where('id = :id')->setParameter(':id', $this->id);
     foreach ($set as $key => $item) {
         $query->set($this->dc->getConnection()->quoteIdentifier($key), $this->dc->getConnection()->quote($item));
     }
     $query->execute();
 }
Ejemplo n.º 3
0
 /**
  * Remove the entry for a ban (unban)
  *
  * @return  \Foolz\FoolFuuka\Model\Ban
  */
 public function delete()
 {
     $this->dc->qb()->delete($this->dc->p('banned_posters'))->where('id = :id')->setParameter(':id', $this->id)->execute();
     return $this;
 }