function siteexport_add_page_export(&$event) { global $ID; if ($this->getConf('allowallusers') || auth_isadmin() || auth_ismanager()) { $event->data['items'][] = '<li>' . tpl_link(wl($ID, array('do' => 'siteexport_addpage')), '<span>Export Page</span>', 'class="action siteexport_addpage" title="Add page"', 1) . '</li>'; } }
/** * Step up * * @param Doku_Event $event */ public function handle_ajax(Doku_Event $event) { if ($event->data != 'plugin_move_progress') { return; } $event->preventDefault(); $event->stopPropagation(); global $INPUT; global $USERINFO; if (!auth_ismanager($_SERVER['REMOTE_USER'], $USERINFO['grps'])) { http_status(403); exit; } $return = array('error' => '', 'complete' => false, 'progress' => 0); /** @var helper_plugin_move_plan $plan */ $plan = plugin_load('helper', 'move_plan'); if (!$plan->isCommited()) { // There is no plan. Something went wrong $return['complete'] = true; } else { $todo = $plan->nextStep($INPUT->bool('skip')); $return['progress'] = $plan->getProgress(); $return['error'] = $plan->getLastError(); if ($todo === 0) { $return['complete'] = true; } } $json = new JSON(); header('Content-Type: application/json'); echo $json->encode($return); }
function test_isadmin() { global $conf; $conf['superuser'] = '******'; // anonymous user $this->assertEqual(auth_ismanager('jill', '', true), false); // admin user $this->assertEqual(auth_ismanager('john', '', true), true); $this->assertEqual(auth_ismanager('doe', '', true), true); // admin groups $this->assertEqual(auth_ismanager('jill', array('admin'), true), true); $this->assertEqual(auth_ismanager('jill', array('roots'), true), true); $this->assertEqual(auth_ismanager('john', array('admin'), true), true); $this->assertEqual(auth_ismanager('doe', array('admin'), true), true); }
/** * Render a subtree * * @param Doku_Event $event * @param $params */ public function handle_ajax_call(Doku_Event $event, $params) { if ($event->data != 'plugin_move_tree') { return; } $event->preventDefault(); $event->stopPropagation(); global $INPUT; global $USERINFO; if (!auth_ismanager($_SERVER['REMOTE_USER'], $USERINFO['grps'])) { http_status(403); exit; } /** @var admin_plugin_move_tree $plugin */ $plugin = plugin_load('admin', 'move_tree'); $ns = cleanID($INPUT->str('ns')); if ($INPUT->bool('is_media')) { $type = admin_plugin_move_tree::TYPE_MEDIA; } else { $type = admin_plugin_move_tree::TYPE_PAGES; } $data = $plugin->tree($type, $ns, $ns); echo html_buildlist($data, 'tree_list', array($plugin, 'html_list'), array($plugin, 'html_li')); }
/** * Check if a user is admin * * Alias to auth_ismanager with adminonly=true * * The info is available through $INFO['isadmin'], too * * @author Andreas Gohr <*****@*****.**> * @see auth_ismanager() * @param string $user Username * @param array $groups List of groups the user is in * @return bool */ function auth_isadmin($user = null, $groups = null) { return auth_ismanager($user, $groups, true); }
function html_diff_head($l_rev, $r_rev, $id = null, $media = false) { global $lang; if ($id === null) { global $ID; $id = $ID; } $media_or_wikiFN = $media ? 'mediaFN' : 'wikiFN'; $ml_or_wl = $media ? 'ml' : 'wl'; $l_minor = $r_minor = ''; if (!$l_rev) { $l_head = '—'; } else { $l_info = getRevisionInfo($id, $l_rev, true, $media); if ($l_info['user']) { $l_user = editorinfo($l_info['user']); if (auth_ismanager()) { $l_user .= ' (' . $l_info['ip'] . ')'; } } else { $l_user = $l_info['ip']; } $l_user = '******' . $l_user . '</span>'; $l_sum = $l_info['sum'] ? '<span class="sum">' . hsc($l_info['sum']) . '</span>' : ''; if ($l_info['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT) { $l_minor = 'class="minor"'; } $l_head_title = $media ? dformat($l_rev) : $id . ' [' . dformat($l_rev) . ']'; $l_head = '<a class="wikilink1" href="' . $ml_or_wl($id, "rev={$l_rev}") . '">' . $l_head_title . '</a>' . '<br />' . $l_user . ' ' . $l_sum; } if ($r_rev) { $r_info = getRevisionInfo($id, $r_rev, true, $media); if ($r_info['user']) { $r_user = editorinfo($r_info['user']); if (auth_ismanager()) { $r_user .= ' (' . $r_info['ip'] . ')'; } } else { $r_user = $r_info['ip']; } $r_user = '******' . $r_user . '</span>'; $r_sum = $r_info['sum'] ? '<span class="sum">' . hsc($r_info['sum']) . '</span>' : ''; if ($r_info['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT) { $r_minor = 'class="minor"'; } $r_head_title = $media ? dformat($r_rev) : $id . ' [' . dformat($r_rev) . ']'; $r_head = '<a class="wikilink1" href="' . $ml_or_wl($id, "rev={$r_rev}") . '">' . $r_head_title . '</a>' . '<br />' . $r_user . ' ' . $r_sum; } elseif ($_rev = @filemtime($media_or_wikiFN($id))) { $_info = getRevisionInfo($id, $_rev, true, $media); if ($_info['user']) { $_user = editorinfo($_info['user']); if (auth_ismanager()) { $_user .= ' (' . $_info['ip'] . ')'; } } else { $_user = $_info['ip']; } $_user = '******' . $_user . '</span>'; $_sum = $_info['sum'] ? '<span class="sum">' . hsc($_info['sum']) . '</span>' : ''; if ($_info['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT) { $r_minor = 'class="minor"'; } $r_head_title = $media ? dformat($_rev) : $id . ' [' . dformat($_rev) . ']'; $r_head = '<a class="wikilink1" href="' . $ml_or_wl($id) . '">' . $r_head_title . '</a> ' . '(' . $lang['current'] . ')' . '<br />' . $_user . ' ' . $_sum; } else { $r_head = '— (' . $lang['current'] . ')'; } return array($l_head, $r_head, $l_minor, $r_minor); }
/** * Return info about the current document as associative * array. * * @author Andreas Gohr <*****@*****.**> */ function pageinfo() { global $ID; global $REV; global $RANGE; global $USERINFO; global $lang; // include ID & REV not redundant, as some parts of DokuWiki may temporarily change $ID, e.g. p_wiki_xhtml // FIXME ... perhaps it would be better to ensure the temporary changes weren't necessary $info['id'] = $ID; $info['rev'] = $REV; // set info about manager/admin status. $info['isadmin'] = false; $info['ismanager'] = false; if (isset($_SERVER['REMOTE_USER'])) { $info['userinfo'] = $USERINFO; $info['perm'] = auth_quickaclcheck($ID); $info['subscribed'] = get_info_subscribed(); $info['client'] = $_SERVER['REMOTE_USER']; if ($info['perm'] == AUTH_ADMIN) { $info['isadmin'] = true; $info['ismanager'] = true; } elseif (auth_ismanager()) { $info['ismanager'] = true; } // if some outside auth were used only REMOTE_USER is set if (!$info['userinfo']['name']) { $info['userinfo']['name'] = $_SERVER['REMOTE_USER']; } } else { $info['perm'] = auth_aclcheck($ID, '', null); $info['subscribed'] = false; $info['client'] = clientIP(true); } $info['namespace'] = getNS($ID); $info['locked'] = checklock($ID); $info['filepath'] = fullpath(wikiFN($ID)); $info['exists'] = @file_exists($info['filepath']); if ($REV) { //check if current revision was meant if ($info['exists'] && @filemtime($info['filepath']) == $REV) { $REV = ''; } elseif ($RANGE) { //section editing does not work with old revisions! $REV = ''; $RANGE = ''; msg($lang['nosecedit'], 0); } else { //really use old revision $info['filepath'] = fullpath(wikiFN($ID, $REV)); $info['exists'] = @file_exists($info['filepath']); } } $info['rev'] = $REV; if ($info['exists']) { $info['writable'] = is_writable($info['filepath']) && $info['perm'] >= AUTH_EDIT; } else { $info['writable'] = $info['perm'] >= AUTH_CREATE; } $info['editable'] = $info['writable'] && empty($info['locked']); $info['lastmod'] = @filemtime($info['filepath']); //load page meta data $info['meta'] = p_get_metadata($ID); //who's the editor if ($REV) { $revinfo = getRevisionInfo($ID, $REV, 1024); } else { if (is_array($info['meta']['last_change'])) { $revinfo = $info['meta']['last_change']; } else { $revinfo = getRevisionInfo($ID, $info['lastmod'], 1024); // cache most recent changelog line in metadata if missing and still valid if ($revinfo !== false) { $info['meta']['last_change'] = $revinfo; p_set_metadata($ID, array('last_change' => $revinfo)); } } } //and check for an external edit if ($revinfo !== false && $revinfo['date'] != $info['lastmod']) { // cached changelog line no longer valid $revinfo = false; $info['meta']['last_change'] = $revinfo; p_set_metadata($ID, array('last_change' => $revinfo)); } $info['ip'] = $revinfo['ip']; $info['user'] = $revinfo['user']; $info['sum'] = $revinfo['sum']; // See also $INFO['meta']['last_change'] which is the most recent log line for page $ID. // Use $INFO['meta']['last_change']['type']===DOKU_CHANGE_TYPE_MINOR_EDIT in place of $info['minor']. if ($revinfo['user']) { $info['editor'] = $revinfo['user']; } else { $info['editor'] = $revinfo['ip']; } // draft $draft = getCacheName($info['client'] . $ID, '.draft'); if (@file_exists($draft)) { if (@filemtime($draft) < @filemtime(wikiFN($ID))) { // remove stale draft @unlink($draft); } else { $info['draft'] = $draft; } } // mobile detection $info['ismobile'] = clientismobile(); return $info; }
/** * Determine basic information for a request of $id * * @author Andreas Gohr <*****@*****.**> * @author Chris Smith <*****@*****.**> * * @param string $id pageid * @param bool $htmlClient add info about whether is mobile browser * @return array with info for a request of $id * */ function basicinfo($id, $htmlClient = true) { global $USERINFO; /* @var Input $INPUT */ global $INPUT; // set info about manager/admin status. $info = array(); $info['isadmin'] = false; $info['ismanager'] = false; if ($INPUT->server->has('REMOTE_USER')) { $info['userinfo'] = $USERINFO; $info['perm'] = auth_quickaclcheck($id); $info['client'] = $INPUT->server->str('REMOTE_USER'); if ($info['perm'] == AUTH_ADMIN) { $info['isadmin'] = true; $info['ismanager'] = true; } elseif (auth_ismanager()) { $info['ismanager'] = true; } // if some outside auth were used only REMOTE_USER is set if (!$info['userinfo']['name']) { $info['userinfo']['name'] = $INPUT->server->str('REMOTE_USER'); } } else { $info['perm'] = auth_aclcheck($id, '', null); $info['client'] = clientIP(true); } $info['namespace'] = getNS($id); // mobile detection if ($htmlClient) { $info['ismobile'] = clientismobile(); } return $info; }
function test_isadmin_sensitive() { $this->setSensitive(); global $conf; $conf['superuser'] = '******'; // anonymous user $this->assertEquals(auth_ismanager('jill', null, true), false); // admin user $this->assertEquals(auth_ismanager('john', null, true), true); $this->assertEquals(auth_ismanager('Doe', null, true), false); // admin groups $this->assertEquals(auth_ismanager('jill', array('admin'), true), true); $this->assertEquals(auth_ismanager('jill', array('roots'), true), true); $this->assertEquals(auth_ismanager('john', array('admin'), true), true); $this->assertEquals(auth_ismanager('doe', array('admin'), true), true); $this->assertEquals(auth_ismanager('Doe', array('admin'), true), true); }
/** * @return bool */ function isDiscussionMod() { global $USERINFO; $groups = trim($this->getConf('moderatorgroups')); if (auth_ismanager()) { return true; } // Check if user is member of the moderator groups if (!empty($groups) && auth_isMember($groups, $_SERVER['REMOTE_USER'], (array) $USERINFO['grps'])) { return true; } return false; }
/** * show diff * * @author Andreas Gohr <*****@*****.**> */ function html_diff($text = '', $intro = true) { require_once DOKU_INC . 'inc/DifferenceEngine.php'; global $ID; global $REV; global $lang; global $conf; // we're trying to be clever here, revisions to compare can be either // given as rev and rev2 parameters, with rev2 being optional. Or in an // array in rev2. $rev1 = $REV; if (is_array($_REQUEST['rev2'])) { $rev1 = (int) $_REQUEST['rev2'][0]; $rev2 = (int) $_REQUEST['rev2'][1]; if (!$rev1) { $rev1 = $rev2; unset($rev2); } } else { $rev2 = (int) $_REQUEST['rev2']; } if ($text) { // compare text to the most current revision $l_rev = ''; $l_text = rawWiki($ID, ''); $l_head = '<a class="wikilink1" href="' . wl($ID) . '">' . $ID . ' ' . strftime($conf['dformat'], @filemtime(wikiFN($ID))) . '</a> ' . $lang['current']; $r_rev = ''; $r_text = cleanText($text); $r_head = $lang['yours']; } else { if ($rev1 && $rev2) { // two specific revisions wanted // make sure order is correct (older on the left) if ($rev1 < $rev2) { $l_rev = $rev1; $r_rev = $rev2; } else { $l_rev = $rev2; $r_rev = $rev1; } } elseif ($rev1) { // single revision given, compare to current $r_rev = ''; $l_rev = $rev1; } else { // no revision was given, compare previous to current $r_rev = ''; $revs = getRevisions($ID, 0, 1); $l_rev = $revs[0]; } // when both revisions are empty then the page was created just now if (!$l_rev && !$r_rev) { $l_text = ''; } else { $l_text = rawWiki($ID, $l_rev); } $r_text = rawWiki($ID, $r_rev); if (!$l_rev) { $l_head = '—'; } else { $l_info = getRevisionInfo($ID, $l_rev, true); if ($l_info['user']) { $l_user = editorinfo($l_info['user']); if (auth_ismanager()) { $l_user .= ' (' . $l_info['ip'] . ')'; } } else { $l_user = $l_info['ip']; } $l_user = '******' . $l_user . '</span>'; $l_sum = $l_info['sum'] ? '<span class="sum">' . hsc($l_info['sum']) . '</span>' : ''; if ($l_info['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT) { $l_minor = 'class="minor"'; } $l_head = '<a class="wikilink1" href="' . wl($ID, "rev={$l_rev}") . '">' . $ID . ' [' . strftime($conf['dformat'], $l_rev) . ']</a>' . '<br />' . $l_user . ' ' . $l_sum; } if ($r_rev) { $r_info = getRevisionInfo($ID, $r_rev, true); if ($r_info['user']) { $r_user = editorinfo($r_info['user']); if (auth_ismanager()) { $r_user .= ' (' . $r_info['ip'] . ')'; } } else { $r_user = $r_info['ip']; } $r_user = '******' . $r_user . '</span>'; $r_sum = $r_info['sum'] ? '<span class="sum">' . hsc($r_info['sum']) . '</span>' : ''; if ($r_info['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT) { $r_minor = 'class="minor"'; } $r_head = '<a class="wikilink1" href="' . wl($ID, "rev={$r_rev}") . '">' . $ID . ' [' . strftime($conf['dformat'], $r_rev) . ']</a>' . '<br />' . $r_user . ' ' . $r_sum; } elseif ($_rev = @filemtime(wikiFN($ID))) { $_info = getRevisionInfo($ID, $_rev, true); if ($_info['user']) { $_user = editorinfo($_info['user']); if (auth_ismanager()) { $_user .= ' (' . $_info['ip'] . ')'; } } else { $_user = $_info['ip']; } $_user = '******' . $_user . '</span>'; $_sum = $_info['sum'] ? '<span class="sum">' . hsc($_info['sum']) . '</span>' : ''; if ($_info['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT) { $r_minor = 'class="minor"'; } $r_head = '<a class="wikilink1" href="' . wl($ID) . '">' . $ID . ' [' . strftime($conf['dformat'], $_rev) . ']</a> ' . '(' . $lang['current'] . ')' . '<br />' . $_user . ' ' . $_sum; } else { $r_head = '— (' . $lang['current'] . ')'; } } $df = new Diff(explode("\n", htmlspecialchars($l_text)), explode("\n", htmlspecialchars($r_text))); $tdf = new TableDiffFormatter(); if ($intro) { print p_locale_xhtml('diff'); } ?> <table class="diff"> <tr> <th colspan="2" <?php echo $l_minor; ?> > <?php echo $l_head; ?> </th> <th colspan="2" <?php echo $r_minor; ?> > <?php echo $r_head; ?> </th> </tr> <?php echo $tdf->format($df); ?> </table> <?php }
/** * Outputs the comment form */ function _form($raw = '', $act = 'add', $cid = NULL) { global $lang; global $conf; global $ID; global $INFO; // not for unregistered users when guest comments aren't allowed if (!$_SERVER['REMOTE_USER'] && !$this->getConf('allowguests')) { ?> <div class="comment_form"> <?php echo $this->getLang('noguests'); ?> </div> <?php return false; } // fill $raw with $_REQUEST['text'] if it's empty (for failed CAPTCHA check) if (!$raw && $_REQUEST['comment'] == 'show') { $raw = $_REQUEST['text']; } ?> <div class="comment_form"> <form id="discussion__comment_form" method="post" action="<?php echo script(); ?> " accept-charset="<?php echo $lang['encoding']; ?> "> <div class="no"> <input type="hidden" name="id" value="<?php echo $ID; ?> " /> <input type="hidden" name="do" value="show" /> <input type="hidden" name="comment" value="<?php echo $act; ?> " /> <?php // for adding a comment if ($act == 'add') { ?> <input type="hidden" name="reply" value="<?php echo $cid; ?> " /> <?php // for guest/adminimport: show name, e-mail and subscribe to comments fields if (!$_SERVER['REMOTE_USER'] or $this->getConf('adminimport') && auth_ismanager()) { ?> <input type="hidden" name="user" value="<?php echo clientIP(); ?> " /> <div class="comment_name"> <label class="block" for="discussion__comment_name"> <span><?php echo $lang['fullname']; ?> :</span> <input type="text" class="edit<?php if ($_REQUEST['comment'] == 'add' && empty($_REQUEST['name'])) { echo ' error'; } ?> " name="name" id="discussion__comment_name" size="50" tabindex="1" value="<?php echo hsc($_REQUEST['name']); ?> " /> </label> </div> <div class="comment_mail"> <label class="block" for="discussion__comment_mail"> <span><?php echo $lang['email']; ?> :</span> <input type="text" class="edit<?php if ($_REQUEST['comment'] == 'add' && empty($_REQUEST['mail'])) { echo ' error'; } ?> " name="mail" id="discussion__comment_mail" size="50" tabindex="2" value="<?php echo hsc($_REQUEST['mail']); ?> " /> </label> </div> <?php } // allow entering an URL if ($this->getConf('urlfield')) { ?> <div class="comment_url"> <label class="block" for="discussion__comment_url"> <span><?php echo $this->getLang('url'); ?> :</span> <input type="text" class="edit" name="url" id="discussion__comment_url" size="50" tabindex="3" value="<?php echo hsc($_REQUEST['url']); ?> " /> </label> </div> <?php } // allow entering an address if ($this->getConf('addressfield')) { ?> <div class="comment_address"> <label class="block" for="discussion__comment_address"> <span><?php echo $this->getLang('address'); ?> :</span> <input type="text" class="edit" name="address" id="discussion__comment_address" size="50" tabindex="4" value="<?php echo hsc($_REQUEST['address']); ?> " /> </label> </div> <?php } // allow setting the comment date if ($this->getConf('adminimport') && auth_ismanager()) { ?> <div class="comment_date"> <label class="block" for="discussion__comment_date"> <span><?php echo $this->getLang('date'); ?> :</span> <input type="text" class="edit" name="date" id="discussion__comment_date" size="50" /> </label> </div> <?php } // for saving a comment } else { ?> <input type="hidden" name="cid" value="<?php echo $cid; ?> " /> <?php } ?> <div class="comment_text"> <?php echo $this->getLang('entercomment'); echo $this->getConf('wikisyntaxok') ? "" : ":"; if ($this->getConf('wikisyntaxok')) { echo '. ' . $this->getLang('wikisyntax') . ':'; } ?> <!-- Fix for disable the toolbar when wikisyntaxok is set to false. See discussion's script.jss --> <?php if ($this->getConf('wikisyntaxok')) { ?> <div id="discussion__comment_toolbar"> <?php } else { ?> <div id="discussion__comment_toolbar_disabled"> <?php } ?> </div> <textarea class="edit<?php if ($_REQUEST['comment'] == 'add' && empty($_REQUEST['text'])) { echo ' error'; } ?> " name="text" cols="80" rows="10" id="discussion__comment_text" tabindex="5"><?php if ($raw) { echo formText($raw); } else { echo $_REQUEST['text']; } ?> </textarea> </div> <?php //bad and dirty event insert hook $evdata = array('writable' => true); trigger_event('HTML_EDITFORM_INJECTION', $evdata); ?> <input class="button comment_submit" id="discussion__btn_submit" type="submit" name="submit" accesskey="s" value="<?php echo $lang['btn_save']; ?> " title="<?php echo $lang['btn_save']; ?> [S]" tabindex="7" /> <input class="button comment_preview_button" id="discussion__btn_preview" type="button" name="preview" accesskey="p" value="<?php echo $lang['btn_preview']; ?> " title="<?php echo $lang['btn_preview']; ?> [P]" /> <?php if ((!$_SERVER['REMOTE_USER'] || $_SERVER['REMOTE_USER'] && !$conf['subscribers']) && $this->getConf('subscribe')) { ?> <div class="comment_subscribe"> <input type="checkbox" id="discussion__comment_subscribe" name="subscribe" tabindex="6" /> <label class="block" for="discussion__comment_subscribe"> <span><?php echo $this->getLang('subscribe'); ?> </span> </label> </div> <?php } ?> <div class="clearer"></div> <div id="discussion__comment_preview"> </div> </div> </form> </div> <?php if ($this->getConf('usecocomment')) { echo $this->_coComment(); } }
/** * show diff * * @author Andreas Gohr <*****@*****.**> * @param string $text - compare with this text with most current version * @param bool $intr - display the intro text */ function html_diff($text = '', $intro = true, $type = null) { global $ID; global $REV; global $lang; global $conf; if (!$type) { $type = $_REQUEST['difftype']; } if ($type != 'inline') { $type = 'sidebyside'; } // we're trying to be clever here, revisions to compare can be either // given as rev and rev2 parameters, with rev2 being optional. Or in an // array in rev2. $rev1 = $REV; if (is_array($_REQUEST['rev2'])) { $rev1 = (int) $_REQUEST['rev2'][0]; $rev2 = (int) $_REQUEST['rev2'][1]; if (!$rev1) { $rev1 = $rev2; unset($rev2); } } else { $rev2 = (int) $_REQUEST['rev2']; } $r_minor = ''; $l_minor = ''; if ($text) { // compare text to the most current revision $l_rev = ''; $l_text = rawWiki($ID, ''); $l_head = '<a class="wikilink1" href="' . wl($ID) . '">' . $ID . ' ' . dformat((int) @filemtime(wikiFN($ID))) . '</a> ' . $lang['current']; $r_rev = ''; $r_text = cleanText($text); $r_head = $lang['yours']; } else { if ($rev1 && $rev2) { // two specific revisions wanted // make sure order is correct (older on the left) if ($rev1 < $rev2) { $l_rev = $rev1; $r_rev = $rev2; } else { $l_rev = $rev2; $r_rev = $rev1; } } elseif ($rev1) { // single revision given, compare to current $r_rev = ''; $l_rev = $rev1; } else { // no revision was given, compare previous to current $r_rev = ''; $revs = getRevisions($ID, 0, 1); $l_rev = $revs[0]; $REV = $l_rev; // store revision back in $REV } // when both revisions are empty then the page was created just now if (!$l_rev && !$r_rev) { $l_text = ''; } else { $l_text = rawWiki($ID, $l_rev); } $r_text = rawWiki($ID, $r_rev); if (!$l_rev) { $l_head = '—'; } else { $l_info = getRevisionInfo($ID, $l_rev, true); if ($l_info['user']) { $l_user = editorinfo($l_info['user']); if (auth_ismanager()) { $l_user .= ' (' . $l_info['ip'] . ')'; } } else { $l_user = $l_info['ip']; } $l_user = '******' . $l_user . '</span>'; $l_sum = $l_info['sum'] ? '<span class="sum">' . hsc($l_info['sum']) . '</span>' : ''; if ($l_info['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT) { $l_minor = 'class="minor"'; } $l_head = '<a class="wikilink1" href="' . wl($ID, "rev={$l_rev}") . '">' . $ID . ' [' . dformat($l_rev) . ']</a>' . '<br />' . $l_user . ' ' . $l_sum; } if ($r_rev) { $r_info = getRevisionInfo($ID, $r_rev, true); if ($r_info['user']) { $r_user = editorinfo($r_info['user']); if (auth_ismanager()) { $r_user .= ' (' . $r_info['ip'] . ')'; } } else { $r_user = $r_info['ip']; } $r_user = '******' . $r_user . '</span>'; $r_sum = $r_info['sum'] ? '<span class="sum">' . hsc($r_info['sum']) . '</span>' : ''; if ($r_info['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT) { $r_minor = 'class="minor"'; } $r_head = '<a class="wikilink1" href="' . wl($ID, "rev={$r_rev}") . '">' . $ID . ' [' . dformat($r_rev) . ']</a>' . '<br />' . $r_user . ' ' . $r_sum; } elseif ($_rev = @filemtime(wikiFN($ID))) { $_info = getRevisionInfo($ID, $_rev, true); if ($_info['user']) { $_user = editorinfo($_info['user']); if (auth_ismanager()) { $_user .= ' (' . $_info['ip'] . ')'; } } else { $_user = $_info['ip']; } $_user = '******' . $_user . '</span>'; $_sum = $_info['sum'] ? '<span class="sum">' . hsc($_info['sum']) . '</span>' : ''; if ($_info['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT) { $r_minor = 'class="minor"'; } $r_head = '<a class="wikilink1" href="' . wl($ID) . '">' . $ID . ' [' . dformat($_rev) . ']</a> ' . '(' . $lang['current'] . ')' . '<br />' . $_user . ' ' . $_sum; } else { $r_head = '— (' . $lang['current'] . ')'; } } $df = new Diff(explode("\n", htmlspecialchars($l_text)), explode("\n", htmlspecialchars($r_text))); if ($type == 'inline') { $tdf = new InlineDiffFormatter(); } else { $tdf = new TableDiffFormatter(); } if ($intro) { print p_locale_xhtml('diff'); } if (!$text) { ptln('<p class="difflink">'); $form = new Doku_Form(array('action' => wl())); $form->addHidden('id', $ID); $form->addHidden('rev2[0]', $l_rev); $form->addHidden('rev2[1]', $r_rev); $form->addHidden('do', 'diff'); $form->addElement(form_makeListboxField('difftype', array('sidebyside' => $lang['diff_side'], 'inline' => $lang['diff_inline']), $type, $lang['diff_type'], '', '', array('class' => 'quickselect'))); $form->addElement(form_makeButton('submit', 'diff', 'Go')); $form->printForm(); $diffurl = wl($ID, array('do' => 'diff', 'rev2[0]' => $l_rev, 'rev2[1]' => $r_rev, 'difftype' => $type)); ptln('<br /><a class="wikilink1" href="' . $diffurl . '">' . $lang['difflink'] . '</a>'); ptln('</p>'); } ?> <table class="diff diff_<?php echo $type; ?> "> <tr> <th colspan="2" <?php echo $l_minor; ?> > <?php echo $l_head; ?> </th> <th colspan="2" <?php echo $r_minor; ?> > <?php echo $r_head; ?> </th> </tr> <?php echo $tdf->format($df); ?> </table> <?php }
/** * Get info about existing schemas columns * * Returns only current, enabled columns * * @param string $schema the schema to query, empty for all * @return array * @throws RemoteAccessDeniedException * @throws RemoteException */ public function getSchema($schema) { if (!auth_ismanager()) { throw new RemoteAccessDeniedException('you need to be manager to access schema info'); } if (!$schema) { $schema = null; } try { $result = array(); $schemas = $this->hlp->getSchema($schema); foreach ($schemas as $name => $schema) { $result[$name] = array(); foreach ($schema->getColumns(false) as $column) { $result[$name][] = array('name' => $column->getLabel(), 'type' => array_pop(explode('\\', get_class($column->getType()))), 'ismulti' => $column->isMulti()); } } return $result; } catch (StructException $e) { throw new RemoteException($e->getMessage(), 0, $e); } }
private function oauth_isadmin() { /*{{{*/ if (auth_isadmin() || $this->getConf('manager_admin') && auth_ismanager()) { return true; } return false; }