getParam() public method

public getParam ( $name )
Ejemplo n.º 1
0
    /**
     * @service theme write
     */
    public function revertFile(Gpf_Rpc_Params $params) {
        $action = new Gpf_Rpc_Action($params);
        try{
            $themeId = $action->getParam('themeId');
            $itemId = $action->getParam("Id");
            $themeBase = $this->getThemeFile($action->getParam('panelName'));

            $file_original = new Gpf_Io_File($themeBase.'/'.Gpf_Paths::DEFAULT_THEME.$itemId);
            $file_new = new Gpf_Io_File($themeBase.'/'.$themeId.$itemId);

            if($file_original->isExists() && $file_new->isExists()){
                if(!$file_new->delete()){
                    throw new Gpf_Exception(_("Revert of file has failed"));
                }else{
                    $action->setInfoMessage(_("Revert of file success"));
                }
            }else{
                $action->setInfoMessage(_("This file cannot be reverted"));
            }
            $action->addOk();
        }catch (Gpf_Exception $e){
            $action->addError();
            $action->setErrorMessage($e->getMessage());
        }
        return $action;
    }
    /**
     * @service commission_group 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) in %s(s)', '%s', $this->_('commission group')));
        $action->setInfoMessage($this->_('%s field(s) in %s(s) successfully saved', '%s', $this->_('commission group')));

        $userId = $action->getParam('id');
        $fields = new Gpf_Data_RecordSet();
        $fields->loadFromArray($action->getParam("fields"));

        foreach ($fields as $field) {
        	$this->saveCommissionGroup($field->get('id'), $userId, $field->get("value"));
            $action->addOk();
        }

        return $action;
    }
Ejemplo n.º 3
0
 /**
  *
  * @param $params
  * @param $activate
  * @return Gpf_Rpc_Action
  */
 private function pluginChangeState(Gpf_Rpc_Params $params, $activate)
 {
     $action = new Gpf_Rpc_Action($params);
     $code = $action->getParam("code");
     if (defined('ENABLE_ENGINECONFIG_LOG')) {
         Gpf_Log::info('pluginChangeState: ' . $code . ', activate:' . $activate);
     }
     $engineConfig = Gpf_Plugins_Engine::getInstance();
     try {
         $engineConfig->activate($code, $activate);
         $engineConfig->saveConfiguration();
         if ($activate) {
             $action->setInfoMessage($this->_('Plugin was successfully activated'));
         } else {
             $action->setInfoMessage($this->_('Plugin was successfully deactivated'));
         }
         $action->addOk();
     } catch (Exception $e) {
         if (defined('ENABLE_ENGINECONFIG_LOG')) {
             Gpf_Log::error('pluginChangeState-error: ' . $e->getMessage());
         }
         $action->setErrorMessage($e->getMessage());
         $action->addError();
     }
     return $action;
 }
 /**
  * Delete pending background task if it is allowed
  *
  * @service tasks delete
  * @param $params
  * @return Gpf_Rpc_Action
  */
 public function deleteTask(Gpf_Rpc_Params $params)
 {
     $action = new Gpf_Rpc_Action($params);
     $dbTask = new Gpf_Db_Task();
     try {
         $dbTask->setId($action->getParam('taskid'));
         $dbTask->load();
     } catch (Gpf_Exception $e) {
         $action->addError();
         $action->setErrorMessage($this->_('Failed to delete task.'));
         return $action;
     }
     if ($dbTask->isExecuting()) {
         $action->addError();
         $action->setErrorMessage($this->_('It is not possible to delete running task.'));
         return $action;
     }
     try {
         $longTask = Gpf::newObj($dbTask->getClassName());
         if (!$longTask->canUserDeleteTask()) {
             $action->addError();
             $action->setErrorMessage($this->_('This type of task is not allowed to be deleted.'));
             return $action;
         }
     } catch (Gpf_Exception $e) {
     }
     $dbTask->delete();
     $action->addOk();
     $action->setInfoMessage($this->_('Task deleted.'));
     return $action;
 }
    protected function saveFieldsRpc(Gpf_Rpc_Params $params) {
        $action = new Gpf_Rpc_Action($params);
        $action->setErrorMessage($this->_('Failed to save %s field(s) in %s(s)', '%s', $this->getDbRowObjectName()));
        $action->setInfoMessage($this->_('%s field(s) in %s(s) successfully saved', '%s', $this->getDbRowObjectName()));

        $fields = new Gpf_Data_RecordSet();
        $fields->loadFromArray($action->getParam("fields"));


        foreach ($fields as $field) {
            $dbRow = $this->createDbRowObject();
            $dbRow->setPrimaryKeyValue($field->get(Gpf_Db_Table_FormFields::ID));
            $dbRow->load();
            $dbRow->setName($field->get(Gpf_Db_Table_FormFields::NAME));
            $dbRow->setStatus($field->get(Gpf_Db_Table_FormFields::STATUS));
            $dbRow->setType($field->get(Gpf_Db_Table_FormFields::TYPE));
            if ($field->get(Gpf_Db_Table_FormFields::AVAILABLEVALUES) != null) {
                $dbRow->setAvailableValues($field->get(Gpf_Db_Table_FormFields::AVAILABLEVALUES));
            }
            $dbRow->save();
            $action->addOk();
        }

        return $action;
    }
