/**
  * @return Gpf_Db_Table_UserAttributes
  */
 public static function getInstance()
 {
     if (self::$instance === null) {
         self::$instance = new self();
     }
     return self::$instance;
 }
	/**
	 * @param String_type $attributeName
	 * @param String $defaultValue
	 * @return String
	 */
	private function getSettingWithDefaultValue($attributeName, $defaultValue) {
		try {
			return Gpf_Db_Table_UserAttributes::getSetting($attributeName, $this->user->getAccountUserId());
		} catch (Gpf_DbEngine_NoRowException $e) {
		}
		return $defaultValue;
	}
 private function updateThemeExistingAffiliates($themeId) {
     $update = new Gpf_SqlBuilder_UpdateBuilder();
     $update->from->add(Gpf_Db_Table_UserAttributes::getName(), 'ua');
     $update->from->addInnerJoin(Pap_Db_Table_Users::getName(), 'pu', 'ua.'.Gpf_Db_Table_UserAttributes::ACCOUNT_USER_ID.'=pu.'.Pap_Db_Table_Users::ACCOUNTUSERID);
     $update->set->add('ua.'.Gpf_Db_Table_UserAttributes::VALUE, $themeId);
     $update->where->add('ua.'.Gpf_Db_Table_UserAttributes::NAME, '=', Gpf_Auth_User::THEME_ATTRIBUTE_NAME);
     $update->where->add('pu.'.Pap_Db_Table_Users::TYPE, '=', Pap_Application::ROLETYPE_AFFILIATE);
     $update->update();
 }
    /**
     * @service affiliate_email_notification write
     * @param $fields
     */
    public function save(Gpf_Rpc_Params $params) {
        $form = new Gpf_Rpc_Form($params);

       	Gpf_Db_Table_UserAttributes::setSetting("aff_notification_on_new_sale", $this->getFieldValue($form, "aff_notification_on_new_sale"), Gpf_Session::getAuthUser()->getAccountUserId());
       	Gpf_Db_Table_UserAttributes::setSetting("aff_notification_on_change_comm_status", $this->getFieldValue($form, "aff_notification_on_change_comm_status"), Gpf_Session::getAuthUser()->getAccountUserId());
       	Gpf_Db_Table_UserAttributes::setSetting("aff_notification_on_subaff_signup", $this->getFieldValue($form, "aff_notification_on_subaff_signup"), Gpf_Session::getAuthUser()->getAccountUserId());
       	Gpf_Db_Table_UserAttributes::setSetting("aff_notification_on_subaff_sale", $this->getFieldValue($form, "aff_notification_on_subaff_sale"), Gpf_Session::getAuthUser()->getAccountUserId());
       	Gpf_Db_Table_UserAttributes::setSetting("aff_notification_on_direct_link_enabled", $this->getFieldValue($form, "aff_notification_on_direct_link_enabled"), Gpf_Session::getAuthUser()->getAccountUserId());
       	Gpf_Db_Table_UserAttributes::setSetting("aff_notification_daily_report", $this->getFieldValue($form, "aff_notification_daily_report"), Gpf_Session::getAuthUser()->getAccountUserId());
       	Gpf_Db_Table_UserAttributes::setSetting("aff_notification_weekly_report", $this->getFieldValue($form, "aff_notification_weekly_report"), Gpf_Session::getAuthUser()->getAccountUserId());
       	Gpf_Db_Table_UserAttributes::setSetting("aff_notification_monthly_report", $this->getFieldValue($form, "aff_notification_monthly_report"), Gpf_Session::getAuthUser()->getAccountUserId());

        $form->setInfoMessage($this->_("Email notifications saved"));
        return $form;
    }
 /**
  * returns recordset of given attribute values for given array of users
  *
  * @param unknown_type $settingsNames
  * @param unknown_type $accountUserIds
  */
 public static function getSettingsForGroupOfUsers($settingsNames, $accountUserIds)
 {
     $select = new Gpf_SqlBuilder_SelectBuilder();
     $select->select->add(Gpf_Db_Table_UserAttributes::ACCOUNT_USER_ID, "accountuserid");
     $select->select->add(Gpf_Db_Table_UserAttributes::NAME, "name");
     $select->select->add(Gpf_Db_Table_UserAttributes::VALUE, "value");
     $select->from->add(Gpf_Db_Table_UserAttributes::getName());
     $select->where->add(Gpf_Db_Table_UserAttributes::NAME, "IN", $settingsNames);
     $select->where->add(Gpf_Db_Table_UserAttributes::ACCOUNT_USER_ID, "IN", $accountUserIds);
     $recordSet = $select->getAllRows();
     $results = array();
     foreach ($recordSet as $record) {
         $results[$record->get('accountuserid')][$record->get('name')] = $record->get('value');
     }
     return $results;
 }
	protected function modifySelect(Gpf_SqlBuilder_SelectBuilder $selectBuilder) {
		$condition = new Gpf_SqlBuilder_CompoundWhereCondition();
		$condition->add('accountUsers.'.Gpf_Db_Table_Users::ID, '=',
    	   'ua.'.Gpf_Db_Table_UserAttributes::ACCOUNT_USER_ID, 'AND', false);
		$condition->add('ua.'.Gpf_Db_Table_UserAttributes::NAME, '=',
           'apply_vat_invoicing');
		$selectBuilder->from->addLeftJoin(Gpf_Db_Table_UserAttributes::getName(), 'ua',
		  $condition->toString());
		 
		if ($this->getVat() == Gpf::NO) {
			$condition = new Gpf_SqlBuilder_CompoundWhereCondition();
			$condition->add('ua.'.Gpf_Db_Table_UserAttributes::VALUE, '=', Gpf::NO, 'OR');
			$condition->add('ua.'.Gpf_Db_Table_UserAttributes::VALUE, '=', null, 'OR');
			$selectBuilder->where->addCondition($condition);
			return;
		}
		$selectBuilder->where->add('ua.'.Gpf_Db_Table_UserAttributes::VALUE, '=', Gpf::YES);
	}
    /**
     * @service affiliate_email_notification read
     * @param $fields
     */
    public function load(Gpf_Rpc_Params $params) {
        $form = new Gpf_Rpc_Form($params);

        $this->attribute = Gpf_Db_Table_UserAttributes::getInstance();
        $this->attribute->loadAttributes(Gpf_Session::getAuthUser()->getAccountUserId());

        $data = new Gpf_Db_UserAttribute();
        $data->setAccountUserId(Gpf_Session::getAuthUser()->getUserId());
        $data->setName('RecipientsList');
        try {
            $data->loadFromData(array(Gpf_Db_Table_UserAttributes::ACCOUNT_USER_ID,Gpf_Db_Table_UserAttributes::NAME));
            $form->setField("recipients",$data->getValue());

        } catch(Gpf_DbEngine_NoRowException $e) {
            $form->setField("recipients","");
        }
        $form->setField('affEmail',Gpf_Session::getAuthUser()->getUsername());

       	return $form;
    }
    private function loadPayoutSettings(Gpf_Rpc_Form $form) {
        $form->setField(Pap_Settings::SUPPORT_VAT_SETTING_NAME,
        Gpf_Settings::get(Pap_Settings::SUPPORT_VAT_SETTING_NAME));

        $form->setField("applyVatInvoicing", $this->attribute->getAttributeWithDefaultValue("apply_vat_invoicing", ""));

        $defaultVatPercentage = Gpf_Settings::get(Pap_Settings::VAT_PERCENTAGE_SETTING_NAME);
        $vatPercentage = $this->attribute->getAttributeWithDefaultValue(Pap_Settings::VAT_PERCENTAGE_SETTING_NAME, "");
        if($vatPercentage == '' || $vatPercentage == 0) {
            $vatPercentage = $defaultVatPercentage;
        }
        $form->setField("vatPercentage", $vatPercentage);

        $form->setField("vatNumber", $this->attribute->getAttributeWithDefaultValue("vat_number", ""));
        $form->setField("amountOfRegCapital", $this->attribute->getAttributeWithDefaultValue("amount_of_reg_capital", ""));
        $form->setField("regNumber", $this->attribute->getAttributeWithDefaultValue("reg_number", ""));
        $form->setField("currency", $this->attribute->getAttributeWithDefaultValue("currency_id", ""));

        $form->setField("minimumPayoutOptions", Gpf_Settings::get(Pap_Settings::PAYOUTS_PAYOUT_OPTIONS_SETTING_NAME));
        $form->setField("minimumpayout", $this->getAffiliate()->getMinimumPayout());

        return $form;
    }
 /**
  * Get recordset of all selected wallpaper
  *
  * @param Gpf_Rpc_Params $params
  * @return Gpf_Data_RecordSet
  */
 public function loadSelectedWallpaperNoRpc()
 {
     $response = new Gpf_Data_RecordSet();
     $response->addColumn(self::WALLPAPER_TYPE);
     $response->addColumn(self::WALLPAPER_POSITION);
     $response->addColumn(self::BACKGROUND_COLOR);
     $response->addColumn("fileId");
     $response->addColumn("url");
     $record = $response->createRecord();
     try {
         Gpf_Db_Table_UserAttributes::getInstance()->loadAttributes(Gpf_Session::getAuthUser()->getAccountUserId());
         $wallpaperType = Gpf_Db_Table_UserAttributes::getInstance()->getAttributeWithDefaultValue(self::WALLPAPER_TYPE, self::TYPE_THEME);
         $theme = new Gpf_Desktop_Theme();
         $wallpaperId = Gpf_Db_Table_UserAttributes::getInstance()->getAttributeWithDefaultValue(self::WALLPAPER, $theme->getDefaultWallpaper());
         $position = Gpf_Db_Table_UserAttributes::getInstance()->getAttributeWithDefaultValue(self::WALLPAPER_POSITION, $theme->getDefaultWallpaperPosition());
         $color = Gpf_Db_Table_UserAttributes::getInstance()->getAttributeWithDefaultValue(self::BACKGROUND_COLOR, $theme->getDefaultBackgroundColor());
         $record->set(self::WALLPAPER_POSITION, $position);
         $record->set(self::BACKGROUND_COLOR, $color);
         $record->set(self::WALLPAPER_TYPE, $wallpaperType);
         if ($wallpaperType == self::TYPE_THEME) {
             $record->set("url", Gpf_Paths::getInstance()->getResourceUrl($wallpaperId, Gpf_Paths::IMAGE_DIR . Gpf_Paths::WALLPAPER_DIR));
         } else {
             if ($wallpaperType == self::TYPE_CUSTOM) {
                 $wallpaper = new Gpf_Db_Wallpaper();
                 $wallpaper->setPrimaryKeyValue($wallpaperId);
                 $wallpaper->load();
                 $record->set("fileId", $wallpaper->getFileId());
                 $record->set("url", $wallpaper->getUrl());
             }
         }
     } catch (Gpf_Exception $e) {
         $theme = new Gpf_Desktop_Theme();
         $record->set(self::WALLPAPER_POSITION, "S");
         $record->set(self::BACKGROUND_COLOR, "#000000");
         $record->set(self::WALLPAPER_TYPE, self::TYPE_NONE);
         $record->set("fileId", null);
         $record->set("url", "");
     }
     $response->addRecord($record);
     return $response;
 }
    /**
     * @param String $affAttribute
     * @param String $changeableByAffSettingName
     * @param String $defaultValueSettingName
     * @return boolean
     */
    private function hasNotifyEnabled($affAttribute, $changeableByAffSettingName, $defaultValueSettingName) {    	
    	if ($this->accountSettings->get($changeableByAffSettingName) == Gpf::YES) {
            $isNotify = Gpf_Db_Table_UserAttributes::getInstance()->getAttributeWithDefaultValue($affAttribute, $this->accountSettings->get($defaultValueSettingName));
		} else {
			$isNotify = $this->accountSettings->get($defaultValueSettingName);
		}    	
        return $isNotify === Gpf::YES;
    }
