コード例 #1
0
 function saveSite($mode)
 {
     //copy currect webmaster email to be in site row
     if ($mode == "on") {
         $this->request->webmasterEmail = $this->session->get("email");
     }
     if ($this->request->url == "http://") {
         $this->request->url = "";
     }
     $siteType = $this->request->siteType;
     if (!$this->validSiteType($siteType)) {
         $this->return404();
     }
     $package = null;
     // if we edit site
     if (!empty($this->request->siteId) && $mode == "on") {
         $c = new Criteria();
         $c->add("siteId", $this->request->siteId);
         $c->add("webmasterId", $this->userId);
         $site = $this->site->find($c);
         //this site doesn't exists
         if (empty($site)) {
             $this->set("status", "error");
             $this->set("message", _t("This site doesn't exists"));
             return false;
         }
         $package = $site->packageId ? $this->package->findByPk($site->packageId) : null;
         //validate edited site and for some things compare with old state
         $errorMessage = $this->siteValidator->validate($this->request, $site, array("package" => $package));
     } else {
         if ($siteType == "premium") {
             if ($mode == "on") {
                 $payment = $this->payment->getUnusedPaidOneByUserId($this->userId);
             } else {
                 $payment = $this->payment->getUnusedPaidOneByIp($this->request->getIp());
             }
             if (empty($payment)) {
                 $errorMessage = "You haven't credit for this action";
             } else {
                 $package = $this->package->findByPk($payment->packageId);
                 $paymentProcessor = $this->paymentProcessor->findByPk($payment->processorId);
             }
         }
         if (empty($errorMessage)) {
             //validate new site
             $errorMessage = $this->siteValidator->validate($this->request, null, array("package" => $package));
             if ($mode == "off") {
                 //checking captcha
                 if (Config::get('captchaEnabledOnSiteInscription') && !$errorMessage && !$this->captchaCode->validatePublicAndPrivateCodes($this->request)) {
                     $errorMessage = 'You did not guess the security code.';
                 }
             }
         }
         //if everything okey create new SiteRecord
         if (!$errorMessage) {
             $site = new SiteRecord();
             $site->siteType = $siteType;
             if (Config::get('siteDescriptionHtmlEnabled')) {
                 $site->descriptionDisplayMethod = 'html';
             } else {
                 $site->descriptionDisplayMethod = 'text';
             }
             if ($mode == "on") {
                 $site->webmasterId = $this->userId;
             }
         }
     }
     if ($errorMessage) {
         //set status to js part about that something is wrong with site data
         $this->set("status", "error");
         //set error message what is wrong
         $this->set("message", _t($errorMessage));
         return false;
     }
     //values which will be retrieved from post data
     $fields = array("categoryId", "siteTitle", "url", "rssTitle", "rssFeedOfSite", "returnBond", "description", "proposalForCategory", "proposalForKeywords", "webmasterEmail");
     if (Config::get("countryFlagsEnabled")) {
         array_push($fields, "countryCode");
     }
     if (Config::get("companyInfoEnabled") || Config::get("googleMapEnabled")) {
         array_push($fields, "address", "zipCode", "city", "country", "phoneNumber", "faxNumber");
     }
     //fillling siteRecord with post data
     $site->fromArray($this->request->getArray($fields));
     $site->status = Config::get('automaticSiteValidation') == 1 ? 'validated' : 'waiting';
     $site->searchPartnership = empty($this->request->searchPartnership) ? 0 : 1;
     $site->newsletterActive = empty($this->request->newsletterActive) ? 0 : 1;
     $site->ip = $this->request->getIp();
     //if premium option mark payment as used to submit site and copy package details to site
     if (!empty($payment)) {
         $site->siteType = "premium";
         $site->priority = $package->priority;
         $site->packageId = $package->packageId;
         if ($package->siteDescriptionHtmlEnabled) {
             $site->descriptionDisplayMethod = 'html';
         } else {
             $site->descriptionDisplayMethod = 'text';
         }
         if ($payment->status == "pending") {
             $site->status = "waiting";
             $site->paymentStatus = $payment->status;
         }
         $site->paymentProcessorName = $paymentProcessor->displayName;
     }
     $site->ascreen = 0;
     if (Config::get("ascreenEnabled")) {
         $site->updateAscreen();
     }
     $site->save();
     if (!empty($payment)) {
         $payment->siteId = $site->siteId;
         $payment->used = 1;
         $payment->save();
     }
     //store keywords
     if (!empty($this->request->keywords)) {
         $maxKeywordsCountPerSite = $package ? $package->maxKeywordsCountPerSite : Config::get("maxKeywordsCountPerSite");
         $this->keywordsOfSite->storeKeywords($site->siteId, $this->request->keywords, $maxKeywordsCountPerSite);
     }
     if (!empty($this->request->tempId)) {
         $c = new Criteria();
         $c->add("tempId", $this->request->tempId);
         $this->photo->update(array("itemId" => $site->siteId, "_tempId" => "NULL"), $c);
         $site->updatePhotos();
     }
     $this->extraField->saveExtraFieldsValues($site, $this->request);
     $this->site->attachParents($site);
     //send email to admin that site was submitted/edited
     if (Config::get('sendEmailsOnInscriptionAndApproval')) {
         Mailer::getInstance()->sendAdminNotification($site);
     }
     //send notifications to webmaster that his site was saved to database
     if (Config::get('informWebmastersForAdminDecisions')) {
         Mailer::getInstance()->sendWebmasterNotification($site, $site->webmasterEmail);
     }
     if ($mode == "off" && Config::get("emailConfirmationEnabled")) {
         $verification = $this->verification->addVerification($site->siteId, "siteEmail");
         $confirmLink = Config::get("siteRootUrl") . $this->moduleLink("confirmSiteEmail/" . $verification->code, false);
         Mailer::getInstance()->sendEmailConfirmation("siteEmail", $site->webmasterEmail, $confirmLink);
     }
     return true;
 }