Ejemplo n.º 6
0
    /**
     * @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;
    }
Ejemplo n.º 7
0
    /**
     * @service theme write
     *
     * @return Gpf_Rpc_Action
     */
    public function setTheme(Gpf_Rpc_Params $params) {
        $action = new Gpf_Rpc_Action($params);
        $action->setErrorMessage($this->_("Error changing theme"));
        $action->setInfoMessage($this->_("Theme changed"));

        try {
            $themeId = $action->getParam('themeId');
            Gpf_Session::getAuthUser()->setTheme($themeId);
            Gpf_Settings::set($action->getParam('settingName'), $themeId);
            $action->addOk();
        } catch (Exception $e) {
            $action->addError();
        }

        return $action;
    }
Ejemplo n.º 8
0
 /**
  * Set language as default and unset another default language
  *
  * @service language write
  * @param Gpf_Rpc_Params $params
  * @return Gpf_Rpc_Action
  */
 public function setLanguageAsDefault(Gpf_Rpc_Params $params)
 {
     $action = new Gpf_Rpc_Action($params);
     try {
         Gpf_Db_Table_Languages::getInstance()->unsetDefaultLanguage($action->getParam(Gpf_Db_Table_Languages::ID));
         $lang = new Gpf_Db_Language();
         $lang->setId($action->getParam(Gpf_Db_Table_Languages::ID));
         $lang->load();
         $lang->setIsDefault(true);
         $lang->save();
     } catch (Exception $e) {
         $action->addError();
         $action->setErrorMessage($this->_('Failed to set default language with error: %s', $e->getMessage()));
         return $action;
     }
     $action->setInfoMessage($this->_('Language %s set as default.', $lang->getEnglishName()));
     $action->addOk();
     return $action;
 }
    /**
     *
     * @service direct_link read_own
     * @param Gpf_Rpc_Params $params (pattern, url)
     * @return Gpf_Rpc_Action
     */
    public function checkUrlMatch(Gpf_Rpc_Params $params) {
        $action = new Gpf_Rpc_Action($params);
        $action->setErrorMessage($this->_("Pattern didn't matched the URL, check your pattern"));
        $action->setInfoMessage($this->_("Pattern matched the URL"));

        $pattern = $action->getParam("pattern");
        $url = $action->getParam("url");

        $url = str_replace('https://', '', $url);
        $url = str_replace('http://', '', $url);

        $directLinksBase = Pap_Tracking_DirectLinksBase::getInstance();
        $pattern = $directLinksBase->transformToPreg($pattern);

        if ($directLinksBase->isMatch($url, '', $pattern)) {
            $action->addOk();
        } else {
            $action->addError();
        }

        return $action;
    }
    /**
     *
     * @service affiliate write
     * @param ids, status
     * @return Gpf_Rpc_Action
     */
    public function changeStatus(Gpf_Rpc_Params $params) {
        $action = new Gpf_Rpc_Action($params);
        $action->setInfoMessage($this->_("Selected affiliate(s) status is changed"));
        $action->setErrorMessage($this->_("Failed to change status for selected affiliate(s)"));

        foreach ($action->getIds() as $id){
            try {
                $trackingCode = $this->createDbRowObject();
                $trackingCode->setId($id);
                $trackingCode->load();
                if ($trackingCode->getStatus() == $action->getParam("status")) {
                    continue;
                }
                $trackingCode->setStatus($action->getParam("status"));
                $trackingCode->update();
                $action->addOk();
            } catch(Gpf_DbEngine_NoRowException $e) {
                $action->addError();
            }
        }

        return $action;
    }
