Exemple #1
0
 public function onAfterInsertMessage($message)
 {
     if (Am_Di::getInstance()->config->get('helpdesk.notify_new_message_admin', 1)) {
         $et = Am_Mail_Template::load('helpdesk.notify_new_message_admin');
         if ($et) {
             $et->setUrl(sprintf('%s/helpdesk/admin/p/view/view/ticket/%s', Am_Di::getInstance()->config->get('root_surl'), $message->getTicket()->ticket_mask));
             $et->send(Am_Mail_Template::TO_ADMIN);
         }
     }
 }
Exemple #2
0
 public function onAfterInsertMessage($message)
 {
     if ($message->type == 'message' && Am_Di::getInstance()->config->get('helpdesk.notify_new_message', 1)) {
         $user = $this->getMember($message->getTicket()->user_id);
         $et = Am_Mail_Template::load('helpdesk.notify_new_message');
         if ($et) {
             $et->setUser($user);
             $et->setUrl(sprintf('%s/helpdesk/index/p/view/view/ticket/%s', Am_Di::getInstance()->config->get('root_surl'), $message->getTicket()->ticket_mask));
             $et->send($user);
         }
     }
 }
 public function doSignup(array $vars)
 {
     $vars['name'] = preg_replace('/[^\\w\\s]+/u', '', $vars['name']);
     $rand = substr(sha1(mt_rand()), 0, 10);
     $link = ROOT_SURL . "/newsletter/subscribe/confirm/k/" . $rand;
     $this->getDi()->store->setBlob(self::STORE_KEY . $rand, serialize($vars), sqlTime('+48 hours'));
     /// send confirmation e-mail
     $et = Am_Mail_Template::load('verify_guest');
     if (!$et) {
         throw new Am_Exception_Configuration("No e-mail template found for [verify_guest]");
     }
     $et->setName($vars['name'])->setLink($link)->setCode($rand);
     $et->send($vars['email']);
     $this->_redirect('newsletter/subscribe/confirm');
 }
Exemple #4
0
 public function onAfterInsertTicket($ticket)
 {
     if ($this->getDi()->config->get('helpdesk.new_ticket')) {
         $user = $this->getUser($ticket->user_id);
         if ($user->unsubscribed) {
             return;
         }
         $et = Am_Mail_Template::load('helpdesk.new_ticket', $user->lang);
         if ($et) {
             $et->setTicket($ticket);
             $et->setUser($user);
             $et->setUrl(sprintf('%s/helpdesk/ticket/%s', $this->getDi()->config->get('root_surl'), $ticket->ticket_mask));
             $et->send($user);
         }
     }
 }
Exemple #5
0
 public function onAfterInsertMessage($message)
 {
     if ($message->type == 'message' && $this->getDi()->config->get('helpdesk.notify_new_message', 1)) {
         $user = $this->getUser($message->getTicket()->user_id);
         if ($user->unsubscribed) {
             return;
         }
         $et = Am_Mail_Template::load('helpdesk.notify_new_message', $user->lang);
         if ($et) {
             $et->setTicket($message->getTicket());
             $et->setUser($user);
             $et->setMessage($message);
             $et->setUrl(sprintf('%s/helpdesk/ticket/%s', $this->getDi()->config->get('root_surl'), $message->getTicket()->ticket_mask));
             $et->send($user);
         }
     }
 }
Exemple #6
0
 public function takeAction()
 {
     $ticketIdentity = $this->getParam('ticket');
     $ticket = $this->getDi()->helpdeskTicketTable->load($ticketIdentity);
     if (!$this->strategy->canEditOwner($ticket)) {
         throw new Am_Exception_AccessDenied(___('Access Denied'));
     }
     $id = $this->getParam('id');
     $id = $id ? $this->getDi()->app->reveal($id) : $this->strategy->getIdentity();
     $ticket->owner_id = $id;
     $ticket->save();
     if ($this->strategy->getIdentity() != $id && $this->getModule()->getConfig('notify_assign')) {
         $admin = $this->getDi()->adminTable->load($id);
         $et = Am_Mail_Template::load('helpdesk.notify_assign');
         $et->setTicket($ticket);
         $et->setAdmin($admin);
         $et->setUrl(sprintf('%s/helpdesk/admin/ticket/%s', $this->getDi()->config->get('root_surl'), $ticket->ticket_mask));
         $et->send($admin->email);
     }
     $this->redirectTicket($ticket);
 }
