Skip to content

Commit

Permalink
fix openbasedir issue
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelfolaron committed Aug 29, 2024
1 parent 9b3eb06 commit 3940627
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
34 changes: 17 additions & 17 deletions app/Domain/Projects/Repositories/Projects.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use DateInterval;
use DatePeriod;
use Illuminate\Contracts\Container\BindingResolutionException;
use Illuminate\Support\Facades\Log;
use LasseRafn\InitialAvatarGenerator\InitialAvatar;
use LasseRafn\Initials\Initials;
use Leantime\Core\Configuration\Environment;
Expand Down Expand Up @@ -260,12 +261,12 @@ public function getUserProjects(int $userId, string $projectStatus = "all", int
$query .= " AND project.clientId = :clientId";
}

if($projectTypes != "all" && $projectTypes != "project") {
if ($projectTypes != "all" && $projectTypes != "project") {
$projectTypeIn = DbCore::arrayToPdoBindingString("projectType", count(explode(",", $projectTypes)));
$query .= " AND project.type IN(" . $projectTypeIn . ")";
}

if($projectTypes == "project") {
if ($projectTypes == "project") {
$query .= " AND (project.type = 'project' OR project.type IS NULL)";
}

Expand All @@ -285,13 +286,13 @@ public function getUserProjects(int $userId, string $projectStatus = "all", int
$stmn->bindValue(':clientId', $clientId, PDO::PARAM_STR);
}

if($projectTypes != "all" && $projectTypes != "project") {
if ($projectTypes != "all" && $projectTypes != "project") {
foreach (explode(",", $projectTypes) as $key => $type) {
$stmn->bindValue(":projectType" . $key, $type, PDO::PARAM_STR);
}
}

if($projectTypes == "project") {
if ($projectTypes == "project") {
$query .= " AND (project.type = 'project' OR project.type IS NULL)";
}

Expand Down Expand Up @@ -879,7 +880,6 @@ public function deleteProject($id): void

$stmn->execute();
$stmn->closeCursor();

}

/**
Expand Down Expand Up @@ -1375,37 +1375,38 @@ public function getProjectAvatar($id): array|SVG
$value = $stmn->fetch();
$stmn->closeCursor();
}

$avatar = (new InitialAvatar())
try {
$avatar = (new InitialAvatar())
->fontName("Verdana")
->background('#555555')
->color("#fff");

if(empty($value)){
return $avatar->name("🦄")->generateSvg();
if (empty($value)) {
return $avatar->name("🦄")->generateSvg();
}
} catch (\Exception $e) {
Log::error("Could not generate project avatar.");
Log::error($e);
return array("filename" => "not_found", "type" => "uploaded");
}

if(empty($value['avatar'])) {
if (empty($value['avatar'])) {

/** @var Initials $initialsClass */
$initialsClass = app()->make(Initials::class);
$initialsClass->name($value['name']);
$imagename = $initialsClass->getInitials();

if(!file_exists($filename = APP_ROOT . "/cache/avatars/".$imagename .".svg")){

if (!file_exists($filename = APP_ROOT . "/cache/avatars/" . $imagename . ".svg")) {
$image = $avatar->name($value['name'])->generateSvg();

if(!is_writable(APP_ROOT . "/cache/avatars/")) {
if (!is_writable(APP_ROOT . "/cache/avatars/")) {
return $image;
}

file_put_contents($filename, $image);

}

return array("filename" => $filename, "type" => "generated");

}

$files = app()->make(Files::class);
Expand All @@ -1419,7 +1420,6 @@ public function getProjectAvatar($id): array|SVG
}

return $avatar->name("🦄")->generateSvg();

}
}

Expand Down
4 changes: 3 additions & 1 deletion app/Domain/Users/Repositories/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,7 @@ public function getProfilePicture($id): array|SVG
}

try {

$avatar = (new InitialAvatar())
->fontName("Verdana")
->background('#00a887')
Expand All @@ -729,8 +730,9 @@ public function getProfilePicture($id): array|SVG
if (empty($value)) {
return $avatar->name("👻")->generateSvg();
}

} catch (\Exception $e) {
Log::error("Could not generate avatar.");
Log::error("Could not generate user avatar.");
Log::error($e);
return array("filename" => "not_found", "type" => "uploaded");
}
Expand Down
1 change: 0 additions & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ package: clean build

# Remove DeepL.com and mltranslate engine (not needed in production)
rm -rf $(TARGET_DIR)/vendor/mpdf/mpdf/ttfonts
rm -rf $(TARGET_DIR)/vendor/lasserafn/php-initial-avatar-generator/src/fonts
rm -rf $(TARGET_DIR)/vendor/lasserafn/php-initial-avatar-generator/tests/fonts

# Remove local configuration, if any
Expand Down

0 comments on commit 3940627

Please sign in to comment.