本文整理汇总了PHP中BaseActiveRecordVersioned::beforeValidate方法的典型用法代码示例。如果您正苦于以下问题:PHP BaseActiveRecordVersioned::beforeValidate方法的具体用法?PHP BaseActiveRecordVersioned::beforeValidate怎么用?PHP BaseActiveRecordVersioned::beforeValidate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseActiveRecordVersioned
的用法示例。
在下文中一共展示了BaseActiveRecordVersioned::beforeValidate方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeValidate
protected function beforeValidate()
{
if (!$this->isAllowed()) {
$this->addError('recipient_email', 'Recipient email is not in the list of allowed domains');
}
return parent::beforeValidate();
}
示例2: beforeValidate
protected function beforeValidate()
{
return parent::beforeValidate();
}
示例3: beforeValidate
public function beforeValidate()
{
if (!preg_match('/^[0-9a-f]{32}$/', $this->password)) {
if ($this->password != $this->password_repeat) {
$this->addError('password', 'Password confirmation must match exactly');
}
$this->salt = $this->randomSalt();
}
if ($this->getIsNewRecord() && !$this->password) {
$this->addError('password', 'Password is required');
}
return parent::beforeValidate();
}
示例4: beforeValidate
/**
* ensures that mimetype and size are set based on the file that's been stored (unless the file
* is being copied from elsewhere, in which case this should have been taken care of)
*
* (non-PHPdoc)
* @see BaseActiveRecord::beforeSave()
*/
public function beforeValidate()
{
if (!$this->_source_path) {
// the file should be in place
$path = $this->getPath();
if (!$this->mimetype) {
$this->mimetype = $this->lookupMimetype($path);
}
if (!$this->size) {
$this->size = filesize($path);
}
}
return parent::beforeValidate();
}
示例5: beforeValidate
public function beforeValidate()
{
$whereParams = array();
if ($this->id) {
$where = 'id != :id and ';
$whereParams[':id'] = $this->id;
} else {
$where = '';
}
if (!$this->subspecialty_id) {
$where .= ' subspecialty_id is null and ';
} else {
$where .= ' subspecialty_id = :subspecialty_id and ';
$whereParams[':subspecialty_id'] = $this->subspecialty_id;
}
if (!$this->episode_status_id) {
$where .= ' episode_status_id is null';
} else {
$where .= ' episode_status_id = :episode_status_id';
$whereParams[':episode_status_id'] = $this->episode_status_id;
}
if (self::model()->find($where, $whereParams)) {
//$this->addError('id','There is already a rule for this subspecialty and episode status combination');
}
return parent::beforeValidate();
}
示例6: beforeValidate
/**
* check the time entry is valid.
*
* @return bool
*/
public function beforeValidate()
{
if (!preg_match('/^(([01]?[0-9])|(2[0-3])):?[0-5][0-9]$/', $this->measurement_timestamp)) {
$this->addError('measurement_timestamp', 'Invalid ' . $this->getAttributeLabel('measurement_timestamp'));
}
return parent::beforeValidate();
}
示例7: beforeValidate
/**
* Checks made before the validation runs
*
* @return bool
*/
protected function beforeValidate()
{
if ($this->date && !preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/', $this->date)) {
$this->date = date('Y-m-d', strtotime($this->date));
}
// Ensure we are still compatible with any active bookings
$helper = $this->getHelper();
foreach ($this->activeBookings as $booking) {
foreach ($helper->checkSessionCompatibleWithOperation($this, $booking->operation) as $error) {
switch ($error) {
case $helper::ANAESTHETIST_REQUIRED:
$this->addError('anaesthetist', 'One or more active bookings require an anaesthetist');
break;
case $helper::CONSULTANT_REQUIRED:
$this->addError('consultant', 'One or more active bookings require a consultant');
break;
case $helper::PAEDIATRIC_SESSION_REQUIRED:
$this->addError('paediatric', 'One or more active bookings are for a child');
break;
case $helper::GENERAL_ANAESTHETIC_REQUIRED:
$this->addError('general_anaesthetic', 'One or more active bookings require general anaesthetic');
}
}
}
$this->validateNewSessionConflict();
return parent::beforeValidate();
}
示例8: beforeValidate
protected function beforeValidate()
{
if ($this->start_date && !preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/', $this->start_date)) {
$this->start_date = date('Y-m-d', strtotime($this->start_date));
}
if ($this->end_date && !preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/', $this->end_date)) {
$this->end_date = date('Y-m-d', strtotime($this->end_date));
}
// Verify that this session doesn't conflict with any other sequences or sessions
$criteria = new CDbCriteria();
if ($this->id) {
$criteria->addCondition('id <> :id');
$criteria->params[':id'] = $this->id;
}
$criteria->addCondition('theatre_id = :theatre_id');
$criteria->params[':theatre_id'] = $this->theatre_id;
$criteria->addCondition('weekday = :weekday');
$criteria->params[':weekday'] = $this->weekday;
$criteria->addCondition('end_date is null or end_date >= :start_date');
$criteria->params[':start_date'] = $this->start_date;
$dateList = $this->getDateListForMonths(12);
$conflicts = array();
foreach (self::model()->findAll($criteria) as $sequence) {
$s_dateList = $sequence->getDateListForMonths(12);
foreach ($s_dateList as $date) {
if (in_array($date, $dateList)) {
$start = strtotime("{$date} {$this->start_time}");
$end = strtotime("{$date} {$this->end_time}");
$s_start = strtotime("{$date} {$sequence->start_time}");
$s_end = strtotime("{$date} {$sequence->end_time}");
if ($start < $s_end && $start >= $s_start) {
if (!isset($conflicts[$sequence->id]['start_time'])) {
$this->addError('start_time', "This start time conflicts with sequence {$sequence->id}");
$conflicts[$sequence->id]['start_time'] = 1;
}
}
if ($end > $s_start && $end <= $s_end) {
if (!isset($conflicts[$sequence->id]['end_time'])) {
$this->addError('end_time', "This end time conflicts with sequence {$sequence->id}");
$conflicts[$sequence->id]['end_time'] = 1;
}
}
if ($start < $s_start && $end > $s_end) {
if (!isset($conflicts[$sequence->id]['end_time']) || !isset($conflicts[$sequence->id]['start_time'])) {
$this->addError('start_time', "This start time conflicts with sequence {$sequence->id}");
$conflicts[$sequence->id]['start_time'] = 1;
$this->addError('end_time', "This end time conflicts with sequence {$sequence->id}");
$conflicts[$sequence->id]['end_time'] = 1;
}
}
}
}
}
$criteria = new CDbCriteria();
$criteria->addCondition('sequence_id <> :sequence_id or sequence_id is null');
$criteria->params[':sequence_id'] = $this->id;
$criteria->addCondition('theatre_id = :theatre_id');
$criteria->params[':theatre_id'] = $this->theatre_id;
$criteria->addInCondition('date', $dateList);
$conflicts = array();
foreach (OphTrOperationbooking_Operation_Session::model()->findAll($criteria) as $session) {
$start = strtotime("{$session->date} {$this->start_time}");
$end = strtotime("{$session->date} {$this->end_time}");
$s_start = strtotime("{$session->date} {$session->start_time}");
$s_end = strtotime("{$session->date} {$session->end_time}");
if ($start < $s_end && $start >= $s_start) {
if (!isset($conflicts[$session->id]['start_time'])) {
$this->addError('start_time', "This start time conflicts with session {$session->id}");
$conflicts[$session->id]['start_time'] = 1;
}
}
if ($end > $s_start && $end <= $s_end) {
if (!isset($conflicts[$session->id]['end_time'])) {
$this->addError('end_time', "This end time conflicts with session {$session->id}");
$conflicts[$session->id]['end_time'] = 1;
}
}
if ($start < $s_start && $end > $s_end) {
if (!isset($conflicts[$session->id]['end_time']) || !isset($conflicts[$session->id]['start_time'])) {
$this->addError('start_time', "This start time conflicts with session {$session->id}");
$conflicts[$session->id]['start_time'] = 1;
$this->addError('end_time', "This end time conflicts with session {$session->id}");
$conflicts[$session->id]['end_time'] = 1;
}
}
}
return parent::beforeValidate();
}
示例9: beforeValidate
/**
* Ensure display_order is set.
*
* @return bool
*/
protected function beforeValidate()
{
if ($this->session && $this->isNewRecord) {
$this->display_order = $this->calculateDefaultDisplayOrder();
}
return parent::beforeValidate();
}
示例10: beforeValidate
public function beforeValidate()
{
if (!parent::beforeValidate()) {
return false;
}
//If someone is marked as dead by date, set the boolean flag.
if ($this->isAttributeDirty('date_of_death') && $this->date_of_death) {
$this->is_deceased = 1;
}
return true;
}