Exemple #7
0
 public function onIpCountExceeded(User $user)
 {
     if ($user->is_locked < 0) {
         return;
     }
     // auto-lock disabled
     if ($this->getDi()->store->get('on-ip-count-exceeded-' . $user->pk())) {
         return;
     }
     //action already done
     $this->getDi()->store->set('on-ip-count-exceeded-' . $user->pk(), 1, '+20 minutes');
     if (in_array('email-admin', $this->getDi()->config->get('max_ip_actions', array()))) {
         $et = Am_Mail_Template::load('max_ip_actions_admin');
         if (!$et) {
             throw new Am_Exception_Configuration("No e-mail template found for [max_ip_actions_admin]");
         }
         $et->setMaxipcount($this->getDi()->config->get('max_ip_count', 0))->setMaxipperiod($this->getDi()->config->get('max_ip_period', 0))->setUser($user);
         if (in_array('disable-user', $this->getDi()->config->get('max_ip_actions', array()))) {
             $et->setUserlocked(___('Customer account has been automatically locked.'));
         }
         $et->sendAdmin();
     }
     if (in_array('email-user', $this->getDi()->config->get('max_ip_actions', array()))) {
         $et = Am_Mail_Template::load('max_ip_actions_user');
         if (!$et) {
             throw new Am_Exception_Configuration("No e-mail template found for [max_ip_actions_user]");
         }
         $et->setMaxipcount($this->getDi()->config->get('max_ip_count', 0))->setMaxipperiod($this->getDi()->config->get('max_ip_period', 0))->setUser($user);
         if (in_array('disable-user', $this->getDi()->config->get('max_ip_actions', array()))) {
             $et->setUserlocked(___('Your account has been automatically locked.'));
         }
         $et->send($user->email);
     }
     if (in_array('disable-user', $this->getDi()->config->get('max_ip_actions', array()))) {
         // disable customer
         $user->lock();
     }
 }
 function process(array $vars, $name, HTML_QuickForm2_Controller_Page $page)
 {
     $this->vars = $vars;
     $em = $page->getController()->getSessionContainer()->getOpaque('EmailCode');
     // do actions here
     $this->user = $this->getDi()->userRecord;
     $this->user->setForInsert($this->vars);
     // vars are filtered by the form !
     $this->user->is_affiliate = 1;
     if (empty($this->user->login)) {
         $this->user->generateLogin();
     }
     if (empty($this->vars['pass'])) {
         $this->user->generatePassword();
     } else {
         $this->user->setPass($this->vars['pass']);
     }
     $this->user->insert();
     // remove verification record
     if (!empty($em)) {
         $this->getDi()->store->delete(Am_Form_Signup_Action_SendEmailCode::STORE_PREFIX . $em);
     }
     $page->getController()->destroySessionContainer();
     $this->getDi()->hook->call(Am_Event::SIGNUP_USER_ADDED, array('vars' => $this->vars, 'user' => $this->user, 'form' => $this->form));
     $this->getDi()->hook->call(Am_Event::SIGNUP_AFF_ADDED, array('vars' => $this->vars, 'user' => $this->user, 'form' => $this->form));
     $this->getDi()->auth->setUser($this->user, $_SERVER['REMOTE_ADDR']);
     if ($this->getDi()->config->get('aff.registration_mail')) {
         if ($et = Am_Mail_Template::load('aff.registration_mail', $this->user->lang)) {
             $et->setUser($this->user);
             $et->password = $this->user->getPlaintextPass();
             $et->send($this->user);
         }
     }
     $this->_redirect('aff/aff');
     return true;
 }
