[spip-dev] Sessions for anonymous users; private area interface things; and licences for plug-in

Hi SPIP Devs,

I sent this to spip-en@ last week and Ben replied that it's OK to use English on this list as well.

Any suggestions about fixing the following problems will be gratefully received.

Thanks,

Thomas Sutton
bouncingorange

From: Thomas Sutton <thomas@bouncingorange.com>
Date: 22 October 2008 7:09:45 PM
To: Spip Mailing List <spip-en@rezo.net>
Subject: Sessions for anonymous users; private area interface things; and licences for plug-in

Hi folks,

I'm still working on my plug-in (a catalogue and shopping cart for SPIP) and have a few questions to ask. All of the below is with respect to 1.9.2e, but I'll be moving to 2.0.0 when it's stable. Thanks to everyone who's already answered my previous questions (Fil, Pierre, Gilles, and everyone else) and in advance to anyone who responds to this lot. My questions are below, easy ones first.

SPIP plug-ins should be under GPLv2 as they're derivative works, shouldn't they?

My notes on writing this plug-in are reasonably incomplete (it's mostly a list of stuff that *doesn't* work), but its about 9 A4 pages or so currently. Where's the best place to make it public: spip.net, plugins.spip.net, spip-contrib.net, doc.spip.org, our company web-site, or my personal blog (or some combination)?

Is there a block diagram or flow chart or something that explains SPIP's architecture? Writing this plug-in (or, more correctly, trying to figure out how to write this plug-in) has given me a much better understanding of SPIP, but it's also been extremely frustrating, not particularly elucidating and I can't imagine that it'll be a popular way to learn. :slight_smile:

Now for the harder, technical questions.

I've looked through the code in inc/session.php and inc/utils.php and I get the impression that SPIP's session handling is for authenticated users (accounts in `spip_auteurs`). Is this true? If I want to store session information for anonymous users, is there a proper way to go about it (from PHP in a plug-in, not a template)? In particular, I want to maintain a shopping cart in a session without forcing users to log-in first (indeed, I'd rather they not login at all). Can I do this with SPIP's session handling? Or will I need to fall back on session_start() and $_SESSION?

Since I sent this message, I've looked at inc/session.php some more and decided to use session_start(). It's all working fine.

Hi Thomas,

Some answers to your message, not all.

Adding logos to products was relatively simple. I just based my code on that in exec/articles.php (calling inc/iconifier.php). inc_iconifier_dist uses a global array to determine the heading for the logo block, so I had to use the second line below to add the correct title.

       $iconifier = charger_fonction('iconifier', 'inc');
       $GLOBALS['logo_libelles']['id_product'] = _T('yobbo:logo_product');
       $info .= $iconifier('id_product', $id_product, 'products', $flag_editable);

I added logos after wrestling with documents, keywords, authors, etc. so I was, frankly, surprised that it worked so well. Indeed, the only problem is that the widget is re-loaded using AJAX whenever the user adds or deletes a logo and that the AJAX action doesn't know about the heading that I added on line 2 above. How should I add my own headings to this array so that it is available to the AJAX action as well as to my call point?

You should define the following function in the mes_options.php file:

function inc_iconifier($id_objet, $id, $script, $visible=false, $flag_modif=true) {
  include _DIR_RESTREINT . 'inc/iconifier.php';
  $GLOBALS['logo_libelles']['id_product'] = _T('yobbo:logo_product');
  return inc_iconifier_dist($id_objet, $id, $script, $visible, $flag_modif);
}

Is there a way to use the standard widget from inc/dater.php for my own tables?

Yes, with this:
http://trac.rezo.net/trac/spip/changeset/13043

Similarly for the keywords widget

Similarly:
http://trac.rezo.net/trac/spip/changeset/13044

Thanks for your remarks

Committo,Ergo:Sum