add() public method

Adds new row to RecordSet
public add ( array $record )
$record array array of data for all columns in record
Exemplo n.º 1
0
 /**
  * @service
  * @anonym
  *
  * @param $gridcode
  */
 public function getActiveView(Gpf_Rpc_Params $params) {
     $view = new Gpf_Data_RecordSet();
     $view->setHeader(array("id"));
     try {
         $view->add(array($this->getActiveViewId($params->get('gridcode'))));
     } catch (Exception $e) {
         $view->add(array("default"));
     }
     return $view;
 }
Exemplo n.º 2
0
 private function loadSubfilesFiles($fileUrl, Gpf_Data_RecordSet $result, $directories = false)
 {
     foreach (new Gpf_Io_DirectoryIterator($fileUrl, '', false, $directories) as $fullFileName => $file) {
         $file = new Gpf_Io_File($fullFileName);
         if ($file->isDirectory()) {
             $filesData = $this->getFilesData($fullFileName);
             $result->add(array($fullFileName, $filesData['count'], $file->getName(), $filesData['size'], self::TYPE_DIRECTORY));
             continue;
         }
         $result->add(array($fullFileName, 0, $file->getName(), $file->getSize(), self::TYPE_FILE));
     }
 }
Exemplo n.º 3
0
 private function serializeToRecordset(Gpf_Data_RecordSet $response, $level)
 {
     foreach ($this->items as $menuItem) {
         $response->add(array($menuItem->getCode(), "" . $level, $menuItem->getTitle()));
         $menuItem->serializeToRecordset($response, $level + 1);
     }
 }
 /**
  * @service mail_template write
  * @param $fields
  * @return Gpf_Rpc_Form
  */
 public function save(Gpf_Rpc_Params $params)
 {
     $form = new Gpf_Rpc_Form($params);
     try {
         $mailTemplate = $this->loadMailTemplate($form->getFieldValue('templateid'));
     } catch (Gpf_Exception $e) {
         $form->setErrorMessage($this->_('Failed to load mail template with error: %s', $e->getMessage()));
         return $form;
     }
     try {
         $className = $mailTemplate->get(Gpf_Db_Table_MailTemplates::CLASS_NAME);
         $objTemplate = new $className();
         $templateVariables = new Gpf_Data_RecordSet();
         $templateVariables->setHeader(array('id', 'value'));
         foreach ($objTemplate->getTemplateVariables() as $code => $name) {
             $record = $templateVariables->createRecord();
             $record->set('id', $code);
             $record->set('value', $form->getFieldValue('var_' . $code));
             $templateVariables->add($record);
         }
         $objTemplate->setCachedVariableValues($templateVariables);
         $objTemplate->addRecipient($form->getFieldValue('recipient'));
         $objTemplate->sendNow();
     } catch (Gpf_Exception $e) {
         $form->setErrorMessage($this->_('Failed to send test mail with error: %s', $e->getMessage()));
         return $form;
     }
     $form->setInfoMessage($this->_('Test mail was successfully queued'));
     return $form;
 }
Exemplo n.º 5
0
 /**
  * @param array $requestArray
  * @return StdClass
  */
 function decode($requestArray)
 {
     $param = new stdClass();
     $reservedParams = array(Gpf_Rpc_Params::CLASS_NAME, Gpf_Rpc_Params::METHOD_NAME, Gpf_Rpc_Params::SESSION_ID, Gpf_Rpc_Server::FORM_REQUEST, Gpf_Rpc_Server::FORM_RESPONSE);
     $recordset = new Gpf_Data_RecordSet();
     $recordset->setHeader(array("name", "value"));
     foreach ($requestArray as $name => $value) {
         if (in_array($name, $reservedParams)) {
             continue;
         }
         if (get_magic_quotes_gpc()) {
             $value = stripslashes($value);
         }
         $record = $recordset->createRecord();
         $record->set("name", $name);
         $record->set("value", $value);
         $recordset->add($record);
     }
     $param->fields = $recordset->toObject();
     foreach ($reservedParams as $paramName) {
         if (array_key_exists($paramName, $requestArray)) {
             $param->{$paramName} = $requestArray[$paramName];
         }
     }
     return $param;
 }
