Monday, September 04, 2006

Beginning with Xoops

So I just recently finished a contract job where they wanted a whole portal type deal with wiki, blog, forum etc. And they wanted all of this managed under centralized login ala CMS. After some digging, I landed on the Xoops page. This is a real neat project which makes it possible to integrate other php web apps such as mediawiki, wordpress etc. Some of the software I wanted to try out would only work well with xoops-2.2.3a-Final. Here's some little tweaks I had to do along the way to make things work just right.

Mediawiki in the xoops environment does lock out anonymous users from making edits, however you can't seem to restrict edit access to any particular user group(s) from xoops.

This little workaround did it for me. Mind you there's probably a nicer way to do it but the quick and dirty method worked for me.
In mediawiki/includes/User.php I modified the isAllowed function (which seems to get run on every page load) as such.

function isAllowed($action='') {
if ( $action === '' )
// In the spirit of DWIM
return true;

$this->loadFromDatabase();
global $xoopsUser;
ini_set("register_globals", "on");
#checking for edit page, edit action and whether user is logged in
if( ($_GET['action'] == "edit") && ($action == "edit") && ($this->mId) && is_object($xoopsUser) )
{
$usergroups =
$xoopsUser->getGroups();
#check if admin or a developer
if( in_array( 1 , $usergroups ) || in_array( 4 , $usergroups ) ){
return true;
}
else{
#deny edit access
return false;
}

}
else{
return in_array( $action , $this->mRights );
}
}
`

All I do right now is check for the usergroup ID's I'm interested in that big if statement but ideally you can build your array of ID's that you want to give access to and compare against. This is an exercise I leave upto you.

Another module that needed some work was the Edito module. This provides a nice and neat way to post static content on the site. There's even hooks to use an HTML editor. However this module didn't seem to even get to the install part right (I'm doing this on a Linux machine, not sure what the behavior is on Windows). The best thing to do before doing the install is turn on the debug mode in xoops. Right away I noticed that permission problems were keeping me from loading the module.
Moving on ..
In edito/admin/index.php
I changed.
include_once ("../include/nav.php");
include_once("../include/myblockslist.php");
to...
include_once ("../../include/nav.php");
include_once("../../include/myblockslist.php

Hope this was actually helpfull to someone. Let me know what you guys think.