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());
 }
	public function __construct() {
		$this->codeName = self::CODE_NAME;
		$this->name = $this->_('Commission Groups');
		$this->description = $this->_('Commission groups allow you to set different commissions for different users for the same campaign.<br/><a href="%s" target="_blank">More help in our Knowledge Base</a>',Gpf_Application::getKnowledgeHelpUrl('343724-Commission-groups'));
		$this->version = '1.0.0';
		$this->pluginType = self::PLUGIN_TYPE_FEATURE;
	}
 /**
  * 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;
 }
 /**
  * @service report_problem write
  * 
  * @param Gpf_Rpc_Params $params
  * @return Gpf_Rpc_Form
  */
 public function report(Gpf_Rpc_Params $params) {
     $form = new Gpf_Rpc_Form($params);
     
     $subject = 'PAP4: '.$form->getFieldValue('subject');
     
     $message = 'License: '.$form->getFieldValue('licenseId').'<br>'.
                'Product: <b>'.Gpf_Settings::get(Pap_Settings::BRANDING_TEXT_POST_AFFILIATE_PRO).' '.Gpf_Settings::get(Gpf_Settings_Gpf::VARIATION).'</b><br>'.
                'Version: <b>'.Gpf_Application::getInstance()->getVersion().'</b><br>'.
                'Url: <a href="'.Gpf_Paths::getInstance()->getFullBaseServerUrl().'">'.Gpf_Paths::getInstance()->getFullBaseServerUrl().'</a><br>'.
                '-------------------------------------------------------------------------------<br>'.
                $form->getFieldValue('message');
     
     $mail = new Gpf_Db_Mail();
     $mail->setSubject($subject);
     $mail->setHtmlBody($message);
     $mail->setFromMail($form->getFieldValue('email'));
     $mail->setRecipients("*****@*****.**");
     
     try {
         $mail->insert();
         $mail->scheduleNow(true);
         $form->setInfoMessage($this->_("Email sent"));
     } catch (Exception $e) {
         $form->setErrorMessage($this->_("Error while sending mail"));
     }
     return $form;
 }
 /**
  *
  * @return Gpf_Rpc_Form
  */
 public function getDescription()
 {
     $data = new Gpf_Rpc_Form();
     $data->setField(self::VERSION, Gpf_Application::getInstance()->getVersion());
     $data->setField(self::SCENARION_NAME, $this->name);
     return $data;
 }
 function __construct()
 {
     parent::__construct();
     $this->setApplication(Gpf_Application::getInstance()->getCode());
     $date = new Gpf_DateTime();
     $this->setDateinserted($date->toDateTime());
 }
 private function throwException()
 {
     if ($this->message == "") {
         throw new Gpf_DbEngine_Row_ConstraintException($this->columnName, $this->columnName . $this->_(' has not valid Smarty Syntax. More information: ') . Gpf_Application::getKnowledgeHelpUrl('079741-Invalid-Smarty-syntax'));
     }
     throw new Gpf_DbEngine_Row_ConstraintException($this->columnName, $this->message);
 }
 private function output($message)
 {
     $template = new Gpf_Templates_Template('quick_task.stpl');
     $template->assign('message', $message);
     $template->assign('title', Gpf_Application::getInstance()->getName() . ' - ' . $this->_('Merchant'));
     echo $template->getHTML();
 }
 public function isApplicationCodeValid()
 {
     if (strlen($this->applicationCode) <= 0) {
         return true;
     }
     return $this->applicationCode == Gpf_Application::getInstance()->getCode();
 }
 public static function create(Gpf_Application $application)
 {
     setlocale(LC_ALL, 'en.UTF-8');
     self::$instance = $application;
     self::$instance->registerRolePrivileges();
     self::$instance->initLogger();
     self::$instance->addSmartyPluginsDir();
     $timezone = Gpf_Settings_Gpf::DEFAULT_TIMEZONE;
     try {
         $timezone = Gpf_Settings::get(Gpf_Settings_Gpf::TIMEZONE_NAME);
     } catch (Gpf_Exception $e) {
         Gpf_Log::error('Unable to load timezone: %s - using default one.', $e->getMessage());
     }
     if (false === @date_default_timezone_set($timezone)) {
         Gpf_Log::error('Unable to set timezone %s:', $timezone);
     }
 }
 /**
  * @anonym 
  * @param Gpf_Rpc_Params $params
  * @service
  * @return Gpf_Rpc_Form
  */
 public function load(Gpf_Rpc_Params $params)
 {
     $form = new Gpf_Rpc_Form($params);
     $form->setField(self::LICENSE_AGREE_NAME, '');
     $form->setField(self::LICENSE_ID_NAME, '');
     $form->setField(self::VERSION_NAME, Gpf_Application::getInstance()->getVersion());
     return $form;
 }
    public function __construct() {
        $this->codeName = 'PapCore';
        $this->name = 'Pap Core Plugin';
        $this->description = 'Pap Core functionality.';
        $this->version = Gpf_Application::getInstance()->getVersion();
        $this->pluginType = self::PLUGIN_TYPE_SYSTEM;

        $this->initDefines();
    }
 /**
  * Import selected language into database and
  * create language cache file in account directory
  */
 protected function importLanguage($code)
 {
     $fileName = Gpf_Paths::getInstance()->getLanguageInstallDirectory() . Gpf_Application::getInstance()->getCode() . '_' . $code . '.csv';
     if (!Gpf_Io_File::isFileExists($fileName)) {
         return;
     }
     $importer = new Gpf_Lang_ImportLanguageTask($fileName, $code, false);
     $importer->run();
 }
    public function __construct() {
        $this->codeName = self::CODE;
        $this->name = $this->_('Performance rewards');
        $this->description = $this->_('Performance rewards is a powerful featuure that allows you to reward your affiliates for their performance.<br/><a href="%s" target="_blank">More help in our Knowledge Base</a>', Gpf_Application::getKnowledgeHelpUrl('466568-Performance-rewards'));
        $this->version = '1.0.0';
        $this->pluginType = self::PLUGIN_TYPE_FEATURE;

        $this->addImplementation('PostAffiliate.Transaction.afterSave', 'Pap_Features_PerformanceRewards_Main', 'checkRules');
    }
    public function __construct() {
        $this->codeName =  'MultipleMerchants';
        $this->name = $this->_('Multiple merchants');
        $this->description = $this->_('Multiple merchants feature allows you to have more merchants (administrators) who can access %s. All admins will be able to see same campaigns! In case you are looking for affiliate network functionality, where each merchant can administer own campaigns, please visit our home page and look for Post Affiliate Network section.<br/><a href="%s" target="_blank">More help in our Knowledge Base</a>', Gpf_Settings::get(Pap_Settings::BRANDING_TEXT_POST_AFFILIATE_PRO), Gpf_Application::getKnowledgeHelpUrl('732104-Multiple-merchants'));
        $this->version = '1.0.0';
        $this->pluginType = self::PLUGIN_TYPE_FEATURE;

        $this->addImplementation('PostAffiliate.merchant.menu', 'Pap_Features_MultipleMerchants_Main', 'addToMenu');
    }
 private function getFilename($server = true)
 {
     $ext = 's';
     if (!$server) {
         $ext = 'c';
     }
     $application = Gpf_Application::getInstance()->getCode();
     return $this->directory . $application . '_' . $this->languageCode . ".{$ext}.php";
 }
 /**
  * Unset on all languages status default language
  */
 public function unsetDefaultLanguage($defaultLanguageId)
 {
     $sql = new Gpf_SqlBuilder_UpdateBuilder();
     $sql->from->add(self::getName());
     $sql->where->add(Gpf_Db_Table_Accounts::ID, '=', Gpf_Application::getInstance()->getAccountId());
     $sql->where->add(Gpf_Db_Table_Languages::ID, '<>', $defaultLanguageId);
     $sql->set->add(self::IS_DEFAULT, Gpf::NO);
     $sql->execute();
 }
	public function __construct() {
		$this->codeName = 'HoverBanner';
		$this->name = $this->_('Hover Banner');
		$this->description = $this->_('Enables hover (DIV on page) banner').
		'<br><a href="' . Gpf_Application::getKnowledgeHelpUrl('247495-Hover-Banner') . '" target="_blank">'.$this->_('More help in our Knowledge Base').'</a>';
		$this->version = '1.0.0';
		$this->pluginType = self::PLUGIN_TYPE_FEATURE;

		$this->addImplementation('PostAffiliate.BannerFactory.getBannerObjectFromType', 'Pap_Features_HoverBanner_Main', 'getBanner');
	}
	public function __construct() {
		$this->codeName =  'AffiliateCampaigns';
		$this->name = $this->_('Affiliate campaigns');
		$this->description = $this->_('Enable variable {$affiliatecampaigns} in email templates. This variable will contain associative array of all user campaigns. <a href="%s" target="_blank">%s</a>', Gpf_Application::getKnowledgeHelpUrl('047476-Affiliate-Campaigns-Plugin'), $this->_('Read more in our Knowledge Base'));
		$this->version = '1.0.0';
		$this->addRequirement('PapCore', '4.2.5.0');

		$this->addImplementation('PostAffiliate.UserMail.initTemplateVariables', 'AffiliateCampaigns_Main', 'initCampaignsVariable');
		$this->addImplementation('PostAffiliate.UserMail.setVariableValues', 'AffiliateCampaigns_Main', 'setCampaignsVariable');
	}
 /**
  * Return list of all system mail templates
  * @service mail_template read
  */
 public function getAllSystemTemplates()
 {
     $sql = new Gpf_SqlBuilder_SelectBuilder();
     $sql->select->add(Gpf_Db_Table_MailTemplates::ID);
     $sql->select->add(Gpf_Db_Table_MailTemplates::TEMPLATE_NAME);
     $sql->from->add(Gpf_Db_Table_MailTemplates::getName());
     $sql->where->add(Gpf_Db_Table_Accounts::ID, '=', Gpf_Application::getInstance()->getAccountId());
     $sql->where->add(Gpf_Db_Table_MailTemplates::IS_CUSTOM, '=', Gpf::NO);
     return $sql->getAllRows();
 }
    public function __construct() {
        $this->codeName = 'CpmCommission';
        $this->name = $this->_('CPM commissions');
        $this->description = $this->_('CPM (cost per mille) commissions are a special type of commissions that are rewarded for 1000 impressions, which means for displaying your banners 1000 times.<br/><a href="%s" target="_blank">More help in our Knowledge Base</a>', Gpf_Application::getKnowledgeHelpUrl('875056-CPM-commissions'));
        $this->version = '1.0.0';
        $this->pluginType = self::PLUGIN_TYPE_FEATURE;

        $this->addImplementation('Tracker.impression.afterSave', 'Pap_Features_CpmCommission_Main', 'saveCommission', 5);
        $this->addImplementation('PostAffiliate.CampaignForm.insertDefaultCommissionTypes',  'Pap_Features_CpmCommission_Main', 'insertDefaultCommissionType');
    }
 public function __construct() {
     $this->codeName = 'SiteReplication';
     $this->name = $this->_('Site Replication');
     $this->description = $this->_('Site Replication is a special type of banner that replicates pages created by you so they are specific for affiliate. They can contain variables like affiliate refid, name, ... .%s<br/>', '<a href="'.Gpf_Application::getKnowledgeHelpUrl('856887-Site-Replication').'" target="_blank">'.$this->_('More help in our Knowledge Base').'</a>');
     $this->version = '1.0.0';
     $this->pluginType = self::PLUGIN_TYPE_FEATURE;
     
     $this->addImplementation('PostAffiliate.BannerFactory.getBannerObjectFromType', 'Pap_Features_SiteReplication_Config', 'getBanner');
     $this->addImplementation('PostAffiliate.BannerForm.load', 'Pap_Features_SiteReplication_Config', 'load');
 }
 protected function createAuthUser()
 {
     if (!$this->existsVar(self::AUTH_USER)) {
         $authUser = Gpf::newObj(Gpf_Application::getInstance()->getAuthClass());
         $this->authUser = $authUser->createAnonym();
         $this->save($this->authUser);
     } else {
         $this->authUser = $this->getVar(self::AUTH_USER);
     }
 }
 protected function checkAndSavePayoutInvoice(Gpf_Rpc_Form $form, $templateSource, $settingName) {
 	$template = new Gpf_Templates_Template($templateSource, '', Gpf_Templates_Template::FETCH_TEXT);
     if ($template->isValid()) {
     	Gpf_Settings::set($settingName, $templateSource);
         $form->setInfoMessage($this->getInfoMessage());
         return;
     }
     $form->setErrorMessage($this->_('Invalid Smarty syntax. More information: ') .
     Gpf_Application::getKnowledgeHelpUrl(Pap_Common_Constants::SMARTY_SYNTAX_URL));
 }
    public function __construct() {
        $this->codeName = 'CompressedCommissionPlacementModel';
        $this->name = $this->_('Compressed commission placement model');
        $this->description = $this->_('This feature applies compressed commission placement model.<br/><a href="%s" target="_blank">More help in our Knowledge Base</a>',Gpf_Application::getKnowledgeHelpUrl('285838-Compressed-commission-placement-model'));
        $this->version = '1.0.0';
        $this->pluginType = self::PLUGIN_TYPE_FEATURE;

        $this->addImplementation('PostAffiliate.merchant.menu', 'Pap_Features_CompressedCommissionPlacementModel_Main', 'addToMenu');
        $this->addImplementation('Core.defineSettings', 'Pap_Features_CompressedCommissionPlacementModel_Main', 'initSettings');
    }
 public function __construct() {
     $this->codeName = 'ZipBanner';
     $this->name = $this->_('Zip Banner');
     $this->description = $this->_('Zip banner is a special type of banner that allows you to create zip files with banner images, templates, ... You can use user variables that are raplaced with properiate values. %s<br/>', '<a href="' . Gpf_Application::getKnowledgeHelpUrl('968931-Zip-Banner') . '" target="_blank">' . $this->_('More help in our Knowledge Base') . '</a>');
     $this->version = '1.0.0';
     $this->pluginType = self::PLUGIN_TYPE_FEATURE;
     
     $this->addImplementation('PostAffiliate.BannerFactory.getBannerObjectFromType', 'Pap_Features_ZipBanner_Config', 'getBanner');
     $this->addImplementation('PostAffiliate.BannerForm.load', 'Pap_Features_ZipBanner_Config', 'load');
 }
    public function __construct() {
        $this->codeName = 'BrandingFree';
        $this->name = $this->_('Branding free');
        $this->description = $this->_('Branding Free is a special feature that allows you to change the links in the footer of panels and signup form from "Powered by %s" to your own text and link.<br/><a href="%s" target="_blank">More help in our Knowledge Base</a>', Gpf_Settings::get(Pap_Settings::BRANDING_TEXT_POST_AFFILIATE_PRO), Gpf_Application::getKnowledgeHelpUrl('522705-Branding-Free'));

        $this->version = '1.0.0';
        $this->pluginType = self::PLUGIN_TYPE_FEATURE;
        
        $this->addImplementation('PostAffiliate.AffiliateGeneralSettingsForm.load', 'Pap_Features_BrandingFree_Config', 'load');
        $this->addImplementation('PostAffiliate.AffiliateGeneralSettingsForm.save', 'Pap_Features_BrandingFree_Config', 'save');
    }
    public function __construct() {
        $this->codeName =  'AutoResponsePlus';
        $this->name = $this->_('Auto response plus');
        $this->description = $this->_('Register your new affiliates automatically to AutoResponsePlus<br/><a href="%s" target="_blank">More help in our Knowledge Base</a>', Gpf_Application::getKnowledgeHelpUrl('798014-Auto-response-plus-plugin-configuration'));
        $this->configurationClassName = 'AutoResponsePlus_Config';
        $this->version = '1.0.1';
        $this->addRequirement('PapCore', '4.1.30.0');

        $this->addImplementation('Core.defineSettings', 'AutoResponsePlus_Main', 'initSettings');
        $this->addImplementation('PostAffiliate.signup.after', 'AutoResponsePlus_Main', 'sendMail');
    }
    public function __construct() {
        $this->codeName = 'RebrandPdfBanner';
        $this->name = $this->_('RebrandPdf Banner');
        $this->description = $this->_('It alows you to create a special type of promo materials - rebrandable e-books. You can create your PDF e-book only once and upload it to %s.Your affiliates will automatically get their own re-branded copy of the book, with their name, affiliate links, texts, etc. There is no need to run any Windows program for branding, they will simply download rebranded PDF. All the rebranding is made automatically in the background.<br/><a href="%s" target="_blank">%s</a>', Gpf_Settings::get(Pap_Settings::BRANDING_TEXT_POST_AFFILIATE_PRO), Gpf_Application::getKnowledgeHelpUrl('443650-Rebrand-PDF-Banner') ,$this->_('Read more in our Knowledge Base'));
        $this->version = '1.0.0';
        $this->pluginType = self::PLUGIN_TYPE_FEATURE;

        $this->addImplementation('PostAffiliate.BannerFactory.getBannerObjectFromType'
        , 'Pap_Features_RebrandPdfBanner_Config', 'getBanner');
        $this->addImplementation(Pap_Tracking_BannerViewer::EXT_POINT_NAME,
        'Pap_Features_RebrandPdfBanner_Config' , 'processRequest');
    }
 public function __construct() {
     $this->codeName = 'CampaignsCategories';
     $this->name = $this->_('Campaigns categories');
     $this->description = $this->_('Campaigns categories allow you to categorize your campaigns to tree-like structure. <br/><a href="%s" target="_blank">More help in our Knowledge Base</a>',Gpf_Application::getKnowledgeHelpUrl('268879-Campaigns-categories'));
     $this->version = '1.0.0';
     $this->pluginType = self::PLUGIN_TYPE_FEATURE;
     
     $this->addImplementation('PostAffiliate.merchant.menu',
                              'Pap_Features_CampaignsCategories_Main', 'addToMenu');
     $this->addImplementation('CampaignGrid.modifyWhere',
                              'Pap_Features_CampaignsCategories_Main', 'addCategoryFilterToMerchantCategoryList');
 }