Exemplo n.º 6
0
 protected function addRequiredColumn($columnName) {
    try {
         $this->_requiredColumns->getRecord($columnName);            
     } catch (Gpf_Data_RecordSetNoRowException $e) {
         $this->_requiredColumns->add(array($columnName, Gpf::YES));    
     }        
 }
    /**
     * @service campaign read
     * @return Gpf_Data_RecordSet
     */
    public function getActionTypes(Gpf_Rpc_Params $params) {
        $actionTypesHeader = array(Pap_Db_Table_CommissionTypes::TYPE, Pap_Db_Table_CommissionTypes::NAME, Pap_Db_Table_CommissionTypes::ID, 'campaignName');

        $data = new Gpf_Rpc_Data($params);
        $filters = $data->getFilters();

        $statsParams = new Pap_Stats_Params();
        $statsParams->setCampaignId($filters->getFilterValue('campaignid'));
        $statsParams->setBannerId($filters->getFilterValue('bannerid'));

        $transactionTypeStats = new Pap_Stats_TransactionTypeStats($statsParams);
        $transactionTypes = $transactionTypeStats->getTypes();

        $actionTypesRecordSet = new Gpf_Data_RecordSet();
        $actionTypesRecordSet->setHeader($actionTypesHeader);

        $this->initActionCampaignNames();

        foreach ($transactionTypes as $transactionType) {
            if ($transactionType->getType() != Pap_Common_Constants::TYPE_SALE && $transactionType->getType() !=Pap_Common_Constants::TYPE_ACTION && $transactionType->getType() != Pap_Common_Constants::TYPE_RECURRING) {
                continue;
            }
            $actionTypesRecordSet->add(new Gpf_Data_Record($actionTypesHeader, array($transactionType->getType(), $transactionType->getName(), $transactionType->getCommissionTypeId(), $this->getActionCampaignName($transactionType->getCommissionTypeId()))));
        }
        return $actionTypesRecordSet;
    }
Exemplo n.º 8
0
 /**
  * @service coupon read
  * @param $params
  * @return Gpf_Data_RecordSet
  */
 public function loadCouponConstants(Gpf_Rpc_Params $params) {
     $couponConstants = new Gpf_Data_RecordSet();
     $couponConstants->setHeader(array('id', 'name'));
     foreach ($this->getCouponBannersSelect()->getAllRowsIterator() as $couponBannerData) {
         if ($params->get('bannertype') == Pap_Common_Banner_Factory::BannerTypeHtml || $params->get('bannertype') == Pap_Common_Banner_Factory::BannerTypePromoEmail) {
             $couponConstant = $couponConstants->createRecord();
             $couponConstant->set('id', 'coupon_' . $couponBannerData->get('id'));
             $couponConstant->set('name', $this->_($couponBannerData->get('name')));
             $couponConstants->add($couponConstant);
         }
         $couponConstant = $couponConstants->createRecord();
         $couponConstant->set('id', 'couponcode_' . $couponBannerData->get('id'));
         $couponConstant->set('name', $this->_($couponBannerData->get('name')) . ' ' . $this->_('(only coupon code)'));
         $couponConstants->add($couponConstant);
     }
     return $couponConstants;
 }
Exemplo n.º 9
0
	protected function afterExecute(Gpf_Data_RecordSet $inputResult) {
		$outPutResult = new Gpf_Data_RecordSet();
		$outPutResult->setHeader(array(parent::KEY_COLUMN_ID, 'number', 'rule'));

		foreach ($inputResult as $row) {
		    $rule = new Pap_Features_PerformanceRewards_Rule_Transaction();
		    $rule->fillFromRecord($row);
		    $rule->setCommissionGroupId($row->get('commissiongroup'));
		    try {
			     $outPutResult->add(array($row->get(parent::KEY_COLUMN_ID), $row->get('number'), $rule->getString()));
		    } catch (Pap_Features_PerformanceRewards_UnknownRuleException $e) {
		         $outPutResult->add(array($row->get(parent::KEY_COLUMN_ID), $row->get('number'), $this->_('Unknown rule (%s) - probably created with some feature or plugin - this rule will not be applied.', $rule->getAction())));
		    }
		}
	    
		return $outPutResult;
	}
Exemplo n.º 10
0
 /**
  *
  * @return Gpf_Data_RecordSet
  */
 private function getAvailableLanguages()
 {
     $languages = new Gpf_Data_RecordSet();
     $languages->setHeader(array('id', 'name'));
     foreach (new Gpf_Lang_InstallLanguages() as $language) {
         $languages->add(array($language->getCode(), $language->getExtendedName()));
     }
     return $languages;
 }
 /**
  * @service banner_format_setting read
  * @return Gpf_Data_RecordSet
  */
 public function loadWrapperNames(Gpf_Rpc_Params $params) {
     $row = new Pap_Db_BannerWrapper();
     $collection = $row->loadCollection();
     $result = new Gpf_Data_RecordSet();
     $result->setHeader(array('id', 'name'));
     foreach ($collection as $row){
         $result->add(array($row->getId(), $row->getName()));
     }
     return $result;
 }
