Fixing phpqrcode autoload. The lib was always loaded no matter what. This need to be fixed in the phpqrcode lib repo. For now we use composer to generate the class map for this library.

skala
Julio Montoya 13 years ago
parent 1df55367aa
commit e3883f43b9
  1. 3
      composer.json
  2. 7
      main/auth/my_progress.php
  3. 31
      main/inc/lib/certificate.lib.php
  4. 6
      main/inc/lib/display.lib.php
  5. 1
      src/ChamiloLMS/Resources/config/prod.php
  6. 2
      vendor/autoload.php
  7. 19
      vendor/composer/autoload_classmap.php
  8. 7
      vendor/composer/autoload_real.php
  9. 4
      vendor/jmontoyaa/phpqrcode/composer.json
  10. 15
      vendor/jmontoyaa/phpqrcode/phpqrcode.php

@ -23,7 +23,8 @@
"main/inc/lib", "main/inc/lib",
"main/install", "main/install",
"main/inc/lib/getid3", "main/inc/lib/getid3",
"main/survey" "main/survey",
"vendor/jmontoyaa/phpqrcode"
] ]
}, },
"repositories": [ "repositories": [

@ -12,7 +12,6 @@ $language_file = array('registration', 'tracking', 'exercice', 'admin', 'learnpa
$cidReset = true; $cidReset = true;
require_once '../inc/global.inc.php'; require_once '../inc/global.inc.php';
require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpath.class.php';
require_once api_get_path(SYS_CODE_PATH).'exercice/exercise.lib.php'; require_once api_get_path(SYS_CODE_PATH).'exercice/exercise.lib.php';
$this_section = SECTION_TRACKING; $this_section = SECTION_TRACKING;
@ -80,7 +79,7 @@ if (!empty($course_user_list)) {
} }
} }
$content .= Tracking::show_user_progress(api_get_user_id()); $content = Tracking::show_user_progress(api_get_user_id());
$content .= Tracking::show_course_detail(api_get_user_id(), $_GET['course'], $_GET['session_id']); $content .= Tracking::show_course_detail(api_get_user_id(), $_GET['course'], $_GET['session_id']);
if (!empty($dates)) { if (!empty($dates)) {
@ -103,12 +102,12 @@ if (!empty($dates)) {
</ul> </ul>
</div></div>'; </div></div>';
} }
$message = null;
if (empty($content)) { if (empty($content)) {
$message = Display::return_message(get_lang('NoDataAvailable'), 'warning'); $message = Display::return_message(get_lang('NoDataAvailable'), 'warning');
} }
$app['title'] = $tool_name; //$app['title'] = $tool_name;
$tpl = $app['template']; $tpl = $app['template'];
$tpl->assign('message', $message); $tpl->assign('message', $message);

@ -5,27 +5,29 @@
* gradebook tool. * gradebook tool.
* @package chamilo.library.certificates * @package chamilo.library.certificates
*/ */
class Certificate extends Model class Certificate extends Model
{ {
var $table; public $table;
var $columns = array('id','cat_id','score_certificate','created_at','path_certificate'); public $columns = array('id','cat_id','score_certificate','created_at','path_certificate');
/** /**
* Certification data * Certification data
*/ */
var $certificate_data = array(); public $certificate_data = array();
/** /**
* Student's certification path * Student's certification path
*/ */
var $certification_user_path = null; public $certification_user_path = null;
var $certification_web_user_path = null; public $certification_web_user_path = null;
var $html_file = null; public $html_file = null;
var $qr_file = null; public $qr_file = null;
var $user_id; public $sys_qr_file = null;
public $user_id;
//If true every time we enter to the certificate URL we would generate a new certificate //If true every time we enter to the certificate URL we would generate a new certificate
// (good thing because we can edit the certificate and all users will have the latest certificate bad because we load the certificate everytime) // (good thing because we can edit the certificate and all users will have the latest certificate bad because we load the certificate everytime)
var $force_certificate_generation = true; //default true public $force_certificate_generation = true; //default true
/** /**
* Constructor * Constructor
@ -65,6 +67,7 @@ class Certificate extends Model
$pathinfo = pathinfo($this->certificate_data['path_certificate']); $pathinfo = pathinfo($this->certificate_data['path_certificate']);
$this->html_file = $this->certification_user_path.basename($this->certificate_data['path_certificate']); $this->html_file = $this->certification_user_path.basename($this->certificate_data['path_certificate']);
$this->qr_file = $this->certification_user_path.$pathinfo['filename'].'_qr.png'; $this->qr_file = $this->certification_user_path.$pathinfo['filename'].'_qr.png';
//$this->sys_qr_file = $this->certification_user_path.$pathinfo['filename'].'_qr.png';
} }
} }
@ -100,7 +103,8 @@ class Certificate extends Model
* the teacher from the gradebook tool to re-generate the certificate because * the teacher from the gradebook tool to re-generate the certificate because
* the original version wa flawed. * the original version wa flawed.
*/ */
public function delete($force_delete = false) { public function delete($force_delete = false)
{
if (!empty($this->certificate_data)) { if (!empty($this->certificate_data)) {
if (!is_null($this->html_file) || $this->html_file != '' || strlen($this->html_file)) { if (!is_null($this->html_file) || $this->html_file != '' || strlen($this->html_file)) {
@ -128,7 +132,7 @@ class Certificate extends Model
} }
/** /**
* Generates an HTML Certificate and fills the path_certificate field in the DB * Generates an HTML Certificate and fills the path_certificate field in the DB
* */ * */
public function generate($params = array()) { public function generate($params = array()) {
@ -187,7 +191,7 @@ class Certificate extends Model
$file_info = pathinfo($path_certificate); $file_info = pathinfo($path_certificate);
$qr_code_filename = $this->certification_user_path.$file_info['filename'].'_qr.png'; $qr_code_filename = $this->certification_user_path.$file_info['filename'].'_qr.png';
$my_new_content_html = str_replace('((certificate_barcode))', Display::img($this->certification_web_user_path.$file_info['filename'].'_qr.png', 'QR'), $new_content_html['content']); $my_new_content_html = str_replace('((certificate_barcode))', Display::img($this->certification_web_user_path.$file_info['filename'].'_qr.png', 'QR', null, false), $new_content_html['content']);
$my_new_content_html = mb_convert_encoding($my_new_content_html,'UTF-8', api_get_system_encoding()); $my_new_content_html = mb_convert_encoding($my_new_content_html,'UTF-8', api_get_system_encoding());
$result = @file_put_contents($my_path_certificate, $my_new_content_html); $result = @file_put_contents($my_path_certificate, $my_new_content_html);
@ -249,7 +253,8 @@ class Certificate extends Model
* @param string Text to be added in the QR code * @param string Text to be added in the QR code
* @param string file path of the image * @param string file path of the image
* */ * */
public function generate_qr($text, $path) { public function generate_qr($text, $path)
{
//Make sure HTML certificate is generated //Make sure HTML certificate is generated
if (!empty($text) && !empty($path)) { if (!empty($text) && !empty($path)) {
//L low, M - Medium, L large error correction //L low, M - Medium, L large error correction

@ -692,11 +692,13 @@ class Display
* @param array additional attributes (for instance height, width, onclick, ...) * @param array additional attributes (for instance height, width, onclick, ...)
* @author Julio Montoya 2010 * @author Julio Montoya 2010
*/ */
public static function img($image_path, $alt_text = '', $additional_attributes = array()) public static function img($image_path, $alt_text = '', $additional_attributes = array(), $applyFilter = true)
{ {
// Sanitizing the parameter $image_path // Sanitizing the parameter $image_path
$image_path = Security::filter_img_path($image_path); if ($applyFilter) {
$image_path = Security::filter_img_path($image_path);
}
// alt text = the image name if there is none provided (for XHTML compliance) // alt text = the image name if there is none provided (for XHTML compliance)
if ($alt_text == '') { if ($alt_text == '') {

@ -44,6 +44,7 @@ $app['temp.paths']->folders[] = _MPDF_TEMP_PATH;
//QR code //QR code
define('QR_CACHE_DIR', $app['temp.path'].'qr'); define('QR_CACHE_DIR', $app['temp.path'].'qr');
define('QR_LOG_DIR', $app['temp.path'].'qr'); define('QR_LOG_DIR', $app['temp.path'].'qr');
$app['temp.paths']->folders[] = QR_CACHE_DIR; $app['temp.paths']->folders[] = QR_CACHE_DIR;
//Chamilo Temp class //Chamilo Temp class

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer' . '/autoload_real.php'; require_once __DIR__ . '/composer' . '/autoload_real.php';
return ComposerAutoloaderInit2db8af3d1b760bc756d3b49e9c2a45bd::getLoader(); return ComposerAutoloaderInit9686e641bdeddab21fbf49db8b6b38e6::getLoader();

@ -190,6 +190,7 @@ return array(
'ForumThreadLink' => $baseDir . '/main/gradebook/lib/be/forumthreadlink.class.php', 'ForumThreadLink' => $baseDir . '/main/gradebook/lib/be/forumthreadlink.class.php',
'ForumTopic' => $baseDir . '/main/coursecopy/classes/ForumTopic.class.php', 'ForumTopic' => $baseDir . '/main/coursecopy/classes/ForumTopic.class.php',
'Frame' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/frame.cls.php', 'Frame' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/frame.cls.php',
'FrameFiller' => $vendorDir . '/jmontoyaa/phpqrcode/phpqrcode.php',
'FrameList' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/frame.cls.php', 'FrameList' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/frame.cls.php',
'FrameListIterator' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/frame.cls.php', 'FrameListIterator' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/frame.cls.php',
'FrameTreeIterator' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/frame.cls.php', 'FrameTreeIterator' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/frame.cls.php',
@ -336,6 +337,7 @@ return array(
'Javascript_Embedder' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/javascript_embedder.cls.php', 'Javascript_Embedder' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/javascript_embedder.cls.php',
'KeyAuth' => $baseDir . '/main/auth/key/key_auth.class.php', 'KeyAuth' => $baseDir . '/main/auth/key/key_auth.class.php',
'LearnpathLink' => $baseDir . '/main/gradebook/lib/be/learnpathlink.class.php', 'LearnpathLink' => $baseDir . '/main/gradebook/lib/be/learnpathlink.class.php',
'LearnpathList' => $baseDir . '/main/newscorm/learnpathList.class.php',
'LegalManager' => $baseDir . '/main/inc/lib/legal.lib.php', 'LegalManager' => $baseDir . '/main/inc/lib/legal.lib.php',
'Link' => $baseDir . '/main/inc/lib/link.lib.php', 'Link' => $baseDir . '/main/inc/lib/link.lib.php',
'LinkAddEditForm' => $baseDir . '/main/gradebook/lib/fe/linkaddeditform.class.php', 'LinkAddEditForm' => $baseDir . '/main/gradebook/lib/fe/linkaddeditform.class.php',
@ -475,6 +477,21 @@ return array(
'Portfolio\\User' => $baseDir . '/main/inc/lib/system/portfolio/user.class.php', 'Portfolio\\User' => $baseDir . '/main/inc/lib/system/portfolio/user.class.php',
'Positioner' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/positioner.cls.php', 'Positioner' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/positioner.cls.php',
'Promotion' => $baseDir . '/main/inc/lib/promotion.lib.php', 'Promotion' => $baseDir . '/main/inc/lib/promotion.lib.php',
'QRbitstream' => $vendorDir . '/jmontoyaa/phpqrcode/qrbitstream.php',
'QRcode' => $vendorDir . '/jmontoyaa/phpqrcode/phpqrcode.php',
'QRencode' => $vendorDir . '/jmontoyaa/phpqrcode/phpqrcode.php',
'QRimage' => $vendorDir . '/jmontoyaa/phpqrcode/qrimage.php',
'QRinput' => $vendorDir . '/jmontoyaa/phpqrcode/phpqrcode.php',
'QRinputItem' => $vendorDir . '/jmontoyaa/phpqrcode/phpqrcode.php',
'QRmask' => $vendorDir . '/jmontoyaa/phpqrcode/phpqrcode.php',
'QRrawcode' => $vendorDir . '/jmontoyaa/phpqrcode/phpqrcode.php',
'QRrs' => $vendorDir . '/jmontoyaa/phpqrcode/phpqrcode.php',
'QRrsItem' => $vendorDir . '/jmontoyaa/phpqrcode/phpqrcode.php',
'QRrsblock' => $vendorDir . '/jmontoyaa/phpqrcode/phpqrcode.php',
'QRspec' => $vendorDir . '/jmontoyaa/phpqrcode/qrspec.php',
'QRsplit' => $vendorDir . '/jmontoyaa/phpqrcode/qrsplit.php',
'QRtools' => $vendorDir . '/jmontoyaa/phpqrcode/phpqrcode.php',
'QRvect' => $vendorDir . '/jmontoyaa/phpqrcode/phpqrcode.php',
'Question' => $baseDir . '/main/exercice/question.class.php', 'Question' => $baseDir . '/main/exercice/question.class.php',
'QuickformElement' => $baseDir . '/main/inc/lib/pear/HTML/QuickForm/Renderer/Object.php', 'QuickformElement' => $baseDir . '/main/inc/lib/pear/HTML/QuickForm/Renderer/Object.php',
'QuickformFlexyElement' => $baseDir . '/main/inc/lib/pear/HTML/QuickForm/Renderer/ObjectFlexy.php', 'QuickformFlexyElement' => $baseDir . '/main/inc/lib/pear/HTML/QuickForm/Renderer/ObjectFlexy.php',
@ -700,7 +717,6 @@ return array(
'langstats' => $baseDir . '/main/cron/lang/langstats.class.php', 'langstats' => $baseDir . '/main/cron/lang/langstats.class.php',
'learnpath' => $baseDir . '/main/newscorm/learnpath.class.php', 'learnpath' => $baseDir . '/main/newscorm/learnpath.class.php',
'learnpathItem' => $baseDir . '/main/newscorm/learnpathItem.class.php', 'learnpathItem' => $baseDir . '/main/newscorm/learnpathItem.class.php',
'LearnpathList' => $baseDir . '/main/newscorm/learnpathList.class.php',
'learnpath_processor' => $baseDir . '/main/inc/lib/search/tool_processors/learnpath_processor.class.php', 'learnpath_processor' => $baseDir . '/main/inc/lib/search/tool_processors/learnpath_processor.class.php',
'lessc' => $vendorDir . '/leafo/lessphp/lessc.inc.php', 'lessc' => $vendorDir . '/leafo/lessphp/lessc.inc.php',
'lessc_formatter_classic' => $vendorDir . '/leafo/lessphp/lessc.inc.php', 'lessc_formatter_classic' => $vendorDir . '/leafo/lessphp/lessc.inc.php',
@ -738,6 +754,7 @@ return array(
'phpCAS' => $baseDir . '/main/auth/cas/lib/CAS.php', 'phpCAS' => $baseDir . '/main/auth/cas/lib/CAS.php',
'phpmailerException' => $baseDir . '/main/inc/lib/phpmailer/class.phpmailer.php', 'phpmailerException' => $baseDir . '/main/inc/lib/phpmailer/class.phpmailer.php',
'phpmailerTest' => $baseDir . '/main/inc/lib/phpmailer/test/phpmailerTest.php', 'phpmailerTest' => $baseDir . '/main/inc/lib/phpmailer/test/phpmailerTest.php',
'qrstr' => $vendorDir . '/jmontoyaa/phpqrcode/qrconst.php',
'quiz_processor' => $baseDir . '/main/inc/lib/search/tool_processors/quiz_processor.class.php', 'quiz_processor' => $baseDir . '/main/inc/lib/search/tool_processors/quiz_processor.class.php',
'scorm' => $baseDir . '/main/newscorm/scorm.class.php', 'scorm' => $baseDir . '/main/newscorm/scorm.class.php',
'scormItem' => $baseDir . '/main/newscorm/scormItem.class.php', 'scormItem' => $baseDir . '/main/newscorm/scormItem.class.php',

@ -2,7 +2,7 @@
// autoload_real.php generated by Composer // autoload_real.php generated by Composer
class ComposerAutoloaderInit2db8af3d1b760bc756d3b49e9c2a45bd class ComposerAutoloaderInit9686e641bdeddab21fbf49db8b6b38e6
{ {
private static $loader; private static $loader;
@ -19,9 +19,9 @@ class ComposerAutoloaderInit2db8af3d1b760bc756d3b49e9c2a45bd
return self::$loader; return self::$loader;
} }
spl_autoload_register(array('ComposerAutoloaderInit2db8af3d1b760bc756d3b49e9c2a45bd', 'loadClassLoader'), true, true); spl_autoload_register(array('ComposerAutoloaderInit9686e641bdeddab21fbf49db8b6b38e6', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(); self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInit2db8af3d1b760bc756d3b49e9c2a45bd', 'loadClassLoader')); spl_autoload_unregister(array('ComposerAutoloaderInit9686e641bdeddab21fbf49db8b6b38e6', 'loadClassLoader'));
$vendorDir = dirname(__DIR__); $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir); $baseDir = dirname($vendorDir);
@ -40,7 +40,6 @@ class ComposerAutoloaderInit2db8af3d1b760bc756d3b49e9c2a45bd
require $vendorDir . '/swiftmailer/swiftmailer/lib/swift_required.php'; require $vendorDir . '/swiftmailer/swiftmailer/lib/swift_required.php';
require $vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier.composer.php'; require $vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier.composer.php';
require $vendorDir . '/jmontoyaa/phpqrcode/qrlib.php';
return $loader; return $loader;
} }

@ -14,6 +14,8 @@
"php": ">=4.3.10" "php": ">=4.3.10"
}, },
"autoload": { "autoload": {
"files": ["qrlib.php"] "classmap": [
"phpqrcode"
]
} }
} }

@ -115,15 +115,16 @@
* Config file, tuned-up for merged verion * Config file, tuned-up for merged verion
*/ */
define('QR_CACHEABLE', false); // use cache - more disk reads but less CPU power, masks and format templates are stored there define('QR_CACHEABLE', false); // use cache - more disk reads but less CPU power, masks and format templates are stored there
define('QR_CACHE_DIR', false); // used when QR_CACHEABLE === true
define('QR_LOG_DIR', false); // default error logs dir
define('QR_FIND_BEST_MASK', true); // if true, estimates best mask (spec. default, but extremally slow; set to false to significant performance boost but (propably) worst quality code if (!defined('QR_CACHE_DIR')) define('QR_CACHE_DIR', false); // used when QR_CACHEABLE === true
define('QR_FIND_FROM_RANDOM', 2); // if false, checks all masks available, otherwise value tells count of masks need to be checked, mask id are got randomly if (!defined('QR_LOG_DIR')) define('QR_LOG_DIR', false); // default error logs dir
define('QR_DEFAULT_MASK', 2); // when QR_FIND_BEST_MASK === false
define('QR_PNG_MAXIMUM_SIZE', 1024); // maximum allowed png image width (in pixels), tune to make sure GD and PHP can handle such big images define('QR_FIND_BEST_MASK', true); // if true, estimates best mask (spec. default, but extremally slow; set to false to significant performance boost but (propably) worst quality code
define('QR_FIND_FROM_RANDOM', 2); // if false, checks all masks available, otherwise value tells count of masks need to be checked, mask id are got randomly
define('QR_DEFAULT_MASK', 2); // when QR_FIND_BEST_MASK === false
define('QR_PNG_MAXIMUM_SIZE', 1024); // maximum allowed png image width (in pixels), tune to make sure GD and PHP can handle such big images

Loading…
Cancel
Save