Example #1
0
 /**
  * @param string $realname
  * @return bool
  */
 private function setRealName($realname)
 {
     if ($this->user->getRealName() !== $realname) {
         $this->user->setRealName($realname);
         return true;
     }
     return false;
 }
Example #2
0
 /**
  * @inheritdoc
  */
 public function getRealName()
 {
     $knownRealName = $this->user->getRealName();
     if (!empty($knownRealName)) {
         return $knownRealName;
     }
     return $this->realName;
 }
    /**
     * Generate the generic "this page has been changed" e-mail text.
     */
    protected function composeCommonMailtext()
    {
        global $wgPasswordSender, $wgPasswordSenderName, $wgNoReplyAddress;
        global $wgEnotifFromEditor, $wgEnotifRevealEditorAddress;
        global $wgEnotifUseRealName, $wgRequest;
        $this->composed_common = true;
        if ($this->editor->isAnon()) {
            $pageEditor = wfMsgForContent('enotif_anon_editor', $this->editor->getName());
        } else {
            $pageEditor = $wgEnotifUseRealName ? $this->editor->getRealName() : $this->editor->getName();
        }
        // build the subject
        $this->subject = wfMessage('moodbar-enotif-subject')->params($pageEditor)->escaped();
        // build the body
        $targetUserName = $this->targetUser->getName();
        $links = $this->buildEmailLink();
        //text version, no need to escape since client will interpret it as plain text
        $textBody = wfMessage('moodbar-enotif-body')->params($targetUserName, $links['feedbackPageUrl'], $links['editorTalkPageUrl'], $this->response, $links['targetUserTalkPageUrl'], $pageEditor)->text();
        //html version, this is a little bit ugly as we have to make wiki link clickable in emails
        $action = $wgRequest->getVal('action');
        $wgRequest->setVal('action', 'render');
        $htmlBody = wfMsgExt('moodbar-enotif-body', array('parse'), $targetUserName, $links['feedbackPageUrl'], $links['editorTalkPageUrl'], '<div style="margin-left:20px; margin-right:20px;">"' . $this->response . '"</div>', $links['targetUserTalkPageUrl'], $pageEditor);
        $wgRequest->setVal('action', $action);
        // assemble the email body
        $this->body = <<<HTML
--{$this->mime_boundary}
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

{$textBody}

--{$this->mime_boundary}
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<html>
\t<body>
\t\t{$htmlBody}
\t</body>
</html>

--{$this->mime_boundary}--
HTML;
        # Reveal the page editor's address as REPLY-TO address only if
        # the user has not opted-out and the option is enabled at the
        # global configuration level.
        $adminAddress = new MailAddress($wgPasswordSender, $wgPasswordSenderName);
        if ($wgEnotifRevealEditorAddress && $this->editor->getEmail() != '' && $this->editor->getOption('enotifrevealaddr')) {
            $editorAddress = new MailAddress($this->editor);
            if ($wgEnotifFromEditor) {
                $this->from = $editorAddress;
            } else {
                $this->from = $adminAddress;
                $this->replyto = $editorAddress;
            }
        } else {
            $this->from = $adminAddress;
            $this->replyto = new MailAddress($wgNoReplyAddress);
        }
    }
 /**
  *  method to stamp each pdf page (add a banner with timestamp user real name and  confidentiality level)
  *  @param  void
  *  @return void
  */
 public function stamp($values)
 {
     // Prepare stamp
     if ($values != null) {
         $first = true;
         foreach ($values as $value) {
             if ($first) {
                 $sep = '';
                 $first = false;
             } else {
                 $sep = ', ';
             }
             $valueTxt = $sep . $value->getName();
         }
     } else {
         $valueTxt = '';
     }
     $text = "Downloaded on " . date("d M Y H:i", $_SERVER['REQUEST_TIME']) . " by " . $this->user->getRealName() . " " . $valueTxt;
     $stamp = $text . " // " . $text;
     // Text and box style
     $style = new Zend_Pdf_Style();
     $style->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD), 10);
     $style->setFillColor(new Zend_Pdf_Color_Rgb(1, 0, 0));
     $style->setLineColor(new Zend_Pdf_Color_Rgb(1, 0, 0));
     //get pdf watermarking level based on number of pages in pdf document.
     $watermarkingLevel = $this->getWatermarkingLevelFromPdfSize();
     // Stamp with adequate watermarking level
     switch ($watermarkingLevel) {
         case self::WATERMARK_EVERYPAGE:
             // Apply it on all pages
             foreach ($this->pdf->pages as $page) {
                 $this->stampOnePage($page, $style, $stamp);
             }
             break;
         case self::WATERMARK_EVERY_TWO_PAGES:
             $count = 0;
             foreach ($this->pdf->pages as $page) {
                 if ($count % 2 == 0) {
                     $this->stampOnePage($page, $style, $stamp);
                 }
                 $count++;
             }
             break;
         case self::WATERMARK_THIRTY_PERCENT_OF_PAGES:
             $pagesToWatermark = $this->getPagesToWatermark(0.3, count($this->pdf->pages));
             foreach ($pagesToWatermark as $pageNo) {
                 $this->stampOnePage($this->pdf->pages[$pageNo], $style, $stamp);
             }
             break;
         case self::WATERMARK_TEN_PERCENT_OF_PAGES:
         default:
             $pagesToWatermark = $this->getPagesToWatermark(0.1, count($this->pdf->pages));
             foreach ($pagesToWatermark as $pageNo) {
                 $this->stampOnePage($this->pdf->pages[$pageNo], $style, $stamp);
             }
             break;
     }
 }
 private function getProperty($params)
 {
     switch ($params[0]) {
         case "author_realname":
             $user = new User($this->pdo->databaseConnector, "", $this->pdo->getContent("owner"));
             return $user->getRealName();
         case "author_nickname":
             $user = new User($this->pdo->databaseConnector, "", $this->pdo->getContent("owner"));
             return $user->getNickName();
     }
 }