Exemplo n.º 12
0
 /**
  * returns data for chart
  *
  * @service trend_stats read
  * @param $fields
  * @return Gpf_Rpc_Chart
  */
 public function loadDataTypes(Gpf_Rpc_Params $params) {
     $this->initCampaignId($params);
     $this->initDataTypes();
     $recordSet = new Gpf_Data_RecordSet();
     $recordSet->setHeader(array("id", "value"));
     foreach ($this->dataTypes as $dataType) {
         $recordSet->add(array($dataType->getId(), $dataType->getName()));
     }
     return $recordSet;
 }
Exemplo n.º 13
0
 private function fillFromUser(Gpf_Rpc_Form $form, Pap_Affiliates_User $user) {
     $userData = new Gpf_Data_RecordSet();
     $userData->setHeader(array('userid', 'username','firstname', 'lastname'));
     $data = $userData->createRecord();
     $data->add('userid', $user->getId());
     $data->add('username', $user->getUserName());
     $data->add('firstname', $user->getFirstName());
     $data->add('lastname', $user->getLastName());
     $userData->add($data);
     $form->setField('userid', null, $userData->toObject());
 }
 /**
  * Load list of template variables for custom template
  *
  * @service mail_template read
  * @param Gpf_Rpc_Params $params
  */
 public function getTemplateVariables(Gpf_Rpc_Params $params)
 {
     $recordSet = new Gpf_Data_RecordSet();
     $recordSet->setHeader(array('code', 'name'));
     //TODO - treba prerobit cez extension point ... v pap newsletter feature budu premenne definovane cez Pap_Mail_UserMail
     $objTemplate = new Pap_Mail_UserMail();
     foreach ($objTemplate->getTemplateVariables() as $code => $name) {
         $recordSet->add(array($code, $name));
     }
     return $recordSet;
 }
Exemplo n.º 15
0
    /**
     * Load list of template variables for custom template
     *
     * @service mail_template read
     * @param Gpf_Rpc_Params $params
     */
    public function getTemplateVariables(Gpf_Rpc_Params $params) {
        $recordSet = new Gpf_Data_RecordSet();
        $recordSet->setHeader(array('code', 'name'));

        $objTemplate = new Pap_Mail_UserMail();

        foreach ($objTemplate->getTemplateVariables() as $code => $name) {
            $recordSet->add(array($code, $name));
        }

        return $recordSet;
    }
 /**
  * Load list of template variables for template specified in input parameter templateId
  *
  * @service mail_template read
  * @param Gpf_Rpc_Params $params
  */
 public function getTemplateVariables(Gpf_Rpc_Params $params)
 {
     $dbRow = $this->loadMailTemplate($params->get("templateId"));
     $recordSet = new Gpf_Data_RecordSet();
     $recordSet->setHeader(array('code', 'name'));
     $className = $dbRow->get(Gpf_Db_Table_MailTemplates::CLASS_NAME);
     $objTemplate = new $className();
     foreach ($objTemplate->getTemplateVariables() as $code => $name) {
         $recordSet->add(array($code, $name));
     }
     return $recordSet;
 }
Exemplo n.º 17
0
 public function getAllIconsNoRpc()
 {
     $response = new Gpf_Data_RecordSet();
     $response->setHeader(array("iconName", "smallIcon", "middleIcon", "bigIcon"));
     foreach ($this->icons as $iconName => $imageFile) {
         try {
             $response->add(array($iconName, $this->getImageUrl($imageFile, "small"), $this->getImageUrl($imageFile, "middle"), $this->getImageUrl($imageFile, "big")));
         } catch (Exception $e) {
             //TODO: add default image !
         }
     }
     return $response;
 }
