Uploaded track media filenames should always be lowercase

This update makes sure that when the file is moved from the Filechucker upload folder to the admin transfer directory it converts the file to lowercase.  In the database at present the field 'Original_filename' will contain the original case and any sanitisation by Filechucker, meanwhile 'filename' contains the actual filename.

The code changes also move the logic of prefixing the filename to ensure 'uniqueness' to one location as the function 'moveFileChuckerUpload()' in folder.php also had the logic and it would have been easy to not realised it.

Signed-off-by: Ben Hawkridge <jamiedaniels123@gmail.com>
Fixed: Track title is determined from filename however 'periods' in filename would cut the title short

The fix in the code now uses 'pathinfo()' to get the whole filename, it then as an added bonus converts any underscores (_) to spaces to make the titles look a bit better.

An additional change is removing periods (.) from filenames except the one needed for the extension.

Signed-off-by: Ben Hawkridge <jamiedaniels123@gmail.com>
Tidy up on callback to make $commands array slightly more ledgible

Signed-off-by: Ben Hawkridge <jamiedaniels123@gmail.com>
added the new OU player to dev
Player.xml bug fix

Restored the use of $this->podcast_item_media_folder in player.xml code but with bug fix.

On surface $this->podcast_item_media_folder is not needed for player.xml while only been generated for default flavour.  However in case other flavours are supported in future I have included $this->podcast_item_media_folder (as before) except this time taking into account that $this->podcast_item_media_folder has a leading '/' which means even for the default flavour it consists of a '/'.

This meant in the case of the "oup:longlink" atom link we have to remove the '/' as the shortcode is added to the url without a trailing '/'.

Signed-off-by: Ben Hawkridge <jamiedaniels123@gmail.com>
Bug Fixed: duration was not been set in podcast_item record for default flavour

When the default flavour was been returned only the filename was been set not the duration.

This fix adds the duration returned by the transcoding cluster, in case it's changed compared to the originally uploaded file.

Signed-off-by: Ben Hawkridge <jamiedaniels123@gmail.com>
Added Duration column to the track list view

Added a duration column to the track list view, and a helper to format the duration (in seconds) to a modified SMPTE format.

Note, that we don't use PHP functions like date() as this take into account timezones and so will offset the time.  In theory gmdate() should work but current function is safer.

Signed-off-by: Ben Hawkridge <jamiedaniels123@gmail.com>
Small fix: added image and image-wm flavour support when displaying all the flavours.

Signed-off-by: Ben Hawkridge <jamiedaniels123@gmail.com>
Code layout tidy

Signed-off-by: Ben Hawkridge <jamiedaniels123@gmail.com>
Multiple CakePHP script executions caused by files missing

