public function process() { $affiliate = new \model\affiliate($this->getDbconnection()); if (!is_null($this->getRequestVar('submsave')) && !is_null($this->getRequestVar('antiSpamAnswer'))) { if ($this->getRequestVar('antiSpamAnswer') === $this->getSysconfig()->getAntispamAnswer()) { $data = $this->getRequestVar('affiliate'); foreach ($data as $key => $value) { $data[$key] = $this->filterRequest($value, array(1, 4, 7)); } $affiliate->setPageName($data['pageName']); $affiliate->setPageUrl($data['pageUrl']); $affiliate->setPageAdminName($data['pageAdminName']); $affiliate->setPageAdminEmail($data['pageAdminEmail']); $affiliate->setPageButton($data['pageButton']); $affiliate->setAffiliateCategory($data['affiliateCategory']); $affiliate->setAffiliateAddedTime(time()); $affiliate->setAffiliateEditedTime(0); $affiliate->setAffiliateIsMarked(0); $affiliate->setAffiliateIsAccpted(0); if ($affiliate->save()) { \messages::registerNotice(\language::returnLanguageConstant('APPLY_OK')); $catgory = new \model\category($this->dbconnection, $affiliate->getAffiliateCategory()); $mailData = array('mailTo' => $this->getSysconfig()->getAdminMail(), 'mailSubject' => \language::replaceLanguageConstant(\language::returnLanguageConstant('APPLY_MAIL_SUBJECT'), array('{{affiliateKategory}}' => $catgory->getName())), 'mailText' => \language::replaceLanguageConstant(\language::returnLanguageConstant('APPLY_MAIL_TEXT'), array('{{name}}' => $affiliate->getPageAdminName(), '{{page}}' => $affiliate->getPageUrl(), '{{affiliateKategory}}' => $catgory->getName(), '{{acpLink}}' => \base_config::$rootPath)), 'mailFrom' => $affiliate->getPageAdminEmail()); \messages::sendEMail($mailData); } else { \messages::registerError(\language::returnLanguageConstant('APPLY_FAILED')); } $affiliate = new \model\affiliate($this->getDbconnection()); } else { \messages::registerError(\language::returnLanguageConstant('APPLY_FAILED_SPAM')); } } $categoryList = new \model\category_list($this->getDbconnection(), false); $categories = array(); foreach ($categoryList->getCategories() as $category) { $categories[$category->getName()] = $category->getId(); } $view = new \model\view_public('apply_form'); $view->assign('affiliate', $affiliate); $view->assign('categories', $categories); $view->assign('antiSpamQuestion', $this->getSysconfig()->getAntispamQuestion()); $view->assign('isNotUtf8', $this->isNotUtf8); $view->assign('systemVersion', $this->getSysconfig()->getSysVersion()); $view->setReturnRender($this->returnRender); if ($this->returnRender) { $data = $view->render(); return $data; } $view->render(); }
public function process() { if (!parent::process()) { $this->redirectNoSession(); } $affiliateIds = array($this->getRequestVar('affiliateid', array(1, 4, 7))); $data = array('emailText' => '', 'mailSubject' => ''); if (is_null($affiliateIds[0])) { $this->redirect('affiliate/list'); } if (!is_null($this->getRequestVar('mailData'))) { $data = array_merge($data, $this->getRequestVar('mailData')); if (strpos($data['mailRecipients'], PHP_EOL) == false) { str_replace(PHP_EOL, ';', $data['mailRecipients']); } $recipients = explode(';', $data['mailRecipients']); $sendRecipients = array(); $affiliateList = new \model\affiliate_list($this->dbconnection); foreach ($affiliateList->getAffiliateIdsByEmail($recipients) as $affiliateIdArr) { $affiliate = new \model\affiliate($this->getDbconnection(), $affiliateIdArr['id']); $category = new \model\category($this->getDbconnection(), $affiliate->getAffiliateCategory()); $replacers = array('pagename' => $affiliate->getPageName(), 'pageurl' => $affiliate->getPageUrl(), 'adminname' => $affiliate->getPageAdminName(), 'adminmail' => $affiliate->getPageAdminEmail(), 'category' => $category->getName()); $mailtext = $data['emailText']; foreach ($replacers as $key => $value) { $mailtext = str_replace('{{' . $key . '}}', $value, $mailtext); } $mailData = array('mailTo' => $affiliate->getPageAdminEmail(), 'mailSubject' => $this->filterRequest($data['mailSubject'], array(1, 4, 7, 2)), 'mailText' => $this->filterRequest($mailtext, array(1, 4, 7, 2)), 'mailFrom' => 'affiliat_r_no_reply@' . $_SERVER['HTTP_HOST']); \messages::sendEMail($mailData); $sendRecipients[] = $affiliate->getPageAdminEmail(); } $mailtext = $data['emailText']; foreach ($replacers as $key => $value) { $mailtext = str_replace('{{' . $key . '}}', '', $mailtext); } foreach ($recipients as $recipient) { if (in_array($recipient, $sendRecipients)) { continue; } $mailData = array('mailTo' => $recipient, 'mailSubject' => $this->filterRequest($data['mailSubject'], array(1, 4, 7, 2)), 'mailText' => $this->filterRequest($mailtext, array(1, 4, 7, 2)), 'mailFrom' => 'affiliat_r_no_reply@' . $_SERVER['HTTP_HOST']); \messages::sendEMail($mailData); } $this->redirect('affiliate/list'); } else { $affiliate = new \model\affiliate($this->getDbconnection(), $affiliateIds[0]); $recipients = array($affiliate->getPageAdminEmail()); } $data['recipients'] = implode(';', $recipients); $view = new \model\view_acp('contact'); foreach ($data as $key => $value) { $view->assign($key, $value); } $view->render(); }
public function process() { $affiliates = new \model\affiliate_list($this->getDbconnection(), $this->categoryId, $this->acceptedOnly, $this->textOnly); $view = new \model\view_public($this->viewName); if (count($affiliates->getAffiliates()) > 0) { $view->assign('affiliates', $affiliates->getAffiliates()); } else { $view->assign('notaffiliates', true); } $category = new \model\category($this->getDbconnection(), $this->categoryId); $value = $this->openBlank ? 'target="_blank"' : ''; $categoryName = $this->textOnly == 2 ? $category->getName() . '-text' : $category->getName(); $view->assign('linkTarget', $value); $view->assign('categoryNameClass', strtolower($categoryName)); $view->assign('showastext', $this->textOnly); $view->assign('isNotUtf8', $this->isNotUtf8); $view->assign('systemVersion', $this->getSysconfig()->getSysVersion()); $view->setReturnRender($this->returnRender); if ($this->returnRender) { $data = $view->render(); return $data; } $view->render(); }
/** * Ließt Daten ein * @return void */ private function loadData() { if ($this->groupByCategory) { $this->affiliates = array(); $categoryList = new category_list($this->dbconnection); $categoryList = $categoryList->getCategories(); foreach ($categoryList as $category) { $affiliates = new affiliate_list($this->dbconnection, $category->getId()); $this->affiliates[$category->getName()] = $affiliates->getAffiliates(); } } else { $where = !is_null($this->categoryId) ? "affiliateCategory = {$this->categoryId} ORDER BY id ASC" : null; $affiliateIds = $this->dbconnection->select($this->affiliateTab, 'id', $where); if ($affiliateIds === false) { return; } foreach ($affiliateIds as $affiliateId) { $affiliateId = $affiliateId['id']; $affiliate = new \model\affiliate($this->dbconnection, $affiliateId); $category = new \model\category($this->dbconnection, $affiliate->getAffiliateCategory()); $affiliate->setAffiliateCategory($category->getName()); if ($this->exclude($affiliate)) { continue; } $this->affiliates[$affiliateId] = $affiliate; } } }