Example #6
0
 protected function getRealName()
 {
 	if ($this->m_realName === false) {
     	$userId = $this->m_dbObject->getUserId();
         if ($userId > 0) {
             $userObj = new User($userId);
             $this->m_realName = $userObj->getRealName();
         } else {
         	$this->m_realName = null;
         }
 	}
 	return $this->m_realName;
 }
 function getProperty($name)
 {
     switch ($name) {
         case "author_realname":
             $user = new User($this->pdo->databaseConnector, "", $this->pdo->getContent("owner"));
             echo $user->getRealName();
             break;
         case "author_nickname":
             $user = new User($this->pdo->databaseConnector, "", $this->pdo->getContent("owner"));
             echo $user->getNickName();
             break;
     }
 }
 /**
  * Do all the synchronization between an ldap result and a Tuleap user.
  *
  * This method returns if it modified the user or not. This is usefull during
  * batch process in order to limit computing.
  *
  * @param User       $user User
  * @param LDAPResult $lr   Ldap result
  *
  * @return Boolean True if the method modified the user object
  */
 public function sync(User $user, LDAPResult $lr)
 {
     $modified = false;
     $ldapEmail = $lr->getEmail();
     $realname = ucwords(preg_replace('/^(\\w+).(\\w+)@.*/', '\\1 \\2', $ldapEmail));
     if ($realname !== null && $user->getRealName() != substr($realname, 0, 32)) {
         $user->setRealName($realname);
         $modified = true;
     }
     if ($ldapEmail !== null && $user->getEmail() != $ldapEmail) {
         $user->setEmail($ldapEmail);
         $modified = true;
     }
     return $modified;
 }
 /**
  * This method actually generates the output
  * @param array $aParams not used here
  * @return string HTML output
  */
 public function execute($aParams = false)
 {
     global $wgUser;
     $sUserName = $this->oUser->getName();
     $sUserRealName = $this->oUser->getRealName();
     //Fallback for old entries without user_id
     if ($this->oUser->isAnon()) {
         $sUserName = $this->sUsername;
     }
     $aOut = array();
     $aOut[] = '<li class="bs-sb-listitem clearfix" id="bs-sb-' . $this->iShoutID . '">';
     $aOut[] = '  <div class="bs-user-image">';
     if ($this->oMiniProfile instanceof ViewUserMiniProfile) {
         $aOut[] = $this->oMiniProfile->execute();
     }
     $aOut[] = '  </div>';
     $aOut[] = '  <div class="bs-sb-message">';
     $aOut[] = '    <div class="bs-sb-message-head">';
     $aOut[] = '      <strong>' . $sUserName . '</strong>';
     if (!empty($sUserRealName)) {
         $aOut[] = '      <span class="bs-sb-meassage-head-small">' . $sUserRealName . '</span>';
     }
     $aOut[] = '    </div>';
     if (isset($this->sDate)) {
         $aOut[] = '<div class="bs-sb-message-time">' . $this->sDate;
         $aOut[] = '</div> ';
     }
     $aOut[] = '    <div class="bs-sb-message-text">' . nl2br($this->sMessage);
     $aOut[] = '    </div> ';
     $aOut[] = '  </div>';
     $sArchiveButton = '';
     $sArchiveButtonEnabled = '  <div class="bs-sb-archive"></div>';
     //set button if user has the right to archive
     if (BsCore::checkAccessAdmission('archiveshoutbox')) {
         $sArchiveButton = $sArchiveButtonEnabled;
     }
     //if setting for "allow own entries to be archived" is set + username == shoutbox-entry-username => set button
     if (BsConfig::get('MW::ShoutBox::AllowArchive') && $wgUser->getName() == $sUserName) {
         $sArchiveButton = $sArchiveButtonEnabled;
     }
     $aOut[] = $sArchiveButton;
     $aOut[] = '</li>';
     return implode("\n", $aOut);
 }
Example #10
0
/**
 * Set Lock Info and Row Class strings
 * for the usage in Article list tables.
 *
 * @param object $p_articleObj
 * @param string $p_lockInfo
 * @param string $p_rowClass
 * @param boolean $p_color
 */
function camp_set_article_row_decoration(&$p_articleObj, &$p_lockInfo, &$p_rowClass, &$p_color)
{
    global $g_user;
    $p_lockInfo = '';
    $timeDiff = camp_time_diff_str($p_articleObj->getLockTime());
    if ($p_articleObj->isLocked() && $timeDiff['days'] <= 0) {
        $lockUserObj = new User($p_articleObj->getLockedByUser());
        if ($timeDiff['hours'] > 0) {
            $p_lockInfo = getGS('The article has been locked by $1 ($2) $3 hour(s) and $4 minute(s) ago.', htmlspecialchars($lockUserObj->getRealName()), htmlspecialchars($lockUserObj->getUserName()), $timeDiff['hours'], $timeDiff['minutes']);
        } else {
            $p_lockInfo = getGS('The article has been locked by $1 ($2) $3 minute(s) ago.', htmlspecialchars($lockUserObj->getRealName()), htmlspecialchars($lockUserObj->getUserName()), $timeDiff['minutes']);
        }
    }
    if ($p_articleObj->isLocked() && $timeDiff['days'] <= 0 && $p_articleObj->getLockedByUser() != $g_user->getUserId()) {
        $p_rowClass = "article_locked";
    } else {
        if ($p_color) {
            $p_rowClass = "list_row_even";
        } else {
            $p_rowClass = "list_row_odd";
        }
    }
    $p_color = !$p_color;
}
 function getDocentsForCategory($title)
 {
     $html = "";
     $results = array();
     $dbr = wfGetDB(DB_SLAVE);
     $res = $dbr->select(array('docentcategories', 'user'), array('user_id', 'user_name', 'user_real_name'), array('dc_user=user_id', 'dc_to' => $title->getDBKey()));
     while ($row = $dbr->fetchObject($res)) {
         $u = new User();
         $u->setName($row->user_name);
         $u->setRealName($row->user_real_name);
         $results[] = $u;
     }
     $html = "<div id='docents'>";
     if (sizeof($results) > 0) {
         $html .= "<h2><span id='docent_header'>" . wfMsg('docents') . "</span></h2><p>\n";
         $first = true;
         foreach ($results as $u) {
             $display = $u->getRealName() == "" ? $u->getName() : $u->getRealName();
             if ($first) {
                 $first = false;
             } else {
                 $html .= "<strong>&bull;</strong>";
             }
             $html .= " <a href='" . $u->getUserPage()->getFullURL() . "'>{$display}</a>\n";
         }
         $html .= "</p>";
     } else {
         $html .= "<h2><span id='docent_header'>" . wfMsg('docents') . "</span></h2><p>\n";
         $html .= wfMsg('no_docents');
     }
     $html .= "<div id='become_docent'><span>+</span>" . wfMsg('become_a_docent') . "</div></div>";
     return $html;
 }
 /**
  * Get a link to $user's user page
  * @param $user User object
  * @return String: html
  */
 protected function link(User $user)
 {
     global $wgHiddenPrefs;
     if (!in_array('realname', $wgHiddenPrefs) && !$user->isAnon()) {
         $real = $user->getRealName();
     } else {
         $real = false;
     }
     $page = $user->isAnon() ? SpecialPage::getTitleFor('Contributions', $user->getName()) : $user->getUserPage();
     return Linker::link($page, htmlspecialchars($real ? $real : $user->getName()));
 }
    /**
     * Create the first message for an article, which is a blank message
     * with the title of the article as the subject.
     *
     * @param Article $p_article
     * @param int $p_forumId
     * @return mixed
     * 		The comment created (or the one that already exists) on success,
     *  	or false on error.
     */
    private function CreateFirstComment($p_article, $p_forumId)
    {
        // Check if the first post already exists.
        $articleNumber = $p_article->getArticleNumber();
        $languageId = $p_article->getLanguageId();
        $firstPost = ArticleComment::GetCommentThreadId($articleNumber, $languageId);
        if ($firstPost) {
            return new Phorum_message($firstPost);
        }

        // Get article creator
        $user = new User($p_article->getCreatorId());
        if ($user->exists()) {
            $userId = $user->getUserId();
            $userEmail = $user->getEmail();
            $userPasswd = $user->getPassword();
            $userName = $user->getUserName();
            $userRealName = $user->getRealName();

            // Create phorum user if necessary
            $phorumUser = Phorum_user::GetByUserName($userName);
            if (!is_object($phorumUser)) {
                $phorumUser = new Phorum_user();
            }
            if (!$phorumUser->CampUserExists($userId)
            && !$phorumUser->create($userName, $userPasswd, $userEmail, $userId)) {
                return null;
            }
        } else {
            $userId = null;
            $userEmail = '';
            $userRealName = '';
        }

        // Create the comment.
        $title = $p_article->getTitle();
        $commentObj = new Phorum_message();
        if ($commentObj->create($p_forumId, $title, '', 0, 0, $userRealName,
        $userEmail, is_null($userId) ? 0 : $userId)) {
            // Link the message to the current article.
            ArticleComment::Link($articleNumber, $languageId, $commentObj->getMessageId(), true);
            return $commentObj;
        } else {
            return null;
        }
    } // method CreateFirstComment
    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 #15
