New Ubuntu installation: admin recognized as having administrator role but gets "Sorry, but you do not currently have permissions to do that ()"

New Ubuntu installation: admin recognized as having administrator role but gets "Sorry, but you do not currently have permissions to do that ()"

by David Benfell -
Number of replies: 6
Hello all,

Apparently various flavors of this problem are common enough, but I'm still having trouble. I installed moodle using a combination of the instructions on this site and the apparently new Ubuntu package.

The Ubuntu package did not include a number of steps that were included in the instructions here and did not require certain dependencies indicated here. But the set-up script succeeded with a little troubleshooting.

So moodle came up, but the admin user, while recognized as having an administrator role, did not have administrative functions. With help from a friend (who, unlike me, has some understanding of mysql) we managed to create a missing database table that appears to define which users have administrative functions. I can't find the name of that table right now, but it was something like user_admins.

My friend's efforts appear to have had no impact. How does one determine what is missing and how to replace it?

Thanks!
Average of ratings: -
In reply to David Benfell

Re: New Ubuntu installation: admin recognized as having administrator role but gets "Sorry, but you do not currently have permissions to do that ()"

by Richard Enison -
DB,

For starters, every version of Moodle uses a different set of tables, and you haven't said what version of Moodle you installed. But you can get a list of the tables used by Moodle core by looking at lib/db/install.xml under your main Moodle directory (folder). It's an xml file, which looks a lot like an html file with all the tags beginning < and ending >. Look for all the tags beginning <TABLE NAME=

Assuming you used the default table prefix of mdl_, and that you are using a relatively recent version of Moodle, so that it uses roles, the main tables involved with your problem I believe would be

mdl_user
mdl_role
mdl_role_allow_assign
mdl_role_allow_override
mdl_role_assignments
mdl_role_capabilities
mdl_role_names

RLE
In reply to Richard Enison

Re: New Ubuntu installation: admin recognized as having administrator role but gets "Sorry, but you do not currently have permissions to do that ()"

by David Benfell -
Hi Richard,

These are the tables I see:

