protected function log($time, $message, $logLevel, $logGroup, $ip, $file, $line, $type = null) { if ($message == "") { return; } $timeString = strftime("Y-m-d H:i:s", $time); $userId = null; try { $userId = Gpf_Session::getAuthUser()->getUserId(); } catch (Gpf_Exception $e) { } try { $dbLog = new Gpf_Db_Log(); $dbLog->set('groupid', $logGroup); $dbLog->set('level', $logLevel); $dbLog->set('created', $timeString); $dbLog->set('filename', $file); $dbLog->set('message', $message); $dbLog->set('line', $line); $dbLog->set('ip', $ip); $dbLog->set('accountuserid', $userId); $dbLog->set(Gpf_Db_Table_Logs::TYPE, $type); $dbLog->save(); } catch (Exception $e) { Gpf_Log::disableType(Gpf_Log_LoggerDatabase::TYPE); Gpf_Log::error($this->_sys("Database Logger Error. Logging on display: %s", $message)); Gpf_Log::enableAllTypes(); } }
public function setCountriesFromOldConfigFile() { $countriesConfigFile = new CountriesConfigFile(); try { $countries = $countriesConfigFile->read(); } catch (Gpf_Exception $e) { Gpf_Country_Countries::insertCountriesToDB(Gpf_Db_Country::STATUS_ENABLED); return; } if ($countries == '') { Gpf_Country_Countries::insertCountriesToDB(Gpf_Db_Country::STATUS_ENABLED); return; } Gpf_Country_Countries::insertCountriesToDB(Gpf_Db_Country::STATUS_DISABLED); $countriesCodesArray = preg_split('/,/', $countries); foreach ($countriesCodesArray as $countryCode) { $country = new Gpf_Db_Country(); $country->setCountryCode($countryCode); $country->setAccountId(Gpf_Session::getAuthUser()->getAccountId()); try { $country->loadFromData(array(Gpf_Db_Table_Countries::COUNTRY_CODE, Gpf_Db_Table_Countries::ACCOUNTID)); $country->setStatus(Gpf_Db_Country::STATUS_ENABLED); $country->save(); } catch (Gpf_Exception $e) { } } }
public function getPreview(Pap_Common_User $user) { $flag = self::FLAG_MERCHANT_PREVIEW; if (Gpf_Session::getAuthUser()->isAffiliate()) { return $this->getAfiliatePreview($user); } return $this->getDisplayCodeFrom('data2', $user, $flag); }
protected function buildWhere() { parent::buildWhere(); $this->_selectBuilder->where->add(Gpf_Db_Table_Accounts::ID, '=', Gpf_Application::getInstance()->getAccountId()); $this->_selectBuilder->where->add(Gpf_Db_Table_MailTemplates::IS_CUSTOM, '=', Gpf::YES); $this->_selectBuilder->where->add(Gpf_Db_Table_MailTemplates::USERID, '=', Gpf_Session::getAuthUser()->getUserId()); }
/** * Processes contact us form and sends email to merchant * * @service contact_us write * @param $fields */ public function save(Gpf_Rpc_Params $params) { $form = new Gpf_Rpc_Form($params); $subject = $this->getFieldValue($form, "subject"); $text = $this->getFieldValue($form, "text"); Gpf_Session::getAuthUser()->getPapUserId(); $user = new Pap_Common_User(); $user->setPrimaryKeyValue(Gpf_Session::getAuthUser()->getPapUserId()); try { $user->load(); } catch (Gpf_DbEngine_NoRowException $e) { $form->setErrorMessage($this->_("User cannot be found")); return $form; } $mailTemplate = new Pap_Mail_MerchantOnContactUs(); $mailTemplate->setUser($user); $mailTemplate->setEmail($subject, $text); $mailTemplate->addRecipient(Pap_Common_User::getMerchantEmail()); $mailTemplate->setFromEmail($user->getEmail()); $mailTemplate->setFromName($user->getFirstName()." ".$user->getLastName()); $mailTemplate->send(); $form->setInfoMessage($this->_("Email was successfully sent to merchant")); return $form; }
private function getUser() { $user = new Pap_Affiliates_User(); $user->setId(Gpf_Session::getAuthUser()->getPapUserId()); $user->load(); return $user; }
public function getRoleType() { if ($this->roleType == '') { return Gpf_Session::getModule()->getRoleType(); } return $this->roleType; }
private function deleteSplitCommissionsMailTemplate() { $dbTemplate = new Gpf_Db_MailTemplate(); $dbTemplate->setAccountId(Gpf_Session::getAuthUser()->getAccountId()); $dbTemplate->setClassName('Pap_Mail_SplitCommissionsMerchantOnSale'); $dbTemplate->loadFromData(); $dbTemplate->delete(); }
private function getUserCommissionTypes($campaignId = null) { $userId = null; if (Gpf_Session::getAuthUser()->isAffiliate()) { $userId = Gpf_Session::getAuthUser()->getPapUserId(); } return Pap_Db_Table_CommissionTypes::getInstance()->getAllUserCommissionTypes($campaignId, Pap_Common_Constants::TYPE_ACTION, $userId); }
/** * @service channel write * * @param $fields * @return Gpf_Rpc_Action */ public function saveFields(Gpf_Rpc_Params $params) { $action = new Gpf_Rpc_Action($params); $action->setErrorMessage($this->_('Failed to save %s field(s)')); $action->setInfoMessage($this->_('%s field(s) successfully saved')); $fields = new Gpf_Data_RecordSet(); $fields->loadFromArray($action->getParam("fields")); $channels = Pap_Db_Table_Channels::getUserChannels(Gpf_Session::getAuthUser()->getPapUserId()); foreach ($fields as $field) { $isUnique = true; foreach ($channels as $channel) { if ($field->get('value') == $channel->get(Pap_Db_Table_Channels::VALUE)) { $isUnique = false; break; } } if ($isUnique) { $this->saveField($field); } else { $action->setErrorMessage($this->_("Failed to save %s field(s). Data with value '".$field->get('value'). "' already exist. Data must be unique.")); $action->addError(); return $action; } } $action->addOk(); return $action; }
public function loadNoRpc(Gpf_Rpc_Params $params, $useParent = true) { $data = new Gpf_Rpc_Data($params); $signupFormPanel = new Pap_Affiliates_Promo_SignupFormPanel(); $addScript = ''; if ($useParent) { $parentUserId = '<input type="hidden" name="parentuserid"' . ' value="' . Gpf_Session::getAuthUser()->getPapUserId() . '" />'; } else { $parentUserId = '<input type="hidden" name="parentuserid" id="parentuserid" value="" />'; $scriptUrl = Gpf_Paths::getInstance()->getFullScriptsUrl().'salejs.php'; $addScript = '<script id="pap_x2s6df8d" src="'.$scriptUrl.'" type="text/javascript"> </script> <script type="text/javascript"> PostAffTracker.writeAffiliateToCustomField(\'parentuserid\'); </script>'; } if ($signupFormPanel->containsId("parentuserid")) { $signupFormPanel->add($parentUserId, "parentuserid"); } else { $signupFormPanel->addWidget($parentUserId, "parentuserid"); } $signupFormPanelHtml = '<form action="' . self::getSignupScriptUrl($useParent) . '" method="post">' . $signupFormPanel->render() . '</form>' . $addScript; $data->setValue("formSource", $signupFormPanelHtml); $data->setValue("formPreview", $signupFormPanelHtml); return $data; }
public function getNumberOfSubaffiliates($userid = null) { $result = new Gpf_Data_RecordSet(); $selectBuilder = new Gpf_SqlBuilder_SelectBuilder(); $selectBuilder->select->add('COUNT(u.userid)', 'amount'); $selectBuilder->from->add(Pap_Db_Table_Users::getName(), "u"); $selectBuilder->from->addInnerJoin(Gpf_Db_Table_Users::getName(), "gu", "u.accountuserid = gu.accountuserid"); $selectBuilder->from->addInnerJoin(Gpf_Db_Table_AuthUsers::getName(), "au", "gu.authid = au.authid"); $selectBuilder->where->add('u.deleted', '=', Gpf::NO); if ($userid === null) { $selectBuilder->where->add('u.parentuserid', '=', Gpf_Session::getAuthUser()->getPapUserId()); } else { $selectBuilder->where->add('u.parentuserid', '=', $userid); } $selectBuilder->where->add('gu.rstatus', '<>', 'D'); if ($this->params->isDateFromDefined()) { $selectBuilder->where->add('u.' . Pap_Stats_Table::DATEINSERTED, '>=', $this->params->getDateFrom()->toDateTime()); } if ($this->params->isDateToDefined()) { $selectBuilder->where->add('u.' . Pap_Stats_Table::DATEINSERTED, '<=', $this->params->getDateTo()->toDateTime()); } $selectBuilder->limit->set(0, 1); $result->load($selectBuilder); if($result->getSize() == 0) { return 0; } foreach($result as $record) { return $record->get('amount'); } }
/** * Load role privileges * * @service * @anonym * @param Gpf_Rpc_Params $params * @return Gpf_Data_RecordSet */ public function loadRolePrivileges(Gpf_Rpc_Params $params) { if (!Gpf_Session::getAuthUser()->hasPrivilege(Gpf_Privileges::ROLE, Gpf_Privileges::P_READ) && !Gpf_Session::getAuthUser()->hasPrivilege(Gpf_Privileges::ROLE, Pap_Privileges::P_READ_OWN)) { throw new Gpf_Rpc_PermissionDeniedException('Gpf_Role_RolePrivilegesForm', 'loadRolePrivileges'); } $role = new Gpf_Db_Role(); $role->setId($params->get('roleid')); $role->load(); $defaultPrivileges = Gpf_Application::getInstance()->getDefaultPrivilegesByRoleType($role->getRoleType()); $result = new Gpf_Data_RecordSet(); $result->addColumn('object'); $result->addColumn('objectName'); $result->addColumn('possiblePrivileges'); $result->addColumn('activePrivileges'); $rolePrivileges = Gpf_Privileges::loadPrivileges($role->getId()); foreach ($defaultPrivileges->getDefaultPrivileges() as $object => $privileges) { $record = new Gpf_Data_Record($result->getHeader()); $record->add('object', $object); $record->add('objectName', ucfirst(str_replace('_', ' ', strtolower($object)))); $allTypes = $defaultPrivileges->getObjectToTypeRelation(); $record->add('possiblePrivileges', implode(',', $allTypes[$object])); if (array_key_exists($object, $rolePrivileges)) { $record->add('activePrivileges', implode(',', array_keys($rolePrivileges[$object]))); } else { $record->add('activePrivileges', ''); } $result->addRecord($record); } $result->sort('objectName'); return $result; }
protected function loadItems($userId) { $maxTiers = Gpf_Settings::get(Pap_Settings::TIERS_VISIBLE_TO_AFFILIATE); if ($maxTiers == -1) { return parent::loadItems($userId); } $currentUserId = Gpf_Session::getAuthUser()->getPapUserId(); $numberOfTiers = -1; if($userId != '') { try { $numberOfTiers = $this->getNumberOfTiersToAncestor($userId, $currentUserId); } catch (Gpf_Exception $e) { } } if ($userId == '' && $maxTiers == 0) { return new Gpf_Data_RecordSet(); } if ($numberOfTiers >= $maxTiers-2) { $lastTier = true; } else { $lastTier = false; } return parent::loadItems($userId, $lastTier); }
public function __construct($accountId, $authToken = '', $roleType = '') { parent::__construct($accountId, $roleType); $this->authToken = $authToken; if ($authToken == '') { $this->authToken = Gpf_Session::getAuthUser()->getRemeberMeToken(); } }
/** * constructs context instance * It creates debug logger if there are parameters for it * */ protected function __construct() { Gpf_Session::getAuthUser()->setAccountId(Gpf_Db_Account::DEFAULT_ACCOUNT_ID); $this->initDebugLogger(); $cookieObj = new Pap_Tracking_Cookie(); $cookieObj->setLogger($this->getLogger()); }
private function writeFileData() { $accountId = Gpf_Session::getAuthUser()->getAccountId(); $settings = new Gpf_File_Settings($accountId); foreach ($settings->getAll() as $name => $value) { $this->file->writeArray(array($name, $value)); } }
/** * @return Gpf_DbEngine_Row */ protected function createEmptyRow(Gpf_Rpc_Params $params) { $row = new Gpf_Db_Currency(); $row->set(Gpf_Db_Table_Accounts::ID, Gpf_Session::getAuthUser()->getAccountId()); $row->set(Gpf_Db_Table_Currencies::NAME, $this->_("NEW")); $row->set(Gpf_Db_Table_Currencies::SYMBOL, "?"); $row->set(Gpf_Db_Table_Currencies::EXCHANGERATE, "1"); return $row; }
public function __construct($formId, $accountId = null) { $this->formId = $formId; if ($accountId != null) { $this->accountId = $accountId; } else { $this->accountId = Gpf_Session::getAuthUser()->getAccountId(); } }
/** * @param String $channelValue */ private function setChannel($channelValue) { $channel = new Pap_Db_Channel(); $channel->setValue($channelValue); $channel->setPapUserId(Gpf_Session::getAuthUser()->getPapUserId()); try { $channel->loadFromData(array(Pap_Db_Table_Channels::VALUE, Pap_Db_Table_Channels::USER_ID)); $this->banner->setChannel($channel); } catch (Gpf_Exception $e) { } }
private function sendNotificationToMerchant(Pap_Db_DirectLinkUrl $directLink) { $mail = new Pap_Mail_MerchantNewDirectLinkNotification($directLink); $mail->loadUser(Gpf_Session::getAuthUser()->getPapUserId()); $mail->addRecipient(Pap_Common_User::getMerchantEmail()); try { $mail->send(); } catch (Exception $e) { Gpf_Log::error($this->_('Error sending new direct link notification email to merchant: %s', $e->getMessage())); } }
/** * @return Gpf_DbEngine_Row */ protected function createEmptyRow(Gpf_Rpc_Params $params) { $row = new Pap_Db_Channel(); $userId = Gpf_Session::getAuthUser()->getPapUserId(); $row->set(Pap_Db_Table_Channels::USER_ID, $userId); $row->set(Pap_Db_Table_Channels::NAME, $this->_("Channel name")); $row->set(Pap_Db_Table_Channels::VALUE, $this->generateDefaultValue($userId)); return $row; }
public function getGeneralAffiliateLinkNoRpc($affiliateId = null) { if ($affiliateId == null) { $affiliateId = Gpf_Session::getAuthUser()->getUserId(); } $affiliate = new Pap_Common_User(); $affiliate->setId($affiliateId); $affiliate->load(); $mainSiteUrl = Gpf_Settings::get(Pap_Settings::MAIN_SITE_URL); return Pap_Tracking_ClickTracker::getInstance()->getClickUrl(null, $affiliate, $mainSiteUrl); }
public function __construct($filterArray = NULL) { $this->initOperators(); if ($filterArray != NULL) { $this->code = $filterArray[self::FILTER_CODE]; $this->operator = $this->getOperator($filterArray[self::FILTER_OPERATOR]); $this->value = trim($filterArray[self::FILTER_VALUE]); $this->timeOffset = Gpf_Session::getInstance()->getTimeOffset(); } }
private function getUserCommissionTypes($campaignId = null) { $userId = null; if (Gpf_Session::getAuthUser()->isAffiliate()) { $userId = Gpf_Session::getAuthUser()->getPapUserId(); } if (!array_key_exists($campaignId.'_'.$userId, self::$userCommissionTypes)) { self::$userCommissionTypes[$campaignId.'_'.$userId] = Pap_Db_Table_CommissionTypes::getInstance()->getAllUserCommissionTypes($campaignId, Pap_Common_Constants::TYPE_ACTION, $userId); } return self::$userCommissionTypes[$campaignId.'_'.$userId]; }
/** * @return Gpf_SqlBuilder_SelectBuilder */ protected function createSelectBuilder() { $selectBuilder = parent::createSelectBuilder(); if ($this->params->get('userid') != '') { $selectBuilder->where->add(Pap_Db_Table_Channels::USER_ID, '=', $this->params->get('userid')); } else { $selectBuilder->where->add(Pap_Db_Table_Channels::USER_ID, '=', Gpf_Session::getAuthUser()->getPapUserId()); } return $selectBuilder; }
public function getPreview(Pap_Common_User $user) { $this->parseRotatorBannerDescription(); if($this->rotatedBanners!=null){ if(Gpf_Session::getAuthUser()->isAffiliate()) { return $this->getAffiliatePreview($user); } return $this->getMerchantPreview($user); } return ''; }
protected function buildFrom() { $this->_selectBuilder->from->add(Gpf_Db_Table_ActiveViews::getName(), 'av'); $this->_selectBuilder->from->addLeftJoin(Gpf_Db_Table_Views::getName(), 'v', 'av.'.Gpf_Db_Table_ActiveViews::ACTIVEVIEWID.' = v.'.Gpf_Db_Table_Views::ID); $this->_selectBuilder->where->add('av.'.Gpf_Db_Table_ActiveViews::ACCOUNTUSERID, '=', Gpf_Session::getAuthUser()->getUserData()->get(Gpf_Db_Table_Users::ID)); $whereCond = new Gpf_SqlBuilder_CompoundWhereCondition(); $whereCond->add('v.'.Gpf_Db_Table_Views::ACCOUNTUSERID, '!=', '', 'OR'); $whereCond->add('av.'.Gpf_Db_Table_ActiveViews::ACTIVEVIEWID, '=', Gpf_View_ViewService::DEFAULT_VIEW_ID, 'OR'); $this->_selectBuilder->where->addCondition($whereCond); }
/** * returns instance of Gpf_Settings class * * @return Pap_Tracking_DirectLinksBase */ public static function getInstance($accountSettings = true) { if ($accountSettings) { $accountId = Gpf_Session::getAuthUser()->getAccountId(); } else { $accountId = null; } if (!array_key_exists($accountId, self::$instance)) { self::$instance[$accountId] = new Pap_Tracking_DirectLinksBase($accountId); } return self::$instance[$accountId]; }
public function regenerateLanguageCacheFiles() { //load langage $dbLang = new Gpf_Db_Language(); $dbLang->setAccountId(Gpf_Session::getInstance()->getAuthUser()->getAccountId()); $dbLang->setCode($this->languageCode); $dbLang->setId($dbLang->generateId()); $dbLang->load(); $lang = new Gpf_Lang_CsvLanguage(); $lang->loadFromCsvFile(new Gpf_Io_Csv_Reader(Gpf_Lang_CsvLanguage::getAccountCsvFileName($this->languageCode))); $lang->exportAccountCache(); }