コード例 #1
0
 /**
  * @group Slow
  * @slowExecutionTime 0.03205 ms
  */
 function testCheckDomainIsCorrectDomainExists()
 {
     $this->getGlobalFunctionMock('wfMsg')->expects($this->exactly(1))->method('wfMsg')->with($this->equalTo('autocreatewiki-name-taken'))->will($this->returnValue('mocked-string'));
     $this->mockStaticMethod('AutoCreateWiki', 'checkBadWords', true);
     $this->mockStaticMethod('AutoCreateWiki', 'checkDomainExists', true);
     $this->mockStaticMethod('AutoCreateWiki', 'getLanguageNames', array('pl' => 'pl'));
     $result = AutoCreateWiki::checkDomainIsCorrect('woohooo', 'pl');
     $this->assertEquals('mocked-string', $result);
 }
コード例 #2
0
 /**
  * Ajax call to validate domain.
  * Called via nirvana dispatcher
  */
 public function CheckDomain()
 {
     wfProfileIn(__METHOD__);
     global $wgRequest;
     $name = $wgRequest->getVal('name');
     $lang = $wgRequest->getVal('lang');
     $type = $wgRequest->getVal('type');
     $this->res = AutoCreateWiki::checkDomainIsCorrect($name, $lang, $type);
     wfProfileOut(__METHOD__);
 }
コード例 #3
0
function axACWRequestCheckName()
{
    global $wgRequest;
    $sName = $wgRequest->getVal("name");
    $sLang = $wgRequest->getVal("lang");
    $type = $wgRequest->getVal("type");
    $isError = false;
    $sResponse = AutoCreateWiki::checkDomainIsCorrect($sName, $sLang, $type);
    if (empty($sResponse)) {
        $aDomains = AutoCreateWiki::getDomainsLikeOrExact($sName, $sLang, $type);
        if (!empty($aDomains) && is_array($aDomains)) {
            $sResponse = wfMsg('autocreatewiki-similar-wikis');
            $sLike = $sExact = "";
            #--- exact first
            if (!empty($aDomains['exact']) && is_array($aDomains['exact'])) {
                foreach ($aDomains['exact'] as $domain) {
                    $sExact .= "<li><a href=\"http://{$domain->city_domain}/\" target=\"_blank\">{$domain->city_domain}</a></li>";
                }
                if (!empty($sExact)) {
                    $sResponse .= "<ul id='wiki-result-list-exact'>{$sExact}</ul>";
                }
            }
            #--- similar next
            if (!empty($aDomains['like']) && is_array($aDomains['like'])) {
                foreach ($aDomains['like'] as $domain) {
                    $sLike .= "<li><a href=\"http://{$domain->city_domain}/\" target=\"_blank\">{$domain->city_domain}</a></li>";
                }
                if (!empty($sLike)) {
                    $sResponse .= "<ul id='wiki-result-list-like'>{$sLike}</ul>";
                }
            }
            if (!isset($aDomains['exact']) && !isset($aDomains['like']) && isset($aDomains['closed'])) {
                $sResponse = wfMsg('autocreatewiki-violate-policy');
                $isError = true;
            }
        }
    } else {
        $isError = true;
    }
    $aResponse = array('div-body' => $sResponse, 'div-name' => 'wiki-domain-error', 'div-error' => $isError);
    return json_encode($aResponse);
}
コード例 #4
0
 /**
  * check wiki creation form
  */
 private function checkWikiCreationParams()
 {
     global $wgUser;
     $res = true;
     wfProfileIn(__METHOD__);
     #-- check Wiki's name
     $sResponse = AutoCreateWiki::checkWikiNameIsCorrect($this->mName, $this->mLanguage);
     if (!empty($sResponse)) {
         $this->makeError("wiki-name", $sResponse);
         $res = false;
     }
     #-- check Wiki's domain
     $sResponse = AutoCreateWiki::checkDomainIsCorrect($this->mDomain, $this->mLanguage, $this->mType);
     if (!empty($sResponse)) {
         $this->makeError("wiki-domain", $sResponse);
         $res = false;
     }
     #-- check Wiki's category
     $sResponse = AutoCreateWiki::checkCategoryIsCorrect($this->mCategory);
     if (!empty($sResponse)) {
         $this->makeError("wiki-category", $sResponse);
         $res = false;
     }
     #-- check Wiki's language
     $sResponse = AutoCreateWiki::checkLanguageIsCorrect($this->mLanguage);
     if (!empty($sResponse)) {
         $this->makeError("wiki-language", $sResponse);
         $res = false;
     }
     #-- check username given by staff
     if ($wgUser->isAllowed('createwikimakefounder') && !empty($this->mStaff_username)) {
         $user_id = User::idFromName($this->mStaff_username);
         if (empty($user_id)) {
             $this->makeError("wiki-staff-username", wfMsg('autocreatewiki-invalid-username'));
             $res = false;
         } else {
             $user = User::newFromId($user_id);
             if ($user->isBlocked()) {
                 $this->makeError("wiki-staff-username", wfMsg('autocreatewiki-invalid-username'));
                 $res = false;
             }
         }
     }
     wfProfileOut(__METHOD__);
     return $res;
 }