本文整理汇总了PHP中Sentry类的典型用法代码示例。如果您正苦于以下问题:PHP Sentry类的具体用法?PHP Sentry怎么用?PHP Sentry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Sentry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Check_User_Cart
function Check_User_Cart()
{
$Identifier = '';
if (!Sentry::check()) {
return false;
} else {
$Identifier = Sentry::user()->id;
if (Cookie::has('Anon_Cart_Extension')) {
$AnonIdentifier = Cookie::get('Anon_Cart_Extension');
$dataAnon = Cache::get('user_cart.' . $AnonIdentifier);
if (Cache::has('user_cart.' . $Identifier)) {
$dataUser = Cache::get('user_cart.' . $Identifier);
if ($dataAnon != null && $dataUser != null) {
foreach ($dataAnon as $key => $value) {
if (!isset($dataUser[$key])) {
$dataUser[$key] = $value;
}
}
Cache::forever('user_cart.' . $Identifier, $dataUser);
Cache::forget('user_cart.' . $AnonIdentifier);
}
} else {
if ($dataAnon != null) {
Cache::forever('user_cart.' . $Identifier, $dataAnon);
Cache::forget('user_cart.' . $AnonIdentifier);
}
}
}
}
}
示例2: run
public function run()
{
DB::table('users')->delete();
DB::table('groups')->delete();
DB::table('users_groups')->delete();
Sentry::getUserProvider()->create(array('email' => 'admin@admin.com', 'password' => "admin", 'first_name' => 'admin', 'last_name' => 'admin', 'activated' => 1));
Sentry::getGroupProvider()->create(array('name' => 'Super Admin', 'permissions' => array('admin' => 1)));
Sentry::getGroupProvider()->create(array('name' => 'Office Admin', 'permissions' => array('admin' => 1)));
Sentry::getGroupProvider()->create(array('name' => 'Project Manager', 'permissions' => array('admin' => 1)));
Sentry::getGroupProvider()->create(array('name' => 'Team Leader', 'permissions' => array('admin' => 1)));
Sentry::getGroupProvider()->create(array('name' => 'Developer', 'permissions' => array('admin' => 1)));
Sentry::getUserProvider()->create(array('email' => 'ashok@admin.com', 'password' => "admin", 'first_name' => 'Ashok', 'last_name' => 'Adhikari', 'activated' => 1));
Sentry::getUserProvider()->create(array('email' => 'santosh@admin.com', 'password' => "santosh", 'first_name' => 'Santosh', 'last_name' => 'Dhungana', 'activated' => 1));
Sentry::getUserProvider()->create(array('email' => 'dinesh@admin.com', 'password' => "dinesh", 'first_name' => 'Dinesh', 'last_name' => 'Sharma', 'activated' => 1));
Sentry::getUserProvider()->create(array('email' => 'asheem@admin.com', 'password' => "asheem", 'first_name' => 'Asheem', 'last_name' => 'Manandhar', 'activated' => 1));
// Assign user permissions
$adminUser = Sentry::getUserProvider()->findByLogin('admin@admin.com');
$adminGroup = Sentry::getGroupProvider()->findByName('Super Admin');
$adminUser->addGroup($adminGroup);
$adminUser = Sentry::getUserProvider()->findByLogin('ashok@admin.com');
$adminGroup = Sentry::getGroupProvider()->findByName('Office Admin');
$adminUser->addGroup($adminGroup);
$adminUser = Sentry::getUserProvider()->findByLogin('santosh@admin.com');
$adminGroup = Sentry::getGroupProvider()->findByName('Project Manager');
$adminUser->addGroup($adminGroup);
$adminUser = Sentry::getUserProvider()->findByLogin('dinesh@admin.com');
$adminGroup = Sentry::getGroupProvider()->findByName('Team Leader');
$adminUser->addGroup($adminGroup);
$adminUser = Sentry::getUserProvider()->findByLogin('asheem@admin.com');
$adminGroup = Sentry::getGroupProvider()->findByName('Developer');
$adminUser->addGroup($adminGroup);
}
示例3: assessmentupdateget
public function assessmentupdateget($dash, $id)
{
$assessment = Assessments::find($id);
$user = User::find($assessment->teacherid);
if (Sentry::getUser()->id == $user->id) {
$theme = Theme::uses('dashboard')->layout('default');
$view = array('name' => 'Dashboard Assessment Update', 'id' => $id);
$theme->breadcrumb()->add([['label' => 'Dashboard', 'url' => Setting::get('system.dashurl')], ['label' => 'Assessments', 'url' => Setting::get('system.dashurl') . '/assessments'], ['label' => $id, 'url' => Setting::get('system.dashurl') . '/assessment/' . $id]]);
$theme->appendTitle(' - Assessment Update');
$theme->asset()->container('datatable')->writeScript('inline-script', '$(document).ready(function(){
$(\'#attachments\').dataTable({
"sDom": "<\'row\'<\'col-xs-5 col-sm-5 col-md-5\'l><\'col-xs-5 col-sm-5 col-md-5\'f>r>t<\'row\'<\'col-xs-5 col-sm-5 col-md-5\'i><\'col-xs-5 col-sm-5 col-md-5\'p>>",
"oLanguage": {
"sLengthMenu": "_MENU_ ' . ' Attachments per page"
},
"sPagination":"bootstrap"
});
});$(document).ready(function(){
$(\'#questionfail\').dataTable({
"sDom": "<\'row\'<\'col-xs-5 col-sm-5 col-md-5\'l><\'col-xs-5 col-sm-5 col-md-5\'f>r>t<\'row\'<\'col-xs-5 col-sm-5 col-md-5\'i><\'col-xs-5 col-sm-5 col-md-5\'p>>",
"oLanguage": {
"sLengthMenu": "_MENU_ ' . ' Failures per page"
},
"sPagination":"bootstrap"
});
});');
$theme->asset()->container('footer')->writeScript('inline-script', '$(document).ready(function(){
$("#examsheader").hide();
$("div#exams").hide();
$("div#examslock").hide();
$(".hidequestions").hide();
$(".hidequestions").click(function(){
$("div#exams").hide(2000);
$(\'html, body\').animate({
scrollTop: $("#top").offset().top
}, 2000);
$("#examsheader").hide(1200);
$("#examslock").hide(1200);
$(".hidequestions").hide(1000);
$("#showquestions").show(1000);
});
$("#showquestions").click(function(){
$("div#exams").show(2000);
$("div#examslock").show(100);
$(\'html, body\').animate({
scrollTop: $("#examslock").offset().top
}, 2000);
$("#examsheader").show(1000);
$(".hidequestions").show(1000);
$("#showquestions").hide(1000);
});
});');
return $theme->scope('assessment.update', $view)->render();
// return View::make('dashboard.assessments.update')->with('id',$id);
} else {
return "UPDATE NOT AUTHORISED";
}
}
示例4: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('groups')->delete();
Sentry::getGroupProvider()->create(array('name' => 'Users', 'permissions' => array('admin.users' => 0, 'user.interface' => 1)));
Sentry::getGroupProvider()->create(array('name' => 'Admins', 'permissions' => array('admin.users' => 1, 'user.interface' => 1)));
Sentry::getGroupProvider()->create(array('name' => 'EmfUsers', 'permissions' => array('admin.users' => 0, 'user.interface' => 1, 'emf.login' => 1)));
}
示例5: canEdit
public static function canEdit($id)
{
if (Sentry::check() && (Sentry::getUser()->id == $id || Sentry::getUser()->isSuperUser())) {
return true;
}
return false;
}
示例6: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('groups')->delete();
Sentry::getGroupProvider()->create(array('name' => 'Users'));
Sentry::getGroupProvider()->create(array('name' => 'Admins'));
Sentry::getGroupProvider()->create(array('name' => 'Subscribers'));
}
示例7: insert_users
protected function insert_users()
{
for ($i = 0; $i != 20; ++$i) {
$password = $this->get_random(self::$RANDOM_ALPHA_NUM, 6, 16);
Sentry::createUser(['password' => $password, 'nickname' => $this->get_random(self::$RANDOM_ALPHA, 4, 12), 'real_name' => $this->get_random(self::$RANDOM_ALPHA, 4, 12), 'phone' => rand(0, count(self::$TELEPHONE_PREFIX)) + $this->get_random(self::$RANDOM_NUM, 8, 8), 'account' => $this->get_random(self::$RANDOM_ALPHA_NUM, 6, 16), 'role' => 1, 'gender' => rand(0, 1), 'activated' => 1]);
}
}
示例8: getProdlist
public function getProdlist()
{
$user = Sentry::getUser()->id;
// $content = View::make('backend.widgets.prodlist');
// return View::make('backend.general', compact('content'));
return View::make('backend.widgets.prodlist');
}
示例9: pushMessage
public function pushMessage()
{
if (!Sentry::check()) {
return Response::json(array('errCode' => 10, 'message' => '请登录'));
}
Sentry::login(Sentry::findUserById(5), false);
$user = Sentry::getUser();
// $user = User::find(1);
$push_status = PushStatus::where('user_id', $user->id)->first();
if (count($push_status) == 0) {
$push_status = new PushStatus();
$push_status->user_id = $user->id;
$push_status->status = 1;
if (!$push_status->save()) {
return Response::json(array('errCode' => 1, 'message' => '[数据库错误]开启消息推送失败'));
}
return Response::json(array('errCode' => 0, 'message' => '开启消息推送'));
}
if ($push_status->status == 1) {
$push_status->status = 0;
if (!$push_status->save()) {
return Response::json(array('errCode' => 2, 'message' => '[数据库错误]开启消息推送失败'));
}
return Response::json(array('errCode' => 0, 'message' => '开启消息推送'));
}
if ($push_status->status == 0) {
$push_status->status = 1;
if (!$push_status->save()) {
return Response::json(array('errCode' => 3, 'message' => '[数据库错误]开启消息推送失败'));
}
return Response::json(array('errCode' => 0, 'message' => '开启消息推送'));
}
}
示例10: update_post
public function update_post($id)
{
$this->_exists($id);
$rules = User::get_rules($id);
$validator = Validator::make(Input::all(), $rules);
if ($validator->passes()) {
// Find the user using the user id
$user = Sentry::findUserById($id);
$user->first_name = Input::get('first_name');
$user->last_name = Input::get('last_name');
$user->tin_number = Input::get('tin_number');
$user->landline = Input::get('landline');
$user->mobile = Input::get('mobile');
$user->work_address = json_endcode(explode(",", Input::get('work_address')));
$user->home_address = json_endcode(explode(",", Input::get('home_address')));
$user->company = Input::get('company');
$user->occupation = Input::get('occupation');
$user->email = Input::get('email');
if (Input::get('password')) {
$user->password = Input::get('password');
}
if (Input::get('activated') == 1) {
$user->activated = true;
} else {
$user->activated = false;
}
$user->save();
return Redirect::to('admin/clients')->with('success', 'Client account has been successfully updated.');
}
return Redirect::to('admin/clients/update/' . $id)->withErrors($validator)->withInput();
}
示例11: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (\Sentry::check()) {
return new RedirectResponse(url('/'));
}
return $next($request);
}
示例12: postRegistro
public function postRegistro()
{
$input = Input::all();
$reglas = array('nombre' => 'required', 'apellido' => 'required', 'celular' => 'required|numeric|unique:users', 'cedula' => 'required|numeric|unique:users', 'email' => 'required|email|unique:users', 'pin' => 'required|numeric|digits_between:0,4', 'password' => 'required|numbers|case_diff|letters|min:6|confirmed', 'password_confirmation' => 'required|min:6');
$validation = Validator::make($input, $reglas);
if ($validation->fails()) {
return Response::json(['success' => false, 'errors' => $validation->errors()->toArray()]);
}
try {
// se guarda los datos del usuario
$user = Sentry::register(array('first_name' => Input::get('nombre'), 'last_name' => Input::get('apellido'), 'email' => Input::get('email'), 'habilitar_pin' => 1, 'celular' => Input::get('celular'), 'cedula' => Input::get('cedula'), 'password' => Input::get('password'), 'pin' => Input::get('pin'), 'porcentaje' => 0.05, 'activated' => true));
$userId = $user->getId();
$token = new Token();
$token->user_id = $userId;
$token->api_token = hash('sha256', Str::random(10), false);
$token->client = BrowserDetect::toString();
$token->expires_on = Carbon::now()->addMonth()->toDateTimeString();
$token->save();
// Se autentica de una
$user_login = Sentry::findUserById($userId);
Sentry::login($user_login, false);
return Response::json(['success' => true, 'user' => $user_login, 'token' => $token->api_token]);
} catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
$error = array('usuario' => 'Email es requerido');
} catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
$error = array('usuario' => 'Password es requerido');
} catch (Cartalyst\Sentry\Users\UserExistsException $e) {
$error = array('usuario' => 'El Email ya está registrado');
}
return Response::json(['success' => false, 'errors' => $error]);
}
示例13: postCreate
/**
* Blog post create form processing.
*
* @return Redirect
*/
public function postCreate()
{
// Declare the rules for the form validation
$rules = array('title' => 'required|min:3', 'content' => 'required|min:3');
// Validate the inputs
$validator = Validator::make(Input::all(), $rules);
// Check if the form validates with success
if ($validator->passes()) {
// Create a new blog post
$post = new Post();
// Update the blog post data
$post->title = Input::get('title');
$post->slug = convert_to_slug(Input::get('title'));
$post->content = Input::get('content');
$post->meta_title = Input::get('meta-title');
$post->meta_description = Input::get('meta-description');
$post->meta_keywords = Input::get('meta-keywords');
$post->user_id = Sentry::getId();
// Was the blog post created?
if ($post->save()) {
// Redirect to the new blog post page
return Redirect::to('admin/blogs/' . $post->id . '/edit')->with('success', Lang::get('admin/blogs/messages.create.success'));
}
// Redirect to the blog post create page
return Redirect::to('admin/blogs/create')->with('error', Lang::get('admin/blogs/messages.create.error'));
}
// Form validation failed
return Redirect::to('admin/blogs/create')->withInput()->withErrors($validator);
}
示例14: resetAction
public function resetAction()
{
// Fetch all request data.
$data = Input::only('email', 'password', 'password_confirmation', 'pass_code');
// Build the validation constraint set.
$rules = array('email' => array('required'), 'password' => array('required', 'confirmed', 'min:5'));
$validator = Validator::make($data, $rules);
if ($validator->passes()) {
$user = Sentry::findUserByLogin(Input::get('email'));
// Check if the reset password code is valid
if ($user->checkResetPasswordCode(Input::get('pass_code'))) {
// Attempt to reset the user password
if ($user->attemptResetPassword(Input::get('pass_code'), Input::get('password'))) {
$user->reset_password_code = '';
$user->save();
return Redirect::to('/login')->with('global_success', 'Password has been set. You can now sign in with your new password.');
} else {
return Redirect::to('/reset')->with('global_error', 'System couldn\'t change your password. Please try again and if situation repeats, report to support.');
}
} else {
return Redirect::to('/request')->with('global_error', 'Your reset code doesn\'t match. It may be corrupted or outdated. Please make a new request.');
}
}
return Redirect::to('/reset/' . Input::get('pass_code'))->withErrors($validator)->with('message', 'Validation Errors!');
}
示例15: __construct
public function __construct()
{
if (Sentry::check()) {
// User is not logged in, or is not activated
$this->data['admin'] = Sentry::getUser();
}
}