Format code, add docs.

1.10.x
Julio Montoya 10 years ago
parent a9a92938fd
commit 099b17f076
  1. 6
      main/inc/introductionSection.inc.php
  2. 61
      main/inc/lib/glossary.lib.php
  3. 5
      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. 29
      main/inc/lib/specific_fields_manager.lib.php
  7. 18
      main/messages/inbox.php
  8. 195
      main/messages/new_message.php
  9. 8
      main/mySpace/access_details.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;
}
@ -455,19 +462,25 @@ 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');
$column = intval($column);
$session_id = api_get_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';
}
$from = intval($from);
$number_of_items = intval($number_of_items);
$sql = "SELECT glossary.name as col0,
glossary.description as col1,
$col2
glossary.session_id
$sql = "SELECT
glossary.name as col0,
glossary.description as col1,
$col2
glossary.session_id
FROM $t_glossary glossary, $t_item_propery ip
WHERE
glossary.glossary_id = ip.ref AND
@ -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,13 +573,15 @@ 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;
while ($data = Database::fetch_array($res)) {
$sql = "UPDATE $t_glossary SET display_order = $i
WHERE c_id = $course_id AND glossary_id = '".intval($data['glossary_id'])."'";
WHERE c_id = $course_id AND glossary_id = '".intval($data['glossary_id'])."'";
Database::query($sql);
$i++;
}
@ -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)) {
@ -610,9 +627,9 @@ class GlossaryManager
}
}
$sql1 = "UPDATE $t_glossary SET display_order = '".Database::escape_string($next_display_order)."'
WHERE c_id = $course_id AND glossary_id = '".Database::escape_string($current_id)."'";
WHERE c_id = $course_id AND glossary_id = '".Database::escape_string($current_id)."'";
$sql2 = "UPDATE $t_glossary SET display_order = '".Database::escape_string($current_display_order)."'
WHERE c_id = $course_id AND glossary_id = '".Database::escape_string($next_id)."'";
WHERE c_id = $course_id AND glossary_id = '".Database::escape_string($next_id)."'";
Database::query($sql1);
Database::query($sql2);
if ($message)
@ -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);
}
}

