Exemplo n.º 1
0
function PurgePage(&$request)
{
    global $WikiTheme;
    $page = $request->getPage();
    $pagelink = WikiLink($page);
    if ($request->getArg('cancel')) {
        $request->redirect(WikiURL($page));
        // noreturn
    }
    $current = $page->getCurrentRevision();
    if (!$current or !($version = $current->getVersion())) {
        $html = HTML::p(array('class' => 'error'), _("Sorry, this page does not exist."));
    } elseif (!$request->isPost() || !$request->getArg('verify')) {
        $purgeB = Button('submit:verify', _("Purge Page"), 'wikiadmin');
        $cancelB = Button('submit:cancel', _("Cancel"), 'button');
        // use generic wiki button look
        $fieldset = HTML::fieldset(HTML::p(fmt("You are about to purge '%s'!", $pagelink)), HTML::form(array('method' => 'post', 'action' => $request->getPostURL()), HiddenInputs(array('currentversion' => $version, 'pagename' => $page->getName(), 'action' => 'purge')), HTML::div(array('class' => 'toolbar'), $purgeB, $WikiTheme->getButtonSeparator(), $cancelB)));
        $sample = HTML::div(array('class' => 'transclusion'));
        // simple and fast preview expanding only newlines
        foreach (explode("\n", firstNWordsOfContent(100, $current->getPackedContent())) as $s) {
            $sample->pushContent($s, HTML::br());
        }
        $html = HTML($fieldset, HTML::div(array('class' => 'wikitext'), $sample));
    } elseif ($request->getArg('currentversion') != $version) {
        $html = HTML(HTML::p(array('class' => 'error'), _("Someone has edited the page!")), HTML::p(fmt("Since you started the purge process, someone has saved a new version of %s.  Please check to make sure you still want to permanently purge the page from the database.", $pagelink)));
    } else {
        // Real purge.
        $pagename = $page->getName();
        $dbi = $request->getDbh();
        $dbi->purgePage($pagename);
        $dbi->touch();
        $html = HTML::div(array('class' => 'feedback'), fmt("Purged page '%s' successfully.", $pagename));
    }
    GeneratePage($html, _("Purge Page"));
}
Exemplo n.º 2
0
 function showNotify(&$request, $messages, $page, $pagelist, $verified)
 {
     $isNecessary = !$this->contains($pagelist, $page);
     $form = HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), HiddenInputs(array('verify' => 1)), HiddenInputs($request->getArgs(), false, array('verify')), $messages, HTML::p(_("Your current watchlist: "), $this->showWatchList($pagelist)));
     if ($isNecessary) {
         $form->pushContent(HTML::p(_("New watchlist: "), $this->showWatchList($this->addpagelist($page, $pagelist))), HTML::p(sprintf(_("Do you %s want to add this page \"%s\" to your WatchList?"), $verified ? _("really") : "", $page)), HTML::p(Button('submit:add', _("Yes")), HTML::Raw(' '), Button('submit:cancel', _("Cancel"))));
     } else {
         $form->pushContent(HTML::p(fmt("The page %s is already watched!", $page)), HTML::p(Button('submit:edit', _("Edit")), HTML::Raw(' '), Button('submit:cancel', _("Cancel"))));
     }
     $fieldset = HTML::fieldset(HTML::legend("Watch Page"), $form);
     return $fieldset;
 }
