Format code, add docs.

1.10.x
Julio Montoya 10 years ago
parent a9a92938fd
commit 099b17f076
  1. 6
      main/inc/introductionSection.inc.php
  2. 45
      main/inc/lib/glossary.lib.php
  3. 1
      main/inc/lib/grade_model.lib.php
  4. 1
      main/inc/lib/pear/HTML/QuickForm.php
  5. 121
      main/inc/lib/sessionmanager.lib.php
  6. 23
      main/inc/lib/specific_fields_manager.lib.php
  7. 18
      main/messages/inbox.php
  8. 15
      main/messages/new_message.php

@ -44,7 +44,11 @@ $intro_cmdAdd = empty($_GET['intro_cmdAdd']) ? '' : $_GET['intro_cmdAdd'];
$courseId = api_get_course_id();
if (!empty($courseId)) {
$form = new FormValidator('introduction_text', 'post', api_get_self().'?'.api_get_cidreq());
$form = new FormValidator(
'introduction_text',
'post',
api_get_self().'?'.api_get_cidreq()
);
} else {
$form = new FormValidator('introduction_text');
}

@ -230,7 +230,7 @@ class GlossaryManager
* @author Patrick Cool <patrick.cool@ugent.be>, Ghent University, Belgium
* @version januari 2009, dokeos 1.8.6
*/
public static function glossary_exists($term,$not_id='')
public static function glossary_exists($term, $not_id='')
{
// Database table definition
$t_glossary = Database :: get_course_table(TABLE_GLOSSARY);
@ -241,7 +241,7 @@ class GlossaryManager
c_id = $course_id AND
name = '".Database::escape_string($term)."'";
if ($not_id<>'') {
$sql .= " AND glossary_id <> '".Database::escape_string($not_id)."'";
$sql .= " AND glossary_id <> '".intval($not_id)."'";
}
$result = Database::query($sql);
$count = Database::num_rows($result);
@ -311,7 +311,13 @@ class GlossaryManager
$result = Database::query($sql);
if ($result === false or Database::affected_rows($result) < 1) { return false; }
//update item_property (delete)
api_item_property_update(api_get_course_info(), TOOL_GLOSSARY, intval($glossary_id), 'delete', api_get_user_id());
api_item_property_update(
api_get_course_info(),
TOOL_GLOSSARY,
intval($glossary_id),
'delete',
api_get_user_id()
);
// reorder the remaining terms
GlossaryManager::reorder_glossary();
@ -324,7 +330,8 @@ class GlossaryManager
/**
* This is the main function that displays the list or the table with all
* the glossary terms
* @param string View ('table' or 'list'). Optional parameter. Defaults to 'table' and prefers glossary_view from the session by default.
* @param string View ('table' or 'list'). Optional parameter.
* Defaults to 'table' and prefers glossary_view from the session by default.
* @return void
* @author Patrick Cool <patrick.cool@ugent.be>, Ghent University, Belgium
* @version januari 2009, dokeos 1.8.6
@ -392,12 +399,12 @@ class GlossaryManager
public static function display_glossary_list()
{
$glossary_data = self::get_glossary_data(0,1000,0,'ASC');
foreach($glossary_data as $key=>$glossary_item) {
echo '<div class="sectiontitle">'.$glossary_item[0].'</div>';
echo '<div class="sectioncomment">'.$glossary_item[1].'</div>';
foreach ($glossary_data as $key => $glossary_item) {
$actions = '';
if (api_is_allowed_to_edit(null,true)) {
echo '<div>'.self::actions_filter($glossary_item[2], '',$glossary_item).'</div>';
$actions = '<div class="pull-right">'.self::actions_filter($glossary_item[2], '',$glossary_item).'</div>';
}
echo Display::panel($glossary_item[1], $glossary_item[0].' '.$actions);
}
return true;
}
@ -456,7 +463,12 @@ class GlossaryManager
//condition for the session
$session_id = api_get_session_id();
$condition_session = api_get_session_condition($session_id, true, true, 'glossary.session_id');
$condition_session = api_get_session_condition(
$session_id,
true,
true,
'glossary.session_id'
);
$column = intval($column);
if (!in_array($direction,array('DESC', 'ASC'))) {
$direction = 'ASC';
@ -464,7 +476,8 @@ class GlossaryManager
$from = intval($from);
$number_of_items = intval($number_of_items);
$sql = "SELECT glossary.name as col0,
$sql = "SELECT
glossary.name as col0,
glossary.description as col1,
$col2
glossary.session_id
@ -481,7 +494,7 @@ class GlossaryManager
$return = array();
$array = array();
while ($data = Database::fetch_array($res)) {
//validacion when belongs to a session
// Validation when belongs to a session
$session_img = api_get_session_image($data['session_id'], $_user['status']);
$array[0] = $data[0] . $session_img;
@ -560,7 +573,9 @@ class GlossaryManager
// Database table definition
$t_glossary = Database :: get_course_table(TABLE_GLOSSARY);
$course_id = api_get_course_int_id();
$sql = "SELECT * FROM $t_glossary WHERE c_id = $course_id ORDER by display_order ASC";
$sql = "SELECT * FROM $t_glossary
WHERE c_id = $course_id
ORDER by display_order ASC";
$res = Database::query($sql);
$i = 1;
@ -594,7 +609,9 @@ class GlossaryManager
}
$course_id = api_get_course_int_id();
$sql = "SELECT * FROM $t_glossary WHERE c_id = $course_id ORDER BY display_order $sortorder";
$sql = "SELECT * FROM $t_glossary
WHERE c_id = $course_id
ORDER BY display_order $sortorder";
$res = Database::query($sql);
$found = false;
while ($row = Database::fetch_array($res)) {
@ -642,6 +659,6 @@ class GlossaryManager
} else {
$css = '';
}*/
$pdf->content_to_pdf($html, $css, get_lang('Glossary').'_'.$course_code, $course_code);
$pdf->content_to_pdf($html, '', get_lang('Glossary').'_'.$course_code, $course_code);
}
}

