function _opigno_tincan_api_set_actor in Opigno TinCan API 7
Add the current user as the actor of this statement
Parameters
\TinCan\Statement $statement The statement to add the actor:
3 calls to _opigno_tincan_api_set_actor()
- opigno_tincan_api_openbadges_statements_opigno_openbadge_assertion_created in modules/
opigno_tincan_api_openbadges_statements/ opigno_tincan_api_openbadges_statements.module - Implements hook_opigno_openbadge_assertion_created().
- opigno_tincan_api_opigno_statements_opigno_course_passed in modules/
opigno_tincan_api_opigno_statements/ opigno_tincan_api_opigno_statements.module - _opigno_tincan_api_statement_base_creation in includes/
opigno_tincan_api.statements_func.inc - This function will add the current user as the actor, the verb selected in parameter, the object based on the node given in parameter and the timestamp based on the current time.
File
- includes/
opigno_tincan_api.statements_func.inc, line 9
Code
function _opigno_tincan_api_set_actor(TinCan\Statement &$statement, $user = null) {
if (!_opigno_tincan_api_tincanphp_is_installed()) {
return false;
}
if ($user === null) {
global $user;
}
else {
if (empty($user) || empty($user->name) || empty($user->mail)) {
throw new Exception('The user given was not loaded');
}
}
$actor = new TinCan\Agent(array(
'name' => $user->name,
'mbox_sha1sum' => sha1('mailto:' . $user->mail),
));
$statement
->setActor($actor);
}