0
	protected function person( $name, User $user ) {
		global $wgHiddenPrefs;

		if ( $user->isAnon() ) {
			$this->element( $name, wfMessage( 'anonymous' )->numParams( 1 )->text() );
		} else {
			$real = $user->getRealName();
			if ( $real && !in_array( 'realname', $wgHiddenPrefs ) ) {
				$this->element( $name, $real );
			} else {
				$userName = $user->getName();
				$this->pageOrString(
					$name,
					$user->getUserPage(),
					wfMessage( 'siteuser', $userName, $userName )->text()
				);
			}
		}
	}
 /**
  * Set users' fields from SAML attributes.
  * If the user does not exist in the MediaWiki database,
  * it is created. wgSamlCreateUser is not respected.
  *
  * @param User $user the user
  * @param string[][] $attr SAML attributes
  */
 protected static function updateUser(User $user, $attr)
 {
     global $wgSamlRealnameAttr;
     global $wgSamlUsernameAttr;
     global $wgSamlMailAttr;
     global $wgContLang;
     $changed = false;
     if (isset($wgSamlRealnameAttr) && isset($attr[$wgSamlRealnameAttr]) && $attr[$wgSamlRealnameAttr] && $user->getRealName() !== reset($attr[$wgSamlRealnameAttr])) {
         $changed = true;
         $user->setRealName(reset($attr[$wgSamlRealnameAttr]));
     }
     if ($attr[$wgSamlMailAttr] && $user->getEmail() !== reset($attr[$wgSamlMailAttr])) {
         $changed = true;
         $user->setEmail(reset($attr[$wgSamlMailAttr]));
         $user->ConfirmEmail();
     }
     if (!$user->getId()) {
         $user->setName($wgContLang->ucfirst(reset($attr[$wgSamlUsernameAttr])));
         $user->setPassword(null);
         // prevent manual login until reset
         $user->addToDatabase();
     } elseif ($changed) {
         $user->saveSettings();
     }
 }
 /**
  * Add a user to the external authentication database.
  * Return true if successful.
  *
  * @param User $user
  * @param string $password
  * @return bool
  * @access public
  */
 function addUser($user, $password)
 {
     global $wgLDAPAddLDAPUsers, $wgLDAPWikiDN, $wgLDAPWikiPassword;
     global $wgLDAPSearchStrings;
     global $wgLoggedInGroupId;
     if (!$wgLDAPAddLDAPUsers || 'local' == $_SESSION['wsDomain']) {
         return true;
     }
     $this->email = $user->getEmail();
     $this->realname = $user->getRealName();
     $username = $user->getName();
     $pwd_md5 = base64_encode(pack('H*', sha1($password)));
     $pass = "{SHA}" . $pwd_md5;
     $tmpuserdn = $wgLDAPSearchStrings[$_SESSION['wsDomain']];
     $userdn = str_replace("USER-NAME", $user->getName(), $tmpuserdn);
     $ldapconn = $this->connect();
     if ($ldapconn) {
         ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
         $bind = @ldap_bind($ldapconn, $wgLDAPWikiDN, $wgLDAPWikiPassword);
         if (!$bind) {
             return false;
         }
         $values["uid"] = $username;
         $values["sn"] = $username;
         if ('' != $this->email) {
             $values["mail"] = $this->email;
         }
         if ('' != $this->realname) {
             $values["cn"] = $this->realname;
         } else {
             $values["cn"] = $username;
         }
         $values["userpassword"] = $pass;
         $values["objectclass"] = "inetorgperson";
         if (@ldap_add($ldapconn, $userdn, $values)) {
             @ldap_unbind();
             return true;
         } else {
             @ldap_unbind();
             return false;
         }
     } else {
         return false;
     }
 }
