diff --git a/main/dropbox/dropbox_class.inc.php b/main/dropbox/dropbox_class.inc.php index f5042d1869..d632e2fa27 100755 --- a/main/dropbox/dropbox_class.inc.php +++ b/main/dropbox/dropbox_class.inc.php @@ -1,11 +1,11 @@ - who sent it // RH: Mailing: or mailing pseudo_id @@ -68,9 +68,9 @@ class Dropbox_Work { * @param unknown_type $arg6 * @return Dropbox_Work */ - function Dropbox_Work ($arg1, $arg2=null, $arg3=null, $arg4=null, $arg5=null, $arg6=null) { + function Dropbox_Work($arg1, $arg2 = null, $arg3 = null, $arg4 = null, $arg5 = null, $arg6 = null) { - if (func_num_args()>1) { + if (func_num_args() > 1) { $this->_createNewWork($arg1, $arg2, $arg3, $arg4, $arg5, $arg6); } else { $this->_createExistingWork($arg1); @@ -90,8 +90,8 @@ class Dropbox_Work { * @todo $author was originally a field but this has now been replaced by the first and lastname of the uploader (to prevent anonymous uploads) * As a consequence this parameter can be removed */ - function _createNewWork ($uploader_id, $title, $description, $author, $filename, $filesize) { - global $_user,$dropbox_cnf; + function _createNewWork($uploader_id, $title, $description, $author, $filename, $filesize) { + global $_user, $dropbox_cnf; // Do some sanity checks settype($uploader_id, 'integer') or die(get_lang('GeneralError').' (code 201)'); //set $uploader_id to correct type //if (! isCourseMember($uploader_id)) die(); //uploader must be coursemember to be able to upload @@ -105,23 +105,23 @@ class Dropbox_Work { $this->title = $title; $this->description = $description; $this->author = api_get_person_name($_user['firstName'], $_user['lastName']); - $this->last_upload_date = date("Y-m-d H:i:s",time()); + $this->last_upload_date = date('Y-m-d H:i:s', time()); // Check if object exists already. If it does, the old object is used // with updated information (authors, descriptio, upload_date) - $this->isOldWork = FALSE; - $sql="SELECT id, upload_date - FROM ".$dropbox_cnf["tbl_file"]." + $this->isOldWork = false; + $sql = "SELECT id, upload_date + FROM ".$dropbox_cnf['tbl_file']." WHERE filename = '".Database::escape_string($this->filename)."'"; $result = Database::query($sql); $res = Database::fetch_array($result); - if ($res != FALSE) { - $this->isOldWork = TRUE; + if ($res != false) { + $this->isOldWork = true; } - // insert or update the dropbox_file table and set the id property + // Insert or update the dropbox_file table and set the id property if ($this->isOldWork) { - $this->id = $res["id"]; - $this->upload_date = $res["upload_date"]; + $this->id = $res['id']; + $this->upload_date = $res['upload_date']; $sql = "UPDATE ".$dropbox_cnf["tbl_file"]." SET filesize = '".Database::escape_string($this->filesize)."' , title = '".Database::escape_string($this->title)."' @@ -132,7 +132,7 @@ class Dropbox_Work { $result = Database::query($sql); } else { $this->upload_date = $this->last_upload_date; - $sql="INSERT INTO ".$dropbox_cnf["tbl_file"]." + $sql = "INSERT INTO ".$dropbox_cnf['tbl_file']." (uploader_id, filename, filesize, title, description, author, upload_date, last_upload_date, session_id) VALUES ('".Database::escape_string($this->uploader_id)."' , '".Database::escape_string($this->filename)."' @@ -149,8 +149,8 @@ class Dropbox_Work { $this->id = Database::insert_id(); //get automatically inserted id } - // insert entries into person table - $sql="INSERT INTO ".$dropbox_cnf["tbl_person"]." + // Insert entries into person table + $sql = "INSERT INTO ".$dropbox_cnf['tbl_person']." (file_id, user_id) VALUES ('".Database::escape_string($this->id)."' , '".Database::escape_string($this->uploader_id)."' @@ -163,24 +163,24 @@ class Dropbox_Work { * * @param unknown_type $id */ - function _createExistingWork ($id) { - global $_user,$dropbox_cnf; // RH: Feedback + function _createExistingWork($id) { + global $_user, $dropbox_cnf; // RH: Feedback // Do some sanity checks settype($id, 'integer') or die(get_lang('GeneralError').' (code 205)'); //set $id to correct type $id = intval($id); // get the data from DB - $sql="SELECT uploader_id, filename, filesize, title, description, author, upload_date, last_upload_date, cat_id - FROM ".$dropbox_cnf["tbl_file"]." + $sql = "SELECT uploader_id, filename, filesize, title, description, author, upload_date, last_upload_date, cat_id + FROM ".$dropbox_cnf['tbl_file']." WHERE id='".Database::escape_string($id)."'"; $result = Database::query($sql); $res = Database::fetch_array($result, 'ASSOC'); // Check if uploader is still in Dokeos system - $uploader_id = stripslashes($res["uploader_id"]); + $uploader_id = stripslashes($res['uploader_id']); $uploaderName = getUserNameFromId($uploader_id); - if ($uploaderName == FALSE) { + if (!$uploaderName) { //deleted user $this->uploader_id = -1; $this->uploaderName = get_lang('Unknown', ''); @@ -191,35 +191,34 @@ class Dropbox_Work { // Fill in properties $this->id = $id; - $this->filename = stripslashes($res["filename"]); - $this->filesize = stripslashes($res["filesize"]); - $this->title = stripslashes($res["title"]); - $this->description = stripslashes($res["description"]); - $this->author = stripslashes($res["author"]); - $this->upload_date = stripslashes($res["upload_date"]); - $this->last_upload_date = stripslashes($res["last_upload_date"]); + $this->filename = stripslashes($res['filename']); + $this->filesize = stripslashes($res['filesize']); + $this->title = stripslashes($res['title']); + $this->description = stripslashes($res['description']); + $this->author = stripslashes($res['author']); + $this->upload_date = stripslashes($res['upload_date']); + $this->last_upload_date = stripslashes($res['last_upload_date']); $this->category = $res['cat_id']; // Getting the feedback on the work. - if ($_GET['action']=='viewfeedback' AND $this->id==$_GET['id']) { - $feedback2=array(); - $sql_feedback = "SELECT * FROM ".$dropbox_cnf["tbl_feedback"]." WHERE file_id='".$id."' ORDER BY feedback_id ASC"; + if ($_GET['action'] == 'viewfeedback' AND $this->id == $_GET['id']) { + $feedback2 = array(); + $sql_feedback = "SELECT * FROM ".$dropbox_cnf['tbl_feedback']." WHERE file_id='".$id."' ORDER BY feedback_id ASC"; $result = Database::query($sql_feedback); - while ($row_feedback=Database::fetch_array($result)) { + while ($row_feedback = Database::fetch_array($result)) { $row_feedback['feedback'] = Security::remove_XSS($row_feedback['feedback']); - $feedback2[]=$row_feedback; + $feedback2[] = $row_feedback; } $this->feedback2= $feedback2; } /* // RH: Feedback $result = Database::query("SELECT feedback_date, feedback, cat_id FROM ". - dropbox_cnf("tbl_post")." WHERE dest_user_id='".$_user['user_id']. + dropbox_cnf('tbl_post')." WHERE dest_user_id='".$_user['user_id']. "' AND file_id='".$id."'"); - if ($res = Database::fetch_array($result)) - { - $this->feedback_date = $res["feedback_date"]; - $this->feedback = $res["feedback"]; + if ($res = Database::fetch_array($result)) { + $this->feedback_date = $res['feedback_date']; + $this->feedback = $res['feedback']; $this->category = $res['cat_id']; } // do not fail if there is no recipient = current user...*/ } @@ -227,7 +226,7 @@ class Dropbox_Work { class Dropbox_SentWork extends Dropbox_Work { - public $recipients; //array of ["id"]["name"] arrays + public $recipients; //array of ['id']['name'] arrays /** * Constructor calls private functions to create a new work or retreive an existing work from DB @@ -242,11 +241,11 @@ class Dropbox_SentWork extends Dropbox_Work * @param unknown_type $arg7 * @return Dropbox_SentWork */ - function Dropbox_SentWork ($arg1, $arg2=null, $arg3=null, $arg4=null, $arg5=null, $arg6=null, $arg7=null) { - if (func_num_args()>1) { - $this->_createNewSentWork ($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7); + function Dropbox_SentWork($arg1, $arg2 = null, $arg3 = null, $arg4 = null, $arg5 = null, $arg6 = null, $arg7 = null) { + if (func_num_args() > 1) { + $this->_createNewSentWork($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7); } else { - $this->_createExistingSentWork ($arg1); + $this->_createExistingSentWork($arg1); } } @@ -261,7 +260,7 @@ class Dropbox_SentWork extends Dropbox_Work * @param unknown_type $filesize * @param unknown_type $recipient_ids */ - function _createNewSentWork ($uploader_id, $title, $description, $author, $filename, $filesize, $recipient_ids) { + function _createNewSentWork($uploader_id, $title, $description, $author, $filename, $filesize, $recipient_ids) { global $dropbox_cnf; // Call constructor of Dropbox_Work object $this->Dropbox_Work($uploader_id, $title, $description, $author, $filename, $filesize); @@ -270,11 +269,13 @@ class Dropbox_SentWork extends Dropbox_Work // The sanity check for ex-coursemembers is already done in base constructor settype($uploader_id, 'integer') or die(get_lang('GeneralError').' (code 208)'); //set $uploader_id to correct type - $justSubmit = FALSE; // RH: mailing zip-file or just upload + $justSubmit = false; // RH: mailing zip-file or just upload if ( is_int($recipient_ids)) { - $justSubmit = TRUE; $recipient_ids = array($recipient_ids + $this->id); + $justSubmit = true; + $recipient_ids = array($recipient_ids + $this->id); } elseif ( count($recipient_ids) == 0) { // RH: Just Upload - $justSubmit = TRUE; $recipient_ids = array($uploader_id); + $justSubmit = true; + $recipient_ids = array($uploader_id); } if (! is_array($recipient_ids) || count($recipient_ids) == 0) { die(get_lang('GeneralError').' (code 209)'); @@ -283,37 +284,37 @@ class Dropbox_SentWork extends Dropbox_Work if (empty($rec)) die(get_lang('GeneralError').' (code 210)'); //if (!isCourseMember($rec)) die(); //cannot sent document to someone outside of course //this check is done when validating submitted data - $this->recipients[] = array("id"=>$rec, "name"=>getUserNameFromId($rec)); + $this->recipients[] = array('id' => $rec, 'name' => getUserNameFromId($rec)); } - // insert data in dropbox_post and dropbox_person table for each recipient + // Insert data in dropbox_post and dropbox_person table for each recipient foreach ($this->recipients as $rec) { - $sql="INSERT INTO ".$dropbox_cnf["tbl_post"]." + $sql = "INSERT INTO ".$dropbox_cnf['tbl_post']." (file_id, dest_user_id, session_id) - VALUES ('".Database::escape_string($this->id)."', '".Database::escape_string($rec["id"])."', ".intval($_SESSION['id_session']).")"; + VALUES ('".Database::escape_string($this->id)."', '".Database::escape_string($rec['id'])."', ".intval($_SESSION['id_session']).")"; $result = Database::query($sql); //if work already exists no error is generated - //insert entries into person table - $sql="INSERT INTO ".$dropbox_cnf["tbl_person"]." + // Insert entries into person table + $sql = "INSERT INTO ".$dropbox_cnf['tbl_person']." (file_id, user_id) VALUES ('".Database::escape_string($this->id)."' - , '".Database::escape_string($rec["id"])."' + , '".Database::escape_string($rec['id'])."' )"; // RH: do not add recipient in person table if mailing zip or just upload if (!$justSubmit) { $result = Database::query($sql); //if work already exists no error is generated } - //update item_property (previously last_tooledit) table for each recipient + // Update item_property (previously last_tooledit) table for each recipient global $_course, $dropbox_cnf; - if (($ownerid = $this->uploader_id) > $dropbox_cnf["mailingIdBase"]) { + if (($ownerid = $this->uploader_id) > $dropbox_cnf['mailingIdBase']) { $ownerid = getUserOwningThisMailing($ownerid); } - if (($recipid = $rec["id"]) > $dropbox_cnf["mailingIdBase"]) { + if (($recipid = $rec["id"]) > $dropbox_cnf['mailingIdBase']) { $recipid = $ownerid; // mailing file recipient = mailing id, not a person } - api_item_property_update($_course, TOOL_DROPBOX, $this->id, "DropboxFileAdded", $ownerid, NULL, $recipid) ; + api_item_property_update($_course, TOOL_DROPBOX, $this->id, 'DropboxFileAdded', $ownerid, null, $recipid) ; } } @@ -322,7 +323,7 @@ class Dropbox_SentWork extends Dropbox_Work * * @param unknown_type $id */ - function _createExistingSentWork ($id) { + function _createExistingSentWork ($id) { global $dropbox_cnf; // Call constructor of Dropbox_Work object $this->Dropbox_Work($id); @@ -330,22 +331,22 @@ class Dropbox_SentWork extends Dropbox_Work // Do sanity check. The sanity check for ex-coursemembers is already done in base constructor settype($id, 'integer') or die(get_lang('GeneralError').' (code 211)'); //set $id to correct type - //Fill in recipients array/ + // Fill in recipients array/ $this->recipients = array(); // RH: Feedback: added to SELECT - $sql="SELECT dest_user_id, feedback_date, feedback - FROM ".$dropbox_cnf["tbl_post"]." + $sql = "SELECT dest_user_id, feedback_date, feedback + FROM ".$dropbox_cnf['tbl_post']." WHERE file_id='".Database::escape_string($id)."'"; $result = Database::query($sql); while ($res = Database::fetch_array($result)) { // check for deleted users - $dest_user_id = $res["dest_user_id"]; + $dest_user_id = $res['dest_user_id']; $recipientName = getUserNameFromId($dest_user_id); - //$this->category=$res['cat_id']; - if ($recipientName == FALSE) { - $this->recipients[] = array("id"=>-1, "name"=> get_lang('Unknown', '')); + //$this->category = $res['cat_id']; + if (!$recipientName) { + $this->recipients[] = array('id' => -1, 'name' => get_lang('Unknown', '')); } else { - $this->recipients[] = array("id"=>$dest_user_id, "name"=>$recipientName, "user_id"=>$dest_user_id, - "feedback_date"=>$res["feedback_date"], "feedback"=>$res["feedback"]); // RH: Feedback + $this->recipients[] = array('id' => $dest_user_id, 'name' => $recipientName, 'user_id' => $dest_user_id, + 'feedback_date' => $res['feedback_date'], 'feedback' => $res['feedback']); // RH: Feedback } } } @@ -356,8 +357,8 @@ class Dropbox_Person public $receivedWork; //array of Dropbox_Work objects public $sentWork; //array of Dropbox_SentWork objects public $userId = 0; - public $isCourseAdmin = FALSE; - public $isCourseTutor = FALSE; + public $isCourseAdmin = false; + public $isCourseTutor = false; public $_orderBy = ''; //private property that determines by which field //the receivedWork and the sentWork arrays are sorted @@ -396,7 +397,7 @@ class Dropbox_Person $result = Database::query($sql); while ($res = Database::fetch_array($result)) { - $temp = new Dropbox_Work($res["file_id"]); + $temp = new Dropbox_Work($res['file_id']); $temp -> category = $res['cat_id']; $this->receivedWork[] = $temp; } @@ -410,9 +411,9 @@ class Dropbox_Person //if(intval($_SESSION['id_session']>0)) { $sql .= " AND f.session_id = ".intval($_SESSION['id_session']); } - $result =Database::query($sql); + $result = Database::query($sql); while ($res = Database::fetch_array($result)) { - $this->sentWork[] = new Dropbox_SentWork($res["id"]); + $this->sentWork[] = new Dropbox_SentWork($res['id']); } } @@ -426,7 +427,7 @@ class Dropbox_Person * @param unknown_type $b * @return -1, 0 or 1 dependent of the result of the comparison. */ - function _cmpWork ($a, $b) { + function _cmpWork($a, $b) { $sort = $this->_orderBy; $aval = $a->$sort; $bval = $b->$sort; @@ -435,7 +436,7 @@ class Dropbox_Person $bval = $bval[0]['name']; } if ($sort == 'filesize') { //filesize is not a string, so we use other comparison technique - return $aval<$bval ? -1 : 1; + return $aval < $bval ? -1 : 1; } elseif ($sort == 'title') { // natural order for sorting titles is more "human-friendly" return api_strnatcmp($aval, $bval); } else { @@ -476,7 +477,7 @@ class Dropbox_Person $this->_orderBy = 'last_upload_date'; } // switch - usort($this->sentWork, array($this,"_cmpWork")); //this calls the _cmpWork method + usort($this->sentWork, array($this, '_cmpWork')); //this calls the _cmpWork method } /** @@ -508,7 +509,7 @@ class Dropbox_Person $this->_orderBy = 'last_upload_date'; } // switch - usort($this->receivedWork, array($this,"_cmpWork")); //this calls the _cmpWork method + usort($this->receivedWork, array($this, '_cmpWork')); //this calls the _cmpWork method } /** @@ -519,7 +520,7 @@ class Dropbox_Person global $dropbox_cnf; //delete entries in person table concerning received works foreach ($this->receivedWork as $w) { - Database::query("DELETE FROM ".$dropbox_cnf["tbl_person"]." WHERE user_id='".$this->userId."' AND file_id='".$w->id."'"); + Database::query("DELETE FROM ".$dropbox_cnf['tbl_person']." WHERE user_id='".$this->userId."' AND file_id='".$w->id."'"); } removeUnusedFiles(); //check for unused files @@ -532,14 +533,15 @@ class Dropbox_Person global $dropbox_cnf; $id = intval($id); - $sql = "DELETE FROM ".$dropbox_cnf["tbl_file"]." where cat_id = '".$id."' "; - if(!Database::query($sql)) return false; - $sql = "DELETE FROM ".$dropbox_cnf["tbl_category"]." where cat_id = '".$id."' "; - if(!Database::query($sql)) return false; - $sql = "DELETE FROM ".$dropbox_cnf["tbl_post"]." where cat_id = '".$id."' "; - if(!Database::query($sql)) return false; + $sql = "DELETE FROM ".$dropbox_cnf['tbl_file']." where cat_id = '".$id."' "; + if (!Database::query($sql)) return false; + $sql = "DELETE FROM ".$dropbox_cnf['tbl_category']." where cat_id = '".$id."' "; + if (!Database::query($sql)) return false; + $sql = "DELETE FROM ".$dropbox_cnf['tbl_post']." where cat_id = '".$id."' "; + if (!Database::query($sql)) return false; return true; } + /** * Deletes a received dropbox file of this person with id=$id * @@ -562,7 +564,7 @@ class Dropbox_Person } } //delete entries in person table concerning received works - Database::query("DELETE FROM ".$dropbox_cnf["tbl_person"]." WHERE user_id='".$this->userId."' AND file_id='".$id."'"); + Database::query("DELETE FROM ".$dropbox_cnf['tbl_person']." WHERE user_id='".$this->userId."' AND file_id='".$id."'"); removeUnusedFiles(); //check for unused files } @@ -573,7 +575,7 @@ class Dropbox_Person global $dropbox_cnf; //delete entries in person table concerning sent works foreach ($this->sentWork as $w) { - Database::query("DELETE FROM ".$dropbox_cnf["tbl_person"]." WHERE user_id='".$this->userId."' AND file_id='".$w->id."'"); + Database::query("DELETE FROM ".$dropbox_cnf['tbl_person']." WHERE user_id='".$this->userId."' AND file_id='".$w->id."'"); removeMoreIfMailing($w->id); // RH: Mailing: see init1 } removeUnusedFiles(); //check for unused files @@ -603,7 +605,7 @@ class Dropbox_Person } //$file_id = $this->sentWork[$index]->id; // RH: Mailing //delete entries in person table concerning sent works - Database::query("DELETE FROM ".$dropbox_cnf["tbl_person"]." WHERE user_id='".$this->userId."' AND file_id='".$id."'"); + Database::query("DELETE FROM ".$dropbox_cnf['tbl_person']." WHERE user_id='".$this->userId."' AND file_id='".$id."'"); removeMoreIfMailing($id); // RH: Mailing: see init1 removeUnusedFiles(); //check for unused files } @@ -631,22 +633,23 @@ class Dropbox_Person die(get_lang('GeneralError').' (code 221)'); } - $feedback_date = date("Y-m-d H:i:s",time()); + $feedback_date = date('Y-m-d H:i:s', time()); $this->receivedWork[$wi]->feedback_date = $feedback_date; $this->receivedWork[$wi]->feedback = $text; - Database::query("UPDATE ".$dropbox_cnf["tbl_post"]." SET feedback_date='". + Database::query("UPDATE ".$dropbox_cnf['tbl_post']." SET feedback_date='". Database::escape_string($feedback_date)."', feedback='".Database::escape_string($text). "' WHERE dest_user_id='".$this->userId."' AND file_id='".$id."'"); //update item_property (previously last_tooledit) table - if (($ownerid = $this->receivedWork[$wi]->uploader_id) > $dropbox_cnf["mailingIdBase"]) { + if (($ownerid = $this->receivedWork[$wi]->uploader_id) > $dropbox_cnf['mailingIdBase']) { $ownerid = getUserOwningThisMailing($ownerid); } - api_item_property_update($_course, TOOL_DROPBOX, $this->receivedWork[$wi]->id, "DropboxFileUpdated", $this->userId, NULL, $ownerid) ; + api_item_property_update($_course, TOOL_DROPBOX, $this->receivedWork[$wi]->id, 'DropboxFileUpdated', $this->userId, null, $ownerid) ; } + /** * Filter the received work * @param string $type @@ -660,7 +663,7 @@ class Dropbox_Person switch ($type) { case 'uploader_id': if ($work->uploader_id == $value || - ($work->uploader_id > $dropbox_cnf["mailingIdBase"] && + ($work->uploader_id > $dropbox_cnf['mailingIdBase'] && getUserOwningThisMailing($work->uploader_id) == $value)) { $new_received_work[] = $work; } @@ -671,4 +674,4 @@ class Dropbox_Person } $this->receivedWork = $new_received_work; } -} \ No newline at end of file +} diff --git a/main/dropbox/dropbox_config.inc.php b/main/dropbox/dropbox_config.inc.php index ab9f14e17f..f705614069 100755 --- a/main/dropbox/dropbox_config.inc.php +++ b/main/dropbox/dropbox_config.inc.php @@ -1,17 +1,13 @@ -0) -{ - $allowed_to_download=true; +$sql = "SELECT * FROM ".$dropbox_cnf['tbl_person']." WHERE file_id='".Database::escape_string($_GET['id'])."' AND user_id='".Database::escape_string($_user['user_id'])."'"; +$result = Database::query($sql); +if (Database::num_rows($result) > 0) { + $allowed_to_download = true; } /* ------------------------------------------------------------------------------- ERROR IF NOT ALLOWED TO DOWNLOAD ------------------------------------------------------------------------------- */ -if (!$allowed_to_download) -{ - Display::display_header($nameTools,"Dropbox"); +if (!$allowed_to_download) { + Display::display_header($nameTools, 'Dropbox'); Display :: display_error_message(get_lang('YouAreNotAllowedToDownloadThisFile')); Display::display_footer(); exit; } + /* ------------------------------------------------------------------------------- DOWNLOAD THE FILE ------------------------------------------------------------------------------- */ // the user is allowed to download the file -else -{ - $_SESSION['_seen'][$_course['id']][TOOL_DROPBOX][]=intval($_GET['id']); +else { + $_SESSION['_seen'][$_course['id']][TOOL_DROPBOX][] = intval($_GET['id']); $work = new Dropbox_work($_GET['id']); - $path = dropbox_cnf("sysPath") . "/" . $work -> filename; //path to file as stored on server + $path = dropbox_cnf('sysPath') . '/' . $work -> filename; //path to file as stored on server $file = $work->title; require_once api_get_path(LIBRARY_PATH) . '/document.lib.php'; - $mimetype = DocumentManager::file_get_mime_type(TRUE); - $fileparts = explode( '.', $file); - $filepartscount = count( $fileparts); - if ( ( $filepartscount > 1) && isset( $mimetype[$fileparts [$filepartscount - 1]]) && $_GET['action']<>'download') - { + $mimetype = DocumentManager::file_get_mime_type(true); + $fileparts = explode('.', $file); + $filepartscount = count($fileparts); + if (($filepartscount > 1) && isset($mimetype[$fileparts[$filepartscount - 1]]) && $_GET['action'] != 'download') { // give hint to browser about filetype - header( "Content-type: " . $mimetype[$fileparts [$filepartscount - 1]] . "\n"); - } - else - { + header( 'Content-type: ' . $mimetype[$fileparts[$filepartscount - 1]] . "\n"); + } else { //no information about filetype: force a download dialog window in browser header( "Content-type: application/octet-stream\n"); } - if (!in_array(strtolower($fileparts [$filepartscount - 1]), array('doc','xls','ppt','pps','sxw','sxc','sxi'))) - { + if (!in_array(strtolower($fileparts [$filepartscount - 1]), array('doc', 'xls', 'ppt', 'pps', 'sxw', 'sxc', 'sxi'))) { header('Content-Disposition: inline; filename='.$file); // bugs with open office - } - else - { + } else { header('Content-Disposition: attachment; filename='.$file); } @@ -159,50 +131,38 @@ else * before sending a file to the browser, the "Open" option on Internet Explorer's file download dialog will not work properly. If the user clicks "Open" instead of "Save," the target application will open an empty file, because the downloaded file was not cached. The user will have to save the file to their hard drive in order to use it. * Make sure to leave these headers out if you'd like your visitors to be able to use IE's "Open" option. */ - header( "Pragma: \n"); - header( "Cache-Control: \n"); - header( "Cache-Control: public\n"); // IE cannot download from sessions without a cache + header("Pragma: \n"); + header("Cache-Control: \n"); + header("Cache-Control: public\n"); // IE cannot download from sessions without a cache - /*if ( isset( $_SERVER["HTTPS"])) - { + /*if (isset($_SERVER['HTTPS'])) { /** * We need to set the following headers to make downloads work using IE in HTTPS mode. * - //header( "Pragma: "); - //header( "Cache-Control: "); - header( "Expires: Mon, 26 Jul 1997 05:00:00 GMT\n"); - header( "Last-Modified: " . gmdate( "D, d M Y H:i:s") . " GMT\n"); - header( "Cache-Control: no-store, no-cache, must-revalidate\n"); // HTTP/1.1 - header( "Cache-Control: post-check=0, pre-check=0\n", false); + //header('Pragma: '); + //header('Cache-Control: '); + header("Expires: Mon, 26 Jul 1997 05:00:00 GMT\n"); + header("Last-Modified: " . gmdate( "D, d M Y H:i:s") . " GMT\n"); + header("Cache-Control: no-store, no-cache, must-revalidate\n"); // HTTP/1.1 + header("Cache-Control: post-check=0, pre-check=0\n", false); }*/ - header( "Content-Description: " . trim( htmlentities( $file)) . "\n"); - header( "Content-Transfer-Encoding: binary\n"); - header( "Content-Length: " . filesize( $path)."\n" ); + header('Content-Description: ' . trim(htmlentities($file)) . "\n"); + header("Content-Transfer-Encoding: binary\n"); + header("Content-Length: " . filesize($path)."\n" ); - $fp = fopen( $path, "rb"); - fpassthru( $fp); + $fp = fopen( $path, 'rb'); + fpassthru($fp); exit(); } - - - - - - - - - - /** -============================================================================== - * Dropbox module for Claroline + * Dropbox module for Chamilo * handles downloads of files. Direct downloading is prevented because of an .htaccess file in the * dropbox directory. So everything goes through this script. * @@ -218,67 +178,67 @@ else * After searching the only explanation I could find is a problem with the headers: * * HEADERS SENT WITH PHP4.3: - * HTTP/1.1�200�OK(CR) + * HTTP/1.1 200 OK(CR) * (LF) - * Date:�Fri,�12�Sep�2003�19:07:33�GMT(CR) + * Date: Fri, 12 Sep 2003 19:07:33 GMT(CR) * (LF) - * Server:�Apache/2.0.47�(Win32)�PHP/4.3.3(CR) + * Server: Apache/2.0.47 (Win32) PHP/4.3.3(CR) * (LF) - * X-Powered-By:�PHP/4.3.3(CR) + * X-Powered-By: PHP/4.3.3(CR) * (LF) - * Set-Cookie:�PHPSESSID=06880edcc8363be3f60929576fc1bc6e;�path=/(CR) + * Set-Cookie: PHPSESSID=06880edcc8363be3f60929576fc1bc6e; path=/(CR) * (LF) - * Expires:�Thu,�19�Nov�1981�08:52:00�GMT(CR) + * Expires: Thu, 19 Nov 1981 08:52:00 GMT(CR) * (LF) - * Cache-Control:�public(CR) + * Cache-Control: public(CR) * (LF) - * Pragma:�(CR) + * Pragma: (CR) * (LF) - * Content-Transfer-Encoding:�binary(CR) + * Content-Transfer-Encoding: binary(CR) * (LF) - * Content-Disposition:�attachment;�filename=SV-262E4.png(CR) + * Content-Disposition: attachment; filename=SV-262E4.png(CR) * (LF) - * Content-Length:�92178(CR) + * Content-Length: 92178(CR) * (LF) - * Connection:�close(CR) + * Connection: close(CR) * (LF) - * Content-Type:�application/octet-stream(CR) + * Content-Type: application/octet-stream(CR) * (LF) * (CR) * (LF) * * HEADERS SENT WITH PHP4.0.4: - * HTTP/1.1�200�OK(CR) + * HTTP/1.1 200 OK(CR) * (LF) - * Date:�Fri,�12�Sep�2003�18:28:21�GMT(CR) + * Date: Fri, 12 Sep 2003 18:28:21 GMT(CR) * (LF) - * Server:�Apache/2.0.47�(Win32)(CR) + * Server: Apache/2.0.47 (Win32)(CR) * (LF) - * X-Powered-By:�PHP/4.0.4(CR) + * X-Powered-By: PHP/4.0.4(CR) * (LF) - * Expires:�Thu,�19�Nov�1981�08:52:00�GMT(CR) + * Expires: Thu, 19 Nov 1981 08:52:00 GMT(CR) * (LF) - * Cache-Control:�no-store,�no-cache,�must-revalidate,�post-check=0,�pre-check=0,�,�public(CR) + * Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0, , public(CR) * (LF) - * Pragma:�no-cache,�(CR) + * Pragma: no-cache, (CR) * (LF) - * Content-Disposition:�attachment;�filename=SV-262E4.png(CR) + * Content-Disposition: attachment; filename=SV-262E4.png(CR) * (LF) - * Content-Transfer-Encoding:�binary(CR) + * Content-Transfer-Encoding: binary(CR) * (LF) - * Set-Cookie:�PHPSESSID=0a5b1c1b9d5e3b474fef359ee55e82d0;�path=/(CR) + * Set-Cookie: PHPSESSID=0a5b1c1b9d5e3b474fef359ee55e82d0; path=/(CR) * (LF) - * Content-Length:�92178(CR) + * Content-Length: 92178(CR) * (LF) - * Connection:�close(CR) + * Connection: close(CR) * (LF) - * Content-Type:�application/octet-stream(CR) + * Content-Type: application/octet-stream(CR) * (LF) * (CR) * (LF) * * As you can see the there is a difference in the Cache-Control directive. I suspect that this - * explains the problem. Also take a look at http://bugs.php.net/bug.php?id=16458. + * explains the problem. Also have a look at http://bugs.php.net/bug.php?id=16458. * * @version 1.21 * @copyright 2004-2005 @@ -286,79 +246,62 @@ else * @author René Haentjens , several contributions (see RH) * @author Roan Embrechts, virtual course support * - * @package dokeos.dropbox -============================================================================== + * @package chamilo.dropbox */ /* -============================================================================== INITIALISING VARIABLES -============================================================================== */ -require_once( "dropbox_init.inc.php"); //only call init1 because init2 outputs data -require_once( "dropbox_class.inc.php"); +require_once 'dropbox_init.inc.php'; //only call init1 because init2 outputs data +require_once 'dropbox_class.inc.php'; /* -============================================================================== AUTHORISATION SECTION -============================================================================== */ -if ( !isset( $_user['user_id']) || !$is_course_member ) -{ - exit( ); +if (!isset($_user['user_id']) || !$is_course_member) { + exit(); } if ($_GET['mailing']) // RH: Mailing detail window call getUserOwningThisMailing($_GET['mailing'], $_user['user_id'], '500'); // RH or die /* -============================================================================== SANITY CHECKS OF GET DATA & FILE -============================================================================== */ -if ( ! isset( $_GET['id']) || ! is_numeric( $_GET['id'])) die(get_lang('GeneralError').' (code 501)'); +if (!isset($_GET['id']) || !is_numeric($_GET['id'])) die(get_lang('GeneralError').' (code 501)'); $work = new Dropbox_work($_GET['id']); -$path = dropbox_cnf("sysPath") . "/" . $work -> filename; //path to file as stored on server +$path = dropbox_cnf('sysPath') . '/' . $work -> filename; //path to file as stored on server $file = $work->title; // check that this file exists and that it doesn't include any special characters -//if ( !is_file( $path) || ! eregi( '^[A-Z0-9_\-][A-Z0-9._\-]*$', $file)) -if ( !is_file( $path)) -{ +//if (!is_file($path) || ! eregi('^[A-Z0-9_\-][A-Z0-9._\-]*$', $file)) +if (!is_file($path)) { die(get_lang('GeneralError').' (code 504)'); } /* -============================================================================== SEND HEADERS -============================================================================== */ require_once api_get_path(LIBRARY_PATH) . '/document.lib.php'; -$mimetype = DocumentManager::file_get_mime_type(TRUE); +$mimetype = DocumentManager::file_get_mime_type(true); -$fileparts = explode( '.', $file); -$filepartscount = count( $fileparts); +$fileparts = explode('.', $file); +$filepartscount = count($fileparts); -if ( ( $filepartscount > 1) && isset( $mimetype[$fileparts [$filepartscount - 1]])) -{ +if (($filepartscount > 1) && isset($mimetype[$fileparts[$filepartscount - 1]])) { // give hint to browser about filetype - header( "Content-type: " . $mimetype[$fileparts [$filepartscount - 1]] . "\n"); -} -else -{ + header('Content-type: ' . $mimetype[$fileparts[$filepartscount - 1]] . "\n"); +} else { //no information about filetype: force a download dialog window in browser - header( "Content-type: application/octet-stream\n"); + header("Content-type: application/octet-stream\n"); } -if (!in_array(strtolower($fileparts [$filepartscount - 1]), array('doc','xls','ppt','pps','sxw','sxc','sxi'))) -{ +if (!in_array(strtolower($fileparts [$filepartscount - 1]), array('doc', 'xls', 'ppt', 'pps', 'sxw', 'sxc', 'sxi'))) { header('Content-Disposition: inline; filename='.$file); // bugs with open office -} -else -{ +} else { header('Content-Disposition: attachment; filename='.$file); } @@ -375,33 +318,29 @@ header( "Cache-Control: \n"); header( "Cache-Control: public\n"); // IE cannot download from sessions without a cache -/*if ( isset( $_SERVER["HTTPS"])) -{ +/*if (isset($_SERVER['HTTPS'])) { /** * We need to set the following headers to make downloads work using IE in HTTPS mode. * - //header( "Pragma: "); - //header( "Cache-Control: "); - header( "Expires: Mon, 26 Jul 1997 05:00:00 GMT\n"); - header( "Last-Modified: " . gmdate( "D, d M Y H:i:s") . " GMT\n"); - header( "Cache-Control: no-store, no-cache, must-revalidate\n"); // HTTP/1.1 - header( "Cache-Control: post-check=0, pre-check=0\n", false); + //header('Pragma: '); + //header('Cache-Control: '); + header("Expires: Mon, 26 Jul 1997 05:00:00 GMT\n"); + header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . " GMT\n"); + header("Cache-Control: no-store, no-cache, must-revalidate\n"); // HTTP/1.1 + header("Cache-Control: post-check=0, pre-check=0\n", false); }*/ - -header( "Content-Description: " . trim( htmlentities( $file)) . "\n"); -header( "Content-Transfer-Encoding: binary\n"); -header( "Content-Length: " . filesize( $path)."\n" ); +header('Content-Description: ' . trim(htmlentities($file)) . "\n"); +header("Content-Transfer-Encoding: binary\n"); +header('Content-Length: ' . filesize($path)."\n" ); /* -============================================================================== SEND FILE -============================================================================== */ -$fp = fopen( $path, "rb"); -fpassthru( $fp); -exit( ); +$fp = fopen( $path, 'rb'); +fpassthru($fp); +exit(); /** * Found a workaround to another headache that just cropped up tonight. Apparently Opera 6.1 on Linux (unsure of other versions/platforms) has problems downloading files using the above methods if you have enabled compression via zlib.output_compression in php.ini. @@ -409,4 +348,3 @@ exit( ); * Solution: Make sure your download script/section is off in its own directory. and add the following to your .htaccess file for that directory: * php_flag zlib.output_compression off */ -?> \ No newline at end of file diff --git a/main/dropbox/dropbox_functions.inc.php b/main/dropbox/dropbox_functions.inc.php index de89e8bd3b..a7bbce604e 100755 --- a/main/dropbox/dropbox_functions.inc.php +++ b/main/dropbox/dropbox_functions.inc.php @@ -1,18 +1,15 @@ -, Ghent University */ + //require_once '../inc/global.inc.php'; -/* ------------------------------------------------------------ - Javascript ------------------------------------------------------------ -*/ -$this_section=SECTION_COURSES; +$this_section = SECTION_COURSES; $htmlHeadXtra[] = ''; //jQuery $htmlHeadXtra[] = '"; $htmlHeadXtra[] = $javascript; @@ -231,45 +214,31 @@ $htmlHeadXtra[] = ' '; - - -$checked_files=false; -if (!$_GET['view'] OR $_GET['view']=='received') -{ - $part='received'; -} -elseif ($_GET['view']='sent') -{ - $part='sent'; -} -else -{ +$checked_files = false; +if (!$_GET['view'] OR $_GET['view'] == 'received') { + $part = 'received'; +} elseif ($_GET['view'] = 'sent') { + $part = 'sent'; +} else { header ('location: index.php?view='.$_GET['view'].'&error=Error'); } -if (($_POST['action']=='download_received' || $_POST['action']=='download_sent') and !$_POST['store_feedback']) -{ - { + +if (($_POST['action'] == 'download_received' || $_POST['action'] == 'download_sent') and !$_POST['store_feedback']) { $checked_file_ids = $_POST['id']; - if (!is_array($checked_file_ids) || count($checked_file_ids)==0) - { + if (!is_array($checked_file_ids) || count($checked_file_ids) == 0) { header ('location: index.php?view='.$_GET['view'].'&error=CheckAtLeastOneFile'); - exit; - } - else + } else { handle_multiple_actions(); - exit; } + exit; } /* - * ======================================== * AUTHORISATION SECTION - * ======================================== * Prevents access of all users that are not course members */ -if((!$is_allowed_in_course || !$is_course_member) && !api_is_allowed_to_edit(null,true)) { - +if ((!$is_allowed_in_course || !$is_course_member) && !api_is_allowed_to_edit(null, true)) { if ($origin != 'learnpath') { api_not_allowed(true);//print headers/footers } else { @@ -279,54 +248,42 @@ if((!$is_allowed_in_course || !$is_course_member) && !api_is_allowed_to_edit(nul } /* -============================================================================== BREADCRUMBS -============================================================================== */ -if ($_GET['view']=='received') -{ - $interbreadcrumb[] = array ("url" => "../dropbox/index.php", "name" => get_lang('Dropbox', '')); +if ($_GET['view'] == 'received') { + $interbreadcrumb[] = array('url' => '../dropbox/index.php', 'name' => get_lang('Dropbox', '')); $nameTools = get_lang('ReceivedFiles'); - if ($_GET['action'] == 'addreceivedcategory') - { - $interbreadcrumb[] = array ("url" => "../dropbox/index.php?view=received", "name" => get_lang("ReceivedFiles")); + if ($_GET['action'] == 'addreceivedcategory') { + $interbreadcrumb[] = array('url' => '../dropbox/index.php?view=received', 'name' => get_lang('ReceivedFiles')); $nameTools = get_lang('AddNewCategory'); } } -if ($_GET['view']=='sent' OR empty($_GET['view'])) -{ - $interbreadcrumb[] = array ("url" => "../dropbox/index.php", "name" => get_lang('Dropbox', '')); + +if ($_GET['view'] == 'sent' OR empty($_GET['view'])) { + $interbreadcrumb[] = array('url' => '../dropbox/index.php', 'name' => get_lang('Dropbox', '')); $nameTools = get_lang('SentFiles'); - if ($_GET['action'] == 'addsentcategory') - { - $interbreadcrumb[] = array ("url" => "../dropbox/index.php?view=sent", "name" => get_lang("SentFiles")); + if ($_GET['action'] == 'addsentcategory') { + $interbreadcrumb[] = array('url' => '../dropbox/index.php?view=sent', 'name' => get_lang('SentFiles')); $nameTools = get_lang('AddNewCategory'); } - if ($_GET['action'] == 'add') - { - $interbreadcrumb[] = array ("url" => "../dropbox/index.php?view=sent", "name" => get_lang("SentFiles")); + if ($_GET['action'] == 'add') { + $interbreadcrumb[] = array ('url' => '../dropbox/index.php?view=sent', 'name' => get_lang('SentFiles')); $nameTools = get_lang('UploadNewFile'); } } /* -============================================================================== HEADER & TITLE -============================================================================== */ -if ($origin != 'learnpath') -{ - Display::display_header($nameTools,"Dropbox"); -} -else // if we come from the learning path we have to include the stylesheet and the required javascripts manually. -{ - echo ''; +if ($origin != 'learnpath') { + Display::display_header($nameTools, 'Dropbox'); +} else { // if we come from the learning path we have to include the stylesheet and the required javascripts manually. + echo ''; echo $javascript; } // api_display_tool_title($nameTools); -?> \ No newline at end of file diff --git a/main/dropbox/dropbox_submit.php b/main/dropbox/dropbox_submit.php index f971438935..bfedfa49be 100755 --- a/main/dropbox/dropbox_submit.php +++ b/main/dropbox/dropbox_submit.php @@ -1,226 +1,170 @@ - dropbox_cnf("maxFilesize")) - { - $errormsg = get_lang('TooBig'); - - $error = TRUE; - }elseif ( !is_uploaded_file( $dropbox_filetmpname)) // check user fraud : no clean error msg. - { - die(get_lang('BadFormData').' (code 403)'); + if ($dropbox_filesize <= 0 || $dropbox_filesize > dropbox_cnf('maxFilesize')) { + $errormsg = get_lang('TooBig'); // TODO: The "too big" message does not fit in the case of uploading zero-sized file. + $error = true; + } elseif (!is_uploaded_file($dropbox_filetmpname)) { // check user fraud : no clean error msg. + die(get_lang('BadFormData').' (code 403)'); } - if ( !$error) - { + if (!$error) { // Try to add an extension to the file if it hasn't got one - $dropbox_filename = add_ext_on_mime( $dropbox_filename,$dropbox_filetype); + $dropbox_filename = add_ext_on_mime($dropbox_filename, $dropbox_filetype); // Replace dangerous characters - $dropbox_filename = replace_dangerous_char( $dropbox_filename); + $dropbox_filename = replace_dangerous_char($dropbox_filename); // Transform any .php file in .phps fo security - $dropbox_filename = php2phps ( $dropbox_filename); - if(!filter_extension($dropbox_filename)) - { + $dropbox_filename = php2phps($dropbox_filename); + if (!filter_extension($dropbox_filename)) { $error = true; $errormsg = get_lang('UplUnableToSaveFileFilteredExtension'); - } - else - { + } else { // set title $dropbox_title = $dropbox_filename; // set author - if ( $_POST['authors'] == '') - { - $_POST['authors'] = getUserNameFromId( $_user['user_id']); + if ($_POST['authors'] == '') { + $_POST['authors'] = getUserNameFromId($_user['user_id']); } - if ( $dropbox_overwrite) // RH: Mailing: adapted - { - $dropbox_person = new Dropbox_Person( $_user['user_id'], $is_courseAdmin, $is_courseTutor); - - foreach($dropbox_person->sentWork as $w) - { - if ($w->title == $dropbox_filename) - { - if ( ($w->recipients[0]['id'] > dropbox_cnf("mailingIdBase")) xor $thisIsAMailing) - { - $error = TRUE; + if ($dropbox_overwrite) { // RH: Mailing: adapted + $dropbox_person = new Dropbox_Person($_user['user_id'], $is_courseAdmin, $is_courseTutor); + + foreach ($dropbox_person->sentWork as $w) { + if ($w->title == $dropbox_filename) { + if (($w->recipients[0]['id'] > dropbox_cnf('mailingIdBase')) xor $thisIsAMailing) { + $error = true; $errormsg = get_lang('MailingNonMailingError'); } - if ( ($w->recipients[0]['id'] == $_user['user_id']) xor $thisIsJustUpload) - { - $error = TRUE; - $errormsg = get_lang("MailingJustUploadSelectNoOther"); + if ( ($w->recipients[0]['id'] == $_user['user_id']) xor $thisIsJustUpload) { + $error = true; + $errormsg = get_lang('MailingJustUploadSelectNoOther'); } - $dropbox_filename = $w->filename; $found = true; + $dropbox_filename = $w->filename; + $found = true; break; } } - } - else // rename file to login_filename_uniqueId format - { - $dropbox_filename = getLoginFromId( $_user['user_id']) . "_" . $dropbox_filename . "_".uniqid(''); + } else { + // rename file to login_filename_uniqueId format + $dropbox_filename = getLoginFromId( $_user['user_id']) . '_' . $dropbox_filename . '_'.uniqid(''); } - if ( ( ! is_dir( dropbox_cnf("sysPath")))) - { + if (!is_dir(dropbox_cnf('sysPath'))) { //The dropbox subdir doesn't exist yet so make it and create the .htaccess file - mkdir( dropbox_cnf("sysPath"), api_get_permissions_for_new_directories()) or die(get_lang('ErrorCreatingDir').' (code 404)'); - $fp = fopen( dropbox_cnf("sysPath")."/.htaccess", "w") or die(get_lang('ErrorCreatingDir').' (code 405)'); + mkdir(dropbox_cnf('sysPath'), api_get_permissions_for_new_directories()) or die(get_lang('ErrorCreatingDir').' (code 404)'); + $fp = fopen(dropbox_cnf('sysPath').'/.htaccess', 'w') or die(get_lang('ErrorCreatingDir').' (code 405)'); fwrite($fp, "AuthName AllowLocalAccess AuthType Basic @@ -230,38 +174,26 @@ if ( isset( $_POST["submitWork"])) php_flag zlib.output_compression off") or die(get_lang('ErrorCreatingDir').' (code 406)'); } - if ( $error) {} - elseif ( $thisIsAMailing) // RH: $newWorkRecipients is integer - see class - { - if ( preg_match( dropbox_cnf("mailingZipRegexp"), $dropbox_title)) - { - $newWorkRecipients = dropbox_cnf("mailingIdBase"); - } - else - { - $error = TRUE; + if ($error) {} + elseif ($thisIsAMailing) { // RH: $newWorkRecipients is integer - see class + if (preg_match(dropbox_cnf('mailingZipRegexp'), $dropbox_title)) { + $newWorkRecipients = dropbox_cnf('mailingIdBase'); + } else { + $error = true; $errormsg = $dropbox_title . ': ' . get_lang('MailingWrongZipfile'); } - } - elseif ( $thisIsJustUpload) // RH: $newWorkRecipients is empty array - { + } elseif ( $thisIsJustUpload) { // RH: $newWorkRecipients is empty array $newWorkRecipients = array(); - } - else - { // creating the array that contains all the users who will receive the file + } else { + // creating the array that contains all the users who will receive the file $newWorkRecipients = array(); - foreach ($_POST["recipients"] as $rec) - { + foreach ($_POST['recipients'] as $rec) { if (strpos($rec, 'user_') === 0) { - $newWorkRecipients[] = substr($rec, strlen('user_') ); - } - elseif (strpos($rec, 'group_') === 0 ) - { - $userList = GroupManager::get_subscribed_users(substr($rec, strlen('group_') )); - foreach ($userList as $usr) - { - if (! in_array($usr['user_id'], $newWorkRecipients) && $usr['user_id'] != $_user['user_id']) - { + $newWorkRecipients[] = substr($rec, strlen('user_')); + } elseif (strpos($rec, 'group_') === 0) { + $userList = GroupManager::get_subscribed_users(substr($rec, strlen('group_'))); + foreach ($userList as $usr) { + if (!in_array($usr['user_id'], $newWorkRecipients) && $usr['user_id'] != $_user['user_id']) { $newWorkRecipients[] = $usr['user_id']; } } @@ -269,13 +201,12 @@ if ( isset( $_POST["submitWork"])) } } - //After uploading the file, create the db entries + // After uploading the file, create the db entries - if ( !$error) - { - @move_uploaded_file( $dropbox_filetmpname, dropbox_cnf("sysPath") . '/' . $dropbox_filename) + if (!$error) { + @move_uploaded_file( $dropbox_filetmpname, dropbox_cnf('sysPath') . '/' . $dropbox_filename) or die(get_lang('UploadError').' (code 407)'); - new Dropbox_SentWork( $_user['user_id'], $dropbox_title, $_POST['description'], strip_tags($_POST['authors']), $dropbox_filename, $dropbox_filesize, $newWorkRecipients); + new Dropbox_SentWork($_user['user_id'], $dropbox_title, $_POST['description'], strip_tags($_POST['authors']), $dropbox_filename, $dropbox_filesize, $newWorkRecipients); } } } @@ -283,43 +214,35 @@ if ( isset( $_POST["submitWork"])) /** - * ======================================== * SUBMIT FORM RESULTMESSAGE - * ======================================== */ - if ( !$error) - { - $return_message=get_lang('FileUploadSucces'); - } - else - { - $return_message=$errormsg; + if (!$error) { + $return_message = get_lang('FileUploadSucces'); + } else { + $return_message = $errormsg; } -} // end if ( isset( $_POST["submitWork"])) +} // end if ( isset( $_POST['submitWork'])) /** - * ======================================== * // RH: EXAMINE OR SEND MAILING (NEW) - * ======================================== */ -if ( isset( $_GET['mailingIndex'])) // examine or send -{ + +if (isset($_GET['mailingIndex'])) { // examine or send $dropbox_person = new Dropbox_Person( $_user['user_id'], $is_courseAdmin, $is_courseTutor); - if ( isset($_SESSION["sentOrder"])) - { - $dropbox_person->orderSentWork ($_SESSION["sentOrder"]); + if (isset($_SESSION['sentOrder'])) { + $dropbox_person->orderSentWork($_SESSION['sentOrder']); } - $i = $_GET['mailingIndex']; $mailing_item = $dropbox_person->sentWork[$i]; + $i = $_GET['mailingIndex']; + $mailing_item = $dropbox_person->sentWork[$i]; $mailing_title = $mailing_item->title; - $mailing_file = dropbox_cnf("sysPath") . '/' . $mailing_item->filename; + $mailing_file = dropbox_cnf('sysPath') . '/' . $mailing_item->filename; $errormsg = '' . $mailing_item->recipients[0]['name'] . ' (' . "" - . htmlspecialchars($mailing_title,ENT_QUOTES,$charset) . '):

