This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Movie extends AppModel { | |
var $actsAs = array('Media.Transfer'); | |
var $validate = array( | |
'file' => array( | |
'resource' => array('rule' => 'checkResource'), | |
'access' => array('rule' => 'checkAccess'), | |
'location' => array('rule' => array('checkLocation', array(MEDIA_TRANSFER, '/tmp/'))), | |
'permission' => array('rule' => array('checkPermission', '*')), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Movie extends AppModel { | |
// ... | |
var $hasMany = array( | |
'Attachment' => array( | |
'className' => 'Media.Attachment', | |
'foreignKey' => 'foreign_key', | |
'conditions' => array('Attachment.model' => 'Movie'), | |
'dependent' => true, | |
)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Movie extends AppModel { | |
// ... | |
var $hasMany = array( | |
'Poster' => array( | |
'className' => 'Media.Attachment', | |
'foreignKey' => 'foreign_key', | |
'conditions' => array('Poster.model' => 'Movie', 'Poster.group' => 'poster'), | |
'dependent' => true, | |
), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CAKE_CORE_INCLUDE_PATH=/usr/local/share/cake-1.2.x.x | |
CAKE_CONSOLE=${CAKE_CORE_INCLUDE_PATH}/cake/console/cake | |
APP="/path/to/your/app" | |
MODELS="example attachments" # Models separated by one space | |
AUTO="-auto" # Enables automatic (destructive) repair! | |
if [ ! -x $CAKE_CONSOLE ] || [ ! -x $APP ]; then | |
exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Example extends MediaAppModel | |
// ... | |
var $validate = array( | |
// ... | |
'extension' => array('rule' => array('checkExtension', // order: deny, allow | |
array('bin', 'class', 'dll', 'dms', 'exe'), // blacklist | |
array('jpg', 'tmp') // whitelist | |
), | |
), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// app/models/example.php | |
class Example extends AppModel { | |
var $actsAs = array('Media.Transfer'); | |
} | |
// For single uploads | |
// app/controllers/examples_controller.php | |
class ExamplesController extends AppController { | |
function edit($id = null) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// app/controllers/movies_controller.php | |
class MoviesController extends AppController { | |
function edit($id = null) { | |
// ... | |
// $this->data = array( | |
// 'Movie' => array('title' => 'Vicky Cristina Barcelona'), | |
// 'Attachment' => array( | |
// 0 => array('file' => transferable item1, 'model' => 'Movie'), | |
// 1 => array('file' => transferable item2, 'model' => 'Movie'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Movie extends AppModel { | |
// ... | |
var $hasOne = array( | |
'Attachment' => array( | |
'className' => 'Media.Attachment', | |
'foreignKey' => 'foreign_key', | |
'conditions' => array('Attachment.model' => 'Movie'), | |
'dependent' => true, | |
)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Attachment extends AppModel { | |
// ... | |
function beforeMake($file, $process = array()) { | |
extract($process); | |
if ($this->alias == 'Avatar' && $version != 's') { | |
return true; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class MoviesController extends AppController { | |
function edit($id = null) { | |
/* For a single upload */ | |
$this->data = array( | |
'Movie' => array( | |
'file' => 'transferable item here' | |
)); | |
$this->Movie->save($this->data); |
OlderNewer