Exemplo n.º 3
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     if ($request->getArg('action') != 'browse') {
         if ($request->getArg('action') != _("PhpWikiAdministration/SetAclSimple")) {
             return $this->disabled("(action != 'browse')");
         }
     }
     if (!ENABLE_PAGEPERM) {
         return $this->disabled("ENABLE_PAGEPERM = false");
     }
     $args = $this->getArgs($argstr, $request);
     $this->_args = $args;
     $this->preSelectS($args, $request);
     $p = $request->getArg('p');
     $post_args = $request->getArg('admin_setacl');
     $pages = array();
     if ($p && !$request->isPost()) {
         $pages = $p;
     } elseif ($this->_list) {
         $pages = $this->_list;
     }
     $header = HTML::fieldset();
     if ($p && $request->isPost() && (!empty($post_args['aclliberal']) || !empty($post_args['aclrestricted']))) {
         // without individual PagePermissions:
         if (!ENABLE_PAGEPERM and !$request->_user->isAdmin()) {
             $request->_notAuthorized(WIKIAUTH_ADMIN);
             $this->disabled("! user->isAdmin");
         }
         if (!empty($post_args['aclliberal'])) {
             return $this->setaclPages($request, array_keys($p), $this->liberalPerms());
         } else {
             if (!empty($post_args['aclrestricted'])) {
                 return $this->setaclPages($request, array_keys($p), $this->restrictedPerms());
             }
         }
     }
     if (empty($pages)) {
         // List all pages to select from.
         $pages = $this->collectPages($pages, $dbi, $args['sortby'], $args['limit'], $args['exclude']);
     }
     $pagelist = new PageList_Selectable($args['info'], $args['exclude'], array('types' => array('acl' => new _PageList_Column_acl('acl', _("ACL")))));
     $pagelist->addPageList($pages);
     $button_label_liberal = _("Set Liberal Access Rights");
     $button_label_restrictive = _("Set Restrictive Access Rights");
     $header = $this->setaclForm($header, $pages);
     $header->pushContent(HTML::legend(_("Select the pages where to change access rights")));
     $buttons = HTML::p(Button('submit:admin_setacl[aclliberal]', $button_label_liberal, 'wikiadmin'), Button('submit:admin_setacl[aclrestricted]', $button_label_restrictive, 'wikiadmin'));
     $header->pushContent($buttons);
     return HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), $header, $pagelist->getContent(), HiddenInputs($request->getArgs(), false, array('admin_setacl')), ENABLE_PAGEPERM ? '' : HiddenInputs(array('require_authority_for_post' => WIKIAUTH_ADMIN)));
 }
 function wiki_before_content()
 {
     $wiki_page = $this->request->get('wiki_page');
     $group_id = $this->request->get('group_id');
     $item_dao =& $this->_getItemDao();
     $docman_references = HTML();
     // Add js part for toogling referencers section.
     $js_code = '
         function toggle_documents(id) {
             Element.toggle(id);
             toggle_image(id);
         }
         function toggle_image(id) {
             var img_element = $(\'img_\' + id);
             if (img_element.src.indexOf(\'' . util_get_image_theme("ic/toggle_plus.png") . '\') != -1) {
                 img_element.src = \'' . util_get_image_theme("ic/toggle_minus.png") . '\';
                 img_element.title = \'' . $GLOBALS['Language']->getText('plugin_docman', 'docman_wiki_hide_referencers') . '\';
             } else {
                 img_element.src = \'' . util_get_image_theme("ic/toggle_plus.png") . '\';
                 img_element.title = \'' . $GLOBALS['Language']->getText('plugin_docman', 'docman_wiki_open_referencers') . '\';
             }
         }
             ';
     $docman_references->pushContent(HTML::script(array('type' => 'text/javascript'), $js_code));
     if ($item_dao->isWikiPageReferenced($wiki_page, $group_id)) {
         $docman_item_id = $item_dao->getItemIdByWikiPageAndGroupId($wiki_page, $group_id);
         if ($this->referrerIsDocument()) {
             $referrer_id = $this->getReferrerId($this->getReferrer());
         }
         if (isset($docman_item_id) && $docman_item_id) {
             $content = HTML();
             $script = HTML::script(array('type' => 'text/javascript'), "toggle_documents('documents');");
             $user =& $this->getUser();
             $dpm =& Docman_PermissionsManager::instance($group_id);
             // Wiki page could have many references in docman.
             if (is_array($docman_item_id)) {
                 $icon = HTML::img(array('id' => 'img_documents', 'src' => util_get_image_theme("ic/toggle_minus.png"), 'title' => $GLOBALS['Language']->getText('plugin_docman', 'docman_wiki_open_referencers')));
                 $linked_icon = HTML::a(array('href' => "#", 'onclick' => "javascript:toggle_documents('documents'); return false;"), $icon);
                 // creating the title of the section regarding number of referencing documents and from where we arrived to this wiki page.
                 if (count($docman_item_id) > 1) {
                     $title = "";
                     if (isset($referrer_id) && $referrer_id) {
                         $title = HTML::strong($GLOBALS['Language']->getText('plugin_docman', 'breadcrumbs_location') . " ");
                     } else {
                         $title = HTML::strong($GLOBALS['Language']->getText('plugin_docman', 'docman_wiki_breadcrumbs_locations') . " ");
                     }
                 } else {
                     if (count($docman_item_id) == 1) {
                         $title = HTML::strong($GLOBALS['Language']->getText('plugin_docman', 'breadcrumbs_location') . " ");
                     } else {
                         $title = "";
                     }
                 }
                 //create Full legend of the section
                 $legend = HTML::legend(array('class' => 'docman_md_frame'), count($docman_item_id) > 1 ? $linked_icon : "", $title, isset($referrer_id) && $referrer_id ? HTML($this->showReferrerPath($referrer_id, $group_id)) : "");
                 $details = HTML();
                 // create section body.
                 if (isset($referrer_id) && $referrer_id) {
                     if (count($docman_item_id) > 2) {
                         $details->pushContent(HTML::H3($GLOBALS['Language']->getText('plugin_docman', 'docman_wiki_other_locations') . " "));
                     } else {
                         if (count($docman_item_id) == 2) {
                             $details->pushContent(HTML::H3($GLOBALS['Language']->getText('plugin_docman', 'docman_wiki_other_location') . " "));
                         }
                     }
                 }
                 // create Referencing documents linked paths.
                 foreach ($docman_item_id as $index => $value) {
                     $details->pushContent($this->getDocumentPath($value, $group_id, isset($referrer_id) && $referrer_id ? $referrer_id : null));
                 }
                 $content->pushContent(HTML::div(array('id' => 'documents'), $details));
                 if (count($docman_item_id) == 1) {
                     $id = array_pop($docman_item_id);
                     $docman_references->pushContent(HTML::strong($GLOBALS['Language']->getText('plugin_docman', 'breadcrumbs_location') . " "));
                     $docman_references->pushContent(HTML($this->getDocumentPath($id, $group_id)));
                     $docman_references->pushContent(HTML::br());
                 } else {
                     $docman_references->pushContent(HTML::br());
                     $docman_references->pushContent(HTML::fieldset(array('class' => 'docman_md_frame'), $legend, $content, $script));
                 }
             } else {
                 if ($dpm->userCanAccess($user, $docman_item_id)) {
                     $docman_references->pushContent(HTML::strong($GLOBALS['Language']->getText('plugin_docman', 'breadcrumbs_location') . " "));
                     $docman_references->pushContent(HTML($this->getDocumentPath($docman_item_id, $group_id)));
                     //$docman_references->pushContent(HTML::br());
                 }
             }
         }
     }
     // Write documents paths on wiki view.
     // TODO: find another way to return a value.
     // Codendi_Request->params should not be public
     $this->request->params['html'] = $docman_references;
 }
Exemplo n.º 5
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     if ($request->getArg('action') != 'browse') {
         if (!$request->getArg('action') == _("PhpWikiAdministration/Chown")) {
             return $this->disabled("(action != 'browse')");
         }
     }
     $args = $this->getArgs($argstr, $request);
     $this->_args = $args;
     if (empty($args['user'])) {
         $args['user'] = $request->_user->UserName();
     }
     /*if (!empty($args['exclude']))
           $exclude = explodePageList($args['exclude']);
       else
       $exclude = false;*/
     $this->preSelectS($args, $request);
     $p = $request->getArg('p');
     if (!$p) {
         $p = $this->_list;
     }
     $post_args = $request->getArg('admin_chown');
     if (!$request->isPost() and empty($post_args['user'])) {
         $post_args['user'] = $args['user'];
     }
     $next_action = 'select';
     $pages = array();
     if ($p && !$request->isPost()) {
         $pages = $p;
     }
     if ($p && $request->isPost() && !empty($post_args['chown']) && empty($post_args['cancel'])) {
         // without individual PagePermissions:
         if (!ENABLE_PAGEPERM and !$request->_user->isAdmin()) {
             $request->_notAuthorized(WIKIAUTH_ADMIN);
             $this->disabled("! user->isAdmin");
         }
         // DONE: error message if not allowed.
         if ($post_args['action'] == 'verify') {
             // Real action
             return $this->chownPages($dbi, $request, array_keys($p), trim($post_args['user']));
         }
         if ($post_args['action'] == 'select') {
             if (!empty($post_args['user'])) {
                 $next_action = 'verify';
             }
             foreach ($p as $name => $c) {
                 $pages[$name] = 1;
             }
         }
     }
     if ($next_action == 'select' and empty($pages)) {
         // List all pages to select from.
         $pages = $this->collectPages($pages, $dbi, $args['sortby'], $args['limit'], $args['exclude']);
     }
     /* // let the user decide which info
         if ($next_action == 'verify') {
            $args['info'] = "checkbox,pagename,owner,mtime";
        }
        */
     if ($next_action == 'select') {
         $pagelist = new PageList_Selectable($args['info'], $args['exclude'], $args);
     } else {
         $pagelist = new PageList_Unselectable($args['info'], $args['exclude'], $args);
     }
     $pagelist->addPageList($pages);
     $header = HTML::fieldset();
     if ($next_action == 'verify') {
         $button_label = _("Yes");
         $header->pushContent(HTML::p(HTML::strong(_("Are you sure you want to permanently change the owner of the selected pages?"))));
         $header = $this->chownForm($header, $post_args);
     } else {
         $button_label = _("Change owner of selected pages");
         $header->pushContent(HTML::legend(_("Select the pages to change the owner")));
         $header = $this->chownForm($header, $post_args);
     }
     $buttons = HTML::p(Button('submit:admin_chown[chown]', $button_label, 'wikiadmin'), Button('submit:admin_chown[cancel]', _("Cancel"), 'button'));
     $header->pushContent($buttons);
     return HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), $header, $pagelist->getContent(), HiddenInputs($request->getArgs(), false, array('admin_chown')), HiddenInputs(array('admin_chown[action]' => $next_action)), ENABLE_PAGEPERM ? '' : HiddenInputs(array('require_authority_for_post' => WIKIAUTH_ADMIN)));
 }
