コード例 #1
0
ファイル: Member.php プロジェクト: subashemphasize/test_site
 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);
         }
     }
 }
コード例 #2
0
ファイル: Admin.php プロジェクト: subashemphasize/test_site
 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);
         }
     }
 }
コード例 #3
0
 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');
 }
コード例 #4
0
ファイル: User.php プロジェクト: grlf/eyedock
 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);
         }
     }
 }
コード例 #5
0
ファイル: Admin.php プロジェクト: grlf/eyedock
 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);
         }
     }
 }
コード例 #6
0
ファイル: Controller.php プロジェクト: grlf/eyedock
 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);
 }
コード例 #7
0
ファイル: User.php プロジェクト: alexanderTsig/arabic
 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();
     }
 }
コード例 #8
0
 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;
 }
コード例 #9
0
ファイル: Invoice.php プロジェクト: grlf/eyedock
 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();
     }
 }
コード例 #10
0
 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;
 }
コード例 #11
0
ファイル: AffCommission.php プロジェクト: irovast/eyedock
 /**
  * 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();
         }
     }
 }
コード例 #12
0
ファイル: CreditCard.php プロジェクト: alexanderTsig/arabic
 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());
         }
     }
 }
コード例 #13
0
ファイル: Bootstrap.php プロジェクト: grlf/eyedock
 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);
             }
         }
     }
 }
コード例 #14
0
ファイル: AdminAuthController.php プロジェクト: grlf/eyedock
 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);
 }
コード例 #15
0
ファイル: User.php プロジェクト: subashemphasize/test_site
 function sendRegistrationEmail()
 {
     if ($et = Am_Mail_Template::load('registration_mail', $this->lang)) {
         $et->setUser($this);
         $et->password = $this->getPlaintextPass();
         $et->send($this);
     }
 }
コード例 #16
0
 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());
         }
     }
 }
コード例 #17
0
 public function sendCronExpires()
 {
     $mails = $this->findBy(array('name' => EmailTemplate::EXPIRE));
     if (!$mails) {
         return;
     }
     // nothing to send
     $byDate = array();
     // templates by expiration date
     foreach ($mails as $et) {
         $et->_productIds = $et->findMatchingProductIds();
         ///
         $day = -$et->day;
         $string = $day . ' days';
         if ($day >= 0) {
             $string = "+{$string}";
         }
         if ($day == 0) {
             $string = 'today';
         }
         $date = date('Y-m-d', strtotime($string, $this->getDi()->time));
         $byDate[$date][] = $et;
     }
     $userTable = $this->getDi()->userTable;
     // now query expirations
     $q = $this->getDi()->accessTable->queryExpirations(array_keys($byDate));
     $sent = array();
     // user_id => array('tpl_id')
     while ($row = $this->_db->fetchRow($q)) {
         $user = $userTable->createRecord($row);
         if ($user->unsubscribed || !$user->is_approved) {
             continue;
         }
         foreach ($byDate[$row['_expire_date']] as $et) {
             // do not send same template agian to the same user
             if (!empty($sent[$user->user_id]) && array_search($et->pk(), $sent[$user->user_id]) !== false) {
                 continue;
             }
             if ($et->_productIds == ResourceAccess::ANY_PRODUCT || in_array($row['_product_id'], $et->_productIds)) {
                 // check if no matching not_conditions
                 if (!$et->checkNotConditions($user)) {
                     continue;
                 }
                 $recipients = array();
                 if ($et->recipient_user) {
                     $recipients[] = $user;
                 }
                 if ($et->recipient_aff && $user->aff_id && ($aff = $this->getDi()->userTable->load($user->aff_id, false))) {
                     $recipients[] = $aff;
                 }
                 if ($et->recipient_admin) {
                     $recipients[] = Am_Mail_Template::TO_ADMIN;
                 }
                 if ($et->recipient_emails) {
                     foreach (array_map('trim', explode(',', $et->recipient_emails)) as $email) {
                         if ($email) {
                             $recipients[] = $email;
                         }
                     }
                 }
                 foreach ($recipients as $recipient) {
                     $tpl = Am_Mail_Template::createFromEmailTemplate($et);
                     $tpl->setUser($user);
                     $tpl->setExpires(amDate($row['_expire_date']));
                     $tpl->setProduct_title($this->getDi()->productTable->load($row['_product_id'])->title);
                     $tpl->send($recipient);
                 }
                 $sent[$user->user_id][] = $et->pk();
             }
         }
     }
 }
コード例 #18
0
ファイル: Abstract.php プロジェクト: grlf/eyedock
 /**
  * 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);
 }
コード例 #19
0
ファイル: Subusers.php プロジェクト: alexanderTsig/arabic
 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);
     }
 }
コード例 #20
0
 function process(Am_Form $f)
 {
     $vars = $f->getValue();
     $user = Am_Di::getInstance()->userTable->findFirstByLogin($vars['user']);
     if (!$user) {
         list($el) = $f->getElementsByName('user');
         $el->setError(___('User %s not found', $vars['user']));
         return false;
     }
     $product = Am_Di::getInstance()->productTable->load($vars['product_id']);
     $template = $this->grid->getRecord();
     $mail = Am_Mail_Template::createFromEmailTemplate($template);
     switch ($template->name) {
         case EmailTemplate::AUTORESPONDER:
             $mail->setLast_product_title($product->title);
             break;
         case EmailTemplate::EXPIRE:
             $mail->setProduct_title($product->title);
             $mail->setExpires($vars['expires']);
             break;
         default:
             throw new Am_Exception_InternalError('Unknown email template name [%s]', $template->name);
     }
     $mail->setUser($user);
     $mail->send($user, new Am_Mail_Transport_Null());
     if ($template->format == 'text') {
         printf('<div style="margin-bottom:0.5em;">%s: <strong>%s</strong></div><div style="border:1px solid #2E2E2E; width:%s"><pre>%s</pre></div>', ___('Subject'), Am_Controller::escape($this->getSubject($mail)), '100%', Am_Controller::escape($mail->getMail()->getBodyText()->getRawContent()));
     } else {
         $session = new Zend_Session_Namespace('email_preview');
         $session->output = $mail->getMail()->getBodyHtml()->getRawContent();
         printf('<div style="margin-bottom:0.5em;">%s: <strong>%s</strong></div><iframe  style="border:1px solid #2E2E2E; width:%s; height:300px" src="%s/default/admin-content/p/emails/index?_emails_a=preview&_emails_id=67&_emails_preview=1"></iframe>', ___('Subject'), Am_Controller::escape($this->getSubject($mail)), '100%', REL_ROOT_URL);
     }
     return true;
 }
コード例 #21
0
ファイル: ProfileController.php プロジェクト: grlf/eyedock
 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;
 }
コード例 #22
0
 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');
 }
コード例 #23
0
ファイル: Bootstrap.php プロジェクト: alexanderTsig/arabic
 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);
     }
 }
コード例 #24
0
ファイル: Echeck.php プロジェクト: grlf/eyedock
 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();
         }
     }
 }
コード例 #25
0
ファイル: Signup.php プロジェクト: subashemphasize/test_site
 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');
 }
コード例 #26
0
 function sendCronMailNotCompleted()
 {
     return;
     $mails = $this->findBy(array('name' => EmailTemplate::NOT_COMPLETED));
     if (!$mails) {
         return;
     }
     // nothing to send
     $byDate = array();
     // templates by expiration date
     foreach ($mails as $et) {
         $day = -$et->day;
         if (!$day) {
             continue;
         }
         // must be an error
         $string = $day . ' days';
         $date = date('Y-m-d', strtotime($string));
         $byDate[$date] = $et;
         $whereDates[] = "(i.tm_added BETWEEN '{$date} 00:00:00' AND '{$date} 23:59:59')";
     }
     $whereDates = implode(' OR ', $whereDates);
     $q = $this->_db->queryResultOnly("SELECT u.*, \n                i.invoice_id AS _invoice_id,\n                DATE(i.tm_added) AS _invoice_date_added\n            FROM ?_invoice i \n                LEFT JOIN ?_user u USING (user_id)\n            WHERE \n                i.status = ?d \n                AND ({$whereDates})\n                AND u.status = ? \n            ", Invoice::PENDING, User::STATUS_PENDING);
     $sent = array();
     $userTable = $this->getDi()->userTable;
     while ($row = $this->_db->fetchRow($q)) {
         if (array_key_exists($row['user_id'], $sent)) {
             continue;
         }
         $et = $byDate[$row['_invoice_date_added']];
         if (!$et) {
             continue;
         }
         $user = $userTable->createRecord($row);
         $tpl = Am_Mail_Template::createFromEmailTemplate($et);
         $tpl->user = $user;
         $tpl->send($user);
         $sent[$row['user_id']] = true;
     }
 }
コード例 #27
0
 /**
  * @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);
         }
     }
 }
コード例 #28
0
ファイル: User.php プロジェクト: alexanderTsig/arabic
 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);
     }
 }
コード例 #29
0
 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();
             }
         }
     }
 }