<TABLE NAME="config" COMMENT="Moodle configuration variables" NEXT="config_plugins">
<TABLE NAME="config_plugins" COMMENT="Moodle modules and plugins configuration variables" PREVIOUS="config" NEXT="course">
<TABLE NAME="course" COMMENT="Central course table" PREVIOUS="config_plugins" NEXT="course_categories">
<TABLE NAME="course_categories" COMMENT="Course categories" PREVIOUS="course" NEXT="course_display">
<TABLE NAME="course_display" COMMENT="Stores info about how to display the course" PREVIOUS="course_categories" NEXT="course_meta">
<TABLE NAME="course_meta" COMMENT="to store meta-courses relations" PREVIOUS="course_display" NEXT="course_modules">
<TABLE NAME="course_modules" COMMENT="course_modules table retrofitted from MySQL" PREVIOUS="course_meta" NEXT="course_sections">
<TABLE NAME="course_sections" COMMENT="to define the sections for each course" PREVIOUS="course_modules" NEXT="course_request">
<TABLE NAME="course_request" COMMENT="course requests" PREVIOUS="course_sections" NEXT="course_allowed_modules">
<TABLE NAME="course_allowed_modules" COMMENT="allowed modules foreach course" PREVIOUS="course_request" NEXT="event">
<TABLE NAME="event" COMMENT="For everything with a time associated to it" PREVIOUS="course_allowed_modules" NEXT="cache_filters">
<TABLE NAME="cache_filters" COMMENT="For keeping information about cached data" PREVIOUS="event" NEXT="cache_text">
<TABLE NAME="cache_text" COMMENT="For storing temporary copies of processed texts" PREVIOUS="cache_filters" NEXT="grade_category">
<TABLE NAME="grade_category" COMMENT="to define categories to group activity grades" PREVIOUS="cache_text" NEXT="grade_exceptions">
<TABLE NAME="grade_exceptions" COMMENT="individual grades to be skipped for certain students" PREVIOUS="grade_category" NEXT="grade_item">
<TABLE NAME="grade_item" COMMENT="items to be graded" PREVIOUS="grade_exceptions" NEXT="grade_letter">
<TABLE NAME="grade_letter" COMMENT="to convert numerical grades to letter grades" PREVIOUS="grade_item" NEXT="grade_preferences">
<TABLE NAME="grade_preferences" COMMENT="Preferences of the gradebook for each course" PREVIOUS="grade_letter" NEXT="groups">
<TABLE NAME="groups" COMMENT="Each record is a group in a course" PREVIOUS="grade_preferences" NEXT="groups_members">
<TABLE NAME="groups_members" COMMENT="Lists memberships of users to groups" PREVIOUS="groups" NEXT="log">
<TABLE NAME="log" COMMENT="Every action is logged as far as possible" PREVIOUS="groups_members" NEXT="log_display">
<TABLE NAME="log_display" COMMENT="For a particular module/action, specifies a moodle table/field" PREVIOUS="log" NEXT="message">
<TABLE NAME="message" COMMENT="Stores all unread messages" PREVIOUS="log_display" NEXT="message_read">
<TABLE NAME="message_read" COMMENT="Stores all messages that have been read" PREVIOUS="message" NEXT="message_contacts">
<TABLE NAME="message_contacts" COMMENT="Maintains lists of relationships between users" PREVIOUS="message_read" NEXT="modules">
<TABLE NAME="modules" COMMENT="modules available in the site" PREVIOUS="message_contacts" NEXT="scale">
<TABLE NAME="scale" COMMENT="Defines grading scales" PREVIOUS="modules" NEXT="sessions2">
<TABLE NAME="sessions2" COMMENT="Optional database session storage in new format, not used by default" PREVIOUS="scale" NEXT="adodb_logsql">
<TABLE NAME="adodb_logsql" COMMENT="to save some logs from ADOdb" PREVIOUS="sessions2" NEXT="timezone">
<TABLE NAME="timezone" COMMENT="Rules for calculating local wall clock time for users" PREVIOUS="adodb_logsql" NEXT="user">
<TABLE NAME="user" COMMENT="One record for each person" PREVIOUS="timezone" NEXT="user_preferences">
<TABLE NAME="user_preferences" COMMENT="Allows modules to store arbitrary user preferences" PREVIOUS="user" NEXT="user_lastaccess">
<TABLE NAME="user_lastaccess" COMMENT="To keep track of course page access times, used in online participants block, and participants list" PREVIOUS="user_preferences" NEXT="stats_daily">
<TABLE NAME="stats_daily" COMMENT="to accumulate daily stats" PREVIOUS="user_lastaccess" NEXT="stats_weekly">
<TABLE NAME="stats_weekly" COMMENT="To accumulate weekly stats" PREVIOUS="stats_daily" NEXT="stats_monthly">
<TABLE NAME="stats_monthly" COMMENT="To accumulate monthly stats" PREVIOUS="stats_weekly" NEXT="stats_user_daily">
<TABLE NAME="stats_user_daily" COMMENT="To accumulate daily stats per course/user" PREVIOUS="stats_monthly" NEXT="stats_user_weekly">
<TABLE NAME="stats_user_weekly" COMMENT="To accumulate weekly stats per course/user" PREVIOUS="stats_user_daily" NEXT="stats_user_monthly">
<TABLE NAME="stats_user_monthly" COMMENT="To accumulate monthly stats per course/user" PREVIOUS="stats_user_weekly" NEXT="post">
<TABLE NAME="post" COMMENT="Generic post table to hold data blog entries etc in different modules" PREVIOUS="stats_user_monthly" NEXT="tags">
<TABLE NAME="tags" COMMENT="tags structure for moodle" PREVIOUS="post" NEXT="blog_tag_instance">
<TABLE NAME="blog_tag_instance" COMMENT="tag instance for blogs" PREVIOUS="tags" NEXT="role">
<TABLE NAME="role" COMMENT="moodle roles" PREVIOUS="blog_tag_instance" NEXT="context">
<TABLE NAME="context" COMMENT="one of these must be set" PREVIOUS="role" NEXT="capabilities">
<TABLE NAME="capabilities" COMMENT="this defines all capabilities" PREVIOUS="context" NEXT="role_allow_assign">
<TABLE NAME="role_allow_assign" COMMENT="this defines what role can assign what role" PREVIOUS="capabilities" NEXT="role_allow_override">
<TABLE NAME="role_allow_override" COMMENT="this defines what role can override what role" PREVIOUS="role_allow_assign" NEXT="role_assignments">
<TABLE NAME="role_assignments" COMMENT="assigning roles to different context" PREVIOUS="role_allow_override" NEXT="role_capabilities">
<TABLE NAME="role_capabilities" COMMENT="permission has to be signed, overriding a capability for a particular role in a particular context" PREVIOUS="role_assignments" NEXT="role_names">
<TABLE NAME="role_names" COMMENT="role names in native strings" PREVIOUS="role_capabilities" NEXT="user_info_field">
<TABLE NAME="user_info_field" COMMENT="Customisable user profile fields" PREVIOUS="role_names" NEXT="user_info_category">
<TABLE NAME="user_info_category" COMMENT="Customisable fields categories" PREVIOUS="user_info_field" NEXT="user_info_data">
<TABLE NAME="user_info_data" COMMENT="Data for the customisable user fields" PREVIOUS="user_info_category">

The Ubuntu package installs what appears to be a relatively old version--1.7.4.

This is what mysql tells me:

