Exemplo n.º 1
0
function create_wiki($gid = false, $wikiName = 'New wiki')
{
    $creatorId = claro_get_current_user_id();
    $tblList = claro_sql_get_course_tbl();
    $config = array();
    $config["tbl_wiki_properties"] = $tblList["wiki_properties"];
    $config["tbl_wiki_pages"] = $tblList["wiki_pages"];
    $config["tbl_wiki_pages_content"] = $tblList["wiki_pages_content"];
    $config["tbl_wiki_acls"] = $tblList["wiki_acls"];
    $con = Claroline::getDatabase();
    $acl = array();
    if ($gid) {
        $acl = WikiAccessControl::defaultGroupWikiACL();
    } else {
        $acl = WikiAccessControl::defaultCourseWikiACL();
    }
    $wiki = new Wiki($con, $config);
    $wiki->setTitle($wikiName);
    $wiki->setDescription('This is a sample wiki');
    $wiki->setACL($acl);
    $wiki->setGroupId($gid);
    $wikiId = $wiki->save();
    $wikiTitle = $wiki->getTitle();
    $mainPageContent = sprintf("This is the main page of the Wiki %s. Click on edit to modify the content.", $wikiTitle);
    $wikiPage = new WikiPage($con, $config, $wikiId);
    $wikiPage->create($creatorId, '__MainPage__', $mainPageContent, date("Y-m-d H:i:s"), true);
}
Exemplo n.º 2
0
         $wikiDesc = $wiki->getDescription();
         $wikiACL = $wiki->getACL();
         $groupId = $wiki->getGroupId();
     } else {
         $message = get_lang("Invalid Wiki Id");
         $action = 'error';
     }
     break;
     // execute edit
 // execute edit
 case 'exEdit':
     if ($wikiId == 0) {
         $wiki = new Wiki($con, $config);
         $wiki->setTitle($wikiTitle);
         $wiki->setDescription($wikiDesc);
         $wiki->setACL($wikiACL);
         $wiki->setGroupId($groupId);
         $wikiId = $wiki->save();
         //notify wiki modification
         $eventNotifier->notifyCourseEvent('wiki_added', claro_get_current_course_id(), claro_get_current_tool_id(), $wikiId, claro_get_current_group_id(), '0');
         $mainPageContent = sprintf(get_lang("This is the main page of the Wiki %s. Click on '''Edit''' to modify the content."), $wikiTitle);
         $wikiPage = new WikiPage($con, $config, $wikiId);
         if ($wikiPage->create($creatorId, '__MainPage__', $mainPageContent, date("Y-m-d H:i:s"), true)) {
             $message = get_lang("Wiki creation succeed");
             $dialogBox->success($message);
         } else {
             $message = get_lang("Wiki creation failed");
             $dialogBox->error($message . ":" . $wikiPage->getError());
         }
     } elseif ($wikiStore->wikiIdExists($wikiId)) {
         $wiki = $wikiStore->loadWiki($wikiId);