本文整理汇总了PHP中AppModel::beforeSave方法的典型用法代码示例。如果您正苦于以下问题:PHP AppModel::beforeSave方法的具体用法?PHP AppModel::beforeSave怎么用?PHP AppModel::beforeSave使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppModel
的用法示例。
在下文中一共展示了AppModel::beforeSave方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeSave
function beforeSave()
{
if (!$this->data['User']['keep_password']) {
$this->data['User']['password'] = sha1(Configure::read('Security.salt') . $this->data['User']['password']);
}
return parent::beforeSave();
}
示例2: 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;
}
示例3: beforeSave
function beforeSave()
{
if (empty($this->id)) {
$this->data['Gallery']['internal_id'] = md5(uniqid(rand(), true));
}
return parent::beforeSave();
}
示例4: 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);
}
示例5: beforeSave
/**
* 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();
}
示例6: beforeSave
public function beforeSave($options = array())
{
$result = parent::beforeSave($options);
$slug = Inflector::slug($this->data['Page']['title']);
$this->data['Page']['slug'] = $slug;
return $result;
}
示例7: beforeSave
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);
}
示例8: beforeSave
public function beforeSave($options = array())
{
if (isset($this->data[$this->alias]['joining_date'])) {
$this->data[$this->alias]['joining_date'] = time();
}
parent::beforeSave($options);
}
示例9: beforeSave
public function beforeSave($options = array())
{
if (!parent::beforeSave($options)) {
return false;
}
return $this->_processFile();
}
示例10: beforeSave
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;
}
示例11: beforeSave
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);
}
示例12: beforeSave
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);
}
示例13: beforeSave
public function beforeSave($options = array())
{
parent::beforeSave($options);
if (isset($this->data['User']['password'])) {
$this->data['User']['password'] = AuthComponent::password($this->data['User']['password']);
}
}
示例14: beforeSave
public function beforeSave()
{
if (empty($this->data['Subscription']['public'])) {
$this->data['Subscription']['public'] = false;
}
return parent::beforeSave();
}
示例15: 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;
}