Shibbolet "data modification api"

Shibbolet "data modification api"

by Filippo Carnevali -
Number of replies: 7

Does anyone has any experience with it?

I've found nothing, neither in the readme.txt, nor online. Am I missing something? smile

Filippo

Average of ratings: -
In reply to Filippo Carnevali

Re: Shibboleth "data modification api"

by Sara Cenni -

Hi Filippo!

Are you trying to use data manipulation hook?


In reply to Sara Cenni

Re: Shibboleth "data modification api"

by Filippo Carnevali -

yep! smile

In reply to Filippo Carnevali

Re: Shibboleth "data modification api"

by Sara Cenni -

In readme.txt you can find an example at line 206.


BTW you need to create a PHP file where you need to use array $result.

For example if you want to set department field you need to use $result["department"] ='Something' or you can use shibboleth attribute in this way $address = $_SERVER[$this->config->field_map_address];

If you explain more in detail what you want to do I can try to help you.



In reply to Sara Cenni

Re: Shibboleth "data modification api"

by Filippo Carnevali -
First of all thanks a lot for the reply!

What i'm trying to achive is to assign some profile data values to the incoming users. For example

user1 log in with shibbolet into moodle and I have on moodle (or on a csv file) user1 building, security level, nature of the risk he's exposed during work hours. (profile_field_securitylevel, profile_field_risktype, profile_field_building)

I'd like to assign my user1 from shibboleth with the informations I have about him. 
In reply to Filippo Carnevali

Re: Shibboleth "data modification api"

by Sara Cenni -

If you want to use custom fields you can't use $user->profile_field_building='something' because you can use only user fields.

You can try this solution:

  1. when the user log in search in csv file if the user exists in the file.
  2. if you have found informations about him you have to insert them with a query
  3. I've used update_record (http://docs.moodle.org/dev/Data_manipulation_API#Updating_Records
  4. in my case I need to set a custom field "Matricola" 

 $fieldid = $DB->get_field('user_info_field', 'id', array('shortname' => 'matricola')); 
            if (isset($fieldid)) {
                $info = $DB->get_record('user_info_data', array("userid" => $user->id, "fieldid" => $fieldid));
                if ($info) {
                    $info->data = $matr;
                    $DB->update_record('user_info_data', $info, false);
                } else {
                    $record = new stdClass();
                    $record->userid = $user->id;
                    $record->fieldid = $fieldid;
                    $record->data = $matr;
                    $id = $DB->insert_record('user_info_data', $record, true);
                }
            }

I hope it will help you!

Average of ratings: Useful (1)