Minor - format code

pull/2487/head
jmontoyaa 9 years ago
parent 68045da1c1
commit d9623f75b9
  1. 2
      main/auth/catalog_layout.php
  2. 15
      main/auth/courses.php
  3. 53
      main/auth/courses_categories.php
  4. 26
      main/auth/courses_controller.php
  5. 76
      main/auth/courses_list.php
  6. 2
      main/auth/gotocourse.php
  7. 45
      main/auth/inscription.php
  8. 19
      main/auth/lostPassword.php
  9. 2
      main/auth/profile.php
  10. 7
      main/auth/reset.php
  11. 6
      main/auth/set_temp_password.php
  12. 20
      main/auth/unsubscribe_account.php

@ -7,7 +7,7 @@
*/
if (api_get_setting('course_catalog_published') !== 'true') {
// Acces rights: anonymous users can't do anything usefull here.
// Access rights: anonymous users can't do anything usefull here.
api_block_anonymous_users();
}

@ -144,7 +144,14 @@ if (isset($_POST['create_course_category']) &&
// search courses
if (isset($_REQUEST['search_course'])) {
if ($ctok == $_REQUEST['sec_token']) {
$courses_controller->search_courses($_REQUEST['search_term'], null, null, null, $limit, true);
$courses_controller->search_courses(
$_REQUEST['search_term'],
null,
null,
null,
$limit,
true
);
}
}
@ -163,7 +170,11 @@ if (isset($_REQUEST['subscribe_course'])) {
if (isset($_GET['unsubscribe'])) {
$search_term = isset($_GET['search_term']) ? $_GET['search_term'] : null;
if ($ctok == $_GET['sec_token']) {
$courses_controller->unsubscribe_user_from_course($_GET['unsubscribe'], $search_term, $categoryCode);
$courses_controller->unsubscribe_user_from_course(
$_GET['unsubscribe'],
$search_term,
$categoryCode
);
}
}

@ -159,14 +159,14 @@ if ($showCourses && $action != 'display_sessions') {
continue;
}
$userRegisterdInCourse = CourseManager::is_user_subscribed_in_course($user_id, $course['code']);
$userRegisterdInCourseAsTeacher = CourseManager::is_course_teacher($user_id, $course['code']);
$userRegisterd = ($userRegisterdInCourse && $userRegisterdInCourseAsTeacher);
$userRegisteredInCourse = CourseManager::is_user_subscribed_in_course($user_id, $course['code']);
$userRegisteredInCourseAsTeacher = CourseManager::is_course_teacher($user_id, $course['code']);
$userRegistered = $userRegisteredInCourse && $userRegisteredInCourseAsTeacher;
$course_public = ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD);
$course_open = ($course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM);
$course_private = ($course['visibility'] == COURSE_VISIBILITY_REGISTERED);
$course_closed = ($course['visibility'] == COURSE_VISIBILITY_CLOSED);
$course_public = $course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD;
$course_open = $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM;
$course_private = $course['visibility'] == COURSE_VISIBILITY_REGISTERED;
$course_closed = $course['visibility'] == COURSE_VISIBILITY_CLOSED;
$course_subscribe_allowed = ($course['subscribe'] == 1);
$course_unsubscribe_allowed = ($course['unsubscribe'] == 1);
@ -183,7 +183,7 @@ if ($showCourses && $action != 'display_sessions') {
}
// display thumbnail
$html .= returnThumbnail($course, $userRegisterd);
$html .= returnThumbnail($course, $userRegistered);
$separator = '<div class="separator">&nbsp;</div>';
$subscribeButton = return_register_button($course, $stok, $code, $search_term);
@ -211,7 +211,7 @@ if ($showCourses && $action != 'display_sessions') {
// display course title and button bloc
$html .= '<div class="description">';
$html .= return_title($course, $userRegisterdInCourse);
$html .= return_title($course, $userRegisteredInCourse);
$html .= return_teacher($course);
// display button line
@ -222,20 +222,18 @@ if ($showCourses && $action != 'display_sessions') {
$html .= '<div class="right">';
$html .= '<div class="btn-group">';
// if user registered as student
if ($userRegisterdInCourse) {
if ($userRegisteredInCourse) {
$html .= return_already_registered_label('student');
if (!$course_closed) {
if ($course_unsubscribe_allowed) {
$html .= return_unregister_button($course, $stok, $search_term, $code);
}
}
} elseif ($userRegisterdInCourseAsTeacher) {
} elseif ($userRegisteredInCourseAsTeacher) {
// if user registered as teacher
if ($course_unsubscribe_allowed) {
$html .= return_unregister_button($course, $stok, $search_term, $code);
}
//$html .= return_already_registered_label('teacher');
} else {
// if user not registered in the course
if (!$course_closed) {
@ -245,7 +243,6 @@ if ($showCourses && $action != 'display_sessions') {
}
}
}
}
$html .= '</div>';
$html .= '</div>';
@ -290,11 +287,17 @@ function returnThumbnail($course, $registeredUser)
$course_medium_image = api_get_path(WEB_COURSE_PATH).$course['directory'].'/course-pic.png'; // redimensioned image 85x85
} else {
// without picture
$course_medium_image = Display::return_icon('session_default.png', null, null, null, null, true);
$course_medium_image = Display::return_icon(
'session_default.png',
null,
null,
null,
null,
true
);
}
$html .= '<div class="image">';
if (!$registeredUser) {
$html .= '<img class="img-responsive"'
.' src="'.$course_medium_image.'" '
@ -320,16 +323,13 @@ function returnThumbnail($course, $registeredUser)
function return_teacher($course)
{
//Info course
$courseInfo = api_get_course_info($course['code']);
$teachers = CourseManager::getTeachersFromCourse($courseInfo['real_id']);
//$count = 0;
$html = null;
$html .= '<div class="block-author">';
$length = count($teachers);
foreach ($teachers as $value) {
$name = $value['firstname'].' '.$value['lastname'];
if ($length > 2) {
$html .= '<a href="'.$value['url'].'" class="ajax" data-title="'.$name.'">
<img src="'.$value['avatar'].'" alt="'.get_lang('UserPicture').'"/></a>';
@ -342,6 +342,7 @@ function return_teacher($course)
}
}
$html .= '</div>';
return $html;
}
@ -414,7 +415,11 @@ function return_goto_button($course)
$html = Display::url(
Display::returnFontAwesomeIcon('share'),
api_get_course_url($course['code']),
array('class' => 'btn btn-default btn-sm', 'title' => $title, 'aria-label' => $title)
array(
'class' => 'btn btn-default btn-sm',
'title' => $title,
'aria-label' => $title,
)
);
return $html;
}
@ -437,7 +442,12 @@ function return_already_registered_label($in_status)
$html = Display::tag(
'span',
$icon.' '.$title,
array('id' => 'register', 'class' => 'label-subscribed text-success', 'title' => $title, 'aria-label' => $title)
array(
'id' => 'register',
'class' => 'label-subscribed text-success',
'title' => $title,
'aria-label' => $title,
)
);
return $html;
@ -482,5 +492,6 @@ function return_unregister_button($course, $stok, $search_term, $code)
.'&unsubscribe='.$course['code'].'&search_term='.$search_term.'&category_code='.$code,
array('class' => 'btn btn-danger btn-sm', 'title' => $title, 'aria-label' => $title)
);
return $html;
}

