58        $this->logger->info(
'START - Save new certificate template');
 
   60        $objId = $certificateTemplate->
getObjId();
 
   62        $id = $this->database->nextId(
'il_cert_template');
 
   67            'id' => array(
'integer', 
$id),
 
   68            'obj_id' => array(
'integer', $objId),
 
   69            'obj_type' => array(
'text', $certificateTemplate->
getObjType()),
 
   73            'version' => array(
'integer', $certificateTemplate->
getVersion()),
 
   74            'ilias_version' => array(
'text', $certificateTemplate->
getIliasVersion()),
 
   76            'currently_active' => array(
'integer', (integer) $certificateTemplate->
isCurrentlyActive()),
 
   78            'deleted' => array(
'integer', (integer) $certificateTemplate->
isDeleted()),
 
   82        $this->database->insert(
'il_cert_template', 
$columns);
 
   84        $this->logger->info(
'END - certificate template saved with columns: ', json_encode(
$columns));
 
   90        $sql = 
'UPDATE il_cert_template SET currently_active = ' . $this->database->quote($currentlyActive, 
'integer') .
 
   91        ' WHERE id = ' . $this->database->quote($certificateTemplate->
getId(), 
'integer');
 
   93        return $this->database->manipulate($sql);
 
   98        $this->logger->info(sprintf(
'START - Fetch certificate template with id: "%s"', $templateId));
 
  103WHERE id = ' . $this->database->quote($templateId, 
'integer') . 
' 
  104ORDER BY version ASC';
 
  106        $query = $this->database->query($sql);
 
  108        while (
$row = $this->database->fetchAssoc(
$query)) {
 
  112        throw new ilException(sprintf(
'No template with id "%s" found', $templateId));
 
  121        $this->logger->info(sprintf(
'START - Fetch multiple certificate templates for object: "%s"', $objId));
 
  128WHERE obj_id = ' . $this->database->quote($objId, 
'integer') . 
' 
  130ORDER BY version ASC';
 
  132        $query = $this->database->query($sql);
 
  134        while (
$row = $this->database->fetchAssoc(
$query)) {
 
  138        $this->logger->info(sprintf(
'END - Fetching of certificate templates for object: "%s" with "%s" results', $objId, count(
$result)));
 
  149        $this->logger->info(sprintf(
'START - Fetch currently active certificate template for object: "%s"', $objId));
 
  151        $this->database->setLimit(1);
 
  154SELECT * FROM il_cert_template 
  155WHERE obj_id = ' . $this->database->quote($objId, 
'integer') . 
' 
  160        $query = $this->database->query($sql);
 
  162        while (
$row = $this->database->fetchAssoc(
$query)) {
 
  163            $this->logger->info(sprintf(
'END - Found active certificate for: "%s"', $objId));
 
  168        $this->logger->info(sprintf(
'END - Found NO active certificate for: "%s"', $objId));
 
  172            $this->objectDataCache->lookUpType($objId),
 
  192        $this->logger->info(sprintf(
'START - Fetch currently active certificate template for object: "%s"', $objId));
 
  195SELECT * FROM il_cert_template 
  196WHERE obj_id = ' . $this->database->quote($objId, 
'integer') . 
' 
  198AND currently_active = 1 
  201        $query = $this->database->query($sql);
 
  203        while (
$row = $this->database->fetchAssoc(
$query)) {
 
  204            $this->logger->info(sprintf(
'END - Found active certificate for: "%s"', $objId));
 
  209        throw new ilException((sprintf(
'NO active certificate template found for: "%s"', $objId)));
 
  220        $this->logger->info(sprintf(
'START - Fetch previous active certificate template for object: "%s"', $objId));
 
  226            $this->objectDataCache->lookUpType($objId),
 
  246        $this->logger->info(sprintf(
'Latest version active certificate template for object: "%s"', $objId));
 
  248        return $resultTemplate;
 
  258        $this->logger->info(sprintf(
'START - Set deleted flag for certificate template("%s") for object: "%s"', $templateId, $objectId));
 
  261UPDATE il_cert_template 
  262SET deleted = 1, currently_active = 0 
  263WHERE id = ' . $this->database->quote($templateId, 
'integer') . 
' 
  264AND obj_id = ' . $this->database->quote($objectId, 
