@ -72,7 +72,6 @@ class Agenda {
$id = Database::insert($this->tbl_personal_agenda, $attributes);
$id = Database::insert($this->tbl_personal_agenda, $attributes);
break;
break;
case 'course':
case 'course':
//$attributes['user'] = api_get_user_id();
$attributes['title'] = $title;
$attributes['title'] = $title;
$attributes['content'] = $content;
$attributes['content'] = $content;
$attributes['start_date'] = $start;
$attributes['start_date'] = $start;
@ -85,14 +84,14 @@ class Agenda {
$id = Database::insert($this->tbl_course_agenda, $attributes);
$id = Database::insert($this->tbl_course_agenda, $attributes);
if ($id) {
if ($id) {
//api_item_property_update($this->course, TOOL_CALENDAR_EVENT, $id, "AgendaAdded", api_get_user_id(), '','',$start, $end);
$group_id = api_get_group_id();
$group_id = api_get_group_id();
if ((!is_null($users_to_send)) or (!empty($group_id))) {
if ((!is_null($users_to_send)) or (!empty($group_id))) {
$send_to = self::separate_users_groups($users_to_send);
$send_to = self::separate_users_groups($users_to_send);
if (isset($send_to['everyone']) & & $send_to['everyone']) {
if (isset($send_to['everyone']) & & $send_to['everyone']) {
api_item_property_update($this->course, TOOL_CALENDAR_EVENT, $id,"AgendaAdded", api_get_user_id(), '','',$start, $end);
api_item_property_update($this->course, TOOL_CALENDAR_EVENT, $id,"AgendaAdded", api_get_user_id(), $group_id ,'', $start, $end);
} else {
} else {
// storing the selected groups
// storing the selected groups
if (is_array($send_to['groups'])) {
if (is_array($send_to['groups'])) {
@ -103,8 +102,8 @@ class Agenda {
// storing the selected users
// storing the selected users
if (is_array($send_to['users'])) {
if (is_array($send_to['users'])) {
foreach ($send_to['users'] as $my_user_id) {
foreach ($send_to['users'] as $to_user_id) {
api_item_property_update($this->course, TOOL_CALENDAR_EVENT, $id, "AgendaAdded", api_get_user_id(), 0, $my_user_id, $start, $end);
api_item_property_update($this->course, TOOL_CALENDAR_EVENT, $id, "AgendaAdded", api_get_user_id(), $group_id, $to_user_id, $start, $end);
}
}
}
}
}
}
@ -114,7 +113,6 @@ class Agenda {
self::store_agenda_item_as_announcement($id);
self::store_agenda_item_as_announcement($id);
}
}
}
}
break;
break;
case 'admin':
case 'admin':
$attributes['title'] = $title;
$attributes['title'] = $title;
@ -261,7 +259,7 @@ class Agenda {
* @param int course id *integer* not the course code
* @param int course id *integer* not the course code
*
*
*/
*/
function get_events($start, $end, $user_id, $ course_id = null, $group_id = null) {
function get_events($start, $end, $course_id = null, $group_id = null) {
switch ($this->type) {
switch ($this->type) {
case 'admin':
case 'admin':
@ -424,6 +422,7 @@ class Agenda {
WHERE date >= '".$start."' AND (enddate < ='".$end."' OR enddate IS NULL) AND user = $user_id";
WHERE date >= '".$start."' AND (enddate < ='".$end."' OR enddate IS NULL) AND user = $user_id";
$result = Database::query($sql);
$result = Database::query($sql);
$my_events = array();
if (Database::num_rows($result)) {
if (Database::num_rows($result)) {
while ($row = Database::fetch_array($result, 'ASSOC')) {
while ($row = Database::fetch_array($result, 'ASSOC')) {
$event = array();
$event = array();
@ -455,7 +454,6 @@ class Agenda {
function get_course_events($start, $end, $course_info, $group_id = 0) {
function get_course_events($start, $end, $course_info, $group_id = 0) {
$course_id = $course_info['real_id'];
$course_id = $course_info['real_id'];
$group_list = GroupManager::get_group_list(null, $course_info['code']);
$group_list = GroupManager::get_group_list(null, $course_info['code']);
$group_name_list = array();
$group_name_list = array();
@ -709,7 +707,6 @@ class Agenda {
$html = '< select id = "users_to_send_id" data-placeholder = "'.get_lang('Select').'" name = "users_to_send[]" multiple = "multiple" style = "width:250px" class = "chzn-select" > ';
$html = '< select id = "users_to_send_id" data-placeholder = "'.get_lang('Select').'" name = "users_to_send[]" multiple = "multiple" style = "width:250px" class = "chzn-select" > ';
// adding the groups to the select form
// adding the groups to the select form
if (isset($to_already_selected) & & $to_already_selected==='everyone') {
if (isset($to_already_selected) & & $to_already_selected==='everyone') {
}
}
@ -718,12 +715,13 @@ class Agenda {
if (is_array($group_list)) {
if (is_array($group_list)) {
$html .= '< optgroup label = "'.get_lang('Groups').'" > ';
$html .= '< optgroup label = "'.get_lang('Groups').'" > ';
foreach ($group_list as $this_group) {
foreach ($group_list as $this_group) {
//api_display_normal_message("group " . $thisGroup[id] . $thisGroup[name]);
if (!is_array($to_already_selected) || !in_array("GROUP:".$this_group['id'], $to_already_selected)) {
if (!is_array($to_already_selected) || !in_array("GROUP:".$this_group['id'], $to_already_selected)) {
// $to_already_selected is the array containing the groups (and users) that are already selected
// $to_already_selected is the array containing the groups (and users) that are already selected
$html .= "< option value = \"GROUP:".$this_group['id']."\" > ".
$count_users = isset($this_group['count_users']) ? $this_group['count_users'] : $this_group['userNb'];
$this_group['name']." – " . $this_group['userNb'] . " " . get_lang('Users') .
$count_users = " – $count_users ".get_lang('Users');
"< / option > ";
$html .= '< option value = "GROUP:'.$this_group['id'].'" > '.$this_group['name'].$count_users.'< / option > ';
//$html .= "< option value = \"GROUP:".$this_group['id']."\" > ".$this_group['name']." ".get_lang('Users')."< / option > ";
}
}
}
}
$html .= '< / optgroup > ';
$html .= '< / optgroup > ';