CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • General Discussion (please no support requests here!) (Moderator: Michał Mach) »
  • Bridge Application in PHP - Joomla Users to Civicrm_phonecalls
Pages: [1]

Author Topic: Bridge Application in PHP - Joomla Users to Civicrm_phonecalls  (Read 10197 times)

kenlyle

  • I post occasionally
  • **
  • Posts: 116
  • Karma: 7
Bridge Application in PHP - Joomla Users to Civicrm_phonecalls
January 28, 2008, 05:33:41 pm
I've created a little PHP application that can use the Joomla 1.0.13 tables for login (thanks to some hacking by Craig Smith of joomla-host.co.za), and allows viewing all records in the civicrm_phonecalls table, and editing one's own records.

There are some messy details yet, with matching the Joomla IDs of the user with his/her CiviID, but should be easy enough to overcome, if there is interest.

If so, I will try to package it up...

Thanks,

Ken

geilhufe

  • I post frequently
  • ***
  • Posts: 293
  • Karma: 33
    • Social Source Software
Re: Bridge Application in PHP - Joomla Users to Civicrm_phonecalls
January 28, 2008, 07:07:45 pm
Awesome contribution. Thank you.
Drupal and CiviCRM consulting, strategy and configuration
http://www.social-source.com/

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Bridge Application in PHP - Joomla Users to Civicrm_phonecalls
January 29, 2008, 05:46:47 pm
Ken - Can you describe how you're using this a bit? I think that would help others see if / how it could be useful for their organizations / sites.
Protect your investment in CiviCRM by  becoming a Member!

kenlyle

  • I post occasionally
  • **
  • Posts: 116
  • Karma: 7
Re: Bridge Application in PHP - Joomla Users to Civicrm_phonecalls
January 30, 2008, 04:10:31 am
It's really simplistic at this point, a PHP generator run against the civicrm_phonecalls table generates a login screen and enforces "view all records, edit your own".  Craig hacked the login.php to allow access to the jos_users table.

I added a CiviID field to jos_users, because I am not good enough at PHP to use a query against civicrm_uf_match to get the CiviID.  I instruct my users to login to Joomla, then click their Civi profile link, which creates the record in civicrm_uf_match.  Unfortunately, I am the "cron".  Every so often, I run a query via Access that updates the CiviID in jos_users.

So, the 3 attached screen snaps are: list view, detail view, and the what the record looks like in the Civi backend.  Some of the "excess" (mostly Foreign Key) fields in the detail view are there because some of them need a value, even though, for this purpose, I don't really need to know on which number a legislator was called.  I haven't understood yet which fields I might be able to default to "1" or something.  Obviously, I am trying not to hack the Civi schema.  The Constituent field is not needed, and shouldn't be there, because it's actually looked up by the code from jos_users.civiid.

The point is that frontend users of the CMS can record CRM activity relative to the contacts, who could be prospects, donors, voters, or legislators.

I am planning on enhancing and packaging this thing, given time, so that more capable people can work on it.  Hope that helps.

Ken




mcsmom

  • I post frequently
  • ***
  • Posts: 266
  • Karma: 23
    • Official Joomla! Book
  • CiviCRM version: 4 and 3.4
  • CMS version: Joomla!
Re: Bridge Application in PHP - Joomla Users to Civicrm_phonecalls
March 12, 2008, 04:08:44 am
In 1.5 there is a great plugin usermeta
http://joomlacode.org/gf/project/usermeta/

that makes it very easy to extend the user record, no hacking required.

kenlyle

  • I post occasionally
  • **
  • Posts: 116
  • Karma: 7
Re: Bridge Application in PHP - Joomla Users to Civicrm_phonecalls
March 12, 2008, 04:36:19 am
Thanks, but I am not clear how that helps.  Maybe adding the CiviID to the Joomla user record?
The really sticky part as I understand it was un-salting the Joomla password for reversing the MD5 to enable using the Joomla login for the application I created, which opens up the PhoneCalls table to all Joomla users.

There is likely some high level solution, like OpenID, or LDAP, or one of the other authentication methods available in the two CMS that are supported.  I am hoping that someone will shed some light on that.

