addError() public method

public addError ( $count = 1 )
 /**
  *
  * @service export_file delete
  * @param Gpf_Rpc_Params $params
  * @return Gpf_Rpc_Action
  */
 public function deleteFiles(Gpf_Rpc_Params $params)
 {
     $action = new Gpf_Rpc_Action($params);
     $action->setInfoMessage($this->_("File(s) %s was successfully deleted"));
     $action->setErrorMessage($this->_("Could not delete %s file(s)"));
     foreach ($action->getIds() as $id) {
         try {
             $export = new Gpf_Db_Export();
             $export->setPrimaryKeyValue($id);
             $export->load();
             $fileName = $export->getFileName();
             $export->delete();
         } catch (Exception $e) {
             $action->addError();
             continue;
         }
         $filePath = Gpf_Paths::getInstance()->getAccountDirectoryPath() . Gpf_Csv_ImportExportService::EXPORT_DIRECTORY . $fileName;
         $file = new Gpf_Io_File($filePath);
         if ($file->isExists()) {
             if ($file->delete()) {
                 $action->addOk();
             } else {
                 $action->addError();
             }
         } else {
             $action->addOk();
         }
     }
     return $action;
 }
Exemplo n.º 2
0
 /**
  * @service banner read
  * @param $bannerId
  * @return Gpf_Rpc_Action
  */
 public function check(Gpf_Rpc_Params $params) {
     $response = new Gpf_Rpc_Action($params);
     $bannerFactory = new Pap_Common_Banner_Factory();
     $site = $bannerFactory->getBanner($params->get('id'));
     $site->setDestinationUrl(rtrim($params->get('url'), "/\\").'/');
     
     $response->setInfoMessage('Site replication .htaccess is working at this location');
     $response->setErrorMessage('Site replication .htaccess is not set up at this location or it is not working correctly. Please make sure that you have mod_rewrite and mod_proxy enabled in your Apache configuration');
     
     $testUser = new Pap_Common_User();
     $testUser->setRefId(Pap_Features_SiteReplication_Replicator::TEST_STRING);
     $request = new Gpf_Net_Http_Request();
     $request->setUrl($site->getUrl($testUser).Pap_Features_SiteReplication_Replicator::TEST_STRING);
     $httpClient = new Gpf_Net_Http_Client();
     try {
         $testResponse = $httpClient->execute($request);
         if ($testResponse->getBody() == Pap_Features_SiteReplication_Replicator::TEST_RESPONSE) {
             $response->addOk();
         } else {
             $response->addError();                
         }
     } catch (Gpf_Exception $e) {
         $response->addError();
     }
     
     return $response;
 }
Exemplo 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;
 }
Exemplo n.º 4
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;
    }
Exemplo n.º 5
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;
    }
 /**
  * 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;
 }
Exemplo n.º 7
0
 /**
  * Checks if signup form is ok
  *
  * @service affiliate_signup_setting read
  * @param Gpf_Rpc_Params $params
  * @return Gpf_Rpc_Action
  */
 public function checkSignupFieldsRpc(Gpf_Rpc_Params $params) {
     $action = new Gpf_Rpc_Action($params);
     try {
         $this->checkSignupFields();
         $action->addOk();
     } catch (Exception $e) {
         $action->setErrorMessage($e->getMessage());
         $action->addError();
     }
     return $action;
 }
Exemplo n.º 8
0
 /**
  *
  * @service filter delete
  * @param $filterid
  * @return Gpf_Rpc_Action
  */
 public function deleteFilters(Gpf_Rpc_Params $params)
 {
     $action = new Gpf_Rpc_Action($params);
     $action->setErrorMessage($this->_('Failed to delete %s filter(s)'));
     $action->setInfoMessage($this->_('%s filter(s) successfully deleted'));
     foreach ($action->getIds() as $filterid) {
         try {
             $this->delete($filterid);
         } catch (Exception $e) {
             $action->addError();
         }
     }
     return $action;
 }
Exemplo n.º 9
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;
 }
Exemplo n.º 10
0
 /**
  *
  * @service log delete
  * @param none
  * @return Gpf_Rpc_Action
  */
 public function deleteDebugEvents(Gpf_Rpc_Params $params)
 {
     $action = new Gpf_Rpc_Action($params);
     $action->setInfoMessage($this->_("Debug event(s) are deleted"));
     $action->setErrorMessage($this->_("No debug event(s) to delete"));
     $delete = new Gpf_SqlBuilder_DeleteBuilder();
     $delete->from->add(Gpf_Db_Table_Logs::getName());
     $delete->where->add(Gpf_Db_Table_Logs::LEVEL, "=", self::LOG_DEBUG);
     try {
         $delete->execute();
         $action->addOk();
     } catch (Gpf_DbEngine_NoRowException $e) {
         $action->addError();
     }
     return $action;
 }
Exemplo n.º 11
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;
    }
Exemplo n.º 12
0
 /**
  * @service wallpaper delete
  * @param Gpf_Rpc_Params $params
  * @return Gpf_Rpc_Action
  */
 public function delete(Gpf_Rpc_Params $params)
 {
     $action = new Gpf_Rpc_Action($params);
     $action->setErrorMessage($this->_('Failed to delete %s wallpaper(s)'));
     $action->setInfoMessage($this->_('%s wallpaper(s) successfully deleted'));
     foreach ($action->getIds() as $id) {
         try {
             $row = new Gpf_Db_Wallpaper();
             $row->setPrimaryKeyValue($id);
             $row->delete();
             $action->addOk();
         } catch (Exception $e) {
             $action->addError();
         }
     }
     return $action;
 }
