fix file reordering

Fixes a regression from the files API

Test Plan:
 * Reorder some files in the files UI
 * It should work
 * Be sad that the files aren't in alphabetical order
 * Be sad that there aren't other filtering options in the files UI

closes #9576

Change-Id: I97f2d6b771e3bf94612c450aced265968bb4a509
Reviewed-on: https://gerrit.instructure.com/12429
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
avoid root attachment cycles when cloning attachments

fixes #9252

test plan: Set up a course A with at least one file. Clone course A to
make course B. Then copy course B back into course A. Also try copying a
course into itself. None of these actions should cause loading
/courses/A/files or /courses/B/files to break. You can also check the db
directly to verify that root_attachment_id doesn't equal id for any of
the rows.

Change-Id: Iee662358d8cc68f30ef7116cdb1bfa46eb99d996
Reviewed-on: https://gerrit.instructure.com/12061
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Mark Ericksen <marke@instructure.com>
Reviewed-by: Bracken Mosbacker <bracken@instructure.com>
restore sidebar link styles, fixes #9570

test plan:
1. go to the dashboard
2. you should see checkbox/calendar/etc. icons next to any "To Do" or
   "Coming Up" items

Change-Id: Id6ecc40ffb108a741a54f6cba24c12ec2c4fc27c
Reviewed-on: https://gerrit.instructure.com/12445
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Ryan Shaw <ryan@instructure.com>
fix another case of infinite root_attachment_id in course copying

A bug in the spec (b was never saved) was hiding another case where an
root_attachment_id loop could be created.

fixes #9252

test plan: Set up a course A with at least one file. Clone course A to
make course B. Then copy course B back into course A. Also try copying a
course into itself. None of these actions should cause loading
/courses/A/files or /courses/B/files to break. You can also check the db
directly to verify that root_attachment_id doesn't equal id for any of
the rows.

Change-Id: I114bc888067bf0308cc9c8a6a926438734f1e06f
Reviewed-on: https://gerrit.instructure.com/12450
Reviewed-by: Bracken Mosbacker <bracken@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
fix sis batch creation race condition

fixes #9610

test plan: since this is a race condition manual testing is difficult,
when uploading a lot of large sis batches none should fail to process
because of a nil attachment (and stickiness/batch mode settings should
always apply).

Change-Id: Iee9d1f48d8f9ab147409361ac19ccbca9df4fe97
Reviewed-on: https://gerrit.instructure.com/12478
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
correctly find quiz file references in webct data

This fixes two cases that were missed before. Sometimes the
webct relative resource id starts with a '/' and sometimes
not, this accounts for that.

Also, finding a file by a relative path was trying to find it
by the URI escaped version instead of the unescaped one. And
sometimes webct data has differently-cased file paths in the
QTI, so this tries finding files in all lower case.

Test Plan:
 * Import a webct course that has files in quizzes
 * All the images should import correctly into canvas. (meaning the url should be like /courses/:id/files/:id/preview)

closes #9520

Change-Id: I110c7f1968ae5a050fbd6b4e21332e8168481a15
Reviewed-on: https://gerrit.instructure.com/12474
Reviewed-by: Simon Williams <simon@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
add lengths to file/folder sorting indexes

So that MySQL can add the indexes

Change-Id: I32ad7185cdf5cfb7f59d76e734add95fcf545237
Reviewed-on: https://gerrit.instructure.com/12559
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Jon Jensen <jon@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
treesame commit of origin/stable/2012-07-21

Treesame-Commit-Id: 4d8d47f2d9c3b720595228bb1b7df73420ea33b1