'; + . htmlspecialchars($mailing_title, ENT_QUOTES, api_get_system_encoding()) . '):

'; - if ( preg_match( dropbox_cnf("mailingZipRegexp"), $mailing_title, $nameParts)) - { + if (preg_match( dropbox_cnf('mailingZipRegexp'), $mailing_title, $nameParts)) { $var = api_strtoupper($nameParts[2]); // the variable part of the name $course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER); $sel = "SELECT u.user_id, u.lastname, u.firstname, cu.status @@ -328,8 +251,7 @@ if ( isset( $_GET['mailingIndex'])) // examine or send ON cu.user_id = u.user_id AND cu.relation_type<>".COURSE_RELATION_TYPE_RRHH." AND cu.course_code = '".$_course['sysCode']."'"; $sel .= " WHERE u.".dropbox_cnf("mailingWhere".$var)." = '"; - function getUser($thisRecip) - { + function getUser($thisRecip) { // string result = error message, array result = [user_id, lastname, firstname] global $var, $sel; @@ -341,16 +263,11 @@ if ( isset( $_GET['mailingIndex'])) // examine or send while ( ($res = Database::fetch_array($result))) {$students[] = $res;} Database::free_result($result); - if (count($students) == 1) - { + if (count($students) == 1) { return($students[0]); - } - elseif (count($students) > 1) - { + } elseif (count($students) > 1) { return ' <'.get_lang('MailingFileRecipDup', '').$var."= $thisRecip>"; - } - else - { + } else { return ' <'.get_lang('MailingFileRecipNotFound', '').$var."= $thisRecip>"; } } @@ -358,117 +275,84 @@ if ( isset( $_GET['mailingIndex'])) // examine or send $preFix = $nameParts[1]; $postFix = $nameParts[3]; $preLen = api_strlen($preFix); $postLen = api_strlen($postFix); - function findRecipient($thisFile) - { + function findRecipient($thisFile) { // string result = error message, array result = [user_id, lastname, firstname, status] global $nameParts, $preFix, $preLen, $postFix, $postLen; - if ( preg_match(dropbox_cnf("mailingFileRegexp"), $thisFile, $matches)) - { + if (preg_match(dropbox_cnf('mailingFileRegexp'), $thisFile, $matches)) { $thisName = $matches[1]; - if ( api_substr($thisName, 0, $preLen) == $preFix) - { - if ( $postLen == 0 || api_substr($thisName, -$postLen) == $postFix) - { + if (api_substr($thisName, 0, $preLen) == $preFix) { + if ($postLen == 0 || api_substr($thisName, -$postLen) == $postFix) { $thisRecip = api_substr($thisName, $preLen, api_strlen($thisName) - $preLen - $postLen); - if ( $thisRecip) return getUser($thisRecip); + if ($thisRecip) { + return getUser($thisRecip); + } return ' <'.get_lang('MailingFileNoRecip', '').'>'; - } - else - { + } else { return ' <'.get_lang('MailingFileNoPostfix', '').$postFix.'>'; } - } - else - { + } else { return ' <'.get_lang('MailingFileNoPrefix', '').$preFix.'>'; } - } - else - { + } else { return ' <'.get_lang('MailingFileFunny', '').'>'; } } - if (file_exists(api_get_path(INCLUDE_PATH) . "/pclzip/pclzip.lib.php")) - { - require(api_get_path(INCLUDE_PATH) . "/pclzip/pclzip.lib.php"); - } - else - { - require(api_get_path(LIBRARY_PATH) . "/pclzip/pclzip.lib.php"); - } + require api_get_path(LIBRARY_PATH) . 'pclzip/pclzip.lib.php'; - $zipFile = new pclZip($mailing_file); $goodFiles = array(); - $zipContent = $zipFile->listContent(); $ucaseFiles = array(); + $zipFile = new pclZip($mailing_file); + $goodFiles = array(); + $zipContent = $zipFile->listContent(); + $ucaseFiles = array(); - if ( $zipContent) - { - foreach( $zipFile->listContent() as $thisContent) - { + if ($zipContent) { + foreach( $zipFile->listContent() as $thisContent) { $thisFile = substr(strrchr('/' . $thisContent['filename'], '/'), 1); $thisFileUcase = strtoupper($thisFile); - if ( preg_match("~.(php.*|phtml)$~i", $thisFile) ) - { - $error = TRUE; $errormsg .= $thisFile . ': ' . get_lang('MailingZipPhp'); + if (preg_match("~.(php.*|phtml)$~i", $thisFile)) { + $error = true; + $errormsg .= $thisFile . ': ' . get_lang('MailingZipPhp'); break; - } - elseif ( !$thisContent['folder']) - { - if ( $ucaseFiles[$thisFileUcase]) - { - $error = TRUE; $errormsg .= $thisFile . ': ' . get_lang('MailingZipDups'); + } elseif (!$thisContent['folder']) { + if ($ucaseFiles[$thisFileUcase]) { + $error = true; + $errormsg .= $thisFile . ': ' . get_lang('MailingZipDups'); break; - } - else - { + } else { $goodFiles[$thisFile] = findRecipient($thisFile); - $ucaseFiles[$thisFileUcase] = "yep"; + $ucaseFiles[$thisFileUcase] = 'yep'; } } - } - } - else - { - $error = TRUE; $errormsg .= get_lang('MailingZipEmptyOrCorrupt'); + } else { + $error = true; + $errormsg .= get_lang('MailingZipEmptyOrCorrupt'); } - if ( !$error) - { + if (!$error) { $students = array(); // collect all recipients in this course - foreach( $goodFiles as $thisFile => $thisRecip) - { - $errormsg .= htmlspecialchars($thisFile,ENT_QUOTES,$charset) . ': '; - if ( is_string($thisRecip)) // see findRecipient - { + foreach ($goodFiles as $thisFile => $thisRecip) { + $errormsg .= htmlspecialchars($thisFile, ENT_QUOTES, api_get_system_encoding()) . ': '; + if (is_string($thisRecip)) { // see findRecipient $errormsg .= '' - . htmlspecialchars($thisRecip,ENT_QUOTES,$charset) . '
'; - } - else - { - if ( isset( $_GET['mailingSend'])) - { + . htmlspecialchars($thisRecip, ENT_QUOTES, api_get_system_encoding()) . '
'; + } else { + if ( isset( $_GET['mailingSend'])) { $errormsg .= get_lang('MailingFileSentTo'); - } - else - { + } else { $errormsg .= get_lang('MailingFileIsFor'); } - $errormsg .= htmlspecialchars(api_get_person_name($thisRecip[2], $thisRecip[1]), ENT_QUOTES, $charset); + $errormsg .= htmlspecialchars(api_get_person_name($thisRecip[2], $thisRecip[1]), ENT_QUOTES, api_get_system_encoding()); - if ( is_null($thisRecip[3])) - { + if (is_null($thisRecip[3])) { $errormsg .= get_lang('MailingFileNotRegistered'); - } - else - { + } else { $students[] = $thisRecip[0]; } - $errormsg .= '
'; - + $errormsg .= '
'; } } @@ -483,203 +367,159 @@ if ( isset( $_GET['mailingIndex'])) // examine or send AND u.user_id NOT IN ('" . implode("', '" , $students) . "')"; $result = Database::query($sql); - if ( Database::num_rows($result) > 0) - { + if (Database::num_rows($result) > 0) { $remainingUsers = ''; - while ( ($res = Database::fetch_array($result))) - { - $remainingUsers .= ', ' . htmlspecialchars(api_get_person_name($res[1], $res[0]), ENT_QUOTES, $charset); + while ($res = Database::fetch_array($result)) { + $remainingUsers .= ', ' . htmlspecialchars(api_get_person_name($res[1], $res[0]), ENT_QUOTES, api_get_system_encoding()); } $errormsg .= '
' . get_lang('MailingNothingFor') . api_substr($remainingUsers, 1) . '.
'; } - if ( isset( $_GET['mailingSend'])) - { - chdir(dropbox_cnf("sysPath")); + if (isset($_GET['mailingSend'])) { + chdir(dropbox_cnf('sysPath')); $zipFile->extract(PCLZIP_OPT_REMOVE_ALL_PATH); - $mailingPseudoId = dropbox_cnf("mailingIdBase") + $mailing_item->id; + $mailingPseudoId = dropbox_cnf('mailingIdBase') + $mailing_item->id; - foreach( $goodFiles as $thisFile => $thisRecip) - { - if ( is_string($thisRecip)) // remove problem file - { - @unlink(dropbox_cnf("sysPath") . '/' . $thisFile); - } - else - { - $newName = getLoginFromId( $_user['user_id']) . "_" . $thisFile . "_" . uniqid(''); - if ( rename(dropbox_cnf("sysPath") . '/' . $thisFile, dropbox_cnf("sysPath") . '/' . $newName)) - new Dropbox_SentWork( $mailingPseudoId, $thisFile, $mailing_item->description, $mailing_item->author, $newName, $thisContent['size'], array($thisRecip[0])); + foreach ($goodFiles as $thisFile => $thisRecip) { + if (is_string($thisRecip)) { // remove problem file + @unlink(dropbox_cnf('sysPath') . '/' . $thisFile); + } else { + $newName = getLoginFromId( $_user['user_id']) . '_' . $thisFile . '_' . uniqid(''); + if (rename(dropbox_cnf('sysPath') . '/' . $thisFile, dropbox_cnf('sysPath') . '/' . $newName)) + new Dropbox_SentWork($mailingPseudoId, $thisFile, $mailing_item->description, $mailing_item->author, $newName, $thisContent['size'], array($thisRecip[0])); } } - $sendDT = addslashes(date("Y-m-d H:i:s",time())); + $sendDT = addslashes(date('Y-m-d H:i:s', time())); // set filesize to zero on send, to avoid 2nd send (see index.php) $sql = "UPDATE ".dropbox_cnf("tbl_file")." SET filesize = '0' , upload_date = '".$sendDT."', last_upload_date = '".$sendDT."' WHERE id='".addslashes($mailing_item->id)."'"; - $result =Database::query($sql); - } - elseif ($mailing_item->filesize != 0) - { + $result = Database::query($sql); + } elseif ($mailing_item->filesize != 0) { $errormsg .= '
' . get_lang('MailingNotYetSent') . '
'; } } - } - else - { - $error = TRUE; $errormsg .= get_lang('MailingWrongZipfile'); + } else { + $error = true; + $errormsg .= get_lang('MailingWrongZipfile'); } /** - * ======================================== * EXAMINE OR SEND MAILING RESULTMESSAGE - * ======================================== */ - if ( $error) - { + + if ($error) { ?> -

