Новичок | Продам полную версию сайта slonkupon.ru точную копию. Движок написан на фраемворке Symfony Цена 300WMZ (без базы партнеров) Для примера выкладываю часть Classa Модуля Промо акций на сайте. Писать суда в пм либо в аську 751555
PHP код: class promoActions extends sfActions
{
public function executeShow(sfWebRequest $request)
{
$this->currentUser = $this->getUser()->getGuardUser();
if ($this->currentUser) {
$this->auth = true;
} else {
$this->auth = false;
}
$this->promo = $this->getRoute()->getObject();
$this->form = new UserRegisterPromoForm();
}
public function executeRegister(sfWebRequest $request)
{
$form = new UserRegisterPromoForm();
$form->bind($request->getParameter($form->getName()));
if (! $form->isValid()) {
$this->forward404();
}
$this->user = $form->save();
$this->password = substr($this->user->generateRandomKey(), 0, 8);
$this->code = $this->user->generateRandomKey();
$this->user->setPassword($this->password);
$this->user->setPasswordRaw($this->password);
$this->user->setCode($this->code);
$this->user->setIsActive(0);
$this->user->save();
$this->user->addGroupByName('users');
if (! $this->sendConfirmationLetter()) {
$this->forward404();
}
$user = $this->getUser();
$user->setAttribute('promo_pass', $this->password);
$user->setAttribute('promo_code', $this->code);
$user->setAttribute('promo_email', $this->user->getUsername());
$this->redirect('@promo_confirmation');
}
public function executeConfirmation(sfWebRequest $request)
{
$this->forward404If(!$this->getUser()->hasAttribute('promo_email'));
$this->email = $this->getUser()->getAttribute('promo_email');
}
private function sendConfirmationLetter()
{
$settingTable = SettingTable::getInstance();
$from = $settingTable->getValueByCode('core.email.from');
$fromName = $settingTable->getValueByCode('core.email.from_name');
$markers['#PROJECT_URL#'] = $settingTable->getValueByCode('core.project.url');
$markers['#PROJECT_NAME#'] = $settingTable->getValueByCode('core.project.name');
$markers['#PROJECT_LINK#'] = sprintf('<a href="%s">%s</a>', $markers['#PROJECT_URL#'], $markers['#PROJECT_NAME#']);
$markers['#USER_EMAIL_ADDRESS#'] = $this->user->getUsername();
$markers['#USER_CODE#'] = $this->code;
$markers['#USER_PASS#'] = $this->password;
$letter = MessagesTemplatesTable::getByCode('NEW_REGISTERED_USER');
if (!$letter) {
return false;
}
$subject = strtr($letter->getTitle(), $markers);
$body = strtr($letter->getMessage(), $markers);
$messageType = $letter->getIsHtml() ? 'text/html' : 'text/plain';
$mailer = $this->getMailer();
$mail = new Swift_Message($subject, $body, $messageType);
$mail->setFrom($from, $fromName);
$mail->setTo($this->user->getUsername());
$result = $mailer->send($mail);
return (0 !== $result);
}
}
|