Ejemplo n.º 11
0
    /**
     *
     * @service affiliate_panel_settings write
     * @param $fields
     * @return Gpf_Rpc_Action
     */
    public function saveTree(Gpf_Rpc_Params $params) {
        $action = new Gpf_Rpc_Action($params);
        $action->setInfoMessage($this->_("Affiliate panel menu saved"));

        try {
            Gpf_Settings::set(Pap_Settings::AFFILIATE_MENU, $action->getParam(Pap_Settings::AFFILIATE_MENU));
            $action->addOk();
        } catch (QUnit_Exception $e) {
            $action->setErrorMessage($e);
            $action->addError();
        }

        return $action;
    }
Ejemplo n.º 12
0
 /**
  * @service wallpaper add
  * @param Gpf_Rpc_Params $params
  * @return Gpf_Rpc_Action
  */
 public function addUrlWallpaper(Gpf_Rpc_Params $params)
 {
     $action = new Gpf_Rpc_Action($params);
     $action->setInfoMessage("Wallpaper added");
     $url = $action->getParam('url');
     $name = basename($url);
     $wallpaper = new Gpf_Db_Wallpaper();
     $wallpaper->setAccountUserId(Gpf_Session::getAuthUser()->getAccountUserId());
     $wallpaper->setName($name);
     $wallpaper->setUrl($url);
     $wallpaper->insert();
     $action->addOk();
     return $action;
 }
Ejemplo n.º 13
0
 /**
  *
  * @service campaigns_categories write
  * @param $fields
  * @return Gpf_Rpc_Action
  */
 public function saveTree(Gpf_Rpc_Params $params) {
     $action = new Gpf_Rpc_Action($params);
     $action->setInfoMessage($this->_("Campaign categories structure was saved"));
     
     try {
         $tree = new Pap_Features_CampaignsCategories_Tree(false);
         $tree->save($action->getParam(self::CAMPAIGNS_CATEGORIES_TREE));
         $action->addOk();
     } catch (Gpf_Exception $e) {
         $action->setErrorMessage($e);
         $action->addError();
         return $action;
     }
     return $action;
 }
	/**
	 * @service affiliate_tracking_code write_own
	 * @param $ids
	 * @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) in %s(s)', '%s', $this->getDbRowObjectName()));
		$action->setInfoMessage($this->_('%s field(s) in %s(s) successfully saved', '%s', $this->getDbRowObjectName()));

		$fields = new Gpf_Data_RecordSet();
		$fields->loadFromArray($action->getParam("fields"));

		foreach ($fields as $field) {
			$dbRow = $this->loadAffTrackingCode($field);
			$dbRow->setStatus(Pap_Common_Constants::STATUS_PENDING);
			$dbRow->set($field->get("name"), $field->get("value"));
			$dbRow->save();
			$action->addOk();
		}

		return $action;
	}
Ejemplo n.º 15
0
    /**
     * @service coupon write
     * @param Id
     * @return Gpf_Rpc_Action
     */
    public function assignCoupon(Gpf_Rpc_Params $params) {
        $action = new Gpf_Rpc_Action($params);
        $action->setErrorMessage($this->_('Failed to assign coupon'));
        $action->setInfoMessage($this->_('Coupon was successfully assigned'));

        $coupon = new Pap_Features_Coupon_Coupon();
        $coupon->setId($action->getParam('id'));
        try {
            $unusedCoupon = $coupon->getUnusedCoupon();
            $unusedCoupon->setUserID(Gpf_Session::getAuthUser()->getPapUserId());
            $unusedCoupon->save();
            $action->addOk();
        } catch (Gpf_Exception $e) {
            $action->addError();
        }

        return $action;
    }