It seems that lots of orgs that try to use Civi find it daunting technically, so it seems likely that it would be good to have both a low-end, low-impact "point" solution, as well as a more technical "strategic" solution (for synchronizing or sharing login credentials).

Best,
Ken

mcsmom

  • I post frequently
  • ***
  • Posts: 266
  • Karma: 23
    • Official Joomla! Book
  • CiviCRM version: 4 and 3.4
  • CMS version: Joomla!
Re: Bridge Application in PHP - Joomla Users to Civicrm_phonecalls
March 12, 2008, 05:02:05 am
1.5 supports openid, ldap and gmail authentication.

Yes you can use metauser to add civiid to the jos_users record

lcdweb

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1620
  • Karma: 116
    • www.lcdservices.biz
  • CiviCRM version: many versions...
  • CMS version: Joomla/Drupal
  • MySQL version: 5.1+
  • PHP version: 5.2+
Re: Bridge Application in PHP - Joomla Users to Civicrm_phonecalls
March 13, 2008, 06:58:25 am
thanks for the tip on meta user. it's not showing up in JED though -- maybe because it's still in beta? looks like an intriguing extension.

Re: this bridge application --
It would be worth working out the query using the UF tables, as that should eliminate your need for manual syncing.

Another Joomla tool worth looking at is Logos Query Manager (for 1.5). It's a very robust query/report/form building tool, and may help you create some of these applications that merge Joomla and CiviCRM for end users without needing to do custom coding. I was just introduced to it, but it helped me overcome the lack of useful reports in VirtueMart. I haven't yet used it with CiviCRM, but seeing its flexibility with VM made me anxious to find some uses with Civi.

-Brian
support CiviCRM through 'make it happen' initiatives!
http://civicrm.org/mih

kenlyle

  • I post occasionally
  • **
  • Posts: 116
  • Karma: 7
Re: Bridge Application in PHP - Joomla Users to Civicrm_phonecalls
March 13, 2008, 07:33:41 am
Hey Brian and MCSmom...good tips.

However, I believe that there is no way to use the UF tables for login, because the one I am familiar with, I believe it's civicrm_uf_match, is just basically a relation between the Joomla ID, say 63, and the civi_id, say 5.  You still need to authenticate against a username and password field, seems to me, and those are in jos_users.  The code that Craig wrote allows that, in spite of the new password encryption scheme in Joomla since 1.0.13.  That seems valuable.

Eliminating manual synching, or even the requirement that the user click his/her profile while logged in to Joomla would be a nice advance, but I think that's been avoided because it's a hack of the Joomla files, whereas the kludge doesn't require any hacking.

Funny about VirtueMart, I did a custom report in PHPRunner to allow easier inventory updates, showing all items on a single page.

Can anyone see how metauser might actually be implemented?  It seems that it would be best to let Civi generate the uf_match record, and then grab the value for the civi_id and put it into the custom metauser field, then what?  A core hack of the Joomla login process or a call to the Civi code to set the Civi session variables based on the metauser field?

Thanks for thoughts...
Ken

lcdweb

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1620
  • Karma: 116
    • www.lcdservices.biz
  • CiviCRM version: many versions...
  • CMS version: Joomla/Drupal
  • MySQL version: 5.1+
  • PHP version: 5.2+
Re: Bridge Application in PHP - Joomla Users to Civicrm_phonecalls
March 13, 2008, 07:57:28 am
Maybe I misunderstood --

What I thought you were doing was wanting to expose some CiviCRM records to your end user -- namely the phone activity list. So when UserA logs in through Joomla, you needed to identify their corresponding CiviCRM contact ID in order to be able to query the CiviCRM tables and pull just their phone activity logs.

So what you did was add a field to jos_users to hold the individuals CiviCRM id, and create a sync script/query in Access that will grab the CiviCRM id and populate jos_users. That way you're able to grab the person's CiviCRM id and query the activity log once they are logged in.

What I was suggesting with the UF tables is rather than try to sync the CiviCRM id back to jos_users, create a query find the users corresponding CiviCRM id through the UF (since the purpose of the UF tables is to create that match).