Exemplo n.º 6
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     if ($request->getArg('action') != 'browse') {
         if ($request->getArg('action') != _("PhpWikiAdministration/SetAcl")) {
             return $this->disabled("(action != 'browse')");
         }
     }
     if (!ENABLE_PAGEPERM) {
         return $this->disabled("ENABLE_PAGEPERM = false");
     }
     $args = $this->getArgs($argstr, $request);
     $this->_args = $args;
     $this->preSelectS($args, $request);
     $p = $request->getArg('p');
     $post_args = $request->getArg('admin_setacl');
     $next_action = 'select';
     $pages = array();
     if ($p && !$request->isPost()) {
         $pages = $p;
     } elseif ($this->_list) {
         $pages = $this->_list;
     }
     $header = HTML::fieldset();
     if ($p && $request->isPost() && !empty($post_args['acl']) && empty($post_args['cancel'])) {
         // without individual PagePermissions:
         if (!ENABLE_PAGEPERM and !$request->_user->isAdmin()) {
             $request->_notAuthorized(WIKIAUTH_ADMIN);
             $this->disabled("! user->isAdmin");
         }
         if ($post_args['action'] == 'verify') {
             // Real action
             return $this->setaclPages($request, array_keys($p), $request->getArg('acl'));
         }
         if ($post_args['action'] == 'select') {
             if (!empty($post_args['acl'])) {
                 $next_action = 'verify';
             }
             foreach ($p as $name => $c) {
                 $pages[$name] = 1;
             }
         }
     }
     if ($next_action == 'select' and empty($pages)) {
         // List all pages to select from.
         $pages = $this->collectPages($pages, $dbi, $args['sortby'], $args['limit'], $args['exclude']);
     }
     if ($next_action == 'verify') {
         $args['info'] = "checkbox,pagename,perm,mtime,owner,author";
     }
     $pagelist = new PageList_Selectable($args['info'], $args['exclude'], array('types' => array('perm' => new _PageList_Column_perm('perm', _("Permission")), 'acl' => new _PageList_Column_acl('acl', _("ACL")))));
     $pagelist->addPageList($pages);
     if ($next_action == 'verify') {
         $button_label = _("Yes");
         $header = $this->setaclForm($header, $post_args, $pages);
         $header->pushContent(HTML::p(HTML::strong(_("Are you sure you want to permanently change access rights to the selected files?"))));
     } else {
         $button_label = _("Change Access Rights");
         $header = $this->setaclForm($header, $post_args, $pages);
         $header->pushContent(HTML::legend(_("Select the pages where to change access rights")));
     }
     $buttons = HTML::p(Button('submit:admin_setacl[acl]', $button_label, 'wikiadmin'), Button('submit:admin_setacl[cancel]', _("Cancel"), 'button'));
     $header->pushContent($buttons);
     return HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), $header, $pagelist->getContent(), HiddenInputs($request->getArgs(), false, array('admin_setacl')), HiddenInputs(array('admin_setacl[action]' => $next_action)), ENABLE_PAGEPERM ? '' : HiddenInputs(array('require_authority_for_post' => WIKIAUTH_ADMIN)));
 }
