function exists($reset = false) { if (!empty($this->__exists) && $reset !== true) { return $this->__exists; } $conditions = array(); foreach ($this->primaryKeyArray as $pk) { if (isset($this->data[$this->alias][$pk]) && $this->data[$this->alias][$pk]) { $conditions[$this->alias . '.' . $pk] = $this->data[$this->alias][$pk]; } else { $conditions[$this->alias . '.' . $pk] = 0; } } $query = array('conditions' => $conditions, 'fields' => array($this->alias . '.' . $this->primaryKey), 'recursive' => -1, 'callbacks' => false); if (is_array($reset)) { $query = array_merge($query, $reset); } if ($exists = $this->find('first', $query)) { $this->__exists = 1; $this->id = $exists[$this->alias][$this->primaryKey]; return true; } else { return parent::exists($reset); } }
/** * Define Uploader Attachment configuration dynamically. * * @param bool $id * @param string $table * @param string $ds */ public function __construct($id = false, $table = null, $ds = null) { if (CakePlugin::loaded('Uploader')) { $transforms = array('path' => array('method' => 'exif', 'self' => true)) + Configure::read('Admin.uploads.transforms'); $this->actsAs['Uploader.Attachment'] = array('path' => array('nameCallback' => 'formatName', 'overwrite' => true, 'metaColumns' => array('size' => 'size', 'ext' => 'ext', 'type' => 'type', 'height' => 'height', 'width' => 'width'), 'transforms' => $transforms, 'transport' => Configure::read('Admin.uploads.transport'))); $this->actsAs['Uploader.FileValidation'] = array('path' => Configure::read('Admin.uploads.validation')); } else { $this->admin = false; } parent::__construct($id, $table, $ds); }