Example #1
0
 /**
  * Find a Document. If the provided id couldn't be found, return false. Otherwise, return the document (if the user has proper access).
  * @param int $id
  * @param User $user
  * @return boolean|Document
  */
 public static function find($id, User $user)
 {
     global $mysqli;
     $query = $mysqli->query("SELECT id FROM documents WHERE id = {$id}");
     if (self::doesExist($id)) {
         $result = $query->fetch_array();
         $doc = new self($result['id']);
         if ($user->getAdmin() || $user->isThrone() || $doc->isCreator($user) || $doc->isAssigned($user) || $doc->checkClearance($user)) {
             return $doc;
         }
     }
     return false;
 }