existsParam() public method

public existsParam ( $name )
    /**
     * @service affiliate_panel_settings write
     *
     * @return Gpf_Rpc_Action
     */
    public function setDefaultTheme(Gpf_Rpc_Params $params) {
        $action = new Gpf_Rpc_Action($params);
        $action->setErrorMessage($this->_("Error changing default theme"));
        $action->setInfoMessage($this->_("Default theme changed"));

        try {
            Gpf_Settings::set($action->getParam("settingName"), $action->getParam('themeId'));
            if ($action->existsParam('allAffiliates') && $action->getParam('allAffiliates') == Gpf::YES) {
                $this->updateThemeExistingAffiliates($action->getParam('themeId'));
            }
            $action->addOk();
        } catch (Exception $e) {
            $action->addError();
        }

        return $action;
    }
示例#2
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 template write
  * @param $fields
  * @return Gpf_Rpc_Action
  */
 public function deleteFile(Gpf_Rpc_Params $params)
 {
     $action = new Gpf_Rpc_Action($params);
     $templateName = $this->fixTemplateName($action->getParam("templatename"));
     $panelName = '';
     if ($action->existsParam("panelname")) {
         $panelName = $action->getParam("panelname");
     }
     if ($action->existsParam("theme") && $action->getParam("theme") != null && $action->getParam("theme") != "") {
         $theme = $action->getParam("theme");
         if ($theme == trim(Gpf_Paths::DEFAULT_THEME, '/')) {
             $action->setErrorMessage($this->_("Common template can not be deleted"));
             $action->addError();
             return $action;
         }
     } else {
         throw new Gpf_Exception("Theme not set");
     }
     $paths = Gpf_Paths::getInstance()->clonePaths($theme);
     $templateFile = new Gpf_Io_File($paths->getTemplatePath($templateName, $panelName));
     if ($templateFile->delete()) {
         $action->setInfoMessage($this->_("File deleted"));
         $action->addOk();
         return $action;
     }
     $action->setErrorMessage($this->_("File can not be deleted"));
     $action->addError();
     return $action;
 }
 /**
  * @service pdf write
  * @param Gpf_Rpc_Params $params
  * @return Gpf_Rpc_Action
  */
 public function savePdfFromHtml(Gpf_Rpc_Params $params) {
     $action = new Gpf_Rpc_Action($params);
     $action->setInfoMessage($this->_("Pdf saved"));
     
     if ($action->existsParam('html')) {
         $html = $action->getParam('html');
     } else {
         $action->setErrorMessage($this->_("Html data is not defined"));
         $action->addError();
         return $action;
     }
     
     if ($action->existsParam('fileName')) {
         $fileName = $action->getParam('fileName');
     } else {
         $action->setErrorMessage($this->_("File name is not defined"));
         $action->addError();
         return $action;
     }
     
     htmlspecialchars_decode($html);
     $this->generatePDF($html);
     
     if ($this->savePath != null) {
         if (@is_dir($this->savePath)) {
             chdir($this->savePath);
         } else {
             throw new Gpf_Exception($this->_("Path to save file '%s' not exist", $this->savePath));
         }
     } else {
     	throw new Gpf_Exception($this->_("Path to save file %s is null", $fileName));
     }
     
     try {
         $this->pdf->Output($fileName.".pdf", "F");
     } catch (Gpf_Exception $e) {
     	$action->setErrorMessage($this->_("Unable to create file %s%s.pdf", $this->savePath, $fileName));
     }
     
     $action->addOk();
     
     return $action;
 }