예제 #1
0
    foreach ($courseToolList as $thisCourseTool) {
        $tmp[$thisCourseTool['label']] = $thisCourseTool['toolId'];
    }
    // 3. compare the two lists and register and install/activate missing tool if necessary
    $listOfToolsToAdd = array();
    foreach ($mainCourseToolList as $thisToolId => $thisMainCourseTool) {
        if (!array_key_exists($thisMainCourseTool['label'], $tmp)) {
            $listOfToolsToAdd[$thisMainCourseTool['label']] = $thisToolId;
        }
    }
    foreach ($listOfToolsToAdd as $toolLabel => $toolId) {
        if (!is_module_registered_in_course($toolId, $_cid)) {
            register_module_in_single_course($toolId, $_cid);
        }
        if (!is_module_installed_in_course($toolLabel, $_cid) && 'AUTOMATIC' == get_module_data($toolLabel, 'add_in_course')) {
            install_module_in_course($toolLabel, $_cid);
        }
        if ('AUTOMATIC' == get_module_data($toolLabel, 'add_in_course')) {
            if ('activated' == get_module_data($toolLabel, 'activation')) {
                update_course_tool_activation_in_course($toolId, $_cid, true);
                set_module_visibility_in_course($toolId, $_cid, true);
            }
        }
    }
}
/*---------------------------------------------------------------------------
  Course / tool relation initialisation
 ---------------------------------------------------------------------------*/
