fill() public method

public fill ( Gpf_Data_Row $row )
$row Gpf_Data_Row
 protected function generateCoupon($code) {
     $coupon = new Pap_Db_Coupon();
     $this->form->fill($coupon);
     $coupon->setBannerID($this->form->getFieldValue(Pap_Features_Coupon_CreateCoupons::BANNER_ID));
     $coupon->setStatus(Pap_Common_Constants::STATUS_APPROVED);
     $coupon->setCode($code);
     $coupon->setUserID($this->affiliateID);
     $coupon->setUseCount(0);
     $this->insertCoupon($coupon);
 }
    /**
     * @service grid_view write
     *
     * @param $Id
     * @param $gridcode
     * @param $name
     * @param $rowsperpage
     * @param $columns
     */
    public function save(Gpf_Rpc_Params $params) {
        $form = new Gpf_Rpc_Form($params);
        $viewId = $form->getFieldValue('Id');

        $view = $this->getView($viewId);
        try {
            $form->fill($view);
            $this->saveView($view, $form);
        } catch (Exception $e) {
            $form->setErrorMessage($this->_("Error while saving ") . $form->getFieldValue('name') . " (" . $e->getMessage() . ")");
        }

        return $form;
    }
 /**
  * @service email_setting write
  * @param $fields
  * @return Gpf_Rpc_Form
  */
 public function save(Gpf_Rpc_Params $params)
 {
     $form = new Gpf_Rpc_Form($params);
     $dbRow = new Gpf_Db_MailAccount();
     try {
         $dbRow->setAsDefault(true);
         $dbRow->loadFromData(array(Gpf_Db_Table_MailAccounts::IS_DEFAULT));
     } catch (Gpf_DbEngine_NoRowException $e) {
         $dbRow->setAccountName($this->_("Default Mail Account"));
         $dbRow->setAsDefault(true);
     }
     $form->fill($dbRow);
     $dbRow->save();
     $form->setInfoMessage($this->_("Email settings saved"));
     return $form;
 }
Ejemplo n.º 4
0
    /** 
     * @service filter write
     * @param $fields
     */
    public function add(Gpf_Rpc_Params $params) {
        $form = new Gpf_Rpc_Form($params);

        $filter = new Gpf_Db_Filter();
        $form->fill($filter);
        $filter->setUserId(Gpf_Session::getAuthUser()->getUserId());

        try {
            $filter->insert();
            $this->saveFilterPresets($form, $filter->getPrimaryKeyValue());
        } catch (Exception $e) {
            $form->setErrorMessage($e->getMessage());
            return $form;
        }

        $form->load($filter);
        $form->setField('Id', $filter->get('filterid'));
        $form->setInfoMessage($this->_("Filter added"));
        return $form;
    }
 /**
  * Create new language
  *
  * @service language add
  * @return Gpf_Rpc_Form
  */
 public function add(Gpf_Rpc_Params $params)
 {
     $form = new Gpf_Rpc_Form($params);
     $lang = new Gpf_Db_Language();
     $lang->setCode($form->getFieldValue(Gpf_Db_Table_Languages::CODE));
     $lang->setAccountId(Gpf_Application::getInstance()->getAccountId());
     $lang->setId($lang->generateId());
     try {
         //Load should fail, otherwise it is error - language already exists
         $lang->load();
         $form->setErrorMessage($this->_('Language code %s is already used in your installation', $form->getFieldValue(Gpf_Db_Table_Languages::CODE)));
         return $form;
     } catch (Exception $e) {
     }
     try {
         //Load language from default csv file
         $fileNameDefault = Gpf_Paths::getInstance()->getLanguageInstallDirectory() . Gpf_Application::getInstance()->getCode() . '_' . Gpf_Lang_CsvHandler::DEFAULT_LANGUAGE . '.csv';
         $file = new Gpf_Io_Csv_Reader($fileNameDefault, ';', '"', array('source', 'translation', 'type', 'module', 'status', 'customer'));
         $csvLanguage = new Gpf_Lang_CsvLanguage();
         $csvLanguage->loadFromCsvFile($file);
         $form->fill($lang);
         $lang->setAccountId(Gpf_Application::getInstance()->getAccountId());
         $lang->setId($lang->generateId());
         $lang->setActive(true);
         $lang->setTranslatedPercentage(0);
         $lang->insert();
         //update metadata
         $csvLanguage->copyMetadataFromDbLanguage($lang);
         foreach ($csvLanguage->getTranslations() as $translation) {
             $translation->setStatus(Gpf_Lang_Parser_Translation::STATUS_NOT_TRANSLATED);
         }
         //export cache
         $csvLanguage->exportAccountCache();
     } catch (Exception $e) {
         $form->setErrorMessage($this->_('Failed to create new language: %s', $e->getMessage()));
         return $form;
     }
     $form->setInfoMessage($this->_('New language with code %s created', $form->getFieldValue(Gpf_Db_Table_Languages::CODE)));
     return $form;
 }
    /** 
     *
     * @service user_comm_group add
     * @param $fields
     */
    public function add(Gpf_Rpc_Params $params) {
        $form = new Gpf_Rpc_Form($params);     

        $dbRow = $this->createDbRowObject();
        $this->setDefaultDbRowObjectValues($dbRow);

        $form->fill($dbRow);
        $dbRow->set(Pap_Db_Table_UserInCommissionGroup::STATUS, self::DEFAULT_STATUS);
        $dbRow->set(Pap_Db_Table_UserInCommissionGroup::NOTE, self::DEFAULT_NOTE);
        $dbRow->set(Pap_Db_Table_UserInCommissionGroup::DATE_ADDED, Gpf_Common_DateUtils::now());

        try {
            $dbRow->save();
        } catch (Exception $e) {
            $form->setErrorMessage($e->getMessage());
            return $form;
        }

        $form->load($dbRow);
        $form->setField("Id", $dbRow->getPrimaryKeyValue());
        $form->setInfoMessage($this->getDbRowObjectName().$this->_(" added"));
        return $form;
    }
    /** 
     *
     * @service user_in_commission_group add
     * @param $fields
     * @return Gpf_Rpc_Form
     */
    public function add(Gpf_Rpc_Params $params) {
        $form = new Gpf_Rpc_Form($params);

        $dbRow = $this->createDbRowObject();
        $this->setDefaultDbRowObjectValues($dbRow);

        $form->fill($dbRow);
        $dbRow->setDateAdded(Gpf_Common_DateUtils::getDateTime(time()));
        
        $dbRow->removeUserFromCampaignGroups($form->getFieldValue('campaignid'));
        
        try {
            $dbRow->save();
        } catch (Exception $e) {
            $form->setErrorMessage($e->getMessage());
            return $form;
        }

        $form->load($dbRow);
        $form->setField("Id", $dbRow->getPrimaryKeyValue());
        $form->setInfoMessage($this->_("%s was successfully added", $this->getDbRowObjectName()));
        
        return $form;
    }