Exemple #9
0
 function onHourly()
 {
     if ($this->getConfig('autoclose')) {
         $period = $this->getConfig('autoclose_period', 72);
         $thresholdDate = sqlTime("-{$period} hours");
         foreach ($this->getDi()->db->selectPage($total, "\n                SELECT *\n                FROM ?_helpdesk_ticket\n                WHERE status=? AND updated < ?\n                ", HelpdeskTicket::STATUS_AWAITING_USER_RESPONSE, $thresholdDate) as $row) {
             $ticket = $this->getDi()->helpdeskTicketRecord->fromRow($row);
             $ticket->status = HelpdeskTicket::STATUS_CLOSED;
             $ticket->updated = $this->getDi()->sqlDateTime;
             $ticket->save();
             $user = $ticket->getUser();
             if ($this->getConfig('notify_autoclose')) {
                 $et = Am_Mail_Template::load('helpdesk.notify_autoclose', $user->lang);
                 $et->setUser($user);
                 $et->setTicket($ticket);
                 $et->setUrl(sprintf('%s/helpdesk/ticket/%s', $this->getDi()->config->get('root_surl'), $ticket->ticket_mask));
                 $et->send($user);
             }
         }
     }
 }
Exemple #10
0
 function sendRegistrationEmail()
 {
     if ($et = Am_Mail_Template::load('registration_mail', $this->lang)) {
         $et->setUser($this);
         $et->password = $this->getPlaintextPass();
         $et->send($this);
     }
 }
 protected function _addPendingInvoiceAndSend(Invoice $invoice, Am_Form $form, $vars)
 {
     if ($vars['paysys_id']) {
         try {
             $invoice->setPaysystem($vars['paysys_id'], false);
         } catch (Am_Exception_InputError $e) {
             $form->setError($e->getMessage());
             return false;
         }
     }
     $errors = $invoice->validate();
     if ($errors) {
         $form->setError(current($errors));
         return false;
     }
     $invoice->data()->set('added-by-admin', $this->getDi()->authAdmin->getUserId());
     $invoice->due_date = $vars['tm_due'];
     $invoice->save();
     $et = Am_Mail_Template::load('invoice_pay_link', $invoice->getUser()->lang ? $invoice->getUser()->lang : null);
     $et->setUser($invoice->getUser());
     $et->setUrl(ROOT_SURL . sprintf('/pay/%s', $invoice->getSecureId('payment-link')));
     $et->setMessage($vars['message']);
     $et->setInvoice($invoice);
     $et->setInvoice_text($invoice->render());
     $et->send($invoice->getUser());
     return true;
 }
