本文整理汇总了PHP中DBObject::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP DBObject::validate方法的具体用法?PHP DBObject::validate怎么用?PHP DBObject::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBObject
的用法示例。
在下文中一共展示了DBObject::validate方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
function validate($data, $action, $options = array())
{
$toret = true;
$data = parent::validate($data, $action, $options);
if ($data) {
$data['active'] = array_key_exists('active', $data) ? $data['active'] : 1;
}
return $toret ? $data : false;
}
示例2: validate
function validate($data, $action, $options = array())
{
$toret = false;
$data = parent::validate($data, $action, $options);
if ($data) {
$toret = true;
}
return $toret ? $data : false;
}
示例3: validate
function validate($data, $action, $options = array())
{
$toret = false;
$data = parent::validate($data, $action, $options);
if ($data) {
$toret = true;
if ($action == 'create') {
$data['active'] = array_key_exists('active', $data) && !is_null($data['active']) ? $data['active'] : 1;
}
}
return $toret ? $data : false;
}
示例4: validate
function validate($data, $action, $options = array())
{
$toret = true;
$data = parent::validate($data, $action, $options);
if ($data) {
if (preg_match(REGEX_LINKS, $data['content'])) {
$data['active'] = empty($data['active']) ? 0 : $data['active'];
} else {
$data['active'] = empty($data['active']) ? 1 : $data['active'];
}
}
return $toret ? $data : false;
}
示例5: validate
function validate($data, $action, $options = array())
{
$data = parent::validate($data, $action, $options);
if (!$data) {
return $data;
}
switch ($action) {
case 'create':
$data['active'] = array_key_exists('active', $data) ? $data['active'] : true;
//We need either an email, mobile number or username to register a user
//Lower ASCII only
if (!empty($data['username'])) {
$data['username'] = filter_var(trim($data['username']), FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH);
//TODO Make the banned usernames configurable
$banned_usernames = array('root', 'admin', 'superadmin', 'superuser', 'webadmin', 'postmaster', 'webdeveloper', 'webmaster', 'administrator', 'sysadmin');
if (in_array($data['username'], $banned_usernames) && BackendUser::hasSuperUser()) {
Backend::addError('Please choose a valid username');
return false;
}
}
if (empty($data['username']) && empty($data['email']) && empty($data['mobile'])) {
Backend::addError('Please provide a username');
}
//If the username is an email address, make it the email address
if (!empty($data['username']) && filter_var($data['username'], FILTER_VALIDATE_EMAIL)) {
if (!empty($data['email'])) {
list($data['username'], $data['email']) = array($data['email'], $data['username']);
} else {
$data['email'] = $data['username'];
unset($data['username']);
}
}
$data['salt'] = get_random('numeric');
$data['password'] = md5($data['salt'] . $data['password'] . Controller::$salt);
if (ConfigValue::get('application.confirmUser')) {
$data['confirmed'] = false;
} else {
$data['confirmed'] = array_key_exists('confirmed', $data) ? $data['confirmed'] : true;
}
break;
case 'update':
if (!empty($data['password'])) {
$data['password'] = md5($this->array['salt'] . $data['password'] . Controller::$salt);
}
break;
}
return $data;
}
示例6: validate
function validate($data, $action, $options = array())
{
$toret = false;
$data = parent::validate($data, $action, $options);
if ($data) {
if (empty($data['user_id']) && !empty($_SESSION['BackendUser']->id)) {
$data['user_id'] = $_SESSION['BackendUser']->id;
}
if (!isset($data['active'])) {
$data['active'] = 1;
}
$data['body'] = Markdown($data['markdown']);
$toret = true;
}
return $toret ? $data : false;
}
示例7: validate
function validate($data, $action, $options = array())
{
$toret = true;
$data = parent::validate($data, $action, $options);
if ($data) {
if (array_key_exists('type', $data)) {
if (!in_array($data['type'], BackendLock::$types)) {
Backend::addError('Invalid Lock Type');
$toret = false;
}
}
if (!empty($data['expire'])) {
if (strtotime($data['expire']) < time()) {
Backend::addError('Expiry date in the past');
$toret = false;
}
}
}
return $toret ? $data : false;
}