Adding new functions/options created in 1.10

skala
Julio Montoya 12 years ago
parent 6e81cab486
commit fd54364e94
  1. 4
      main/exercice/hotspot.class.php
  2. 24
      main/inc/lib/events.lib.inc.php
  3. 26
      main/inc/lib/group_portal_manager.lib.php
  4. 6
      main/inc/lib/main_api.lib.php
  5. 28
      main/inc/lib/sessionmanager.lib.php

@ -54,7 +54,7 @@ class HotSpot extends Question {
} }
function processCreation ($form, $objExercise) { function processCreation ($form, $objExercise = null) {
$file_info = $form -> getSubmitValue('imageUpload'); $file_info = $form -> getSubmitValue('imageUpload');
parent::processCreation ($form, $objExercise); parent::processCreation ($form, $objExercise);
if(!empty($file_info['tmp_name'])) { if(!empty($file_info['tmp_name'])) {
@ -102,7 +102,7 @@ class HotSpotDelineation extends HotSpot {
parent::createForm ($form, $fck_config); parent::createForm ($form, $fck_config);
} }
function processCreation ($form, $objExercise) { function processCreation ($form, $objExercise = null) {
$file_info = $form -> getSubmitValue('imageUpload'); $file_info = $form -> getSubmitValue('imageUpload');
parent::processCreation ($form, $objExercise); parent::processCreation ($form, $objExercise);
} }

@ -681,6 +681,30 @@ function get_event_users($event_name) {
return json_encode($user_list); return json_encode($user_list);
} }
function get_events_by_user_and_type($user_id, $event_type) {
global $TABLETRACK_DEFAULT;
$user_id = intval($user_id);
$event_type = Database::escape_string($event_type);
$sql = "SELECT * FROM $TABLETRACK_DEFAULT
WHERE default_value_type = 'user_id' AND
default_value = $user_id AND
default_event_type = '$event_type'
ORDER BY default_date ";
$result = Database::query($sql);
if ($result) {
return Database::store_result($result, 'ASSOC');
}
return false;
}
function get_latest_event_by_user_and_type($user_id, $event_type) {
$result = get_events_by_user_and_type($user_id, $event_type);
if ($result && !empty($result)) {
return $result[0];
}
}
/** /**
* Save the new message for one event and for one language * Save the new message for one event and for one language
* *

@ -1095,4 +1095,28 @@ class GroupPortalManager
Database::query($sql); Database::query($sql);
} }
} public static function get_groups_by_user_count($user_id = '', $relation_type = GROUP_USER_PERMISSION_READER, $with_image = false) {
$table_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP);
$tbl_group = Database::get_main_table(TABLE_MAIN_GROUP);
$user_id = intval($user_id);
if ($relation_type == 0) {
$where_relation_condition = '';
} else {
$relation_type = intval($relation_type);
$where_relation_condition = "AND gu.relation_type = $relation_type ";
}
$sql = "SELECT count(g.id) as count
FROM $tbl_group g
INNER JOIN $table_group_rel_user gu
ON gu.group_id = g.id WHERE gu.user_id = $user_id $where_relation_condition ";
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
$row = Database::fetch_array($result, 'ASSOC');
return $row['count'];
}
return 0;
}
}

@ -2089,6 +2089,12 @@ function api_get_settings_params($params) {
return $result; return $result;
} }
function api_get_settings_params_simple($params) {
$table = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
$result = Database::select('*', $table, array('where' => $params), 'one');
return $result;
}
/** /**
* Returns the value of a setting from the web-adjustable admin config settings. * Returns the value of a setting from the web-adjustable admin config settings.
**/ **/

@ -1559,6 +1559,34 @@ class SessionManager {
return $return_array; return $return_array;
} }
/**
* The general coach (field: session.id_coach)
* @param int user id
*/
public static function get_sessions_by_general_coach($user_id) {
$session_table = Database::get_main_table(TABLE_MAIN_SESSION);
$user_id = intval($user_id);
// session where we are general coach
$sql = "SELECT DISTINCT *
FROM $session_table
WHERE id_coach = $user_id";
if (api_is_multiple_url_enabled()) {
$tbl_session_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1) {
$sql = 'SELECT DISTINCT session.*
FROM '.$session_table.' session INNER JOIN '.$tbl_session_rel_access_url.' session_rel_url
ON (session.id = session_rel_url.session_id)
WHERE id_coach = '.$user_id.' AND access_url_id = '.$access_url_id;
}
}
$sql .= ' ORDER by name';
$result = Database::query($sql);
return Database::store_result($result, 'ASSOC');
}
public static function get_sessions_by_coach($user_id) { public static function get_sessions_by_coach($user_id) {
$session_table = Database::get_main_table(TABLE_MAIN_SESSION); $session_table = Database::get_main_table(TABLE_MAIN_SESSION);
return Database::select('*', $session_table, array('where'=>array('id_coach = ?'=>$user_id))); return Database::select('*', $session_table, array('where'=>array('id_coach = ?'=>$user_id)));

Loading…
Cancel
Save