System for embedding Phorum in other applications (early preview)

Posted by Maurice Makaay 
Re: System for embedding Phorum in other applications (early preview)
February 09, 2006 06:21PM
That's true Maurice. The Image relative path won't work with this. So your opinion will be to use preg_replace() or str_replace() to replace all relative path from phorum? It will need to be applied to the pre-output, right? which is in your embed_phorum, it will be the element['body_text']. Is that correct?

Or do I need to use some other thing?
Thanks
Re: System for embedding Phorum in other applications (early preview)
February 09, 2006 06:58PM
That will be about it. I was a bit afraid that I would have to parse the HTML tree, just to catch those situations where there is <img src=".."/> code in a form input field (changing field contents should not happen), but that won't be a problem, since the form field contents are all html escaped and will therefore look like &lt;img src=".."/&gt;. So I think it's safe to find all matches for an image tag with a src parameter that either starts with no slash, dot-slash or dot-dot-slash. For the replacement, Phorum's http_path setting can be used.

This substitution should of course honour more than <img src=".."> alone, think of things like <img width="100" height="240" src=".."/>. There's no guarantee for the exact <img> tag format.

I want to make this a default feature for the module, which the connector can turn on by simply setting a class variable to a true value. On my own site, I do not need the rewriting, because I can safely put the <base href=".."/> code in my header (my own site's framework uses absolute links only).


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: System for embedding Phorum in other applications (early preview)
February 09, 2006 08:58PM
Maurice,

These code work beautifully!
function hook_common_post_user()
{
// We use a hard-coded template for this connector.
$GLOBALS["PHORUM"]["template"] = "embed_phorum";
$GLOBALS["PHORUM"]["default_template"] = "embed_phorum";
}

Now we are in business! I am wonder how could I go about customizing the template.

Where could I find some resources on tips to do that?
What is the entry point of your embed template?

Thanks

[opensourceCMS.com]
[ongetc.com]
Chanh Ong
Re: System for embedding Phorum in other applications (early preview)
February 09, 2006 11:41PM
Quote
chanh
Now we are in business! I am wonder how could I go about customizing the template.

Where could I find some resources on tips to do that?
What is the entry point of your embed template?

Thanks

Browse over to the templates forum. Check out dissurion's martha_with_settings template. [www.dissurion.com] Basically almost every page has an html template. Phorum's template stucture is very powerful (uses {VAR} syntax so no php needed - similar idea as some php cms systems) and the only disadvantage that I see is there is so many template pages.

A big key to making things go smoothly for you is using the css.tpl file to setup css. Also settings.tpl. This is why I recommend you compare dissurion's version to the default template.

Keep in mind that the header.tpl and footer.tpl simplify things a little because they are constant on every page.

I believe one of the dev team has started a documentation file for templates. It is located under the development section (wiki).



Edited 3 time(s). Last edit at 02/09/2006 11:56PM by kevwit.
Re: System for embedding Phorum in other applications (early preview)
February 10, 2006 12:44AM
Is there anyway to have the outputed smiley to have the right path? I was also wondering, the rest of the images, except the smiley will be on the template, right? So it won't be a problem to me, because I can just change the template with the right relative/absolute path for the images that I use.

So with this, the only thing that really a major concern is just the smiley, am I correct? Will it be possible for embed_phorum to run a hook that will intercept the image path being produced on smiley engine to have the right path? It's just a thought though, because parsing raw output will take some resources, as well as there is no guarantee that the parser will actually parse the right image path that need to be changed.

Can you guide me a little bit on how to use hook? I think I might need to check the doc tomorow, but if someone could give me a head start or maybe direct me to the right page, that will be awesome.

Thanks.
Re: System for embedding Phorum in other applications (early preview)
February 10, 2006 03:21AM
I was thinking too of modifying the smiley paths from a hook. That should be possible using hook_common_post_user() in the connector. The smiley replacement data is in $PHORUM["mod_smileys"] I think (just use a print_var($GLOBALS["PHORUM"]) to find out where exactly), so you can modify the <img> tags to which smileys are rewritten. What I dislike about that, is that it's not a generic solution to the problem. I'd rather only mangle with data which is in Phorum's core. Fixing the smileys in this way could be something for a separate module though.

Information about mods and hooks is in docs/creating_mods.txt


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: System for embedding Phorum in other applications (early preview)
February 10, 2006 08:08AM
One of the things you might want to consider adding to a later preview is the ability to sync user group memberships between the master application and phorum. On our site, we have a group of people who handle routine maintenance and they also handle phorum moderation and have a private forum.
Re: System for embedding Phorum in other applications (early preview)
February 10, 2006 08:38AM
I have been thinking about the groups management. Till now I have given full control over the groups to Phorum. It might be a future feature to be able to disable group management for Phorum as well and let that be fed by the master application.

The problem that I see with this, is that group management can define lots of permissions and you can do crazy stuff with it, beyond the simple "This user is moderator for forum [x]". So an interface to it wouldn't be a really simple and straight-forward one, like the user synchronization is. My guess is that building this might result in a difficult connector API structure, which is defenitely not my goal ;)

The thing that you already can do, is set the "admin" field for a user to "1" in the user synchronization. That will make the user an administrator for Phorum. This might be already enough for supporting your case, but I don't know whether your maintainers are allowed to access the admin interface.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: System for embedding Phorum in other applications (early preview)
February 10, 2006 09:28AM
I am not really talking about group management of permissions by the master program, but simply whether a phorum user belongs to a group (I think this is the table user_group_xref). If I make a user a member of a group, it would be nice if there was a sync program to let phorum know that that user was a member of a group (or a number of groups). The phorum administrator still would determine what permissions a group would have.

Is there a way to delete a user?
Re: System for embedding Phorum in other applications (early preview)
February 11, 2006 12:29AM
I think you can delete a user from your master application, which is it's not part of this embed_phorum. You need to do it from your external application that handle the user account.

As far as group permission, I think by having an ability to sync the user groups on the master application to the phorum will be great. So basically in the phorum, it will have a copy of sync user group, and when the user session created during login, it will contain the group information for that user based on phorum/master app, which suppose to have the same data and id. With this, phorum still do its own permission setting.

Hope I'm making a sense here.
Sorry, only registered users may post in this forum.

Click here to login