@ -13,13 +13,14 @@ class GradeModel extends Model
/**
* Constructor
*/
public function __construct()
public function __construct()
{
$this->table = Database::get_main_table(TABLE_GRADE_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
*
*/

@ -5,8 +5,8 @@
*/
// Database table definitions
$table_sf = Database :: get_main_table(TABLE_MAIN_SPECIFIC_FIELD);
$table_sf_val = Database :: get_main_table(TABLE_MAIN_SPECIFIC_FIELD_VALUES);
$table_sf = Database :: get_main_table(TABLE_MAIN_SPECIFIC_FIELD);
$table_sf_val = Database :: get_main_table(TABLE_MAIN_SPECIFIC_FIELD_VALUES);
/**
* Add a specific field
@ -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'];
$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">';

@ -153,14 +153,14 @@ function show_compose_to_user ($receiver_id) {
function manage_form($default, $select_from_user_list = null, $sent_to = null)
{
$group_id = isset($_REQUEST['group_id']) ? intval($_REQUEST['group_id']) : null;
$message_id = isset($_GET['message_id']) ? intval($_GET['message_id']) : null;
$param_f = isset($_GET['f']) && $_GET['f'] == 'social' ? 'social' : null;
$form = new FormValidator('compose_message', null, api_get_self().'?f='.$param_f, null, array('enctype'=>'multipart/form-data'));
if (empty($group_id)) {
if (isset($select_from_user_list)) {
$form->addText(
$group_id = isset($_REQUEST['group_id']) ? intval($_REQUEST['group_id']) : null;
$message_id = isset($_GET['message_id']) ? intval($_GET['message_id']) : null;
$param_f = isset($_GET['f']) && $_GET['f'] == 'social' ? 'social' : null;
$form = new FormValidator('compose_message', null, api_get_self().'?f='.$param_f, null, array('enctype'=>'multipart/form-data'));
if (empty($group_id)) {
if (isset($select_from_user_list)) {
$form->addText(
'id_text_name',
get_lang('SendMessageTo'),
true,
@ -170,54 +170,54 @@ function manage_form($default, $select_from_user_list = null, $sent_to = null)
'autocomplete'=>'off'
)
);
$form->addRule('id_text_name', get_lang('ThisFieldIsRequired'), 'required');
$form->addElement('html','<div id="id_div_search" style="padding:0px" class="message-select-box" >&nbsp;</div>');
$form->addElement('hidden','user_list', 0, array('id'=>'user_list'));
} else {
$form->addRule('id_text_name', get_lang('ThisFieldIsRequired'), 'required');
$form->addElement('html','<div id="id_div_search" style="padding:0px" class="message-select-box" >&nbsp;</div>');
$form->addElement('hidden','user_list', 0, array('id'=>'user_list'));
} else {
if (!empty($sent_to)) {
$form->addLabel(get_lang('SendMessageTo'), $sent_to);
}
if (empty($default['users'])) {
if (empty($default['users'])) {
//fb select
$form->addElement('select', 'users', get_lang('SendMessageTo'), array(), array('id' => 'users'));
} else {
$form->addElement('hidden','hidden_user',$default['users'][0],array('id'=>'hidden_user'));
}
}
} else {
$userGroup = new UserGroup();
$group_info = $userGroup->get($group_id);
} else {
$form->addElement('hidden','hidden_user',$default['users'][0],array('id'=>'hidden_user'));
}
}
} else {
$userGroup = new UserGroup();
$group_info = $userGroup->get($group_id);
$form->addElement('label', get_lang('ToGroup'), api_xml_http_response_encode($group_info['name']));
$form->addElement('hidden','group_id',$group_id);
$form->addElement('hidden','parent_id',$message_id);
}
$form->addElement('label', get_lang('ToGroup'), api_xml_http_response_encode($group_info['name']));
$form->addElement('hidden','group_id',$group_id);
$form->addElement('hidden','parent_id',$message_id);
}
$form->addText('title', get_lang('Subject'), true);
$form->addHtmlEditor(
'content',
get_lang('Message'),
false,
false,
array('ToolbarSet' => 'Messages', 'Width' => '100%', 'Height' => '250')
);
if (isset($_GET['re_id'])) {
$message_reply_info = MessageManager::get_message_by_id($_GET['re_id']);
$form->addText('title', get_lang('Subject'), true);
$form->addHtmlEditor(
'content',
get_lang('Message'),
false,
false,
array('ToolbarSet' => 'Messages', 'Width' => '100%', 'Height' => '250')
);
if (isset($_GET['re_id'])) {
$message_reply_info = MessageManager::get_message_by_id($_GET['re_id']);
$default['title'] = get_lang('MailSubjectReplyShort')." ".$message_reply_info['title'];
$form->addElement('hidden','re_id', intval($_GET['re_id']));
$form->addElement('hidden','save_form','save_form');
//adding reply mail
$user_reply_info = api_get_user_info($message_reply_info['user_sender_id']);
$default['content'] = '<p><br/></p>'.sprintf(
get_lang('XWroteY'),
$user_reply_info['complete_name'],
Security::filter_terms($message_reply_info['content'])
);
}
$form->addElement('hidden','re_id', intval($_GET['re_id']));
$form->addElement('hidden','save_form','save_form');
//adding reply mail
$user_reply_info = api_get_user_info($message_reply_info['user_sender_id']);
$default['content'] = '<p><br/></p>'.sprintf(
get_lang('XWroteY'),
$user_reply_info['complete_name'],
Security::filter_terms($message_reply_info['content'])
);
}
if (empty($group_id)) {
if (empty($group_id)) {
$form->addElement('label', '', '<div id="filepaths" class="form-group">
<div id="filepath_1">
@ -227,56 +227,56 @@ function manage_form($default, $select_from_user_list = null, $sent_to = null)
<input id="file-descrtiption" type="text" name="legend[]" class="form-control"/>
</div>
</div>'
);
);
$form->addElement('label', '', '<span id="link-more-attach"><a href="javascript://" onclick="return add_image_form()">'.get_lang('AddOneMoreFile').'</a></span>&nbsp;('.sprintf(get_lang('MaximunFileSizeX'),format_file_size(api_get_setting('message_max_upload_filesize'))).')');
}
$form->addElement('label', '', '<span id="link-more-attach"><a href="javascript://" onclick="return add_image_form()">'.get_lang('AddOneMoreFile').'</a></span>&nbsp;('.sprintf(get_lang('MaximunFileSizeX'),format_file_size(api_get_setting('message_max_upload_filesize'))).')');
}
$form->addButtonSend(get_lang('SendMessage'), 'compose');
$form->setRequiredNote('<span class="form_required">*</span> <small>'.get_lang('ThisFieldIsRequired').'</small>');
$form->addButtonSend(get_lang('SendMessage'), 'compose');
$form->setRequiredNote('<span class="form_required">*</span> <small>'.get_lang('ThisFieldIsRequired').'</small>');
if (!empty($group_id) && !empty($message_id)) {
$message_info = MessageManager::get_message_by_id($message_id);
$default['title'] = get_lang('MailSubjectReplyShort')." ".$message_info['title'];
}
$form->setDefaults($default);
if (!empty($group_id) && !empty($message_id)) {
$message_info = MessageManager::get_message_by_id($message_id);
$default['title'] = get_lang('MailSubjectReplyShort')." ".$message_info['title'];
}
$form->setDefaults($default);
$html = '';
if ($form->validate()) {
$check = Security::check_token('post');
if ($check) {
if ($form->validate()) {
$check = Security::check_token('post');
if ($check) {
$user_list = $default['users'];
$file_comments = $_POST['legend'];
$title = $default['title'];
$content = $default['content'];
$group_id = isset($default['group_id']) ? $default['group_id'] : null;
$parent_id = isset($default['parent_id']) ? $default['parent_id'] : null;
if (is_array($user_list) && count($user_list)> 0) {
//all is well, send the message
foreach ($user_list as $user) {
$res = MessageManager::send_message(
$user,
$title,
$content,
$_FILES,
$file_comments,
$group_id,
$parent_id
);
if ($res) {
$html .= MessageManager::display_success_message($user);
}
}
} else {
Display::display_error_message('ErrorSendingMessage');
}
}
Security::clear_token();
} else {
$token = Security::get_token();
$form->addElement('hidden','sec_token');
$form->setConstants(array('sec_token' => $token));
$html .= $form->returnForm();
}
$group_id = isset($default['group_id']) ? $default['group_id'] : null;
$parent_id = isset($default['parent_id']) ? $default['parent_id'] : null;
if (is_array($user_list) && count($user_list)> 0) {
//all is well, send the message
foreach ($user_list as $user) {
$res = MessageManager::send_message(
$user,
$title,
$content,
$_FILES,
$file_comments,
$group_id,
$parent_id
);
if ($res) {
$html .= MessageManager::display_success_message($user);
}
}
} else {
Display::display_error_message('ErrorSendingMessage');
}
}
Security::clear_token();
} else {
$token = Security::get_token();
$form->addElement('hidden','sec_token');
$form->setConstants(array('sec_token' => $token));
$html .= $form->returnForm();
}
return $html;
}
@ -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 {
@ -355,7 +364,7 @@ if (!isset($_POST['compose'])) {
$restrict = true;
}
$default['title'] = $_POST['title'];
$default['title'] = $_POST['title'];
$default['content'] = $_POST['content'];
// comes from a reply button

@ -139,10 +139,10 @@ $form->display();
<div id="cev_cont_stats">
<?php
if ($result_to_print != "") {
$rst = get_stats($user_id, $courseId);
$foo_stats = '<strong>'.get_lang('Total').': </strong>'.$rst['total'].'<br />';
$foo_stats .= '<strong>'.get_lang('Average').': </strong>'.$rst['avg'].'<br />';
$foo_stats .= '<strong>'.get_lang('Quantity').' : </strong>'.$rst['times'].'<br />';
$rst = get_stats($user_id, $courseId);
$foo_stats = '<strong>'.get_lang('Total').': </strong>'.$rst['total'].'<br />';
$foo_stats .= '<strong>'.get_lang('Average').': </strong>'.$rst['avg'].'<br />';
$foo_stats .= '<strong>'.get_lang('Quantity').' : </strong>'.$rst['times'].'<br />';
echo $foo_stats;
} else {
echo Display::display_warning_message(get_lang('NoDataAvailable'));

Loading…
Cancel
Save