Esempio n. 1
0
 /**
  * Get the most recent posts
  *
  * @param bool $showAll
  * @param int $offset
  * @param int $limit
  * @return array
  */
 public function listPosts(bool $showAll = false, int $offset = 0, int $limit = 20) : array
 {
     if ($showAll) {
         // You're an admin, so you get to see non-public information
         $posts = $this->db->run(\Airship\queryString('blog.posts.list_all', ['offset' => $offset, 'limit' => $limit]));
     } else {
         // Only show posts that are public or owned by one of
         // the authors this user belongs to
         $posts = $this->db->safeQuery(\Airship\queryString('blog.posts.list_mine', ['offset' => $offset, 'limit' => $limit]), [\Airship\LensFunctions\userid()]);
     }
     // Always return an array
     if (empty($posts)) {
         return [];
     }
     return $posts;
 }
Esempio n. 2
0
/**
 * Get the user's public display name.
 *
 * @param int|null $userId
 * @return string
 * @throws \Airship\Alerts\Database\DBException
 */
function user_unique_id(int $userId = null) : string
{
    if (empty($userId)) {
        $userId = \Airship\LensFunctions\userid();
    }
    $db = \Airship\get_database();
    return $db->cell('SELECT uniqueid FROM airship_users WHERE userid = ?', $userId);
}