private function interruptIfMemoryFull() { if ($this->checkIfMemoryIsFull(memory_get_usage())) { Gpf_Log::warning('Be carefull, memory was filled up so im interrupting Gpf_Newsletter_GenerateBroadcastMailsTask task.'); $this->setDone(); $this->interrupt(); } }
public function __construct(Pap_Common_Transaction $transaction) { try { $user = $this->loadUser($transaction->getUserId()); $this->setAttributes($user->getName(), $user->getEmail(), $transaction); } catch (Gpf_DbEngine_NoRowException $e) { Gpf_Log::warning('User with userid=' . $transaction->getUserId() . ' was not found!'); $this->setAttributes($this->_('Unknown user'), $this->_('Unknown email'), $transaction); } }
/** * * @param $params */ protected function sendNotificationEmail(array $linkIds, $deleted = false) { $selectBuilder = new Gpf_SqlBuilder_SelectBuilder(); $selectBuilder->select->addAll(Pap_Db_Table_DirectLinkUrls::getInstance()); $selectBuilder->from->add(Pap_Db_Table_DirectLinkUrls::getName()); $selectBuilder->where->add(Pap_Db_Table_DirectLinkUrls::ID, 'IN', $linkIds); $usersMailTemplates = $this->getLinks($selectBuilder->getAllRowsIterator(), $deleted); foreach ($usersMailTemplates as $userId => $mail) { try { $user = $this->loadUser($userId); } catch (Gpf_DbEngine_NoRowException $e) { Gpf_Log::warning($this->_('Error load affiliate with userid=' . $userId . ', mail will not be send.')); continue; } $attribute = $this->loadAttributes($user->getAccountUserId()); if (Gpf_Settings::get(Pap_Settings::AFF_NOTIFICATION_ON_DIRECT_LINK_ENABLED) == Gpf::YES) { $isNotify = $attribute->getAttributeWithDefaultValue(Pap_Settings::AFF_NOTIFICATION_ON_DIRECT_LINK_ENABLED, Gpf_Settings::get(Pap_Settings::AFF_NOTIFICATION_ON_DIRECT_LINK_DEFAULT)); } else { $isNotify = Gpf_Settings::get(Pap_Settings::AFF_NOTIFICATION_ON_DIRECT_LINK_DEFAULT); } if ($isNotify == Gpf::YES) { $mail->setUser($user); $mail->addRecipient($user->getEmail()); try { $mail->send(); } catch (Exception $e) { Gpf_Log::error($this->_('Error sending direct link changed status notification email to affiliate: %s', $e->getMessage())); } } } }
/** * @throws Gpf_Tasks_LongTaskInterrupt */ public function importCSV(){ Gpf_Log::info('Importing file' . $this->form->getFieldValue(self::FILENAME)); $transactionHeader = $this->getHeader(); $rowsList = $this->getDataFromFile(); $this->cache = new Pap_Merchants_Transaction_TransactionsImportCache(); $i = 0; while($this->row = $rowsList->readArray()) { $this->interruptIfMemoryFull(); if ($this->isPending($i, $this->_('Importing transactions'))) { if ($i == 0 && $this->form->getFieldValue(self::SKIP_FIRST_ROW) == Gpf::YES) { Gpf_Log::info('Skipping first row'); $this->row[]='errorMessage'; $this->errorHeader = $this->row; $i++; continue; } if(count($this->row)<=1) { Gpf_Log::info('Skipping empty row ' . $i); $i++; continue; } $transaction = $this->getTransactionObject(); try { $this->saveTransaction($transaction, $transactionHeader, $this->row); } catch (Gpf_DbEngine_DuplicateEntryException $e) { $this->addError($this->_('Duplicate row')); } catch (Gpf_Exception $e){ $this->addError($this->_($e->getMessage())); } $this->setDone(); } $i++; } Gpf_Log::info('Import complete'); if ($this->errorFile !== null) { $this->errorFile->close(); if($this->errorFile->isExists()) { Gpf_Log::warning('Error occured during import, please check ' . Gpf_Paths::getInstance()->getCacheAccountDirectory().self::ERROR_FILE); $this->form->setInfoMessage("Import was not successful<br /><a href='" . Gpf_Paths::getInstance()->getCacheAccountDirectory().self::ERROR_FILE. "'>" . $this->_("Download unimported .csv") . "</a><br /> (error messages are at the end of each line)"); } else{ $this->form->setInfoMessage("Import was successful"); } } else{ $this->form->setInfoMessage("Import was successful"); } $this->form->setErrorMessage($this->_('Import was not successful.')); $this->form->setSuccessful(); $this->cache->clearCache(); return $this->form; }
public function handleError($severity, $message, $filename, $lineno) { if (error_reporting() == 0) { return; } if (error_reporting() & $severity) { $exception = new ErrorException($message, 0, $severity, $filename, $lineno); Gpf_Log::warning('Error calling function: ' . $this->getFunctionName($this->callback) . ', with parameters: ' . var_export($this->params, true) . '. Error trace: ' . $exception->getTraceAsString()); if ($severity != E_WARNING && $severity != E_NOTICE) { throw $exception; } } }
/** * Executes given extension point, which means it will run * all its registered handlers. * * @param string $extensionPointName * @param object $context */ public static function extensionPoint($extensionPointName, $context = null) { $pluginsEngine = self::getInstance(); try { $definition = $pluginsEngine->getDefinitionForExtensionPoint($extensionPointName); $extensionPoint = Gpf_Plugins_ExtensionPoint::getInstance($extensionPointName, $definition); } catch (Gpf_Exception $e) { Gpf_Log::warning("Extension point {$extensionPointName} not defined (" . $e->getMessage() . ")", "plugins"); return; } $extensionPoint->processHandlers($context); }
private function deleteMailTemplateFromDb() { $dbTemplate = new Gpf_Db_MailTemplate(); $dbTemplate->setAccountId(Gpf_Session::getAuthUser()->getAccountId()); $dbTemplate->setClassName('Pap_Mail_SplitCommissionsMerchantOnSale'); try { $dbTemplate->loadFromData(); } catch (Gpf_DbEngine_NoRowException $e) { Gpf_Log::warning('Mail template Pap_Mail_SplitCommissionsMerchantOnSale was not found during deactivation of split commissions... It should be there.'); return; } $dbTemplate->delete(); }
private function logMessage(Exception $e) { Gpf_Log::warning('Trying to show non-existing banner: '. $e->getMessage()); }
/** * @return array {key == lang code, value == array {key == timeOffset, value == array of recipients}} */ private function getRecipients() { $recipients = array(); $emailValidator = new Gpf_Rpc_Form_Validator_EmailValidator(); foreach ($this->recipients as $email => $recipient) { if (!$emailValidator->validate($email)) { Gpf_Log::warning('Email will not be sent to the address "' . $email . '". Address is not valid.'); continue; } try { $authuser = new Gpf_Db_AuthUser(); $authuser->setNotificationEmail($email); $authuser->loadFromData(array(Gpf_Db_Table_AuthUsers::NOTIFICATION_EMAIL)); $recipients = $this->insertRecipient($recipients, $recipient, $this->getAccountUser($authuser->getId())); } catch (Gpf_Exception $e) { try { $authuser->setUsername($email); $authuser->loadFromUsername(); $recipients = $this->insertRecipient($recipients, $recipient, $this->getAccountUser($authuser->getId())); } catch (Gpf_DbEngine_NoRowException $e) { $recipients = $this->insertRecipient($recipients, $recipient); } } } return $recipients; }
public function authenticate($username, $password) { try { $userId = $this->findUserId($username, $password); $this->user = new Pap_Common_User(); $this->user->setId($userId); $this->user->load(); Gpf_Session::create(new Pap_Tracking_ModuleBase()); $this->computeTimeOffset(); } catch (Gpf_Exception $e) { Gpf_Log::warning($e->getMessage()); $this->user = null; } }
private function interruptIfMemoryFull() { if ($this->checkIfMemoryIsFull(memory_get_usage())) { Gpf_Log::warning('Be carefull, memory was filled up so im interrupting Pap_Mail_Reports_ReportsSendTask task.'); $this->setDone(); $this->interrupt(); } }