admin_fix.php

admin_fix.php

by Frank B -
Number of replies: 5

I recal their being a php script that would help you recover your admin priviledges if they were lost in an upgrade. Is that still available somewhere?

Average of ratings: -
In reply to Frank B

Re: admin_fix.php

by Frank B -

At http://tamingmoodle.blogspot.mx/2007/11/how-to-get-administrator-rights-back.html  I found the following script, however it doesn't work for me. It just says that role already exists.

Step by step approach:
1. Open your favourite text editor
2. Copy there this script

<?php

require 'config.php';

$systemcontext = get_context_instance(CONTEXT_SYSTEM);
$adminroleid = create_role('new admin6', 'admin6', 'delete me later', ' moodle/legacy:admin');
reset_role_capabilities($adminroleid);
$user = get_record('user', 'username', 'admin');
role_assign($adminroleid, $user->id, 0, $systemcontext->id);
echo 'done';
?>


3. Save it as createadmin.php
4.Upload this file to your moodle server to moodle directory, where the config.php is located
5.Set proper rights for this file to be accessible
6.Access this file with your browser with calling url http://yourmoodle.com/createadmin.php

In reply to Frank B

Re: admin_fix.php

by Frank B -

I finally found the adminfix.php but that did not help me. I even did a $CFG->defaultuserroleid = 1 ; in the config.php  and it did not help.

So my problem is not that I dont' have admin priviledges, it's just that the admin priviledges are worthless.

How do I reset roles?

In reply to Frank B

Re: admin_fix.php

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Sigh! - http://moodle.org/mod/forum/discuss.php?d=209636

Again, please avoid starting multiple threads or re-supply basic info if you do smile

When you say you have lost your admin rights what *exactly* are the symptoms? That script was written for people who had screwed up their roles system. Can you login yes/no? What happens then? Do you have Debugging on (again)?

In reply to Howard Miller

Re: admin_fix.php

by Doug Bott -

HI i have exactly the same problem ( I think). I am logged in as admin and checking every role assignemnt administrators list etc. tells me I am logged in as the current (and only) main admin. however, there are no "edit" links or icons whatsoever anywhere. There are also no admin blocks nor any what to add them. I can go to 

http://localhost/moodle/admin ( and the admin block appears only there but there is no way to edit its setting to check if it is supposed to appear elsewhere)

and to

http://localhost/moodle/admin/blocks (yes I can see there are supposed to be be settings and admin blocks)

Am am using Moodle 2.3 on a mac (development)

The trouble started after I installed a plug-in called Mass Action that did not work because all of the settings icons etc disappeared..

I tried the big fix but it is probably outdated, this is what I got: 

Coding error detected, it must be fixed 
by a programmer: Invalid call to role_assign(),
code needs to be updated to use new
order of parameters More information about this error Debug info: Error code: codingerror Stack trace: line 1586 of /lib/accesslib.php: coding_exception thrown line 36 of /adminfix.php: call to role_assign() Output buffer: <p>RESETING ADMIN ROLE</p>
<p>RELOADING CONTEXT</p>
<p>PRIMARY ADMIN IS 'admin', LOG IN WITH THIS</p>
<p>PRIMARY ADMIN ('admin') PASSWORD IS NOW 'moodle'</p>