Exemple #12
0
 function afterInsert(array &$values, User $record, Am_Grid_Editable $grid)
 {
     if ($et = Am_Mail_Template::load('subusers.registration_mail', $record->lang)) {
         $et->setUser($record);
         $et->setPassword($record->getPlaintextPass());
         $reseller = $this->getDi()->userTable->load($record->subusers_parent_id);
         $et->setReseller($reseller);
         //backward compatibality (reseller_name_f, reseller_name_l, reseller_email)
         $et->setReseller_name_f($reseller->name_f);
         $et->setReseller_name_l($reseller->name_l);
         $et->setReseller_email($reseller->email);
         if (!empty($values['_groups'])) {
             $userTitle = array();
             foreach ($this->getDi()->productTable->loadIds($values['_groups']) as $product) {
                 $userTitle[] = $product->title;
             }
             $et->setUser_product(join(', ', $userTitle));
             $resellerTitle = array();
             $conditions = array('subusers_product_id' => $values['_groups']);
             foreach ($this->getDi()->productTable->findBy($conditions) as $product) {
                 $resellerTitle[] = $product->title;
             }
             $et->setReseller_product(join(', ', $resellerTitle));
         }
         $et->send($record);
     }
 }
 function onAffCommissionAfterInsert(Am_Event $event)
 {
     /* @var $commission AffCommission */
     $commission = $event->getCommission();
     if ($commission->record_type == AffCommission::VOID) {
         return;
     }
     // void
     if ($this->getConfig('mail_sale_admin')) {
         if ($et = Am_Mail_Template::load('aff.mail_sale_admin')) {
             $et->setPayment($commission->getPayment())->setInvoice($invoice = $commission->getInvoice())->setAffiliate($commission->getAff())->setUser($invoice->getUser())->setCommission($commission->amount)->setTier($commission->tier + 1)->setProduct($this->getDi()->productTable->load($commission->product_id, false))->sendAdmin();
         }
     }
     if ($this->getConfig('mail_sale_user')) {
         if ($et = Am_Mail_Template::load('aff.mail_sale_user')) {
             $et->setPayment($commission->getPayment())->setInvoice($invoice = $commission->getInvoice())->setAffiliate($commission->getAff())->setUser($invoice->getUser())->setCommission($commission->amount)->setTier($commission->tier + 1)->setProduct($this->getDi()->productTable->load($commission->product_id, false))->send($commission->getAff());
         }
     }
 }
Exemple #14
0
 private function sendSecurityCode(Admin $admin)
 {
     $security_code = $this->getDi()->app->generateRandomString(16);
     $securitycode_expire = sqlTime(time() + self::EXPIRATION_PERIOD * 60 * 60);
     $et = Am_Mail_Template::load('send_security_code_admin', null, true);
     $et->setUser($admin);
     $et->setUrl(sprintf('%s/admin-auth/change-pass/?s=%s', $this->getDi()->config->get('root_url'), $security_code));
     $et->setHours(self::EXPIRATION_PERIOD);
     $et->send($admin);
     $this->getDi()->store->set(self::SECURITY_CODE_STORE_PREFIX . $security_code, $admin->pk(), $securitycode_expire);
 }
Exemple #15
0
 public function sendCcExpireMessage()
 {
     // Send Message only if plugin is allowed to store CC info.
     if (!$this->storesCcInfo()) {
         return;
     }
     if (!$this->getDi()->config->get('cc.card_expire')) {
         return;
     }
     $oRebillDate = $this->getDi()->dateTime;
     $oRebillDate->modify(sprintf("+%d days", $this->getDi()->config->get('cc.card_expire_days', 5)));
     foreach ($this->getDi()->db->selectPage($total, "\n            SELECT i.invoice_id, c.cc_expire \n            FROM ?_invoice i LEFT JOIN ?_cc c using(user_id)\n            WHERE i.rebill_date = ? and CONCAT(SUBSTR(c.cc_expire, 3,2), SUBSTR(c.cc_expire, 1,2)) < ? \n            and i.paysys_id = ? \n            ", $oRebillDate->format('Y-m-d'), $oRebillDate->format('ym'), $this->getId()) as $r) {
         $invoice = $this->getDi()->invoiceTable->load($r['invoice_id']);
         if ($et = Am_Mail_Template::load('cc.card_expire')) {
             $et->setUser($invoice->getUser());
             $et->setInvoice($invoice);
             $et->setExpires(substr_replace($r['cc_expire'], '/', 2, 0));
             $et->setMailPeriodic(Am_Mail::USER_REQUESTED);
             $et->send($invoice->getUser());
         }
     }
 }