mysql> use moodle;
mysql> show tables;
Tables_in_moodle
adodb_logsql
mdl_assignment
mdl_assignment_submissions
mdl_backup_config
mdl_backup_courses
mdl_backup_files
mdl_backup_ids
mdl_backup_log
mdl_block
mdl_block_instance
mdl_block_pinned
mdl_block_rss_client
mdl_blog_tag_instance
mdl_cache_filters
mdl_cache_text
mdl_capabilities
mdl_chat
mdl_chat_messages
mdl_chat_users
mdl_choice
mdl_choice_answers
mdl_choice_options
mdl_config
mdl_config_plugins
mdl_context
mdl_course
mdl_course_allowed_modules
mdl_course_categories
mdl_course_display
mdl_course_meta
mdl_course_modules
mdl_course_request
mdl_course_sections
mdl_data
mdl_data_comments
mdl_data_content
mdl_data_fields
mdl_data_ratings
mdl_data_records
mdl_enrol_authorize
mdl_enrol_authorize_refunds
mdl_enrol_paypal
mdl_event
mdl_forum
mdl_forum_discussions
mdl_forum_posts
mdl_forum_queue
mdl_forum_ratings
mdl_forum_read
mdl_forum_subscriptions
mdl_forum_track_prefs
mdl_glossary
mdl_glossary_alias
mdl_glossary_categories
mdl_glossary_comments
mdl_glossary_entries
mdl_glossary_entries_categories
mdl_glossary_formats
mdl_glossary_ratings
mdl_grade_category
mdl_grade_exceptions
mdl_grade_item
mdl_grade_letter
mdl_grade_preferences
mdl_groups
mdl_groups_members
mdl_hotpot
mdl_hotpot_attempts
mdl_hotpot_details
mdl_hotpot_questions
mdl_hotpot_responses
mdl_hotpot_strings
mdl_journal
mdl_journal_entries
mdl_label
mdl_lams
mdl_lesson
mdl_lesson_answers
mdl_lesson_attempts
mdl_lesson_branch
mdl_lesson_default
mdl_lesson_grades
mdl_lesson_high_scores
mdl_lesson_pages
mdl_lesson_timer
mdl_log
mdl_log_display
mdl_message
mdl_message_contacts
mdl_message_read
mdl_modules
mdl_post
mdl_question
mdl_question_answers
mdl_question_attempts
mdl_question_calculated
mdl_question_categories
mdl_question_dataset_definitions
mdl_question_dataset_items
mdl_question_datasets
mdl_question_match
mdl_question_match_sub
mdl_question_multianswer
mdl_question_multichoice
mdl_question_numerical
mdl_question_numerical_units
mdl_question_randomsamatch
mdl_question_rqp
mdl_question_rqp_servers
mdl_question_rqp_states
mdl_question_rqp_types
mdl_question_sessions
mdl_question_shortanswer
mdl_question_states
mdl_question_truefalse
mdl_quiz
mdl_quiz_attempts
mdl_quiz_feedback
mdl_quiz_grades
mdl_quiz_question_instances
mdl_quiz_question_versions
mdl_resource
mdl_role
mdl_role_allow_assign
mdl_role_allow_override
mdl_role_assignments
mdl_role_capabilities
mdl_role_names
mdl_scale
mdl_scorm
mdl_scorm_scoes
mdl_scorm_scoes_track
mdl_sessions2
mdl_stats_daily
mdl_stats_monthly
mdl_stats_user_daily
mdl_stats_user_monthly
mdl_stats_user_weekly
mdl_stats_weekly
mdl_survey
mdl_survey_analysis
mdl_survey_answers
mdl_survey_questions
mdl_tags
mdl_timezone
mdl_user
mdl_user_admins
mdl_user_info_category
mdl_user_info_data
mdl_user_info_field
mdl_user_lastaccess
mdl_user_preferences
mdl_wiki
mdl_wiki_entries
mdl_wiki_locks
mdl_wiki_pages
mdl_workshop
mdl_workshop_assessments
mdl_workshop_comments
mdl_workshop_elements
mdl_workshop_grades
mdl_workshop_rubrics
mdl_workshop_stockcomments
mdl_workshop_submissions
mysql>

Now what?

Thanks!
In reply to David Benfell

Re: New Ubuntu installation: admin recognized as having administrator role but gets "Sorry, but you do not currently have permissions to do that ()"

by Richard Enison -
DB,

Sorry for the delay. So many posts in so many forums, so little time ...

Anyway, 1.7 I believe is the version of Moodle in which roles were introduced, which explains why you have all the role tables, as mentioned in my previous post. I have 1.8.3, and I don't have mdl_user_admins. Furthermore, this table does not appear to be mentioned in the list of TABLE tags in your post, so I'm guessing it is not used by Moodle 1.7.4; it might be a hold-over from a previous version. For now, let's ignore it.

