/** * Get the current execution context * @return array */ public static function getCurrentContext() { $context = array(); if (claro_is_in_a_course()) { $context[CLARO_CONTEXT_COURSE] = claro_get_current_course_id(); } if (claro_is_in_a_group()) { $context[CLARO_CONTEXT_GROUP] = claro_get_current_group_id(); } if (claro_is_in_a_tool()) { if (isset($GLOBALS['tlabelReq']) && $GLOBALS['tlabelReq']) { $context[CLARO_CONTEXT_TOOLLABEL] = $GLOBALS['tlabelReq']; } if (claro_get_current_tool_id()) { $context[CLARO_CONTEXT_TOOLINSTANCE] = claro_get_current_tool_id(); } } if (get_current_module_label()) { $context[CLARO_CONTEXT_MODULE] = get_current_module_label(); } return $context; }
public function event($type, $args = null) { if (!is_array($args)) { $args = array(); } if (!array_key_exists('cid', $args) && claro_is_in_a_course()) { $args['cid'] = claro_get_current_course_id(); } if (!array_key_exists('gid', $args) && claro_is_in_a_group()) { $args['gid'] = claro_get_current_group_id(); } if (!array_key_exists('tid', $args) && claro_is_in_a_tool()) { $args['tid'] = claro_get_current_tool_id(); // $args['tlabel'] = get_current_module_label(); } if (!array_key_exists('uid', $args) && claro_is_user_authenticated()) { $args['uid'] = claro_get_current_user_id(); } if (!array_key_exists('date', $args)) { $args['date'] = claro_date("Y-m-d H:i:00"); } $this->notifyEvent($type, $args); }
/** * Function that removes the need to directly use is_courseAdmin global in * tool scripts. It returns true or false depending on the user's rights in * this particular course. * * @version 1.1, February 2004 * @return boolean true: the user has the rights to edit, false: he does not * @author Roan Embrechts * @author Patrick Cool */ function claro_is_allowed_to_edit() { if (claro_is_course_manager()) { $isAllowedToEdit = true; } else { if (claro_is_in_a_tool()) { $isAllowedToEdit = claro_is_allowed_tool_edit(); } else { $isAllowedToEdit = false; } } if (claro_is_display_mode_available()) { return $isAllowedToEdit && claro_get_tool_view_mode() != 'STUDENT'; } else { return $isAllowedToEdit; } }
if (claro_is_user_authenticated()) { //global events (can happen outside of courses too) $claroline->notification->addListener('course_deleted', 'modificationDelete'); } if (claro_is_user_authenticated() && claro_is_in_a_course()) { //global events IN COURSE only $claroline->notification->addListener('toollist_changed', 'modificationDefault'); $claroline->notification->addListener('introsection_modified', 'modificationDefault'); $claroline->notification->addListener('course_access', 'trackCourseAccess'); // todo : should move this event to initialisation of course context $claroline->notifier->event('course_access'); } if (claro_is_in_a_group()) { $claroline->notification->addListener('group_deleted', 'modificationDelete'); } if (claro_is_in_a_tool()) { // generic tool event $claroline->notification->addListener('tool_access', 'trackToolAccess'); // todo : should move this event to initialisation of tool context $claroline->notifier->event('tool_access'); // others load_current_module_listeners(); } /*---------------------------------------------------------------------- Prevent duplicate form submission ----------------------------------------------------------------------*/ // The code below is a routine to prevent duplicate form submission, for // example if the user clicks on the 'Refresh' or 'Back' button of his // browser. It will nullify all the variables posted to the server by the // form, provided this form complies to 2 points : //