Minor - remove unused code, add int casting

pull/2865/head
Julio 7 years ago
parent 9f4829cbea
commit 4606bc7186
  1. 40
      main/inc/lib/agenda.lib.php

@ -2705,10 +2705,14 @@ class Agenda
*/ */
public function getAttachment($attachmentId, $eventId, $courseInfo) public function getAttachment($attachmentId, $eventId, $courseInfo)
{ {
if (empty($courseInfo) || empty($attachmentId) || empty($eventId)) {
return [];
}
$tableAttachment = Database::get_course_table(TABLE_AGENDA_ATTACHMENT); $tableAttachment = Database::get_course_table(TABLE_AGENDA_ATTACHMENT);
$courseId = intval($courseInfo['real_id']); $courseId = (int) $courseInfo['real_id'];
$eventId = intval($eventId); $eventId = (int) $eventId;
$attachmentId = intval($attachmentId); $attachmentId = (int) $attachmentId;
$row = []; $row = [];
$sql = "SELECT id, path, filename, comment $sql = "SELECT id, path, filename, comment
@ -2743,7 +2747,7 @@ class Agenda
$courseInfo $courseInfo
) { ) {
$agenda_table_attachment = Database::get_course_table(TABLE_AGENDA_ATTACHMENT); $agenda_table_attachment = Database::get_course_table(TABLE_AGENDA_ATTACHMENT);
$eventId = intval($eventId); $eventId = (int) $eventId;
// Storing the attachments // Storing the attachments
$upload_ok = false; $upload_ok = false;
@ -2880,6 +2884,8 @@ class Agenda
public function getAllRepeatEvents($eventId) public function getAllRepeatEvents($eventId)
{ {
$events = []; $events = [];
$eventId = (int) $eventId;
switch ($this->type) { switch ($this->type) {
case 'personal': case 'personal':
break; break;
@ -3094,7 +3100,7 @@ class Agenda
api_get_self().'?action=importical&type='.$this->type, api_get_self().'?action=importical&type='.$this->type,
['enctype' => 'multipart/form-data'] ['enctype' => 'multipart/form-data']
); );
$form->addElement('header', get_lang('ICalFileImport')); $form->addHeader(get_lang('ICalFileImport'));
$form->addElement('file', 'ical_import', get_lang('ICalFileImport')); $form->addElement('file', 'ical_import', get_lang('ICalFileImport'));
$form->addRule( $form->addRule(
'ical_import', 'ical_import',
@ -4059,30 +4065,6 @@ class Agenda
return $items; return $items;
} }
/**
* This function retrieves one personal agenda item returns it.
*
* @param int $id The agenda item ID
*
* @return array The results of the database query, or null if not found
*/
public static function get_personal_agenda_item($id)
{
$table = Database::get_main_table(TABLE_PERSONAL_AGENDA);
$id = intval($id);
// make sure events of the personal agenda can only be seen by the user himself
$user = api_get_user_id();
$sql = " SELECT * FROM ".$table." WHERE id=".$id." AND user = ".$user;
$result = Database::query($sql);
if (Database::num_rows($result) == 1) {
$item = Database::fetch_array($result);
} else {
$item = null;
}
return $item;
}
/** /**
* This function calculates the startdate of the week (monday) * This function calculates the startdate of the week (monday)
* and the enddate of the week (sunday) * and the enddate of the week (sunday)

Loading…
Cancel
Save