WSN Links https://scripts.webmastersite.net/wsnlinks/manual en-us WordPress Using WSN and WordPress together effectively. https://scripts.webmastersite.net/wsnlinks/manual/integration/wordpress-555.html Sun, 22 May 2011 17:13:26 GMT https://scripts.webmastersite.net/wsnlinks/manual/integration/wordpress-555.html Update: Most of this can now be accomplished more easily simply by installing WSN as a wordpress plugin using the plugins downloadable from https://www.webmastersite.net/wordpress.html

To have WSN use WordPress member logins, just go to Admin Panel -> Members -> Integration and select wordpress from the pre-supplied options. Important Note: With WordPress, the usergroup is called user level. 10 is the user level value for admins, 1 for contributors, 0 for subscribers, 2 for authors and 7 for editors -- be sure to use those values when mapping usergroups. There's no need to mape group 10 (admins) because the integration file already maps that to the administrators group automatically, and makes everybody else a regular member.

To display listings from WSN inside your wordpress, you can either use the javascript export or install a wordpress rss reader plugin so that you can call data from WSN's rss feeds (which can be crafted to produce whatever you need). Conversely, to display content from wordpress inside WSN you can use WSN's template rss parser (the url for a wordpress rss feed is your wordpress url plus /?feed=rss).

Cookie Integration

WSN can't get or set wordpress login cookies, because their format is complex and poorly documented. Fortunately there's an alternative that gets us most of the way there: have wordpress set WSN login cookies when users login to wordpress, and clear them when users logout of wordpress. We can do this by adding a plugin to wordpress. Follow these steps:

1. Via your FTP client, navigate to wordpress' wp-content/plugins/ subdirectory and create a subdirectory named wsnlogincookiesforwordpress in there.

2. With your desktop text editor (such as notepad), create a wsnlogincookiesforwordpress.php file with this content:

<?php
/**
* @package WSN Login Cookies For Wordpress
* @version 1.0
*/
/*
Plugin Name: WSN Login Cookies For Wordpress
Plugin URI: [url=http://www.webmastersite.net]http://www.webmastersite.net[/url]
Description: Sets and unsets WSN login cookies on wordpress login and logout.
Author: Paul Knierim
Version: 1.0
Author URI: [url=http://www.webmastersite.net]http://www.webmastersite.net[/url]
*/

$wsninfo['cookiepath'] = "";
$wsninfo['cookiedomain'] = "";

function setwsnlogincookies($user_login, $user)
{
global $wpdb, $wsninfo;
$id = $user->ID;
$hash = $wpdb->get_var( "SELECT user_pass FROM $wpdb->users WHERE ID=$id" );
if ($_REQUEST['rememberme']) $expiration = time()+86400*365*7; // 7 years
else $expiration = 0; // session only

setcookie("wsnuser", $id, $expiration, $wsninfo['cookiepath'], $wsninfo['cookiedomain']);
setcookie("wsnpass", $hash, $expiration, $wsninfo['cookiepath'], $wsninfo['cookiedomain']);
}

function unsetwsnlogincookies()
{
global $wsninfo;
$expiration = time() - 86400*365; // last year
setcookie("wsnuser", "", $expiration, $wsninfo['cookiepath'], $wsninfo['cookiedomain']);
setcookie("wsnpass", "", $expiration, $wsninfo['cookiepath'], $wsninfo['cookiedomain']);
}

add_action('wp_login', 'setwsnlogincookies', 10, 2);
add_action('wp_logout', 'unsetwsnlogincookies');

?>

Make sure you don't have any leading or trailing whitespace.

3. If you've got a cookie path or cookie domain at Admin -> Settings -> System Configuration -> Cookie Info, fill in $wsninfo['cookiepath'] and $wsninfo['cookiedomain'] above.

4. Upload the wsnlogincookiesforwordpress.php file to the wsnlogincookiesforwordpress subdirectory you created.