@ -614,7 +614,10 @@ class CoursesController
return Display::div(
$icon,
array('class' => 'btn btn-default btn-sm registered', 'title' => get_lang("AlreadyRegisteredToSession"))
array(
'class' => 'btn btn-default btn-sm registered',
'title' => get_lang("AlreadyRegisteredToSession"),
)
);
}
@ -689,13 +692,18 @@ class CoursesController
$searchTag = isset($_POST['search_tag']) ? $_POST['search_tag'] : null;
$searchDate = isset($_POST['date']) ? $_POST['date'] : date('Y-m-d');
$hiddenLinks = isset($_GET['hidden_links']) ? intval($_GET['hidden_links']) == 1 : false;
$courseUrl = CourseCategory::getCourseCategoryUrl(1, $limit['length'], null, 0, 'subscribe');
$courseUrl = CourseCategory::getCourseCategoryUrl(
1,
$limit['length'],
null,
0,
'subscribe'
);
$sessions = $this->model->browseSessionsByTags($searchTag, $limit);
$sessionsBlocks = $this->getFormattedSessionsBlock($sessions);
$tpl = new Template();
$tpl->assign('show_courses', CoursesAndSessionsCatalog::showCourses());
$tpl->assign('show_sessions', CoursesAndSessionsCatalog::showSessions());
$tpl->assign('show_tutor', (api_get_setting('show_session_coach') === 'true' ? true : false));
@ -720,7 +728,13 @@ class CoursesController
{
$q = isset($_REQUEST['q']) ? Security::remove_XSS($_REQUEST['q']) : null;
$hiddenLinks = isset($_GET['hidden_links']) ? intval($_GET['hidden_links']) == 1 : false;
$courseUrl = CourseCategory::getCourseCategoryUrl(1, $limit['length'], null, 0, 'subscribe');
$courseUrl = CourseCategory::getCourseCategoryUrl(
1,
$limit['length'],
null,
0,
'subscribe'
);
$searchDate = isset($_POST['date']) ? $_POST['date'] : date('Y-m-d');
$sessions = $this->model->browseSessionsBySearch($q, $limit);
@ -807,12 +821,10 @@ class CoursesController
);
$hasRequirements = false;
foreach ($sequences['sequences'] as $sequence) {
if (count($sequence['requirements']) === 0) {
continue;
}
$hasRequirements = true;
break;
}
@ -846,7 +858,7 @@ class CoursesController
'is_subscribed' => SessionManager::isUserSubscribedAsStudent($session->getId(), $userId),
'icon' => $this->getSessionIcon($session->getName()),
'date' => $sessionDates['display'],
'price' => (!empty($isThisSessionOnSale['html']) ? $isThisSessionOnSale['html'] : ''),
'price' => !empty($isThisSessionOnSale['html']) ? $isThisSessionOnSale['html'] : '',
'subscribe_button' => isset($isThisSessionOnSale['buy_button']) ? $isThisSessionOnSale['buy_button'] : $this->getRegisteredInSessionButton(
$session->getId(),
$session->getName(),

@ -172,7 +172,6 @@ if (!empty($user_course_categories)) {
}
echo Display::page_subheader(get_lang('NoCourseCategory'));
echo '<table class="data_table">';
// COURSES WITHOUT CATEGORY
if (!empty($courses_without_category)) {
@ -185,9 +184,18 @@ if (!empty($courses_without_category)) {
<a name="course<?php echo $course['code']; ?>"></a>
<strong><?php echo $course['title']; ?></strong><br />
<?php
if (api_get_setting('display_coursecode_in_courselist') === 'true') { echo $course['visual_code']; }
if (api_get_setting('display_coursecode_in_courselist') === 'true' && api_get_setting('display_teacher_in_courselist') === 'true') { echo " - "; }
if (api_get_setting('display_teacher_in_courselist') === 'true') { echo $course['tutor']; }
if (api_get_setting('display_coursecode_in_courselist') === 'true') {
echo $course['visual_code'];
}
if (api_get_setting('display_coursecode_in_courselist') === 'true' &&
api_get_setting('display_teacher_in_courselist') === 'true'
) {
echo " - ";
}
if (api_get_setting('display_teacher_in_courselist') === 'true') {
echo $course['tutor'];
}
?>
</td>
<td valign="top">
@ -209,56 +217,54 @@ if (!empty($courses_without_category)) {
</form><br />
</div>
<?php } ?>
<div style="float:left; width:110px">
<?php
if (api_get_setting('show_courses_descriptions_in_catalog') == 'true') {
$icon_title = get_lang('CourseDetails').' - '.$course['title'];
$icon_title = get_lang('CourseDetails').' - '.$course['title'];
?>
<a href="<?php echo api_get_path(WEB_CODE_PATH); ?>inc/ajax/course_home.ajax.php?a=show_course_information&code=<?php echo $course['code'] ?>" data-title="<?php echo $icon_title ?>" title="<?php echo $icon_title ?>" class="ajax">
<?php echo Display::return_icon('info.png', $icon_title, '', '22'); ?>
</a>
<?php } ?>
<?php if (isset($_GET['edit']) && $course['code'] == $_GET['edit']) { ?>
<?php echo Display::display_icon('edit_na.png', get_lang('Edit'), '', 22); ?>
<?php } else { ?>
<a href="courses.php?action=<?php echo $action; ?>&amp;edit=<?php echo $course['code']; ?>&amp;sec_token=<?php echo $stok; ?>">
<?php echo Display::display_icon('edit.png', get_lang('Edit'), '', 22); ?>
</a>
<?php }
if (isset($_GET['edit']) && $course['code'] == $_GET['edit']) { ?>
<?php echo Display::display_icon('edit_na.png', get_lang('Edit'), '', 22); ?>
<?php } else { ?>
<a href="courses.php?action=<?php echo $action; ?>&amp;edit=<?php echo $course['code']; ?>&amp;sec_token=<?php echo $stok; ?>">
<?php echo Display::display_icon('edit.png', get_lang('Edit'), '', 22); ?>
</a>
<?php } ?>
<!-- up /down icons-->
<?php if ($key > 0) { ?>
<a href="courses.php?action=<?php echo $action; ?>&amp;move=up&amp;course=<?php echo $course['code']; ?>&amp;category=<?php echo $course['user_course_cat']; ?>&amp;sec_token=<?php echo $stok; ?>">
<?php echo Display::display_icon('up.png', get_lang('Up'), '', 22) ?>
</a>
<a href="courses.php?action=<?php echo $action; ?>&amp;move=up&amp;course=<?php echo $course['code']; ?>&amp;category=<?php echo $course['user_course_cat']; ?>&amp;sec_token=<?php echo $stok; ?>">
<?php echo Display::display_icon('up.png', get_lang('Up'), '', 22) ?>
</a>
<?php } else {
echo Display::display_icon('up_na.png', get_lang('Up'), '', 22);
}
if ($key < $number_of_courses - 1) { ?>
<a href="courses.php?action=<?php echo $action; ?>&amp;move=down&amp;course=<?php echo $course['code']; ?>&amp;category=<?php echo $course['user_course_cat']; ?>&amp;sec_token=<?php echo $stok; ?>">
<?php echo Display::display_icon('down.png', get_lang('Down'), '', 22); ?>
</a>
echo Display::display_icon('up_na.png', get_lang('Up'), '', 22);
}
if ($key < $number_of_courses - 1) { ?>
<a href="courses.php?action=<?php echo $action; ?>&amp;move=down&amp;course=<?php echo $course['code']; ?>&amp;category=<?php echo $course['user_course_cat']; ?>&amp;sec_token=<?php echo $stok; ?>">
<?php echo Display::display_icon('down.png', get_lang('Down'), '', 22); ?>
</a>
<?php } else {
echo Display::display_icon('down_na.png', get_lang('Down'), '', 22);
}?>
</div>
<div style="float:left; margin-right:10px;">
<!-- cancel subscrioption-->
<?php if ($course['status'] != 1) {
<?php
if ($course['status'] != 1) {
if ($course['unsubscr'] == 1) {
?>
<!-- changed link to submit to avoid action by the search tool indexer -->
<form action="<?php echo api_get_self(); ?>" method="post" onsubmit="javascript: if (!confirm('<?php echo addslashes(api_htmlentities(get_lang("ConfirmUnsubscribeFromCourse"), ENT_QUOTES, api_get_system_encoding())) ?>')) return false;">
<input type="hidden" name="sec_token" value="<?php echo $stok; ?>">
<input type="hidden" name="unsubscribe" value="<?php echo $course['code']; ?>" />
<button class="btn btn-default" value="<?php echo get_lang('Unsubscribe'); ?>" name="unsub">
<?php echo get_lang('Unsubscribe'); ?>
</button>
</form>
</div>
?>
<!-- changed link to submit to avoid action by the search tool indexer -->
<form action="<?php echo api_get_self(); ?>" method="post" onsubmit="javascript: if (!confirm('<?php echo addslashes(api_htmlentities(get_lang("ConfirmUnsubscribeFromCourse"), ENT_QUOTES, api_get_system_encoding())) ?>')) return false;">
<input type="hidden" name="sec_token" value="<?php echo $stok; ?>">
<input type="hidden" name="unsubscribe" value="<?php echo $course['code']; ?>" />
<button class="btn btn-default" value="<?php echo get_lang('Unsubscribe'); ?>" name="unsub">
<?php echo get_lang('Unsubscribe'); ?>
</button>
</form>
</div>
<?php }
}
?>

@ -50,7 +50,7 @@ if (isset($_GET['firstpage'])) {
}
$msg .= '<div class="well_login">';
$msg .= $form->return_form();
$msg .= $form->returnForm();
$msg .= '</div>';
if (api_is_cas_activated()) {
$msg .= "</div>";

@ -109,7 +109,15 @@ if ($user_already_registered_show_terms === false) {
if (api_get_setting('registration', 'email') != 'true') {
$form->addRule('email', get_lang('ThisFieldIsRequired'), 'required');
}
$form->addRule('email', sprintf(get_lang('UsernameMaxXCharacters'), (string) USERNAME_MAX_LENGTH), 'maxlength', USERNAME_MAX_LENGTH);
$form->addRule(
'email',
sprintf(
get_lang('UsernameMaxXCharacters'),
(string)USERNAME_MAX_LENGTH
),
'maxlength',
USERNAME_MAX_LENGTH
);
$form->addRule('email', get_lang('UserTaken'), 'username_available');
}
@ -151,7 +159,15 @@ if ($user_already_registered_show_terms === false) {
);
$form->applyFilter('username', 'trim');
$form->addRule('username', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('username', sprintf(get_lang('UsernameMaxXCharacters'), (string) USERNAME_MAX_LENGTH), 'maxlength', USERNAME_MAX_LENGTH);
$form->addRule(
'username',
sprintf(
get_lang('UsernameMaxXCharacters'),
(string)USERNAME_MAX_LENGTH
),
'maxlength',
USERNAME_MAX_LENGTH
);
$form->addRule('username', get_lang('UsernameWrong'), 'username');
$form->addRule('username', get_lang('UserTaken'), 'username_available');
}
@ -253,10 +269,25 @@ if ($user_already_registered_show_terms === false) {
);
$form->addElement('static', null, null, get_lang('ClickOnTheImageForANewOne'));
$form->addElement('text', 'captcha', get_lang('EnterTheLettersYouSee'), array('size' => 40));
$form->addRule('captcha', get_lang('EnterTheCharactersYouReadInTheImage'), 'required', null, 'client');
$form->addRule('captcha', get_lang('TheTextYouEnteredDoesNotMatchThePicture'), 'CAPTCHA', $captcha_question);
$form->addElement(
'text',
'captcha',
get_lang('EnterTheLettersYouSee'),
array('size' => 40)
);
$form->addRule(
'captcha',
get_lang('EnterTheCharactersYouReadInTheImage'),
'required',
null,
'client'
);
$form->addRule(
'captcha',
get_lang('TheTextYouEnteredDoesNotMatchThePicture'),
'CAPTCHA',
$captcha_question
);
}
// EXTENDED FIELDS
@ -570,7 +601,7 @@ if ($form->validate()) {
$form
);
//update the extra fields
// Update the extra fields
$count_extra_field = count($extras);
if ($count_extra_field > 0 && is_integer($user_id)) {
foreach ($extras as $key => $value) {

@ -1,5 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* SCRIPT PURPOSE :
*
@ -9,11 +10,11 @@
*
* Special case : If the password are encrypted in the database, we have
* to generate a new one.
*
* @todo refactor, move relevant functions to code libraries
*
* @package chamilo.auth
*/
*
* @todo refactor, move relevant functions to code libraries
*
* @package chamilo.auth
*/
require_once __DIR__.'/../inc/global.inc.php';
@ -53,7 +54,13 @@ if ($reset && $userId) {
$form = new FormValidator('lost_password');
$form->addHeader($tool_name);
$form->addText('user', [get_lang('LoginOrEmailAddress'), get_lang('EnterEmailUserAndWellSendYouPassword')], true);
$form->addText('user',
[
get_lang('LoginOrEmailAddress'),
get_lang('EnterEmailUserAndWellSendYouPassword'),
],
true
);
$form->addButtonSend(get_lang('Send'));
if ($form->validate()) {

@ -230,7 +230,7 @@ if (api_get_setting('profile', 'language') !== 'true') {
$form->freeze('language');
}
//THEME
// THEME
if (is_profile_editable() && api_get_setting('user_selected_theme') == 'true') {
$form->addElement('SelectTheme', 'theme', get_lang('Theme'));
if (api_get_setting('profile', 'theme') !== 'true') {

@ -15,7 +15,12 @@ $form = new FormValidator('reset', 'POST', api_get_self().'?token='.$token);
$form->addElement('header', get_lang('ResetPassword'));
$form->addHidden('token', $token);
$form->addElement('password', 'pass1', get_lang('Password'));
$form->addElement('password', 'pass2', get_lang('Confirmation'), array('id' => 'pass2', 'size' => 20, 'autocomplete' => 'off'));
$form->addElement(
'password',
'pass2',
get_lang('Confirmation'),
array('id' => 'pass2', 'size' => 20, 'autocomplete' => 'off')
);
$form->addRule('pass1', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('pass2', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule(array('pass1', 'pass2'), get_lang('PassTwo'), 'compare');

@ -28,7 +28,11 @@ $course_info = api_get_course_info_by_id($course_id);
$tpl = new Template(null);
// Build the form
$form = new FormValidator('set_temp_password', 'POST', api_get_self().'?course_id='.$course_id.'&session_id='.$session_id);
$form = new FormValidator(
'set_temp_password',
'POST',
api_get_self().'?course_id='.$course_id.'&session_id='.$session_id
);
$form->addElement('header', get_lang('CourseRequiresPassword'));
$form->addElement('hidden', 'course_id', $course_id);
$form->addElement('hidden', 'session_id', $session_id);

@ -12,14 +12,28 @@ $tool_name = get_lang('Unsubscribe');
$message = Display::return_message(get_lang('UnsubscribeFromPlatform'), 'warning');
$form = new FormValidator('user_add');
$form->addElement('button', 'submit', get_lang('Unsubscribe'), array('onclick' => "javascript:if(!confirm('".addslashes(api_htmlentities(get_lang("UnsubscribeFromPlatformConfirm")))."')) return false;"));
$content = $form->return_form();
$form->addElement(
'button',
'submit',
get_lang('Unsubscribe'),
array(
'onclick' => "javascript:if(!confirm('".addslashes(api_htmlentities(get_lang("UnsubscribeFromPlatformConfirm")))."')) return false;",
)
);
$content = $form->returnForm();
if ($form->validate()) {
$user_info = api_get_user_info();
$result = UserManager::delete_user($user_info['user_id']);
if ($result) {
$message = Display::return_message(sprintf(get_lang('UnsubscribeFromPlatformSuccess', $user_info['username'])));
$message = Display::return_message(
sprintf(
get_lang(
'UnsubscribeFromPlatformSuccess',
$user_info['username']
)
)
);
$content = null;
online_logout($user_info['user_id'], false);
api_not_allowed(true, $message);

Loading…
Cancel
Save