コード例 #2
0
ファイル: SiteController.php プロジェクト: reinfire/arfooo
 function saveSiteAction()
 {
     $this->viewClass = "JsonView";
     $edit = !empty($this->request->siteId);
     $validationOptions = array("admin" => true, "forceCategoryDuplicate" => true, "forcePossibleTender" => true);
     if ($this->request->url == "http://") {
         $this->request->url = "";
     }
     if ($edit) {
         $site = $this->site->findByPk($this->request->siteId);
         if ($site->status != "validated" && $this->request->status == "validated") {
             $site->_creationDate = "NOW()";
         }
         $package = $site->packageId ? $this->package->findByPk($site->packageId) : null;
         $errorMessage = $this->siteValidator->validate($this->request, $site, $validationOptions + array("package" => $package));
     } else {
         $site = new SiteRecord();
         $this->request->webmasterEmail = $this->session->get("email");
         $errorMessage = $this->siteValidator->validate($this->request, null, $validationOptions);
     }
     if ($errorMessage) {
         $status = "error";
         $this->set("status", $status);
         $this->set("message", _t($errorMessage));
         return;
     }
     $fields = array("categoryId", "webmasterName", "webmasterEmail", "webmasterId", "siteTitle", "url", "rssTitle", "rssFeedOfSite", "description", "returnBond", "status", "problemExists", "priority", "visitsCount", "referrerTimes");
     if (Config::get("countryFlagsEnabled")) {
         array_push($fields, "countryCode");
     }
     if (Config::get("companyInfoEnabled")) {
         array_push($fields, "address", "zipCode", "city", "country", "phoneNumber", "faxNumber");
     }
     if (isset($this->request->proposalForCategory)) {
         array_push($fields, 'proposalForCategory');
     }
     if (isset($this->request->proposalForKeywords)) {
         array_push($fields, 'proposalForKeywords');
     }
     if (isset($this->request->descriptionDisplayMethod)) {
         array_push($fields, 'descriptionDisplayMethod');
     }
     $site->fromArray($this->request->getArray($fields));
     $site->searchPartnership = empty($this->request->searchPartnership) ? 0 : 1;
     $site->save();
     // store keywords, admin has no limit here
     if (!empty($this->request->keywords)) {
         $this->keywordsOfSite->storeKeywords($site->siteId, $this->request->keywords, 1000);
     }
     // save additional categories
     if (!empty($this->request->additionalCategoryIds)) {
         $c = new Criteria();
         $c->add('siteId', $site->siteId);
         $this->siteAdditionalCategory->del($c);
         foreach ($this->request->additionalCategoryIds as $categoryId) {
             $additionalCategory = new SiteAdditionalCategoryRecord(array('siteId' => $site->siteId, 'categoryId' => $categoryId));
             $additionalCategory->save();
         }
         $this->site->updateStats();
     }
     if (!empty($this->request->tempId)) {
         $c = new Criteria();
         $c->add("tempId", $this->request->tempId);
         $this->photo->update(array("itemId" => $site->siteId, "_tempId" => "NULL"), $c);
         $site->updatePhotos();
     }
     $this->extraField->saveExtraFieldsValues($site, $this->request);
     $site->updateSuffix();
     $this->set("status", "ok");
     $this->set("message", _t("The site was successfully submitted."));
     $this->set("redirectUrl", AppRouter::getRewrittedUrl("/admin/category/index/" . $site->categoryId));
 }
