Example #1
0
 /**
  * Get Documents. Only return documents that the user has access to (i.e. They've either made the document, been assigned to the document, or they're either an Admin or a member of the Throne.)
  * @param User $user
  * @return Document[]
  */
 public static function getDocuments(User $user)
 {
     global $mysqli;
     $docs = array();
     $query = $mysqli->query("SELECT id FROM documents ORDER BY date DESC");
     while ($result = $query->fetch_array()) {
         $doc = new self($result['id']);
         if ($user->getAdmin() || $user->isThrone() || $doc->isCreator($user) || $doc->isAssigned($user)) {
             $docs[] = $doc;
         }
     }
     return $docs;
 }