5. Login to your wordpress admin panel, go to the plugins section, find the WSN Login Cookies For Wordpress plugin and click the "activate" link to enable it.

6. You may want to remove the login/logout/register links from your WSN via Admin -> Customizations -> Menu Manager (if the integrated wordpress theme already has wordpress versions of those links in the header/footer), or to change those to link to the wordpress versions.

Theme integration

The most important task is to make both parts of your site look alike as part of a unified whole website. If you check the box when WSN asks you if you want theme integration when you're integrating your members, this'll be done for you by replacing your stylesheet and automatically replacing sections of your wrapper template with the wordpress header, sidebar and footer.

If for some reason you're having to do this manually later, go to Admin Panel -> Themes -> Manage Templates -> "Wrapper" and insert this just below the <body> tag: {FUNC_WORDPRESSHEADER[/path/to/wordpress/]}. Make sure you change /path/to/wordpress to the appropriate file path of your wordpress installation. Relative paths are allowed, so if your WSN is a subdirectory of your wordpress you can use {FUNC_WORDPRESSHEADER[../]}. Next, insert {FUNC_WORDPRESSSIDEBAR[/path/to/wordpress]}{FUNC_WORDPRESSFOOTER[/path/to/wordpress/]} just above the </body> closing tag at the bottom of the wrapper. Again replace /path/to/wordpress/ with your path.

Have a look at your WSN front end now and you'll see your WSN site will be encapsulated in your wordpress header and footer. You may want to remove some redundant bits from your WSN wrapper template or menus.

Finally, you'll need to link to your WSN in an approprite place on a wordpress menu or page so people find it on your site.

]]>
Integrating With Other WSN Scripts Integrating WSN Links, WSN Gallery, WSN Classifieds, WSN Software Directory, WSN Directory, WSN Forum and WSN Knowledge Base to work together. https://scripts.webmastersite.net/wsnlinks/manual/integration/integrating-with-other-wsn-scripts-426.html Mon, 03 Sep 2007 08:11:57 GMT https://scripts.webmastersite.net/wsnlinks/manual/integration/integrating-with-other-wsn-scripts-426.html Integrating the member systems of WSN scripts just consists of picking one script to integrate the others into. You can also integrate templates so that template customizations in one script will apply to the others.

Integrating Members, PMs, IMs, Online Users, Stylesheets and Images

First, select one script installation (where you have the most members currently) and declare that the parent installation, which the child installations will connect to.

Go to Admin Panel -> Members -> Integration in each child installation, and select to integrate with the parent script. Use the pre-supplied options for the WSN scripts in the dropdown menu. This will automatically integrate members (including avatars), PMs, IMs and online users. More details in the member integration article.

When the script you're integrating with is another WSN script, please be aware that all the scripts should be on the same series -- if you have Classifieds 7.1, use Links 7.1 too, or there could be errors in spots. You don't have to have the exact same version, just series.

Note that stylesheets and images are automatically shared when integrating. The stylesheet of the script you integrate into is automatically put into use, along with its associated images directory, so you don't have to redo your design. In most cases this is good, but sometimes you want to style them differently. To do that, first set the $nostyleintegration tweak at Admin -> Settings -> Tweaks Editor. Then add a new member field named 'secondstylesheet', and edit your integration file in the /integration/ subdirectory to add the line $newstylesheet = 'secondstylesheet'; just before the closing ?>.

Integrating Additional Tables

Sometimes, you may want to share even more database tables between the scripts. To do this, open the integration file (in the /integration/ subdirectory) and add this line:
$integratetables[] = 'chat';
efore the closing ?>. Repeat for any other tables. Can work with custom tables. Please note additional table integration only works with WSN 10.3.0 and later.

Integrating Toplist Data

You can do a toplist of items from one WSN script from the template of a different WSN script. See the cross-script toplists article for the details.

Integrating Templates

Many templates are by default the same across all the WSN scripts. It can thus be convient to have them locked in sync so you can customize it in any script and have the changes apply to all the scripts.