@ -20,6 +20,7 @@ class GradeModel extends Model
/**
* @param array $where_conditions
*
* @return array
*/
public function get_all($where_conditions = array())

@ -1620,7 +1620,6 @@ class HTML_QuickForm extends HTML_Common
$result = $registry->validate($rule['type'], $submitValue, $rule['format'], true);
} else {
$result = $registry->validate($rule['type'], $submitValue, $rule['format'], false);
}
if (!$result || (!empty($rule['howmany']) && $rule['howmany'] > (int)$result)) {

@ -250,6 +250,7 @@ class SessionManager
/**
* @param string $name
*
* @return bool
*/
public static function session_name_exists($name)
@ -573,7 +574,10 @@ class SessionManager
/**
* Gets the progress of learning paths in the given session
* @param int session id
* @param int $sessionId
* @param int $courseId
* @param string $date_from
* @param string $date_to
* @param array options order and limit keys
* @return array table with user name, lp name, progress
*/
@ -696,9 +700,9 @@ class SessionManager
/**
* Gets the survey answers
* @param int session id
* @param int course id
* @param int survey id
* @param int $sessionId
* @param int $courseId
* @param int $surveyId
* @param array options order and limit keys
* @todo fix the query
* @return array table with user name, lp name, progress
@ -807,8 +811,10 @@ class SessionManager
/**
* Gets the progress of the given session
* @param int session id
* @param int $sessionId
* @param int $courseId
* @param array options order and limit keys
*
* @return array table with user name, lp name, progress
*/
public static function get_session_progress($sessionId, $courseId, $date_from, $date_to, $options)
@ -826,8 +832,6 @@ class SessionManager
$user = Database::get_main_table(TABLE_MAIN_USER);
$workTable = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$workTableAssignment = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
$forum = Database::get_course_table(TABLE_FORUM);
$forum_post = Database::get_course_table(TABLE_FORUM_POST);
$tbl_course_lp = Database::get_course_table(TABLE_LP_MAIN);
$wiki = Database::get_course_table(TABLE_WIKI);
$table_stats_default = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DEFAULT);
@ -1287,7 +1291,7 @@ class SessionManager
/**
* Creates a new course code based in given code
*
* @param string wanted code
* @param string $session_name
* <code>
* $wanted_code = 'curse' if there are in the DB codes like curse1 curse2 the function will return: course3
* if the course code doest not exist in the DB the same course code will be returned
@ -1453,8 +1457,9 @@ class SessionManager
/**
* Delete session
* @author Carlos Vargas from existing code
* @param array id_checked an array to delete sessions
* @param boolean optional, true if the function is called by a webservice, false otherwise.
* @param array $id_checked an array to delete sessions
* @param boolean $from_ws optional, true if the function is called
* by a webservice, false otherwise.
* @return void Nothing, or false on error
* */
public static function delete($id_checked, $from_ws = false)
@ -1512,6 +1517,7 @@ class SessionManager
/**
* @param int $id_promotion
*
* @return bool
*/
public static function clear_session_ref_promotion($id_promotion)
@ -1825,7 +1831,6 @@ class SessionManager
return false;
}
$courseCode = Database::escape_string($courseInfo['code']);
$courseId = $courseInfo['real_id'];
$statusCondition = null;
@ -2187,7 +2192,11 @@ class SessionManager
}
// Create
DocumentManager::generateDefaultCertificate($courseInfo, true, $sessionId);
DocumentManager::generateDefaultCertificate(
$courseInfo,
true,
$sessionId
);
}
}
@ -2397,8 +2406,15 @@ class SessionManager
* @param integer day_end
* @return $id_session;
* */
public static function create_category_session($sname, $syear_start, $smonth_start, $sday_start, $syear_end, $smonth_end, $sday_end)
{
public static function create_category_session(
$sname,
$syear_start,
$smonth_start,
$sday_start,
$syear_end,
$smonth_end,
$sday_end
) {
$tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
$name = trim($sname);
$year_start = intval($syear_start);
@ -2462,8 +2478,16 @@ class SessionManager
* @return $id;
* The parameter id is a primary key
* */
public static function edit_category_session($id, $sname, $syear_start, $smonth_start, $sday_start, $syear_end, $smonth_end, $sday_end)
{
public static function edit_category_session(
$id,
$sname,
$syear_start,
$smonth_start,
$sday_start,
$syear_end,
$smonth_end,
$sday_end
) {
$tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
$name = trim($sname);
$year_start = intval($syear_start);
@ -2658,7 +2682,9 @@ class SessionManager
{
$tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
$id = intval($id);
$sql = "SELECT id, name, date_start, date_end FROM $tbl_session_category WHERE id= $id";
$sql = "SELECT id, name, date_start, date_end
FROM $tbl_session_category
WHERE id= $id";
$result = Database::query($sql);
$num = Database::num_rows($result);
if ($num > 0) {
@ -3103,13 +3129,13 @@ class SessionManager
$sessions = array();
if (Database::num_rows($result) > 0) {
$sessionImage = '';
$sysUploadPath = api_get_path(SYS_UPLOAD_PATH). 'sessions/';
$webUploadPath = api_get_path(WEB_UPLOAD_PATH). 'sessions/';
$imgPath = api_get_path(WEB_IMG_PATH) . 'session_default_small.png';
$tableExtraFields = Database::get_main_table(TABLE_EXTRA_FIELD);
$sql = "SELECT id FROM " . $tableExtraFields . " WHERE extra_field_type = 3 AND variable='image'";
$sql = "SELECT id FROM " . $tableExtraFields . "
WHERE extra_field_type = 3 AND variable='image'";
$resultField = Database::query($sql);
$imageFieldId = Database::fetch_assoc($resultField);
@ -3286,8 +3312,8 @@ class SessionManager
/**
* Gets the list of courses by session filtered by access_url
* @param int session id
* @param string course_name
* @param int $session_id
* @param string $course_name
* @return array list of courses
*/
public static function get_course_list_by_session_id_like($session_id, $course_name = '')
@ -3705,8 +3731,9 @@ class SessionManager
$quiz_table = Database::get_course_table(TABLE_QUIZ_TEST);
$course_id = $course_info['real_id'];
//@todo check this query
$sql = "UPDATE $quiz_table SET active = 0 WHERE c_id = $course_id AND session_id = $sid";
$result = Database::query($sql);
$sql = "UPDATE $quiz_table SET active = 0
WHERE c_id = $course_id AND session_id = $sid";
Database::query($sql);
}
$new_short_courses[] = $course_info['real_id'];
}
@ -4955,13 +4982,21 @@ class SessionManager
continue;
}
$messages[] = Display::return_message(get_lang('StudentList') . '<br />' . $userToString, 'info', false);
SessionManager::suscribe_users_to_session($sessionDestinationId, $newUserList, SESSION_VISIBLE_READ_ONLY, false);
SessionManager::suscribe_users_to_session(
$sessionDestinationId,
$newUserList,
SESSION_VISIBLE_READ_ONLY,
false
);
}
} else {
$messages[] = Display::return_message(get_lang('NoDestinationSessionProvided'), 'warning');
}
} else {
$messages[] = Display::return_message(get_lang('NoStudentsFoundForSession') . ' #' . $sessionInfo['name'], 'warning');
$messages[] = Display::return_message(
get_lang('NoStudentsFoundForSession').' #'.$sessionInfo['name'],
'warning'
);
}
}
} else {
@ -5004,7 +5039,10 @@ class SessionManager
if (!empty($result)) {
foreach ($result as $courseCode => $data) {
$url = api_get_course_url($courseCode);
$htmlResult .= sprintf(get_lang('CoachesSubscribedAsATeacherInCourseX'), Display::url($courseCode, $url, array('target' => '_blank')));
$htmlResult .= sprintf(
get_lang('CoachesSubscribedAsATeacherInCourseX'),
Display::url($courseCode, $url, array('target' => '_blank'))
);
foreach ($data as $sessionId => $coachList) {
$sessionInfo = self::fetch($sessionId);
$htmlResult .= '<br />';
@ -5321,6 +5359,8 @@ class SessionManager
/**
* @param array $userSessionList format see self::importSessionDrhCSV()
*
* @return string
*/
public static function checkSubscribeDrhToSessionList($userSessionList)
{
@ -5368,6 +5408,8 @@ class SessionManager
* @param string $file
* @param bool $sendEmail
* @param bool $removeOldRelationShips
*
* @return string
*/
public static function importSessionDrhCSV($file, $sendEmail, $removeOldRelationShips)
{
@ -5564,6 +5606,7 @@ class SessionManager
* Gets one row from the session_rel_user table
* @param int $userId
* @param int $sessionId
*
* @return array
*/
public static function getUserSession($userId, $sessionId)
@ -5985,7 +6028,7 @@ class SessionManager
);
$sessionCategoryId = intval($sessionCategoryId);
// Check if sesssion category id is valid
// Check if session category id is valid
if ($sessionCategoryId > 0) {
// Get table names
$sessionTable = Database::get_main_table(TABLE_MAIN_SESSION);
@ -6296,15 +6339,16 @@ class SessionManager
$accessUrlId = api_get_current_access_url_id();
if ($accessUrlId != -1) {
$sql = "SELECT DISTINCT s.* "
. "FROM $sessionTable s "
. "INNER JOIN $sessionUserTable sru ON s.id = sru.id_session "
. "INNER JOIN $sessionAccessUrlTable srau ON s.id = srau.session_id "
. "WHERE srau.access_url_id = $accessUrlId "
. "AND ( "
. "sru.id_user IN (" . implode(', ', $userIdList) . ") "
. "AND sru.relation_type = 0"
. ")";
$sql = "SELECT DISTINCT s.*
FROM $sessionTable s
INNER JOIN $sessionUserTable sru ON s.id = sru.id_session
INNER JOIN $sessionAccessUrlTable srau ON s.id = srau.session_id
WHERE
srau.access_url_id = $accessUrlId
AND (
sru.id_user IN (" . implode(', ', $userIdList) . ")
AND sru.relation_type = 0
)";
}
}
@ -7277,7 +7321,7 @@ class SessionManager
public static function isSessionDateOkForCoach($sessionId)
{
return api_get_session_visibility($sessionId);
/*
$listSessionInfo = api_get_session_info($sessionId);
$dateStart = $listSessionInfo['date_start'];
$dateEnd = $listSessionInfo['date_end'];
@ -7306,7 +7350,7 @@ class SessionManager
}
}
return false;
return false;*/
}
/**
@ -7390,6 +7434,7 @@ class SessionManager
* sessionName
*
* @param $userId
*
* @return array
*
*/

@ -66,7 +66,7 @@ function edit_specific_field($id, $name)
}
$sql = 'UPDATE %s SET name = \'%s\' WHERE id = %s LIMIT 1';
$sql = sprintf($sql, $table_sf, $name, $id);
$result = Database::query($sql);
Database::query($sql);
}
/**
@ -278,25 +278,32 @@ function get_specific_field_code_from_name($name) {
'X',
'Y',
);
$table_sf = Database :: get_main_table(TABLE_MAIN_SPECIFIC_FIELD);
$table_sf = Database:: get_main_table(TABLE_MAIN_SPECIFIC_FIELD);
$sql = "SELECT code FROM $table_sf ORDER BY code";
$res = Database::query($sql);
$code = strtoupper(substr($name,0,1));
$code = strtoupper(substr($name, 0, 1));
//if no code exists in DB, return current one
if (Database::num_rows($res)<1) { return $code;}
if (Database::num_rows($res) < 1) {
return $code;
}
$existing_list = array();
while ($row = Database::fetch_array($res)) {
$existing_list[] = $row['code'];
}
//if the current code doesn't exist in DB, return current one
if (!in_array($code,$existing_list)) { return $code;}
if (!in_array($code, $existing_list)) {
return $code;
}
$idx = array_search($code,$list);
$idx = array_search($code, $list);
$c = count($list);
for ($i = $idx+1, $j=0 ; $j<$c ; $i++, $j++) {
if (!in_array($list[$i],$existing_list)) { return $idx[$i]; }
for ($i = $idx + 1, $j = 0; $j < $c; $i++, $j++) {
if (!in_array($list[$i], $existing_list)) {
return $idx[$i];
}
}
// all 26 codes are used
return false;
}

@ -115,13 +115,17 @@ if (isset($_GET['f']) && $_GET['f'] == 'social' || api_get_setting('allow_social
$actions = null;
//Comes from normal profile
if (api_get_setting('allow_social_tool') == 'true' && api_get_setting('allow_message_tool') == 'true') {
$actions .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.Display::return_icon('shared_profile.png', get_lang('ViewSharedProfile')).'</a>';
$actions .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.
Display::return_icon('shared_profile.png', get_lang('ViewSharedProfile')).'</a>';
}
if (api_get_setting('allow_message_tool') == 'true') {
$actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.Display::return_icon('message_new.png', get_lang('ComposeMessage')).'</a>';
$actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.Display::return_icon('inbox.png', get_lang('Inbox')).'</a>';
$actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.Display::return_icon('outbox.png', get_lang('Outbox')).'</a>';
$actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.
Display::return_icon('message_new.png', get_lang('ComposeMessage')).'</a>';
$actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.
Display::return_icon('inbox.png', get_lang('Inbox')).'</a>';
$actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.
Display::return_icon('outbox.png', get_lang('Outbox')).'</a>';
}
}
@ -137,8 +141,10 @@ $social_right_content = null;
if (api_get_setting('allow_social_tool') == 'true') {
$social_right_content .= '<div class="col-md-12">';
$social_right_content .= '<div class="actions">';
$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php?f=social">'.Display::return_icon('compose_message.png', get_lang('ComposeMessage'), array(), 32).'</a>';
$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php?f=social">'.Display::return_icon('outbox.png', get_lang('Outbox'), array(), 32).'</a>';
$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php?f=social">'.
Display::return_icon('compose_message.png', get_lang('ComposeMessage'), array(), 32).'</a>';
$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php?f=social">'.
Display::return_icon('outbox.png', get_lang('Outbox'), array(), 32).'</a>';
$social_right_content .= '</div>';
$social_right_content .= '</div>';
$social_right_content .= '<div class="col-md-12">';

@ -286,10 +286,16 @@ $socialToolIsActive = isset($_GET['f']) && $_GET['f'] == 'social';
/* MAIN SECTION */
if ($socialToolIsActive) {
$this_section = SECTION_SOCIAL;
$interbreadcrumb[]= array ('url' => api_get_path(WEB_PATH).'main/social/home.php','name' => get_lang('SocialNetwork'));
$interbreadcrumb[] = array(
'url' => api_get_path(WEB_PATH).'main/social/home.php',
'name' => get_lang('SocialNetwork'),
);
} else {
$this_section = SECTION_MYPROFILE;
$interbreadcrumb[]= array ('url' => api_get_path(WEB_PATH).'main/auth/profile.php','name' => get_lang('Profile'));
$interbreadcrumb[] = array(
'url' => api_get_path(WEB_PATH).'main/auth/profile.php',
'name' => get_lang('Profile'),
);
}
$group_id = isset($_REQUEST['group_id']) ? intval($_REQUEST['group_id']) : null;
@ -339,7 +345,10 @@ if (api_get_setting('allow_social_tool') == 'true') {
// MAIN CONTENT
if (!isset($_POST['compose'])) {
if(isset($_GET['re_id'])) {
$social_right_content .= show_compose_reply_to_message($_GET['re_id'], api_get_user_id());
$social_right_content .= show_compose_reply_to_message(
$_GET['re_id'],
api_get_user_id()
);
} elseif(isset($_GET['send_to_user'])) {
$social_right_content .= show_compose_to_user($_GET['send_to_user']);
} else {

Loading…
Cancel
Save