|
|
|
@ -113,37 +113,43 @@ if ($allowExport) { |
|
|
|
|
|
|
|
|
|
$htmlHeadXtra[] = '<script src="' . $backpack . 'issuer.js"></script>'; |
|
|
|
|
} |
|
|
|
|
$objSkill = new Skill(); |
|
|
|
|
$skills = $objSkill->get($skillId); |
|
|
|
|
$unbakedBadge = api_get_path(SYS_UPLOAD_PATH) . "badges/".$skills['icon']; |
|
|
|
|
|
|
|
|
|
$unbakedBadge = file_get_contents($unbakedBadge); |
|
|
|
|
$badgeInfoError = false; |
|
|
|
|
$personalBadge = ""; |
|
|
|
|
$png = new PNGImageBaker($unbakedBadge); |
|
|
|
|
|
|
|
|
|
if ($png->checkChunks("tEXt", "openbadges")) { |
|
|
|
|
$bakedInfo = $png->addChunk("tEXt", "openbadges", $assertionUrl); |
|
|
|
|
$bakedBadge = UserManager::getUserPathById($userId, "system"); |
|
|
|
|
$bakedBadge = $bakedBadge.'badges'; |
|
|
|
|
if (!file_exists($bakedBadge)) { |
|
|
|
|
mkdir($bakedBadge, api_get_permissions_for_new_directories(), true); |
|
|
|
|
} |
|
|
|
|
$skillRelUserId = $userSkills[0]->getId(); |
|
|
|
|
if (!file_exists($bakedBadge . "/badge_" . $skillRelUserId)) { |
|
|
|
|
file_put_contents($bakedBadge . "/badge_" . $skillRelUserId . ".png", $bakedInfo); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//Process to validate a baked badge |
|
|
|
|
$badgeContent = file_get_contents($bakedBadge . "/badge_" . $skillRelUserId . ".png"); |
|
|
|
|
$verifyBakedBadge = $png->extractBadgeInfo($badgeContent); |
|
|
|
|
if (!is_array($verifyBakedBadge)) { |
|
|
|
|
$badgeInfoError = true; |
|
|
|
|
} |
|
|
|
|
if ($skill->getIcon()) { |
|
|
|
|
$unbakedBadge = file_get_contents( |
|
|
|
|
api_get_path(SYS_UPLOAD_PATH) . "badges/" . $skill->getIcon() |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$png = new PNGImageBaker($unbakedBadge); |
|
|
|
|
|
|
|
|
|
if ($png->checkChunks("tEXt", "openbadges")) { |
|
|
|
|
$bakedInfo = $png->addChunk("tEXt", "openbadges", $assertionUrl); |
|
|
|
|
$bakedBadge = UserManager::getUserPathById($userId, "system") . 'badges'; |
|
|
|
|
|
|
|
|
|
if (!file_exists($bakedBadge)) { |
|
|
|
|
mkdir($bakedBadge, api_get_permissions_for_new_directories(), true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$skillRelUserId = $userSkills[0]->getId(); |
|
|
|
|
|
|
|
|
|
if (!file_exists($bakedBadge . "/badge_" . $skillRelUserId)) { |
|
|
|
|
file_put_contents($bakedBadge . "/badge_" . $skillRelUserId . ".png", $bakedInfo); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//Process to validate a baked badge |
|
|
|
|
$badgeContent = file_get_contents($bakedBadge . "/badge_" . $skillRelUserId . ".png"); |
|
|
|
|
$verifyBakedBadge = $png->extractBadgeInfo($badgeContent); |
|
|
|
|
|
|
|
|
|
if (!is_array($verifyBakedBadge)) { |
|
|
|
|
$badgeInfoError = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!$badgeInfoError) { |
|
|
|
|
$personalBadge = UserManager::getUserPathById($userId, "web"); |
|
|
|
|
$personalBadge = $personalBadge."badges/badge_" . $skillRelUserId . ".png"; |
|
|
|
|
if (!$badgeInfoError) { |
|
|
|
|
$personalBadge = UserManager::getUserPathById($userId, "web"); |
|
|
|
|
$personalBadge = $personalBadge."badges/badge_" . $skillRelUserId . ".png"; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|