Exemplo n.º 7
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     if ($request->getArg('action') != 'browse') {
         if (!$request->getArg('action') == _("PhpWikiAdministration/SetExternal")) {
             return $this->disabled("(action != 'browse')");
         }
     }
     $args = $this->getArgs($argstr, $request);
     $this->_args = $args;
     $this->preSelectS($args, $request);
     $p = $request->getArg('p');
     if (!$p) {
         $p = $this->_list;
     }
     $post_args = $request->getArg('admin_external');
     if (!$request->isPost() and empty($post_args['external'])) {
         $post_args['external'] = $args['external'];
     }
     $pages = array();
     if ($p && !$request->isPost()) {
         $pages = $p;
     }
     if ($p && $request->isPost() && !empty($post_args['button']) && empty($post_args['cancel'])) {
         // without individual PagePermissions:
         if (!ENABLE_PAGEPERM and !$request->_user->isAdmin()) {
             $request->_notAuthorized(WIKIAUTH_ADMIN);
             $this->disabled("! user->isAdmin");
         }
         // Real action
         return $this->setExternalPages($dbi, $request, array_keys($p));
     }
     $pages = $this->collectPages($pages, $dbi, $args['sortby'], $args['limit'], $args['exclude']);
     $pagelist = new PageList_Selectable($args['info'], $args['exclude'], $args);
     $pagelist->addPageList($pages);
     $header = HTML::fieldset();
     $button_label = _("Set pages to external");
     $header->pushContent(HTML::legend(_("Select the pages to set as external")));
     $buttons = HTML::p(Button('submit:admin_external[button]', $button_label, 'wikiadmin'), Button('submit:admin_external[cancel]', _("Cancel"), 'button'));
     $header->pushContent($buttons);
     return HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), $header, $pagelist->getContent(), HiddenInputs($request->getArgs(), false, array('admin_external')), ENABLE_PAGEPERM ? '' : HiddenInputs(array('require_authority_for_post' => WIKIAUTH_ADMIN)));
 }