- ">
+

+ ">
-

- ">
+

+ ">
orderSentWork ($_SESSION["sentOrder"]); + if (isset($_SESSION['sentOrder'])) { + $dropbox_person->orderSentWork($_SESSION['sentOrder']); } - if ( isset($_SESSION["receivedOrder"])) - { - $dropbox_person->orderReceivedWork ($_SESSION["receivedOrder"]); + if (isset($_SESSION['receivedOrder'])) { + $dropbox_person->orderReceivedWork($_SESSION['receivedOrder']); } - /*if (! $dropbox_person->isCourseAdmin || ! $dropbox_person->isCourseTutor) { + /*if (!$dropbox_person->isCourseAdmin || ! $dropbox_person->isCourseTutor) { die(get_lang('GeneralError').' (code 408)'); }*/ $tellUser = get_lang('FileDeleted'); // RH: Feedback - if ( isset( $_GET['deleteReceived'])) - { - if ( $_GET["deleteReceived"] == "all") - { - $dropbox_person->deleteAllReceivedWork( ); - }elseif ( is_numeric( $_GET["deleteReceived"])) - { + if (isset($_GET['deleteReceived'])) { + if ($_GET['deleteReceived'] == 'all') { + $dropbox_person->deleteAllReceivedWork(); + } elseif (is_numeric($_GET['deleteReceived'])) { $dropbox_person->deleteReceivedWork( $_GET['deleteReceived']); - } - else - { + } else { die(get_lang('GeneralError').' (code 409)'); } - } - elseif ( isset( $_GET['deleteSent'])) // RH: Feedback - { - if ( $_GET["deleteSent"] == "all") - { + } elseif (isset( $_GET['deleteSent'])) { // RH: Feedback + if ($_GET['deleteSent'] == 'all') { $dropbox_person->deleteAllSentWork( ); - }elseif ( is_numeric( $_GET["deleteSent"])) - { - $dropbox_person->deleteSentWork( $_GET['deleteSent']); - } - else - { + } elseif (is_numeric($_GET['deleteSent'])) { + $dropbox_person->deleteSentWork($_GET['deleteSent']); + } else { die(get_lang('GeneralError').' (code 410)'); } - } - elseif ( isset( $_GET['showFeedback'])) // RH: Feedback - { + } elseif (isset($_GET['showFeedback'])) { // RH: Feedback $w = new Dropbox_SentWork($id = $_GET['showFeedback']); - if ($w->uploader_id != $_user['user_id']) + if ($w->uploader_id != $_user['user_id']) { getUserOwningThisMailing($w->uploader_id, $_user['user_id'], '411'); // RH or die + } - foreach( $w -> recipients as $r) if (($fb = $r["feedback"])) - { - $fbarray [$r["feedback_date"].$r["name"]]= - $r["name"] . ' ' . get_lang('SentOn', '') . - ' ' . $r["feedback_date"] . ":\n" . $fb; + foreach ($w -> recipients as $r) { + if (($fb = $r['feedback'])) { + $fbarray[$r['feedback_date'].$r['name']] = $r['name'].' '.get_lang('SentOn', '').' '.$r['feedback_date'].":\n".$fb; + } } - if ($fbarray) - { + if ($fbarray) { krsort($fbarray); echo '', "\n"; - } - else - { + htmlspecialchars(implode("\n\n", $fbarray), ENT_QUOTES, api_get_system_encoding()), '', "\n"; + } else { echo '', "\n"; } $tellUser = get_lang('ShowFeedback'); - } - else // if ( isset( $_GET['editFeedback'])) // RH: Feedback - { - $id = $_GET['editFeedback']; $found = false; - foreach($dropbox_person->receivedWork as $w) { + + } else { // if ( isset( $_GET['editFeedback'])) { // RH: Feedback + $id = $_GET['editFeedback']; + $found = false; + foreach ($dropbox_person->receivedWork as $w) { if ($w->id == $id) { - $found = true; break; + $found = true; + break; } } - if (! $found) die(get_lang('GeneralError').' (code 415)'); + if (!$found) die(get_lang('GeneralError').' (code 415)'); echo '
', "\n", '', "\n", '', "
\n", + htmlspecialchars($w->feedback, ENT_QUOTES, api_get_system_encoding()), '', "
\n", '', "\n", '
', "\n"; $tellUser = get_lang('GiveFeedback'); } /** - * ============================================== * RESULTMESSAGE FOR DELETE FILE OR EDIT FEEDBACK // RH: Feedback - * ============================================== */ $return_message = get_lang('BackList'); } -?> diff --git a/main/dropbox/dropbox_zipdownload.inc.php b/main/dropbox/dropbox_zipdownload.inc.php index f57e3c5054..185ddd9630 100755 --- a/main/dropbox/dropbox_zipdownload.inc.php +++ b/main/dropbox/dropbox_zipdownload.inc.php @@ -1,6 +1,5 @@ - \ No newline at end of file +require_once 'dropbox_init.inc.php'; diff --git a/main/dropbox/index.php b/main/dropbox/index.php index 4d1b16978f..4fbf9e88bc 100755 --- a/main/dropbox/index.php +++ b/main/dropbox/index.php @@ -1,7 +1,7 @@ '.$return_information['message']); - display_addcategory_form($_POST['category_name'],$_POST['edit_id'],$_POST['action']); + display_addcategory_form($_POST['category_name'], $_POST['edit_id'], $_POST['action']); } } -// *** Move a File *** -if (($_GET['action']=='movesent' OR $_GET['action']=='movereceived') AND isset($_GET['move_id'])) { - if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) { +// Move a File +if (($_GET['action'] == 'movesent' OR $_GET['action'] == 'movereceived') AND isset($_GET['move_id'])) { + if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { api_not_allowed(); - } - display_move_form(str_replace('move','',$_GET['action']), $_GET['move_id'], get_dropbox_categories(str_replace('move','',$_GET['action']))); + } + display_move_form(str_replace('move', '', $_GET['action']), $_GET['move_id'], get_dropbox_categories(str_replace('move', '', $_GET['action']))); } if ($_POST['do_move']) { Display :: display_confirmation_message(store_move($_POST['id'], $_POST['move_target'], $_POST['part'])); } -// *** Delete a file *** -if (($_GET['action']=='deletereceivedfile' OR $_GET['action']=='deletesentfile') AND isset($_GET['id']) AND is_numeric($_GET['id'])) { - if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) { +// Delete a file +if (($_GET['action'] == 'deletereceivedfile' OR $_GET['action'] == 'deletesentfile') AND isset($_GET['id']) AND is_numeric($_GET['id'])) { + if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { api_not_allowed(); - } - $dropboxfile=new Dropbox_Person( $_user['user_id'], $is_courseAdmin, $is_courseTutor); - if ($_GET['action']=='deletereceivedfile') { + } + $dropboxfile = new Dropbox_Person($_user['user_id'], $is_courseAdmin, $is_courseTutor); + if ($_GET['action'] == 'deletereceivedfile') { $dropboxfile->deleteReceivedWork($_GET['id']); - $message=get_lang('ReceivedFileDeleted'); + $message = get_lang('ReceivedFileDeleted'); } - if ($_GET['action']=='deletesentfile') { + if ($_GET['action'] == 'deletesentfile') { $dropboxfile->deleteSentWork($_GET['id']); - $message=get_lang('SentFileDeleted'); + $message = get_lang('SentFileDeleted'); } Display :: display_confirmation_message($message); } -// *** Delete a category *** -if (($_GET['action']=='deletereceivedcategory' OR $_GET['action']=='deletesentcategory') AND isset($_GET['id']) AND is_numeric($_GET['id'])) { - if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) { +// Delete a category +if (($_GET['action'] == 'deletereceivedcategory' OR $_GET['action'] == 'deletesentcategory') AND isset($_GET['id']) AND is_numeric($_GET['id'])) { + if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { api_not_allowed(); - } - $message=delete_category($_GET['action'], $_GET['id']); + } + $message = delete_category($_GET['action'], $_GET['id']); Display :: display_confirmation_message($message); } -// *** Do an action on multiple files *** +// Do an action on multiple files // only the download has is handled separately in dropbox_init_inc.php because this has to be done before the headers are sent // (which also happens in dropbox_init.inc.php -if (!isset($_POST['feedback']) && (strstr($_POST['action'],'move_received') OR - $_POST['action'] == 'delete_received' OR $_POST['action'] == 'download_received' OR - $_POST['action'] == 'delete_sent' OR $_POST['action'] == 'download_sent')) -{ - $display_message=handle_multiple_actions(); +if (!isset($_POST['feedback']) && (strstr($_POST['action'], 'move_received') OR + $_POST['action'] == 'delete_received' OR $_POST['action'] == 'download_received' OR + $_POST['action'] == 'delete_sent' OR $_POST['action'] == 'download_sent')) { + + $display_message = handle_multiple_actions(); Display :: display_normal_message($display_message); } -// *** Store Feedback *** +// Store Feedback -if ($_POST['feedback']) { - if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) { +if ($_POST['feedback']) { + if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false,true)) { api_not_allowed(); - } - $check = Security::check_token(); - if ($check) { + } + $check = Security::check_token(); + if ($check) { $display_message = store_feedback(); Display :: display_normal_message($display_message); - Security::check_token(); - } + Security::check_token(); + } } -// *** Error Message *** +// Error Message if (isset($_GET['error']) AND !empty($_GET['error'])) { Display :: display_normal_message(get_lang($_GET['error'])); } +if ($_GET['action'] != 'add') { -if ($_GET['action']!="add") { -// getting all the categories in the dropbox for the given user -$dropbox_categories=get_dropbox_categories(); -// creating the arrays with the categories for the received files and for the sent files -foreach ($dropbox_categories as $category) { - if ($category['received']=='1') { - $dropbox_received_category[]=$category; - } - if ($category['sent']=='1') { - $dropbox_sent_category[]=$category; + // getting all the categories in the dropbox for the given user + $dropbox_categories = get_dropbox_categories(); + // creating the arrays with the categories for the received files and for the sent files + foreach ($dropbox_categories as $category) { + if ($category['received'] == '1') { + $dropbox_received_category[] = $category; + } + if ($category['sent'] == '1') { + $dropbox_sent_category[] = $category; + } } -} - -// ACTIONS -if ( $_GET['view']=='received' OR $dropbox_cnf['sent_received_tabs']==false) { - //echo '