Ejemplo n.º 16
0
 /**
  * @service gadget write
  * @return Gpf_Rpc_Action
  */
 public function saveGadgets(Gpf_Rpc_Params $params)
 {
     $action = new Gpf_Rpc_Action($params);
     $action->setInfoMessage($this->_('Gadgets saved'));
     $gadgets = new Gpf_Data_RecordSet();
     $gadgets->loadFromArray($action->getParam('gadgets'));
     foreach ($gadgets as $gadgetRecord) {
         $gadget = new Gpf_Db_Gadget();
         $gadget->setPrimaryKeyValue($gadgetRecord->get("gadgetid"));
         try {
             $gadget->load();
         } catch (Gpf_Db_NoRowException $e) {
         }
         $gadget->fillFromRecord($gadgetRecord);
         $gadget->set('accountuserid', Gpf_Session::getAuthUser()->getAccountUserId());
         $gadget->save();
     }
     $action->addOk();
     return $action;
 }
    /**
     *
     * @service click delete
     * @param ids, status
     * @return Gpf_Rpc_Action
     */
    public function deleteClicks(Gpf_Rpc_Params $params) {
        $action = new Gpf_Rpc_Action($params);
        
        $date = array();
    	switch ($action->getParam("status")) {
    		case self::DATE_ONE_WEEK:
    			$filter = new Gpf_SqlBuilder_Filter(array("", "DP", "L7D"));
    	        $date = $filter->addDateValueToArray($date);
    	        $olderThan = "one week";
    			break;
    		case self::DATE_TWO_WEEKS:
    			$dateFrom = Gpf_DbEngine_Database::getDateString(
    			     Gpf_Common_DateUtils::getServerTime(
    			         mktime(0,0,0,date("m"), date("d") - 14, date("Y"))));
                $date = array("dateFrom" => $dateFrom);
                $olderThan = "two weeks";
    			break;
    		case self::DATE_ONE_MONTH:
    			$filter = new Gpf_SqlBuilder_Filter(array("", "DP", "L30D"));
                $date = $filter->addDateValueToArray($date);
                $olderThan = "one month";
    			break;
    	}
    	
    	$action->setInfoMessage($this->_("Raw clicks older than %s are deleted", $olderThan));
        $action->setErrorMessage($this->_("Failed to delete raw clicks"));
        
        $delete = new Gpf_SqlBuilder_DeleteBuilder();
        $delete->from->add(Pap_Db_Table_RawClicks::getName());
        $delete->where->add(Pap_Db_Table_RawClicks::DATETIME, "<", $date["dateFrom"]);
        

        try {
            $delete->delete();
            $action->addOk();
        } catch(Gpf_DbEngine_NoRowException $e) {
            $action->addError();
        }

        return $action;
    }
Ejemplo n.º 18
0
    /**
     * @service coupon write
     * @param ids, status
     * @return Gpf_Rpc_Action
     */
    public function changeStatus(Gpf_Rpc_Params $params) {
        $action = new Gpf_Rpc_Action($params);
        $action->setInfoMessage($this->_("Status successfully set to selected coupon(s)"));
        $action->setErrorMessage($this->_("Failed to set status selected coupon(s)"));

        $update = new Gpf_SqlBuilder_UpdateBuilder();
        $update->from->add(Pap_Db_Table_Coupons::getName());
        $update->set->add(Pap_Db_Table_Coupons::STATUS, $action->getParam("status"));

        foreach ($action->getIds() as $id){
            $update->where->add(Pap_Db_Table_Coupons::ID, "=", $id, "OR");
        }

        try {
            $update->execute();
            $action->addOk();
        } catch(Gpf_DbEngine_NoRowException $e) {
            $action->addError();
        }

        return $action;
    }