Exemplo n.º 8
0
function RevertPage(&$request)
{
    $mesg = HTML::div();
    $pagename = $request->getArg('pagename');
    $version = $request->getArg('version');
    if (!$version) {
        PrintXML(HTML::p(fmt("Revert"), " ", WikiLink($pagename)), HTML::p(_("missing required version argument")));
        return;
    }
    $dbi =& $request->_dbi;
    $page = $dbi->getPage($pagename);
    $current = $page->getCurrentRevision();
    $currversion = $current->getVersion();
    if ($currversion == 0) {
        $mesg->pushContent(' ', _("no page content"));
        PrintXML(HTML::p(fmt("Revert"), " ", WikiLink($pagename)), $mesg);
        flush();
        return;
    }
    if ($currversion == $version) {
        $mesg->pushContent(' ', _("same version page"));
        PrintXML(HTML::p(fmt("Revert"), " ", WikiLink($pagename)), $mesg);
        flush();
        return;
    }
    if ($request->getArg('cancel')) {
        $mesg->pushContent(' ', _("Cancelled"));
        PrintXML(HTML::p(fmt("Revert"), " ", WikiLink($pagename)), $mesg);
        flush();
        return;
    }
    if (!$request->getArg('verify')) {
        $mesg->pushContent(HTML::p(fmt("Are you sure to revert %s to version {$version}?", WikiLink($pagename))), HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), HiddenInputs($request->getArgs(), false, array('verify')), HiddenInputs(array('verify' => 1)), Button('submit:verify', _("Yes"), 'button'), HTML::Raw(' '), Button('submit:cancel', _("Cancel"), 'button')));
        $rev = $page->getRevision($version);
        $html = HTML(HTML::fieldset($mesg), HTML::hr(), $rev->getTransformedContent());
        $template = Template('browse', array('CONTENT' => $html));
        GeneratePage($template, $pagename, $rev);
        $request->checkValidators();
        flush();
        return;
    }
    $rev = $page->getRevision($version);
    $content = $rev->getPackedContent();
    $versiondata = $rev->_data;
    $versiondata['summary'] = sprintf(_("revert to version %d"), $version);
    $new = $page->save($content, $currversion + 1, $versiondata);
    $dbi->touch();
    $mesg = HTML::span();
    $pagelink = WikiLink($pagename);
    $mesg->pushContent(fmt("Revert: %s", $pagelink), fmt("- version %d saved to database as version %d", $version, $new->getVersion()));
    // Force browse of current page version.
    $request->setArg('version', false);
    $template = Template('savepage', array());
    $template->replace('CONTENT', $new->getTransformedContent());
    GeneratePage($template, $mesg, $new);
    flush();
}
Exemplo n.º 9
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     $args = $this->getArgs($argstr, $request);
     $user =& $request->_user;
     $user->_request = $request;
     if (isa($request, 'MockRequest')) {
         return '';
     }
     if (defined('FUSIONFORGE') and FUSIONFORGE) {
         if (!$user->isAuthenticated()) {
             return HTML::div(array('class' => 'errors'), _("Error: You are not logged in, cannot display UserPreferences."));
         }
     }
     if (!isActionPage($request->getArg('pagename')) and (!isset($user->_prefs->_method) or !in_array($user->_prefs->_method, array('ADODB', 'SQL', 'PDO'))) or in_array($request->getArg('action'), array('zip', 'ziphtml', 'dumphtml')) or isa($user, '_ForbiddenUser')) {
         $no_args = $this->getDefaultArguments();
         $no_args['errmsg'] = HTML::div(array('class' => 'errors'), _("Error: The user HomePage must be a valid WikiWord. Sorry, UserPreferences cannot be saved."));
         $no_args['isForm'] = false;
         return Template('userprefs', $no_args);
     }
     $userid = $user->UserName();
     if ($user->isAuthenticated() and !empty($userid)) {
         $pref =& $request->_prefs;
         $args['isForm'] = true;
         if ($request->isPost()) {
             $errmsg = '';
             $delete = $request->getArg('delete');
             if ($delete and $request->getArg('verify')) {
                 // deleting prefs, verified
                 $default_prefs = $pref->defaultPreferences();
                 $default_prefs['userid'] = $user->UserName();
                 $user->setPreferences($default_prefs);
                 $request->_setUser($user);
                 $request->setArg("verify", false);
                 $request->setArg("delete", false);
                 $errmsg .= _("Your UserPreferences have been successfully reset to default.");
                 $args['errmsg'] = HTML::div(array('class' => 'feedback'), HTML::p($errmsg));
                 return Template('userprefs', $args);
             } elseif ($delete and !$request->getArg('verify')) {
                 return HTML::fieldset(HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), HiddenInputs(array('verify' => 1)), HiddenInputs($request->getArgs()), HTML::p(_("Do you really want to reset all your UserPreferences?")), HTML::p(Button('submit:delete', _("Yes"), 'delete'), HTML::Raw(' '), Button('cancel', _("Cancel")))));
             } elseif ($rp = $request->getArg('pref')) {
                 // replace only changed prefs in $pref with those from request
                 if (!empty($rp['passwd']) and $rp['passwd2'] != $rp['passwd']) {
                     $errmsg = _("Wrong password. Try again.");
                 } else {
                     if (empty($rp['passwd'])) {
                         unset($rp['passwd']);
                     }
                     // fix to set system pulldown's. empty values don't get posted
                     if (empty($rp['theme'])) {
                         $rp['theme'] = '';
                     }
                     if (empty($rp['lang'])) {
                         $rp['lang'] = '';
                     }
                     $num = $user->setPreferences($rp);
                     if (!empty($rp['passwd'])) {
                         $passchanged = false;
                         if ($user->mayChangePass()) {
                             if (method_exists($user, 'storePass')) {
                                 $passchanged = $user->storePass($rp['passwd']);
                             }
                             if (!$passchanged and method_exists($user, 'changePass')) {
                                 $passchanged = $user->changePass($rp['passwd']);
                             }
                             if ($passchanged) {
                                 $errmsg = _("Password updated.");
                             } else {
                                 $errmsg = _("Password was not changed.");
                             }
                         } else {
                             $errmsg = _("Password cannot be changed.");
                         }
                     }
                     if (!$num) {
                         $errmsg .= " " . _("No changes.");
                     } else {
                         $request->_setUser($user);
                         $pref = $user->_prefs;
                         if ($num == 1) {
                             $errmsg .= _("One UserPreferences field successfully updated.");
                         } else {
                             $errmsg .= sprintf(_("%d UserPreferences fields successfully updated."), $num);
                         }
                     }
                 }
                 $args['errmsg'] = HTML::div(array('class' => 'feedback'), HTML::p($errmsg));
             }
         }
         $args['available_themes'] = listAvailableThemes();
         $args['available_languages'] = listAvailableLanguages();
         return Template('userprefs', $args);
     } else {
         // wrong or unauthenticated user
         return $request->_notAuthorized(WIKIAUTH_BOGO);
     }
 }
