For a while now, we have been using an alternative interface to the elgg database, using the django framework (written in Python), which we would like to share. Django makes it easy to create an administrative view of a database, with basic CRUD functionality.The other great advantage is that you can write Python scripts to interact with your database, which is especially useful for the SQL-challenged like me.
Disclaimer: if you use this, be careful, since you are interacting directly with your elgg database. Data may be lost, corrupted, etc. I have used it for some months now, without any problems, but there may be programming mistakes or different assumptions about the database than elgg makes. If you only use it to read the DB, the risks are lower. But anyway, make a backup of your DB before experimenting with this.
You can browse the code here and check it out with svn co http://pccepa3.if.usp.br/svn/trunk/admintools . Note that the file elgg/models.py must be kept mannualy in sync with elgg database scheme, and what we have here may not correspond exactly to the DB that you have. In particular, we have an extra "nusp" field on the user table, and you'll probably want to delete the whole "uspdata" application so that you don't pollute your DB with tables that you don't have.
Here is a screenshot of the initial admin view:
[File does not exist]
and editing the details of a user:
[File does not exist]
To install, set up Django, copy settings-dist.py to settings.py and fill in your DB access details and database prefix. Make manage.py executable, do a "./manage.py syncdb" as per the django documentation. Run "./manage.py runserver" to run a small server on port 8000. Go to localhost:8000 and log in to the admin interface.
As an example, this is what you can do via python scripting:
# Change all forwarder = dashboard to profile
for uf in UserFlag.objects.all():
if uf.flag == 'forwarder' and uf.value == 'dashboard':
uf.value = 'profile'
uf.save()
Now, this is not dificult to do with SQL, but to do a migration of the old widget to the new ones, I would not know how to express this in SQL:
def migrate(user):
print 'migrating widgets for user', user.name
dwidgets = DashboardWidget.objects.filter(widget_type='text', owner=user)
i = 1
for dwidget in dwidgets:
print 'found a widget of type ',dwidget.widget_type
(widget,created) = Widget.objects.get_or_create(owner=user, \\
wtype='widget::text',location='profile \\
location_id=0,wcolumn=0,display_order = i*10)
widget.access=dwidget.access
widget.save()
i+=1
for dd in DashboardData.objects.filter(widget=dwidget):
name = dd.name.replace('adash','widget')
value = dd.value
(wd,created) = WidgetData.objects.get_or_create(widget = widget.ident, \\
name=name, value=value)
wd.save()
If you find this useful and want to help the development, drop me a note.