public function decryptSignature()
 {
     $form = new certCheckSignatureFormGUI();
     if (!$form->checkInput()) {
         ilUtil::sendFailure($this->pl->txt('decrypt_failed'), true);
     }
     $public_key = openssl_get_publickey('file://' . ilCertificateConfig::get('signature_publickey'));
     openssl_public_decrypt(base64_decode($form->getInput('signature')), $decrypted, $public_key);
     if ($decrypted) {
         ilUtil::sendInfo($this->pl->txt('decrypt_successful') . '<br/>' . $decrypted, true);
     } else {
         ilUtil::sendFailure($this->pl->txt('decrypt_failed'), true);
     }
 }
 /**
  * Check permissions
  */
 protected function checkPermission()
 {
     $allowed_roles = ilCertificateConfig::get('roles_administrate_certificate_types');
     return $this->rbac->isAssignedToAtLeastOneGivenRole($this->user->getId(), json_decode($allowed_roles, true));
 }
Example #3
0
?>
<#17>
     <?php 
require_once './Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/Certificate/classes/Definition/class.srCertificateDefinition.php';
srCertificateDefinition::updateDB();
// Migrate from signature table
global $ilDB;
if ($ilDB->tableExists('cert_signature_def')) {
    $set = $ilDB->query('SELECT * FROM cert_signature_def');
    while ($row = $ilDB->fetchObject($set)) {
        /** @var srCertificateDefinition $definition */
        $definition = srCertificateDefinition::find($row->definition_id);
        $definition->setSignatureId($row->signature_id);
        $definition->save();
    }
}
?>
<#18>
<?php 
// Change data-type for longer emails
global $ilDB;
if ($ilDB->tableExists('uihkcertificate_c')) {
    $ilDB->modifyTableColumn('uihkcertificate_c', 'value', array("type" => "clob", "default" => null, "notnull" => false));
}
?>
<#19>
<?php 
require_once './Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/Certificate/classes/class.ilCertificateConfig.php';
ilCertificateConfig::set('jasper_locale', 'de_DE.UTF-8');
ilCertificateConfig::set('jasper_path_java', '/usr/bin/java');
 /**
  * Return all object types where a certificate type can be defined
  *
  * @return array
  */
 public static function getAllAvailableObjectTypes()
 {
     $types = self::$all_available_object_types;
     // crs-tpl is only available if activated in the plugin config
     if (!ilCertificateConfig::get('course_templates')) {
         $key = array_search('crs-tpl', $types);
         unset($types[$key]);
     }
     return $types;
 }
 /**
  * @param array $a_set
  */
 protected function fillRow(array $a_set)
 {
     // For checkboxes in first column
     if (count($this->getOption('actions_multi')) && $a_set['status'] == 3) {
         $this->tpl->setCurrentBlock('CHECKBOXES');
         $this->tpl->setVariable('VALUE', $a_set['id']);
         $this->tpl->parseCurrentBlock();
     } else {
         $this->tpl->setCurrentBlock('COL');
         $this->tpl->setVariable('VALUE', '');
         $this->tpl->parseCurrentBlock();
     }
     $utc = ilCertificateConfig::get('time_format_utc');
     $date_function = $utc ? 'gmdate' : 'date';
     foreach ($this->columns as $k => $column) {
         $value = is_null($a_set[$column]) ? '' : $a_set[$column];
         if ($this->isColumnSelected($column)) {
             // Format dates
             if (in_array($column, array('valid_from', 'valid_to')) && $value != '') {
                 $time = strtotime($value);
                 $time = $utc ? $time + srCertificate::TIME_ZONE_CORRECTION : $time;
                 switch ($this->user->getDateFormat()) {
                     case ilCalendarSettings::DATE_FORMAT_DMY:
                         $value = $date_function('d.m.Y', $time);
                         break;
                     case ilCalendarSettings::DATE_FORMAT_MDY:
                         $value = $date_function('m/d/Y', $time);
                         break;
                 }
             } elseif (in_array($column, array('valid_from', 'valid_to')) && $value == '') {
                 $value = $this->pl->txt('unlimited');
             }
             if ($column == 'status') {
                 $value = $this->pl->txt("cert_status_" . (int) $value);
             }
             // Set value
             $this->tpl->setCurrentBlock('COL');
             $this->tpl->setVariable('VALUE', $value);
             $this->tpl->parseCurrentBlock();
         }
     }
     // Actions
     if (count($this->getOption('actions'))) {
         if ($this->hasAction($a_set)) {
             $this->ctrl->setParameterByClass(get_class($this->parent_obj), 'cert_id', $a_set['id']);
             $this->ctrl->setParameterByClass(get_class($this->parent_obj), 'status', $a_set['status']);
             $async_url = $this->ctrl->getLinkTargetByClass(array(ilCertificatePlugin::getBaseClass(), get_class($this->parent_obj)), 'buildActions', '', true);
             $actions = new ilAdvancedSelectionListGUI();
             $actions->setId('action_list_' . $a_set['id']);
             $actions->setAsynchUrl($async_url);
             $actions->setAsynch(true);
             $actions->setListTitle($this->pl->txt('actions'));
         } else {
             $actions = '&nbsp;';
         }
         $this->tpl->setCurrentBlock('ACTIONS');
         $this->tpl->setVariable('ACTIONS', is_string($actions) ? $actions : $actions->getHTML());
         $this->tpl->parseCurrentBlock();
     }
 }
 /**
  * See formatDate() method
  *
  * @param $identifier
  * @param int $timestamp
  * @return string
  */
 protected function formatDateTime($identifier, $timestamp = 0)
 {
     $timestamp = $timestamp ? $timestamp : time();
     $utc = ilCertificateConfig::get('time_format_utc');
     $format = ilCertificateConfig::get('str_format_datetime');
     // Check if a hook wants to modify the date format
     $format_custom = $this->pl->getHooks()->formatDate($this->certificate, $identifier);
     if ($format_custom) {
         $format = $format_custom;
     }
     $value = $utc ? gmdate($format, $timestamp) : date($format, $timestamp);
     return $value;
 }
 /**
  * @param  ilFormPropertyGUI $item
  */
 private function saveValueForItem($item)
 {
     if (self::checkItem($item)) {
         $key = $item->getPostVar();
         if ($item instanceof ilMultiSelectInputGUI) {
             ilCertificateConfig::set($key, json_encode($this->getInput($key)));
         } else {
             ilCertificateConfig::set($key, $this->getInput($key));
         }
         if (self::checkForSubItem($item)) {
             foreach ($item->getSubItems() as $subitem) {
                 $this->saveValueForItem($subitem);
             }
         }
     }
 }
 /**
  * Check if course is a "template course"
  * This method returns true if the given ref-ID is a children of a category defined in the plugin options
  *
  * @param int $ref_id Ref-ID of the object to check
  * @return bool
  */
 public function isCourseTemplate($ref_id)
 {
     global $tree;
     if (ilCertificateConfig::get('course_templates') && ilCertificateConfig::get('course_templates_ref_ids')) {
         // Course templates enabled -> check if given ref_id is defined as template
         $ref_ids = explode(',', ilCertificateConfig::get('course_templates_ref_ids'));
         /** @var $tree ilTree */
         $parent_ref_id = $tree->getParentId($ref_id);
         return in_array($parent_ref_id, $ref_ids);
     }
     return false;
 }