Exemplo n.º 13
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;
    }
Exemplo n.º 14
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 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;
    }
Exemplo n.º 16
0
 /**
  *
  * @service mail_outbox write
  * @param $ids
  * @return Gpf_Rpc_Action
  */
 public function restartSendingMail(Gpf_Rpc_Params $params)
 {
     $action = new Gpf_Rpc_Action($params);
     $action->setErrorMessage($this->_('Failed to restart %s row(s)'));
     $action->setInfoMessage($this->_('%s row(s) successfully restarted'));
     foreach ($action->getIds() as $id) {
         try {
             $update = new Gpf_SqlBuilder_UpdateBuilder();
             $update->from->add(Gpf_Db_Table_MailOutbox::getName());
             $update->set->add(Gpf_Db_Table_MailOutbox::ERROR_MSG, self::RESTART_ERROR_MSG);
             $update->set->add(Gpf_Db_Table_MailOutbox::RETRY_NR, self::RESTART_RETRY_NR);
             $update->set->add(Gpf_Db_Table_MailOutbox::SCHNEDULET_AT, Gpf_Common_DateUtils::now());
             $update->where->add(Gpf_Db_Table_MailOutbox::ID, '=', $id, 'AND');
             $update->where->add(Gpf_Db_Table_MailOutbox::STATUS, '=', self::STATUS_PENDING);
             $update->executeOne();
             $action->addOk();
         } catch (Exception $e) {
             $action->addError();
         }
     }
     return $action;
 }
Exemplo n.º 17
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;
    }
Exemplo n.º 18
0
    /**
     *
     * @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;
    }
Exemplo 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;
 }
Exemplo 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 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;
    }
Exemplo n.º 22
0
 /**
  * @service merchant write
  * @param Gpf_Rpc_Params $params
  * @return Gpf_Rpc_Action
  */    
 public function setAsDefault(Gpf_Rpc_Params $params) {
 	$action = new Gpf_Rpc_Action($params);
     $action->setErrorMessage($this->_('Failed to set default merchant'));
     $action->setInfoMessage($this->_('Default merchant changed'));      
     foreach ($action->getIds() as $id) {
         try {
             Gpf_Settings::set(Pap_Settings::DEFAULT_MERCHANT_ID, $id);
             $action->addOk();
             return $action;
         } catch (Exception $e) {
         }
     }
     $action->addError();
     return $action;
 }
Exemplo n.º 23
0
 /**
  * @service
  * @param $ids
  * @return Gpf_Rpc_Action
  */
 public function deleteRows(Gpf_Rpc_Params $params) {
     $action = new Gpf_Rpc_Action($params);
     $errorMessages = "";
     foreach ($action->getIds() as $id) {
         try {
             $row = $this->createDbRowObject();
             $row->setPrimaryKeyValue($id);
             $this->deleteRow($row);
             $action->addOk();
         } catch (Exception $e) {
             $action->addError();
             $errorMessages .= '<br/>' . $e->getMessage();
         }
     }
      
     $action->setErrorMessage($this->_('Failed to delete %s %s(s)', '%s', $this->getDbRowObjectName()) .
                                 '<br/>' .
     $this->_('Error details: %s', $errorMessages));
     $action->setInfoMessage($this->_('%s %s(s) successfully deleted', '%s', $this->getDbRowObjectName()));
      
     return $action;
 }
Exemplo 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;
    }
Exemplo 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;
 }
 private function addUserNoRpc(Gpf_Rpc_Action $action, $campaignId, $userId, $commissionGroupId, $status, $sendNotification = false) {
     try {
         if ($sendNotification) {
             $this->addUserToGroupAndSendNotification($campaignId, $userId, $commissionGroupId, $status);
         } else {
             $this->addUserToGroup($campaignId, $userId, $commissionGroupId, $status);
         }
         Gpf_Plugins_Engine::extensionPoint('PostAffiliate.UserInCommissionGroup.addUser', Pap_Common_Campaign::getCampaignById($campaignId));
         $action->addOk();
     } catch (Exception $e) {
         $action->setErrorMessage($this->_('User is also in this or other commission group for this campaign'));
         $action->addError();
     }
 }
Exemplo 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;
	}
    /**
     * 
     * @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;
    }
Exemplo n.º 29
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;
 }
Exemplo n.º 30
0
    /**
     * @service campaign write
     * @return Gpf_Rpc_Action
     */
    public function setAsDefault(Gpf_Rpc_Params $params) {
        $action = new Gpf_Rpc_Action($params);
        $action->setErrorMessage($this->_('Failed to set default campaign'));
        $action->setInfoMessage($this->_('Default campaign changed'));

        foreach ($action->getIds() as $id) {
            try {
                $this->setCampaignDefault($id);
                $action->addOk();
                return $action;
            } catch (Exception $e) {
                $action->setErrorMessage($e->getMessage());
                $action->addError();
            }
        }
        return $action;
    }