'.get_lang('ReceivedFiles').'

'; - - // This is for the categories - if (isset($_GET['view_received_category']) AND $_GET['view_received_category']<>'') { - $view_dropbox_category_received=Security::remove_XSS($_GET['view_received_category']); - } else { - $view_dropbox_category_received=0; - } + // ACTIONS + if ($_GET['view'] == 'received' OR !$dropbox_cnf['sent_received_tabs']) { + //echo '

'.get_lang('ReceivedFiles').'

'; - /* *** Menu Received *** */ - - if (api_get_session_id()==0) { - echo '
'; - if ($view_dropbox_category_received<>0 && api_is_allowed_to_session_edit(false,true)) { - echo get_lang('CurrentlySeeing').': '.$dropbox_categories[$view_dropbox_category_received]['cat_name'].' '; - echo ''.Display::return_icon('folder_up.gif',get_lang('Up')).' '.get_lang('Root')."\n"; - $movelist[0] = 'Root'; // move_received selectbox content + // This is for the categories + if (isset($_GET['view_received_category']) AND $_GET['view_received_category']<>'') { + $view_dropbox_category_received = Security::remove_XSS($_GET['view_received_category']); } else { - echo ''.Display::return_icon('folder_new.gif',get_lang('AddNewCategory')).' '.get_lang('AddNewCategory').''; + $view_dropbox_category_received = 0; } - echo '
'; - } else { - if (api_is_allowed_to_session_edit(false,true)) { - echo '
'; - if ($view_dropbox_category_received<>0 && api_is_allowed_to_session_edit(false,true)) { + + /* Menu Received */ + + if (api_get_session_id() == 0) { + echo '
'; + if ($view_dropbox_category_received != 0 && api_is_allowed_to_session_edit(false, true)) { echo get_lang('CurrentlySeeing').': '.$dropbox_categories[$view_dropbox_category_received]['cat_name'].' '; - echo ''.Display::return_icon('folder_up.gif',get_lang('Up')).' '.get_lang('Root')."\n"; - $movelist[0] = 'Root'; // move_received selectbox content + echo ''.Display::return_icon('folder_up.gif', get_lang('Up')).' '.get_lang('Root')."\n"; + $movelist[0] = 'Root'; // move_received selectbox content } else { - echo ''.Display::return_icon('folder_new.gif',get_lang('AddNewCategory')).' '.get_lang('AddNewCategory').''; + echo ''.Display::return_icon('folder_new.gif', get_lang('AddNewCategory')).' '.get_lang('AddNewCategory').''; } echo '
'; - } - } -} -if (!$_GET['view'] OR $_GET['view']=='sent' OR $dropbox_cnf['sent_received_tabs']==false) { - //echo '