Exemplo n.º 18
0
 /**
  * Gets template names for template name suggestion oracle
  *
  * @service template read
  * @param $search
  */
 public function getTemplateNames(Gpf_Rpc_Params $params)
 {
     $searchString = $params->get('search');
     $this->loadTemplates();
     $result = new Gpf_Data_RecordSet();
     $result->setHeader(array('id', 'name'));
     foreach ($this->templates as $templateName) {
         if ($searchString == "" || strstr($templateName, $searchString) !== false) {
             $result->add(array($templateName, $templateName . '.tpl'));
         }
     }
     return $result;
 }
	protected function buildData(Gpf_Data_RecordSet $fields, Gpf_Rpc_Params $params) {
		$selectBuilder = Pap_Db_Table_Commissions::getInstance()->getAllCommissionsInCampaignSelectBuilder($params->get('campaignid'), '');
		$selectBuilder->orderBy->add('c.' . Pap_Db_Table_Commissions::ID);
		$selectBuilder->orderBy->add('tier');
		$selectBuilder->orderBy->add('ct.' . Pap_Db_Table_CommissionTypes::PARENT_COMMISSIONTYPE_ID);
		$commissionGroupID = $this->getCommissionGroupId($params->get('campaignid'));

		foreach ($selectBuilder->getAllRowsIterator() as $commission) {
			if ($commission->get('commissiongroupid') != $commissionGroupID) {
				continue;
			}
			$fields->add($this->createRecordArray($commission));
			$this->addCommission($commission);
		}
	}
    /**
     * Load list of template variables for custom template
     *
     * @service mail_template read
     * @param Gpf_Rpc_Params $params
     */
    public function getTemplateVariables(Gpf_Rpc_Params $params) {
        $recordSet = new Gpf_Data_RecordSet();
        $recordSet->setHeader(array('code', 'name'));

        $objTemplate = new Pap_Mail_AffiliateUserMail();

        foreach ($objTemplate->getTemplateVariables() as $code => $name) {
            if($code == 'password' || $code == 'parent_password'){
                continue;  
            } 
            $recordSet->add(array($code, $name));
        }

        return $recordSet;
    }
 private function addUserToRecordSet(Gpf_Data_RecordSet $result, $userId) {
     $user = new Pap_Affiliates_User();
     $user->setId($userId);
     try {
         $user->load();
         $record = $result->createRecord();
         $record->loadFromObject(array_values($user->toArray()));
         $record->set("subaffiliates", 1);
         $result->add($record);
         if (strlen($user->getParentUserId())) {
             $this->addUserToRecordSet($result, $user->getParentUserId());
         }
     } catch (Exception $e) {
     }
 }
Exemplo n.º 22
0
	protected function buildData(Gpf_Data_RecordSet $fields, Gpf_Rpc_Params $params) {
		$select = new Gpf_SqlBuilder_SelectBuilder();        
        $select->select->add("name", "payoutFieldName", "ff");
        $select->select->add(Pap_Db_Table_UserPayoutOptions::VALUE, Pap_Db_Table_UserPayoutOptions::VALUE, "upo");
        $select->select->add(Pap_Db_Table_UserPayoutOptions::FORMFIELDID, Pap_Db_Table_UserPayoutOptions::FORMFIELDID, "upo");
        $select->from->add(Pap_Db_Table_Users::getName(), "pu");
        $select->from->addInnerJoin(Gpf_Db_Table_FormFields::getName(), "ff", "(ff.formid = CONCAT('payout_option_', pu.payoutoptionid))");
        $select->from->addInnerJoin(Pap_Db_Table_UserPayoutOptions::getName(), "upo", "(pu.userid = upo.userid AND ff.formfieldid = upo.formfieldid)");
        $select->where->add("pu.userid", "=", $params->get('userid'));       
        
        $i = 1;
		foreach ($select->getAllRowsIterator() as $payoutField) {
			$fields->add(array($payoutField->get(Pap_Db_Table_UserPayoutOptions::FORMFIELDID), 
								'data' . $i, 
								$this->_($payoutField->get('payoutFieldName')), 'T', 'M', null, ''));
			$this->fieldValues['data' . $i++] = $payoutField->get(Pap_Db_Table_UserPayoutOptions::VALUE);			
		}
	}
    protected function afterExecute(Gpf_Data_RecordSet $inputResult) {
        $outputResult = new Gpf_Data_RecordSet();
        $outputResult->setHeader($inputResult->getHeader());

        $tree = new Pap_Features_BannersCategories_Tree(false);
        foreach ($inputResult as $record) {
            if ($record->get('code')=='0' || $record->get('selected')=='N') {
                continue;
            }

            $newRecord = new Gpf_Data_Record($inputResult->getHeader());
            $newRecord->add('name', $this->_localize($tree->getBreadcrumb($record->get('id'), ' > ')));
            $newRecord->add('id', $record->get('id'));

            $outputResult->add($newRecord);
        }
        return $outputResult;
    }
    protected function afterExecute(Gpf_Data_RecordSet $inputResult) {
        $outputResult = new Gpf_Data_RecordSet();
        $outputResult->setHeader($inputResult->getHeader());

        $tree = new Pap_Features_BannersCategories_Tree(false);
        foreach ($inputResult as $record) {
            if ($record->get('code')=='0') {
                $this->_count--;
                continue;
            }

            $newRecord = new Gpf_Data_Record($inputResult->getHeader());
            $newRecord->add('name', $record->get('name'));
            $newRecord->add('id', $record->get('id'));
            $newRecord->add('state', $record->get('state'));
            $newRecord->add('depth', $record->get('depth'));


            $outputResult->add($newRecord);
        }
        return $outputResult;
    }