As of WSN 10.3.7, the integration page presents several theme integration options:
share styles - This will make the integrating script use the stylesheet/images of the host script. Always a safe selection.
share styles and many templates but not wrapper - This will integrate a bunch of templates for which there's no reason why 99% of people would want them to differ by script.
share styles many templates including wrapper - This is like the above but also integrates the wrapper template. You probably will want a few things to differ by script in your wrapper, so if you select this you'll need to handle those differences using template conditionals that check the current URL or something else distinguishing (e.g. <IF {CURRENTURLCONTAINS[/gallery/]}>gallery wrapper stuff here</IF>)
share entire theme - This will integrate every single template. Can only work correctly if integrating with another copy of the same WSN script, since for example a forum's front page has to look different from a gallery's front page.

You may change these values later by editing the $integrationoptions['integratetemplates'] in the /integration/ subdirectory file.

For pre-10.3.7 versions, or to override the exact list of templates to share in 10.3.7+, you can specify template integration in your integration file (the member integration file created in your /integration/ directory during member system integration). Add these lines:

$templatesharepath = '/blah/blah/otherscript/';
$templatesharing = 'atomfeed.tpl, badrequest.tpl, banned.tpl, buddyignore.tpl, buddylist.tpl, bulkeditposts.tpl, calendar.tpl, calendarday.tpl, calendareditevent.tpl, chatdownload.tpl, chatmain.tpl, codes.tpl, contactform.tpl, contactreply.tpl, coppa.tpl, deletedpost.tpl, downloadpms.tpl, downloadthread.tpl, emailmember.tpl, flagged.tpl, forumdetails.tpl, guestbook.tpl, helpcatcontents.tpl, helpitem.tpl, helpmain.tpl, ignored.tpl, imchat.tpl, immain.tpl, javascriptheader.js, leaders.tpl, login.tpl, macros.tpl, modlog.tpl, modnotes.tpl, navigation.tpl, noaccess.tpl, offline.tpl, pagination.tpl, paginationfull.tpl, pmdrafts.tpl, pmedit.tpl, pmlist.tpl, pmmove.tpl, pmsend.tpl, pmsentitems.tpl, printable.css, privacy.tpl, promote.tpl, prototype.js, quoteedit.tpl, quotelist.tpl, redirect.tpl, reportcomment.tpl, rss.css, rssfeed.tpl, searchcomments.tpl, searchips.tpl, shouteditfull.tpl, shoutedit.tpl, shoutframe.tpl, shoutfull.tpl, sitedead.tpl, smilies.tpl, tos.tpl, traderedit.tpl, tradermain.tpl, traderreport.tpl, tradersubmit.tpl, usernotes.tpl, viewreports.tpl, whiteboard.tpl';

Replace /blah/blah/otherscript/ with the full file path to the script you're integrating with (the base directory, thus the same as your config.php's $uploadpath with the 'attachments/' chopped off). The $templatesharing list of templates to share has been filled here with the list of non-admin templates which are the same across all the WSN scripts.

The stylesheets and images are auto-shared in pre-10.3.7 versions.

To share the entire templates directory, use
$templatesharing = 'all';
Please remember that sharing the entire directory only works if it's another install of the same WSN script -- with different WSN scripts, you'll want to share only specific templates.

You can edit the template from any of the scripts and it'll save to the host script appropriately. Note that shared templates must be chmoded since the non-host script won't be able to do FTP chmoding automatically.

It's also possible to share your wrapper template. Add wrapper.tpl to the $templatesharing list. Then use conditionals which detect {DIRURL}, {SITETITLE} or some other distinctive setting in order to serve up any desired slightly different wrapper content depending on the script its being used from. If your forum is at forum.yourdomain.com for example you could use <IF {DIRURL} contains forum.yourdomain.com>forum-only stuff here</IF>