'.get_lang('SentFiles').'

'; - - // This is for the categories - if (isset($_GET['view_sent_category']) AND $_GET['view_sent_category']<>'') { - $view_dropbox_category_sent=$_GET['view_sent_category']; - } else { - $view_dropbox_category_sent=0; + } else { + if (api_is_allowed_to_session_edit(false, true)) { + echo '
'; + if ($view_dropbox_category_received != 0 && api_is_allowed_to_session_edit(false, true)) { + echo get_lang('CurrentlySeeing').': '.$dropbox_categories[$view_dropbox_category_received]['cat_name'].' '; + echo ''.Display::return_icon('folder_up.gif', get_lang('Up')).' '.get_lang('Root')."\n"; + $movelist[0] = 'Root'; // move_received selectbox content + } else { + echo ''.Display::return_icon('folder_new.gif', get_lang('AddNewCategory')).' '.get_lang('AddNewCategory').''; + } + echo '
'; + } + } } - /* *** Menu Sent *** */ + if (!$_GET['view'] OR $_GET['view'] == 'sent' OR !$dropbox_cnf['sent_received_tabs']) { + //echo '

'.get_lang('SentFiles').'

'; - if (api_get_session_id()==0) { - echo '
'; - if ($view_dropbox_category_sent<>0) { - echo get_lang('CurrentlySeeing').': '.$dropbox_categories[$view_dropbox_category_sent]['cat_name'].' '; - echo ''.Display::return_icon('folder_up.gif',get_lang('Up')).' '.get_lang('Root')."\n"; + // This is for the categories + if (isset($_GET['view_sent_category']) AND $_GET['view_sent_category'] != '') { + $view_dropbox_category_sent = $_GET['view_sent_category']; } else { - echo "".Display::return_icon('folder_new.gif',get_lang('AddNewCategory'))." ".get_lang('AddNewCategory')."\n"; - } - if (empty($_GET['view_sent_category'])) { - echo "".Display::return_icon('submit_file.gif',get_lang('UploadNewFile')).' '.get_lang('UploadNewFile')." \n"; + $view_dropbox_category_sent = 0; } - echo '
'; - } else { - if (api_is_allowed_to_session_edit(false,true)) { - echo '
'; - if ($view_dropbox_category_sent<>0) { + + /* Menu Sent */ + + if (api_get_session_id() == 0) { + echo ''; - } + echo '
'; + } else { + if (api_is_allowed_to_session_edit(false, true)) { + echo '
'; + if ($view_dropbox_category_sent != 0) { + echo get_lang('CurrentlySeeing').': '.$dropbox_categories[$view_dropbox_category_sent]['cat_name'].' '; + echo ''.Display::return_icon('folder_up.gif', get_lang('Up')).' '.get_lang('Root')."\n"; + } else { + echo "".Display::return_icon('folder_new.gif', get_lang('AddNewCategory'))." ".get_lang('AddNewCategory')."\n"; + } + if (empty($_GET['view_sent_category'])) { + echo "".Display::return_icon('submit_file.gif', get_lang('UploadNewFile')).' '.get_lang('UploadNewFile')." \n"; + } + echo '
'; + } + } } - -} -/* ------------------------------------------------------------ - THE MENU TABS ------------------------------------------------------------ -*/ -if ($dropbox_cnf['sent_received_tabs']) { + /* + THE MENU TABS + */ + if ($dropbox_cnf['sent_received_tabs']) { ?>
'.get_lang('ReceivedFiles').''; - - // This is for the categories - if (isset($_GET['view_received_category']) AND $_GET['view_received_category']<>'') { - $view_dropbox_category_received=$_GET['view_received_category']; - } else { - $view_dropbox_category_received=0; } - // object initialisation - $dropbox_person = new Dropbox_Person( $_user['user_id'], $is_courseAdmin, $is_courseTutor); // note: are the $is_courseAdmin and $is_courseTutor parameters needed???? - - // constructing the array that contains the total number of feedback messages per document. - $number_feedback=get_total_number_feedback(); - - // sorting and paging options - $sorting_options = array(); - $paging_options = array(); - - // the headers of the sortable tables - $column_header=array(); - $column_header[] = array('',false,''); - $column_header[] = array(get_lang('Type'),true,'style="width:40px"'); - $column_header[] = array(get_lang('ReceivedTitle'), TRUE, ''); - $column_header[] = array(get_lang('Size'), TRUE, ''); - $column_header[] = array(get_lang('Authors'), TRUE, ''); - $column_header[] = array(get_lang('LastResent'), true); - - if (api_get_session_id()==0) - $column_header[] = array(get_lang('Modify'), FALSE, '', 'nowrap style="text-align: right"'); - elseif (api_is_allowed_to_session_edit(false,true)){ - $column_header[] = array(get_lang('Modify'), FALSE, '', 'nowrap style="text-align: right"'); - } - - $column_header[] = array('RealDate', true); - - - // An array with the setting of the columns -> 1: columns that we will show, 0:columns that will be hide - $column_show[]=1; - $column_show[]=1; - $column_show[]=1; - $column_show[]=1; - $column_show[]=1; - $column_show[]=1; - - if (api_get_session_id()==0) - $column_show[]=1; - elseif (api_is_allowed_to_session_edit(false,true)){ - $column_show[]=1; - } - $column_show[]=0; + /* + RECEIVED FILES + */ + if ($_GET['view'] == 'received' OR !$dropbox_cnf['sent_received_tabs']) { + //echo '

