Minor - Format code

1.10.x
jmontoyaa 9 years ago
parent 41de17be66
commit 9bb86dee35
  1. 89
      main/inc/lib/agenda.lib.php
  2. 1
      main/inc/lib/banner.lib.php

@ -48,7 +48,6 @@ class Agenda
$this->event_session_color = '#00496D'; // kind of green $this->event_session_color = '#00496D'; // kind of green
$this->eventOtherSessionColor = '#999'; $this->eventOtherSessionColor = '#999';
$this->event_personal_color = 'steel blue'; //steel blue $this->event_personal_color = 'steel blue'; //steel blue
} }
/** /**
@ -508,24 +507,24 @@ class Agenda
} }
/** /**
* @param int $item_id * @param int $itemId
* @param array $sentTo * @param array $sentTo
* @return int * @return int
*/ */
public function storeAgendaEventAsAnnouncement($item_id, $sentTo = array()) public function storeAgendaEventAsAnnouncement($itemId, $sentTo = array())
{ {
$table_agenda = Database::get_course_table(TABLE_AGENDA); $table_agenda = Database::get_course_table(TABLE_AGENDA);
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
// Check params // Check params
if (empty($item_id) or $item_id != strval(intval($item_id))) { if (empty($itemId) || $itemId != strval(intval($itemId))) {
return -1; return -1;
} }
// Get the agenda item. // Get the agenda item.
$item_id = intval($item_id); $itemId = intval($itemId);
$sql = "SELECT * FROM $table_agenda $sql = "SELECT * FROM $table_agenda
WHERE c_id = $course_id AND id = ".$item_id; WHERE c_id = $course_id AND id = ".$itemId;
$res = Database::query($sql); $res = Database::query($sql);
if (Database::num_rows($res) > 0) { if (Database::num_rows($res) > 0) {
@ -622,7 +621,6 @@ class Agenda
} }
if ($this->getIsAllowedToEdit()) { if ($this->getIsAllowedToEdit()) {
$attributes = array( $attributes = array(
'title' => $title, 'title' => $title,
'content' => $content, 'content' => $content,
@ -650,12 +648,10 @@ class Agenda
$usersToDelete = array_diff($eventInfo['send_to']['users'], $sendTo['users']); $usersToDelete = array_diff($eventInfo['send_to']['users'], $sendTo['users']);
$usersToAdd = array_diff($sendTo['users'], $eventInfo['send_to']['users']); $usersToAdd = array_diff($sendTo['users'], $eventInfo['send_to']['users']);
$groupsToDelete = array_diff($eventInfo['send_to']['groups'], $sendTo['groups']); $groupsToDelete = array_diff($eventInfo['send_to']['groups'], $sendTo['groups']);
$groupToAdd = array_diff($sendTo['groups'], $eventInfo['send_to']['groups']); $groupToAdd = array_diff($sendTo['groups'], $eventInfo['send_to']['groups']);
if ($sendTo['everyone']) { if ($sendTo['everyone']) {
// Delete all from group // Delete all from group
if (isset($eventInfo['send_to']['groups']) && if (isset($eventInfo['send_to']['groups']) &&
!empty($eventInfo['send_to']['groups']) !empty($eventInfo['send_to']['groups'])
@ -702,7 +698,6 @@ class Agenda
$this->sessionId $this->sessionId
); );
} else { } else {
// Delete "everyone". // Delete "everyone".
api_item_property_delete( api_item_property_delete(
$this->course, $this->course,
@ -1809,53 +1804,6 @@ class Agenda
return $eventDate->format(DateTime::ISO8601); return $eventDate->format(DateTime::ISO8601);
} }
/**
* this function shows the form with the user that were not selected
* @author: Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @return string code
*/
public static function construct_not_selected_select_form($group_list = null, $user_list = null, $to_already_selected = array())
{
$html = '<select id="users_to_send_id" data-placeholder="'.get_lang('Select').'" name="users_to_send[]" multiple="multiple">';
if ($to_already_selected == 'everyone') {
$html .= '<option value="everyone" checked="checked">'.get_lang('Everyone').'</option>';
} else {
$html .= '<option value="everyone">'.get_lang('Everyone').'</option>';
}
if (is_array($group_list)) {
$html .= '<optgroup label="'.get_lang('Groups').'">';
foreach ($group_list as $this_group) {
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
$count_users = isset($this_group['count_users']) ? $this_group['count_users'] : $this_group['userNb'];
$count_users = " &ndash; $count_users ".get_lang('Users');
$html .= '<option value="GROUP:'.$this_group['id'].'"> '.$this_group['name'].$count_users.'</option>';
}
}
$html .= '</optgroup>';
}
// adding the individual users to the select form
if (is_array($group_list)) {
$html .= '<optgroup label="'.get_lang('Users').'">';
}
foreach ($user_list as $this_user) {
// $to_already_selected is the array containing the users (and groups) that are already selected
if (!is_array($to_already_selected) || !in_array("USER:".$this_user['user_id'], $to_already_selected)) {
$username = api_htmlentities(sprintf(get_lang('LoginX'), $this_user['username']), ENT_QUOTES);
// @todo : add title attribute $username in the jqdialog window. wait for a chosen version to inherit title attribute
$html .= '<option title="'.$username.'" value="USER:'.$this_user['user_id'].'">'.api_get_person_name($this_user['firstname'], $this_user['lastname']).' ('.$this_user['username'].') </option>';
}
}
if (is_array($group_list)) {
$html .= '</optgroup>';
$html .= "</select>";
}
return $html;
}
/** /**
* @param FormValidator $form * @param FormValidator $form
* @param array $groupList * @param array $groupList
@ -1867,10 +1815,10 @@ class Agenda
*/ */
public function setSendToSelect( public function setSendToSelect(
$form, $form,
$groupList = null, $groupList = [],
$userList = null, $userList = [],
$sendTo = array(), $sendTo = [],
$attributes = array(), $attributes = [],
$addOnlyItemsInSendTo = false, $addOnlyItemsInSendTo = false,
$required = false $required = false
) { ) {
@ -1898,7 +1846,7 @@ class Agenda
$form->setRequired($select); $form->setRequired($select);
} }
$selectedEveryoneOptions = array(); $selectedEveryoneOptions = [];
if (isset($sendTo['everyone']) && $sendTo['everyone']) { if (isset($sendTo['everyone']) && $sendTo['everyone']) {
$selectedEveryoneOptions = array('selected'); $selectedEveryoneOptions = array('selected');
$sendToUsers = array(); $sendToUsers = array();
@ -2159,7 +2107,6 @@ class Agenda
); );
} }
} }
} }
// } // }
@ -2235,7 +2182,6 @@ class Agenda
); );
return true; return true;
} }
/** /**
@ -2337,7 +2283,7 @@ class Agenda
* Add an attachment file into agenda * Add an attachment file into agenda
* @param int $eventId * @param int $eventId
* @param array $fileUserUpload ($_FILES['user_upload']) * @param array $fileUserUpload ($_FILES['user_upload'])
* @param string comment about file * @param string $comment about file
* @param array $courseInfo * @param array $courseInfo
* @return string * @return string
*/ */
@ -2542,7 +2488,7 @@ class Agenda
$sql = "SELECT count(DISTINCT(id)) as count $sql = "SELECT count(DISTINCT(id)) as count
FROM ".$this->tbl_course_agenda." FROM ".$this->tbl_course_agenda."
WHERE WHERE
c_id = ".$courseId." AND c_id = $courseId AND
parent_event_id = ".$eventId; parent_event_id = ".$eventId;
$result = Database::query($sql); $result = Database::query($sql);
if (Database::num_rows($result)) { if (Database::num_rows($result)) {
@ -2591,9 +2537,7 @@ class Agenda
); );
if ($this->type == 'course') { if ($this->type == 'course') {
if (!isset($_GET['action'])) { if (!isset($_GET['action'])) {
$form = new FormValidator( $form = new FormValidator(
'form-search', 'form-search',
'post', 'post',
@ -2620,10 +2564,9 @@ class Agenda
api_is_session_admin() || api_is_session_admin() ||
api_is_coach() api_is_coach()
) { ) {
if ($this->type == 'personal') { if ($this->type === 'personal') {
$form = null; $form = null;
if (!isset($_GET['action'])) { if (!isset($_GET['action'])) {
$form = new FormValidator( $form = new FormValidator(
'form-search', 'form-search',
'get', 'get',
@ -2740,7 +2683,6 @@ class Agenda
/** @var Sabre\VObject\Property\ICalendar\Recur $repeat */ /** @var Sabre\VObject\Property\ICalendar\Recur $repeat */
$repeat = $event->RRULE; $repeat = $event->RRULE;
if ($id && !empty($repeat)) { if ($id && !empty($repeat)) {
$repeat = $repeat->getParts(); $repeat = $repeat->getParts();
$freq = $trans[$repeat['FREQ']]; $freq = $trans[$repeat['FREQ']];
@ -2812,15 +2754,16 @@ class Agenda
$groupId = null; $groupId = null;
$userId = null; $userId = null;
if ($filter == 'everyone') { if ($filter === 'everyone') {
$everyone = true; $everyone = true;
} else { } else {
if (substr($filter, 0, 1) == 'G') { if (substr($filter, 0, 1) === 'G') {
$groupId = str_replace('GROUP:', '', $filter); $groupId = str_replace('GROUP:', '', $filter);
} else { } else {
$userId = str_replace('USER:', '', $filter); $userId = str_replace('USER:', '', $filter);
} }
} }
if (empty($userId) && empty($groupId)) { if (empty($userId) && empty($groupId)) {
$everyone = true; $everyone = true;
} }

@ -148,6 +148,7 @@ function getCustomTabs()
} }
/** /**
*
* @param string $theme * @param string $theme
*/ */
function return_logo($theme) function return_logo($theme)

Loading…
Cancel
Save