Exemple #11
0
 protected function loadAuthData(Gpf_Data_Record $data)
 {
     $this->username = $data->get("username");
     $this->accountUserId = $data->get("accountuserid");
     $this->authtoken = $data->get("authtoken");
     $this->accountid = $data->get("accountid");
     $this->roletypeid = $data->get("roletypeid");
     $this->roleid = $data->get('roleid');
     $this->authId = $data->get('authid');
     $this->firstname = $data->get('firstname');
     $this->lastname = $data->get('lastname');
     $this->ip = $data->get('ip');
     $attributes = Gpf_Db_Table_UserAttributes::getInstance();
     $attributes->loadAttributes($this->accountUserId);
     $this->setLanguage($attributes->getAttributeWithDefaultValue(self::LANGUAGE_ATTRIBUTE_NAME, Gpf_Lang_Dictionary::getDefaultLanguage()));
 }
	private function deleteAffiliates() {
		Pap3Compatibility_Migration_OutputWriter::logOnce("  Deleting affiliates .....");
		// pap users
		$sql = new Gpf_SqlBuilder_DeleteBuilder();
    	$sql->from->add(Pap_Db_Table_Users::getName());
    	$sql->where->add('rtype', '=', 'A');
    	$sql->execute();

    	// g_users
    	$inSelect = new Gpf_SqlBuilder_SelectBuilder();
    	$inSelect->select->add(Pap_Db_Table_Users::ACCOUNTUSERID);
    	$inSelect->from->add(Pap_Db_Table_Users::getName());
		$sql = new Gpf_SqlBuilder_DeleteBuilder();
    	$sql->from->add(Gpf_Db_Table_Users::getName());
    	$sql->where->add('accountuserid', 'NOT IN', $inSelect, 'AND', false);
    	$sql->execute();

    	// g_authusers
    	$inSelect = new Gpf_SqlBuilder_SelectBuilder();
        $inSelect->select->add(Gpf_Db_Table_Users::AUTHID);
        $inSelect->from->add(Gpf_Db_Table_Users::getName());
		$sql = new Gpf_SqlBuilder_DeleteBuilder();
    	$sql->from->add(Gpf_Db_Table_AuthUsers::getName());
    	$sql->where->add('authid', 'NOT IN', $inSelect, 'AND', false);
    	$sql->execute();

    	// g_userattributes
    	$inSelect = new Gpf_SqlBuilder_SelectBuilder();
        $inSelect->select->add(Gpf_Db_Table_Users::ID);
        $inSelect->from->add(Gpf_Db_Table_Users::getName());
		$sql = new Gpf_SqlBuilder_DeleteBuilder();
    	$sql->from->add(Gpf_Db_Table_UserAttributes::getName());
    	$sql->where->add('accountuserid', 'NOT IN', $inSelect, 'AND', false);
    	$sql->execute();

    	// g_gadgets
    	$inSelect = new Gpf_SqlBuilder_SelectBuilder();
        $inSelect->select->add(Gpf_Db_Table_Users::ID);
        $inSelect->from->add(Gpf_Db_Table_Users::getName());
		$sql = new Gpf_SqlBuilder_DeleteBuilder();
    	$sql->from->add(Gpf_Db_Table_Gadgets::getName());
    	$sql->where->add('accountuserid', 'NOT IN', $inSelect, 'AND', false);
    	$sql->execute();

    	Pap3Compatibility_Migration_OutputWriter::log("DONE<br/>");
	}