Exemplo n.º 10
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     if ($request->getArg('action') != 'browse') {
         if ($request->getArg('action') != _("PhpWikiAdministration/Remove")) {
             return $this->disabled("(action != 'browse')");
         }
     }
     $args = $this->getArgs($argstr, $request);
     if (!is_numeric($args['min_age'])) {
         $args['min_age'] = -1;
     }
     $this->_args =& $args;
     /*if (!empty($args['exclude']))
           $exclude = explodePageList($args['exclude']);
       else
       $exclude = false;*/
     $this->preSelectS($args, $request);
     $p = $request->getArg('p');
     if (!$p) {
         $p = $this->_list;
     }
     $post_args = $request->getArg('admin_remove');
     $next_action = 'select';
     $pages = array();
     if ($p && $request->isPost() && !empty($post_args['remove']) && empty($post_args['cancel'])) {
         // check individual PagePermissions
         if (!ENABLE_PAGEPERM and !$request->_user->isAdmin()) {
             $request->_notAuthorized(WIKIAUTH_ADMIN);
             $this->disabled("! user->isAdmin");
         }
         if ($post_args['action'] == 'verify') {
             // Real delete.
             return $this->removePages($request, array_keys($p));
         }
         if ($post_args['action'] == 'select') {
             $next_action = 'verify';
             foreach ($p as $name => $c) {
                 $name = str_replace(array('%5B', '%5D'), array('[', ']'), $name);
                 $pages[$name] = $c;
             }
         }
     } elseif ($p && is_array($p) && !$request->isPost()) {
         // from WikiAdminSelect
         $next_action = 'verify';
         foreach ($p as $name => $c) {
             $name = str_replace(array('%5B', '%5D'), array('[', ']'), $name);
             $pages[$name] = $c;
         }
         $request->setArg('p', false);
     }
     if ($next_action == 'select') {
         // List all pages to select from.
         $pages = $this->collectPages($pages, $dbi, $args['sortby'], $args['limit'], $args['exclude']);
     }
     $pagelist = new PageList_Selectable($args['info'], $args['exclude'], array('types' => array('remove' => new _PageList_Column_remove('remove', _("Remove")))));
     $pagelist->addPageList($pages);
     $header = HTML::fieldset();
     if ($next_action == 'verify') {
         $button_label = _("Yes");
         $header->pushContent(HTML::p(HTML::strong(_("Are you sure you want to permanently remove the selected files?"))));
     } else {
         $button_label = _("Remove selected pages");
         $header->pushContent(HTML::legend(_("Select the files to remove")));
         if ($args['min_age'] > 0) {
             $header->pushContent(fmt("Also pages which have been deleted at least %s days.", $args['min_age']));
         }
         if ($args['max_age'] > 0) {
             $header->pushContent(" ", fmt("Pages which have been deleted at least %s days are already checked.", $args['max_age']));
         }
     }
     $buttons = HTML::p(Button('submit:admin_remove[remove]', $button_label, 'wikiadmin'), Button('submit:admin_remove[cancel]', _("Cancel"), 'button'));
     $header->pushContent($buttons);
     // TODO: quick select by regex javascript?
     return HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), $header, $pagelist->getContent(), HiddenInputs($request->getArgs(), false, array('admin_remove')), HiddenInputs(array('admin_remove[action]' => $next_action, 'require_authority_for_post' => WIKIAUTH_ADMIN)));
 }
