Minor - format code, replace function names to camelCase

pull/2487/head
jmontoyaa 7 years ago
parent 1b5a9ae1e2
commit e6b6b3fc00
  1. 2
      certificates/index.php
  2. 2
      main/document/document.php
  3. 4
      main/gradebook/lib/be/category.class.php
  4. 13
      main/inc/lib/certificate.lib.php
  5. 72
      main/inc/lib/skill.lib.php

@ -21,7 +21,7 @@ switch ($action) {
$certificate->generate(array('hide_print_button' => true));
if ($certificate->html_file_is_generated()) {
if ($certificate->isHtmlFileGenerated()) {
$certificatePathList[] = $certificate->html_file;
$pdfParams = array(

@ -688,7 +688,7 @@ if (isset($_GET['curdirpath']) && $_GET['curdirpath'] == '/certificates' &&
$qr_code_web_filename = api_get_path(WEB_ARCHIVE_PATH).$filename;
$certificate = new Certificate();
$text = $certificate->parse_certificate_variables($content_html['variables']);
$text = $certificate->parseCertificateVariables($content_html['variables']);
$result = $certificate->generateQRImage($text, $qr_code_filename);
$new_content_html = $content_html['content'];

@ -2179,7 +2179,7 @@ class Category implements GradebookItem
$html = array();
if (!empty($my_certificate)) {
$certificate_obj = new Certificate($my_certificate['id']);
$fileWasGenerated = $certificate_obj->html_file_is_generated();
$fileWasGenerated = $certificate_obj->isHtmlFileGenerated();
if (!empty($fileWasGenerated)) {
$url = api_get_path(WEB_PATH).'certificates/index.php?id='.$my_certificate['id'];
@ -2272,7 +2272,7 @@ class Category implements GradebookItem
foreach ($list_certificate as $value_certificate) {
$certificate_obj = new Certificate($value_certificate['id']);
$certificate_obj->generate(array('hide_print_button' => true));
if ($certificate_obj->html_file_is_generated()) {
if ($certificate_obj->isHtmlFileGenerated()) {
$certificate_path_list[] = $certificate_obj->html_file;
}
}

@ -229,16 +229,16 @@ class Certificate extends Model
$result = @file_put_contents($myPathCertificate, $newContent);
if ($result) {
// Updating the path
self::update_user_info_about_certificate(
self::updateUserCertificateInfo(
$this->certificate_data['cat_id'],
$this->user_id,
$path_certificate
);
$this->certificate_data['path_certificate'] = $path_certificate;
if ($this->html_file_is_generated()) {
if ($this->isHtmlFileGenerated()) {
if (!empty($file_info)) {
$text = $this->parse_certificate_variables(
$text = $this->parseCertificateVariables(
$new_content_html['variables']
);
$this->generateQRImage(
@ -357,7 +357,7 @@ class Certificate extends Model
* @param string $path_certificate the path name of the certificate
* @return void
*/
public function update_user_info_about_certificate(
public function updateUserCertificateInfo(
$cat_id,
$user_id,
$path_certificate
@ -374,12 +374,11 @@ class Certificate extends Model
}
/**
*
* Check if the file was generated
*
* @return boolean
*/
public function html_file_is_generated()
public function isHtmlFileGenerated()
{
if (empty($this->certification_user_path)) {
return false;
@ -416,7 +415,7 @@ class Certificate extends Model
* second is an array of contents
* @return string The translated string
*/
public function parse_certificate_variables($array)
public function parseCertificateVariables($array)
{
$headers = $array[0];
$content = $array[1];

@ -241,9 +241,15 @@ class SkillRelSkill extends Model
* @param bool $user_id
* @return array
*/
public function get_children($skill_id, $load_user_data = false, $user_id = false)
{
$skills = $this->find('all', array('where' => array('parent_id = ? ' => $skill_id)));
public function get_children(
$skill_id,
$load_user_data = false,
$user_id = false
) {
$skills = $this->find(
'all',
array('where' => array('parent_id = ? ' => $skill_id))
);
$skill_obj = new Skill();
$skill_rel_user = new SkillRelUser();
@ -325,6 +331,9 @@ class SkillRelGradebook extends Model
{
public $columns = array('id', 'gradebook_id', 'skill_id');
/**
* SkillRelGradebook constructor.
*/
public function __construct()
{
$this->table = Database::get_main_table(TABLE_MAIN_SKILL_REL_GRADEBOOK);
@ -382,7 +391,7 @@ class SkillRelGradebook extends Model
* @param int $skill_id
* @param array $gradebook_list
*/
public function update_gradebooks_by_skill($skill_id, $gradebook_list)
public function updateGradeBookListBySkill($skill_id, $gradebook_list)
{
$original_gradebook_list = $this->find(
'all',
@ -419,7 +428,10 @@ class SkillRelGradebook extends Model
if (!empty($gradebooks_to_add)) {
foreach ($gradebooks_to_add as $gradebook_id) {
$attributes = array('skill_id' => $skill_id, 'gradebook_id' => $gradebook_id);
$attributes = array(
'skill_id' => $skill_id,
'gradebook_id' => $gradebook_id
);
$this->save($attributes);
}
}
@ -634,7 +646,8 @@ class Skill extends Model
$skill_list = array_map('intval', $skill_list);
$skill_list = implode("', '", $skill_list);
$sql = "SELECT * FROM {$this->table} WHERE id IN ('$skill_list') ";
$sql = "SELECT * FROM {$this->table}
WHERE id IN ('$skill_list') ";
$result = Database::query($sql);
$users = Database::store_result($result, 'ASSOC');
@ -644,7 +657,10 @@ class Skill extends Model
continue;
}
$user['icon_small'] = sprintf("badges/%s-small.png", sha1($user['name']));
$user['icon_small'] = sprintf(
"badges/%s-small.png",
sha1($user['name'])
);
}
return $users;
@ -657,8 +673,12 @@ class Skill extends Model
* @param int $parent_id
* @return array
*/
public function get_all($load_user_data = false, $user_id = false, $id = null, $parent_id = null)
{
public function get_all(
$load_user_data = false,
$user_id = false,
$id = null,
$parent_id = null
) {
$id_condition = '';
if (!empty($id)) {
$id = intval($id);
@ -743,7 +763,7 @@ class Skill extends Model
$skill_rel_skill = new SkillRelSkill();
if ($load_user_data) {
$user_id = api_get_user_id();
$skills = $skill_rel_skill->get_children($skill_id, true, $user_id);
$skills = $skill_rel_skill->get_children($skill_id, true, $user_id);
} else {
$skills = $skill_rel_skill->get_children($skill_id);
}
@ -824,8 +844,8 @@ class Skill extends Model
$relation_exists = $skill_rel_skill->relation_exists($skill_id, $parent_id);
if (!$relation_exists) {
$attributes = array(
'skill_id' => $skill_id,
'parent_id' => $parent_id,
'skill_id' => $skill_id,
'parent_id' => $parent_id,
'relation_type' => (isset($params['relation_type']) ? $params['relation_type'] : 0),
//'level' => $params['level'],
);
@ -837,7 +857,7 @@ class Skill extends Model
foreach ($params['gradebook_id'] as $gradebook_id) {
$attributes = array();
$attributes['gradebook_id'] = $gradebook_id;
$attributes['skill_id'] = $skill_id;
$attributes['skill_id'] = $skill_id;
$skill_rel_gradebook->save($attributes);
}
}
@ -913,7 +933,7 @@ class Skill extends Model
if (!isset($params['parent_id'])) {
$params['parent_id'] = 1;
}
$skill_rel_skill = new SkillRelSkill();
$skill_rel_skill = new SkillRelSkill();
$skill_rel_gradebook = new SkillRelGradebook();
//Saving name, description
@ -932,8 +952,8 @@ class Skill extends Model
$relation_exists = $skill_rel_skill->relation_exists($skill_id, $parent_id);
if (!$relation_exists) {
$attributes = array(
'skill_id' => $skill_id,
'parent_id' => $parent_id,
'skill_id' => $skill_id,
'parent_id' => $parent_id,
'relation_type' => $params['relation_type'],
//'level' => $params['level'],
);
@ -941,7 +961,10 @@ class Skill extends Model
}
}
$skill_rel_gradebook->update_gradebooks_by_skill($skill_id, $params['gradebook_id']);
$skill_rel_gradebook->updateGradeBookListBySkill(
$skill_id,
$params['gradebook_id']
);
return $skill_id;
}
return null;
@ -955,14 +978,14 @@ class Skill extends Model
*
* @return array
*/
public function get_user_skills($user_id, $get_skill_data = false)
public function get_user_skills($userId, $get_skill_data = false)
{
$user_id = intval($user_id);
$userId = intval($userId);
$sql = 'SELECT DISTINCT s.id, s.name, s.icon, u.id as issue
FROM '.$this->table_skill_rel_user.' u
INNER JOIN '.$this->table.' s
ON u.skill_id = s.id
WHERE user_id = '.$user_id;
WHERE user_id = '.$userId;
$result = Database::query($sql);
$skills = Database::store_result($result, 'ASSOC');
@ -1071,7 +1094,6 @@ class Skill extends Model
}
$skill['data']['name'] = $skill['name'];
$skill['data']['status'] = $skill['status'];
// In order to paint all members of a family with the same color
@ -1083,7 +1105,6 @@ class Skill extends Model
if ($skill['parent_id'] == $skill_id) {
$family[$skill['id']] = $this->get_all_children($skill['id']);
}
/*if ($skill_id == $skill['id']) {
$skill['parent_id'] = 1;
}*/
@ -1211,7 +1232,11 @@ class Skill extends Model
$tmp['isSearched'] = self::isSearched($elem['id']);
if (isset($elem['children']) && is_array($elem['children'])) {
$tmp['children'] = $this->get_skill_json($elem['children'], $depth + 1, $max_depth);
$tmp['children'] = $this->get_skill_json(
$elem['children'],
$depth + 1,
$max_depth
);
} else {
//$tmp['colour'] = $this->colours[$depth][rand(0,3)];
}
@ -1580,7 +1605,6 @@ class Skill extends Model
break;
case STUDENT_BOSS:
$studentBosses = $userRepo->getStudentBosses($toUser);
foreach ($studentBosses as $studentBoss) {
if ($studentBoss->getId() !== $fromUser->getId()) {
continue;

Loading…
Cancel
Save