CMS Integration
mindless
![]()
Joined: 2004-01-04
Posts: 8601 |
![]() |
ok, watch me flip-flop (should I run for president?) while the above doesn't sound too complicated, it isn't trivial either. I'll still do item 3 above, so we reset any existing g2 sessions on cms logout. |
|
bd_csmc
Joined: 2004-10-01
Posts: 1 |
![]() |
would you guys mind posting the file you're using for the xaraya integration? i'm trying to get G2 integrated with mambo, and while i was able to use a script that was written for G1 (had to make a couple of modifications), it's not a complete integration, just display. i'd like to get gallery sharing user info, and i'd prefer to not haveta hack up G2 for this purpose i'd appreciate it |
|
mindless
![]()
Joined: 2004-01-04
Posts: 8601 |
![]() |
Here's the code I'm working with.. valiant's may be more up to date. |
|
mindless
![]()
Joined: 2004-01-04
Posts: 8601 |
![]() |
User/group functions now in embed.php (cowritten by valiant and me). |
|
Luxus
Joined: 2004-07-07
Posts: 30 |
![]() |
you guys are great... i will wait for g²beta but then i will play arround with it :D |
|
valiant
Joined: 2003-01-04
Posts: 32509 |
![]() |
1. submitted a small xaraya roles module patch. now the roles module addmember / removemember hook calls tell us what user has been added/removed from the group, before we just got the group, lol. 2. changed GalleryEmbed::addUserToGroup() to check if the user is already a member of the group before adding it. else we get multiple mappings in the maps table. I'm not yet sure if we definitely need this check, but mapping from the tree like user<->group structure of xaraya to a flat mapping is somewhat tricky. 3. Added some module variables in the xaraya gallery2 module. 4. I'm working on the xaraya hook functions for createUser, ... mindless, question: when would I call GalleryEmbed::done() ? |
|
mindless
![]()
Joined: 2004-01-04
Posts: 8601 |
![]() |
Quote:
question: when would I call GalleryEmbed::done() ? Only call this once, after all G2 processing is done for this request. |
|
valiant
Joined: 2003-01-04
Posts: 32509 |
![]() |
mindless, thanks, that are good docs! mindless, question: Accordingly, we should allow to change the userName too in GalleryEmbed::_setUserData(), after all you can change it in the UI too. |
|
valiant
Joined: 2003-01-04
Posts: 32509 |
![]() |
requested 2,3 other xaraya roles module patches, hope to get them included. I've completed: Next: mindless, changed embed.php updateUser and added updateGroup to make userName / groupName changes possible. edit: removed obsolete module version attachement |
|
valiant
Joined: 2003-01-04
Posts: 32509 |
![]() |
mindless, I'm not sure if a CMS <-> G2 user/group mapping based on the unique userName / groupName is the right approach. xaraya is surely not only CMS that allows changing the userName / groupName and G2 allows it too. I'm discussing the issue with the xaraya role module author and perhaps soon with other xaraya devs. The alternative: Not only the user / group create / update / delete hook calls would base on the CMS_id (instead of the userName, groupName), but the GalleryEmbed::Login and ::handleRequest methods too. Well, this is just an idea (we already had this thing before you/we decided wo map basing on the userName). I'm undicided and I'm willing to discuss this (well, I have to anyway, with the xaraya guys). |
|
valiant
Joined: 2003-01-04
Posts: 32509 |
![]() |
I'm writing more and more stuff for the xaraya gallery2 module. Now I know what is part of the xaraya gallery2 module and what is part of the G2 CMS module. G2 CMS module: This module should also disable the registration capabilities (on API level). xaraya gallery2 module: The whole user import/export process is initiated by the CMS and part of the CMS and I think this is the best solution. |
|
mindless
![]()
Joined: 2004-01-04
Posts: 8601 |
![]() |
I like mapping on username because it keeps things simple.. we don't have to sync ids between dbs and we don't have to perform any extra mapping. Your changes in GalleryEmbed to allow renaming users/groups allows this method to still work. |
|
valiant
Joined: 2003-01-04
Posts: 32509 |
![]() |
mindless, please take a look at my last post, we posted nearly simultaneously, perhaps you didn't see it. I like the mapping based on userNames too, because it's simple. That's the main argument I instanced (hope this englesa). All I say: It works with userName maps, but it's perhaps not the best solution. The special groups/user show that the userName mapping is not as simple as it might look like, but still, it's simpler (and a little bit less reliable) than a mapping basing on IDs. |
|
valiant
Joined: 2003-01-04
Posts: 32509 |
![]() |
Ok, I'm finished with the hook functions, the admin area (config/install) and the activation / initial synchronization code. TODO: Unfortunately, i had to request lots of feature in xaraya and some things are not even clear if they get implemented. So, the finished code won't work at the moment. BUT: With the newest version of xaraya (perhaps only from bitkeeper) you can install the gallery2 module and configure it and it works. There are no constants in the code etc. mindless, we should clarify which methods/functions we move from the gallery2 module in xaraya to GalleryEmbed / CMS module in g2. i.e. my parseHead function which parses the HTML head for javascript/css/title should be part of GalleryEmbed. After my first user/group import/export implementation which is completly coded in the gallery2 module in xaraya, I have following idea: Make this "initialUserGroupImportExport" function a part of GalleryEmbed or the CMS module in G2. example: GalleryEmbed::initialUserGroupImportExport(array( 'importG2Uroups' => 'someFunctionName', 'exportCMSGroups' => ..., 'importG2Users' => ..., 'exportCMSUsers0 => ...)); And GalleryEmbed::initialUserGroupImportExport would call the registered functions accordingly with lots of common code in between. edit: removed obsolete xaraya gallery2 module. |
|
valiant
Joined: 2003-01-04
Posts: 32509 |
![]() |
mindless, the current version of my xaraya module seems to work. What's wrong? My setup: /xaraya-0-9-10/index.php embedUri = index.php?module=gallery2 |
|
mindless
![]()
Joined: 2004-01-04
Posts: 8601 |
![]() |
you're doing |
|
valiant
Joined: 2003-01-04
Posts: 32509 |
![]() |
mindless, thanks. It was very very late, that was exactly my error. |
|
valiant
Joined: 2003-01-04
Posts: 32509 |
![]() |
mindless, I could fix a dozen bugs in my xaraya gallery2 module. But I have 1 problem though. URLs ! All URLs that should go through the CMS are ok, I can navigate etc. But: All direct G2 URLs are broken. - style sheet urls: <style type="text/css" media="all">@import url(http://192.168.123.123/gallery2/themes/matrix/styles/theme.css);</style> I get <style type="text/css" media="all">@import url(http://gallery2/themes/matrix/styles/theme.css);</style> - ShowItem / Download item URLs don't work neither. - Slideshow URLs are broken too, with or without ShortUrls. I tried to fix it. In GalleryUtilities::convertPathToUrl($path) But then I get <style type="text/css" media="all">@import url(http://192.168.123.123/themes/matrix/styles/theme.css);</style> What's special with these URLs? Same setup as before: embedUri = index.php?module=gallery2 And as I said, all other URLs are ok. edit: removed obsolete module version attachement |
|
Luxus
Joined: 2004-07-07
Posts: 30 |
![]() |
the attachment is broken.. |
|
valiant
Joined: 2003-01-04
Posts: 32509 |
![]() |
Luxus, the new one? seems to be working for me. could open the zipt archive and open a file of it. |
|
Luxus
Joined: 2004-07-07
Posts: 30 |
![]() |
strange ... just some seconds ago i got a message about that the attachment not exist... |
|
mindless
![]()
Joined: 2004-01-04
Posts: 8601 |
![]() |
valiant, how do you configure the xaraya module? I deactivated and removed my old module, unzipped your file and activated that. I didn't see any link/option for configure, but when I visit index.php?module=gallery2 it says the module is not configured. So I commented out the is-configured check in the module and manually set the module vars in the db.. g2.basefile needed fixing (should be filename/query param only, no path! index.php?module=gallery2) and g2.relativeurl, g2.includepath were blank so I added the values.. my G2 in xaraya comes up ok now. Does this help you locate the problem in your install? Check your xar_module_vars table to make sure the settings are correct.. (btw, valiant.. your code needs to pass empty string to GalleryEmbed::handleRequest() when user is anonymous/guest) |
|
valiant
Joined: 2003-01-04
Posts: 32509 |
![]() |
mindless, thanks! That was yet another bug. I used $_SERVER['SCRIPT_NAME'] instead of $scriptName = preg_replace('|/([^/]+/)*|', '', $_SERVER['SCRIPT_NAME']); Now it works. All URLs are correct !! I fixed the anonymous user thing. But why should i not pass the anonymous user? the xaraya module configuration is done it the Admin panel. Here's the fixed version of the xaraya gallery2 module. mindless, I'm also using the latest xaraya version from the dev repository through bitkeeper. If you want, I could post a url to the latest version i downloaded. edit: removed an obsolete xaraya gallery2 module version attachement. |
|
mindless
![]()
Joined: 2004-01-04
Posts: 8601 |
![]() |
Quote:
I fixed the anonymous user thing. But why should i not pass the anonymous user? I didn't want to require the username for anonymous/guest to line up between CMS and G2.. who knows, maybe some CMS don't have a "username" for this.. so the handleRequest() api specifies to pass empty string for this case. |
|
valiant
Joined: 2003-01-04
Posts: 32509 |
![]() |
Ok, agreed. Noticed that the upload applet doesn't work in embedded mode. mindless, could you change what is needed to create direct G2 DownloadItem urls? They should go directly to G2, not via the CMS baseUrl etc. |
|
Luxus
Joined: 2004-07-07
Posts: 30 |
![]() |
atupid question but how i activate cms embeded in g² ? |
|
valiant
Joined: 2003-01-04
Posts: 32509 |
![]() |
I guess you refer to "mode.embed.only". $gallery->setConfig('mode.embed.only', true); in the config.php of G2, set it to true during the xaraya admin gallery2 module config process. |
|
mindless
![]()
Joined: 2004-01-04
Posts: 8601 |
![]() |
valiant, what more needs to be done for core:DownloadItem urls? I already made the changes so these go directly to G2 (do "view image" on any thumb/image to see the url). Luxus, unzip gallery2.zip in your xaraya/modules directory, then login to xaraya as an administrator and activate the module.. if you get an error, what is the error? After the module is activated you should see Gallery2 in the "Modules" list in the xaraya sidebar. |
|
valiant
Joined: 2003-01-04
Posts: 32509 |
![]() |
mindless, my bad. The DownloadItem urls are ok, sorry. Or if you really can't see this menu item ?!?! browse to And I said, you need to set |
|
valiant
Joined: 2003-01-04
Posts: 32509 |
![]() |
take a look at my signature, i keep an up to date version of the xaraya gallery2 module online. online demo: http://nei.ch/test/xaraya-0-9-10/ G2 is in embedded only mode. edit: corrected the url, thanks mindless. |
|
mindless
![]()
Joined: 2004-01-04
Posts: 8601 |
![]() |
demo url is missing "test/" in the path... |
|
valiant
Joined: 2003-01-04
Posts: 32509 |
![]() |
Fixed another dozen bugs and rewrote some code in my xaraya module. Now, actually the create user, group, addmember, removemember, update user, group hooks work. mindless: 2. You can take a look at my xaraya gallery2 module (see link in signature). All we had to code foreach integration is: - and we would get the small performance penalty for translating all G2 db queries on the fly. Bottom line: note: i had the idea to move some import/export code to g2. That's not possible. As the import/export code needs to call CMS API functions again and again and we can't call CMS API functions from G2, but the other way around works. |
|
valiant
Joined: 2003-01-04
Posts: 32509 |
![]() |
@language code: I will set the G2 user language code whenever it's updated in xaraya, but for anonymous users and generally for session var updates I cannot submit the change to G2, but as I said, handing over the language/locale to G2 in GalleryEmbed::handlerequest would be perfect, IMO. The format is "en_US.utf-8", it's like the lang code of G2, but there are .utf-8, ... extensions. My questions: b) Do you think it's a good idea to hand over the language code on each request (at no cost)? update: i hand over the lang code as lang_COUNTRY to handleRequest and in GalleryEmbed::handleRequest($userName=null, $langCode=null) i set the session language after running the langCode through GalleryTranslater::getSupportedLanguageCode($languageCode, $fallback=true) and it works. |
|
valiant
Joined: 2003-01-04
Posts: 32509 |
![]() |
we still could add the ext_uid attribute to the GalleryUser and synchronize with that attribute/id. it would come with zero costs as it is cached with the GalleryUser entity. just an idea... |
|
valiant
Joined: 2003-01-04
Posts: 32509 |
![]() |
updated the task on sf.net: |
|
bharat
![]()
Joined: 2002-05-21
Posts: 7994 |
![]() |
valiant wrote:
i hand over the lang code as lang_COUNTRY to handleRequest and in GalleryEmbed::handleRequest($userName=null, $langCode=null) i set the session language after running the langCode through GalleryTranslater::getSupportedLanguageCode($languageCode, $fallback=true) and it works. That sounds pretty reasonable to me. We want to synchronize with the CMS language whenever possible so we should be passing it through GalleryEmbed. |
|
valiant
Joined: 2003-01-04
Posts: 32509 |
![]() |
update: as usual, remove/reinstall the gallery2 module. |
|
valiant
Joined: 2003-01-04
Posts: 32509 |
![]() |
@xaraya: it looks like the discussion whether to add some update / delete hook extrainfo has come to an end and we will not get what we need. If we have such a ext_id in the galleryUser and galleryGroup classes/db tables, we have the free choice to synchronize on a userName / groupName mapping or on the ext_id, entityId mapping. I'm for it, it's done in a few minutes, G2 doesn't need any other changes than to add ext_id attibrute to GalleryUser and GalleryGroup and we're back in business. If we have ext_id in our GalleryUser and GalleryGroup objects, I'm for the loose coupled integration/synchronization that we do now and would say, we won't do the tight coupled on-the-fly-query translations integration. |
|
baschny
![]()
Joined: 2003-01-04
Posts: 328 |
![]() |
valiant, instead of adding that info into GalleryUser, why not extend GalleryUser in the xaraya-module to be created? Something like class XarayaUser extends GalleryUser { var $_xarayaId; ... } This would create a new G2-table for XarayaUsers. This way the same G2 install could be integrated in more than one CMS at the same time, just have multiple classes extending GalleryUser. Maybe sometime later another CMS needs to add more info to the GalleryUser, etc. |
|
bharat
![]()
Joined: 2002-05-21
Posts: 7994 |
![]() |
If we add the external id to the GalleryUser class, that'll mean that we can't be embedded into two different CMSen at the same time any more. Not that this is a bad thing (I can't envision a scenario where multiple embedding isn't going to lead to weirdness or disaster). Ernst, IIRC that Valiant considered and rejected extending GalleryUser earlier on in this thread (but maybe I'm mis-remembering)? Can one of you guys summarize the reasons why it's bad, again? I'm torn between a) thinking that the external id has no place in the core module, and b) realizing that it's the easiest possible way to get it into the code. I guess the right thing to do is to add it in core, but be willing to refactor it into its own module if necessary. |
|
valiant
Joined: 2003-01-04
Posts: 32509 |
![]() |
bharat, Ernst: There are two processes involved. For 2. we don't really need the ext_id, because userNames are unique and work perfectly in GalleryEmbed::handlerequest(). Now that we know that we need the ext_id <-> entityId mapping, we should ask us, if we don't want to handle everything (also 2.) with this map, just because it would be more unified. If I create a XarayaGalleryUser extends GalleryUser class, where should I do this? In the xaraya gallery2 module? In a embedding module in G2? And how would I register my factoryimplementation to make sure Gallery uses this class for all GalleryUser factory requests? However, we need this ext_id <-> entityId map, where should it go? Thanks |
|
mindless
![]()
Joined: 2004-01-04
Posts: 8601 |
![]() |
valiant, can you explain: |
|
valiant
Joined: 2003-01-04
Posts: 32509 |
![]() |
mindless, sure, sorry, didn't explain that. I have all hooks I need in xaraya. But the philosophy behind the hook calls is that they only inform you who called the hooks (which module) and which objects are involved. i.e. the roles (user, group management) calls the item update hook for role with itemid 15 and of itemtype 0. In case of update user / group hooks, we get the uid and itemtype. With the uid I can the updated data from the API. But I don't know the state before the update. How would the ext_id <-> entityId map fix the problem? |
|
mindless
![]()
Joined: 2004-01-04
Posts: 8601 |
![]() |
Got it, thanks. I thought about extending GalleryUser, and the problem with instantiating the extended class via the factory... I reached the conclusion that we probably don't want to do this, or allow any module to extend GalleryUser.. if any module extends GalleryUser (and modified the entityType of all existing users to the new type) then no other module can do the same, or it will break the first module. It seems better for other modules adding user data to maintain their own map, and not load the data along with the user entity.. then they can coexist. (Aside: maybe custom fields module should support additional user fields) I'm tempted by the suggestion to add externalId to GalleryUser, as this keeps GalleryEmbed from having any module dependency.. but then we'd have to do the same for GalleryGroup. Another possibility is to add a single map table (entityType, externalId, galleryId) that can map both users and groups (or anything else..). This could go in an external module, but again it's nice if it's in core so GalleryEmbed has no dependency. It can just call GalleryCoreApi::loadEntityByExternalId or something.. Comments? |
|
baschny
![]()
Joined: 2003-01-04
Posts: 328 |
![]() |
mindless, I like your suggestions, keeping the map "G2-id vs External-id" in the Core, but separated from GalleryUser. The only problem with that is that G2 can only be integrated in one CMS per G2-installation, but I think this is not a big problem. |
|
valiant
Joined: 2003-01-04
Posts: 32509 |
![]() |
mindless, good points. We can't allow modules to subclass GalleryUser. Or just allow it for this special case? Bad idea. For some external applications, the externalId may be an integer, for others a string (i.e. applications that don't have a uid integer field, but use the unique userName everywhere). And we can't just use a single map table entityId, externalId, because most applications have two sets of ids for groups and users. Having some functions of GalleryEmbed:: depend on a embedding module isn't that bad, is it? -> The extId fields: We could savely use a string field which would work for uid = integer and strings. |
|
baschny
![]()
Joined: 2003-01-04
Posts: 328 |
![]() |
valiant, instead of having CMS-dependant info in GalleryEmbed, I would rather make a separate CMS-module in Gallery. G2-core could provide an interface to this user/group/internal/external "mapping" functionality that GalleryEmbed can use and which each CMS-module could implement (as a map or however). |
|
mindless
![]()
Joined: 2004-01-04
Posts: 8601 |
![]() |
baschny, if we really wanted we could add an externalApp column in the map table, to allow multiple apps to add mappings. I'd rather not offer that support by default, but the (entityType, externalId, galleryId) setup does leave the door open for someone who wants to hack together multiple-app support... ie, if someone really wants to support a single G2 embedded in multiple apps they can alter their G2 to use strings like 'xaraya-GalleryUser' or 'wordpress-GalleryUser' as the "entityType" string... valiant, no, I guess a dependency on a module isn't that bad.. but, I haven't seen enough yet to convince me that we'll even have a CMS module in G2.. so if we put this map table in core and we don't need a cms module, great. If we decide we do need a cms module we can put the map table there. externalId: agreed, string type |
|
valiant
Joined: 2003-01-04
Posts: 32509 |
![]() |
mindless wrote:
One map table: entityType+externalId = primary key perhaps my logic module is already shut down due to alcohol abuse, but i disagree. the external app gives us the externalId and we should find the entityId that matches this externalId, right? As I said, the external application most probably has two different tables for users and groups and most probably has two sets of ids, one set for users, one for groups. You see, a "loadEntitiesByExtId($extId) doesn't work because there are two entries in your single map table that match externalId = "1". But: Here comes xaraya which can transform a groups into a users and users into groups just by clicking on a button in the admin panel. So, the second optional parameter, the hint, should be optional. loadEntitiesByExtIds($extIds, $hint=null) I agree, we only need one map table: entityId, externalId, galleryId (for baschny's mutli gallery install proposal?). But how do we get this entityId <-> extId map into the GalleryUser entity filesystem cached objects or into the session cache? mindless: why a cms module? just for the configs. i think this config flags would be very cool and putting them into the core, dunno... |
|
valiant
Joined: 2003-01-04
Posts: 32509 |
![]() |
uuh, ooh, new member title mindless, one of the xaraya devs (in contrary to 3 others, 'til now) thinks they should add the update / delete hook extrainfos we need. |
|