However, *IF* my understanding is correct, you may be able to handle all  this using a profile form. I don't use activities in CiviCRM that much, but I'm pretty sure those fields are available to you in the profile groups. You could create a list profile and a form profile, so that the user can view their phone activities and add to the list.

...I may be way off here in my understanding of what you're trying to do...
support CiviCRM through 'make it happen' initiatives!
http://civicrm.org/mih

kenlyle

  • I post occasionally
  • **
  • Posts: 116
  • Karma: 7
Re: Bridge Application in PHP - Joomla Users to Civicrm_phonecalls
March 13, 2008, 08:44:07 am
Hey Brian,

Yeah, you understood the objective correctly.

Quote from: lcdweb on March 13, 2008, 07:57:28 am
Maybe I misunderstood --
What I thought you were doing was wanting to expose some CiviCRM records to your end user -- namely the phone activity list. So when UserA logs in through Joomla, you needed to identify their corresponding CiviCRM contact ID in order to be able to query the CiviCRM tables

Yes.

Quote from: lcdweb on March 13, 2008, 07:57:28 am
and pull just their phone activity logs.

Not quite.  I had the PHPRunner application generate security code based on a setting: "user can SEE other people's records, and EDIT his own".  I don't believe that Civi has record level security/ownership...that might be in 2.2 or 2.3, according to what Lobo has posted elsewhere.

This is potentially far superior, for group actions, to just being able to see one's own records.  See below.

Quote from: lcdweb on March 13, 2008, 07:57:28 am
So what you did was add a field to jos_users to hold the individuals CiviCRM id, and create a sync script/query in Access that will grab the CiviCRM id and populate jos_users. That way you're able to grab the person's CiviCRM id and query the activity log once they are logged in.

Yep, "Update Jos_Users with Civi_Contact_ID" is the Access query, which is:
"UPDATE civicrm_uf_match INNER JOIN jos_users ON civicrm_uf_match.uf_id = jos_users.id SET jos_users.civiid = [contact_id]
WHERE (((jos_users.civiid)=0));"

I did that because PHPRunner will automatically create environment(?) variables in PHP, including the civiid, which I can then use for the record level security.

Quote from: lcdweb on March 13, 2008, 07:57:28 am
What I was suggesting with the UF tables is rather than try to sync the CiviCRM id back to jos_users, create a query find the users corresponding CiviCRM id through the UF (since the purpose of the UF tables is to create that match).

Um, yeah, and duh - it's an ugly kludge, because I can't do the PHP.  I would just have to have the PHP code to do the lookup and assign the variable.  PHPRunner does most of this for me, and using a field for security is a standard feature.  If you can do the PHP, I would be happy to test it.

Quote from: lcdweb on March 13, 2008, 07:57:28 am
However, *IF* my understanding is correct, you may be able to handle all  this using a profile form. I don't use activities in CiviCRM that much, but I'm pretty sure those fields are available to you in the profile groups. You could create a list profile and a form profile, so that the user can view their phone activities and add to the list.

I like my way better.  The user can see what others are doing, and see which prospects/legislators/neighbors/activists have not been contacted, which are on the fence, etc. and target their actions intelligently based on that information.  As the use case develops, it would likely be good to expose other tables, but phone_calls seems good as a proof of concept.

Besides, are you talking about one profile per user, based on groups of one user?  That might just be kludgier than what I have done, if the fields are available for profile filtration.

Let me know if you have an idea on hacking the PHPRunner security scheme to use a variable looked up from a separate table rather than from the login table, jos_users.  Remember that the code should fail politely if the Civi id doesn't exist in uf_match, and, preferably, should activate the creation of the uf_match record.

So I think that it's as simple and compartmentalized as it can be, with each piece doing its own function, with no hacking of anything, so it's clean that way...it's just not elegant.  The code generator generates the application, so it's efficient, too...I think 100K of code in under a minute.

Thanks,
Ken

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • General Discussion (please no support requests here!) (Moderator: Michał Mach) »
  • Bridge Application in PHP - Joomla Users to Civicrm_phonecalls

This forum was archived on 2017-11-26.