Example #1
0
 /**
  * Metodo Session::getUser()
  * restituisce un oggetto user che ha avviato la sessione		
  */
 static function getUser()
 {
     if (isset($_SESSION['iduser'])) {
         $user = User::loadFromDatabase($_SESSION['iduser']);
         if ($user != false) {
             return $user;
         } else {
             //TODO header("location: http://ioesisto/?err=errore3…");
             echo "<p>Session Error: utente non presente nel database</p>";
         }
     }
 }
Example #2
0
 /**
  * Metodo Session::getUser()
  * restituisce un oggetto user che ha avviato la sessione		
  */
 static function getUser($who_asks = "Anonimous")
 {
     /*if( !session_start() )
     		return false;*/
     //require_once 'user/UserManager.php';
     //return UserManager::loadUser(1);
     if (isset($_SESSION["iduser"])) {
         $user = User::loadFromDatabase($_SESSION["iduser"], false);
         if (!isset($_SESSION["getUser"])) {
             $_SESSION["getUser"] = 1;
         } else {
             $_SESSION["getUser"]++;
         }
         if ($user != false) {
             return $user;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
Example #3
0
 /**
  * Create a new user object using data from session
  * @static
  */
 function loadFromSession()
 {
     global $wgMemc, $wgDBname, $wgCookiePrefix;
     if (isset($_SESSION['wsUserID'])) {
         if (0 != $_SESSION['wsUserID']) {
             $sId = $_SESSION['wsUserID'];
         } else {
             return new User();
         }
     } else {
         if (isset($_COOKIE["{$wgCookiePrefix}UserID"])) {
             $sId = intval($_COOKIE["{$wgCookiePrefix}UserID"]);
             $_SESSION['wsUserID'] = $sId;
         } else {
             return new User();
         }
     }
     if (isset($_SESSION['wsUserName'])) {
         $sName = $_SESSION['wsUserName'];
     } else {
         if (isset($_COOKIE["{$wgCookiePrefix}UserName"])) {
             $sName = $_COOKIE["{$wgCookiePrefix}UserName"];
             $_SESSION['wsUserName'] = $sName;
         } else {
             return new User();
         }
     }
     $passwordCorrect = FALSE;
     $user = $wgMemc->get($key = "{$wgDBname}:user:id:{$sId}");
     if (!is_object($user) || $user->mVersion < MW_USER_VERSION) {
         # Expire old serialized objects; they may be corrupt.
         $user = false;
     }
     if ($makenew = !$user) {
         wfDebug("User::loadFromSession() unable to load from memcached\n");
         $user = new User();
         $user->mId = $sId;
         $user->loadFromDatabase();
     } else {
         wfDebug("User::loadFromSession() got from cache!\n");
     }
     if (isset($_SESSION['wsToken'])) {
         $passwordCorrect = $_SESSION['wsToken'] == $user->mToken;
     } else {
         if (isset($_COOKIE["{$wgCookiePrefix}Token"])) {
             $passwordCorrect = $user->mToken == $_COOKIE["{$wgCookiePrefix}Token"];
         } else {
             return new User();
             # Can't log in from session
         }
     }
     if ($sName == $user->mName && $passwordCorrect) {
         if ($makenew) {
             if ($wgMemc->set($key, $user)) {
                 wfDebug("User::loadFromSession() successfully saved user\n");
             } else {
                 wfDebug("User::loadFromSession() unable to save to memcached\n");
             }
         }
         return $user;
     }
     return new User();
     # Can't log in from session
 }
Example #4
0
 /**
  * Special page main function
  */
 function execute($par)
 {
     global $wgRequest, $wgOut, $wgUser, $wgTitle;
     wfReviewExtensionInitMessages();
     $out = "";
     $skin =& $wgUser->getSkin();
     $mode = $wgRequest->getText('mode', 'view_page_statistics');
     $page_id = $wgRequest->getInt('page_id', 0);
     $rev_id = $wgRequest->getInt('rev_id', 0);
     $user_id = $wgRequest->getInt('user_id', 0);
     $user_ip = $wgRequest->getText('user_ip', "");
     $error = false;
     if ($user_id != 0 or $user_ip != "") {
         $theuser = new User();
         if ($user_id == 0) {
             $theuser->setName($user_ip);
         } else {
             $theuser->setID($user_id);
             $theuser->loadFromDatabase();
         }
     }
     if ($page_id == 0) {
         if ($par != '') {
             $title = Title::newFromURL($par);
             $page_id = $title->getArticleID();
         } else {
             $title = null;
         }
     } else {
         $title = Title::newFromID($page_id);
     }
     # Info ahead
     $o = array();
     if ($page_id != 0) {
         $link = $skin->makeLinkObj($title);
         $o[] = wfMsgForContent('review_concerns_page', $link);
     }
     if (isset($theuser)) {
         $link = $skin->makeLinkObj($theuser->getUserPage(), $theuser->getName());
         $o[] = wfMsgForContent('review_concerns_user', $link);
     }
     if ($page_id > 0 and $rev_id > 0) {
         $link = $skin->makeLinkObj($wgTitle, wfMsgForContent('revision_review_this_page_version_link'), "&mode=review&page_id={$page_id}&rev_id={$rev_id}");
         $o[] = $link;
     }
     if (count($o) > 0) {
         $out .= "<ul><li>" . implode("</li>\n<li>", $o) . "</li></ul>";
     }
     // FIXME: use private methods!
     # Modes
     if ($mode == 'view_page_statistics' && $title != null) {
         # View statistics for one page
         $revisions = $this->get_reviewed_revisions($title);
         arsort($revisions);
         # Newest first
         if (count($revisions) == 0) {
             $out .= wfMsgForContent('review_no_reviews_for_page', $skin->makeLinkObj($title));
         } else {
             # Load review data for each version separately to avoid memory apocalypse
             $statistics = array();
             $out .= "<table id='review_statistics_table'>\n";
             $out .= $this->get_revision_statistics_row($title, -1, $statistics);
             $out2 = "";
             foreach ($revisions as $revision) {
                 $reviews = $this->get_reviews_for_revision($title, $revision);
                 $data = $this->analyze_review_data($title, $revision, $reviews, $statistics);
                 $out2 .= $this->get_revision_statistics_row($title, $revision, $data);
             }
             $out .= $this->get_revision_statistics_row($title, 0, $statistics);
             $out .= $out2;
             $out .= "</table>\n";
         }
         $page_title = wfMsgForContent('review_for_page', $title->getPrefixedText());
     } else {
         if ($mode == 'view_version_statistics' && $title != null) {
             # View statistics for a specific version of a page
             $data = array();
             $out .= "<table id='review_statistics_table'>\n";
             $out .= $this->get_revision_statistics_row($title, -2, $data);
             $reviews = $this->get_reviews_for_revision($title, $rev_id);
             $this->analyze_review_data($title, $rev_id, $reviews, $data);
             $out .= $this->get_revision_statistics_row($title, 0, $data);
             # Statistics for the revision
             $data = $this->group_data_by_user($reviews);
             foreach ($data as $entry) {
                 $out .= $this->get_revision_statistics_row($title, 1, $entry, true);
             }
             $out .= "</table>\n";
             $page_title = wfMsgForContent('review_for_page', $title->getPrefixedText());
         } else {
             if ($mode == 'view_user_reviews' and isset($theuser)) {
                 if ($page_id != 0) {
                     # View the reviews of a user for a specific page
                     global $wgReviewFeatureSingleUserMode;
                     $wgReviewFeatureSingleUserMode = true;
                     $revisions = wfReviewExtensionGetUserRatingsForPage($title, $theuser);
                     $statistics = array();
                     $out .= "<table id='review_statistics_table'>\n";
                     $out .= $this->get_revision_statistics_row($title, -1, $statistics);
                     $out2 = "";
                     foreach ($revisions as $revision => $reviews) {
                         $data = $this->analyze_review_data($title, $revision, $reviews, $statistics);
                         $out2 .= $this->get_revision_statistics_row($title, $revision, $data);
                     }
                     $out .= $this->get_revision_statistics_row($title, 0, $statistics);
                     $out .= $out2;
                     $out .= "</table>\n";
                     $wgReviewFeatureSingleUserMode = false;
                 } else {
                     # View the pages reviewed by a user
                     $data = $this->get_list_of_pages_reviewed_by_user($theuser);
                     $out .= "<h2>" . wfMsgExt('review_user_page_list', array('content', 'parsemag'), $theuser->getName()) . "</h2>\n";
                     $data2 = array();
                     if ($user_id == 0) {
                         $user_link = "user_ip=" . $user_ip;
                     } else {
                         $user_link = "user_id=" . $user_id;
                     }
                     foreach ($data as $pid) {
                         $t = Title::newFromID($pid);
                         $link1 = $skin->makeLinkObj($t);
                         $link2 = $skin->makeLinkObj($wgTitle, wfMsgForContent('review_user_details_link'), "mode=view_user_reviews&" . $user_link . "&page_id={$pid}");
                         $data2[] = $link1 . " " . $link2;
                     }
                     asort($data2);
                     if (count($data2) > 0) {
                         $out .= "<ol><li>" . implode("</li>\n<li>", $data2) . "</li></ul>";
                     }
                 }
                 $page_title = wfMsgForContent('review_for_user', $theuser->getName());
             } else {
                 if ($mode == 'review') {
                     $out = $this->review_page($page_id, $rev_id);
                     $page_title = wfMsgForContent('review_page_review', $title->getPrefixedText());
                 } else {
                     $error = true;
                 }
             }
         }
     }
     $this->setHeaders();
     if ($error) {
         $wgOut->addHTML(wfMsgForContent('review_error'));
     } else {
         $wgOut->setPageTitle($page_title);
         $wgOut->addHTML($out);
     }
 }
    private function displayNABConsole(&$dbw, &$dbr, $target)
    {
        global $wgOut, $wgRequest, $wgUser, $wgParser;
        $not_found = false;
        $title = Title::newFromURL($target);
        if (!$title || !$title->exists()) {
            $articleName = $title ? $title->getFullText() : $target;
            $wgOut->addHTML("<p>Error: Article &ldquo;{$articleName}&rdquo; not found. Return to <a href='/Special:Newarticleboost'>New Article Boost</a> instead.</p>");
            $not_found = true;
        }
        if (!$not_found) {
            $rev = Revision::newFromTitle($title);
            if (!$rev) {
                $wgOut->addHTML("<p>Error: No revision for &ldquo;{$title->getFullText()}&rdquo;. Return to <a href='/Special:Newarticleboost'>New Article Boost</a> instead.</p>");
                $not_found = true;
            }
        }
        if (!$not_found) {
            $in_nab = $dbr->selectField('newarticlepatrol', 'count(*)', array('nap_page' => $title->getArticleID()), __METHOD__) > 0;
            if (!$in_nab) {
                $wgOut->addHTML("<p>Error: This article is not in the NAB list.</p>");
                $not_found = true;
            }
        }
        if ($not_found) {
            $pageid = $wgRequest->getVal('page');
            if (strpos($target, ':') !== false && $pageid) {
                $wgOut->addHTML('<p>We can to try to <a href="/Special:NABClean/' . $pageid . '">delete this title</a> if you know this title exists in NAB yet is likely bad data.</p>');
            }
            return;
        }
        $locked = false;
        $min_timestamp = $dbr->selectField("revision", "min(rev_timestamp)", "rev_page=" . $title->getArticleId(), __METHOD__);
        $first_user = $dbr->selectField("revision", "rev_user_text", array("rev_page=" . $title->getArticleId(), 'rev_timestamp' => $min_timestamp), __METHOD__);
        $first_user_id = $dbr->selectField("revision", "rev_user", array("rev_page=" . $title->getArticleId(), 'rev_timestamp' => $min_timestamp), __METHOD__);
        $user = new User();
        if ($first_user_id) {
            $user->setId($first_user_id);
            $user->loadFromDatabase();
        } else {
            $user->setName($first_user);
        }
        $user_talk = $user->getTalkPage();
        $ut_id = $user_talk->getArticleID();
        $display_name = $user->getRealName() ? $user->getRealName() : $user->getName();
        $wgOut->setPageTitle(wfMsg('nap_title', $title->getFullText()));
        $count = $dbr->selectField('suggested_titles', array('count(*)'), array('st_title' => $title->getDBKey()), __METHOD__);
        $extra = $count > 0 ? ' - from Suggested Titles database' : '';
        $wgOut->addWikiText(wfMsg('nap_writtenby', $user->getName(), $display_name, $extra));
        $wgOut->addHTML(wfMsgExt('nap_quicklinks', 'parseinline', $this->me->getFullText() . "/" . $title->getFullText()));
        /// CHECK TO SEE IF ARTICLE IS LOCKED OR ALREADY PATROLLED
        $aid = $title->getArticleID();
        $half_hour_ago = wfTimestamp(TS_MW, time() - 30 * 60);
        $patrolled = $dbr->selectField('newarticlepatrol', 'nap_patrolled', array("nap_page={$aid}"), __METHOD__);
        if ($patrolled) {
            $locked = true;
            $wgOut->addHTML(wfMsgExt("nap_patrolled", 'parse'));
        } else {
            $user_co = $dbr->selectField('newarticlepatrol', 'nap_user_co', array("nap_page={$aid}", "nap_timestamp_co > '{$half_hour_ago}'"), __METHOD__);
            if ($user_co != '' && $user_co != 0 && $user_co != $wgUser->getId()) {
                $x = User::newFromId($user_co);
                $wgOut->addHTML(wfMsgExt("nap_usercheckedout", 'parse', $x->getName()));
                $locked = true;
            } else {
                // CHECK OUT THE ARTICLE TO THIS USER
                $ts = wfTimestampNow();
                $dbw->update('newarticlepatrol', array('nap_timestamp_co' => $ts, 'nap_user_co' => $wgUser->getId()), array("nap_page = {$aid}"), __METHOD__);
            }
        }
        $expandSpan = '<span class="nap_expand">&#9660;</span>';
        $externalLinkImg = '<img src="' . wfGetPad('/skins/common/images/external.png') . '"/>';
        /// SIMILAR RESULT
        $wgOut->addHTML("<div class='nap_section minor_section'>");
        $wgOut->addHTML("<h2 class='nap_header'>{$expandSpan} " . wfMsg('nap_similarresults') . "</h2>");
        $wgOut->addHTML("<div class='nap_body section_text'>");
        $count = 0;
        $l = new LSearch();
        $hits = $l->googleSearchResultTitles($title->getFullText(), 0, 5);
        if (sizeof($hits) > 0) {
            $html = "";
            foreach ($hits as $hit) {
                $t1 = $hit;
                $id = rand(0, 500);
                if ($t1 == null || $t1->getFullURL() == $title->getFullURL() || $t1->getNamespace() != NS_MAIN || !$t1->exists()) {
                    continue;
                }
                $safe_title = htmlspecialchars(str_replace("'", "&#39;", $t1->getText()));
                $html .= "<tr><td>" . $this->skin->makeLinkObj($t1, wfMsg('howto', $t1->getText())) . "</td><td style='text-align:right; width: 200px;'>[<a href='#action' onclick='nap_Merge(\"{$safe_title}\");'>" . wfMsg('nap_merge') . "</a>] " . " [<a href='#action' onclick='javascript:nap_Dupe(\"{$safe_title}\");'>" . wfMsg('nap_duplicate') . "</a>] " . " <span id='mr_{$id}'>[<a onclick='javascript:nap_MarkRelated({$id}, {$t1->getArticleID()}, {$title->getArticleID()});'>" . wfMsg('nap_related') . "</a>]</span> " . "</td></tr>";
                $count++;
            }
        }
        if ($count == 0) {
            $wgOut->addHTML(wfMsg('nap_no-related-topics'));
        } else {
            $wgOut->addHTML(wfMsg('nap_already-related-topics') . "<table style='width:100%;'>{$html}</table>");
        }
        $wgOut->addHTML(wfMsg('nap_othersearches', urlencode($title->getFullText())));
        $wgOut->addHTML("</div>");
        $wgOut->addHTML("</div>");
        /// COPYRIGHT CHECKER
        $cc_check = SpecialPage::getTitleFor('Copyrightchecker', $title->getText());
        $wgOut->addHTML("<script type='text/javascript'>window.onload = nap_cCheck; var nap_cc_url = \"{$cc_check->getFullURL()}\";</script>");
        $wgOut->addHTML("<div class='nap_section minor_section'>");
        $wgOut->addHTML("<h2 class='nap_header'>{$expandSpan} " . wfMsg('nap_copyrightchecker') . "</h2>");
        $wgOut->addHTML("<div class='nap_body section_text'>");
        $wgOut->addHTML("<div id='nap_copyrightresults'><center><img src='/extensions/wikihow/rotate.gif' alt='loading...'/></center></div>");
        $wgOut->addHTML("<center><input type='button' class='button primary' onclick='nap_cCheck();' value='Check'/></center>");
        $wgOut->addHTML("</div>");
        $wgOut->addHTML("</div>");
        /// ARTICLE PREVIEW
        $editUrl = Title::makeTitle(NS_SPECIAL, "QuickEdit")->getFullURL() . "?type=editform&target=" . urlencode($title->getFullText()) . "&fromnab=1";
        $wgOut->addHTML("<div class='nap_section minor_section'>");
        $wgOut->addHTML("<a name='article' id='anchor-article'></a>");
        $wgOut->addHTML("<h2 class='nap_header'>{$expandSpan} " . wfMsg('nap_articlepreview') . " - <a href=\"{$title->getFullURL()}\" target=\"new\">" . wfMsg('nap_articlelinktext') . "</a> {$externalLinkImg}" . " - <a href=\"{$title->getEditURL()}\" target=\"new\">" . wfMsg('edit') . "</a> {$externalLinkImg}" . " - <a href=\"{$title->getFullURL()}?action=history\" target=\"new\">" . wfMsg('history') . "</a> {$externalLinkImg}" . " - <a href=\"{$title->getTalkPage()->getFullURL()}\" target=\"new\">" . wfMsg('discuss') . "</a> {$externalLinkImg}" . "</h2>");
        $wgOut->addHTML("<div class='nap_body section_text'>");
        $wgOut->addHTML("<div id='article_contents' ondblclick='nap_editClick(\"{$editUrl}\");'>");
        $popts = $wgOut->parserOptions();
        $popts->setTidy(true);
        // $parserOutput = $wgOut->parse($rev->getText(), $title, $popts);
        $output = $wgParser->parse($rev->getText(), $title, $popts);
        $parserOutput = $output->getText();
        $magic = WikihowArticleHTML::grabTheMagic($rev->getText());
        $html = WikihowArticleHTML::processArticleHTML($parserOutput, array('no-ads' => true, 'ns' => $title->getNamespace(), 'magic-word' => $magic));
        $wgOut->addHTML($html);
        $wgOut->addHTML("</div>");
        $wgOut->addHTML("<center><input id='editButton' type='button' class='button primary' name='wpEdit' value='" . wfMsg('edit') . "' onclick='nap_editClick(\"{$editUrl}\");'/></center>");
        $wgOut->addHTML("</div>");
        $wgOut->addHTML("</div>");
        $wgOut->addHTML('<div style="clear: both;"></div>');
        /// DISCUSSION PREVIEW
        $talkPage = $title->getTalkPage();
        $wgOut->addHTML("<div class='nap_section minor_section'>");
        $wgOut->addHTML("<a name='talk' id='anchor-talk'></a>");
        $wgOut->addHTML("<h2 class='nap_header'>{$expandSpan} " . wfMsg('nap_discussion') . " - <a href=\"{$talkPage->getFullURL()}\" target=\"new\">" . wfMsg('nap_articlelinktext') . "</a> {$externalLinkImg}" . "</h2>");
        $wgOut->addHTML("<div class='nap_body section_text'>");
        $wgOut->addHTML("<div id='disc_page'>");
        if ($talkPage->getArticleID() > 0) {
            $rp = Revision::newFromTitle($talkPage);
            $wgOut->addHTML($wgOut->parse($rp->getText()));
        } else {
            $wgOut->addHTML(wfMsg('nap_discussionnocontent'));
        }
        $wgOut->addHTML(PostComment::getForm(true, $talkPage, true));
        $wgOut->addHTML("</div>");
        $wgOut->addHTML("</div>");
        $wgOut->addHTML("</div>");
        /// USER INFORMATION
        $wgOut->addHTML("<div class='nap_section minor_section'>");
        $wgOut->addHTML("<a name='user' id='anchor-user'></a>");
        $used_templates = array();
        if ($ut_id > 0) {
            $res = $dbr->select('templatelinks', array('tl_title'), array('tl_from=' . $ut_id), __METHOD__);
            while ($row = $dbr->fetchObject($res)) {
                $used_templates[] = strtolower($row->tl_title);
            }
            $dbr->freeResult($res);
        }
        $wgOut->addHTML("<h2 class='nap_header'>{$expandSpan} " . wfMsg('nap_userinfo') . " - <a href=\"{$user_talk->getFullURL()}\" target=\"new\">" . wfMsg('nap_articlelinktext') . "</a> {$externalLinkImg}" . "</h2>");
        $wgOut->addHTML("<div class='nap_body section_text'>");
        $contribs = SpecialPage::getTitleFor('Contributions', $user->getName());
        $regDateTxt = "";
        if ($user->getRegistration() > 0) {
            preg_match('/^(\\d{4})(\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)$/D', $user->getRegistration(), $da);
            $uts = gmmktime((int) $da[4], (int) $da[5], (int) $da[6], (int) $da[2], (int) $da[3], (int) $da[1]);
            $regdate = gmdate('F j, Y', $uts);
            $regDateTxt = wfMsg('nap_regdatetext', $regdate) . ' ';
        }
        $key = 'nap_userinfodetails_anon';
        if ($user->getID() != 0) {
            $key = 'nap_userinfodetails';
        }
        $wgOut->addWikiText(wfMsg($key, $user->getName(), number_format(WikihowUser::getAuthorStats($first_user), 0, "", ","), $title->getFullText(), $regDateTxt));
        if (WikihowUser::getAuthorStats($first_user) < 50) {
            if ($user_talk->getArticleId() == 0) {
                $wgOut->addHTML(wfMsg('nap_newwithouttalkpage'));
            } else {
                $rp = Revision::newFromTitle($user_talk);
                $xtra = "";
                if (strpos($_SERVER['HTTP_USER_AGENT'], "MSIE 8.0") === false) {
                    $xtra = "max-height: 300px; overflow: scroll;";
                }
                $output = $wgParser->parse($rp->getText(), $user_talk, $popts);
                $parserOutput = $output->getText();
                $wgOut->addHTML("<div style='border: 1px solid #eee; {$xtra}'>" . $parserOutput . "</div>");
            }
        }
        if ($user_talk->getArticleId() != 0 && sizeof($used_templates) > 0) {
            $wgOut->addHTML('<br />' . wfMsg('nap_usertalktemplates', implode($used_templates, ", ")));
        }
        $wgOut->addHTML(PostComment::getForm(true, $user_talk, true));
        $wgOut->addHTML("</div>");
        $wgOut->addHTML("</div>");
        /// ACTION INFORMATION
        $maxrcid = $dbr->selectField('recentchanges', 'max(rc_id)', array('rc_cur_id=' . $aid), __METHOD__);
        $wgOut->addHTML("<div class='nap_section minor_section'>");
        $wgOut->addHTML("<a name='action' id='anchor-action'></a>");
        $wgOut->addHTML("<h2 class='nap_header'> " . wfMsg('nap_action') . "</h2>");
        $wgOut->addHTML("<div class='nap_body section_text'>");
        $wgOut->addHTML("<form action='{$this->me->getFullURL()}' name='nap_form' method='post' onsubmit='return checkNap();'>");
        $wgOut->addHTML("<input type='hidden' name='target' value='" . htmlspecialchars($title->getText()) . "'/>");
        $wgOut->addHTML("<input type='hidden' name='page' value='{$aid}'/>");
        $wgOut->addHTML("<input type='hidden' name='newbie' value='" . $wgRequest->getVal('newbie', 0) . "'/>");
        $wgOut->addHTML("<input type='hidden' name='prevuser' value='" . $user->getName() . "'/>");
        $wgOut->addHTML("<input type='hidden' name='maxrcid' value='{$maxrcid}'/>");
        $wgOut->addHTML("<table>");
        $suggested = $dbr->selectField('suggested_titles', 'count(*)', array('st_title' => $title->getDBKey()), __METHOD__);
        if ($suggested > 0) {
            $wgOut->addHTML("<tr><td valign='top'>" . wfMsg('nap_suggested_warning') . "</td></tr>");
        }
        $wgOut->addHTML("</table>");
        $wgOut->addHTML(wfMsg('nap_actiontemplates'));
        if ($wgUser->isAllowed('delete') || $wgUser->isAllowed('move')) {
            $wgOut->addHTML(wfMsg('nap_actionmovedeleteheader'));
            if ($wgUser->isAllowed('move')) {
                $wgOut->addHTML(wfMsg('nap_actionmove', htmlspecialchars($title->getText())));
            }
            if ($wgUser->isAllowed('delete')) {
                $wgOut->addHTML(wfMsg('nap_actiondelete'));
            }
        }
        // BUTTONS
        $wgOut->addHTML("<input type='submit' value='" . wfMsg('nap_skip') . "' id='nap_skip' name='nap_skip' class='button secondary' />");
        if (!$locked) {
            $wgOut->addHTML("<input type='submit' value='" . wfMsg('nap_markaspatrolled') . "' id='nap_submit' name='nap_submit' class='button primary' />");
        }
        $wgOut->addHTML("</form>");
        $wgOut->addHTML("</div>");
        $wgOut->addHTML("</div>");
        $wgOut->addHTML(<<<END
<script type='text/javascript'>

var tabindex = 1;
for(i = 0; i < document.forms.length; i++) {
\tfor (j = 0; j < document.forms[i].elements.length; j++) {
\t\tswitch (document.forms[i].elements[j].type) {
\t\t\tcase 'submit':
\t\t\tcase 'text':
\t\t\tcase 'textarea':
\t\t\tcase 'checkbox':
\t\t\tcase 'button':
\t\t\t\tdocument.forms[i].elements[j].tabIndex = tabindex++;
\t\t\t\tbreak;
\t\t\tdefault:
\t\t\t\tbreak;
\t\t}
\t}
}

// Handlers for expand/contract arrows
(function (\$) {
\$('.nap_expand').click(function() {
\tvar thisSpan = \$(this);
\tvar body = thisSpan.parent().next();
\tvar footer = body.next();
\tif (body.css('display') != 'none') {
\t\tfooter.hide();
\t\tbody.css('overflow', 'hidden');
\t\tvar oldHeight = body.height();
\t\tbody.animate(
\t\t\t{ height: 0 },
\t\t\t200,
\t\t\t'swing',
\t\t\tfunction () {
\t\t\t\tthisSpan.html('&#9658;');
\t\t\t\tbody
\t\t\t\t\t.hide()
\t\t\t\t\t.height(oldHeight);
\t\t\t});
\t} else {
\t\tvar oldHeight = body.height();
\t\tbody.height(0);
\t\tbody.animate(
\t\t\t{ height: oldHeight },
\t\t\t200,
\t\t\t'swing',
\t\t\tfunction () {
\t\t\t\tthisSpan.html('&#9660;');
\t\t\t\tfooter.show();
\t\t\t\tbody.css('overflow', 'visible');
\t\t\t});
\t}
\treturn false;
});
})(jQuery);

</script>

END
);
    }
Example #6
0
            } else {
                $predvolene = null;
            }
            $zoznam_uzivatelov = vsetci_uzivatelia();
            generuj_dropdown_box("uzivatel", $zoznam_uzivatelov, $predvolene);
            ?>
             <input type="hidden" name="pageaction" value="settings">
             <input type="hidden" name="subpageaction" value="nastavenie_opravneni">
             <input type="hidden" name="action" value="nastavenie_opravneni_zobraz">
             <input type="submit" name="submit" value="Potvrď">
             </form>
<?php 
            //zobrazime opravnenia pre daneho uzivatela
            if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "nastavenie_opravneni_zobraz") {
                $aktualny_uzivatel = new User();
                $aktualny_uzivatel->loadFromDatabase($_REQUEST["uzivatel"]);
                //natiahne opravnenia pre tohto konrektneho uzivatela aj s opravneniami
                $zoznam_opravneni = vsetky_opravnenia();
                //sekcia spracovania formularu ak tento bol odklepnuty
                if (isset($_REQUEST["spracovanie"]) && $_REQUEST["spracovanie"] == "nastavenie_opravneni_proceed") {
                    foreach ($zoznam_opravneni as $kluc => $hodnota) {
                        //kontrola ci je zaskrtnuty
                        if (isset($_REQUEST[$kluc])) {
                            //je zaskrtnuty
                            $aktualny_uzivatel->zapisOpravnenie($kluc);
                        } else {
                            //nieje zaskrtnuty
                            $aktualny_uzivatel->vymazOpravnenie($kluc);
                        }
                    }
                    //end foreach
Example #7
0
// $passwd = 'ckeqexon';
// $database  = new Database($dsn, $user, $passwd);
// DEVELOPING - classic mysql
$dsn = 'localhost';
$dbuser = '******';
$passwd = '';
$database_name = 'iqsklad';
$database = new Database($dsn, $dbuser, $passwd, $database_name);
global $uzivatel;
//definovanie globalnej premennej repreyentujucej uzivatela
global $aktivny_sklad;
if (is_registered()) {
    //uzivatel je prihlaseny
    //natiahnutie udajov o uzivatelovi z databazy
    $uzivatel = new User();
    $uzivatel->loadFromDatabase($_SESSION["user"]);
    //toto bz som nahradil natiahnutia zo session, bude to rychlejsie
    $aktivny_sklad = najdi_aktivny_sklad();
    //nacita do premennej aktivny_sklad vsetkz udaje o sklade
}
if (!isset($message)) {
    global $message;
    $message = new Message();
    //definovanie objektu na vypisovanie sprav
}
global $page;
$page = new Page();
//definovanie instancie triedy stranky (hlavne presmerovanie)
//definovanie smerovaca na stranky, bud sa naplni poziadavkou od uzivatela,
//alebo sa naplni vnutornym presmerovanim po vzkonani operacii
global $presmerovac;
 /**
  *
  * For the given userId, returns the html for that user's
  * avatar. Also makes $foundAdmin true if the current user
  * is an admin.
  *
  */
 static function getActualAvatar($user_id, &$foundAdmin)
 {
     if ($user_id) {
         $u = new User();
         $u->setID($user_id);
         if ($u->loadFromDatabase()) {
             $foundAdmin = $foundAdmin || $u->getGroups() && $u->isSysop();
         }
         $img = Avatar::getAvatarURL($u->getName());
         if ($img == '') {
             $img = Avatar::getDefaultPicture();
         } else {
             $img = "<img src='{$img}' />";
         }
         $avatar = "<div class='nfd_avatar'><a href='{$u->getUserPage()->getFullURL()}' target='_blank' class='tooltip'>{$img}</a>";
         $avatar .= "<span class='tooltip_span'>Hi, I'm {$u->getName()}</span></div>";
     }
     return $avatar;
 }
Example #9
0
 static function loadUser($id, $loadDependencies = true, $error = null)
 {
     return User::loadFromDatabase($id, $loadDependencies);
 }