Ejemplo n.º 19
0
 /**
  * @service country write
  *
  * @param $id
  * @return Gpf_Rpc_Action
  */
 public function setDefaultCountry(Gpf_Rpc_Params $params)
 {
     $action = new Gpf_Rpc_Action($params);
     $action->setErrorMessage($this->_("Error changing default country"));
     $action->setInfoMessage($this->_("Default country changed"));
     try {
         $countryCode = $action->getParam('id');
         Gpf_Settings::set(Gpf_Settings_Gpf::DEFAULT_COUNTRY, $countryCode);
         $country = new Gpf_Db_Country();
         $country->setCountryCode($countryCode);
         $country->setAccountId(Gpf_Session::getAuthUser()->getAccountId());
         $country->loadFromData(array(Gpf_Db_Table_Countries::COUNTRY_CODE, Gpf_Db_Table_Countries::ACCOUNTID));
         if ($country->getStatus() != Gpf_Db_Country::STATUS_ENABLED) {
             $country->setStatus(Gpf_Db_Country::STATUS_ENABLED);
             $country->save();
         }
         $action->addOk();
     } catch (Exception $e) {
         $action->addError();
     }
     return $action;
 }
Ejemplo n.º 20
0
    /**
     * @service views write
     *
     * @param $id
     * @return Gpf_Rpc_Action
     */
    public function setDefaultView(Gpf_Rpc_Params $params) {
        $action = new Gpf_Rpc_Action($params);
        $action->setErrorMessage($this->_("Error changing default view"));
        $action->setInfoMessage($this->_("Default view changed"));

        try {
            $viewType = $action->getParam('id');
            $activeView = new Gpf_Db_ActiveView();
            $activeView->setViewType($viewType);
            $activeView->setAccountUserId(Gpf_Session::getAuthUser()->getUserData()->get(Gpf_Db_Table_Users::ID));
            $activeView->loadFromData(array(Gpf_Db_Table_ActiveViews::VIEWTYPE, Gpf_Db_Table_ActiveViews::ACCOUNTUSERID));

            if ($activeView->getActiveViewId() != Gpf_View_ViewService::DEFAULT_VIEW_ID) {
                $activeView->setActiveViewId(Gpf_View_ViewService::DEFAULT_VIEW_ID);
                $activeView->save();
            }
            $action->addOk();
        } catch (Exception $e) {
            $action->addError();
        }

        return $action;
    }
    /**
     * @service campaign write
     * @return Gpf_Rpc_Serializable
     */
    public function saveCategories(Gpf_Rpc_Params $params) {
        $action = new Gpf_Rpc_Action($params);
        $campaignId = $action->getParam('campaignid');

        $fields = $action->getParam('fields');
        for ($i=1; $i<count($fields); $i++) {
            $field = $fields[$i];
            $catgoryId = $field[0];
            $selected = $field[2];
            if ($selected == Gpf::YES) {
                $campaignInCateogry = new Pap_Db_CampaignInCategory();
                $campaignInCateogry->setCampaignId($campaignId);
                $campaignInCateogry->setCategoryId($catgoryId);
                $campaignInCateogry->insert();
            } else if ($selected == Gpf::NO) {
                $delete = new Gpf_SqlBuilder_DeleteBuilder();
                $delete->from->add(Pap_Db_Table_CampaignsInCategory::getName());
                $delete->where->add(Pap_Db_Table_CampaignsInCategory::CAMPAIGNID, '=', $campaignId);
                $delete->where->add(Pap_Db_Table_CampaignsInCategory::CATEGORYID, '=', $catgoryId);
                $delete->execute();
            }
        }
        
        $action->setInfoMessage('Cateogries saved');
        return $action;
    }
Ejemplo n.º 22
0
 /**
  * Set time offset between client and server and store it to session
  * Offset is computed as client time - server time
  *
  * @anonym
  * @service
  * @param Gpf_Rpc_Params $params
  * @return Gpf_Rpc_Action
  */
 public function syncTime(Gpf_Rpc_Params $params)
 {
     $action = new Gpf_Rpc_Action($params);
     Gpf_Session::getInstance()->setTimeOffset($action->getParam('offset') / 1000);
     $action->addOk();
     return $action;
 }