Exemple #16
0
 /**
  * Generate payout records for records on $date
  * @param date $date today's date
  */
 function runPayout($date)
 {
     $threseholdDate = sqlDate(amstrtotime($date) - 24 * 3600 * $this->getDi()->config->get('aff.payout_delay_days', 30));
     // now select all affiliates to pay with one query
     $q = $this->_db->queryResultOnly("\n            SELECT SUM(IF(c.record_type=?,-c.amount,c.amount)) AS _total,\n                a.*\n            FROM ?_aff_commission c RIGHT JOIN ?_user a ON a.user_id=c.aff_id\n            WHERE (c.record_type=? OR c.date<=?) AND (c.payout_detail_id IS NULL)\n            GROUP BY c.aff_id\n            HAVING _total > 0 AND _total >= ?  AND a.aff_payout_type > ''\n        ", AffCommission::VOID, AffCommission::VOID, $threseholdDate, (double) $this->getDi()->config->get('aff.payout_min', 0));
     // then do job
     $payouts = array();
     while ($row = $this->_db->fetchRow($q)) {
         $aff = $this->getDi()->userTable->createRecord($row);
         if (empty($payouts[$aff->aff_payout_type])) {
             $payout = $this->getDi()->affPayoutRecord;
             $payout->type = $aff->aff_payout_type;
             $payout->date = sqlDate($date);
             $payout->thresehold_date = $threseholdDate;
             $payout->insert();
             $payouts[$aff->aff_payout_type] = $payout;
         }
         $detail = $payouts[$aff->aff_payout_type]->addDetail($aff->pk(), $row['_total']);
         $this->_db->query("UPDATE ?_aff_commission c\n                SET c.payout_detail_id=?d\n                WHERE aff_id=?d AND (c.record_type=? OR c.date<=?) AND (c.payout_detail_id IS NULL)\n                ", $detail->pk(), $aff->pk(), AffCommission::VOID, $threseholdDate);
     }
     foreach ($payouts as $payout) {
         $payout->update();
     }
     // store totals
     if ($payouts) {
         $this->getDi()->hook->call(Bootstrap_Aff::AFF_PAYOUT, array('payouts' => $payouts));
         if ($et = Am_Mail_Template::load('aff.new_payouts')) {
             $et->setUrl(ROOT_SURL . '/aff/admin-payout')->sendAdmin();
         }
     }
 }
Exemple #17
0
 /**
  * Logs-in customer by given username and password
  * @param string Username
  * @param string Password
  * @param string IP
  * @return Am_Auth_Result
  */
 public function login($login, $pass, $ip, $disableProtector = false, $loginAttemptId = null)
 {
     //Zend_Session::regenerateId();
     $this->setUser(null, null);
     $login = preg_replace('/[^a-zA-Z0-9 _.@+-]/ms', '', $login);
     if (!strlen($login) || !strlen($pass)) {
         return new Am_Auth_Result(Am_Auth_Result::INVALID_INPUT);
     }
     if ($loginAttemptId) {
         if (@in_array($loginAttemptId, @$this->session->login_attempt_id)) {
             return new Am_Auth_Result(Am_Auth_Result::INVALID_INPUT, ___('Session expired, please enter username and password again'));
         }
     }
     ///
     if (!$disableProtector) {
         $bp = $this->getProtector();
         $wait = $bp->loginAllowed($ip, $login);
         if (null !== $wait) {
             // this customer have to wait before next attempt
             do {
                 if (!$this->getDi()->config->get('bruteforce_notify')) {
                     break;
                 }
                 if ($this->getDi()->store->get('bruteforce-' . $ip)) {
                     break;
                 }
                 //action already done
                 $this->getDi()->store->set('bruteforce-' . $ip, 1, '+20 minutes');
                 $et = Am_Mail_Template::load('bruteforce_notify');
                 if (!$et) {
                     break;
                 }
                 $et->setIp($ip);
                 $et->setLogin($login);
                 $et->sendAdmin();
             } while (false);
             $fail = new Am_Auth_Result(Am_Auth_Result::FAILURE_ATTEMPTS_VIOLATION, ___('Please wait %d seconds before next login attempt', $wait));
             $fail->wait = $wait;
             return $fail;
         }
     }
     $code = null;
     $user = $this->authenticate($login, $pass, $code);
     if ($user && $code == Am_Auth_Result::SUCCESS) {
         $newResult = $this->checkUser($user, $ip, $code);
         if ($newResult) {
             return $newResult;
         }
         // as returned from checkUser()
         $this->setUser($user, $ip, $code);
         $this->onSuccess();
         if ($loginAttemptId) {
             if (isset($this->session->login_attempt_id)) {
                 $this->session->login_attempt_id[] = $loginAttemptId;
             } else {
                 $this->session->login_attempt_id = array($loginAttemptId);
             }
         }
     } else {
         if (!$disableProtector) {
             $bp->reportFailure($ip, $login);
         }
     }
     return new Am_Auth_Result($code);
 }