'.get_lang('ReceivedFiles').'

'; - // Here we change the way how the colums are going to be sort - // in this case the the column of LastResent ( 4th element in $column_header) we will be order like the column RealDate - // because in the column RealDate we have the days in a correct format "2008-03-12 10:35:48" - - $column_order[]=1; - $column_order[]=2; - $column_order[]=3; - $column_order[]=4; - $column_order[]=7; - $column_order[]=6; - $column_order[]=7; - $column_order[]=8; + // This is for the categories + if (isset($_GET['view_received_category']) AND $_GET['view_received_category'] != '') { + $view_dropbox_category_received = $_GET['view_received_category']; + } else { + $view_dropbox_category_received = 0; + } + // object initialisation + $dropbox_person = new Dropbox_Person($_user['user_id'], $is_courseAdmin, $is_courseTutor); // note: are the $is_courseAdmin and $is_courseTutor parameters needed???? + + // constructing the array that contains the total number of feedback messages per document. + $number_feedback = get_total_number_feedback(); + + // sorting and paging options + $sorting_options = array(); + $paging_options = array(); + + // the headers of the sortable tables + $column_header = array(); + $column_header[] = array('', false, ''); + $column_header[] = array(get_lang('Type'), true, '', 'style="width:40px; text-align:center"'); + $column_header[] = array(get_lang('ReceivedTitle'), true, ''); + $column_header[] = array(get_lang('Size'), true, ''); + $column_header[] = array(get_lang('Authors'), true, ''); + $column_header[] = array(get_lang('LastResent'), true); + + if (api_get_session_id() == 0) { + $column_header[] = array(get_lang('Modify'), false, '', 'nowrap style="text-align: right"'); + } elseif (api_is_allowed_to_session_edit(false,true)) { + $column_header[] = array(get_lang('Modify'), false, '', 'nowrap style="text-align: right"'); + } + $column_header[] = array('RealDate', true); - // the content of the sortable table = the received files - foreach ( $dropbox_person -> receivedWork as $dropbox_file) { - $dropbox_file_data=array(); - if ($view_dropbox_category_received==$dropbox_file->category) {// we only display the files that are in the category that we are in. - $dropbox_file_data[]=$dropbox_file->id; + // An array with the setting of the columns -> 1: columns that we will show, 0:columns that will be hide + $column_show[] = 1; + $column_show[] = 1; + $column_show[] = 1; + $column_show[] = 1; + $column_show[] = 1; + $column_show[] = 1; - if (!is_array($_SESSION['_seen'][$_course['id']][TOOL_DROPBOX])) { - $_SESSION['_seen'][$_course['id']][TOOL_DROPBOX] = array(); + if (api_get_session_id() == 0) { + $column_show[] = 1; + } elseif (api_is_allowed_to_session_edit(false, true)) { + $column_show[] = 1; + } + $column_show[] = 0; + + // Here we change the way how the colums are going to be sort + // in this case the the column of LastResent ( 4th element in $column_header) we will be order like the column RealDate + // because in the column RealDate we have the days in a correct format "2008-03-12 10:35:48" + + $column_order[] = 1; + $column_order[] = 2; + $column_order[] = 3; + $column_order[] = 4; + $column_order[] = 7; + $column_order[] = 6; + $column_order[] = 7; + $column_order[] = 8; + + // the content of the sortable table = the received files + foreach ($dropbox_person -> receivedWork as $dropbox_file) { + $dropbox_file_data = array(); + if ($view_dropbox_category_received == $dropbox_file->category) { // we only display the files that are in the category that we are in. + $dropbox_file_data[] = $dropbox_file->id; + + if (!is_array($_SESSION['_seen'][$_course['id']][TOOL_DROPBOX])) { + $_SESSION['_seen'][$_course['id']][TOOL_DROPBOX] = array(); + } + + // new icon + $new_icon = ''; + if ($dropbox_file->last_upload_date > $last_access AND !in_array($dropbox_file->id, $_SESSION['_seen'][$_course['id']][TOOL_DROPBOX])) { + $new_icon = ' '.Display::return_icon('new.gif', get_lang('New')); + } + + $dropbox_file_data[] = build_document_icon_tag('file', $dropbox_file->title); + $dropbox_file_data[] = ''.Display::return_icon('filesave.gif', get_lang('Download'), array('style' => 'float:right;')).''.$dropbox_file->title.''.$new_icon.'
'.$dropbox_file->description; + $dropbox_file_data[] = ceil(($dropbox_file->filesize) / 1024).' '.get_lang('kB'); + $dropbox_file_data[] = $dropbox_file->author; + //$dropbox_file_data[] = $dropbox_file->description; + + $dropbox_file_data[] = date_to_str_ago(api_get_local_time($dropbox_file->last_upload_date, null, null, date_default_timezone_get())).'
'.api_get_local_time($dropbox_file->last_upload_date, null, null, date_default_timezone_get()).''; + + $action_icons = check_number_feedback($dropbox_file->id, $number_feedback).' '.get_lang('Feedback').' + '.Display::return_icon('comment_bubble.gif', get_lang('Comment')).' + '.Display::return_icon('deplacer_fichier.gif', get_lang('Move')).' + '.Display::return_icon('delete.gif', get_lang('Delete')).''; + //$action_icons=' '.Display::return_icon('deplacer.gif',get_lang('Move')).' + // '.Display::return_icon('delete.gif', get_lang('Delete')).''; + // this is a hack to have an additional row in a sortable table + + if ($_GET['action'] == 'viewfeedback' AND isset($_GET['id']) and is_numeric($_GET['id']) AND $dropbox_file->id == $_GET['id']) { + $action_icons .= "\n"; // ending the normal row of the sortable table + $action_icons .= '".get_lang('CloseFeedback')."".feedback($dropbox_file->feedback2)."\n\n"; + } + if (api_get_session_id() == 0) { + $dropbox_file_data[] = $action_icons; + } elseif (api_is_allowed_to_session_edit(false, true)) { + $dropbox_file_data[] = $action_icons; + } + $action_icons = ''; + + $dropbox_file_data[] = $dropbox_file->last_upload_date; //date + + $dropbox_data_recieved[] = $dropbox_file_data; } + } - // new icon - $new_icon=''; - if ($dropbox_file->last_upload_date > $last_access AND !in_array($dropbox_file->id,$_SESSION['_seen'][$_course['id']][TOOL_DROPBOX])) { - $new_icon=' '.Display::return_icon('new.gif', get_lang('New')); + // the content of the sortable table = the categories (if we are not in the root) + if ($view_dropbox_category_received == 0) { + foreach ($dropbox_categories as $category) { // note: this can probably be shortened since the categories for the received files are already in the $dropbox_received_category array; + $dropbox_category_data = array(); + if ($category['received'] == '1') { + $movelist[$category['cat_id']] = $category['cat_name']; + $dropbox_category_data[] = $category['cat_id']; // this is where the checkbox icon for the files appear + // the icon of the category + $dropbox_category_data[] = build_document_icon_tag('folder', $category['cat_name']); + $dropbox_category_data[] = ''.Display::return_icon('folder_zip.gif', get_lang('Save'), array('width' => '16px', 'height' => '16px', 'style' => 'float:right;')).''.$category['cat_name'].''; + $dropbox_category_data[] = ''; + $dropbox_category_data[] = ''; + $dropbox_category_data[] = ''; + $dropbox_category_data[] = ''.Display::return_icon('edit.gif',get_lang('Edit')).' + '.Display::return_icon('delete.gif', get_lang('Delete')).''; + } + if (is_array($dropbox_category_data) && count($dropbox_category_data) > 0) { + $dropbox_data_recieved[] = $dropbox_category_data; + } } + } + // Displaying the table + $additional_get_parameters = array('view' => $_GET['view'], 'view_received_category' => $_GET['view_received_category'], 'view_sent_category' => $_GET['view_sent_category']); + $selectlist = array('delete_received' => get_lang('Delete'), 'download_received' => get_lang('Download')); + if (is_array($movelist)) { + foreach ($movelist as $catid => $catname){ + $selectlist['move_received_'.$catid] = get_lang('Move') . '->'. $catname; + } + } + if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { + $selectlist = array(); + } - $dropbox_file_data[]=build_document_icon_tag('file',$dropbox_file->title); - $dropbox_file_data[]=''.Display::return_icon('filesave.gif', get_lang('Download'), array('style'=>'float:right;')).''.$dropbox_file->title.''.$new_icon.'
'.$dropbox_file->description; - $dropbox_file_data[]=ceil(($dropbox_file->filesize)/1024).' '.get_lang('kB'); - $dropbox_file_data[]=$dropbox_file->author; - //$dropbox_file_data[]=$dropbox_file->description; - - $dropbox_file_data[]=date_to_str_ago(api_get_local_time($dropbox_file->last_upload_date, null, null, date_default_timezone_get())).'
'.api_get_local_time($dropbox_file->last_upload_date, null, null, date_default_timezone_get()).''; - - $action_icons=check_number_feedback($dropbox_file->id, $number_feedback).' '.get_lang('Feedback').' - '.Display::return_icon('comment_bubble.gif',get_lang('Comment')).' - '.Display::return_icon('deplacer_fichier.gif',get_lang('Move')).' - '.Display::return_icon('delete.gif',get_lang('Delete')).''; - //$action_icons=' '.Display::return_icon('deplacer.gif',get_lang('Move')).' - // '.Display::return_icon('delete.gif',get_lang('Delete')).''; - // this is a hack to have an additional row in a sortable table + Display::display_sortable_config_table($column_header, $dropbox_data_recieved, $sorting_options, $paging_options, $additional_get_parameters, $column_show, $column_order, $selectlist); + } - if ($_GET['action']=='viewfeedback' AND isset($_GET['id']) and is_numeric($_GET['id']) AND $dropbox_file->id==$_GET['id']) { - $action_icons.="\n"; // ending the normal row of the sortable table - $action_icons.='".get_lang('CloseFeedback')."".feedback($dropbox_file->feedback2)."\n\n"; - } - if (api_get_session_id()==0) - $dropbox_file_data[]=$action_icons; - elseif (api_is_allowed_to_session_edit(false,true)){ - $dropbox_file_data[]=$action_icons; - } - $action_icons=''; + /* + SENT FILES + */ - $dropbox_file_data[]=$dropbox_file->last_upload_date;//date + if (!$_GET['view'] OR $_GET['view'] == 'sent' OR !$dropbox_cnf['sent_received_tabs']) { + //echo '