Ejemplo n.º 23
0
    /**
     * @service
     *
     * @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) in %s(s)', '%s', $this->getDbRowObjectName()));
        $action->setInfoMessage($this->_('%s field(s) in %s(s) successfully saved', '%s', $this->getDbRowObjectName()));

        $fields = new Gpf_Data_RecordSet();
        $fields->loadFromArray($action->getParam("fields"));


        foreach ($fields as $field) {
            $dbRow = $this->createDbRowObject();
            $dbRow->setPrimaryKeyValue($field->get('id'));
            $dbRow->load();
            $dbRow->set($field->get("name"), $field->get("value"));
            $dbRow->save();
            $action->addOk();
        }

        return $action;
    }
Ejemplo n.º 24
0
    /**
     * @service grid_view write
     *
     * @param $gridcode
     * @param $viewid
     * @return Gpf_Rpc_Action
     */
    public function saveActiveView(Gpf_Rpc_Params $params) {
        $action = new Gpf_Rpc_Action($params);
        $action->setInfoMessage($this->_("Active view changed"));
        $action->setErrorMessage($this->_("Error while changing active view"));

        $viewId = $action->getParam("viewid");
        if ($viewId != self::DEFAULT_VIEW_ID) {
            try {
                $view = new Gpf_Db_View();
                $view->set(Gpf_Db_Table_Views::ID, $viewId);
                $view->load();
            } catch (Gpf_DbEngine_NoRowException $e) {
                $action->setErrorMessage($this->_("View does not exist"));
                $action->addError();
                return $action;
            }
        }

        $activeViewsTable = Gpf_Db_Table_ActiveViews::getInstance();
        $activeViewsTable->saveActiveView($action->getParam('gridcode'), $viewId);

        $action->addOk();
        return $action;
    }
Ejemplo n.º 25
0
 /**
  * Delete uploaded file from database or files directory
  *
  * @service uploaded_file delete
  * @param Gpf_Rpc_Params $params
  * @return Gpf_Rpc_Action
  */
 public function deleteFile(Gpf_Rpc_Params $params)
 {
     $action = new Gpf_Rpc_Action($params);
     if ($action->existsParam('fileid') && $action->getParam('fileid') != '') {
         $dbRow = new Gpf_Db_File();
         $dbRow->setFileId($action->getParam('fileid'));
         try {
             $dbRow->load();
         } catch (Gpf_DbEngine_NoRow $e) {
             throw new Exception($this->_("Failed to delete file. File doesn't exist in database."));
         }
         try {
             $dbRow->delete();
         } catch (Gpf_Exception $e) {
             $action->addError();
             $action->setErrorMessage($this->_('Failed to delete file from database.'));
             return $action;
         }
     } else {
         $fileUrl = $action->getParam('fileurl');
         $fileName = substr($fileUrl, strrpos($fileUrl, '/') + 1);
         $file = new Gpf_Io_File(Gpf_Paths::getInstance()->getAccountDirectoryPath() . Gpf_Paths::FILES_DIRECTORY . $fileName);
         if (!$file->delete()) {
             $action->addError();
             $action->setErrorMessage($this->_('Failed to delete file.'));
         }
     }
     $action->addOk();
     return $action;
 }
    /**
     * @service user_comm_group add
     *
     * @param Gpf_Rpc_Params $params
     * @return Gpf_Rpc_Action
     */
    public function addUser(Gpf_Rpc_Params $params) {
        $action = new Gpf_Rpc_Action($params);
        $action->setInfoMessage($this->_('%s successfully add', $this->getRowName()));
        $campaignId = $action->getParam('campaignId');

        $cTable = Pap_Db_Table_Commissions::getInstance();
        $commissionGroup = $cTable->getDefaultCommissionGroup($campaignId);

        $this->addUserNoRpc($action, $campaignId, Gpf_Session::getAuthUser()->getPapUserId(), $commissionGroup, 'P', $action->getParam('sendNotification') == Gpf::YES);

        return $action;
    }
