How to disable a specific delete button in grocery_crud - codeigniter-3

In my user management page, I want to disable the delete button of my super admin account so that it can't be deleted. I used ion_auth for authentication and grocery_crud for my crud functions. How can I accomplish that? Any help? :)

i faced same problem and there is one quick that i know .
make superadmin userid 1 and in php part check if userid = 1 like this
$user_id = $this->ion_auth->user()->row()->id;
if($user_id == 1){
// this is superadmin do not delete
}else{
// your delete functions
}

Related

Perform extra validation after a Student signs into Moodle

I am hoping someone can point me in the right direction. We host a University Moodle site and we are looking for a way in which we can perform extra validation on a Student whenever they login. I will give a scenario.
We have an endpoint with a list of email addresses of students allowed to use the system, for example a list of Students who are fully paid up on tuition. Therefore, we are looking for a way to hook into the login process, perform this check and the allow the student to continue or redirect back to the login page with an error.
I would appreciate any advice on how we can achieve this. Thank you.
I found a solution to my problem. I ended up creating a custom Authentication plugin using the guidelines from https://docs.moodle.org/dev/Authentication_plugins. With that knowledge, I used the copied the folder in the Moodle installation path auth/none and used that as a shell for my new plugin. I went ahead and customized the plugin names to what I needed. Once that was done and once the plugin was installed and enabled from the Administrator Dashboard, I had something like this in my auth.php file:
// Required for all auth plugins
public function user_login($username, $password)
{
return false;
}
// Hooks in immediately after the User submits the login form
public function loginpage_hook()
{
$username = $_REQUEST['username'] ?? '';
/** CODE CHECKING IF USERNAME IS ALLOWED TO ACCESS MOODLE **/
/** FOR EXAMPLE CHECK IF USER PAID FEES **/
$userHasPaidFees = api_checks_if_user_paid_fees($username);
if ($userHasPaidFees ) {
// Returning true here proceeds with the
// normal Username/Password login combination
return true;
}
// If not, redirect them back to Login
// Or any other page and notify
redirect(
new moodle_url('/login/index.php'),
'Message telling user why they were not able to sign in',
null,
\core\output\notification::NOTIFY_ERROR
);
}
Thanks and I hope someone finds this useful.

Is there anyway to know when user is logged in to tumblr via javascript?

I am looking for ways to do this. API doesn't seem to be helping. I tried many ways without api too. I need to achieve this with javascript.
Does anyone know any kind of way to do this?
I have tried something like this:
How to detect if a tumblr user is logged in?
https://github.com/apandhi/Tumblr-Logged-In-Checker
which is without api. I can't find how to do this with api and I am not sure if it's even possible.
To update my comment.
If you run this code on your blog (or in the console)
document.cookie.indexOf('logged_in=1') != -1;
It returns true if user is logged in, or false if user is not logged in.
By this logic you can set this equal to a variable and run different functions depending on the value of the variable.
var user_logged_in = document.cookie.indexOf('logged_in=1') != -1;
if(user_logged_in) {
// insert code here for logged in users
}else{
// insert code here for non logged in users
}

App deauthorization: Is there any triggered event by which I can update fbsr cookie without reloading page?

My first post here ! :)
Situation:
User authorized the app and while using it, in the next tab he is removing app from settings page (app deauthorization).
Why:
I want authorize every function call through existing fbsr cookie where its existence is a proof of user login status.
Other solutions:
I can do it using signed request passed in every Canvas POST but I don't want to mix it :)
Before every each call I can refresh login status by FB.getLoginStatus() method
... check every user_id from sr with database entries (what anyway must be done), it's ok but not straight ;)
Just check me/permissions every time you want to verify your user...
FB.api('/me/permissions', function(response) {
var ra = response['data'][0];
pPublishStream = (ra['publish_stream'] == 1);
pCreateEvent = (ra['create_event'] == 1);
if (pPublishStream && pCreateEvent) {
// yay!!!
}
});
Edit: In retrospect, my answer above solves the issues you mentioned but also catches the case where the user removes individual permissions for the app. So maybe it's not exactly what you wanted.

Zend: Redirect to page after log in with a URL from email

I am using Zend and I have an email sent to all members which contains a link to a Post. Only members logged in can comment but all guest can see it. Of course whoever is clicking on the link in the email should be able to comment straight away.
For this reason what I would like to find out is a way to check if a member clicking on the link is logged in or not:-
if already logged in the URL in the email should take the member to the Post directly.
if not logged in forward the member to the log in page and then to the proper URL containined in the link.
I hope I explained myself. Please ask me if not. Could someone please advise the best way to do it?
Thank you. F.
Create a plugin and save the requested Uri in the session using:
$this->_session->lastUrl = $this->getRequest()->getRequestUri();
Then, after the user enters his credentials, redirect him to this saved URL.
Another option would be to save the url and add it as parameter to the next requests, like Google, Yahoo and SO do.
public function emailAction()
{
$loggedIn = Zend_Auth::getInstance()->getIdentity();
if($loggedIn)
{
$this->_helper->_forward('post);
}else {
$this->_helper->_forward('login');
}
}
public function loginAction()
{
$success = new Zend_Session_Namespace('success');
if(!isset($success->url))
{
$success->url = $this->view->serverUrl(true);
}
$form = new Login_Form();
if($this->getRequest()->isPost() && $form->isValid($_POST))
{
$this->_redirect($success->url);
}
}

Filter Friends that are Online FBML

Ok, I have this array of a users friends, and I'm just wondering how I can filter out the ones that are offline so that I only have the online ones in the array :D
Thanks
You don't need to do that, you just have to account for current logged in user whether it is you or anyone else and behind the scenes it will be however is logged in. You should simply make a check if a user is logged in (any user including friend):
if ($facebook->user > 0 && isset($facebook->user))
{
// your code here....
}
The code in the condition will run only if a user is logged in.