'.get_lang('SentFiles').'

'; - $dropbox_data_recieved[]=$dropbox_file_data; + // This is for the categories + if (isset($_GET['view_sent_category']) AND $_GET['view_sent_category'] != '') { + $view_dropbox_category_sent = $_GET['view_sent_category']; + } else { + $view_dropbox_category_sent = 0; } - } + // object initialisation + $dropbox_person = new Dropbox_Person( $_user['user_id'], $is_courseAdmin, $is_courseTutor); + // constructing the array that contains the total number of feedback messages per document. + $number_feedback = get_total_number_feedback(); - // the content of the sortable table = the categories (if we are not in the root) - if ($view_dropbox_category_received==0) { - foreach ($dropbox_categories as $category) { // note: this can probably be shortened since the categories for the received files are already in the $dropbox_received_category array; - $dropbox_category_data=array(); - if ($category['received']=='1') { - $movelist[$category['cat_id']] = $category['cat_name']; - $dropbox_category_data[]=$category['cat_id']; // this is where the checkbox icon for the files appear - // the icon of the category - $dropbox_category_data[]=build_document_icon_tag('folder',$category['cat_name']); - $dropbox_category_data[]=''.Display::return_icon('folder_zip.gif',get_lang('Save'),array('width'=>'16px', 'height'=>'16px', 'style'=>'float:right;')).''.$category['cat_name'].''; - $dropbox_category_data[]=''; - $dropbox_category_data[]=''; - $dropbox_category_data[]=''; - $dropbox_category_data[]=''.Display::return_icon('edit.gif',get_lang('Edit')).' - '.Display::return_icon('delete.gif',get_lang('Delete')).''; - } - if (is_array($dropbox_category_data) && count($dropbox_category_data)>0) { - $dropbox_data_recieved[]=$dropbox_category_data; - } - } - } - // Displaying the table - $additional_get_parameters=array('view'=>$_GET['view'], 'view_received_category'=>$_GET['view_received_category'],'view_sent_category'=>$_GET['view_sent_category']); - $selectlist = array ('delete_received' => get_lang('Delete'),'download_received'=>get_lang('Download')); - if (is_array($movelist)) { - foreach ($movelist as $catid => $catname){ - $selectlist['move_received_'.$catid] = get_lang('Move') . '->'. $catname; - } - } - - if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) { - $selectlist=array(); - } - - Display::display_sortable_config_table($column_header, $dropbox_data_recieved, $sorting_options, $paging_options, $additional_get_parameters,$column_show,$column_order, $selectlist); -} + // sorting and paging options + $sorting_options = array(); + $paging_options = array(); + // the headers of the sortable tables + $column_header = array(); -/* ------------------------------------------------------------ - SENT FILES ------------------------------------------------------------ -*/ -if (!$_GET['view'] OR $_GET['view']=='sent' OR $dropbox_cnf['sent_received_tabs']==false) { - //echo '