Ejemplo n.º 27
0
	/**
	 *
	 * @service commission write
	 * @param $fields
	 * @return Gpf_Rpc_Action
	 */
	public function deleteCommissionType(Gpf_Rpc_Params $params) {
		$action = new Gpf_Rpc_Action($params);
		$action->setErrorMessage($this->_('Failed to delete type, some transactions are connected to this type. Remove them first.'));
		$action->setInfoMessage($this->_('Commission type successfully removed'));

		$commTypeId = $action->getParam('commtypeid');

		$transaction = new Pap_Db_Transaction();
		$transaction->setCommissionTypeId($commTypeId);
		$collection = $transaction->loadCollection(array(Pap_Db_Table_Transactions::COMMISSIONTYPEID));
		if ($collection->getSize() > 0) {
			$action->addError();
			return $action;
		}

        $commissionType = new Pap_Db_CommissionType();
        $commissionType->setId($commTypeId);
        $commissionType->delete();

        $action->addOk();
        return $action;
	}
Ejemplo n.º 28
0
 /**
  * changes status of user(s)
  *
  * @service affiliate write
  * @param ids - array of IDs
  * @param status - new status
  * @return Gpf_Rpc_Action
  */
 public function changeStatusUsers(Gpf_Rpc_Params $params)
 {
     $action = new Gpf_Rpc_Action($params);
     $action->setErrorMessage($this->_('Failed to change status for %s user(s)'));
     $action->setInfoMessage($this->_('Status successfully changed for %s user(s)'));
     $status = $action->getParam("status");
     if (!in_array($status, array(Gpf_Db_User::APPROVED, Gpf_Db_User::PENDING, Gpf_Db_User::DECLINED))) {
         throw new Exception($this->_("Status does not have allowed value"));
     }
     foreach ($action->getIds() as $userid) {
         try {
             $result = $this->changeStatus($userid, $status);
             $action->addOk();
         } catch (Exception $e) {
             $action->addError();
         }
     }
     return $action;
 }
Ejemplo n.º 29
0
    /**
     * @service campaign write
     *
     * @param $fields
     * @return Gpf_Rpc_Action
     */
    public function saveFields(Gpf_Rpc_Params $params) {
        $action = new Gpf_Rpc_Action($params);
        $fields = new Gpf_Data_RecordSet();
        $fields->loadFromArray($action->getParam("fields"));

        $action->setErrorMessage($this->_('Failed to save %s field(s) in %s(s)', '%s', $this->getDbRowObjectName()));
        $action->setInfoMessage($this->_('%s field(s) in %s(s) successfully saved', '%s', $this->getDbRowObjectName()));

        foreach ($fields as $field) {
            $dbRow = $this->createDbRowObject();
            $dbRow->setPrimaryKeyValue($field->get('id'));
            $dbRow->load();

            if ($dbRow->getIsDefault() && $field->get("name") == "rstatus" && $field->get("value") != Pap_Db_Campaign::CAMPAIGN_STATUS_ACTIVE) {
                $action->setErrorMessage($this->_('You cannot deactivate default campaign'));
                $action->addError();
                continue;
            }

            $dbRow->set($field->get("name"), $field->get("value"));
            $dbRow->save();
            $action->addOk();
        }

        return $action;
    }
    /**
     * 
     * @param $params
     * @param $option
     * @return Gpf_Rpc_Action
     */
    private function maintenanceTable(Gpf_Rpc_Params $params, $option) {
    	$action = new Gpf_Rpc_Action($params);
        $dbMaintenance = new Gpf_SqlBuilder_DBMaintenance();

        try {
           $dbMaintenance->addTable($action->getParam("tableName"));
           $record = $dbMaintenance->maintenanceOne($option);
           $action->setInfoMessage($this->_("Operation")." ".$this->_($record->get("Op")." table ".$action->getParam("tableName")." finished with ".$record->get("Msg_type").": ".$record->get("Msg_text")));
           $action->addOk();
        } catch (Gpf_Exception $e) {
            $action->setErrorMessage($this->_($e));
            $action->addError();
        }

        return $action;
    }