public function Authors($userId)
 {
     $userAuthorsFolder = Settings::getInstance()->p['userAuthorsFolder'];
     $UserHandler = new UsersDatabaseHandler();
     $User = $UserHandler->UserById($userId);
     if ($User == null) {
         throw new RestException(401, "Unauthorized");
     }
     $sql = "SELECT AuthorId, Name, UniqueName, Image FROM Author WHERE UserId = {$userId} AND Active = true ORDER BY Name";
     $result = $this->mysqli->query($sql) or die($authIssueText);
     $recordsCount = mysqli_num_rows($result);
     $authors = array();
     if ($recordsCount >= 1 && $result != null) {
         while ($row = mysqli_fetch_array($result)) {
             $imageUrl = strlen($row[Image]) > 0 ? parent::GetImageUrl($userId, $row[Image], $userAuthorsFolder) : "";
             $imageThumbnailUrl = strlen($row[Image]) > 0 ? parent::GetImageUrl($userId, $row[Image], $userAuthorsFolder, true) : "";
             $authors[] = array('AuthorId' => intval($row['AuthorId']), 'UniqueName' => $row['UniqueName'], 'Name' => $row['Name'], 'Image' => $imageUrl, 'Thumbnail' => $imageThumbnailUrl);
         }
     }
     return $authors;
 }
 public function CreateArticle($Title, $UserId)
 {
     global $authIssueText;
     $UsersHandler = new UsersDatabaseHandler();
     $User = $UsersHandler->UserById($UserId);
     $Language = $User['Language'];
     $sql = "INSERT INTO Article (Title, UserId, CreationDateTime, Language) ";
     $sql .= "VALUES(\"" . $this->mysqli->real_escape_string($Title) . "\", {$UserId}, '" . time() . "', \"{$Language}\")";
     $result = $this->mysqli->query($sql) or die($authIssueText);
     return $result;
 }
 private function UnlinkRemovedUserImages($userId, $image)
 {
     $userUserFolder = Settings::getInstance()->p['userUserFolder'];
     $imageFileToRemove = "../../" . parent::GetImageUrl($userId, $image, $userUserFolder, false, false);
     $imageThumbnailFileToRemove = "../../" . parent::GetImageUrl($userId, $image, $userUserFolder, true, false);
     if (strlen($image) > 0) {
         if (file_exists($imageFileToRemove)) {
             unlink($imageFileToRemove);
         }
         if (file_exists($imageThumbnailFileToRemove)) {
             unlink($imageThumbnailFileToRemove);
         }
     }
 }
 function CreateEvent($Title, $UserId)
 {
     global $authIssueText;
     $UsersHandler = new UsersDatabaseHandler();
     $User = $UsersHandler->UserById($UserId);
     $Language = $User['Language'];
     $sql = "INSERT INTO Event (Title, UserId, CreationDateTime, Language) ";
     $sql .= "VALUES('{$Title}', {$UserId}, '" . time() . "', '{$Language}')";
     $result = $this->mysqli->query($sql) or die($authIssueText);
     return $result;
 }