Here are some previous posts on restoring the admin capabilities to the Admin user, using some of those tables (hope they apply to 1.7.4!):

http://moodle.org/mod/forum/discuss.php?d=66281 (complex)
http://moodle.org/mod/forum/discuss.php?d=82400#p364679 (mine, on role assignment)
http://moodle.org/mod/forum/discuss.php?d=85883#p380354 (mine, on role capabilities)

RLE
In reply to Richard Enison

Re: New Ubuntu installation: admin recognized as having administrator role but gets "Sorry, but you do not currently have permissions to do that ()"

by David Benfell -
Richard,

Thanks for responding. You wrote, in part....

<quote>
Here are some previous posts on restoring the admin capabilities to the Admin user, using some of those tables (hope they apply to 1.7.4!):

http://moodle.org/mod/forum/discuss.php?d=66281 (complex)
http://moodle.org/mod/forum/discuss.php?d=82400#p364679 (mine, on role assignment)
http://moodle.org/mod/forum/discuss.php?d=85883#p380354 (mine, on role capabilities)
</quote>

Okay, the PHP script in the first of these returned an error that sorry, there is already a role by that name. The second of these generated no error but appears to have had no impact (but thanks for the SQL command; I don't have PHPmyadmin or whatever it is either). And I don't know what to do with the third. All appear to apply to 1.8.
In reply to David Benfell

Re: New Ubuntu installation: admin recognized as having administrator role but gets "Sorry, but you do not currently have permissions to do that ()"

by Richard Enison -
DB,

OK, but there is more in those posts I linked to than scripts. And if by "I don't have PHPmyadmin or whatever it is either" you mean that you don't have any MySQL client program at all, I doubt that. There is a command-line client called simply mysql (as opposed to PHPmyadmin, which is GUI) that I believe comes with MySQL, along with a few other utilities. At least, it comes with the XAMPPlite download of Moodle that I have on my PC. I use it all the time. You can log into it using the same username and password that is in config.php. Also, several posts in the discussion the first link points to seem to confirm my hunch that the table mdl_user_admins was only used through Moodle 1.6; starting with 1.7, that functionality is in mdl_role_assignments.

Anyway, never mind the ad hoc PHP scripts. The point of the posts I linked to was to explain the structure of the role tables and how they are used to give the admin user(s) the capabilities they are supposed to have. What I would like you to do is use whatever MySQL client you have to look in your database and find out
  1. what id Admin has in your mdl_user table;
  2. what id admin has in your mdl_role table;
  3. what role(s) is/are assigned to your Admin id (from #1 above) in your mdl_role_assignments table.
When you have posted the answers to those questions, we can proceed from there.

BTW if you would prefer to use the GUI client PHPMyAdmin, there is a Moodle plugin that will let you run it under Moodle: http://moodle.org/mod/data/view.php?d=13&rid=448

RLE
In reply to Richard Enison

Re: New Ubuntu installation: admin recognized as having administrator role but gets "Sorry, but you do not currently have permissions to do that ()"

by David Benfell -
Hi Richard,

I'm new to mysql so I'm fumbling about here...

mysql> select * from mdl_user;
id auth confirmed policyagreed deleted username password idnumber firstname lastname email emailstop icq skype yahoo aim msn phone1 phone2 institution department address city country lang theme timezone firstaccess lastaccess lastlogin currentlogin lastip secret picture url description mailformat maildigest maildisplay htmleditor ajax autosubscribe trackforums timemodified trustbitmask
2 manual 1 0 0 admin e50081b0de0be206cd443d20094d3894 David Benfell benfell@parts-unknown.org 0 Los Gatos US en_utf8 -8.0 0 1204184646 1204184484 1204184644 134.154.208.37 mGWQeKte9B9zAvQ 0 Huh? 1 0 1 1 1 1 0
1203760967 0
mysql> select * from mdl_role;
id name shortname description sortorder
1 Administrator admin Administrators can usually do anything on the site, in all courses. 0
2 Course creator coursecreator Course creators can create new courses and teach in them. 1
3 Teacher editingteacher Teachers can do anything within a course, including changing the activities and grading students. 2
4 Non-editing teacher teacher Non-editing teachers can teach in courses and grade students, but may not alter activities. 3
5 Student student Students generally have less privileges within a course. 4
6 Guest guest Guests have minimal privileges and usually can not enter text anywhere. 5
7 new admin6 admin6 delete me later 6
mysql> select * from mdl_role_assignments;
id roleid contextid userid hidden timestart timeend timemodified modifierid enrol sortorder
1 1 2 2 0 0 0 1203760656 0 manual 0
mysql>

If I'm reading this right, admin has id 1 in mdl_user and in mdl_role, and id 1 has roleid 1 in mdl_role_assignments. If I'm understanding correctly how all this goes, that should be what I want, right?

Thanks!