コード例 #3
0
ファイル: SiteController.php プロジェクト: reinfire/arfooo
 function saveSiteAction()
 {
     $this->viewClass = "JsonView";
     $edit = !empty($this->request->siteId);
     $validationOptions = array("admin" => true, "forceCategoryDuplicate" => true, "forcePossibleTender" => true);
     if ($edit) {
         $site = $this->site->findByPk($this->request->siteId);
         if ($site->status != "validated" && $this->request->status == "validated") {
             $site->_creationDate = "NOW()";
         }
         $package = $site->packageId ? $this->package->findByPk($site->packageId) : null;
         $errorMessage = $this->siteValidator->validate($this->request, $site, $validationOptions + array("package" => $package));
     } else {
         $site = new SiteRecord();
         $this->request->webmasterEmail = $this->session->get("email");
         $errorMessage = $this->siteValidator->validate($this->request, null, $validationOptions);
     }
     if ($errorMessage) {
         $status = "error";
         $this->set("status", $status);
         $this->set("message", _t($errorMessage));
         return;
     }
     $fields = array("categoryId", "webmasterName", "webmasterEmail", "webmasterId", "siteTitle", "url", "rssTitle", "rssFeedOfSite", "description", "returnBond", "status", "problemExists", "priority", "visitsCount", "referrerTimes");
     if (Config::get("countryFlagsEnabled")) {
         array_push($fields, "countryCode");
     }
     if (Config::get("companyInfoEnabled")) {
         array_push($fields, "address", "zipCode", "city", "country", "phoneNumber", "faxNumber");
     }
     $site->fromArray($this->request->getArray($fields));
     $site->save();
     // store keywords
     if (!empty($this->request->keywords)) {
         $maxKeywordsCountPerSite = $package ? $package->maxKeywordsCountPerSite : Config::get("maxKeywordsCountPerSite");
         $this->keywordsOfSite->storeKeywords($site->siteId, $this->request->keywords, $maxKeywordsCountPerSite);
     }
     if (!empty($this->request->tempId)) {
         $c = new Criteria();
         $c->add("tempId", $this->request->siteId);
         $this->photo->update(array("siteId" => $site->siteId, "_tempId" => "NULL"), $c);
         $site->updatePhotos();
     }
     $this->extraField->saveExtraFieldsValues($site, $this->request);
     $site->updateSuffix();
     $this->set("status", "ok");
     $this->set("message", _t("The site was successfully submitted."));
     $this->set("redirectUrl", AppRouter::getRewrittedUrl("/moderation/site/waiting"));
 }