'.get_lang('SentFiles').'

'; - - // This is for the categories - if (isset($_GET['view_sent_category']) AND $_GET['view_sent_category']<>'') { - $view_dropbox_category_sent=$_GET['view_sent_category']; - } else { - $view_dropbox_category_sent=0; - } + $column_header[] = array('', false, ''); + $column_header[] = array(get_lang('Type'), true, '', 'style="width:40px; text-align:center"'); + $column_header[] = array(get_lang('SentTitle'), true, ''); + $column_header[] = array(get_lang('Size'), true, ''); + $column_header[] = array(get_lang('SentTo'), true, ''); + $column_header[] = array(get_lang('LastResent'), true, ''); - // object initialisation - $dropbox_person = new Dropbox_Person( $_user['user_id'], $is_courseAdmin, $is_courseTutor); - - // constructing the array that contains the total number of feedback messages per document. - $number_feedback=get_total_number_feedback(); - - // sorting and paging options - $sorting_options = array(); - $paging_options = array(); - - // the headers of the sortable tables - $column_header=array(); - - $column_header[] = array('',false,''); - $column_header[] = array(get_lang('Type'),true,'style="width:40px"','style="text-align:center"'); - $column_header[] = array(get_lang('SentTitle'), TRUE, ''); - $column_header[] = array(get_lang('Size'), TRUE, ''); - $column_header[] = array(get_lang('SentTo'), TRUE, ''); - $column_header[] = array(get_lang('LastResent'), TRUE, ''); - - if (api_get_session_id()==0) - $column_header[] = array(get_lang('Modify'), FALSE, '', 'nowrap style="text-align: right"'); - elseif (api_is_allowed_to_session_edit(false,true)){ - $column_header[] = array(get_lang('Modify'), FALSE, '', 'nowrap style="text-align: right"'); - } - - - $column_header[] = array('RealDate', FALSE); - - $column_show=array(); - $column_order=array(); - - // An array with the setting of the columns -> 1: columns that we will show, 0:columns that will be hide - $column_show[]=1; - $column_show[]=1; - $column_show[]=1; - $column_show[]=1; - $column_show[]=1; - $column_show[]=1; - if (api_get_session_id()==0) - $column_show[]=1; - elseif (api_is_allowed_to_session_edit(false,true)){ - $column_show[]=1; - } - $column_show[]=0; - - // Here we change the way how the colums are going to be sort - // in this case the the column of LastResent ( 4th element in $column_header) we will be order like the column RealDate - // because in the column RealDate we have the days in a correct format "2008-03-12 10:35:48" - - $column_order[]=1; - $column_order[]=2; - $column_order[]=3; - $column_order[]=4; - $column_order[]=7; - $column_order[]=6; - $column_order[]=7; - $column_order[]=8; - - // the content of the sortable table = the received files - foreach ( $dropbox_person -> sentWork as $dropbox_file) { - $dropbox_file_data=array(); - - if ($view_dropbox_category_sent==$dropbox_file->category) { - $dropbox_file_data[]=$dropbox_file->id; - $dropbox_file_data[]=build_document_icon_tag('file',$dropbox_file->title); - $dropbox_file_data[]=''.Display::return_icon('filesave.gif',get_lang('Save'), array('style'=>'float:right;')).''.$dropbox_file->title.'
'.$dropbox_file->description; - $dropbox_file_data[]=ceil(($dropbox_file->filesize)/1024).' '.get_lang('kB'); - foreach ($dropbox_file->recipients as $recipient) { - $receivers_celldata=display_user_link_work($recipient['user_id'], $recipient['name']).', '.$receivers_celldata; - } - $receivers_celldata = trim(trim($receivers_celldata), ','); // Removing the trailing comma. - $dropbox_file_data[]=$receivers_celldata; - $dropbox_file_data[]=date_to_str_ago(api_get_local_time($dropbox_file->last_upload_date, null, null, date_default_timezone_get())).'
'.api_get_local_time($dropbox_file->last_upload_date, null, null, date_default_timezone_get()).''; - - //$dropbox_file_data[]=$dropbox_file->author; - $receivers_celldata=''; - $action_icons=check_number_feedback($dropbox_file->id, $number_feedback).' '.get_lang('Feedback').' - '.Display::return_icon('comment_bubble.gif',get_lang('Comment')).' - '.Display::return_icon('deplacer_fichier.gif',get_lang('Move')).' - '.Display::return_icon('delete.gif',get_lang('Delete')).''; - // this is a hack to have an additional row in a sortable table - if ($_GET['action']=='viewfeedback' AND isset($_GET['id']) and is_numeric($_GET['id']) AND $dropbox_file->id==$_GET['id']) { - $action_icons.="\n"; // ending the normal row of the sortable table - $action_icons.="\n\t".get_lang('CloseFeedback')."".feedback($dropbox_file->feedback2)."\n\n"; + if (api_get_session_id() == 0) { + $column_header[] = array(get_lang('Modify'), false, '', 'nowrap style="text-align: right"'); + } elseif (api_is_allowed_to_session_edit(false, true)) { + $column_header[] = array(get_lang('Modify'), false, '', 'nowrap style="text-align: right"'); + } + $column_header[] = array('RealDate', false); + + $column_show = array(); + $column_order = array(); + + // An array with the setting of the columns -> 1: columns that we will show, 0:columns that will be hide + $column_show[] = 1; + $column_show[] = 1; + $column_show[] = 1; + $column_show[] = 1; + $column_show[] = 1; + $column_show[] = 1; + if (api_get_session_id() == 0) { + $column_show[] = 1; + } elseif (api_is_allowed_to_session_edit(false, true)) { + $column_show[] = 1; + } + $column_show[] = 0; + + // Here we change the way how the colums are going to be sort + // in this case the the column of LastResent ( 4th element in $column_header) we will be order like the column RealDate + // because in the column RealDate we have the days in a correct format "2008-03-12 10:35:48" + + $column_order[] = 1; + $column_order[] = 2; + $column_order[] = 3; + $column_order[] = 4; + $column_order[] = 7; + $column_order[] = 6; + $column_order[] = 7; + $column_order[] = 8; + + // the content of the sortable table = the received files + foreach ($dropbox_person -> sentWork as $dropbox_file) { + $dropbox_file_data = array(); + + if ($view_dropbox_category_sent == $dropbox_file->category) { + $dropbox_file_data[] = $dropbox_file->id; + $dropbox_file_data[] = build_document_icon_tag('file', $dropbox_file->title); + $dropbox_file_data[] = ''.Display::return_icon('filesave.gif', get_lang('Save'), array('style' => 'float:right;')).''.$dropbox_file->title.'
'.$dropbox_file->description; + $dropbox_file_data[] = ceil(($dropbox_file->filesize)/1024).' '.get_lang('kB'); + foreach ($dropbox_file->recipients as $recipient) { + $receivers_celldata = display_user_link_work($recipient['user_id'], $recipient['name']).', '.$receivers_celldata; + } + $receivers_celldata = trim(trim($receivers_celldata), ','); // Removing the trailing comma. + $dropbox_file_data[] = $receivers_celldata; + $dropbox_file_data[] = date_to_str_ago(api_get_local_time($dropbox_file->last_upload_date, null, null, date_default_timezone_get())).'
'.api_get_local_time($dropbox_file->last_upload_date, null, null, date_default_timezone_get()).''; + + //$dropbox_file_data[] = $dropbox_file->author; + $receivers_celldata = ''; + $action_icons = check_number_feedback($dropbox_file->id, $number_feedback).' '.get_lang('Feedback').' + '.Display::return_icon('comment_bubble.gif', get_lang('Comment')).' + '.Display::return_icon('deplacer_fichier.gif', get_lang('Move')).' + '.Display::return_icon('delete.gif', get_lang('Delete')).''; + // this is a hack to have an additional row in a sortable table + if ($_GET['action'] == 'viewfeedback' AND isset($_GET['id']) and is_numeric($_GET['id']) AND $dropbox_file->id==$_GET['id']) { + $action_icons .= "\n"; // ending the normal row of the sortable table + $action_icons .= "\n\t".get_lang('CloseFeedback')."".feedback($dropbox_file->feedback2)."\n\n"; + } + $dropbox_file_data[] = $action_icons; + $dropbox_file_data[] = $dropbox_file->last_upload_date; + $action_icons = ''; + $dropbox_data_sent[] = $dropbox_file_data; } - $dropbox_file_data[]=$action_icons; - $dropbox_file_data[]=$dropbox_file->last_upload_date; - $action_icons=''; - $dropbox_data_sent[]=$dropbox_file_data; } - } - // the content of the sortable table = the categories (if we are not in the root) - if ($view_dropbox_category_sent==0) { - foreach ($dropbox_categories as $category) { - $dropbox_category_data=array(); - if ($category['sent']=='1') { - $dropbox_category_data[]=$category['cat_id']; // this is where the checkbox icon for the files appear - $dropbox_category_data[]=build_document_icon_tag('folder',$category['cat_name']); - $dropbox_category_data[]=''.Display::return_icon('folder_zip.gif',get_lang('Save'),array('width'=>'16px', 'height'=>'16px', 'style'=>'float:right;')).''.$category['cat_name'].''; - //$dropbox_category_data[]=''; - $dropbox_category_data[]=''; - //$dropbox_category_data[]=''; - $dropbox_category_data[]=''; - $dropbox_category_data[]=''; - $dropbox_category_data[]=''.Display::return_icon('edit.gif',get_lang('Edit')).' - '.Display::return_icon('delete.gif',get_lang('Delete')).''; - } - if (is_array($dropbox_category_data) && count($dropbox_category_data)>0) { - $dropbox_data_sent[]=$dropbox_category_data; + // the content of the sortable table = the categories (if we are not in the root) + if ($view_dropbox_category_sent == 0) { + foreach ($dropbox_categories as $category) { + $dropbox_category_data = array(); + if ($category['sent'] == '1') { + $dropbox_category_data[] = $category['cat_id']; // this is where the checkbox icon for the files appear + $dropbox_category_data[] = build_document_icon_tag('folder', $category['cat_name']); + $dropbox_category_data[] = ''.Display::return_icon('folder_zip.gif', get_lang('Save'), array('width' => '16px', 'height' => '16px', 'style' => 'float:right;')).''.$category['cat_name'].''; + //$dropbox_category_data[] = ''; + $dropbox_category_data[] = ''; + //$dropbox_category_data[] = ''; + $dropbox_category_data[] = ''; + $dropbox_category_data[] = ''; + $dropbox_category_data[] = ''.Display::return_icon('edit.gif', get_lang('Edit')).' + '.Display::return_icon('delete.gif', get_lang('Delete')).''; + } + if (is_array($dropbox_category_data) && count($dropbox_category_data) > 0) { + $dropbox_data_sent[] = $dropbox_category_data; + } } } + // Displaying the table + $additional_get_parameters = array('view' => Security::remove_XSS($_GET['view']), 'view_received_category' => Security::remove_XSS($_GET['view_received_category']), 'view_sent_category' => Security::remove_XSS($_GET['view_sent_category'])); + $selectlist = array('delete_received' => get_lang('Delete'), 'download_received' => get_lang('Download')); + if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { + $selectlist = array('download_received' => get_lang('Download')); + } + Display::display_sortable_config_table($column_header, $dropbox_data_sent, $sorting_options, $paging_options, $additional_get_parameters, $column_show, $column_order, $selectlist); } - // Displaying the table - $additional_get_parameters=array('view'=>Security::remove_XSS($_GET['view']), 'view_received_category'=>Security::remove_XSS($_GET['view_received_category']),'view_sent_category'=>Security::remove_XSS($_GET['view_sent_category'])); - $selectlist = array ('delete_received' => get_lang('Delete'),'download_received'=>get_lang('Download')); - if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) { - $selectlist = array ('download_received'=>get_lang('Download')); - } - Display::display_sortable_config_table($column_header, $dropbox_data_sent, $sorting_options, $paging_options, $additional_get_parameters,$column_show,$column_order, $selectlist); - } + } + Display::display_footer();