Ejemplo n.º 8
0
 protected function fillAdd(Gpf_Rpc_Form $form, Gpf_DbEngine_RowBase $dbRow) {
     $form->fill($dbRow);
 }
Ejemplo n.º 9
0
    /**
     * @service grid_view write
     *
     * @param $Id
     * @param $gridcode
     * @param $name
     * @param $rowsperpage
     * @param $columns
     */
    public function save(Gpf_Rpc_Params $params) {
        $form = new Gpf_Rpc_Form($params);
        $viewId = $form->getFieldValue('Id');
        if ($viewId == self::DEFAULT_VIEW_ID) {
            $form->setErrorMessage($this->_("Default view can not be modified"));
            return $form;
        }

        $view = $this->getView($viewId);
        try {
            $form->fill($view);
            if (($view->getName() == $this->_(self::DEFAULT_VIEW_NAME))) {
                throw new Gpf_Exception($this->_("View name must be unique"));
            }
            $this->saveView($view, $form);
        } catch (Exception $e) {
            $form->setErrorMessage($this->_("Error while saving view ") . $form->getFieldValue('name') . " (" . $e->getMessage() . ")");
        }

        return $form;
    }
Ejemplo n.º 10
0
    /**
     * @service currency write
     * @param $fields
     */
    public function save(Gpf_Rpc_Params $params) {
        $form = new Gpf_Rpc_Form($params);

        $dbRow = $this->createDbRowObject();
        $dbRow->setIsDefault(Gpf_Db_Currency::DEFAULT_CURRENCY_VALUE);

        try {
        	$dbRow->loadFromData();
        } catch (Gpf_DbEngine_NoRowException $e) {
            $dbRow->setAccountId(Gpf_Session::getAuthUser()->getAccountId());
        }

        $oldDbRow = clone $dbRow;
        $form->fill($dbRow);

        foreach ($oldDbRow as $name => $oldValue) {
            if ($dbRow->get($name) != $oldValue) {
                $form->addField('changed', 'Y');
                break;
            }
        }

        try {
            $dbRow->save();
            Gpf_Plugins_Engine::extensionPoint('PostAffiliate.CurrencyForm.save', $form);
        } catch (Exception $e) {
            $form->setErrorMessage($e->getMessage());
            return $form;
        }

        $form->load($dbRow);
        $form->setInfoMessage($this->getDbRowObjectName().$this->_(" saved"));
        return $form;
    }
Ejemplo n.º 11
0
    /**
     * Saves capping settings for this campaign
     *
     * @service campaign write
     * @param $fields
     */
    public function saveCapping(Gpf_Rpc_Params $params) {
        $form = new Gpf_Rpc_Form($params);

        $campaign = new Pap_Common_Campaign();
        $campaign->set('campaignid', $form->getFieldValue("Id"));

        try {
            $campaign->load();
        } catch (Gpf_DbEngine_NoRow $e) {
            $form->setErrorMessage($this->_("Campaign does not exist"));
            return $form;
        }

        $form->fill($campaign);

        $this->checkBeforeSave($campaign, $form);

        try {
            $campaign->save();
        } catch (Exception $e) {
            $form->setErrorMessage($e->getMessage());
            return $form;
        }

        $form->load($campaign);
        $form->setInfoMessage($this->_("Campaign capping saved"));
        return $form;
    }
    /**
     *
     * @param $form
     * @return Gpf_Rpc_Form
     */
    protected function processMultiTier(Gpf_Rpc_Form $form) {
        $transaction = new Pap_Common_Transaction();
        $form->fill($transaction);

        $this->addMultiTierTransaction($form->getFieldValue(Pap_Db_Table_Transactions::TOTAL_COST),
        $form->getFieldValue(Pap_Db_Table_Transactions::CAMPAIGN_ID),
        $form->getFieldValue(Pap_Db_Table_Transactions::USER_ID),
        $form->getFieldValue(Pap_Db_Table_Transactions::COMMISSIONTYPEID),
        $form->getFieldValue(Pap_Db_Table_Transactions::R_STATUS),
        $transaction);

        $form->setInfoMessage($this->_('Transaction was successfully added'));
        return $form;
    }