/**
  * Returns a single resquested decsription.
  * @param array $args must contain 'resID' key with the resource identifier of the requested resource
  * @throws InvalidArgumentException if one of the paramaters is missing
  * @webservice{/module/MOBILE/CLANN/getSingleResource/cidReq/resId}
  * @ws_arg{Method,getSingleResource}
  * @ws_arg{cidReq,SYSCODE of requested cours}
  * @ws_arg{resID,Resource Id of requested resource}
  * @return announce object (can be null if not visible for the current user)
  */
 function getSingleResource($args)
 {
     $resourceId = isset($args['resID']) ? $args['resID'] : null;
     $cid = claro_get_current_course_id();
     if ($cid == null || $resourceId == null) {
         throw new InvalidArgumentException('Missing cid or resourceId argument!');
     }
     From::Module('CLCAL')->uses('agenda.lib');
     $claroNotification = Claroline::getInstance()->notification;
     $date = $claroNotification->getLastActionBeforeLoginDate(claro_get_current_user_id());
     $d = new DateTime($date);
     $d->sub(new DateInterval('P1D'));
     if ($item = agenda_get_item($resourceId, $cid)) {
         $notified = $claroNotification->isANotifiedRessource($cid, $date, claro_get_current_user_id(), claro_get_current_group_id(), get_tool_id_from_module_label('CLCAL'), $item['id'], false);
         $item['visibility'] = $item['visibility'] != 'HIDE';
         $item['content'] = trim(strip_tags($item['content']));
         $item['date'] = $item['day'] . ' ' . $item['hour'];
         $item['resourceId'] = $item['id'];
         if ($notified) {
             $item['notifiedDate'] = $date;
         }
         $item['seenDate'] = $d->format('Y-m-d');
         unset($item['id']);
         return claro_is_allowed_to_edit() || $item['visibility'] ? $item : null;
     } else {
         throw new RuntimeException('Resource not found', 404);
     }
 }
示例#2
0
文件: agenda.php 项目: rhertzog/lcs
     }
     if ($cmd == 'mkHide') {
         $visibility = 'HIDE';
         $eventNotifier->notifyCourseEvent('agenda_event_invisible', claro_get_current_course_id(), claro_get_current_tool_id(), $id, claro_get_current_group_id(), '0');
         // notify changes to event manager
         $autoExportRefresh = true;
     }
     agenda_set_item_visibility($id, $visibility);
 }
 /*------------------------------------------------------------------------
   EVENT EDIT
   --------------------------------------------------------------------------*/
 if ('rqEdit' == $cmd || 'rqAdd' == $cmd) {
     claro_set_display_mode_available(false);
     if ('rqEdit' == $cmd && !empty($id)) {
         $editedEvent = agenda_get_item($id);
         // get date as unixtimestamp for claro_dis_date_form and claro_html_time_form
         $editedEvent['date'] = strtotime($editedEvent['dayAncient'] . ' ' . $editedEvent['hourAncient']);
         $nextCommand = 'exEdit';
     } else {
         $editedEvent['id'] = '';
         $editedEvent['title'] = '';
         $editedEvent['content'] = '';
         $editedEvent['date'] = time();
         $editedEvent['lastingAncient'] = false;
         $editedEvent['location'] = '';
         $nextCommand = 'exAdd';
     }
     $display_form = true;
 }
 // end if cmd == 'rqEdit' && cmd == 'rqAdd'