Of course, template sharing is optional and unnecessary.

]]>
Cross-Script Toplists Making a toplist of items from one WSN script while in another. https://scripts.webmastersite.net/wsnlinks/manual/integration/cross-script-toplists-604.html Mon, 20 Jun 2005 09:35:14 GMT https://scripts.webmastersite.net/wsnlinks/manual/integration/cross-script-toplists-604.html Presuming you own multiple WSN scripts, sometimes you may wish to show toplists of items from a different WSN script than the one you're in. The toplist syntax remains the same as usual for the most part, with the first term changing to indicate the desired database table. It's easiest to explain this by example. Here's a toplist that will show the five newest images from WSN Gallery within any of the other scripts:
<!-- BEGIN TOPLIST -->
<CONFIG>wsngallery_links[,]id[,]5[,]descending</CONFIG>
<a href="
{LINKDETAILSURL}">{LINKTHUMBIMAGE}</a>
<!-- END TOPLIST -->

sngallery_links is simply the name of the database table you want the data from, which you can find in phpmyadmin. For another example, here's a way to show the most recently posted in ten threads from WSN Forum within WSN Links (or Gallery or KB):
<!-- BEGIN TOPLIST -->
<CONFIG>wsnforum_links[,]lastcomment[,]10[,]descending</CONFIG>
<a href="
{LINKTHREADURL}">{LINKTITLE}</a> by {LINKOWNERNAME}<br>
{LINKMESSAGE[50]}<br>
<!-- END TOPLIST -->


Finally, you can show similar threads from your forum within WSN Links (or vice versa, or any other combination) with a special toplist condition like this:
<!-- BEGIN TOPLIST -->
<CONFIG>wsnforum_links[,]time[,]5[,]descending[,]MATCH (title) AGAINST('{LINKTITLE}')</CONFIG>
<a href="{LINKTHREADURL}">{LINKTITLE}</a><br>
<!-- END TOPLIST -->

You can do cross-script toplists for comments, categories/forums, etc as well just by using the appropriate table name.

Troubleshooting

Important note: when doing URL rewriting, you must have the same rewrite formatting (except for template variables being of the host script's type of course) on all the scripts involved for it to rewrite correctly in cross-script toplists. You can work around this by writing out non-rewritten versions of the URLs, if you need to.

]]>
Member system integration Using WSN with a preexisting member base. https://scripts.webmastersite.net/wsnlinks/manual/integration/member-system-integration-75.html Fri, 17 Oct 2003 17:39:26 GMT https://scripts.webmastersite.net/wsnlinks/manual/integration/member-system-integration-75.html
Mapping Usergroups

Since different types of scripts have different types of permissions, there's no logical way to integrate usergroup permissions -- instead, we map a usergroup number from the other script to be treated as an equivalent WSN usergroup number. You can find your WSN usergroup numbers at Admin Panel -> Members -> Manage Usergroups -> (select a group) at the top.

By default, only the basic usergroups are mapped: guests, members, administrators. All other groups are considered as members. You can change this to map more of the other script's groups onto WSN groups. Open the integration file (in the /integration/ subdirectory) in a text editor. You can map groups by adding lines in the form
$group4 = '6';

This example specifies that everyone in group #6 of the member system you're integrating with will be treated as being in WSN group #4. Create a group #4 in your WSN admin panel and give it the permissions you want members in group 6 of your other database to have.

This can be continued for multiple groups by adding more lines, like
$group5 = '10';
to set group 10 to work as WSN usergroup #5.

For Advanced Users

Continue reading this manual entry only if you have problems with the integration generator not fully supporting what you want to do, or you or just want to learn more about how integration works.

To get an idea of what you're trying to do, have a look at /integration/setup/smf.php. That file has a bit of everything -- various special functions to handle the awkward cases SMF presents. You may find it useful to copy from there to your integration file. Note that any .php file you save to the integration directory will automatically become a selectable option in your settings (except ones named with 'encoder' in the title, as will be explained in a moment).