'integer');
 
  266        $this->database->manipulate($sql);
 
  268        $this->logger->info(sprintf(
'END - Deleted flag set fo certificate template("%s") for object: "%s"', $templateId, $objectId));
 
  278        $this->logger->info(sprintf(
'START - Activate previous certificate template for object: "%s"', $objId));
 
  283        $previousCertificate = 
null;
 
  285            if (
null === $previousCertificate) {
 
  287            } elseif ((
int) 
$certificate->getVersion() > (
int) $previousCertificate->getVersion()) {
 
  292        $sql = 
'UPDATE il_cert_template 
  293SET currently_active = 1 
  294WHERE id = ' . $this->database->quote($previousCertificate->getId(), 
'integer');
 
  296        $this->database->manipulate($sql);
 
  298        $this->logger->info(sprintf(
'END - Previous certificate updated for object: "%s"', $objId));
 
  300        return $previousCertificate;
 
  309        $this->logger->info(sprintf(
'START - Fetch all active certificate templates for object type: "%s"', 
$type));
 
  311        $sql = 
'SELECT * FROM il_cert_template WHERE obj_type = ' . $this->database->quote(
$type, 
'text') . 
' 
  312AND currently_active = 1';
 
  313        $query = $this->database->query($sql);
 
  316        while (
$row = $this->database->fetchAssoc(
$query)) {
 
  320        $this->logger->info(sprintf(
'END - All certificate templates for object type: "%s": "%s"', 
$type, json_encode(
$result)));
 
  332        $this->logger->info(sprintf(
'START - Fetch first create certificate template for object: "%s"', $objId));
 
  334        $this->database->setLimit(1, 0);
 
  336        $sql = 
'SELECT * FROM il_cert_template 
  337WHERE obj_id = ' . $this->database->quote($objId, 
'integer') . 
' 
  340        $query = $this->database->query($sql);
 
  342        while (
$row = $this->database->fetchAssoc(
$query)) {
 
  343            $this->logger->info(sprintf(
'END - Found first create certificate template for object: "%s"', $objId));
 
  348        throw new ilException(
'No matching template found. MAY missing DBUpdate. Please check if the correct version is installed.');
 
  357        $this->logger->info(sprintf(
'START - Deactivate previous certificate template for object: "%s"', $objId));
 
  360UPDATE il_cert_template 
  361SET currently_active = 0 
  362WHERE obj_id = ' . $this->database->quote($objId, 
'integer');
 
  364        $this->database->manipulate($sql);
 
  366        $this->logger->info(sprintf(
'END - Certificate template deactivated for object: "%s"', $objId));
 
  378            $row[
'certificate_content'],
 
  379            $row[
'certificate_hash'],
 
  380            $row[
'template_values'],
 
  382            $row[
'ilias_version'],
 
  383            $row[
'created_timestamp'],
 
  384            (
boolean) 
$row[
'currently_active'],
 
  385            $row[
'background_image_path'],
 
  386            $row[
'thumbnail_image_path'],
 
An exception for terminatinating execution or to throw for unit testing.
fetchCurrentlyActiveCertificate(int $objId)
deleteTemplate(int $templateId, int $objectId)
fetchCurrentlyUsedCertificate(int $objId)
fetchPreviousCertificate(int $objId)
Fetch latest created certificate EVEN IF it is deleted.
fetchFirstCreatedTemplate(int $objId)
fetchActiveTemplatesByType(string $type)
__construct(\ilDBInterface $database, \ilLogger $logger=null, \ilObjectDataCache $objectDataCache=null)
fetchCertificateTemplatesByObjId(int $objId)
createCertificateTemplate(array $row)
save(ilCertificateTemplate $certificateTemplate)
deactivatePreviousTemplates(int $objId)
updateActivity(ilCertificateTemplate $certificateTemplate, bool $currentlyActive)
fetchTemplate(int $templateId)
Base class for ILIAS Exception handling.
Component logger with individual log levels by component id.
if(@file_exists(dirname(__FILE__).'/lang/eng.php')) $certificate
if(!array_key_exists('StateId', $_REQUEST)) $id