Exemple #1
0
/**
 * Change the activation status for the given tool in the given course
 * @param int $toolId main tool id
 * @param string $courseId
 * @param boolean $activated
 * @return boolean
 */
function update_course_tool_activation_in_course($toolId, $courseId, $activated)
{
    if ($activated && !course_tool_already_installed($toolId, $courseId)) {
        $tLabel = get_module_label_from_tool_id($toolId);
        if ($tLabel) {
            if (!is_tool_registered_in_course($toolId, $courseId)) {
                register_module_in_single_course($toolId, $courseId);
            }
            install_module_in_course($tLabel, $courseId);
            update_tool_installation_in_course($toolId, $courseId);
        }
    }
    $sql_activated = $activated ? "'true'" : "'false'";
    $tbl_cdb_names = claro_sql_get_course_tbl(claro_get_course_db_name_glued($courseId));
    $tblCourseToolList = $tbl_cdb_names['tool'];
    $sql = "UPDATE `{$tblCourseToolList}`\n" . "SET `activated` = " . $sql_activated . "\n" . "WHERE tool_id = " . (int) $toolId;
    if (claro_sql_query($sql)) {
        return claro_sql_affected_rows();
    } else {
        false;
    }
}
 /**
  * Retrieve the notified items for the current user. Do not mark them as showed.
  * @webservice{/module/MOBILE/User/getUpdates}
  * @ws_arg{Method, getUpdates}
  * @return empty array if no notification.
  * 		   Else, return array([SYSCODE] => array([LABEL] => notified resource object, ...), ...)
  */
 function getUpdates($args)
 {
     $claroNotification = Claroline::getInstance()->notification;
     $date = isset($args['date']) ? $args['date'] : $claroNotification->getLastActionBeforeLoginDate(claro_get_current_user_id());
     $gid = 0;
     $result = array();
     foreach ($claroNotification->getNotifiedCourses($date, claro_get_current_user_id()) as $cid) {
         foreach ($claroNotification->getNotifiedTools($cid, $date, claro_get_current_user_id()) as $tid) {
             $result[$cid][get_module_label_from_tool_id($tid)] = $claroNotification->getNotifiedRessources($cid, $date, claro_get_current_user_id(), $gid, $tid);
         }
     }
     return $result;
 }