本文整理汇总了PHP中Gpf_Rpc_Form::setErrorMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP Gpf_Rpc_Form::setErrorMessage方法的具体用法?PHP Gpf_Rpc_Form::setErrorMessage怎么用?PHP Gpf_Rpc_Form::setErrorMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gpf_Rpc_Form
的用法示例。
在下文中一共展示了Gpf_Rpc_Form::setErrorMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
private function validate(Gpf_Rpc_Form $form) {
require_once('../include/Pap/Features/ReCaptcha/recaptchalib.php');
if ((is_null($form->getFieldValue("recaptcha_challenge_field")) || $form->getFieldValue("recaptcha_challenge_field") == '') &&
(is_null($form->getFieldValue("recaptcha_response_field")) || $form->getFieldValue("recaptcha_response_field") == '')) {
$form->setErrorMessage($this->_("The reCAPTCHA isn't configured correctly") . ': ' . $this->_("wrong public key or check template 'signup_fields.tpl' if contains: {widget id=\"recaptcha\"}"));
return;
}
if (is_null($form->getFieldValue("recaptcha_response_field")) || $form->getFieldValue("recaptcha_response_field") == '') {
$form->setErrorMessage($this->_("The reCAPTCHA wasn't entered correctly"));
return;
}
$resp = recaptcha_check_answer (Gpf_Settings::get(Pap_Settings::RECAPTCHA_PRIVATE_KEY),
$_SERVER["REMOTE_ADDR"],
$form->getFieldValue("recaptcha_challenge_field"),
$form->getFieldValue("recaptcha_response_field"));
if (!$resp->is_valid && $resp->error == 'incorrect-captcha-sol') {
$form->setErrorMessage($this->_("The reCAPTCHA wasn't entered correctly"));
return;
}
if (!$resp->is_valid && $resp->error == 'invalid-site-private-key') {
$form->setErrorMessage($this->_("The reCAPTCHA isn't configured correctly") . ': ' . $this->_("wrong private key"));
return;
}
if (!$resp->is_valid) {
$form->setErrorMessage($this->_("The reCAPTCHA isn't configured correctly") . " Error: " . $resp->error);
return;
}
}
示例2: save
/**
* @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;
}
示例3: execute
protected function execute(Gpf_Rpc_Params $params)
{
$form = new Gpf_Rpc_Form($params);
if (!$form->getFieldValue(self::LICENSE_AGREE_NAME)) {
$form->setFieldError(self::LICENSE_AGREE_NAME, $this->_('You have to agree license.'));
$form->setErrorMessage($this->_('You have to agree license.'));
return $form;
}
try {
$setting = new Gpf_File_Settings();
$settingsArray = $setting->getAll();
if (is_array($settingsArray) && empty($settingsArray)) {
$this->addDBDefaultSettings($setting);
}
$setting->saveAll();
@chmod($setting->getSettingFileName(), 0777);
} catch (Exception $e) {
$form->setErrorMessage($this->_('Could not create settings file. Reason: %s', $e->getMessage()));
return $form;
}
try {
$info = $this->licenseManager->getLicense(trim($form->getFieldValue(self::LICENSE_ID_NAME)));
if (!$info->isApplicationCodeValid()) {
$form->setErrorMessage($this->_('Invalid license.'));
return $form;
}
} catch (Exception $e) {
$form->setErrorMessage($this->_('Could not validate license. Reason: %s', $e->getMessage()));
return $form;
}
$this->setNextStep($form);
return $form;
}
示例4: save
public function save(Gpf_Rpc_Form $form) {
$minSaleValueForBonus = $form->getFieldValue(self::MIN_SALE_VALUE_FOR_BONUS);
$bonusValue = $form->getFieldValue(self::BONUS_VALUE);
if (is_float($minSaleValueForBonus)) {
$form->setErrorMessage($this->_('Wrong format used for Bonus for sales'));
return;
}
if ($minSaleValueForBonus < 0 && $minSaleValueForBonus != -1) {
$form->setErrorMessage($this->_('Bonus for sales value must be greater than 0 or must equals to -1'));
return;
}
if (is_float($bonusValue)) {
$form->setErrorMessage($this->_('Wrong format used for Bonus commission value'));
return;
}
if ($bonusValue < 0) {
$form->setErrorMessage($this->_('Bonus commission must be greater or equal to 0'));
return;
}
$commTypeAttr = Pap_Db_Table_CommissionTypeAttributes::getInstance();
$commTypeAttr->setCommissionTypeAttributeValue($form->getFieldValue('Id'), self::MIN_SALE_VALUE_FOR_BONUS,
$minSaleValueForBonus);
$commTypeAttr->setCommissionTypeAttributeValue($form->getFieldValue('Id'), self::BONUS_VALUE,
$bonusValue);
}
示例5: validate
/**
* @return boolean
*/
public function validate()
{
$errorMsg = false;
foreach ($this->validators as $fieldName => $fieldValidator) {
if (!$fieldValidator->validate($this->form->getFieldValue($fieldName))) {
$errorMsg = true;
$this->form->setFieldError($fieldName, $fieldValidator->getMessage());
}
}
if ($errorMsg) {
$this->form->setErrorMessage($this->_('There were errors, please check highlighted fields'));
}
return !$errorMsg;
}
示例6: report
/**
* @service report_problem write
*
* @param Gpf_Rpc_Params $params
* @return Gpf_Rpc_Form
*/
public function report(Gpf_Rpc_Params $params) {
$form = new Gpf_Rpc_Form($params);
$subject = 'PAP4: '.$form->getFieldValue('subject');
$message = 'License: '.$form->getFieldValue('licenseId').'<br>'.
'Product: <b>'.Gpf_Settings::get(Pap_Settings::BRANDING_TEXT_POST_AFFILIATE_PRO).' '.Gpf_Settings::get(Gpf_Settings_Gpf::VARIATION).'</b><br>'.
'Version: <b>'.Gpf_Application::getInstance()->getVersion().'</b><br>'.
'Url: <a href="'.Gpf_Paths::getInstance()->getFullBaseServerUrl().'">'.Gpf_Paths::getInstance()->getFullBaseServerUrl().'</a><br>'.
'-------------------------------------------------------------------------------<br>'.
$form->getFieldValue('message');
$mail = new Gpf_Db_Mail();
$mail->setSubject($subject);
$mail->setHtmlBody($message);
$mail->setFromMail($form->getFieldValue('email'));
$mail->setRecipients("support@qualityunit.com");
try {
$mail->insert();
$mail->scheduleNow(true);
$form->setInfoMessage($this->_("Email sent"));
} catch (Exception $e) {
$form->setErrorMessage($this->_("Error while sending mail"));
}
return $form;
}
示例7: save
/**
* @service filter write
* @param $fields
*/
public function save(Gpf_Rpc_Params $params) {
$form = new Gpf_Rpc_Form($params);
$filter = new Gpf_Db_Filter();
$filter->setPrimaryKeyValue($form->getFieldValue("Id"));
//TODO: check if filterid belongs to authUser
try {
$filter->load();
} catch (Gpf_DbEngine_NoRow $e) {
$form->setErrorMessage($this->_("Filter does not exist"));
return $form;
}
$form->fill($filter);
try {
$filter->save();
$this->saveFilterPresets($form, $filter->getPrimaryKeyValue());
} catch (Exception $e) {
$form->setErrorMessage($e->getMessage());
return $form;
}
$form->load($filter);
$form->setInfoMessage($this->_("Filter saved"));
return $form;
}
示例8: execute
protected function execute(Gpf_Rpc_Params $params)
{
$form = new Gpf_Rpc_Form($params);
$updateFile = $this->getNextUpdateFile();
if ($updateFile !== null) {
try {
Gpf_Install_CreateDatabaseTask::setStorageEngine($this->createDatabase());
$updateFile->execute();
} catch (Exception $e) {
$form->setErrorMessage($e->getMessage());
return $form;
}
$this->setResponseType($form, self::PART_DONE_TYPE);
$form->setInfoMessage($this->_('Updated to version %s-%s', $updateFile->getApplication(), $updateFile->getVersion()));
return $form;
}
$task = $this->getUpdateAccountTask();
try {
$task->run();
} catch (Gpf_Tasks_LongTaskInterrupt $e) {
$this->setResponseType($form, self::PART_DONE_TYPE);
$form->setInfoMessage($e->getMessage());
return $form;
} catch (Exception $e) {
$form->setErrorMessage($this->_('Error during application update (%s)', $e->getMessage()));
return $form;
}
$this->setNextStep($form);
return $form;
}
示例9: saveRolePrivileges
/**
* Save role privileges
*
* @service role write
* @param Gpf_Rpc_Params $params
* @return Gpf_Rpc_Form
*/
public function saveRolePrivileges(Gpf_Rpc_Params $params)
{
$form = new Gpf_Rpc_Form($params);
$role = new Gpf_Db_Role();
$role->setId($form->getFieldValue('roleid'));
$role->load();
if (!strlen($role->getAccountId())) {
$form->setErrorMessage($this->_('It is not possible to changes privileges for default role %s', $role->getName()));
return $form;
}
//delete all privileges for selected role
Gpf_Db_Table_RolePrivileges::getInstance()->deleteAllPrivileges($role->getId());
//insert all privileges again to database
$objects = new Gpf_Data_RecordSet();
$objects->loadFromArray($form->getFieldValue('objects'));
foreach ($objects as $record) {
$rights = explode(',', $record->get('privileges'));
foreach ($rights as $right) {
$privilege = new Gpf_Db_RolePrivilege();
$privilege->setObject($record->get('object'));
$privilege->setRoleId($role->getId());
$privilege->setPrivilege($right);
$privilege->insert();
}
}
$form->setInfoMessage($this->_('Changes saved'));
return $form;
}
示例10: save
/**
* @service tracking_mod_rewrite write
* @param $fields
*/
public function save(Gpf_Rpc_Params $params) {
$form = new Gpf_Rpc_Form($params);
$prefix = $form->getFieldValue(Pap_Settings::MOD_REWRITE_PREFIX_SETTING_NAME);
$separator = $form->getFieldValue(Pap_Settings::MOD_REWRITE_SEPARATOR_SETTING_NAME);
$suffix = $form->getFieldValue(Pap_Settings::MOD_REWRITE_SUFIX_SETTING_NAME);
$htaccessCode = $this->generateHtaccessCode($prefix, $separator, $suffix);
if($separator == '') {
$form->setErrorMessage("Separator cannot be empty!");
return $form;
}
Gpf_Settings::set(Pap_Settings::MOD_REWRITE_PREFIX_SETTING_NAME, $prefix);
Gpf_Settings::set(Pap_Settings::MOD_REWRITE_SEPARATOR_SETTING_NAME, $separator);
Gpf_Settings::set(Pap_Settings::MOD_REWRITE_SUFIX_SETTING_NAME, $suffix);
$form->setField("htaccess_code", $htaccessCode);
$form->setInfoMessage($this->_("Changes saved"));
Pap_Db_Table_CachedBanners::clearCachedBanners();
return $form;
}
示例11: save
/**
* @service theme write
*
* @return Gpf_Rpc_Action
*/
public function save(Gpf_Rpc_Params $params) {
$form = new Gpf_Rpc_Form($params);
$newThemeId = str_replace(' ', '_', $form->getFieldValue('name'));
$srcTheme = new Gpf_Desktop_Theme($form->getFieldValue('Id')
, $form->getFieldValue('panelName'));
$srcPath = $srcTheme->getThemePath();
$targetPath = new Gpf_Io_File($srcPath->getParent().$newThemeId);
try{
$targetPath->mkdir();
$srcPath->recursiveCopy($targetPath);
$newTheme = new Gpf_Desktop_Theme($newThemeId
, $form->getFieldValue('panelName'));
$newTheme->load();
$newTheme->setName($form->getFieldValue('name'));
$newTheme->setAuthor($form->getFieldValue('author'));
$newTheme->setUrl($form->getFieldValue('url'));
$newTheme->setDescription($form->getFieldValue('description'));
$newTheme->setBuiltIn(false);
$newTheme->save();
}catch(Gpf_Exception $ex){
$form->setErrorMessage($ex->getMessage());
}
$form->setField('themeId', $newThemeId);
return $form;
}
示例12: processStep
/**
*
* @return Gpf_Rpc_Form
*/
private function processStep()
{
$form = new Gpf_Rpc_Form();
if (!$this->getRequirements()->isValid()) {
$form->setErrorMessage($this->_("Please check system requirements and try again"));
}
return $form;
}
示例13: checkAndSavePayoutInvoice
protected function checkAndSavePayoutInvoice(Gpf_Rpc_Form $form, $templateSource, $settingName) {
$template = new Gpf_Templates_Template($templateSource, '', Gpf_Templates_Template::FETCH_TEXT);
if ($template->isValid()) {
Gpf_Settings::set($settingName, $templateSource);
$form->setInfoMessage($this->getInfoMessage());
return;
}
$form->setErrorMessage($this->_('Invalid Smarty syntax. More information: ') .
Gpf_Application::getKnowledgeHelpUrl(Pap_Common_Constants::SMARTY_SYNTAX_URL));
}
示例14: save
/**
* @anonym
* @service custom_separator write
* @param Gpf_Rpc_Params $params
* @return Gpf_Rpc_Form
*/
public function save(Gpf_Rpc_Params $params) {
$form = new Gpf_Rpc_Form($params);
if (SignupToPrivateCampaigns_Main::getHandlerInstance()->getCampaignsIdsFromString($form->getFieldValue(self::CAMPAIGNS_IDS)) === false) {
$form->setErrorMessage('Campaigns IDs must be 8 characters long and be divided by comma!');
return $form;
}
Gpf_Settings::set(self::CAMPAIGNS_IDS, str_replace(' ', '',$form->getFieldValue(self::CAMPAIGNS_IDS)));
$form->setInfoMessage($this->_('Signup To Private Campaigns plugin configuration saved'));
return $form;
}
示例15: getUser
/**
* @param Gpf_Rpc_Form $form
* @return Pap_Common_User
*/
private function getUser(Gpf_Rpc_Form $form) {
$user = new Pap_Common_User();
try {
$user->setId(Gpf_Session::getAuthUser()->getPapUserId());
$user->load();
} catch (Gpf_Exception $e) {
$form->setErrorMessage($e->getMessage());
return null;
}
return $user;
}