Exemplo n.º 11
0
     $result = $conn->query($insert_div_data);
     echo 'HTML & CSS Code created successfully<br/>';
     break;
 case 'image':
     $data_html = $obj->image($var_name, $label, $value, $div_name);
     $data_css = $obj_css->styles($var_name, $color, $width, $height, $x_position, $y_position, $z_index, $font_size, $font_color);
     $obj->write_to_file($data_html, $html_file_name, $css_file_name, $data_css);
     $insert = "INSERT INTO `CMS`.`html_css` (`ID`, `HTML`, `CSS`,  `FORM_ID`,`STATUS`, `NAME`) VALUES (NULL, '{$data_html}', '{$data_css}', {$index_of_form},'1', '{$label}');";
     $result = $conn->query($insert);
     $ID = mysqli_insert_id($conn);
     $insert_div_data = "INSERT INTO `CMS`.`divs` (`ID`, `ELEMENT`, `HTML_CSS_ID`) VALUES (NULL, '{$data_html}',{$ID});";
     $result = $conn->query($insert_div_data);
     echo 'HTML & CSS Code created successfully<br/>';
     break;
 case 'fieldset':
     $data_html = $obj->fieldset($var_name, $label, $value, $div_name);
     $data_css = $obj_css->styles($var_name, $color, $width, $height, $x_position, $y_position, $z_index, $font_size, $font_color);
     $obj->write_to_file($data_html, $html_file_name, $css_file_name, $data_css);
     $insert = "INSERT INTO `CMS`.`html_css` (`ID`, `HTML`, `CSS`,  `FORM_ID`,`STATUS`, `NAME`) VALUES (NULL, '{$data_html}', '{$data_css}', {$index_of_form},'1', '{$label}');";
     $result = $conn->query($insert);
     $ID = mysqli_insert_id($conn);
     $insert_div_data = "INSERT INTO `CMS`.`divs` (`ID`, `ELEMENT`, `HTML_CSS_ID`) VALUES (NULL, '{$data_html}',{$ID});";
     $result = $conn->query($insert_div_data);
     echo 'HTML & CSS Code created successfully<br/>';
     break;
 case 'table_row':
     $data_html = $obj->table_row($var_name, $label, $value, $div_name);
     $data_css = $obj_css->styles($var_name, $color, $width, $height, $x_position, $y_position, $z_index, $font_size, $font_color);
     $obj->write_to_file($data_html, $html_file_name, $css_file_name, $data_css);
     $insert = "INSERT INTO `CMS`.`html_css` (`ID`, `HTML`, `CSS`,  `FORM_ID`,`STATUS`, `NAME`) VALUES (NULL, '{$data_html}', '{$data_css}', {$index_of_form},'1', '{$label}');";
     $result = $conn->query($insert);
Exemplo n.º 12
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     // no action=replace support yet
     if ($request->getArg('action') != 'browse') {
         return $this->disabled("(action != 'browse')");
     }
     $args = $this->getArgs($argstr, $request);
     $this->_args = $args;
     //TODO: support p from <!plugin-list !>
     $this->preSelectS($args, $request);
     $p = $request->getArg('p');
     if (!$p) {
         $p = $this->_list;
     }
     $post_args = $request->getArg('admin_replace');
     $next_action = 'select';
     $pages = array();
     if ($p && !$request->isPost()) {
         $pages = $p;
     }
     if ($p && $request->isPost() && empty($post_args['cancel'])) {
         // without individual PagePermissions:
         if (!ENABLE_PAGEPERM and !$request->_user->isAdmin()) {
             $request->_notAuthorized(WIKIAUTH_ADMIN);
             $this->disabled("! user->isAdmin");
         }
         if ($post_args['action'] == 'verify' and !empty($post_args['from'])) {
             // Real action
             return $this->searchReplacePages($dbi, $request, array_keys($p), $post_args['from'], $post_args['to']);
         }
         if ($post_args['action'] == 'select') {
             if (!empty($post_args['from'])) {
                 $next_action = 'verify';
             }
             foreach ($p as $name => $c) {
                 $pages[$name] = 1;
             }
         }
     }
     if ($next_action == 'select' and empty($pages)) {
         // List all pages to select from.
         //TODO: check for permissions and list only the allowed
         $pages = $this->collectPages($pages, $dbi, $args['sortby'], $args['limit'], $args['exclude']);
     }
     if ($next_action == 'verify') {
         $args['info'] = "checkbox,pagename";
     } else {
         $args['info'] = "checkbox,pagename,hi_content,mtime,author";
     }
     $pagelist = new PageList_Selectable($args['info'], $args['exclude'], array_merge($args, array('types' => array('hi_content' => new _PageList_Column_content('rev:hi_content', _("Content"))))));
     $pagelist->addPageList($pages);
     $header = HTML::fieldset();
     if (empty($post_args['from'])) {
         $header->pushContent(HTML::p(HTML::em(_("Warning: The search string cannot be empty!"))));
     }
     if ($next_action == 'verify') {
         $button_label = _("Yes");
         $header->pushContent(HTML::p(HTML::strong(_("Are you sure you want to permanently replace text in the selected files?"))));
         $this->replaceForm($header, $post_args);
     } else {
         $button_label = _("Search & Replace");
         $this->replaceForm($header, $post_args);
         $header->pushContent(HTML::legend(_("Select the pages to search and replace")));
     }
     $buttons = HTML::p(Button('submit:admin_replace[replace]', $button_label, 'wikiadmin'), Button('submit:admin_replace[cancel]', _("Cancel"), 'button'));
     $header->pushContent($buttons);
     return HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), $header, $pagelist->getContent(), HiddenInputs($request->getArgs(), false, array('admin_replace')), HiddenInputs(array('admin_replace[action]' => $next_action)), ENABLE_PAGEPERM ? '' : HiddenInputs(array('require_authority_for_post' => WIKIAUTH_ADMIN)));
 }
