1
ChadK
xDirectory hack needed [DONE]
  • 2004/7/15 17:53

  • ChadK

  • Quite a regular

  • Posts: 242

  • Since: 2004/7/9 1


I want to grant a user access to a private forum automatically when I approve their xDirectory listing.

I use the xDirectory module as an Avian Breeder Directory and I have a private forum for breeders.

Here's my first guess at the code that I need to add to the "function approve" function in the file: modules/xdirectory/admin/index.php

Quote:
// ADDED BY CHAD KOVAC to grant access to breeder forum
/* doesnt work
$sql = "SELECT submitter FROM " . $xoopsDB->prefix("xdir_links") . " WHERE lid=" . $lid;
$result = $xoopsDB->query($sql);
$submitter = $xoopsDB->fetchRow($result);
$query = "INSERT INTO `xoops_bb_forum_access` ( `forum_id` , `user_id` , `can_post` ) VALUES ('28', '".$submitter."', '1');";
$xoopsDB->queryF($query) or $eh->show("0013");
echo $sql;
echo $submitter;
*/
// END ADDITION

2
ChadK
Re: xDirectory hack needed
  • 2004/7/20 13:07

  • ChadK

  • Quite a regular

  • Posts: 242

  • Since: 2004/7/9 1


Can anyone help me with this? The current hack I listed doesn't work...

3
Mithrandir
Re: xDirectory hack needed

Wouldn't it just be easier to give access to these forums to a certain group and then add the user to that group, when you approve his listing?

//retrieve userid of the submitter
//[..]

$member_handler =& xoops_gethandler('member');
$member_handler->addUserToGroup($group_id$user_id);


Where $group_id is the id of the group with forum access.

4
ChadK
Re: xDirectory hack needed
  • 2004/7/20 14:15

  • ChadK

  • Quite a regular

  • Posts: 242

  • Since: 2004/7/9 1


Yes, that would work as well.. but I don't see how I can add a group to a forum? There's nothing on the forum_forums page and there's nothing on the admin_priv_forums page.


Also, the portion that isn't working is the code to get the user's ID I think. The original function where I've added my code doesn't know the "submitter ID" so I have to get it from the database. If I had it though, I could use your example to add them to the group.

5
ChadK
[SOLUTION]
  • 2004/7/22 13:33

  • ChadK

  • Quite a regular

  • Posts: 242

  • Since: 2004/7/9 1


Done. Here's what you need to modify to get yours working like mine.
Currently I've hard-coded the forum and categories into my hack so you'll want to edit your own category number(s) and forum(s) in the supplied code to suit your needs. Mine is set up so that if they submit a listing to the "Breeders" category then they get access to the breeder discussion private forum when an admin approves the listing. Same for Rescues.

In your file modules\xclassified\admin\index.php:

Find:
Quote:
echo "
";
echo "";


Replace with:
Quote:
echo "
";
//Added by CMK 7/22/04
// Need the submitterid on the form so it can be
// used in the approval
echo "";
//end additions
echo "";



Find:
Quote:
$query = "update ".$xoopsDB->prefix("xdir_text")." set description='$description' where lid=".$lid."";
$xoopsDB->query($query) or $eh->show("0013");
global $xoopsModule;


Replace with:
Quote:
$query = "update ".$xoopsDB->prefix("xdir_text")." set description='$description' where lid=".$lid."";
$xoopsDB->query($query) or $eh->show("0013");
// ADDED BY CHAD KOVAC 7/22/04 to grant access to breeder forum
// breeder: category ID = 154, forum id = 28
// breeder: category ID = 156, forum id = 34
if($cid=='154') {
$sql = "INSERT INTO `xoops_bb_forum_access` ( `forum_id` , `user_id` , `can_post` ) VALUES ('28', '".$submitterid."', '1');";
} else {
if($cid=='156') {
$sql = "INSERT INTO `xoops_bb_forum_access` ( `forum_id` , `user_id` , `can_post` ) VALUES ('34', '".$submitterid."', '1');";
}
}
$xoopsDB->queryF($sql) or $eh->show("0013");
// END ADDITION
global $xoopsModule;



Find:
Quote:
$premium = $HTTP_POST_VARS['premium'];
if ( empty($cid) ) {


Replace with:
Quote:
$premium = $HTTP_POST_VARS['premium'];

//Added by CMK 7/22/04
$submitterid = $HTTP_POST_VARS['submitterid'];
//End addition
if ( empty($cid) ) {


Now when someone on my site submits a breeder listing and an admin approves it they are automatically given access to the breeder message forum. Same for rescue listings. I could go further and add functions to do the same for bird clubs, whatever...

Enjoy.

6
ChadK
Modified to work with XIPB
  • 2004/7/28 15:21

  • ChadK

  • Quite a regular

  • Posts: 242

  • Since: 2004/7/9 1


When you approve a listing in xDirectory, this hack will auto-add them to a user group in IPB. Assuming you're using the xDirectory and xIPB modules...

I switched to the Invision Power-Board module/hack by bbpixel.com so here's an update to my xDirectory hack to add users to the correct category based on which directory they submitted to:

Editted file:
modules / xdirectory / admin / index.php

Replaced:
Quote:

echo "
";
echo "";


With:
Quote:

echo "
";

//Added by CMK 7/22/04
echo "";
//end additions

echo "";



Replaced:
Quote:

$premium = $HTTP_POST_VARS['premium'];
if ( empty($cid) ) {

With:
Quote:

$premium = $HTTP_POST_VARS['premium'];

//Added by CMK 7/22/04
$submitterid = $HTTP_POST_VARS['submitterid'];
//End addition

if ( empty($cid) ) {


Replaced:
Quote:
$xoopsDB->query($query) or $eh->show("0013");
global $xoopsModule;

With:
Quote:
$xoopsDB->query($query) or $eh->show("0013");


// ADDED BY CHAD KOVAC 7/22/04 to grant access to breeder forum
// cid = 154 = breeder = forum 28 = mgroup 6
// cid = 156 = rescue = forum 34 = mgroup 7
//On your site, cid is the category ID that determines what group to add them to
// in my example, 154 are parrot breeders. when they submit a listing
// and I approve it, I want to add them to IPB's group #6 which I've set up as
// BREEDERS and it uses the forum permission template of the same name
// which gives them permission to the breeder forum. you get the idea.
// The other cid I use for this example is 156 which are RESCUE listings.
// I add them to mgroup #7 which is the Rescue group.
// You might use this for a guild or clan listing. Have the
// potential clan member submit an xdirectory listing and once
// approved, they get added to the members forums for the clan.
if($cid=='154') {
$sql = "UPDATE `xoops_users` SET `mgroup`='6' WHERE `user_id`='".$submitterid."' AND `mgroup`='3';";
} else {
if($cid=='156') {
$sql = "UPDATE `xoops_users` SET `mgroup`='7' WHERE `user_id`='".$submitterid."' AND `mgroup`='3';";
}
}
$xoopsDB->queryF($sql) or $eh->show("0013");
// END ADDITION

global $xoopsModule;


Login

Who's Online

231 user(s) are online (178 user(s) are browsing Support Forums)


Members: 0


Guests: 231


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits