Add phpdoc and change headers functions

pull/2525/head
Nosolored 8 years ago
parent 4cd1339b30
commit 51b8cfe13f
  1. 2
      certificates/index.php
  2. 25
      plugin/customcertificate/src/CustomCertificatePlugin.php
  3. 23
      plugin/customcertificate/src/index.php

@ -10,7 +10,7 @@ require_once '../main/inc/global.inc.php';
$action = isset($_GET['action']) ? $_GET['action'] : null;
$certificate = new Certificate($_GET['id']);
CustomCertificatePlugin::redirectCheck($certificate, intval($_GET['id']));
CustomCertificatePlugin::redirectCheck($certificate, $_GET['id']);
switch ($action) {
case 'export':

@ -15,16 +15,19 @@ class CustomCertificatePlugin extends Plugin
// When creating a new course this settings are added to the course
public $course_settings = [
[
'name' => 'customcertificate_course_enable',
'type' => 'checkbox',
],
[
'name' => 'use_certificate_default',
'type' => 'checkbox',
],
[
'name' => 'customcertificate_course_enable',
'type' => 'checkbox',
],
[
'name' => 'use_certificate_default',
'type' => 'checkbox',
],
];
/**
* Constructor.
*/
protected function __construct()
{
parent::__construct(
@ -39,6 +42,10 @@ class CustomCertificatePlugin extends Plugin
}
/**
* Instance the plugin.
*
* @staticvar null $result
*
* @return CustomCertificatePlugin
*/
public static function create()
@ -190,7 +197,7 @@ class CustomCertificatePlugin extends Plugin
/**
* Get certificate data.
*
* @param Certificate $id The certificate
* @param int $id The certificate
*
* @return array
*/

@ -125,9 +125,6 @@ if ($enable) {
}
// Image manager
$base = api_get_path(SYS_UPLOAD_PATH);
$pathCertificates = $base.'certificates';
$fieldList = [
'logo_left',
'logo_center',
@ -146,8 +143,7 @@ if ($enable) {
checkInstanceImage(
$certificateId,
$infoCertificate[$field],
$field,
$pathCertificates
$field
);
}
@ -170,8 +166,6 @@ if ($enable) {
// Certificate Default
if (intval($formValues['use_default'] == 1)) {
$base = api_get_path(SYS_UPLOAD_PATH);
$infoCertificateDefault = Database::select(
'*',
$table,
@ -921,14 +915,25 @@ if ($enable) {
api_not_allowed(true, $plugin->get_lang('ToolDisabled'));
}
function checkInstanceImage($certificateId, $imagePath, $field, $path)
/**
* Delete the file if there is only one instance.
*
* @param int $certificateId
* @param string $imagePath
* @param string $field
* @param string $type
*/
function checkInstanceImage($certificateId, $imagePath, $field, $type = 'certificates')
{
$table = Database::get_main_table(CustomCertificatePlugin::TABLE_CUSTOMCERTIFICATE);
$imagePath = Database::escape_string($imagePath);
$sql = "SELECT * FROM $table WHERE $field = '$imagePath'";
$res = Database::query($sql);
if (Database::num_rows($res) == 1) {
@unlink($path.$imagePath);
api_remove_uploaded_file($type, $imagePath);
}
$sql = "UPDATE $table SET $field = '' WHERE id = $certificateId";
Database::query($sql);
}

Loading…
Cancel
Save