Exemple #18
0
 function emailCanceled($is_upgrade = false)
 {
     $products = $this->getProducts();
     if ($this->getDi()->config->get('mail_upgraded_cancel_member', 0) && $is_upgrade) {
         $et = Am_Mail_Template::load('mail_upgraded_cancel_member');
         if (!$et) {
             throw new Am_Exception_Configuration("No e-mail template found for [mail_cancel_member]");
         }
         $et->setUser($this->getUser());
         $et->setProduct($products[0]);
         $et->setInvoice($this);
         $et->send($this->getUser()->getEmail());
     }
     if ($this->getDi()->config->get('mail_cancel_member', 0) && !$is_upgrade) {
         $et = Am_Mail_Template::load('mail_cancel_member');
         if (!$et) {
             throw new Am_Exception_Configuration("No e-mail template found for [mail_cancel_member]");
         }
         $et->setUser($this->getUser());
         $et->setProduct($products[0]);
         $et->setInvoice($this);
         $et->send($this->getUser()->getEmail());
     }
     if ($this->getDi()->config->get('mail_cancel_admin', 0) && !$is_upgrade) {
         $et = Am_Mail_Template::load('mail_cancel_admin');
         if (!$et) {
             throw new Am_Exception_Configuration("No e-mail template found for [mail_cancel_admin]");
         }
         $et->setUser($this->getUser());
         $et->setProduct($products[0]);
         $et->setInvoice($this);
         $et->sendAdmin();
     }
 }
Exemple #19
0
 protected function handleEmail(SavedForm $form, &$vars)
 {
     /* @var $user User */
     $user = $this->user;
     $bricks = $form->getBricks();
     foreach ($bricks as $brick) {
         if ($brick->getClass() == 'email' && $brick->getConfig('validate') && $vars['email'] != $user->email) {
             $code = $this->getDi()->app->generateRandomString(self::EMAIL_CODE_LEN);
             $data = array('security_code' => $code, 'email' => $vars['email']);
             $this->getDi()->store->setBlob(self::SECURITY_CODE_STORE_PREFIX . $this->user_id, serialize($data), sqlTime(Am_Di::getInstance()->time + self::SECURITY_CODE_EXPIRE * 3600));
             $tpl = Am_Mail_Template::load('verify_email_profile', get_first($user->lang, Am_Di::getInstance()->app->getDefaultLocale(false)), true);
             $cur_email = $user->email;
             $user->email = $vars['email'];
             $tpl->setUser($user);
             $tpl->setCode($code);
             $tpl->setUrl($this->getDi()->config->get('root_surl') . '/profile/confirm-email?em=' . $user->pk() . ':' . $code);
             $tpl->send($user);
             $user->email = $cur_email;
             unset($vars['email']);
             return true;
         }
     }
     return false;
 }
 protected function sendSecurityCode(User $user)
 {
     $security_code = $this->getDi()->app->generateRandomString(16);
     $et = Am_Mail_Template::load('send_security_code', $user->lang, true);
     $et->setUser($user);
     $et->setUrl(sprintf('%s/sendpass/?%s=%s', ROOT_SURL, self::SECURITY_VAR, $security_code));
     $et->setHours(self::EXPIRATION_PERIOD);
     $et->send($user);
     $this->getDi()->store->set(self::STORE_PREFIX . $security_code, $user->pk(), '+' . self::EXPIRATION_PERIOD . ' hours');
 }
