is removed from value.
-
if (!($url = trim($linkdata['url'])) || !($title = trim($linkdata['title']))) {
return 0; // 0 = fail
}
diff --git a/main/inc/lib/plugin.class.php b/main/inc/lib/plugin.class.php
index 5400ffbdbd..c9d9ed5aa3 100755
--- a/main/inc/lib/plugin.class.php
+++ b/main/inc/lib/plugin.class.php
@@ -226,7 +226,7 @@ class Plugin
switch ($type) {
case 'html':
- $result->addElement('html', $this->get_lang($name));
+ $result->addHtml($this->get_lang($name));
break;
case 'wysiwyg':
$result->addHtmlEditor($name, $this->get_lang($name), false);
@@ -872,7 +872,11 @@ class Plugin
{
$settings = api_get_settings_params_simple(
array(
- "subkey = ? AND category = ? AND type = ? AND variable = 'status' " => array($this->get_name(), 'Plugins', 'setting')
+ "subkey = ? AND category = ? AND type = ? AND variable = 'status' " => array(
+ $this->get_name(),
+ 'Plugins',
+ 'setting',
+ )
)
);
if (is_array($settings) && isset($settings['selected_value']) && $settings['selected_value'] == 'installed') {
diff --git a/main/inc/lib/plugin.lib.php b/main/inc/lib/plugin.lib.php
index 03de66cb27..df05a3bc47 100755
--- a/main/inc/lib/plugin.lib.php
+++ b/main/inc/lib/plugin.lib.php
@@ -29,8 +29,8 @@ class AppPlugin
'course_tool_plugin'
);
- public $installedPluginListName = array();
- public $installedPluginListObject = array();
+ public $installedPluginListName = [];
+ public $installedPluginListObject = [];
/**
* Constructor
@@ -47,7 +47,7 @@ class AppPlugin
{
/* We scan the plugin directory. Each folder is a potential plugin. */
$pluginPath = api_get_path(SYS_PLUGIN_PATH);
- $plugins = array();
+ $plugins = [];
$handle = @opendir($pluginPath);
while (false !== ($file = readdir($handle))) {
if ($file != '.' && $file != '..' && is_dir(api_get_path(SYS_PLUGIN_PATH).$file)) {
@@ -65,7 +65,7 @@ class AppPlugin
*/
public function get_installed_plugins_by_region()
{
- $plugins = array();
+ $plugins = [];
/* We retrieve all the active plugins. */
$result = api_get_settings('Plugins');
if (!empty($result)) {
@@ -106,7 +106,7 @@ class AppPlugin
public function setInstalledPluginListObject()
{
$pluginListName = $this->getInstalledPluginListName();
- $pluginList = array();
+ $pluginList = [];
if (!empty($pluginListName)) {
foreach ($pluginListName as $pluginName) {
$pluginInfo = $this->getPluginInfo($pluginName);
@@ -123,7 +123,7 @@ class AppPlugin
*/
public function get_installed_plugins()
{
- $installedPlugins = array();
+ $installedPlugins = [];
$plugins = api_get_settings_params(
array(
"variable = ? AND selected_value = ? AND category = ? " => array('status', 'installed', 'Plugins')
@@ -208,7 +208,7 @@ class AppPlugin
public function get_areas_by_plugin($pluginName)
{
$result = api_get_settings('Plugins');
- $areas = array();
+ $areas = [];
foreach ($result as $row) {
if ($pluginName == $row['selected_value']) {
$areas[] = $row['variable'];
@@ -369,7 +369,7 @@ class AppPlugin
if (isset($_template)) {
$_template['plugin_info'] = $plugin_info;
} else {
- $_template = array();
+ $_template = [];
$_template['plugin_info'] = $plugin_info;
}
@@ -377,7 +377,7 @@ class AppPlugin
$template->assign($plugin_name, $_template);
// Loading the Twig template plugin files if exists
- $template_list = array();
+ $template_list = [];
if (isset($plugin_info) && isset($plugin_info['templates'])) {
$template_list = $plugin_info['templates'];
}
@@ -415,7 +415,7 @@ class AppPlugin
} else {
$plugin_file = api_get_path(SYS_PLUGIN_PATH)."$plugin_name/plugin.php";
- $plugin_info = array();
+ $plugin_info = [];
if (file_exists($plugin_file)) {
require $plugin_file;
}
@@ -433,7 +433,7 @@ class AppPlugin
)
);
- $settings_filtered = array();
+ $settings_filtered = [];
foreach ($plugin_settings as $item) {
if (!empty($item['selected_value'])) {
if (@unserialize($item['selected_value']) !== false) {
@@ -576,7 +576,7 @@ class AppPlugin
');
- $groups = array();
+ $groups = [];
foreach ($obj->course_settings as $setting) {
if ($obj->validateCourseSetting($setting['name']) === false) {
continue;
@@ -621,7 +621,7 @@ class AppPlugin
{
$pluginList = $this->getInstalledPluginListObject();
/** @var Plugin $obj */
- $courseSettings = array();
+ $courseSettings = [];
if (!empty($pluginList)) {
foreach ($pluginList as $obj) {
$pluginCourseSetting = $obj->getCourseSettings();
@@ -644,8 +644,7 @@ class AppPlugin
/** @var Plugin $obj */
foreach ($pluginList as $obj) {
$settings = $obj->getCourseSettings();
-
- $subValues = array();
+ $subValues = [];
if (!empty($settings)) {
foreach ($settings as $v) {
if (isset($values[$v])) {
diff --git a/main/inc/lib/search/xapian/XapianIndexer.class.php b/main/inc/lib/search/xapian/XapianIndexer.class.php
index 2698891c5f..39790c728e 100755
--- a/main/inc/lib/search/xapian/XapianIndexer.class.php
+++ b/main/inc/lib/search/xapian/XapianIndexer.class.php
@@ -235,7 +235,8 @@ abstract class XapianIndexer
if ($this->db == null) {
$this->connectDb();
}
- if (is_numeric($did) && $did > 0) {
+ $did = (int) $did;
+ if ($did > 0) {
$doc = $this->get_document($did);
if ($doc !== false) {
$this->db->delete_document($did);
diff --git a/main/inc/lib/security.lib.php b/main/inc/lib/security.lib.php
index 64e22c8d85..5a94dfaf50 100755
--- a/main/inc/lib/security.lib.php
+++ b/main/inc/lib/security.lib.php
@@ -167,7 +167,7 @@ class Security
/**
* Checks the user agent of the client as recorder by get_ua() to prevent
* most session hijacking attacks.
- * @return bool True if the user agent is the same, false otherwise
+ * @return bool True if the user agent is the same, false otherwise
*/
public static function check_ua()
{
@@ -197,7 +197,7 @@ class Security
* the one that sent this form in knowingly (this form hasn't been generated from
* another website visited by the user at the same time).
* Check the token with check_token()
- * @return string Hidden-type input ready to insert into a form
+ * @return string Hidden-type input ready to insert into a form
*/
public static function get_HTML_token()
{
@@ -215,7 +215,7 @@ class Security
* the one that sent this form in knowingly (this form hasn't been generated from
* another website visited by the user at the same time).
* Check the token with check_token()
- * @return string Token
+ * @return string Token
*/
public static function get_token()
{
@@ -438,9 +438,11 @@ class Security
}
/**
- * This method provides specific protection (against XSS and other kinds of attacks) for static images (icons) used by the system.
- * Image paths are supposed to be given by programmers - people who know what they do, anyway, this method encourages
- * a safe practice for generating icon paths, without using heavy solutions based on HTMLPurifier for example.
+ * This method provides specific protection (against XSS and other kinds of attacks)
+ * for static images (icons) used by the system.
+ * Image paths are supposed to be given by programmers - people who know what they do, anyway,
+ * this method encourages a safe practice for generating icon paths, without using heavy solutions
+ * based on HTMLPurifier for example.
* @param string $img_path The input path of the image, it could be relative or absolute URL.
* @return string Returns sanitized image path or an empty string when the image path is not secure.
* @author Ivan Tcholakov, March 2011
diff --git a/main/inc/lib/skill.lib.php b/main/inc/lib/skill.lib.php
index 44ce654275..9f902a45e0 100755
--- a/main/inc/lib/skill.lib.php
+++ b/main/inc/lib/skill.lib.php
@@ -132,7 +132,7 @@ class SkillRelProfile extends Model
{
$profileId = intval($profileId);
$skills = $this->get_all(array('where' => array('profile_id = ? ' => $profileId)));
- $return = array();
+ $return = [];
if (!empty($skills)) {
foreach ($skills as $skill_data) {
$return[] = $skill_data['skill_id'];
@@ -184,7 +184,7 @@ class SkillRelSkill extends Model
public function getSkillInfo($id)
{
if (empty($id)) {
- return array();
+ return [];
}
$result = Database::select(
'*',
@@ -212,7 +212,7 @@ class SkillRelSkill extends Model
$skill = Database::store_result($result, 'ASSOC');
$skill = isset($skill[0]) ? $skill[0] : null;
- $parents = array();
+ $parents = [];
if (!empty($skill)) {
if ($skill['parent_id'] != null) {
$parents = self::getSkillParents($skill['parent_id']);
@@ -237,7 +237,7 @@ class SkillRelSkill extends Model
$result = Database::query($sql);
$skill = Database::store_result($result, 'ASSOC');
$skill = isset($skill[0]) ? $skill[0] : null;
- $parents = array();
+ $parents = [];
if (!empty($skill)) {
$parents[] = $skill;
}
@@ -271,7 +271,7 @@ class SkillRelSkill extends Model
if ($load_user_data) {
$passed_skills = $skill_rel_user->getUserSkills($user_id);
- $done_skills = array();
+ $done_skills = [];
foreach ($passed_skills as $done_skill) {
$done_skills[] = $done_skill['skill_id'];
}
@@ -385,7 +385,7 @@ class SkillRelGradebook extends Model
public function getSkillInfo($skill_id, $gradebookId)
{
if (empty($skill_id)) {
- return array();
+ return [];
}
$result = Database::select(
'*',
@@ -413,9 +413,9 @@ class SkillRelGradebook extends Model
'all',
array('where' => array('skill_id = ?' => array($skill_id)))
);
- $gradebooks_to_remove = array();
- $gradebooks_to_add = array();
- $original_gradebook_list_ids = array();
+ $gradebooks_to_remove = [];
+ $gradebooks_to_add = [];
+ $original_gradebook_list_ids = [];
if (!empty($original_gradebook_list)) {
foreach ($original_gradebook_list as $gradebook) {
@@ -505,7 +505,7 @@ class SkillRelUser extends Model
*/
public function getUserBySkills($skill_list)
{
- $users = array();
+ $users = [];
if (!empty($skill_list)) {
$skill_list = array_map('intval', $skill_list);
$skill_list = implode("', '", $skill_list);
@@ -529,7 +529,7 @@ class SkillRelUser extends Model
public function getUserSkills($userId, $courseId = 0, $sessionId = 0)
{
if (empty($userId)) {
- return array();
+ return [];
}
$courseId = intval($courseId);
@@ -847,7 +847,7 @@ class Skill extends Model
ORDER BY ss.id, ss.parent_id";
$result = Database::query($sql);
- $skills = array();
+ $skills = [];
$webPath = api_get_path(WEB_UPLOAD_PATH);
if (Database::num_rows($result)) {
while ($row = Database::fetch_array($result, 'ASSOC')) {
@@ -1012,7 +1012,7 @@ class Skill extends Model
if (!empty($params['gradebook_id'])) {
foreach ($params['gradebook_id'] as $gradebook_id) {
- $attributes = array();
+ $attributes = [];
$attributes['gradebook_id'] = $gradebook_id;
$attributes['skill_id'] = $skill_id;
$skillRelGradebook->save($attributes);
@@ -1174,7 +1174,7 @@ class Skill extends Model
$result = Database::query($sql);
$skills = Database::store_result($result, 'ASSOC');
- $skillList = array();
+ $skillList = [];
if (!empty($skills)) {
foreach ($skills as $skill) {
if ($getSkillData) {
@@ -1418,12 +1418,12 @@ class Skill extends Model
}
}
- $refs = array();
+ $refs = [];
$skills_tree = null;
// Create references for all nodes
- $flat_array = array();
- $family = array();
+ $flat_array = [];
+ $family = [];
if (!empty($skills)) {
foreach ($skills as &$skill) {
if ($skill['parent_id'] == 0) {
@@ -1484,7 +1484,7 @@ class Skill extends Model
// Checking family value
$family_id = 1;
- $new_family_array = array();
+ $new_family_array = [];
foreach ($family as $main_family_id => $family_items) {
if (!empty($family_items)) {
foreach ($family_items as $item) {
@@ -1515,7 +1515,7 @@ class Skill extends Model
'name' => get_lang('SkillRootName'),
'id' => 'root',
'children' => $refs['root']['children'],
- 'data' => array(),
+ 'data' => [],
);
}
@@ -1547,7 +1547,7 @@ class Skill extends Model
$return_flat_array,
true
);
- $simple_tree = array();
+ $simple_tree = [];
if (!empty($tree['children'])) {
foreach ($tree['children'] as $element) {
$children = [];
@@ -1573,11 +1573,11 @@ class Skill extends Model
*/
public function getSkillToJson($subtree, $depth = 1, $max_depth = 2)
{
- $simple_sub_tree = array();
+ $simple_sub_tree = [];
if (is_array($subtree)) {
$counter = 1;
foreach ($subtree as $elem) {
- $tmp = array();
+ $tmp = [];
$tmp['name'] = $elem['name'];
$tmp['id'] = $elem['id'];
$tmp['isSearched'] = self::isSearched($elem['id']);
@@ -1662,7 +1662,7 @@ class Skill extends Model
return Database::store_result($result, 'ASSOC');
}
- return array();
+ return [];
}
/**
@@ -1818,10 +1818,10 @@ class Skill extends Model
$courseId = intval($courseId);
if ($courseId == 0) {
- return array();
+ return [];
}
- $list = array();
+ $list = [];
$sql = "SELECT
course.id c_id,
@@ -1864,10 +1864,10 @@ class Skill extends Model
$skillId = intval($skillId);
if ($skillId == 0) {
- return array();
+ return [];
}
- $list = array();
+ $list = [];
$sql = "SELECT
course.id c_id,
course.title c_name,
diff --git a/main/inc/lib/skill.visualizer.lib.php b/main/inc/lib/skill.visualizer.lib.php
index 88db8e6f16..e0c185e5b0 100755
--- a/main/inc/lib/skill.visualizer.lib.php
+++ b/main/inc/lib/skill.visualizer.lib.php
@@ -35,6 +35,11 @@ class SkillVisualizer
$this->center_x = intval($this->offset_x + $this->canvas_x / 2 - $this->block_size / 2);
}
+ /**
+ * @param $skill
+ * @param $position
+ * @param $class
+ */
public function prepare_skill_box($skill, $position, $class)
{
$block_id = $skill['id'];
@@ -59,7 +64,6 @@ class SkillVisualizer
//$this->html .= Display::url(Display::return_icon('add.png', get_lang('Add'), array(), ICON_SIZE_SMALL), '#', array('id'=>'edit_block_'.$block_id,'class'=>'edit_block'));
//$this->html .= Display::url(Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL), '#', array('id=>"edit_block_'.$block_id,'class'=>'edit_block'));
//$this->html .= Display::url(Display::return_icon('up.png', get_lang('Close'), array(), ICON_SIZE_SMALL), '#', array('id'=>'close_block_'.$block_id,'class'=>'close_block'));
-
//$this->html .= Display::url(Display::return_icon('down.png', get_lang('Open'), array(), ICON_SIZE_SMALL), '#', array('id'=>'open_block_'.$block_id,'class'=>'open_block'));
}
$this->html .= '
';
diff --git a/main/inc/lib/social.lib.php b/main/inc/lib/social.lib.php
index 9fabdd85d4..21408a7802 100755
--- a/main/inc/lib/social.lib.php
+++ b/main/inc/lib/social.lib.php
@@ -28,12 +28,12 @@ class SocialManager extends UserManager
*/
public static function show_list_type_friends()
{
- $friend_relation_list = array();
$table = Database::get_main_table(TABLE_MAIN_USER_FRIEND_RELATION_TYPE);
$sql = 'SELECT id, title FROM '.$table.'
WHERE id<>6
ORDER BY id ASC';
$result = Database::query($sql);
+ $friend_relation_list = array();
while ($row = Database::fetch_array($result, 'ASSOC')) {
$friend_relation_list[] = $row;
}
diff --git a/main/lp/learnpath.class.php b/main/lp/learnpath.class.php
index 626ee5482e..ea68a06c86 100755
--- a/main/lp/learnpath.class.php
+++ b/main/lp/learnpath.class.php
@@ -1265,7 +1265,7 @@ class learnpath
if (Database::num_rows($res) > 0) {
$row2 = Database::fetch_array($res);
$di = new ChamiloIndexer();
- $di->remove_document((int) $row2['search_did']);
+ $di->remove_document($row2['search_did']);
}
$sql = 'DELETE FROM %s
WHERE course_code=\'%s\' AND tool_id=\'%s\' AND ref_id_high_level=%s AND ref_id_second_level=%d