当前位置: 首页>>代码示例>>PHP>>正文


PHP AppModel::beforeSave方法代码示例

本文整理汇总了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();
 }
开发者ID:asadaqain,项目名称:Guide-on-the-Side,代码行数:7,代码来源:User.php

示例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;
 }
开发者ID:robertomendesgarcia,项目名称:prototipo,代码行数:7,代码来源:Noticia.php

示例3: beforeSave

 function beforeSave()
 {
     if (empty($this->id)) {
         $this->data['Gallery']['internal_id'] = md5(uniqid(rand(), true));
     }
     return parent::beforeSave();
 }
开发者ID:phototech,项目名称:sailvenice,代码行数:7,代码来源:gallery.php

示例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);
 }
开发者ID:sonnt1991,项目名称:Goikenban,代码行数:10,代码来源:AdvisorProfile.php

示例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();
 }
开发者ID:eecian,项目名称:Team08-iPeer,代码行数:38,代码来源:evaluation_base.php

示例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;
 }
开发者ID:predominant,项目名称:phpmatsuri-cms,代码行数:7,代码来源:page.php

示例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('&amp;bull;', '&bull;', '‧', '.', '•', '..'), '.', $this->data['Candidate']['name']);
     }
     return parent::beforeSave($options);
 }
开发者ID:parker00811,项目名称:elections,代码行数:26,代码来源:Candidate.php

示例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);
 }
开发者ID:ashutoshdev,项目名称:pickmeals-web,代码行数:7,代码来源:DeliveryBoy.php

示例9: beforeSave

 public function beforeSave($options = array())
 {
     if (!parent::beforeSave($options)) {
         return false;
     }
     return $this->_processFile();
 }
开发者ID:ashwiniks,项目名称:cookbookexp,代码行数:7,代码来源:Upload.php

示例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;
 }
开发者ID:alevilar,项目名称:gestionvilar,代码行数:29,代码来源:field_coordenate.php

示例11: beforeSave

 public function beforeSave($options = array())
 {
     if (isset($this->data['Keyword']['keyword'])) {
         $this->data['Keyword']['keyword'] = str_replace(array('&amp;bull;', '&bull;', '‧', '.', '•', '..'), '.', $this->data['Keyword']['keyword']);
     }
     return parent::beforeSave($options);
 }
开发者ID:parker00811,项目名称:elections,代码行数:7,代码来源:Keyword.php

示例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);
 }
开发者ID:boydepdai92,项目名称:blogPosts,代码行数:7,代码来源:User.php

示例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']);
     }
 }
开发者ID:jeraldluyas,项目名称:chatsystem2,代码行数:7,代码来源:User.php

示例14: beforeSave

 public function beforeSave()
 {
     if (empty($this->data['Subscription']['public'])) {
         $this->data['Subscription']['public'] = false;
     }
     return parent::beforeSave();
 }
开发者ID:kaz0636,项目名称:openflp,代码行数:7,代码来源:subscription.php

示例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;
 }
开发者ID:baserproject,项目名称:basercms,代码行数:31,代码来源:UploaderFile.php


注:本文中的AppModel::beforeSave方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。