Exemplo n.º 25
0
 private function addField($caption, $code, $type, $status, $help = '', $values = array())
 {
     $record = $this->fieldsRecordset->createRecord();
     $record->set('id', '0');
     $record->set('code', $code);
     $record->set('name', $caption);
     $record->set('help', $help);
     $record->set('type', $type);
     $record->set('status', $status);
     if (count($values) > 0) {
         $valuesRecordSet = new Gpf_Data_RecordSet();
         $valuesRecordSet->setHeader(array("id", "value"));
         foreach ($values as $id => $value) {
             if ($id != '') {
                 $valuesRecordSet->add(array($id, $value));
             }
         }
         $json = new Gpf_Rpc_Json();
         $record->set('availablevalues', $json->encode($valuesRecordSet->toObject()));
     }
     $this->fieldsRecordset->addRecord($record);
 }
Exemplo n.º 26
0
 private function createTemplateRecordSet($templateName, $templateContent)
 {
     $recordSet = new Gpf_Data_RecordSet();
     $recordSet->setHeader(array('templateName', 'templateHtml'));
     $recordSet->add(array($templateName, $templateContent));
     return $recordSet;
 }
Exemplo n.º 27
0
 /**
  * Get recordset of default theme wallpapers
  *
  * @return Gpf_Data_RecordSet
  */
 public function getDefaultThemeWallpaperNoRpc()
 {
     $response = new Gpf_Data_RecordSet();
     $response->setHeader(array("filename", "name", "url"));
     foreach (Gpf_Paths::getInstance()->getThemeWallPaperDirPaths() as $dirName) {
         $dir = new Gpf_Io_DirectoryIterator($dirName);
         foreach ($dir as $fullName => $file) {
             $info = pathinfo($file);
             $response->add(array($file, str_replace('_', ' ', $info['filename']), Gpf_Paths::getInstance()->getResourceUrl($file, Gpf_Paths::IMAGE_DIR . Gpf_Paths::WALLPAPER_DIR)));
         }
     }
     return $response;
 }
    /**
     * Load names and setting names for BannersAndLinksFormat
     *
     * @service banner_format_setting read
     * @param $fields
     */
    public function loadNames(Gpf_Rpc_Params $params) {
        $form = new Gpf_Rpc_Form($params);
        $accountId = Gpf_Session::getAuthUser()->getAccountId();

        $result = new Gpf_Data_RecordSet();
        $result->setHeader(array('settingName', 'name'));
        $result->add(array(Pap_Settings::TEXT_BANNER_FORMAT_SETTING_NAME, $this->_('Text link format')));
        $result->add(array(Pap_Settings::IMAGE_BANNER_FORMAT_SETTING_NAME, $this->_('Image banner format')));
        $result->add(array(Pap_Settings::FLASH_BANNER_FORMAT_SETTING_NAME, $this->_('Flash banner format')));

        return $result;
    }
Exemplo n.º 29
0
 /**
  * @return Gpf_Data_RecordSet
  */
 public function getPrivileges()
 {
     $privileges = new Gpf_Data_RecordSet();
     $privileges->setHeader(array('name'));
     foreach ($this->privileges as $object => $objectPrivileges) {
         foreach ($objectPrivileges as $privilege => $value) {
             $privileges->add(array($object . '|' . $privilege));
         }
     }
     return $privileges;
 }
 private function addColumn($code, $view) {
     $name = $this->names->createRecord();
     $name->set('code', $code);
     $name->set('view', $view);
     $this->names->add($name);
 }