Exemple #21
0
 function sendAffRegistrationEmail(User $user)
 {
     if ($this->getConfig('registration_mail') && ($et = Am_Mail_Template::load('aff.registration_mail', $user->lang))) {
         $et->setUser($user);
         $et->password = $user->getPlaintextPass();
         $et->send($user);
     }
 }
Exemple #22
0
 protected function sendStatisticsEmail()
 {
     $date = $this->getDi()->sqlDate;
     $success = $failed = "";
     $success_count = $failed_count = $success_amount = $failed_amount = 0;
     if ($et = Am_Mail_Template::load('cc.admin_rebill_stats')) {
         foreach ($this->getDi()->db->selectPage($total, "\n                SELECT r.*, i.second_total, i.user_id, i.invoice_id, i.public_id, i.rebill_date, u.name_f, u.name_l, u.email, u.login\n                FROM ?_cc_rebill r LEFT JOIN ?_invoice i USING(invoice_id) LEFT JOIN ?_user u ON(i.user_id = u.user_id)\n                WHERE status_tm>? and status_tm<=? and r.paysys_id=?\n                ", $date, $this->getDi()->sqlDateTime, $this->getId()) as $r) {
             if ($r['status'] == CcRebill::SUCCESS) {
                 $success_count++;
                 $success_amount += $r['second_total'];
                 $success .= $this->getStatisticsRow($r);
             } else {
                 $failed_count++;
                 $failed_amount += $r['second_total'];
                 $failed .= $this->getStatisticsRow($r);
             }
         }
         if ($success || $failed) {
             $currency = $this->getDi()->config->get('currency');
             $et->setShort_stats(sprintf(___('Success: %d (%0.2f %s) Failed: %d (%0.2f %s)'), $success_count, $success_amount, $currency, $failed_count, $failed_amount, $currency));
             $et->setRebills_success(!empty($success) ? $success : ___('No items in this section'));
             $et->setRebills_failed(!empty($failed) ? $failed : ___('No items in this section'));
             $et->setPlugin($this->getId());
             $et->setMailPeriodic(Am_Mail::ADMIN_REQUESTED);
             $et->sendAdmin();
         }
     }
 }