// if the requested tool is different from the current tool in session
// (special request can come from the tool id, or the tool label)
if ($tidReq && $tidReq != $_SESSION['_tid'] || $tlabelReq && (!isset($_SESSION['_courseTool']['label']) || $tlabelReq != $_SESSION['_courseTool']['label'])) {
예제 #2
0
/**
 * build the rss file and place it in directory
 *
 * @param array $context context of claroline
 * @param string $calType : ics,xcs,rdf
 * @return string ical file path
 */
function buildICal($context, $calType = 'ics')
{
    if (is_array($context) && count($context) > 0) {
        $iCalRepositorySys = get_path('rootSys') . get_conf('iCalRepositoryCache', 'tmp/cache/iCal/');
        if (!file_exists($iCalRepositorySys)) {
            require_once dirname(__FILE__) . '/fileManage.lib.php';
            claro_mkdir($iCalRepositorySys, CLARO_FILE_PERMISSIONS, true);
            if (!file_exists($iCalRepositorySys)) {
                claro_failure::set_failure('CANT_CREATE_ICAL_DIR');
            }
        }
        $iCal = (object) new iCal('', 0, $iCalRepositorySys);
        // (ProgrammID, Method (1 = Publish | 0 = Request), Download Directory)
        $toolLabelList = ical_get_tool_compatible_list();
        foreach ($toolLabelList as $toolLabel) {
            if (is_tool_activated_in_course(get_tool_id_from_module_label($toolLabel), $context[CLARO_CONTEXT_COURSE])) {
                if (!is_module_installed_in_course($toolLabel, $context[CLARO_CONTEXT_COURSE])) {
                    install_module_in_course($toolLabel, $context[CLARO_CONTEXT_COURSE]);
                }
                $icalToolLibPath = get_module_path($toolLabel) . '/connector/ical.write.cnr.php';
                $icalToolFuncName = $toolLabel . '_write_ical';
                if (file_exists($icalToolLibPath)) {
                    require_once $icalToolLibPath;
                    if (function_exists($icalToolFuncName)) {
                        $iCal = call_user_func($icalToolFuncName, $iCal, $context);
                    }
                }
            }
        }
        $iCalFilePath = $iCalRepositorySys;
        if (array_key_exists(CLARO_CONTEXT_COURSE, $context)) {
            $iCalFilePath .= $context[CLARO_CONTEXT_COURSE] . '.';
        }
        if (array_key_exists(CLARO_CONTEXT_GROUP, $context)) {
            $iCalFilePath .= 'g' . $context[CLARO_CONTEXT_GROUP] . '.';
        }
        if ('ics' == $calType || get_conf('iCalGenStandard', true)) {
            $stdICalFilePath = $iCalFilePath . 'ics';
            if (false !== ($fpICal = @fopen($stdICalFilePath, 'w'))) {
                fwrite($fpICal, $iCal->getOutput('ics'));
                fclose($fpICal);
            }
        }
        if ('xcs' == $calType || get_conf('iCalGenXml', true)) {
            $xmlICalFilePath = $iCalFilePath . 'xml';
            if (false !== ($fpICal = @fopen($xmlICalFilePath, 'w'))) {
                fwrite($fpICal, $iCal->getOutput('xcs'));
                fclose($fpICal);
            }
        }
        if ('rdf' == $calType || get_conf('iCalGenRdf', false)) {
            $rdfICalFilePath = $iCalFilePath . 'rdf';
            if (false !== ($fpICal = @fopen($rdfICalFilePath, 'w'))) {
                fwrite($fpICal, $iCal->getOutput('rdf'));
                fclose($fpICal);
            }
        }
        switch ($calType) {
            case 'xcs':
                return $xmlICalFilePath;
                break;
            case 'rdf':
                return $rdfICalFilePath;
                break;
            default:
                return $stdICalFilePath;
                break;
        }
    }
    return false;
}
예제 #3
0
파일: dock.lib.php 프로젝트: rhertzog/lcs
 public function render()
 {
     $claro_buffer = new ClaroBuffer();
     $claro_buffer->append("\n" . '<!-- ' . $this->name . ' -->' . "\n");
     foreach ($this->appletList as $applet) {
         set_current_module_label($applet['label']);
         pushClaroMessage('Current module label set to : ' . get_current_module_label(), 'debug');
         // install course applet
         if (claro_is_in_a_course()) {
             install_module_in_course($applet['label'], claro_get_current_course_id());
         }
         if ($applet['activation'] == 'activated' && file_exists($applet['path'])) {
             load_module_config();
             Language::load_module_translation();
             if ($this->useList() && count($this->appletList) > 0) {
                 $claro_buffer->append("<li\n                        id=\"dock-" . $this->name . "-applet-" . $applet['label'] . "\"\n                        class=\"applet dock-" . $this->name . " applet-" . $applet['label'] . "\"><span>\n");
             } else {
                 $claro_buffer->append("<span\n                        id=\"dock-" . $this->name . "-applet-" . $applet['label'] . "\"\n                        class=\"applet dock-" . $this->name . " applet-" . $applet['label'] . "\">\n");
             }
             include_once $applet['path'];
             if ($this->useList() && count($this->appletList) > 0) {
                 $claro_buffer->append("\n</span></li>\n");
             } else {
                 $claro_buffer->append("\n</span>\n");
             }
         } else {
             Console::debug("Applet not found or not activated : " . $applet['label']);
         }
         clear_current_module_label();
         pushClaroMessage('Current module label set to : ' . get_current_module_label(), 'debug');
     }
     $claro_buffer->append("\n" . '<!-- End of ' . $this->name . ' -->' . "\n");
     return $claro_buffer->getContent();
 }
예제 #4
0
파일: manage.lib.php 프로젝트: rhertzog/lcs
/**
 * 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;
    }
}
예제 #5
0
function build_rss($context)
{
    if (is_array($context) && count($context) > 0) {
        $rss = new UniversalFeedCreator();
        if (array_key_exists(CLARO_CONTEXT_COURSE, $context)) {
            // $rssFilePath .= $context[CLARO_CONTEXT_COURSE] . '.';
            $_course = claro_get_course_data($context[CLARO_CONTEXT_COURSE]);
            $rss->title = '[' . get_conf('siteName') . '] ' . $_course['officialCode'];
            $rss->description = $_course['name'];
            $rss->editor = $_course['titular'] == '' ? get_conf('administrator_name') : $_course['titular'];
            $rss->editorEmail = $_course['email'] == '' ? get_conf('administrator_email') : $_course['email'];
            $rss->link = get_path('rootWeb') . get_path('coursesRepositoryAppend') . claro_get_course_path();
            $rss->generator = 'Feedcreator';
            if (array_key_exists(CLARO_CONTEXT_GROUP, $context)) {
                // $rssFilePath .= 'g'.$context[CLARO_CONTEXT_GROUP] . '.';
                $rss->title .= '[' . get_lang('Group') . $context[CLARO_CONTEXT_GROUP] . ']';
                $rss->description .= get_lang('Group') . $context[CLARO_CONTEXT_GROUP];
            }
        } else {
            $rss->title = '[' . get_conf('siteName') . '] ' . $_course['officialCode'];
            $rss->description = $_course['name'];
            $rss->editor = get_conf('administrator_name');
            $rss->editorEmail = get_conf('administrator_email');
            $rss->link = get_path('rootWeb');
        }
        $rss->language = get_locale('iso639_1_code');
        $rss->docs = 'http://blogs.law.harvard.edu/tech/rss';
        $rss->pubDate = date("r", time());
        $toolLabelList = rss_get_tool_compatible_list();
        //var_dump($toolLabelList);
        $rssItems = array();
        foreach ($toolLabelList as $toolLabel) {
            /*var_dump(is_tool_activated_in_course(
                  get_tool_id_from_module_label( $toolLabel ),
                  $context[CLARO_CONTEXT_COURSE]
              ));*/
            if (is_tool_activated_in_course(get_tool_id_from_module_label($toolLabel), $context[CLARO_CONTEXT_COURSE])) {
                if (!is_module_installed_in_course($toolLabel, $context[CLARO_CONTEXT_COURSE])) {
                    install_module_in_course($toolLabel, $context[CLARO_CONTEXT_COURSE]);
                }
                $rssToolLibPath = get_module_path($toolLabel) . '/connector/rss.write.cnr.php';
                $rssToolFuncName = $toolLabel . '_write_rss';
                if (file_exists($rssToolLibPath)) {
                    include_once $rssToolLibPath;
                    if (function_exists($rssToolFuncName)) {
                        $rssItems = array_merge($rssItems, call_user_func($rssToolFuncName, $context));
                    }
                }
            }
        }
        $sortDate = array();
        foreach ($rssItems as $key => $rssItem) {
            $sortDate[$key] = $rssItem['pubDate'];
        }
        // die(var_export($sortDate, true));
        array_multisort($sortDate, SORT_DESC, $rssItems);
        foreach ($rssItems as $rssItem) {
            $item = new FeedItem();
            $item->title = claro_utf8_encode($rssItem['title'], get_conf('charset'));
            $item->description = claro_utf8_encode($rssItem['description']);
            $item->category = $rssItem['category'];
            $item->guid = $rssItem['guid'];
            $item->link = $rssItem['link'];
            $item->date = $rssItem['pubDate'];
            $rss->addItem($item);
        }
        return $rss->outputFeed("RSS2.0");
    }
    return false;
}