Exemple #13
0
 protected function setQuickLaunchSetting($setting)
 {
     Gpf_Db_Table_UserAttributes::setSetting('quickLaunchSetting', $setting, $this->getAccountUserId());
 }
 protected function loadAttributes($accountUserId) {
     $attribute = Gpf_Db_Table_UserAttributes::getInstance();
     $attribute->loadAttributes($accountUserId);
     return $attribute;
 }
 /**
  * @return Gpf_Db_Table_UserAttributes
  */
 protected function getUserAttributes() {
     $userAttributes = Gpf_Db_Table_UserAttributes::getInstance();
     $userAttributes->loadAttributes($this->user->getAccountUserId());
     return $userAttributes;
 }
Exemple #16
0
 protected function setDefaultLanguage() {
     Gpf_Db_Table_UserAttributes::setSetting(Gpf_Auth_User::LANGUAGE_ATTRIBUTE_NAME,
         Pap_Branding::DEFAULT_LANGUAGE_CODE, $this->getAccountUserId());
 }
    private function isNotify(Pap_Common_User $user, $defaultSetting, $enabledSetting, $settingName, $transactionStatus = null, $transactionStatusSettingName = null) {

        $isNotify = $this->accountSettings->get($defaultSetting);
        try {
            if ($this->accountSettings->get($enabledSetting) == Gpf::YES) {
                $isNotify = Gpf_Db_Table_UserAttributes::getSetting($settingName, $user->getAccountUserId());
            }
        } catch(Gpf_Exception $e) {
        }

        if ($transactionStatus == null) {
            return $isNotify;
        }

        if (strstr($this->accountSettings->get($transactionStatusSettingName), $transactionStatus) === false) {
            return Gpf::NO;
        }

        return $isNotify;
    }
 public function isOverwriteEnabled(Pap_Common_Campaign $campaignObject = null, Pap_Common_User $userObject = null) {
     if ($userObject != null) {
         try {
             switch (Gpf_Db_Table_UserAttributes::getSetting(Pap_Settings::OVERWRITE_COOKIE, $userObject->getAccountUserId())) {
                 case GPF::YES: return true;
                 case GPF::NO:  return false;
                 default: break;
             }
         } catch (Gpf_Exception $e) {
         }
     }
     $campaignOverwrite = 'D';
     if($campaignObject != null) {
         $campaignOverwrite = $campaignObject->getOverwriteCookie();
     }
     switch ($campaignOverwrite) {
         case GPF::YES: return true;
         case GPF::NO: return false;
         default: return $this->isGeneralOverwriteAllowed();
     }
 }
    protected function sendNewSubAffSignupMail(Pap_Common_User $parentUser, Pap_Common_User $newUser) {
        $attribute = Gpf_Db_Table_UserAttributes::getInstance();
        $attribute->loadAttributes($parentUser->getAccountUserId());    	

		if (Gpf_Settings::get(Pap_Settings::AFF_NOTIFICATION_ON_SUBAFF_SIGNUP_ENABLED_SETTING_NAME) == Gpf::YES) {
            $isNotify = $attribute->getAttributeWithDefaultValue('aff_notification_on_subaff_signup',
			Gpf_Settings::get(Pap_Settings::AFF_NOTIFICATION_ON_SUBAFF_SIGNUP_DEFAULT_SETTING_NAME));
		} else {
			$isNotify = Gpf_Settings::get(Pap_Settings::AFF_NOTIFICATION_ON_SUBAFF_SIGNUP_DEFAULT_SETTING_NAME);
		}
		    	
		if ($isNotify == Gpf::YES) {
			$signupMail = new Pap_Mail_OnSubAffiliateSignup();
			$signupMail->setUser($newUser);
        	$signupMail->addRecipient($parentUser->getEmail());
			$signupMail->sendNow();
		}
    }
Exemple #20
0
 public function getUserAttributeWithDefaultValue($attributeName, $defaultValue)
 {
     try {
         $value = Gpf_Db_Table_UserAttributes::getSetting($attributeName);
     } catch (Gpf_DbEngine_NoRowException $e) {
         $value = $defaultValue;
         Gpf_Db_Table_UserAttributes::setSetting($attributeName, $defaultValue);
     }
     return $value;
 }
Exemple #21
0
 private function isRegistrationEmailSent(Pap_Common_User $user) {
     try {
         if (Gpf::YES == Gpf_Db_Table_UserAttributes::getSetting(self::AUTO_REGISTERED_AFFILIATE_REGISTRATION_EMAIL_SENT, $user->getAccountUserId())) {
             return true;
         }
     } catch (Gpf_DbEngine_NoRowException $e) {
         return false;
     }
     return false;
 }