Minor - format code.

pull/2487/head
jmontoyaa 8 years ago
parent 8296d27318
commit efe2830444
  1. 60
      main/admin/settings.lib.php
  2. 12
      main/inc/lib/extra_field.lib.php
  3. 9
      main/inc/lib/sessionmanager.lib.php

@ -987,11 +987,16 @@ function addEditTemplate()
{
$em = Database::getManager();
// Initialize the object.
$id = isset($_GET['id']) ? '&id='.Security::remove_XSS($_GET['id']) : '';
$id = isset($_GET['id']) ? '&id='.intval($_GET['id']) : 0;
/** @var SystemTemplate $template */
$template = $id ? $em->find('ChamiloCoreBundle:SystemTemplate', $_GET['id']) : new SystemTemplate();
$template = $id ? $em->find('ChamiloCoreBundle:SystemTemplate', $id) : new SystemTemplate();
$form = new FormValidator('template', 'post', 'settings.php?category=Templates&action='.Security::remove_XSS($_GET['action']).$id);
$form = new FormValidator(
'template',
'post',
'settings.php?category=Templates&action='.Security::remove_XSS($_GET['action']).$id
);
// Setting the form elements: the header.
if ($_GET['action'] == 'add') {
@ -1022,7 +1027,7 @@ function addEditTemplate()
// Getting all the information of the template when editing a template.
if ($_GET['action'] == 'edit') {
$defaults['template_id'] = intval($_GET['id']);
$defaults['template_id'] = $id;
$defaults['template_text'] = $template->getContent();
// Forcing get_lang().
$defaults['title'] = get_lang($template->getTitle());
@ -1042,8 +1047,12 @@ function addEditTemplate()
.'"/>'
);
} else {
$form->addElement('static', 'template_image_preview', '',
'<img src="'.api_get_path(WEB_APP_PATH).'home/default_platform_document/template_thumb/noimage.gif" alt="'.get_lang('NoTemplatePreview').'"/>');
$form->addElement(
'static',
'template_image_preview',
'',
'<img src="'.api_get_path(WEB_APP_PATH).'home/default_platform_document/template_thumb/noimage.gif" alt="'.get_lang('NoTemplatePreview').'"/>'
);
}
// Setting the information of the template that we are editing.
@ -1053,10 +1062,15 @@ function addEditTemplate()
$form->addButtonSave(get_lang('Ok'), 'submit');
// Setting the rules: the required fields.
$form->addRule('template_image', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule(
'template_image',
get_lang('ThisFieldIsRequired'),
'required'
);
$form->addRule('title', get_lang('ThisFieldIsRequired'), 'required');
// if the form validates (complies to all rules) we save the information, else we display the form again (with error message if needed)
// if the form validates (complies to all rules) we save the information,
// else we display the form again (with error message if needed)
if ($form->validate()) {
$check = Security::check_token('post');
if ($check) {
@ -1083,7 +1097,6 @@ function addEditTemplate()
$picture_info = $temp->get_image_info();
$max_width_for_picture = 100;
if ($picture_info['width'] > $max_width_for_picture) {
$temp->resize($max_width_for_picture);
}
@ -1094,7 +1107,7 @@ function addEditTemplate()
// Store the information in the database (as insert or as update).
$bootstrap = api_get_css(api_get_path(WEB_PUBLIC_PATH).'assets/bootstrap/dist/css/bootstrap.min.css');
$viewport = '<meta name="viewport" content="width=device-width, initial-scale=1.0">';
if ($_GET['action'] == 'add') {
$templateContent = '<head>'.$viewport.'<title>'.$values['title'].'</title>'.$bootstrap.'</head>'
.$values['template_text'];
@ -1106,12 +1119,17 @@ function addEditTemplate()
$em->flush();
// Display a feedback message.
echo Display::return_message(get_lang('TemplateAdded'), 'confirm');
echo '<a href="settings.php?category=Templates&action=add">'.Display::return_icon('new_template.png', get_lang('AddTemplate'), '', ICON_SIZE_MEDIUM).'</a>';
echo Display::return_message(
get_lang('TemplateAdded'),
'confirm'
);
echo '<a href="settings.php?category=Templates&action=add">'.
Display::return_icon('new_template.png', get_lang('AddTemplate'), '', ICON_SIZE_MEDIUM).
'</a>';
} else {
$templateContent = '<head>'.$viewport.'<title>'.$values['title'].'</title>'.$bootstrap.'</head>'
.$values['template_text'];
$template
->setTitle($values['title'])
->setContent(Security::remove_XSS($templateContent, COURSEMANAGERLOWSECURITY));
@ -1149,9 +1167,10 @@ function addEditTemplate()
*/
function deleteTemplate($id)
{
$id = intval($id);
// First we remove the image.
$table_system_template = Database::get_main_table('system_template');
$sql = "SELECT * FROM $table_system_template WHERE id = ".intval($id)."";
$table = Database::get_main_table('system_template');
$sql = "SELECT * FROM $table WHERE id = $id";
$result = Database::query($sql);
$row = Database::fetch_array($result);
if (!empty($row['image'])) {
@ -1159,7 +1178,7 @@ function deleteTemplate($id)
}
// Now we remove it from the database.
$sql = "DELETE FROM $table_system_template WHERE id = ".intval($id)."";
$sql = "DELETE FROM $table WHERE id = $id";
Database::query($sql);
// Display a feedback message.
@ -1186,7 +1205,8 @@ function select_timezone_value()
*
* @author Guillaume Viguier <guillaume.viguier@beeznest.com>
*/
function select_gradebook_number_decimals() {
function select_gradebook_number_decimals()
{
return array('0', '1', '2');
}
@ -1226,7 +1246,11 @@ function generateSettingsForm($settings, $settings_by_access_list)
$em = Database::getManager();
$table_settings_current = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
$form = new FormValidator('settings', 'post', 'settings.php?category='.Security::remove_XSS($_GET['category']));
$form = new FormValidator(
'settings',
'post',
'settings.php?category='.Security::remove_XSS($_GET['category'])
);
$form->addElement(
'hidden',

@ -2528,8 +2528,8 @@ JAVASCRIPT;
)
";
} else {
if (isset($extra_field_info['field_type'])
&& $extra_field_info['field_type'] == self::FIELD_TYPE_TAG
if (isset($extra_field_info['field_type']) &&
$extra_field_info['field_type'] == self::FIELD_TYPE_TAG
) {
$options['where'] = str_replace(
$extra_info['field'],
@ -2539,10 +2539,12 @@ JAVASCRIPT;
$inject_joins .= "
INNER JOIN $this->table_field_rel_tag tag_rel$counter
ON (tag_rel$counter.field_id = ".$extra_info['id']." AND tag_rel$counter.item_id = s."
.$this->primaryKey.")
ON (
tag_rel$counter.field_id = ".$extra_info['id']." AND
tag_rel$counter.item_id = s.".$this->primaryKey."
)
INNER JOIN $this->table_field_tag tag$counter
ON (tag$counter.id = tag_rel$counter.tag_id)
ON (tag$counter.id = tag_rel$counter.tag_id)
";
} else {
//text, textarea, etc

@ -433,10 +433,10 @@ class SessionManager
* @assert (array(),true) !== false
*/
public static function get_sessions_admin(
$options = array(),
$options = [],
$get_count = false,
$columns = [],
$extraFieldsToLoad = array()
$extraFieldsToLoad = []
) {
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$sessionCategoryTable = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
@ -452,12 +452,12 @@ class SessionManager
}
}
if (!api_is_platform_admin() && api_is_teacher() &&
if (!api_is_platform_admin() &&
api_is_teacher() &&
api_get_setting('allow_teachers_to_create_sessions') == 'true'
) {
$where .= " AND s.id_coach = $user_id ";
}
$extra_field = new ExtraFieldModel('session');
$conditions = $extra_field->parseConditions($options);
$inject_joins = $conditions['inject_joins'];
@ -542,7 +542,6 @@ class SessionManager
}
$query .= $order;
$query .= $limit;
$result = Database::query($query);
$categories = self::get_all_session_category();

Loading…
Cancel
Save