(solved by disabled loading of type.css (doesn't exist) and added missing filechucker .js files)

In my continuing adventures with CakePHP I discovered that it was loading the pages three time (sort of).  Technically what was happening is that the default bootstrapping for CakePHP was firing off because it was loading something in the page (css, js, image etc) that it thought was actually a request for CakePHP rather than just a 'file'.

This issue isn't unique to CakePHP but applies to any framework that uses mod_rewrite rules to turn the URL into something you parser to then execute commands.  The basic formula in the apache config or .htaccess file is...

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>

...the two lines...

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f

...essentially say, if there is NOT a real directory and there is NOT a real file then use the RewriteRule...

    RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

...which uses index.php in the web root and passes the current URL as a parameter.

The issue in our case was that two files...

type.css
/upload/js/js_table_sort.js

...didn't exist this then triggered the rewrite rules to pass the request via index.php, this then started up CakePHP executing various files until it eventually determined that it didn't know what to do with the request either and did nothing (404), meanwhile wasting resources.

There are some variations on the theme, for example this blog entry had problems with relative paths..

http://programming-perils.com/235/cakephp-script-keeps-executing-twice/
Signed-off-by: Ben Hawkridge <jamiedaniels123@gmail.com>
Session handling Changed - note core.php is now NOT ignored in GIT, this may affect deployment

As detailed on cakePHP web site at 'http://book.cakephp.org/1.3/en/view/1310/Sessions' I have added a custom implementation of the Session settings such that sessions are now destroyed when the browser closes.

Note that this required a change to 'app/config/core.php' which has previously been set to 'ignore' in GIT so this might have some impact from a deployment point of view.

For the dev version I've now set it to NOT be ignored.

Signed-off-by: Ben Hawkridge <jamiedaniels123@gmail.com>
(Soft) Deleting of tracks has now been fixed and some performance optimizations made

The (soft) delete method was not correctly (soft) deleting media files.  Soft deleting involves renaming the files so they are hidden (prefixed by period) and setting the 'delete' flag for the podcast_item track.

However the listAssociatedMedia() method was incorrectly assuming that each 'flavour' was in a sub-folder of that 'flavour' when the association is not that simply.  The actual association is defined in the $media_folder which was formerly in the feeds_controller but has now been moved the App_controller so it's available to all controllers.

In addition the updating of the RSS feeds has been moved to be outside the loop for (soft) deleting each track as it was generating far too many updates unnecessarily.  As a further optimisation if all the tracks were unpublished only the default flavour was refreshed as only player.xml actually needed updating.

NOTE: There are still a range of issues/todo's pending, however the primary concern is that poster images are not been (soft) deleted and there are possibly some issues with transcripts not been handled correctly.
Signed-off-by: Ben Hawkridge <jamiedaniels123@gmail.com>
Fixed issue with RSS files files been created for all flavours.

Fixed issue with RSS files files been created for all flavours, part of wider fixes related to flavours whereby Charles had assumed each flavour equally a separate directory and rss2.xml file.

Signed-off-by: Ben Hawkridge <jamiedaniels123@gmail.com>
Disabled sending of emails for callback alerts

If this is re-enabled then care needs to be made as to who receives the emails as at present they are bouncing from Charles and Ian's accounts.

In addition, in future this should only be enabled on the dev server.

Signed-off-by: Ben Hawkridge <jamiedaniels123@gmail.com>
Code tidy and other typo corrections

General code tidy, but also in places fixing references to iTunesU, with iTunes U (with the space between iTunes and the U)

Signed-off-by: Ben Hawkridge <jamiedaniels123@gmail.com>
CakePHP Sessions and SAMS (additional note about OUCU enforcement experiments)

Some changes to CakePHP Sessions such that they are now browser session based, this makes it easier to exit a session and helps ensure that the new session uses the current SAMS user, whereas before it would ignore it unless you actually destroyed the Session using the Podcast Logout.

Experimented with checked SAMS OUCU with Session OUCU however there are some issues when a user is in the server root, because the .htaccess mod_rewrite doesn't seem to correctly trigger the SAMS directive which only protects the index.php file, even though that file is loaded by Apache.  This failure at what might seem like random moments, would log the user out if we enforced the SAMS OUCU matching the Session OUCU

Signed-off-by: Ben Hawkridge <jamiedaniels123@gmail.com>
iTunes U private site user support

Adds support in various key places for exploiting the new iTunes U private site flag users can have enabled.  This allows for selective control over iTunes U metadata which would become confusing if shared with the iTunes U public site whereby the metadata requirements are much greater and mainly not relevant to the iTunes U private site.

Signed-off-by: Ben Hawkridge <jamiedaniels123@gmail.com>
Some array_push()'s disabled as was causing PHP warnings

Some array_push commands were generating warnings due to NULL source arrays, however the lines appear to be redundant as the following line of code appears to do the same job.  Disabling doesn't appear to have broken anything, though there is an issue with the iTunes U category arrays not saving, though it's not thought to be related to this section of code.

Signed-off-by: Ben Hawkridge <jamiedaniels123@gmail.com>
Workflow - aspect ratio logic changed slightly

Signed-off-by: Ben Hawkridge <jamiedaniels123@gmail.com>
$media_folder - revised comments

Additional comments in code to highlight that this code should really be changed so as to use the variables defined in app_model.

Signed-off-by: Ben Hawkridge <jamiedaniels123@gmail.com>