Example #18
0
 /**
  * @param User $user
  * @param IContextSource $context
  * @param array $defaultPreferences
  * @return void
  */
 static function profilePreferences($user, IContextSource $context, &$defaultPreferences)
 {
     global $wgAuth, $wgContLang, $wgParser;
     $config = $context->getConfig();
     // retrieving user name for GENDER and misc.
     $userName = $user->getName();
     # # User info #####################################
     // Information panel
     $defaultPreferences['username'] = array('type' => 'info', 'label-message' => array('username', $userName), 'default' => $userName, 'section' => 'personal/info');
     # Get groups to which the user belongs
     $userEffectiveGroups = $user->getEffectiveGroups();
     $userGroups = $userMembers = array();
     foreach ($userEffectiveGroups as $ueg) {
         if ($ueg == '*') {
             // Skip the default * group, seems useless here
             continue;
         }
         $groupName = User::getGroupName($ueg);
         $userGroups[] = User::makeGroupLinkHTML($ueg, $groupName);
         $memberName = User::getGroupMember($ueg, $userName);
         $userMembers[] = User::makeGroupLinkHTML($ueg, $memberName);
     }
     asort($userGroups);
     asort($userMembers);
     $lang = $context->getLanguage();
     $defaultPreferences['usergroups'] = array('type' => 'info', 'label' => $context->msg('prefs-memberingroups')->numParams(count($userGroups))->params($userName)->parse(), 'default' => $context->msg('prefs-memberingroups-type')->rawParams($lang->commaList($userGroups), $lang->commaList($userMembers))->escaped(), 'raw' => true, 'section' => 'personal/info');
     $editCount = Linker::link(SpecialPage::getTitleFor("Contributions", $userName), $lang->formatNum($user->getEditCount()));
     $defaultPreferences['editcount'] = array('type' => 'info', 'raw' => true, 'label-message' => 'prefs-edits', 'default' => $editCount, 'section' => 'personal/info');
     if ($user->getRegistration()) {
         $displayUser = $context->getUser();
         $userRegistration = $user->getRegistration();
         $defaultPreferences['registrationdate'] = array('type' => 'info', 'label-message' => 'prefs-registration', 'default' => $context->msg('prefs-registration-date-time', $lang->userTimeAndDate($userRegistration, $displayUser), $lang->userDate($userRegistration, $displayUser), $lang->userTime($userRegistration, $displayUser))->parse(), 'section' => 'personal/info');
     }
     $canViewPrivateInfo = $user->isAllowed('viewmyprivateinfo');
     $canEditPrivateInfo = $user->isAllowed('editmyprivateinfo');
     // Actually changeable stuff
     $defaultPreferences['realname'] = array('type' => $canEditPrivateInfo && $wgAuth->allowPropChange('realname') ? 'text' : 'info', 'default' => $user->getRealName(), 'section' => 'personal/info', 'label-message' => 'yourrealname', 'help-message' => 'prefs-help-realname');
     if ($canEditPrivateInfo && $wgAuth->allowPasswordChange()) {
         $link = Linker::link(SpecialPage::getTitleFor('ChangePassword'), $context->msg('prefs-resetpass')->escaped(), array(), array('returnto' => SpecialPage::getTitleFor('Preferences')->getPrefixedText()));
         $defaultPreferences['password'] = array('type' => 'info', 'raw' => true, 'default' => $link, 'label-message' => 'yourpassword', 'section' => 'personal/info');
     }
     // Only show prefershttps if secure login is turned on
     if ($config->get('SecureLogin') && wfCanIPUseHTTPS($context->getRequest()->getIP())) {
         $defaultPreferences['prefershttps'] = array('type' => 'toggle', 'label-message' => 'tog-prefershttps', 'help-message' => 'prefs-help-prefershttps', 'section' => 'personal/info');
     }
     // Language
     $languages = Language::fetchLanguageNames(null, 'mw');
     $languageCode = $config->get('LanguageCode');
     if (!array_key_exists($languageCode, $languages)) {
         $languages[$languageCode] = $languageCode;
     }
     ksort($languages);
     $options = array();
     foreach ($languages as $code => $name) {
         $display = wfBCP47($code) . ' - ' . $name;
         $options[$display] = $code;
     }
     $defaultPreferences['language'] = array('type' => 'select', 'section' => 'personal/i18n', 'options' => $options, 'label-message' => 'yourlanguage');
     $defaultPreferences['gender'] = array('type' => 'radio', 'section' => 'personal/i18n', 'options' => array($context->msg('parentheses')->params($context->msg('gender-unknown')->plain())->escaped() => 'unknown', $context->msg('gender-female')->escaped() => 'female', $context->msg('gender-male')->escaped() => 'male'), 'label-message' => 'yourgender', 'help-message' => 'prefs-help-gender');
     // see if there are multiple language variants to choose from
     if (!$config->get('DisableLangConversion')) {
         foreach (LanguageConverter::$languagesWithVariants as $langCode) {
             if ($langCode == $wgContLang->getCode()) {
                 $variants = $wgContLang->getVariants();
                 if (count($variants) <= 1) {
                     continue;
                 }
                 $variantArray = array();
                 foreach ($variants as $v) {
                     $v = str_replace('_', '-', strtolower($v));
                     $variantArray[$v] = $lang->getVariantname($v, false);
                 }
                 $options = array();
                 foreach ($variantArray as $code => $name) {
                     $display = wfBCP47($code) . ' - ' . $name;
                     $options[$display] = $code;
                 }
                 $defaultPreferences['variant'] = array('label-message' => 'yourvariant', 'type' => 'select', 'options' => $options, 'section' => 'personal/i18n', 'help-message' => 'prefs-help-variant');
             } else {
                 $defaultPreferences["variant-{$langCode}"] = array('type' => 'api');
             }
         }
     }
     // Stuff from Language::getExtraUserToggles()
     // FIXME is this dead code? $extraUserToggles doesn't seem to be defined for any language
     $toggles = $wgContLang->getExtraUserToggles();
     foreach ($toggles as $toggle) {
         $defaultPreferences[$toggle] = array('type' => 'toggle', 'section' => 'personal/i18n', 'label-message' => "tog-{$toggle}");
     }
     // show a preview of the old signature first
     $oldsigWikiText = $wgParser->preSaveTransform('~~~', $context->getTitle(), $user, ParserOptions::newFromContext($context));
     $oldsigHTML = $context->getOutput()->parseInline($oldsigWikiText, true, true);
     $defaultPreferences['oldsig'] = array('type' => 'info', 'raw' => true, 'label-message' => 'tog-oldsig', 'default' => $oldsigHTML, 'section' => 'personal/signature');
     $defaultPreferences['nickname'] = array('type' => $wgAuth->allowPropChange('nickname') ? 'text' : 'info', 'maxlength' => $config->get('MaxSigChars'), 'label-message' => 'yournick', 'validation-callback' => array('Preferences', 'validateSignature'), 'section' => 'personal/signature', 'filter-callback' => array('Preferences', 'cleanSignature'));
     $defaultPreferences['fancysig'] = array('type' => 'toggle', 'label-message' => 'tog-fancysig', 'help-message' => 'prefs-help-signature', 'section' => 'personal/signature');
     # # Email stuff
     if ($config->get('EnableEmail')) {
         if ($canViewPrivateInfo) {
             $helpMessages[] = $config->get('EmailConfirmToEdit') ? 'prefs-help-email-required' : 'prefs-help-email';
             if ($config->get('EnableUserEmail')) {
                 // additional messages when users can send email to each other
                 $helpMessages[] = 'prefs-help-email-others';
             }
             $emailAddress = $user->getEmail() ? htmlspecialchars($user->getEmail()) : '';
             if ($canEditPrivateInfo && $wgAuth->allowPropChange('emailaddress')) {
                 $link = Linker::link(SpecialPage::getTitleFor('ChangeEmail'), $context->msg($user->getEmail() ? 'prefs-changeemail' : 'prefs-setemail')->escaped(), array(), array('returnto' => SpecialPage::getTitleFor('Preferences')->getPrefixedText()));
                 $emailAddress .= $emailAddress == '' ? $link : $context->msg('word-separator')->escaped() . $context->msg('parentheses')->rawParams($link)->escaped();
             }
             $defaultPreferences['emailaddress'] = array('type' => 'info', 'raw' => true, 'default' => $emailAddress, 'label-message' => 'youremail', 'section' => 'personal/email', 'help-messages' => $helpMessages);
         }
         $disableEmailPrefs = false;
         if ($config->get('EmailAuthentication')) {
             $emailauthenticationclass = 'mw-email-not-authenticated';
             if ($user->getEmail()) {
                 if ($user->getEmailAuthenticationTimestamp()) {
                     // date and time are separate parameters to facilitate localisation.
                     // $time is kept for backward compat reasons.
                     // 'emailauthenticated' is also used in SpecialConfirmemail.php
                     $displayUser = $context->getUser();
                     $emailTimestamp = $user->getEmailAuthenticationTimestamp();
                     $time = $lang->userTimeAndDate($emailTimestamp, $displayUser);
                     $d = $lang->userDate($emailTimestamp, $displayUser);
                     $t = $lang->userTime($emailTimestamp, $displayUser);
                     $emailauthenticated = $context->msg('emailauthenticated', $time, $d, $t)->parse() . '<br />';
                     $disableEmailPrefs = false;
                     $emailauthenticationclass = 'mw-email-authenticated';
                 } else {
                     $disableEmailPrefs = true;
                     $emailauthenticated = $context->msg('emailnotauthenticated')->parse() . '<br />' . Linker::linkKnown(SpecialPage::getTitleFor('Confirmemail'), $context->msg('emailconfirmlink')->escaped()) . '<br />';
                     $emailauthenticationclass = "mw-email-not-authenticated";
                 }
             } else {
                 $disableEmailPrefs = true;
                 $emailauthenticated = $context->msg('noemailprefs')->escaped();
                 $emailauthenticationclass = 'mw-email-none';
             }
             if ($canViewPrivateInfo) {
                 $defaultPreferences['emailauthentication'] = array('type' => 'info', 'raw' => true, 'section' => 'personal/email', 'label-message' => 'prefs-emailconfirm-label', 'default' => $emailauthenticated, 'cssclass' => $emailauthenticationclass);
             }
         }
         if ($config->get('EnableUserEmail') && $user->isAllowed('sendemail')) {
             $defaultPreferences['disablemail'] = array('type' => 'toggle', 'invert' => true, 'section' => 'personal/email', 'label-message' => 'allowemail', 'disabled' => $disableEmailPrefs);
             $defaultPreferences['ccmeonemails'] = array('type' => 'toggle', 'section' => 'personal/email', 'label-message' => 'tog-ccmeonemails', 'disabled' => $disableEmailPrefs);
         }
         if ($config->get('EnotifWatchlist')) {
             $defaultPreferences['enotifwatchlistpages'] = array('type' => 'toggle', 'section' => 'personal/email', 'label-message' => 'tog-enotifwatchlistpages', 'disabled' => $disableEmailPrefs);
         }
         if ($config->get('EnotifUserTalk')) {
             $defaultPreferences['enotifusertalkpages'] = array('type' => 'toggle', 'section' => 'personal/email', 'label-message' => 'tog-enotifusertalkpages', 'disabled' => $disableEmailPrefs);
         }
         if ($config->get('EnotifUserTalk') || $config->get('EnotifWatchlist')) {
             $defaultPreferences['enotifminoredits'] = array('type' => 'toggle', 'section' => 'personal/email', 'label-message' => 'tog-enotifminoredits', 'disabled' => $disableEmailPrefs);
             if ($config->get('EnotifRevealEditorAddress')) {
                 $defaultPreferences['enotifrevealaddr'] = array('type' => 'toggle', 'section' => 'personal/email', 'label-message' => 'tog-enotifrevealaddr', 'disabled' => $disableEmailPrefs);
             }
         }
     }
 }
 private function getArticle($number, $language, $user)
 {
     $em = $this->container->get('em');
     $languageObject = $em->getRepository('Newscoop\\Entity\\Language')->findOneByCode($language);
     // Fetch article
     $articleObj = new \Article($languageObject->getId(), $number);
     if (!$articleObj->exists()) {
         throw new NewscoopException('Article does not exist');
     }
     if (!$articleObj->userCanModify($user)) {
         throw new AccessDeniedException('User cannot modify article.');
     }
     // Only users with a lock on the article can change it.
     if ($articleObj->isLocked() && $user->getUserId() != $articleObj->getLockedByUser()) {
         $lockTime = new \DateTime($articleObj->getLockTime());
         $now = new \DateTime('now');
         $difference = $now->diff($lockTime);
         $ago = $difference->format('%R%H:%I:%S');
         $lockUser = new \User($articleObj->getLockedByUser());
         throw new NewscoopException(sprintf('Article locked by %s (%s ago)', $lockUser->getRealName(), $ago));
     }
     return $articleObj;
 }
