本文整理汇总了PHP中Notifications::addValidationFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Notifications::addValidationFail方法的具体用法?PHP Notifications::addValidationFail怎么用?PHP Notifications::addValidationFail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Notifications
的用法示例。
在下文中一共展示了Notifications::addValidationFail方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createPage
function createPage($smarty)
{
if (Users::loggedIn()) {
Redirect::to('?page=profile');
}
if (Input::exists()) {
if (Input::get('action') === 'register') {
$validation = new Validate();
$validation->check($_POST, array_merge(Config::get('validation/register_info'), Config::get('validation/set_password')));
if ($validation->passed()) {
try {
Users::create(array('student_id' => Input::get('sid'), 'password' => Hash::hashPassword(Input::get('password')), 'permission_group' => 1, 'name' => Input::get('name'), 'email' => Input::get('email'), 'umail' => Input::get('sid') . '@umail.leidenuniv.nl', 'phone' => Phone::formatNumber(Input::get('phone')), 'joined' => DateFormat::sql()));
Users::login(Input::get('sid'), Input::get('password'));
Notifications::addSuccess('You have been succesfully registered!');
Redirect::to('?page=profile');
} catch (Exception $e) {
Notifications::addError($e->getMessage());
}
} else {
Notifications::addValidationFail($validation->getErrors());
}
}
if (Input::get('action') === 'login') {
$validation = new Validate();
$validation->check($_POST, Config::get('validation/login'));
if ($validation->passed()) {
$login = Users::login(Input::get('sid'), Input::get('password'), Input::getAsBool('remember'));
if ($login) {
Notifications::addSuccess('You have been logged in!');
Redirect::to('?page=profile');
} else {
Notifications::addValidationFail('Invalid student number or password.');
}
} else {
Notifications::addValidationFail($validation->getErrors());
}
}
}
$smarty->assign('remember', Input::getAsBool('remember'));
$smarty->assign('name', Input::get('name'));
$smarty->assign('sid', Input::get('sid'));
$smarty->assign('email', Input::get('email'));
$smarty->assign('phone', Input::get('phone'));
return $smarty;
}
示例2: createPage
function createPage($smarty)
{
if (!Users::loggedIn()) {
Redirect::to('?page=login');
}
if (Input::exists()) {
if (Input::get('action') === 'logout') {
if (Users::loggedIn()) {
Users::logout();
Notifications::addSuccess('You have been logged out!');
Redirect::to('?page=login');
}
}
if (Input::get('action') === 'update_info') {
$validation = new Validate();
$validation->check($_POST, Config::get('validation/user_info'));
if ($validation->passed()) {
$data = array('name' => Input::get('name'), 'student_id' => Input::get('sid'), 'email' => Input::get('email'), 'phone' => Phone::formatNumber(Input::get('phone')));
if (Users::currentUser()->update($data)) {
Notifications::addSuccess('User information updated!');
} else {
Notifications::addError('Could not update user information.');
}
} else {
Notifications::addValidationFail($validation->getErrors());
}
}
if (Input::get('action') === 'update_pass') {
$validation = new Validate();
$validation->check($_POST, array_merge(Config::get('validation/set_password'), array('password_current' => array('name' => 'Current Password', 'required' => true, 'max' => 72))));
if ($validation->passed()) {
if (Hash::checkPassword(Input::get('password_current'), Users::currentData()->password)) {
if (Users::currentUser()->update(array('password' => Hash::hashPassword(Input::get('password'))))) {
Notifications::addSuccess('Password changed!');
} else {
Notifications::addError('Could not change password.');
}
} else {
Notifications::addValidationFail('Invalid current password.');
}
} else {
Notifications::addValidationFail($validation->getErrors());
}
}
if (Input::get('action') === 'update_googleAuth') {
$validation = new Validate();
$validation->check($_POST, array('authcode' => array('name' => 'Authorisation Code', 'required' => true)));
if ($validation->passed()) {
if (Calendar::setCredentials(Input::get('authcode'))) {
Notifications::addSuccess('Google Calendar API authorized!');
} else {
Notifications::addValidationFail('Could not authorize Google Calendar API.');
}
} else {
Notifications::addValidationFail($validation->getErrors());
}
}
if (Input::get('action') === 'update_calendarAssignmentsId') {
$validation = new Validate();
$validation->check($_POST, array('calid-ass' => array('name' => 'Assignments Calendar ID', 'required' => false), 'calid-ex' => array('name' => 'Exams Calendar ID', 'required' => false)));
if ($validation->passed()) {
$data = array('calendar_assignments' => Input::get('calid-ass'), 'calendar_exams' => Input::get('calid-ex'));
if (Users::currentUser()->update($data)) {
Notifications::addSuccess('Calendar ID\'s updated!');
} else {
Notifications::addValidationFail('Could not update calendar ID\'s.');
}
} else {
Notifications::addValidationFail($validation->getErrors());
}
}
if (Input::get('action') === 'delete_googleAuth') {
Calendar::deleteCredentials();
}
if (Input::get('action') === 'update_calendarAssignments' && Users::isEditor()) {
$assignments = DB::instance()->get(Users::safeSid() . "_assignments")->results();
foreach ($assignments as $assignment) {
Calendar::updateAssignment($assignment->id);
}
}
if (Input::get('action') === 'create_database') {
if (!UserTables::hasTables()) {
UserTables::createTables();
if (Users::isGuest()) {
Users::currentUser()->update(array('permission_group' => '2'));
}
}
}
}
if (!Calendar::isReady()) {
$smarty->assign('authUrl', Calendar::getAuthUrl());
}
$smarty->assign('authCode', Input::get('authcode'));
$smarty->assign('calid_ass', Users::currentData()->calendar_assignments);
$smarty->assign('calid_ex', Users::currentData()->calendar_exams);
$smarty->assign('name', Users::currentData()->name);
$smarty->assign('sid', Users::currentData()->student_id);
$smarty->assign('email', Users::currentData()->email);
$smarty->assign('phone', Users::currentData()->phone);
return $smarty;
//.........这里部分代码省略.........
示例3: adminDeleteItem
public static function adminDeleteItem()
{
if (Users::isAdmin()) {
$validation = new Validate();
$validation->check($_POST, array('action' => array('name' => 'Action', 'required' => true, 'wildcard' => 'admin_item_delete'), 'table' => array('name' => 'Table Name', 'required' => true), 'id' => array('name' => 'Entry ID', 'required' => true)));
if ($validation->passed()) {
DB::instance()->delete(Input::get('table'), array("", "id", "=", Input::get('id')));
if (Input::get('table') === Users::safeSid() . '_assignments') {
Calendar::deleteAssignment(Input::get('id'));
}
Notifications::addSuccess('Entry deleted!');
Redirect::to('?page=home');
} else {
Notifications::addValidationFail($validation->getErrors());
}
} else {
Redirect::error(403);
}
}