Exemple #23
0
 public function perform(HTML_QuickForm2_Controller_Page $page, $name)
 {
     $valid = $page->storeValues();
     if (!$valid) {
         return $page->handle('display');
     }
     $tpl = Am_Mail_Template::load('verify_email_signup', $lc = Am_Di::getInstance()->app->getDefaultLocale(false), true);
     $vars = $page->getController()->getValue();
     $u = Am_Di::getInstance()->userRecord;
     $u->name_f = @$vars['name_f'];
     $u->name_l = @$vars['name_l'];
     $u->email = $vars['email'];
     $tpl->setUser($u);
     $code = $this->storeState($page);
     $signupUrl = $page->getController()->getParentController()->getCurrentUrl();
     $tpl->setCode($code);
     $tpl->setUrl($signupUrl . '?em=' . $code);
     $tpl->send($u);
     // the $page is never the last page, because emailcode is always inserted after
     $next = $page->getController()->nextPage($page);
     return $next->handle('jump');
 }
 static function onPaymentAfterInsert(Am_Event_PaymentAfterInsert $event)
 {
     /**
      * This e-mail is sent for first payment in invoice only
      * another template must be used for the following payments
      */
     if ($event->getInvoice()->getPaymentsCount() != 1) {
         return;
     }
     if ($event->getDi()->config->get('send_payment_mail')) {
         $et = Am_Mail_Template::load('send_payment_mail', $event->getUser()->lang);
         if ($et) {
             $et->setUser($event->getUser())->setInvoice($event->getInvoice())->setPayment($event->getPayment())->setInvoice_text($event->getInvoice()->render());
             if (Am_Di::getInstance()->config->get('send_pdf_invoice', false)) {
                 try {
                     $invoice = new Am_Pdf_Invoice($event->getInvoice());
                     $et->getMail()->createAttachment($invoice->render(), 'application/pdf', Zend_Mime::DISPOSITION_ATTACHMENT, Zend_Mime::ENCODING_BASE64, $invoice->getFileName());
                 } catch (Exception $e) {
                     $this->getDi()->errorLogTable->logException($e);
                 }
             }
             $et->send($event->getUser());
         }
     }
     if ($event->getDi()->config->get('send_payment_admin')) {
         $et = Am_Mail_Template::load('send_payment_admin', $event->getUser()->lang);
         if ($et) {
             $et->setUser($event->getUser())->setInvoice($event->getInvoice())->setPayment($event->getPayment())->setInvoice_text($event->getInvoice()->render());
             $et->send(Am_Mail_Template::TO_ADMIN);
         }
     }
 }
 /**
  * @param array $ids ids of payout details
  * @param int $payout_id
  */
 protected function sendEmailsIfNecessary($ids, $payout_id)
 {
     $di = Am_Di::getInstance();
     $payout = $di->affPayoutTable->load($payout_id);
     $options = Am_Aff_PayoutMethod::getAvailableOptions();
     $payout_method_title = isset($options[$payout->type]) ? $options[$payout->type] : $payout->type;
     if ($di->modules->get('aff')->getConfig('notify_payout_paid')) {
         foreach ($ids as $id) {
             $payout_detail = $di->affPayoutDetailTable->load($id);
             $aff = $di->userTable->load($payout_detail->aff_id);
             $et = Am_Mail_Template::load('aff.notify_payout_paid', $aff->lang);
             $et->setPayout_detail($payout_detail);
             $et->setPayout_method_title($payout_method_title);
             $et->setPayout($payout);
             $et->setAffiliate($aff);
             $et->send($aff);
         }
     }
 }
Exemple #26
0
 function sendNotApprovedEmail()
 {
     if ($et = Am_Mail_Template::load('manually_approve', $this->lang)) {
         $et->setUser($this);
         $et->send($this);
     }
     if ($et = Am_Mail_Template::load('manually_approve_admin', $this->lang)) {
         $et->setUser($this);
         $et->send(Am_Mail_Template::TO_ADMIN);
     }
 }
 function onAuthCheckUser(Am_Event $event)
 {
     /* @var $user User */
     $user = $event->getUser();
     $recs = $this->getDi()->loginSessionTable->findBy(array('user_id' => $user->pk(), 'session_id' => '<>' . Zend_Session::getId(), 'modified' => '>' . sqlTime(sprintf('-%d minutes', $this->getConfig('timeout', 5))), 'need_logout' => 0));
     if ($recs) {
         switch ($this->getConfig('action', self::ACTION_LOGIN_REJECT)) {
             case self::ACTION_LOGIN_REJECT:
                 $event->setReturn(new Am_Auth_Result(-100, $this->getConfig('error', 'There is already exits active login session for your account.
                         Simultaneous login from different computers is not allowed.')));
                 $event->stop();
                 break;
             case self::ACTION_LOGOUT_OTHER:
                 foreach ($recs as $rec) {
                     $rec->updateQuick('need_logout', 1);
                 }
                 break;
             case self::ACTION_NOTHING:
                 break;
         }
         if ($this->getConfig('notify_admin') && !$this->getDi()->store->get('single-login-session-detected-' . $user->pk())) {
             $this->getDi()->store->set('single-login-session-detected-' . $user->pk(), 1, '+20 minutes');
             if ($et = Am_Mail_Template::load('misc.single-login-session.notify_admin')) {
                 $et->setUser($user);
                 $et->sendAdmin();
             }
         }
     }
 }