Exemplo n.º 13
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     $action = $request->getArg('action');
     if ($action != 'browse' and $action != 'rename' and $action != _("PhpWikiAdministration") . "/" . _("Rename")) {
         return $this->disabled("(action != 'browse')");
     }
     if ($action == 'rename') {
         // We rename a single page.
         // No need to display "Regex?" and "Case insensitive?" boxes
         // No need to confirm
         $singlepage = true;
     } else {
         $singlepage = false;
     }
     $args = $this->getArgs($argstr, $request);
     $this->_args = $args;
     $this->preSelectS($args, $request);
     $p = $request->getArg('p');
     if (!$p) {
         $p = $this->_list;
     }
     $post_args = $request->getArg('admin_rename');
     $next_action = 'select';
     $pages = array();
     if ($p && !$request->isPost()) {
         $pages = $p;
     }
     if ($p && $request->isPost() && !empty($post_args['rename']) && empty($post_args['cancel'])) {
         // without individual PagePermissions:
         if (!ENABLE_PAGEPERM and !$request->_user->isAdmin()) {
             $request->_notAuthorized(WIKIAUTH_ADMIN);
             $this->disabled("! user->isAdmin");
         }
         // DONE: error message if not allowed.
         if ($post_args['action'] == 'verify') {
             // Real action
             return $this->renamePages($dbi, $request, array_keys($p), $post_args['from'], $post_args['to'], !empty($post_args['updatelinks']), !empty($post_args['createredirect']));
         }
     }
     if ($post_args['action'] == 'select') {
         if (!empty($post_args['from'])) {
             $next_action = 'verify';
         }
         foreach ($p as $name => $c) {
             $pages[$name] = 1;
         }
     }
     if ($next_action == 'select' and empty($pages)) {
         // List all pages to select from.
         $pages = $this->collectPages($pages, $dbi, $args['sortby'], $args['limit'], $args['exclude']);
     }
     /*if ($next_action == 'verify') {
           $args['info'] = "checkbox,pagename,renamed_pagename";
       }*/
     $pagelist = new PageList_Selectable($args['info'], $args['exclude'], array('types' => array('renamed_pagename' => new _PageList_Column_renamed_pagename('rename', _("Rename to")))));
     $pagelist->addPageList($pages);
     $header = HTML::div();
     if ($next_action == 'verify') {
         $button_label = _("Yes");
         $header->pushContent(HTML::p(HTML::strong(_("Are you sure you want to permanently rename the selected pages?"))));
         $header = $this->renameForm($header, $post_args, $singlepage);
     } else {
         if ($singlepage === true) {
             $button_label = _("Rename page");
         } else {
             $button_label = _("Rename selected pages");
         }
         if (!$post_args and count($pages) == 1) {
             list($post_args['from'], ) = array_keys($pages);
             $post_args['to'] = $post_args['from'];
         }
         $header = $this->renameForm($header, $post_args, $singlepage);
         if ($singlepage === false) {
             $header->pushContent(HTML::p(_("Select the pages to rename:")));
         }
     }
     $buttons = HTML::p(Button('submit:admin_rename[rename]', $button_label, 'wikiadmin'), Button('submit:admin_rename[cancel]', _("Cancel"), 'button'));
     if ($singlepage === false) {
         $list = $pagelist->getContent();
     } else {
         $list = "";
     }
     return HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), HTML::fieldset(HTML::legend("Rename page"), $header, $buttons, $list, HiddenInputs($request->getArgs(), false, array('admin_rename')), HiddenInputs(array('admin_rename[action]' => $next_action)), ENABLE_PAGEPERM ? '' : HiddenInputs(array('require_authority_for_post' => WIKIAUTH_ADMIN))));
 }