Skip to content

Commit

Permalink
Fix notice/warning for file-less items. Fix #470.
Browse files Browse the repository at this point in the history
  • Loading branch information
zerocrates committed Jan 24, 2013
1 parent 5d52dab commit f5e5fbe
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions application/models/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,17 +178,18 @@ protected function afterSave($args)
$post = $args['post'];

// Update file order for this item.
foreach ($post['order'] as $fileId => $fileOrder) {

// File order must be an integer or NULL.
$fileOrder = (int) $fileOrder;
if (!$fileOrder) {
$fileOrder = null;
if (isset($post['order'])) {
foreach ($post['order'] as $fileId => $fileOrder) {
// File order must be an integer or NULL.
$fileOrder = (int) $fileOrder;
if (!$fileOrder) {
$fileOrder = null;
}

$file = $this->getTable('File')->find($fileId);
$file->order = $fileOrder;
$file->save();
}

$file = $this->getTable('File')->find($fileId);
$file->order = $fileOrder;
$file->save();
}

// Delete files that have been designated by passing an array of IDs
Expand Down

0 comments on commit f5e5fbe

Please sign in to comment.