function beforeSave() { if (!$this->data['User']['keep_password']) { $this->data['User']['password'] = sha1(Configure::read('Security.salt') . $this->data['User']['password']); } return parent::beforeSave(); }
public function beforeSave($options = array()) { parent::beforeSave(); $date = new DateTime(str_replace('/', '-', $this->data['Noticia']['data'])); $this->data['Noticia']['data'] = $date->format('Y-m-d H:i:s'); return true; }
function beforeSave() { if (empty($this->id)) { $this->data['Gallery']['internal_id'] = md5(uniqid(rand(), true)); } return parent::beforeSave(); }
/** * @author thientd */ public function beforeSave($options = array()) { if (isset($this->data[$this->name]['tel']) && is_array($this->data[$this->name]['tel'])) { $this->data[$this->name]['tel'] = implode('-', array_filter($this->data[$this->name]['tel'])); } return parent::beforeSave($options); }
/** * beforeSave * * * @access public * @return void */ function beforeSave() { // Ensure the name is not empty if (empty($this->data[$this->name]['name'])) { $this->errorMessage = "Please enter a new name for this " . $this->name . "."; return false; } // Remove any signle quotes in the name, so that custom SQL queries are not confused. $this->data[$this->name]['name'] = str_replace("'", "", $this->data[$this->name]['name']); //check the duplicate name // Removed for enhancement #516 - "Allow duplicate event title" /* if (empty($this->data[$this->name]['id']) && !$this->__checkDuplicateName()) { return false; } */ //check if questions are entered if (!empty($this->data['Question']) && $this->name == 'Mixeval') { foreach ($this->data['Question'] as $row) { if ($row['mixeval_question_type_id'] == '1' && (empty($row['Description']) || count($row['Description']) < 2)) { $this->errorMessage = "Please add at least two descriptors for each of the Lickert questions."; return false; } } } if (empty($this->data['Question']) && $this->name == 'Mixeval') { $this->errorMessage = "Please add at least one question for this mixed evaluation."; return false; } return parent::beforeSave(); }
public function beforeSave($options = array()) { $result = parent::beforeSave($options); $slug = Inflector::slug($this->data['Page']['title']); $this->data['Page']['slug'] = $slug; return $result; }
public function beforeSave($options = array()) { if (isset($this->data['Candidate']['image']) && is_array($this->data['Candidate']['image'])) { if (!empty($this->data['Candidate']['image']['size'])) { $im = new Imagick($this->data['Candidate']['image']['tmp_name']); $im->resizeImage(512, 512, Imagick::FILTER_CATROM, 1, true); $path = WWW_ROOT . 'media'; $fileName = str_replace('-', '/', String::uuid()) . '.jpg'; if (!file_exists($path . '/' . dirname($fileName))) { mkdir($path . '/' . dirname($fileName), 0777, true); } $im->writeImage($path . '/' . $fileName); if (file_exists($path . '/' . $fileName)) { $this->data['Candidate']['image'] = $fileName; } else { unset($this->data['Candidate']['image']); } } else { unset($this->data['Candidate']['image']); } } if (isset($this->data['Candidate']['name'])) { $this->data['Candidate']['name'] = str_replace(array('&bull;', '•', '‧', '.', '•', '..'), '.', $this->data['Candidate']['name']); } return parent::beforeSave($options); }
public function beforeSave($options = array()) { if (isset($this->data[$this->alias]['joining_date'])) { $this->data[$this->alias]['joining_date'] = time(); } parent::beforeSave($options); }
public function beforeSave($options = array()) { if (!parent::beforeSave($options)) { return false; } return $this->_processFile(); }
public function beforeSave($options = array()) { parent::beforeSave($options); /** * usa el this->data para llenar elcampo 'related_field_table * segun el character_type_id y el select del campo 'related_field_table_select */ if (empty($this->data['FieldCoordenate']['character_type'])) { $character_type = $this->field('character_type'); } else { $character_type = $this->data['FieldCoordenate']['character_type']; } if (empty($this->data['FieldCoordenate']['related_field_table_select'])) { $related_field_table_select = $this->field('related_field_table_select'); if (empty($related_field_table_select)) { return true; // guardar, pero no nodificar el campo related_field_table } } else { $related_field_table_select = $this->data['FieldCoordenate']['related_field_table_select']; } if (!empty($character_type)) { $character_type = $character_type . '_'; } if (empty($this->data['FieldCoordenate']['related_field_table'])) { $this->data['FieldCoordenate']['related_field_table'] = $character_type . $related_field_table_select; } return true; }
public function beforeSave($options = array()) { if (isset($this->data['Keyword']['keyword'])) { $this->data['Keyword']['keyword'] = str_replace(array('&bull;', '•', '‧', '.', '•', '..'), '.', $this->data['Keyword']['keyword']); } return parent::beforeSave($options); }
public function beforeSave($option = array()) { if (isset($this->data[$this->alias]['password'])) { $this->data[$this->alias]['password'] = AuthComponent::password($this->data[$this->alias]['password']); } return parent::beforeSave($option); }
public function beforeSave($options = array()) { parent::beforeSave($options); if (isset($this->data['User']['password'])) { $this->data['User']['password'] = AuthComponent::password($this->data['User']['password']); } }
public function beforeSave() { if (empty($this->data['Subscription']['public'])) { $this->data['Subscription']['public'] = false; } return parent::beforeSave(); }
public function beforeSave($options = array()) { parent::beforeSave($options); if (!empty($this->data['UploaderFile']['id'])) { $savePath = WWW_ROOT . 'files' . DS . $this->actsAs['BcUpload']['saveDir'] . DS; $sizes = array('large', 'midium', 'small', 'mobile_large', 'mobile_small'); $pathinfo = pathinfo($this->data['UploaderFile']['name']); if (!empty($this->data['UploaderFile']['publish_begin']) || !empty($this->data['UploaderFile']['publish_end'])) { if (file_exists($savePath . $this->data['UploaderFile']['name'])) { rename($savePath . $this->data['UploaderFile']['name'], $savePath . 'limited' . DS . $this->data['UploaderFile']['name']); } foreach ($sizes as $size) { $file = $pathinfo['filename'] . '__' . $size . '.' . $pathinfo['extension']; if (file_exists($savePath . $file)) { rename($savePath . $file, $savePath . 'limited' . DS . $file); } } } else { if (file_exists($savePath . 'limited' . DS . $this->data['UploaderFile']['name'])) { rename($savePath . 'limited' . DS . $this->data['UploaderFile']['name'], $savePath . $this->data['UploaderFile']['name']); } foreach ($sizes as $size) { $file = $pathinfo['filename'] . '__' . $size . '.' . $pathinfo['extension']; if (file_exists($savePath . 'limited' . DS . $file)) { rename($savePath . 'limited' . DS . $file, $savePath . $file); } } } } return true; }
public function beforeSave() { if (isset($this->Parent) && $this->Parent->exists()) { $this->parent_id = $this->Parent->id; } return parent::beforeSave(); }
public function beforeSave($options = array()) { if (isset($this->data['Point']['member_id']) && empty($this->data['Point']['member_id'])) { $this->data['Point']['member_id'] = '0'; } return parent::beforeSave($options); }
function beforeSave() { if (isset($this->data['Url']['address'])) { $this->data['Url']['title'] = empty($this->data['Url']['title']) ? $this->data['Url']['address'] : $this->data['Url']['title']; } return parent::beforeSave(); }
public function beforeSave($options = array()) { if (!parent::beforeSave($options)) { return false; } if (!empty($this->data[$this->alias]['situacao_desc'])) { $this->data[$this->alias]['situacao_desc'] = strip_tags($this->data[$this->alias]['situacao_desc']); } if (!empty($this->data[$this->alias]['resultado'])) { $this->data[$this->alias]['resultado'] = strip_tags($this->data[$this->alias]['resultado']); } if (!empty($this->data[$this->alias]['providencia'])) { $this->data[$this->alias]['providencia'] = strip_tags($this->data[$this->alias]['providencia']); } if (!empty($this->data[$this->alias]['restricao'])) { $this->data[$this->alias]['restricao'] = strip_tags($this->data[$this->alias]['restricao']); } if (!empty($this->data[$this->alias]['data_ultima_atualizacao'])) { $this->data[$this->alias]['data_ultima_atualizacao'] = Util::inverteData($this->data[$this->alias]['data_ultima_atualizacao']); } if (!empty($this->data[$this->alias]['data_ultima_revisao'])) { $this->data[$this->alias]['data_ultima_revisao'] = Util::inverteData($this->data[$this->alias]['data_ultima_revisao']); } return true; }
/** * Before save callback * * @return bool Success */ function beforeSave() { parent::beforeSave(); // Construct the absolute page URL if (isset($this->data[$this->name]['slug'])) { $level = 0; $homePageId = intval(Configure::read('Wildflower.settings.home_page_id')); if (intval($this->id) === $homePageId && $homePageId !== 0) { // Home page has the URL of root $this->data[$this->name]['url'] = '/'; } else { if (!isset($this->data[$this->name]['parent_id']) or !is_numeric($this->data[$this->name]['parent_id'])) { // Page has no parent $this->data[$this->name]['url'] = "/{$this->data[$this->name]['slug']}"; } else { $parentPage = $this->findById($this->data[$this->name]['parent_id'], array('url')); $url = "/{$this->data[$this->name]['slug']}"; if ($parentPage[$this->name]['url'] !== '/') { $url = $parentPage[$this->name]['url'] . $url; } $this->data[$this->name]['url'] = $url; } } } // Publish? if (isset($this->data[$this->name]['publish'])) { $this->data[$this->name]['draft'] = 0; unset($this->data[$this->name]['publish']); } return true; }
public function beforeSave($options = array()) { parent::beforeSave($options); if (empty($this->data['Pagina']['pin'])) { $this->data['Pagina']['pin'] = strtolower(UteisComponent::slug($this->data['Pagina']['titulo'])) . '_' . rand(1, 9999); } }
/** * beforeSave * * @return bool */ public function beforeSave() { if (!parent::beforeSave()) { return false; } return true; }
public function beforeSave($options = array()) { if (isset($this->data[$this->alias]['slug']) && empty($this->data[$this->alias]['slug'])) { $this->data[$this->alias]['slug'] = strtolower(Inflector::slug($this->data[$this->alias]['title'], '-')); } return parent::beforeSave($options); }
function beforeSave() { if (isset($this->data['Image']['tags'])) { $this->data['Image']['tags'] = $this->cleanTags($this->data['Image']['tags']); } return parent::beforeSave(); }
public function beforeSave($options = array()) { parent::beforeSave($options); //if(!isset($this->data[$this->alias]['timestamp'])){ $this->data[$this->alias]['timestamp'] = time(); //} }
public function beforeSave($options = array()) { Configure::write('debug', 2); App::uses("HtmlHelper", "View/Helper"); $html = new HtmlHelper(new View()); if ($this->data[$this->alias]['image']['name'] != "") { $ext = pathinfo($this->data[$this->alias]['image']['name'], PATHINFO_EXTENSION); $image_name = date('YmdHis') . rand(1, 999) . "." . $ext; $destination = "files/recipe_images/" . $image_name; if (move_uploaded_file($this->data[$this->alias]['image']['tmp_name'], $destination)) { $bowl = $this->createBowl($destination); $tmp = explode("/", $bowl); $destination2 = "files/recipe_images/" . $tmp[1]; //unlink($destination); rename($destination, $dt = "files/recipe_images/ori/" . $tmp[1]); rename($bowl, $destination2); } $this->data[$this->alias]['image'] = $html->url("/" . $dt, true); $this->data[$this->alias]['image_bowl'] = $html->url("/" . $destination2, true); } else { unset($this->data[$this->alias]['image']); } parent::beforeSave($options); return true; }
public function beforeSave() { parent::beforeSave(); if (!empty($this->data['User']['password'])) { $this->data['User']['password'] = AuthComponent::password($this->data['User']['password']); } return true; }
public function beforeSave($options = array()) { parent::beforeSave($options); if (!empty($this->data[$this->alias]['a_password'])) { $this->data[$this->alias]['a_password'] = AuthComponent::password($this->data[$this->alias]['a_password']); } return true; }
public function beforeSave($options = array()) { parent::beforeSave($options); $categoria_pai =& $this->data[$this->alias]['id_categoria_pai']; if (empty($categoria_pai)) { $categoria_pai = 0; } }
/** * Called before each save operation, after validation. * * @param array $options * @return boolean True if the operation should continue, false if it should abort */ public function beforeSave($options = array()) { parent::beforeSave($options); if (isset($this->targetType)) { $this->data[$this->alias]['type'] = $this->targetType; } return true; }