Skip to content

Commit

Permalink
Format code + add api_get_cidreq + use api_get_path()
Browse files Browse the repository at this point in the history
  • Loading branch information
jmontoyaa committed Mar 1, 2016
1 parent 6a6ac98 commit a9322ed
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 41 deletions.
4 changes: 2 additions & 2 deletions main/dropbox/dropbox_class.inc.php
Expand Up @@ -689,8 +689,8 @@ function deleteSentWork($id)
/**
* Updates feedback for received work of this person with id=$id
*
* @param unknown_type $id
* @param unknown_type $text
* @param string $id
* @param string $text
*/
function updateFeedback($id, $text)
{
Expand Down
2 changes: 1 addition & 1 deletion main/dropbox/dropbox_download.php
Expand Up @@ -57,7 +57,7 @@
while ($row = Database::fetch_array($result)) {
$files_to_download[] = $row['id'];
}
if (!is_array($files_to_download) OR empty($files_to_download)) {
if (!is_array($files_to_download) || empty($files_to_download)) {
header('location: index.php?view='.Security::remove_XSS($_GET['sent_received']).'&error=ErrorNoFilesInFolder');
exit;
}
Expand Down
15 changes: 9 additions & 6 deletions main/dropbox/dropbox_functions.inc.php
Expand Up @@ -329,7 +329,7 @@ function get_dropbox_categories($filter = '')

$result = Database::query($sql);
while ($row = Database::fetch_array($result)) {
if (($filter == 'sent' AND $row['sent'] == 1) OR ($filter == 'received' AND $row['received'] == 1) OR $filter == '') {
if (($filter == 'sent' && $row['sent'] == 1) || ($filter == 'received' && $row['received'] == 1) || $filter == '') {
$return_array[$row['cat_id']] = $row;
}
}
Expand Down Expand Up @@ -507,7 +507,7 @@ function display_addcategory_form($category_name = '', $id = '', $action)
$form = new FormValidator('add_new_category', 'post', api_get_self().'?view='.Security::remove_XSS($_GET['view']));
$form->addElement('header', $title);

if (isset($id) AND $id != '') {
if (isset($id) && $id != '') {
$form->addElement('hidden', 'edit_id', intval($id));
}
$form->addElement('hidden', 'action', Security::remove_XSS($action));
Expand Down Expand Up @@ -560,7 +560,7 @@ function display_add_form($dropbox_unid, $viewReceivedCategory, $viewSentCategor
$form->addElement('file', 'file', get_lang('UploadFile'), array('onChange' => 'javascript: checkfile(this.value);'));

if (dropbox_cnf('allowOverwrite')) {
$form->addElement('checkbox', 'cb_overwrite', null, get_lang('OverwriteFile'), array('id' => 'cb_overwrite'));
$form->addElement('checkbox', 'cb_overwrite', null, get_lang('OverwriteFile'), array('id' => 'cb_overwrite'));
}

// List of all users in this course and all virtual courses combined with it
Expand Down Expand Up @@ -715,7 +715,10 @@ function getUserNameFromId($id)
$result = Database::query($sql);
$res = Database::fetch_array($result);

if (!$res) return false;
if (!$res) {
return false;
}

return stripslashes($res['name']);
}

Expand Down Expand Up @@ -871,7 +874,7 @@ function store_add_dropbox()
// Validating the form data

// there are no recipients selected
if (!isset($_POST['recipients']) || count( $_POST['recipients']) <= 0) {
if (!isset($_POST['recipients']) || count($_POST['recipients']) <= 0) {
return get_lang('YouMustSelectAtLeastOneDestinee');
} else {
// Check if all the recipients are valid
Expand Down Expand Up @@ -988,7 +991,7 @@ function store_add_dropbox()
$new_work_recipients = array();
foreach ($_POST['recipients'] as $rec) {
if (strpos($rec, 'user_') === 0) {
$new_work_recipients[] = substr($rec, strlen('user_') );
$new_work_recipients[] = substr($rec, strlen('user_'));
} elseif (strpos($rec, 'group_') === 0) {
$userList = GroupManager::get_subscribed_users(substr($rec, strlen('group_')));
foreach ($userList as $usr) {
Expand Down
33 changes: 24 additions & 9 deletions main/dropbox/dropbox_init.inc.php
Expand Up @@ -278,8 +278,7 @@ function undisplayEl(id)
$javascript .= "
</script>";
$htmlHeadXtra[] = $javascript;
$htmlHeadXtra[] =
"<script type=\"text/javascript\">
$htmlHeadXtra[] ="<script>
function confirmation (name)
{
if (confirm(\" ". get_lang("AreYouSureToDeleteJS") ." \"+ name + \" ?\"))
Expand All @@ -289,7 +288,7 @@ function confirmation (name)
}
</script>";

Session::write('javascript',$javascript);
Session::write('javascript', $javascript);

$htmlHeadXtra[] = '<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="pragma" content="no-cache">
Expand All @@ -302,12 +301,13 @@ function confirmation (name)
$part = 'sent';
} else {
header('location: index.php?view='.$view.'&error=Error');
exit;
}

if (($postAction == 'download_received' || $postAction == 'download_sent') and !$_POST['store_feedback']) {
$checked_file_ids = $_POST['id'];
if (!is_array($checked_file_ids) || count($checked_file_ids) == 0) {
header ('location: index.php?view='.$view.'&error=CheckAtLeastOneFile');
header('location: index.php?view='.$view.'&error=CheckAtLeastOneFile');
} else {
handle_multiple_actions();
}
Expand All @@ -331,25 +331,40 @@ function confirmation (name)
/* BREADCRUMBS */

if ($view == 'received') {
$interbreadcrumb[] = array('url' => '../dropbox/index.php', 'name' => get_lang('Dropbox', ''));
$interbreadcrumb[] = array(
'url' => api_get_path(WEB_CODE_PATH).'dropbox/index.php?'.api_get_cidreq(),
'name' => get_lang('Dropbox', ''),
);
$nameTools = get_lang('ReceivedFiles');

if ($action == 'addreceivedcategory') {
$interbreadcrumb[] = array('url' => '../dropbox/index.php?view=received', 'name' => get_lang('ReceivedFiles'));
$interbreadcrumb[] = array(
'url' => api_get_path(WEB_CODE_PATH).'dropbox/index.php?view=received&'.api_get_cidreq(),
'name' => get_lang('ReceivedFiles'),
);
$nameTools = get_lang('AddNewCategory');
}
}

if ($view == 'sent' || empty($view)) {
$interbreadcrumb[] = array('url' => '../dropbox/index.php', 'name' => get_lang('Dropbox', ''));
$interbreadcrumb[] = array(
'url' => api_get_path(WEB_CODE_PATH).'dropbox/index.php?'.api_get_cidreq(),
'name' => get_lang('Dropbox')
);
$nameTools = get_lang('SentFiles');

if ($action == 'addsentcategory') {
$interbreadcrumb[] = array('url' => '../dropbox/index.php?view=sent', 'name' => get_lang('SentFiles'));
$interbreadcrumb[] = array(
'url' => api_get_path(WEB_CODE_PATH).'dropbox/index.php?view=sent&'.api_get_cidreq(),
'name' => get_lang('SentFiles'),
);
$nameTools = get_lang('AddNewCategory');
}
if ($action == 'add') {
$interbreadcrumb[] = array ('url' => '../dropbox/index.php?view=sent', 'name' => get_lang('SentFiles'));
$interbreadcrumb[] = array(
'url' => api_get_path(WEB_CODE_PATH).'dropbox/index.php?view=sent&'.api_get_cidreq(),
'name' => get_lang('SentFiles'),
);
$nameTools = get_lang('UploadNewFile');
}
}
Expand Down
2 changes: 1 addition & 1 deletion main/dropbox/dropbox_submit.php
Expand Up @@ -227,7 +227,7 @@
} else {
die(get_lang('GeneralError').' (code 409)');
}
} elseif (isset( $_GET['deleteSent'])) {
} elseif (isset($_GET['deleteSent'])) {
if ($_GET['deleteSent'] == 'all') {
$dropbox_person->deleteAllSentWork( );
} elseif (is_numeric($_GET['deleteSent'])) {
Expand Down
33 changes: 18 additions & 15 deletions main/dropbox/index.php
Expand Up @@ -158,11 +158,11 @@
// (which also happens in dropbox_init.inc.php

if (!isset($_POST['feedback']) && (
strstr($postAction, 'move_received') OR
strstr($postAction, 'move_sent') OR
$postAction == 'delete_received' OR
$postAction == 'download_received' OR
$postAction == 'delete_sent' OR
strstr($postAction, 'move_received') ||
strstr($postAction, 'move_sent') ||
$postAction == 'delete_received' ||
$postAction == 'download_received' ||
$postAction == 'delete_sent' ||
$postAction == 'download_sent')
) {
$display_message = handle_multiple_actions();
Expand Down Expand Up @@ -286,10 +286,13 @@
?>
<ul class="nav nav-tabs">
<li <?php if (!$view || $view == 'sent') { echo 'class="active"'; } ?> >
<a href="index.php?<?php echo api_get_cidreq(); ?>&view=sent" ><?php echo get_lang('SentFiles'); ?></a>
<a href="<?php echo api_get_path(WEB_CODE_PATH).'dropbox/'; ?>index.php?<?php echo api_get_cidreq(); ?>&view=sent" >
<?php echo get_lang('SentFiles'); ?>
</a>
</li>
<li <?php if ($view == 'received') { echo 'class="active"'; } ?> >
<a href="index.php?<?php echo api_get_cidreq(); ?>&view=received" ><?php echo get_lang('ReceivedFiles'); ?></a>
<a href="<?php echo api_get_path(WEB_CODE_PATH).'dropbox/'; ?>index.php?<?php echo api_get_cidreq(); ?>&view=received" >
<?php echo get_lang('ReceivedFiles'); ?></a>
</li>
</ul>
<?php
Expand Down Expand Up @@ -373,9 +376,9 @@
$new_icon = '&nbsp;'.Display::return_icon('new_dropbox_message.png', get_lang('New'),'',ICON_SIZE_SMALL);
}

$link_open = '<a href="dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'">';
$link_open = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'">';
$dropbox_file_data[] = $link_open.DocumentManager::build_document_icon_tag('file', $dropbox_file->title).'</a>';
$dropbox_file_data[] = '<a href="dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'&action=download">'.
$dropbox_file_data[] = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'&action=download">'.
Display::return_icon('save.png', get_lang('Download'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.$dropbox_file->title.'</a>'.$new_icon.'<br />'.$dropbox_file->description;
$file_size = $dropbox_file->filesize;
$dropbox_file_data[] = format_file_size($file_size);
Expand All @@ -395,7 +398,7 @@

if ($action == 'viewfeedback' AND isset($_GET['id']) and is_numeric($_GET['id']) AND $dropbox_file->id == $_GET['id']) {
$action_icons .= "</td></tr>"; // Ending the normal row of the sortable table
$action_icons .= '<tr><td colspan="2"><a href="index.php?"'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory."&view_sent_category=".$viewSentCategory."&view=".$view.'&'.$sort_params."\">".get_lang('CloseFeedback')."</a></td><td colspan=\"7\">".feedback($dropbox_file->feedback2)."</td></tr>";
$action_icons .= '<tr><td colspan="2"><a href="'.api_get_path(WEB_CODE_PATH).'dropbox/index.php?"'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory."&view_sent_category=".$viewSentCategory."&view=".$view.'&'.$sort_params."\">".get_lang('CloseFeedback')."</a></td><td colspan=\"7\">".feedback($dropbox_file->feedback2)."</td></tr>";
}
if (api_get_session_id() == 0) {
$dropbox_file_data[] = $action_icons;
Expand Down Expand Up @@ -423,7 +426,7 @@
// The icon of the category
$link_open = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$category['cat_id'].'&view_sent_category='.$viewSentCategory.'&view='.$view.'">';
$dropbox_category_data[] = $link_open.DocumentManager::build_document_icon_tag('folder', $category['cat_name']).'</a>';
$dropbox_category_data[] = '<a href="dropbox_download.php?'.api_get_cidreq().'&cat_id='.$category['cat_id'].'&action=downloadcategory&sent_received=received">'.Display::return_icon('save_pack.png', get_lang('Save'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.$category['cat_name'].'</a>';
$dropbox_category_data[] = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&cat_id='.$category['cat_id'].'&action=downloadcategory&sent_received=received">'.Display::return_icon('save_pack.png', get_lang('Save'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.$category['cat_name'].'</a>';
$dropbox_category_data[] = '';
$dropbox_category_data[] = '';
$dropbox_category_data[] = '';
Expand Down Expand Up @@ -540,9 +543,9 @@

if ($view_dropbox_category_sent == $dropbox_file->category) {
$dropbox_file_data[] = $dropbox_file->id;
$link_open = '<a href="dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'">';
$link_open = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'">';
$dropbox_file_data[] = $link_open.DocumentManager::build_document_icon_tag('file', $dropbox_file->title).'</a>';
$dropbox_file_data[] = '<a href="dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'&action=download">'.
$dropbox_file_data[] = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'&action=download">'.
Display::return_icon('save.png', get_lang('Save'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.$dropbox_file->title.'</a><br />'.$dropbox_file->description;
$file_size = $dropbox_file->filesize;
$dropbox_file_data[] = format_file_size($file_size);
Expand All @@ -567,7 +570,7 @@
if ($action == 'viewfeedback' && isset($_GET['id']) && is_numeric($_GET['id']) && $dropbox_file->id == $_GET['id']) {
$action_icons .= "</td></tr>\n"; // ending the normal row of the sortable table
$action_icons .= "<tr><td colspan=\"2\">";
$action_icons .= "<a href=\"index.php?".api_get_cidreq()."&view_received_category=".$viewReceivedCategory."&view_sent_category=".$viewSentCategory."&view=".$view.'&'.$sort_params."\">".get_lang('CloseFeedback')."</a>";
$action_icons .= "<a href=\"".api_get_path(WEB_CODE_PATH)."dropbox/index.php?".api_get_cidreq()."&view_received_category=".$viewReceivedCategory."&view_sent_category=".$viewSentCategory."&view=".$view.'&'.$sort_params."\">".get_lang('CloseFeedback')."</a>";
$action_icons .= "</td><td colspan=\"7\">".feedback($dropbox_file->feedback2)."</td></tr>";
}
$dropbox_file_data[] = $action_icons;
Expand All @@ -591,7 +594,7 @@
// This is where the checkbox icon for the files appear.
$link_open = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$category['cat_id'].'&view='.$view.'">';
$dropbox_category_data[] = $link_open.DocumentManager::build_document_icon_tag('folder', Security::remove_XSS($category['cat_name'])).'</a>';
$dropbox_category_data[] = '<a href="dropbox_download.php?'.api_get_cidreq().'&cat_id='.$category['cat_id'].'&action=downloadcategory&sent_received=sent">'.Display::return_icon('save_pack.png', get_lang('Save'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.Security::remove_XSS($category['cat_name']).'</a>';
$dropbox_category_data[] = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&cat_id='.$category['cat_id'].'&action=downloadcategory&sent_received=sent">'.Display::return_icon('save_pack.png', get_lang('Save'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.Security::remove_XSS($category['cat_name']).'</a>';
//$dropbox_category_data[] = '';
$dropbox_category_data[] = '';
//$dropbox_category_data[] = '';
Expand Down
14 changes: 7 additions & 7 deletions main/dropbox/recover_dropbox_files.php
Expand Up @@ -40,14 +40,14 @@
$sql = "SELECT * FROM $person_tbl
WHERE c_id = $course_id AND user_id = $user_id AND file_id = {$file['id']}";
$result_person = Database::query($sql);
if (Database::num_rows($result_person) == 0 ) {
if (Database::num_rows($result_person) == 0) {
$rows[] = array(
$file['filename'],
api_convert_and_format_date($file['upload_date']),
Display::url(
get_lang('Recover'), api_get_self().'?recover_id='.$file['id'],
array('class' => 'btn btn-default')
)
$file['filename'],
api_convert_and_format_date($file['upload_date']),
Display::url(
get_lang('Recover'), api_get_self().'?recover_id='.$file['id'],
array('class' => 'btn btn-default')
)
);
}
}
Expand Down

0 comments on commit a9322ed

Please sign in to comment.