From 9c38ce97b318eecc57bfbffc6437ea68e5c90ec5 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 16 Aug 2011 10:59:57 +0200 Subject: [PATCH] Fixing warning message in certificates/index.php --- main/inc/lib/certificate.lib.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/main/inc/lib/certificate.lib.php b/main/inc/lib/certificate.lib.php index 33542b2445..ebde4b5594 100644 --- a/main/inc/lib/certificate.lib.php +++ b/main/inc/lib/certificate.lib.php @@ -17,6 +17,8 @@ class Certificate extends Model { var $certification_web_user_path = null; var $user_id; + var $force_certificate_generation = false; //If true every time we enter to the certificate URL we would generate a new certificate + public function __construct($certificate_id = null) { $this->table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE); $this->certificate_data = null; @@ -35,7 +37,9 @@ class Certificate extends Model { $this->check_certificate_path(); //To force certification generation - $this->generate(); + if ($this->force_certificate_generation) { + $this->generate(); + } if (isset($this->certificate_data) && $this->certificate_data) { if (empty($this->certificate_data['path_certificate'])) { @@ -96,10 +100,10 @@ class Certificate extends Model { * */ public function generate() { - $always_generate = false; // For test purposes + //The user directory should be set - if (empty($this->certification_user_path) && $always_generate == false) { + if (empty($this->certification_user_path) && $this->force_certificate_generation == false) { return false; } require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be.inc.php'; @@ -107,7 +111,7 @@ class Certificate extends Model { require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/scoredisplay.class.php'; $my_category = Category :: load($this->certificate_data['cat_id']); - if ($my_category[0]->is_certificate_available($this->user_id)) { + if (isset($my_category[0]) && $my_category[0]->is_certificate_available($this->user_id)) { $user = api_get_user_info($this->user_id); $scoredisplay = ScoreDisplay :: instance(); @@ -137,7 +141,7 @@ class Certificate extends Model { if ($cat_id = strval(intval($this->certificate_data['cat_id']))) { $name = $this->certificate_data['path_certificate']; $my_path_certificate = $this->certification_user_path.basename($name); - if (file_exists($my_path_certificate) && !empty($name) && !is_dir($my_path_certificate) && $always_generate == false) { + if (file_exists($my_path_certificate) && !empty($name) && !is_dir($my_path_certificate) && $this->force_certificate_generation == false) { //Seems that the file was already generated return true; } else {