The format of the integration files is simple. First you specify the name of the database table, as $memberstable = 'otherscriptstable';
Look at otherscriptstable in phpmyadmin, write down the field names listed for it and be sure you have a general idea of what each field contains or is for. Then specify in the integration file each field in that table which does NOT have the same name as the corresponding item in the WSN Links members table (compare with yourprefix_members in phpmyadmin). The format for this specification consists of putting $new in front of the WSN field name, and then = "the other script's field name we should use";

For example:
$newname = 'username';
$newid = 'userid';

Fields which are named the same as in WSN Links do not have to be specified.

All WSN member fields which do not exist in the script you're integrating with will be automatically added as soon as you load any page on your site with that integration script selected.

Note: Do not drop the WSN members table when done, because it is still used for field comparisons, upgrades, etc.

If for some reason the administrator is identified using something other than the usergroup field, you can set $adminfield = 'fieldname'; and $adminfieldvalue = 'whateverthefieldhasforanadmin';... you could do this with a username field to set just one member as admin for example.

If your script uses an array for the user/password cookies, just supply the name (without an index) as the cookie name and password, and then add this to your integration file:

$cookietype = 'array';
$idindex = 'userid';
$passwordindex = 'password';

Of course replacing userid and password with the actual index names for the array cookie. If it uses a member username instead of an id, add:

$cookieidtype = 'name';

See the integration/setup/mambo.php file as an example.

When dealing with session cookies, you can use $cookietype = 'session'; and add a
$sessionquery = "SELECT x FROM y WHERE id='{SESSIONID}'";
line to specify the query needed to get the member id when given the session id. Put the session cookie name in the $idcookiename spot.

If you set $registrationurl = 'http://hostscript/register.php'; then people will be automatically directed to the registration page of the host script, and avatars will be automatically shared for WSN scripts.

Sometimes you may run into a member system which doesn't keep all the member data in the same table. As of 5.0.0, you can handle this by manually specifying the additional fields ($newsomething = 'something' as above) and then adding this line:
$integrationoptions['queryadditionalfields'] = "SELECT field1,field2,field3 FROM othertable WHERE id='{ID}'";

You need to alter the query to specify how to get data out of the particular table you're dealing with. Note that this method will get the data out of the fields, but won't allow updating the values of the fields by editing a WSN profile.

Additionally, if you need to get the member usergroup out of another table with a custom query, you can specify that like this:
$integrationoptions['usergroupquery'] = "SELECT group FROM othertable WHERE id='{ID}'";


Helper Functions

Helper functions can be used for the registration and cookie setting/unsetting processes. Look at integration/smf.php for an example implimentation of each, copy that and modify to your needs.

integratedregistration - If you want to allow registering through the WSN interface instead of redirecing to the other script's registration page, you can do that and put cleanup code here to make the database correct for the other script's use.

setlogincookies - If cookies needs to be set in some unique way, or a database session needs to be added to the database in the process, do that here.

unsetlogincookies - In case you need a special way to clear the cookies on logout (perhaps deleting a database session).

comparecookiepassword - If your script has a special way of deciding whether the value in a password cookie is authentic, you can specify it here.

integration_extractcookie - Get the id and password out of the cookie.

integration_encodepassword - Special password encoding. This used to be done as a separate xencoder.php file.

Troubleshooting

If you choose an integration option and it does not function, run this query in phpmyadmin to go back to the native member system so that you can login again:
UPDATE yourprefix_settings SET content='' WHERE name='integration';

Change yourprefix_ in that query to whatever tables prefix you selected to use during setup. You will then need to visit upgrade.php (no need to run the upgrade, just view the page) to get the field list reset.

After you set or unset the integration, note that you will likely need to go to Settings -> General Appearance and re-select a member list sort order (this is so that it sorts by a field which exists in your new members table). Also select a valid member sort order for member searches under Settings -> Search & SEO.

Integrating With Other WSN Scripts

When integrating with another WSN script, you automatically share stylesheets, online user lists, private messaging and instant messaging systems. You can also share templates and toplist data.

For details on integrating with other WSN scripts, please see the full article Integrating With Other WSN Scripts.]]>