function setACL($newacl) { $doku = current_dokuwiki_entity(); elgg_set_ignore_access(true); $doku->wiki_acl = $newacl; elgg_set_ignore_access(false); }
/** * Call the needed action handlers * * @author Andreas Gohr <*****@*****.**> * @triggers ACTION_ACT_PREPROCESS * @triggers ACTION_HEADERS_SEND */ function act_dispatch() { global $INFO; global $ACT; global $ID; global $QUERY; global $lang; global $conf; global $license; $preact = $ACT; //error_log("dokuact:".$ACT); // give plugins an opportunity to process the action $evt = new Doku_Event('ACTION_ACT_PREPROCESS', $ACT); if ($evt->advise_before()) { //sanitize $ACT $ACT = act_clean($ACT); //check if searchword was given - else just show $s = cleanID($QUERY); if ($ACT == 'search' && empty($s)) { $ACT = 'show'; } //login stuff if (in_array($ACT, array('login', 'logout'))) { $ACT = act_auth($ACT); } //check if user is asking to (un)subscribe a page if ($ACT == 'subscribe' || $ACT == 'unsubscribe') { $ACT = act_subscription($ACT); } //check if user is asking to (un)subscribe a namespace if ($ACT == 'subscribens' || $ACT == 'unsubscribens') { $ACT = act_subscriptionns($ACT); } //check permissions $ACT = act_permcheck($ACT); //register $nil = array(); if ($ACT == 'register' && $_POST['save'] && register()) { $ACT = 'login'; } if ($ACT == 'resendpwd' && act_resendpwd()) { $ACT = 'login'; } //update user profile if ($ACT == 'profile') { if (!$_SERVER['REMOTE_USER']) { $ACT = 'login'; } else { if (updateprofile()) { msg($lang['profchanged'], 1); $ACT = 'show'; } } } //revert if ($ACT == 'revert') { if (checkSecurityToken()) { $ACT = act_revert($ACT); } else { $ACT = 'show'; } } //save if ($ACT == 'save') { if (checkSecurityToken()) { $ACT = act_save($ACT); } else { $ACT = 'show'; } } //cancel conflicting edit if ($ACT == 'cancel') { $ACT = 'show'; } //draft deletion if ($ACT == 'draftdel') { $ACT = act_draftdel($ACT); } //draft saving on preview if ($ACT == 'preview') { $ACT = act_draftsave($ACT); } //edit if (($ACT == 'edit' || $ACT == 'preview') && $INFO['editable']) { $ACT = act_edit($ACT); } else { unlock($ID); //try to unlock } //handle export if (substr($ACT, 0, 7) == 'export_') { $ACT = act_export($ACT); } //display some infos if ($ACT == 'check') { check(); $ACT = 'show'; } //handle admin tasks if ($ACT == 'admin') { // retrieve admin plugin name from $_REQUEST['page'] $page = get_input('dokupage'); if (!empty($page)) { $pluginlist = plugin_list('admin'); if (in_array($page, $pluginlist)) { // attempt to load the plugin if (($plugin =& plugin_load('admin', $page)) !== NULL) { $plugin->handle(); } } } } // check permissions again - the action may have changed $ACT = act_permcheck($ACT); } // end event ACTION_ACT_PREPROCESS default action $evt->advise_after(); unset($evt); if ($ACT == 'save') { $user = elgg_get_logged_in_user_entity(); $doku = current_dokuwiki_entity(); $group = get_entity($doku->container_guid); add_to_river('river/dokuwiki', 'wiki/' . $ACT . '/' . $QUERY, $user->getGUID(), $doku->getGUID(), $group->access_id); } // when action 'show', the intial not 'show' and POST, do a redirect if ($ACT == 'show' && $preact != 'show' && strtolower($_SERVER['REQUEST_METHOD']) == 'post') { act_redirect($ID, $preact); } //call template FIXME: all needed vars available? $headers[] = 'Content-Type: text/html; charset=utf-8'; trigger_event('ACTION_HEADERS_SEND', $headers, 'act_sendheaders'); include template('main.php'); // output for the commands is now handled in inc/templates.php // in function tpl_content() }
/** * Dispatches dokuwiki pages. * URLs take the form of * All wikis: dokuwiki/all * Group wiki: dokuwiki/<guid> * * @param array $page * @return NULL */ function dokuwiki_page_handler($page) { elgg_load_library('elgg:dokuwiki'); if ($page[0] === "all") { elgg_set_context("search"); include elgg_get_plugins_path() . 'dokuwiki/index.php'; return true; } elgg_set_context("dokuwiki"); $dokuwiki_path = elgg_get_plugins_path() . 'dokuwiki/vendors/dokuwiki/'; $doku = current_dokuwiki_entity(); if (!$doku) { // can fail if there is no user and wiki doesnt exist return false; } $parsed_url = parse_url(elgg_get_site_url() . 'dokuwiki/'); $url_base = $parsed_url['path']; if (is_numeric($page[0])) { $entity_guid = $page[0]; $ent = get_entity($entity_guid); if ($ent && $ent instanceof ElggGroup && $ent->dokuwiki_enable !== 'yes') { // wiki not activated for this group. bail out. elgg_pop_context(); return false; } if ($ent && $ent instanceof ElggGroup) { elgg_set_page_owner_guid($entity_guid); $data_path = elgg_get_data_path() . 'wikis/' . $entity_guid; } else { // can't see the group elgg_pop_context(); return false; } $page = array_slice($page, 1); // pop first element define('DOKU_REL', $url_base . $entity_guid . "/"); define('DOKU_BASE', $url_base . $entity_guid . "/"); define('DOKU_URL', elgg_get_site_url() . 'dokuwiki/' . $entity_guid . "/"); } else { $data_path = elgg_get_data_path() . 'wiki'; define('DOKU_REL', $url_base); define('DOKU_BASE', $url_base); define('DOKU_URL', elgg_get_site_url() . 'dokuwiki/'); } define('DOKU_INC', $dokuwiki_path); define('DOKU_MEDIA', elgg_get_site_url() . 'mod/dokuwiki/vendors/dokuwiki/'); define('DOKU_CONF', $dokuwiki_path . "conf/"); dokuwiki_create_datafolder($data_path); define('DOKU_ELGGDATA', $data_path); if (empty($page) || count($page) == 1 && $page[0] == 'acl') { $page = array('doku.php'); } else { if (count($page) == 1 && $page[0] == 'usermanager') { $page = array('doku.php'); } else { if (count($page) == 1 && $page[0] == 'plugin') { $page = array('doku.php'); } else { if (count($page) == 1 && $page[0] == 'config') { $page = array('doku.php'); } else { if (count($page) == 1 && $page[0] == 'revert') { $page = array('doku.php'); } else { if (count($page) == 1 && $page[0] == 'popularity') { $page = array('doku.php'); } } } } } } if (empty($page) || count($page) == 1 && !$page[0]) { $page = array('doku.php'); } $_SERVER['PHP_AUTH_USER'] = elgg_get_logged_in_user_entity()->username; $_SERVER['PHP_AUTH_PW'] = elgg_get_logged_in_user_entity()->password; if (count($page) == 1) { $doku_body = elgg_view('dokuwiki/index', array('page' => $page[0])); echo $doku_body; } else { // avoid inclusion over root $dest = realpath($dokuwiki_path . implode("/", $page)); if (strpos($dest, $dokuwiki_path) == 0) { $doku_body = elgg_view('dokuwiki/index', array('page' => implode("/", $page))); } echo $doku_body; } return true; }