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) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • who am I? is there a better way?
Pages: [1]

Author Topic: who am I? is there a better way?  (Read 595 times)

Erich Schulz

  • I post frequently
  • ***
  • Posts: 142
  • Karma: 5
    • When no-one understands what you are going on about its time to start a blog
  • CiviCRM version: 4.4
  • CMS version: Drupal 7
  • MySQL version: 5.somthing
  • PHP version: 5.3.3
who am I? is there a better way?
August 09, 2011, 05:39:42 pm
this is my hack, but doesn't smell right to me!
Code: [Select]
  /**
   * Supplies current CiviCRM user ID
   * @return int
   */
  static public function myCiviID() {
    return $_SESSION['CiviCRM']['userID'];
  }

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: who am I? is there a better way?
August 09, 2011, 05:46:01 pm

Code: [Select]
/**
   * Supplies current CiviCRM user ID
   * @return int
   */
  static public function myCiviID() {
     $session =& CRM_Core_Session::singleton( );
     return $session->get( 'userID' );
   }
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Erich Schulz

  • I post frequently
  • ***
  • Posts: 142
  • Karma: 5
    • When no-one understands what you are going on about its time to start a blog
  • CiviCRM version: 4.4
  • CMS version: Drupal 7
  • MySQL version: 5.somthing
  • PHP version: 5.3.3
Re: who am I? is there a better way?
August 10, 2011, 01:24:53 am
thank Lobo!

@xavier, it would be great if the api took a slightly broader view of things and included things like:

- who am i
- run sql (he he)
- checking permissions
- etc etc

wouldn't it?

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: who am I? is there a better way?
August 10, 2011, 01:34:21 am
Quote
- who am i
This is probably more the realm of philosophy than api ;), but UFMatch.get let you find the drupal user id based on the contact id and vice versa

http://drupal.demo.civicrm.org/civicrm/ajax/doc#/civicrm/ajax/rest?json=1&debug=1&version=3&entity=UFMatch&action=get&uf_id=1&sequential=1

Quote
(as an aside, UFMatch is probably a terrible name indeed for that ;)
Quote
- run sql (he he)
Not sure what would be the benefit over calling directly the dao->query
I really really wouldn't want a user being able to run sql commands directly from the web using the rest and ajax interface

Quote
- checking permissions
we got helper functions already to do that (when you develop an api). You had in mind being able to expose them to a client using the api?

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Erich Schulz

  • I post frequently
  • ***
  • Posts: 142
  • Karma: 5
    • When no-one understands what you are going on about its time to start a blog
  • CiviCRM version: 4.4
  • CMS version: Drupal 7
  • MySQL version: 5.somthing
  • PHP version: 5.3.3
Re: who am I? is there a better way?
August 12, 2011, 09:01:38 pm
Xavier,

I think the trouble is when you say 'API' it means something different to when I say it...

I just has quick look at wikipedia - the source of all truth ;-)  - but i couldn't a quick scan find a summary of my point. For what its work it says:

Quote
"An application programming interface (API) is a particular set of rules ('code') and specifications that software programs can follow to communicate with each other. It serves as an interface between different software programs and facilitates their interaction, similar to the way the user interface facilitates interaction between humans and computers."

That list of functions I gave are the services I'm after as a php programmer and are an important part of the interface between civicrm and the rest of the world... my problem is I can't find the documentation for them!!! ie what is 'best practice'? and what is a 'hack'? how do I write code to interact with civicrm that will be stable into the future?

This is not to disrespect the V3 api - as I've said before it's great and very cool, but it's only part of the interface a typical programmer needs to get things done

just my 2cw

;-)

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • who am I? is there a better way?

This forum was archived on 2017-11-26.