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); }
/** * Generate html code of Wiki properties edit form * @param int wikiId ID of the wiki * @param string title wiki tile * @param string desc wiki description * @param int groupId id of the group the wiki belongs to * (0 for a course wiki) * @param array acl wiki access control list * @param string script callback script url * @return string html code of the wiki properties form */ function claro_disp_wiki_properties_form($wikiId = 0, $title = '', $desc = '', $groupId = 0, $acl = null, $script = null) { global $langWikiDescriptionForm, $langWikiDescriptionFormText, $langWikiTitle, $langWikiDescription, $langWikiAccessControl, $langWikiAccessControlText, $langWikiCourseMembers, $langWikiGroupMembers, $langWikiOtherUsers, $langWikiOtherUsersText, $langWikiReadPrivilege, $langWikiEditPrivilege, $langWikiCreatePrivilege, $langCancel, $langSave, $langBack, $course_code; $title = $title != '' ? $title : ''; $desc = $desc != '' ? $desc : ''; if (is_null($acl) && $groupId == 0) { $acl = WikiAccessControl::defaultCourseWikiACL(); } elseif (is_null($acl) && $groupId != 0) { $acl = WikiAccessControl::defaultGroupWikiACL(); } // process ACL $group_read_checked = $acl['group_read'] == true ? ' checked="checked"' : ''; $group_edit_checked = $acl['group_edit'] == true ? ' checked="checked"' : ''; $group_create_checked = $acl['group_create'] == true ? ' checked="checked"' : ''; $course_read_checked = $acl['course_read'] == true ? ' checked="checked"' : ''; $course_edit_checked = $acl['course_edit'] == true ? ' checked="checked"' : ''; $course_create_checked = $acl['course_create'] == true ? ' checked="checked"' : ''; $other_read_checked = $acl['other_read'] == true ? ' checked="checked"' : ''; $other_edit_checked = $acl['other_edit'] == true ? ' checked="checked"' : ''; $other_create_checked = $acl['other_create'] == true ? ' checked="checked"' : ''; $script = is_null($script) ? $_SERVER['SCRIPT_NAME'] . "?course={$course_code}" : $script; $form = action_bar(array(array('title' => $langBack, 'url' => "{$_SERVER['SCRIPT_NAME']}'?course={$course_code}", 'icon' => 'fa-reply', 'level' => 'primary-label'))); $form .= "<div class='form-wrapper'>\n <form class='form-horizontal' role='form' method='POST' id='wikiProperties' action='{$script}'>\n <fieldset>\n <input type='hidden' name='wikiId' value='{$wikiId}'>\n <!-- groupId = 0 if course wiki, != 0 if group_wiki -->\n <input type='hidden' name='gid' value='{$groupId}'> \n <div class='form-group'>\n <label for='title' class='col-sm-2 control-label'>{$langWikiTitle}:</label>\n <div class='col-sm-10'>\n <input name='title' type='text' class='form-control' id='wikiTitle' value='" . q($title) . "' placeholder='{$langWikiTitle}'>\n </div>\n </div>\n <div class='form-group'>\n <label for='wikiDesc' class='col-sm-2 control-label'>" . $langWikiDescription . ":</label>\n <div class='col-sm-10'>\n <textarea class='form-control' id='wikiDesc' name='desc'>" . q($desc) . "</textarea>"; // atkyritsis // hardwiring if ($groupId == 0) { $form .= "\n <input type='hidden' name='acl[course_read]' value='on'>\n <input type='hidden' name='acl[course_edit]' value='on'>\n <input type='hidden' name='acl[course_create]' value='on'>\n <input type='hidden' name='acl[other_read]' value='on'>\n <input type='hidden' name='acl[other_edit]' value='off'>\n <input type='hidden' name='acl[other_create]' value='off'>"; } else { //default values for group wikis $form .= "\n <input type='hidden' name='acl[group_read]' value='on'>\n <input type='hidden' name='acl[group_edit]' value='on'>\n <input type='hidden' name='acl[group_create]' value='on'>\n <input type='hidden' name='acl[course_read]' value='on'>\n <input type='hidden' name='acl[course_edit]' value='off'>\n <input type='hidden' name='acl[course_create]' value='off'>\n <input type='hidden' name='acl[other_read]' value='off'>\n <input type='hidden' name='acl[other_edit]' value='off'>\n <input type='hidden' name='acl[other_create]' value='off'>"; } // hardwiring over $form .= " </div>\n </div>\n <div class='form-group'>\n <div class='col-sm-10 col-sm-offset-2'>\n <input class='btn btn-primary' type='submit' name='action[exEdit]' value='{$langSave}'>\n <a class='btn btn-default' href='{$_SERVER['SCRIPT_NAME']}?course={$course_code}'>{$langCancel}</a>\n </div>\n </div>\n </fieldset>\n </form>\n </div>"; return $form; }
/** * Generate html code of Wiki properties edit form * @param int wikiId ID of the wiki * @param string title wiki tile * @param string desc wiki description * @param int groupId id of the group the wiki belongs to * (0 for a course wiki) * @param array acl wiki access control list * @param string script callback script url * @return string html code of the wiki properties form */ function claro_disp_wiki_properties_form($wikiId = 0, $title = '', $desc = '', $groupId = 0, $acl = null, $script = null) { $title = $title != '' ? $title : get_lang("New Wiki"); $desc = $desc != '' ? $desc : get_lang("Enter the description of your wiki here"); if (is_null($acl) && $groupId == 0) { $acl = WikiAccessControl::defaultCourseWikiACL(); } elseif (is_null($acl) && $groupId != 0) { $acl = WikiAccessControl::defaultGroupWikiACL(); } // process ACL $group_read_checked = $acl['group_read'] == true ? ' checked="checked"' : ''; $group_edit_checked = $acl['group_edit'] == true ? ' checked="checked"' : ''; $group_create_checked = $acl['group_create'] == true ? ' checked="checked"' : ''; $course_read_checked = $acl['course_read'] == true ? ' checked="checked"' : ''; $course_edit_checked = $acl['course_edit'] == true ? ' checked="checked"' : ''; $course_create_checked = $acl['course_create'] == true ? ' checked="checked"' : ''; $other_read_checked = $acl['other_read'] == true ? ' checked="checked"' : ''; $other_edit_checked = $acl['other_edit'] == true ? ' checked="checked"' : ''; $other_create_checked = $acl['other_create'] == true ? ' checked="checked"' : ''; $script = is_null($script) ? Url::Contextualize($_SERVER['PHP_SELF']) : $script; $form = '<form method="post" id="wikiProperties" action="' . claro_htmlspecialchars($script) . '">' . "\n" . '<fieldset>' . "\n" . '<legend>' . get_lang("Wiki description") . '</legend>' . "\n" . '<!-- wikiId = 0 if creation, != 0 if edition -->' . "\n" . '<p class="notice">' . get_lang('You can choose a title and a description for the wiki :') . '</p>' . "\n" . '<input type="hidden" name="wikiId" value="' . $wikiId . '" />' . "\n" . '<!-- groupId = 0 if course wiki, != 0 if group_wiki -->' . "\n" . '<input type="hidden" name="groupId" value="' . $groupId . '" />' . "\n" . '<dl>' . "\n" . '<dt><label for="wikiTitle">' . get_lang("Title of the wiki") . '</label></dt>' . "\n" . '<dd><input type="text" name="title" id="wikiTitle" size="80" maxlength="254" value="' . claro_htmlspecialchars($title) . '" /></dd>' . "\n" . '<dt><label for="wikiDesc">' . get_lang("Description of the Wiki") . '</label></dt>' . "\n" . '<dd><textarea id="wikiDesc" name="desc" cols="80" rows="10">' . $desc . '</textarea></dd>' . "\n" . '</dl>' . '</fieldset>' . "\n\n" . '<fieldset id="acl">' . "\n" . '<legend>' . get_lang("Access control management") . '</legend>' . "\n" . '<p class="notice">' . get_lang('You can set access rights for users using the following grid :') . '</p>' . "\n" . '<table style="text-align: center; padding: 5px;" id="wikiACL">' . "\n" . '<tr class="matrixAbs">' . "\n" . '<td><!-- empty --></td>' . "\n" . '<td>' . get_lang("Read Pages") . '</td>' . "\n" . '<td>' . get_lang("Edit Pages") . '</td>' . "\n" . '<td>' . get_lang("Create Pages") . '</td>' . "\n" . '</tr>' . "\n" . '<tr>' . "\n" . '<td class="matrixOrd">' . get_lang("Course members") . '</td>' . "\n" . '<td><input type="checkbox" onclick="updateBoxes(\'course\',\'read\');" id="course_read" name="acl[course_read]"' . $course_read_checked . ' /></td>' . "\n" . '<td><input type="checkbox" onclick="updateBoxes(\'course\',\'edit\');" id="course_edit" name="acl[course_edit]"' . $course_edit_checked . ' /></td>' . "\n" . '<td><input type="checkbox" onclick="updateBoxes(\'course\',\'create\');" id="course_create" name="acl[course_create]"' . $course_create_checked . ' /></td>' . "\n" . '</tr>' . "\n"; if ($groupId != 0) { $form .= '<!-- group acl row hidden if groupId == 0, set all to false -->' . "\n" . '<tr>' . "\n" . '<td class="matrixOrd">' . get_lang("Group members") . '</td>' . "\n" . '<td><input type="checkbox" onclick="updateBoxes(\'group\',\'read\');" id="group_read" name="acl[group_read]"' . $group_read_checked . ' /></td>' . "\n" . '<td><input type="checkbox" onclick="updateBoxes(\'group\',\'edit\');" id="group_edit" name="acl[group_edit]"' . $group_edit_checked . ' /></td>' . "\n" . '<td><input type="checkbox" onclick="updateBoxes(\'group\',\'create\');" id="group_create" name="acl[group_create]"' . $group_create_checked . ' /></td>' . "\n" . '</tr>' . "\n"; } $form .= '<tr>' . "\n" . '<td class="matrixOrd">' . get_lang("Others (*)") . '</td>' . "\n" . '<td><input type="checkbox" onclick="updateBoxes(\'other\',\'read\');" id="other_read" name="acl[other_read]"' . $other_read_checked . ' /></td>' . "\n" . '<td><input type="checkbox" onclick="updateBoxes(\'other\',\'edit\');" id="other_edit" name="acl[other_edit]"' . $other_edit_checked . ' /></td>' . "\n" . '<td><input type="checkbox" onclick="updateBoxes(\'other\',\'create\');" id="other_create" name="acl[other_create]"' . $other_create_checked . ' /></td>' . "\n" . '</tr>' . "\n" . '</table>' . "\n" . '<p class="notice">' . get_lang("(*) anonymous users, users who are not members of this course...") . '</p>' . "\n" . '</fieldset>' . "\n\n"; if ($groupId != 0) { $form .= '<input type="hidden" name="gidReq" value="' . $groupId . '" />' . "\n"; } $form .= claro_form_relay_context() . "\n"; $form .= '<input type="submit" name="action[exEdit]" value="' . get_lang("Ok") . '" />' . "\n" . claro_html_button(claro_htmlspecialchars(Url::Contextualize($_SERVER['PHP_SELF'] . '?action=list')), get_lang("Cancel")) . "\n"; $form .= '</form>' . "\n"; return $form; }