Conditions | 4 |
Paths | 6 |
Total Lines | 37 |
Code Lines | 22 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | public function hookItemAdded(HookPortfolioItemAddedEventInterface $hookEvent) |
||
13 | { |
||
14 | /** @var Portfolio $item */ |
||
15 | $item = $hookEvent->getEventData()['portfolio']; |
||
16 | $userId = api_get_user_id(); |
||
17 | $courseCode = api_get_course_id(); |
||
18 | |||
19 | $cidreq = api_get_cidreq(); |
||
20 | |||
21 | $url = api_get_path(WEB_CODE_PATH).'portfolio/index.php?'; |
||
22 | $url .= ($cidreq ? $cidreq.'&' : ''); |
||
23 | $url .= http_build_query(['action' => 'view', 'id' => $item->getId()]); |
||
24 | |||
25 | try { |
||
26 | $json = $this->doCreateRequest( |
||
27 | [ |
||
28 | 'user_id' => $userId, |
||
29 | 'course_code' => $courseCode, |
||
30 | 'content_id' => $item->getId(), |
||
31 | 'content_type' => 'eportfolio', |
||
32 | 'content_url' => $url, |
||
33 | 'post_title' => $item->getTitle(), |
||
34 | ] |
||
35 | ); |
||
36 | } catch (Exception $e) { |
||
37 | Display::addFlash( |
||
38 | Display::return_message($e->getMessage(), 'error') |
||
39 | ); |
||
40 | |||
41 | return; |
||
42 | } |
||
43 | |||
44 | if (empty($json)) { |
||
45 | return; |
||
46 | } |
||
47 | |||
48 | error_log('ExtNotifConn: Portfolio item created: ID '.$json['data']['notification_id']); |
||
49 | } |
||
51 |