Example #20
0
 private function expandBodyVariables(User $watchingUser, $content)
 {
     $name = F::app()->wg->EnotifUseRealName ? $watchingUser->getRealName() : $watchingUser->getName();
     // $PAGEEDITDATE is the time and date of the page change expressed in terms
     // of individual local time of the notification recipient, i.e. watching user
     return str_replace(['$WATCHINGUSERNAME', '$PAGEEDITDATE', '$PAGEEDITTIME'], [$name, F::app()->wg->ContLang->userDate($this->timestamp, $watchingUser), F::app()->wg->ContLang->userTime($this->timestamp, $watchingUser)], $content);
 }
Example #21
0
if (!empty($f_message)) {
    camp_html_add_msg($f_message, "ok");
}
if (!$articleObj->userCanModify($g_user)) {
    camp_html_add_msg($translator->trans("You do not have the right to change this article.  You may only edit your own articles and once submitted an article can only be changed by authorized users.", array(), 'articles'));
    camp_html_goto_page($BackLink);
    exit;
}
// Only users with a lock on the article can change it.
if ($articleObj->isLocked() && $g_user->getUserId() != $articleObj->getLockedByUser()) {
    $diffSeconds = time() - strtotime($articleObj->getLockTime());
    $hours = floor($diffSeconds / 3600);
    $diffSeconds -= $hours * 3600;
    $minutes = floor($diffSeconds / 60);
    $lockUser = new User($articleObj->getLockedByUser());
    camp_html_add_msg($translator->trans('Could not save the article. It has been locked by $1 $2 hours and $3 minutes ago.', array('$1' => $lockUser->getRealName(), '$2' => $hours, '$3' => $minutes), 'articles'));
    camp_html_goto_page($BackLink);
    exit;
}
// Update the article author
$blogService = Zend_Registry::get('container')->getService('blog');
$blogInfo = $blogService->getBlogInfo($g_user);
if (!empty($f_article_author)) {
    $em = Zend_Registry::get('container')->getService('em');
    $dispatcher = Zend_Registry::get('container')->getService('dispatcher');
    $language = $em->getRepository('Newscoop\\Entity\\Language')->findOneById($articleObj->getLanguageId());
    $authors = $em->getRepository('Newscoop\\Entity\\ArticleAuthor')->getArticleAuthors($articleObj->getArticleNumber(), $language->getCode())->getArrayResult();
    ArticleAuthor::OnArticleLanguageDelete($articleObj->getArticleNumber(), $articleObj->getLanguageId());
    foreach ($authors as $author) {
        $dispatcher->dispatch("user.set_points", new \Newscoop\EventDispatcher\Events\GenericEvent($this, array('authorId' => $author['fk_author_id'])));
    }
Example #22
0
        			<TR>
        				<TD ALIGN="RIGHT" valign="top" ><b><?php 
        putGS("Name");
        ?>
:</b></TD>
        				<TD align="left" valign="top">
        				    <?php 
        print wordwrap(htmlspecialchars($curPreview->getTitle()), 60, "<br>");
        ?>
        				</TD>
        				<TD ALIGN="RIGHT" valign="top"><b><?php 
        putGS("Created by");
        ?>
:</b></TD>
        				<TD align="left" valign="top"><?php 
        p(htmlspecialchars($articleCreator->getRealName()));
        ?>
</TD>
        				<TD ALIGN="RIGHT" valign="top"></TD>
        				<TD align="left" valign="top" style="padding-top: 0.25em;">
        				<?php 
        putGS('Show article on front page');
        ?>
        				</TD>
        			</TR>
        			<TR>
        				<TD ALIGN="RIGHT" valign="top" style="padding-left: 1em;"><b><?php 
        putGS("Type");
        ?>
:</b></TD>
        				<TD align="left" valign="top">
Example #23
0
	<TD COLSPAN="2">
	<TABLE BORDER="1">
    <tr>
	<td valign="top">
	<!-- BEGIN article content -->
	<table>
	<TR>
		<TD style="padding-top: 3px;">
			<TABLE>
			<TR>
				<TD ALIGN="RIGHT" valign="top" ><b><?php  putGS("Name"); ?>:</b></TD>
				<TD align="left" valign="top">
				    <?php print wordwrap(htmlspecialchars($curPreview->getTitle()), 60, "<br>"); ?>
				</TD>
				<TD ALIGN="RIGHT" valign="top"><b><?php  putGS("Created by"); ?>:</b></TD>
				<TD align="left" valign="top"><?php p(htmlspecialchars($articleCreator->getRealName())); ?></TD>
				<TD ALIGN="RIGHT" valign="top"></TD>
				<TD align="left" valign="top" style="padding-top: 0.25em;">
				<?php  putGS('Show article on front page'); ?>
				</TD>
			</TR>
			<TR>
				<TD ALIGN="RIGHT" valign="top" style="padding-left: 1em;"><b><?php  putGS("Type"); ?>:</b></TD>
				<TD align="left" valign="top">
					<?php print htmlspecialchars($dest->getDisplayName()); ?>
				</TD>
				<TD ALIGN="RIGHT" valign="top" style="padding-left: 1em;"><b><nobr><?php  putGS("Creation date"); ?>:</nobr></b></TD>
				<TD align="left" valign="top" nowrap>
					<?php print $curPreview->getCreationDate(); ?>
				</TD>
				<TD ALIGN="RIGHT" valign="top" style="padding-left: 1em;"></TD>
 protected function person($name, User $user)
 {
     if ($user->isAnon()) {
         $this->element($name, wfMessage('anonymous')->numParams(1)->text());
     } else {
         $real = $user->getRealName();
         if ($real) {
             $this->element($name, $real);
         } else {
             $userName = $user->getName();
             $this->pageOrString($name, $user->getUserPage(), wfMessage('siteuser', $userName, $userName)->text());
         }
     }
 }
Example #25
0
 /**
  * Generate the generic "this page has been changed" e-mail text.
  */
 private function composeCommonMailtext()
 {
     global $wgPasswordSender, $wgNoReplyAddress;
     global $wgEnotifFromEditor, $wgEnotifRevealEditorAddress;
     global $wgEnotifImpersonal, $wgEnotifUseRealName;
     $this->composed_common = true;
     # You as the WikiAdmin and Sysops can make use of plenty of
     # named variables when composing your notification emails while
     # simply editing the Meta pages
     $keys = array();
     $postTransformKeys = array();
     $pageTitleUrl = $this->title->getCanonicalURL();
     $pageTitle = $this->title->getPrefixedText();
     if ($this->oldid) {
         // Always show a link to the diff which triggered the mail. See bug 32210.
         $keys['$NEWPAGE'] = "\n\n" . wfMessage('enotif_lastdiff', $this->title->getCanonicalURL(array('diff' => 'next', 'oldid' => $this->oldid)))->inContentLanguage()->text();
         if (!$wgEnotifImpersonal) {
             // For personal mail, also show a link to the diff of all changes
             // since last visited.
             $keys['$NEWPAGE'] .= "\n\n" . wfMessage('enotif_lastvisited', $this->title->getCanonicalURL(array('diff' => '0', 'oldid' => $this->oldid)))->inContentLanguage()->text();
         }
         $keys['$OLDID'] = $this->oldid;
         // Deprecated since MediaWiki 1.21, not used by default. Kept for backwards-compatibility.
         $keys['$CHANGEDORCREATED'] = wfMessage('changed')->inContentLanguage()->text();
     } else {
         # clear $OLDID placeholder in the message template
         $keys['$OLDID'] = '';
         $keys['$NEWPAGE'] = '';
         // Deprecated since MediaWiki 1.21, not used by default. Kept for backwards-compatibility.
         $keys['$CHANGEDORCREATED'] = wfMessage('created')->inContentLanguage()->text();
     }
     $keys['$PAGETITLE'] = $this->title->getPrefixedText();
     $keys['$PAGETITLE_URL'] = $this->title->getCanonicalURL();
     $keys['$PAGEMINOREDIT'] = $this->minorEdit ? wfMessage('minoredit')->inContentLanguage()->text() : '';
     $keys['$UNWATCHURL'] = $this->title->getCanonicalURL('action=unwatch');
     if ($this->editor->isAnon()) {
         # real anon (user:xxx.xxx.xxx.xxx)
         $keys['$PAGEEDITOR'] = wfMessage('enotif_anon_editor', $this->editor->getName())->inContentLanguage()->text();
         $keys['$PAGEEDITOR_EMAIL'] = wfMessage('noemailtitle')->inContentLanguage()->text();
     } else {
         $keys['$PAGEEDITOR'] = $wgEnotifUseRealName && $this->editor->getRealName() !== '' ? $this->editor->getRealName() : $this->editor->getName();
         $emailPage = SpecialPage::getSafeTitleFor('Emailuser', $this->editor->getName());
         $keys['$PAGEEDITOR_EMAIL'] = $emailPage->getCanonicalURL();
     }
     $keys['$PAGEEDITOR_WIKI'] = $this->editor->getUserPage()->getCanonicalURL();
     $keys['$HELPPAGE'] = wfExpandUrl(Skin::makeInternalOrExternalUrl(wfMessage('helppage')->inContentLanguage()->text()));
     # Replace this after transforming the message, bug 35019
     $postTransformKeys['$PAGESUMMARY'] = $this->summary == '' ? ' - ' : $this->summary;
     // Now build message's subject and body
     // Messages:
     // enotif_subject_deleted, enotif_subject_created, enotif_subject_moved,
     // enotif_subject_restored, enotif_subject_changed
     $this->subject = wfMessage('enotif_subject_' . $this->pageStatus)->inContentLanguage()->params($pageTitle, $keys['$PAGEEDITOR'])->text();
     // Messages:
     // enotif_body_intro_deleted, enotif_body_intro_created, enotif_body_intro_moved,
     // enotif_body_intro_restored, enotif_body_intro_changed
     $keys['$PAGEINTRO'] = wfMessage('enotif_body_intro_' . $this->pageStatus)->inContentLanguage()->params($pageTitle, $keys['$PAGEEDITOR'], $pageTitleUrl)->text();
     $body = wfMessage('enotif_body')->inContentLanguage()->plain();
     $body = strtr($body, $keys);
     $body = MessageCache::singleton()->transform($body, false, null, $this->title);
     $this->body = wordwrap(strtr($body, $postTransformKeys), 72);
     # Reveal the page editor's address as REPLY-TO address only if
     # the user has not opted-out and the option is enabled at the
     # global configuration level.
     $adminAddress = new MailAddress($wgPasswordSender, wfMessage('emailsender')->inContentLanguage()->text());
     if ($wgEnotifRevealEditorAddress && $this->editor->getEmail() != '' && $this->editor->getOption('enotifrevealaddr')) {
         $editorAddress = MailAddress::newFromUser($this->editor);
         if ($wgEnotifFromEditor) {
             $this->from = $editorAddress;
         } else {
             $this->from = $adminAddress;
             $this->replyto = $editorAddress;
         }
     } else {
         $this->from = $adminAddress;
         $this->replyto = new MailAddress($wgNoReplyAddress);
     }
 }
Example #26
0
/**
 * Set Lock Info and Row Class strings
 * for the usage in Article list tables.
 *
 * @param object $p_articleObj
 * @param string $p_lockInfo
 * @param string $p_rowClass
 * @param boolean $p_color
 */
function camp_set_article_row_decoration(&$p_articleObj, &$p_lockInfo, &$p_rowClass, &$p_color)
{
    global $g_user;
    $p_lockInfo = '';
    $translator = \Zend_Registry::get('container')->getService('translator');
    $timeDiff = camp_time_diff_str($p_articleObj->getLockTime());
    if ($p_articleObj->isLocked() && $timeDiff['days'] <= 0) {
        $lockUserObj = new User($p_articleObj->getLockedByUser());
        if ($timeDiff['hours'] > 0) {
            $p_lockInfo = $translator->trans('The article has been locked by $1 ($2) $3 hour(s) and $4 minute(s) ago.', array('$1' => htmlspecialchars($lockUserObj->getRealName()), '$2' => htmlspecialchars($lockUserObj->getUserName()), '$3' => $timeDiff['hours'], '$4' => $timeDiff['minutes']), 'home');
        } else {
            $p_lockInfo = $translator->trans('The article has been locked by $1 ($2) $3 minute(s) ago.', array('$1' => htmlspecialchars($lockUserObj->getRealName()), '$2' => htmlspecialchars($lockUserObj->getUserName()), '$3' => $timeDiff['minutes']), 'home');
        }
    }
    if ($p_articleObj->isLocked() && $timeDiff['days'] <= 0 && $p_articleObj->getLockedByUser() != $g_user->getUserId()) {
        $p_rowClass = "article_locked";
    } else {
        if ($p_color) {
            $p_rowClass = "list_row_even";
        } else {
            $p_rowClass = "list_row_odd";
        }
    }
    $p_color = !$p_color;
}
Example #27
0
 /**
  * Get a link to $user's user page
  * @param User $user
  * @return string Html
  */
 protected function link(User $user)
 {
     if ($this->canShowRealUserName() && !$user->isAnon()) {
         $real = $user->getRealName();
     } else {
         $real = false;
     }
     $page = $user->isAnon() ? SpecialPage::getTitleFor('Contributions', $user->getName()) : $user->getUserPage();
     return Linker::link($page, htmlspecialchars($real ? $real : $user->getName()));
 }
 /**
  * Add a user to LDAP.
  * Return true if successful.
  *
  * @param User $user
  * @param string $password
  * @param string $email
  * @param string $realname
  * @return bool
  */
 public function addUser($user, $password, $email = '', $realname = '')
 {
     $this->printDebug("Entering addUser", NONSENSITIVE);
     if (!$this->getConf('AddLDAPUsers') || 'local' == $this->getSessionDomain()) {
         $this->printDebug("Either the user is using a local domain, or the wiki isn't allowing users to be added to LDAP", NONSENSITIVE);
         // Tell the wiki not to return an error.
         return true;
     }
     if ($this->getConf('RequiredGroups')) {
         $this->printDebug("The wiki is requiring users to be in specific groups, and cannot add users as this would be a security hole.", NONSENSITIVE);
         // It is possible that later we can add users into
         // groups, but since we don't support it, we don't want
         // to open holes!
         return false;
     }
     $writer = $this->getConf('WriterDN');
     if (!$writer) {
         $this->printDebug("The wiki doesn't have wgLDAPWriterDN set", NONSENSITIVE);
         // We can't add users without an LDAP account capable of doing so.
         return false;
     }
     $this->email = $user->getEmail();
     $this->realname = $user->getRealName();
     $username = $user->getName();
     if ($this->getConf('LowercaseUsernameScheme')) {
         $username = strtolower($username);
     }
     $pass = $this->getPasswordHash($password);
     if ($this->connect()) {
         $writeloc = $this->getConf('WriteLocation');
         $this->userdn = $this->getSearchString($username);
         if ('' == $this->userdn) {
             $this->printDebug("userdn is blank, attempting to use wgLDAPWriteLocation", NONSENSITIVE);
             if ($writeloc) {
                 $this->printDebug("wgLDAPWriteLocation is set, using that", NONSENSITIVE);
                 $this->userdn = $this->getConf('SearchAttribute') . "=" . $username . "," . $writeloc;
             } else {
                 $this->printDebug("wgLDAPWriteLocation is not set, failing", NONSENSITIVE);
                 // getSearchString will bind, but will not unbind
                 LdapAuthenticationPlugin::ldap_unbind($this->ldapconn);
                 return false;
             }
         }
         $this->printDebug("Binding as the writerDN", NONSENSITIVE);
         $bind = $this->bindAs($writer, $this->getConf('WriterPassword'));
         if (!$bind) {
             $this->printDebug("Failed to bind as the writerDN; add failed", NONSENSITIVE);
             return false;
         }
         // Set up LDAP objectclasses and attributes
         // TODO: make objectclasses and attributes configurable
         $values["uid"] = $username;
         // sn is required for objectclass inetorgperson
         $values["sn"] = $username;
         if (is_string($this->email)) {
             $values["mail"] = $this->email;
         }
         if (is_string($this->realname)) {
             $values["cn"] = $this->realname;
         } else {
             $values["cn"] = $username;
         }
         $values["userpassword"] = $pass;
         $values["objectclass"] = array("inetorgperson");
         $result = true;
         # Let other extensions modify the user object before creation
         wfRunHooks('LDAPSetCreationValues', array($this, $username, &$values, $writeloc, &$this->userdn, &$result));
         if (!$result) {
             $this->printDebug("Failed to add user because LDAPSetCreationValues returned false", NONSENSITIVE);
             LdapAuthenticationPlugin::ldap_unbind($this->ldapconn);
             return false;
         }
         $this->printDebug("Adding user", NONSENSITIVE);
         if (LdapAuthenticationPlugin::ldap_add($this->ldapconn, $this->userdn, $values)) {
             $this->printDebug("Successfully added user", NONSENSITIVE);
             LdapAuthenticationPlugin::ldap_unbind($this->ldapconn);
             return true;
         }
         $this->printDebug("Failed to add user", NONSENSITIVE);
         LdapAuthenticationPlugin::ldap_unbind($this->ldapconn);
     }
     return false;
 }
 /**
  * Updates the user's details according to what was given from the SSO
  * library.
  * Note that this will be called every time after authenticating
  * to the IdP.
  *
  * @param User $user
  * User object from MW
  * @param Array $attrs
  * Attribute array
  */
 private function modifyUserIfNeeded(&$user, $attrs)
 {
     $username = $user->getName();
     $dirty = false;
     /*
      * Email
      */
     if (isset($attrs['email'])) {
         $new = $attrs['email'];
         $old = $user->getEmail();
         if ($new != $old) {
             $user->setEmail($new);
             $user->confirmEmail();
             wfDebugLog('MultiAuthPlugin', __METHOD__ . ': ' . "Updated email for user '{$username}' from '{$old}' to '{$new}'");
             $dirty = true;
         }
     }
     /*
      * Fullname
      */
     if (isset($attrs['fullname'])) {
         $new = $attrs['fullname'];
         $old = $user->getRealName();
         if ($new != $old) {
             $user->setRealName($new);
             wfDebugLog('MultiAuthPlugin', __METHOD__ . ': ' . "Updated realName for user '{$username}' from '{$old}' to '{$new}'");
             $dirty = true;
         }
     }
     if ($dirty) {
         $user->saveSettings();
     }
 }
Example #30
0
 protected function person($name, User $user)
 {
     if ($user->isAnon()) {
         $this->element($name, wfMsgExt('anonymous', array('parsemag'), 1));
     } else {
         $real = $user->getRealName();
         if ($real) {
             $this->element($name, $real);
         } else {
             $userName = $user->getName();
             $this->pageOrString($name, $user->getUserPage(), wfMsgExt('siteuser', 'parsemag', $userName, $userName));
         }
     }
 }