本文整理汇总了PHP中Vtiger_Response::setError方法的典型用法代码示例。如果您正苦于以下问题:PHP Vtiger_Response::setError方法的具体用法?PHP Vtiger_Response::setError怎么用?PHP Vtiger_Response::setError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vtiger_Response
的用法示例。
在下文中一共展示了Vtiger_Response::setError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
/**
* Save date
* @param <Object> $request
* @return true if saved, false otherwise
*/
public function save(Vtiger_Request $request)
{
$response = new Vtiger_Response();
$moduleName = 'Settings:' . $request->getModule();
try {
$id = $request->get('holidayId');
$date = DateTimeField::convertToDBFormat($request->get('holidayDate'));
$name = $request->get('holidayName');
$type = $request->get('holidayType');
if (empty($name) || empty($date)) {
$response->setResult(array('success' => false, 'message' => vtranslate('LBL_FILL_FORM_ERROR', $moduleName)));
} else {
if (!empty($id)) {
if (Settings_PublicHoliday_Module_Model::edit($id, $date, $name, $type)) {
$response->setResult(array('success' => true, 'message' => vtranslate('LBL_EDIT_DATE_OK', $moduleName)));
} else {
$response->setResult(array('success' => false, 'message' => vtranslate('LBL_EDIT_DATE_ERROR', $moduleName)));
}
} else {
if (Settings_PublicHoliday_Module_Model::save($date, $name, $type)) {
$response->setResult(array('success' => true, 'message' => vtranslate('LBL_NEW_DATE_OK', $moduleName)));
} else {
$response->setResult(array('success' => false, 'message' => vtranslate('LBL_NEW_DATE_ERROR', $moduleName)));
}
}
}
} catch (Exception $e) {
$response->setError($e->getCode(), $e->getMessage());
}
$response->emit();
}
示例2: process
public function process(Vtiger_Request $request)
{
$error_code = '';
$error_message = '';
$success = true;
if (!$request->get('mod') && !$request->get('path')) {
$error_code = 'error-param';
$error_message = getTranslatedString("LBL_ERROR_PARAM", $moduleName);
$success = false;
}
//Get module's structure from manifest file
if ($request->get("mod")) {
$o_module = $this->getStructureFromExistantModule($request->get("mod"));
} elseif ($request->get("path")) {
$o_module = $this->getStructureFromZipPackage($request->get("path"));
}
//Make JSON response
$response = new Vtiger_Response();
if (!$success) {
$response->setError($error_code, $error_message);
} else {
$response->setResult(array('module' => $o_module, 'basedir' => $this->moduleBaseDir));
}
$response->emit();
}
示例3: process
public function process(Vtiger_Request $request) {
$mode = $request->getMode();
if (!empty($mode)) {
echo $this->invokeExposedMethod($mode, $request);
return;
}
$taxId = $request->get('taxid');
$type = $request->get('type');
if (empty($taxId)) {
$taxRecordModel = new Settings_Vtiger_TaxRecord_Model();
} else {
$taxRecordModel = Settings_Vtiger_TaxRecord_Model::getInstanceById($taxId, $type);
}
$fields = array('taxlabel','percentage','deleted');
foreach($fields as $fieldName) {
if($request->has($fieldName)) {
$taxRecordModel->set($fieldName,$request->get($fieldName));
}
}
$taxRecordModel->setType($type);
$response = new Vtiger_Response();
try {
$taxId = $taxRecordModel->save();
$recordModel = Settings_Vtiger_TaxRecord_Model::getInstanceById($taxId, $type);
$response->setResult(array_merge(array('_editurl' => $recordModel->getEditTaxUrl(), 'type' => $recordModel->getType()),$recordModel->getData()));
} catch (Exception $e) {
$response->setError($e->getCode(), $e->getMessage());
}
$response->emit();
}
示例4: process
public function process(Vtiger_Request $request)
{
$mode = $request->getMode();
$currentUser = Users_Record_Model::getCurrentUserModel();
if (!empty($mode)) {
echo $this->invokeExposedMethod($mode, $request);
return;
}
$id = $request->get('id');
$type = $request->get('view');
if (empty($id)) {
$recordModel = new Settings_Inventory_Record_Model();
} else {
$recordModel = Settings_Inventory_Record_Model::getInstanceById($id, $type);
}
$fields = $request->getAll();
foreach ($fields as $fieldName => $fieldValue) {
if ($request->has($fieldName) && !in_array($fieldName, ['module', 'parent', 'view', '__vtrftk', 'action'])) {
$recordModel->set($fieldName, $fieldValue);
}
}
$recordModel->setType($type);
$response = new Vtiger_Response();
try {
$id = $recordModel->save();
$recordModel = Settings_Inventory_Record_Model::getInstanceById($id, $type);
$response->setResult(array_merge(['_editurl' => $recordModel->getEditUrl(), 'row_type' => $currentUser->get('rowheight')], $recordModel->getData()));
} catch (Exception $e) {
$response->setError($e->getCode(), $e->getMessage());
}
$response->emit();
}
示例5: process
public function process(Vtiger_Request $request)
{
$parentModule = 'ITS4YouReports';
$recordIds = ITS4YouReports_Record_Model::getRecordsListFromRequest($request);
$reportsDeleteDenied = array();
foreach ($recordIds as $recordId) {
$recordModel = ITS4YouReports_Record_Model::getInstanceById($recordId);
$recordModel->setId($recordId);
if (!$recordModel->isDefault() && $recordModel->isEditable()) {
$success = $recordModel->delete();
if (!$success) {
$reportsDeleteDenied[] = vtranslate($recordModel->getName(), $parentModule);
}
} else {
$reportsDeleteDenied[] = vtranslate($recordModel->getName(), $parentModule);
}
}
$response = new Vtiger_Response();
if (empty($reportsDeleteDenied)) {
$response->setResult(array(vtranslate('LBL_REPORTS_DELETED_SUCCESSFULLY', $parentModule)));
} else {
$response->setError($reportsDeleteDenied, vtranslate('LBL_DENIED_REPORTS', $parentModule));
}
$response->emit();
}
示例6: process
public function process(Vtiger_Request $request)
{
$error_code = '';
$error_message = '';
$success = true;
$uploaded_file = null;
if (isset($_FILES["myfile"])) {
//Filter the file types , if you want.
if ($_FILES["myfile"]["error"] > 0) {
$success = false;
$error_code = "upload-error";
$error_message = $_FILES["file"]["error"];
} else {
//move the uploaded file to uploads folder;
move_uploaded_file($_FILES["myfile"]["tmp_name"], DIR_TEMP . $_FILES["myfile"]["name"]);
$uploaded_file = DIR_TEMP . $_FILES["myfile"]["name"];
}
} else {
$success = false;
$error_code = "file-empty";
$error_message = getTranslatedString("LBL_UPLOADED_FILE_NOT_DEFINED");
}
//Make JSON response
$response = new Vtiger_Response();
if (!$success) {
$response->setError($error_code, $error_message);
} else {
$response->setResult(array('file' => $uploaded_file));
}
$response->emit();
}
示例7: process
public function process(Vtiger_Request $request) {
$recordId = $request->get('record');
$qualifiedModuleName = $request->getModule(false);
if ($recordId) {
$recordModel = Settings_SysVars_Record_Model::getInstanceById($recordId, $qualifiedModuleName);
} else {
$recordModel = Settings_SysVars_Record_Model::getCleanInstance($qualifiedModuleName);
}
$editableFields = $recordModel->getEditableFields();
foreach ($editableFields as $fieldName => $fieldModel) {
$recordModel->set($fieldName, $request->get($fieldName));
}
$response = new Vtiger_Response();
try {
$recordModel->save();
$response->setResult(array(vtranslate('LBL_SAVED_SUCCESSFULLY', $qualifiedModuleName)));
} catch (Exception $e) {
$response->setError($e->getMessage());
}
$response->emit();
}
示例8: process
public function process(Vtiger_Request $request)
{
$recordId = $request->get('record');
$qualifiedModuleName = $request->getModule(false);
if ($recordId) {
$recordModel = Settings_MailConverter_Record_Model::getInstanceById($recordId);
} else {
$recordModel = Settings_MailConverter_Record_Model::getCleanInstance();
}
$recordModel->set('scannerOldName', $request->get('scannerOldName'));
$fieldsList = $recordModel->getModule()->getFields();
foreach ($fieldsList as $fieldName => $fieldModel) {
$recordModel->set($fieldName, $request->get($fieldName));
}
$status = $recordModel->save();
$response = new Vtiger_Response();
if ($status) {
$result = array('message' => vtranslate('LBL_SAVED_SUCCESSFULLY', $qualifiedModuleName));
$result['id'] = $recordModel->getId();
$response->setResult($result);
} else {
$response->setError(vtranslate('LBL_CONNECTION_TO_MAILBOX_FAILED', $qualifiedModuleName));
}
$response->emit();
}
示例9: process
public function process(Vtiger_Request $request)
{
// SalesPlatform.ru begin
require_once 'includes/SalesPlatform/NetIDNA/idna_convert.class.php';
// SalesPlatform.ru end
$outgoingServerSettingsModel = Settings_Vtiger_Systems_Model::getInstanceFromServerType('email', 'OutgoingServer');
$loadDefaultSettings = $request->get('default');
if ($loadDefaultSettings == "true") {
$outgoingServerSettingsModel->loadDefaultValues();
} else {
$outgoingServerSettingsModel->setData($request->getAll());
}
$response = new Vtiger_Response();
// SalesPlatform.ru begin
$idn = new idna_convert();
$server_username = $idn->encode(vtlib_purify($request->get('server')));
$from_email_field = $idn->encode(vtlib_purify($request->get('from_email_field')));
$request->set('server_username', $server_username);
$request->set('from_email_field', $from_email_field);
// SalesPlatform.ru end
try {
$id = $outgoingServerSettingsModel->save($request);
$data = $outgoingServerSettingsModel->getData();
$response->setResult($data);
} catch (Exception $e) {
$response->setError($e->getCode(), $e->getMessage());
}
$response->emit();
}
示例10: process
public function process(Vtiger_Request $request)
{
$viewer = $this->getViewer($request);
$moduleName = $request->getModule();
$qualifiedModuleName = $request->getModule(false);
if (!$request->get("label") && !$request->get("block") || !$request->get("languages")) {
//Make JSON response
$response = new Vtiger_Response();
$response->setError('error-param', getTranslatedString("LBL_ERROR_PARAM", $moduleName));
$response->emit();
exit;
}
$languages = trim($request->get("languages"));
$a_languages = explode(",", $languages);
$a_block = $request->get("block");
//Repair bug with utf8 characters
if (!is_array($a_block)) {
$oldValue = Zend_Json::$useBuiltinEncoderDecoder;
Zend_Json::$useBuiltinEncoderDecoder = true;
$a_block = Zend_Json::decode($a_block);
Zend_Json::$useBuiltinEncoderDecoder = $oldValue;
foreach ($a_block as &$val) {
$val = utf8_encode($val);
}
}
$viewer->assign('MODULE', $moduleName);
$viewer->assign('QUALIFIED_MODULE', $qualifiedModuleName);
$viewer->assign('LIST_PARENT_TABS', $a_parent_tabs);
$viewer->assign('LIST_MODULES', $a_modules);
$viewer->assign('LIST_MANIFEST_TEMPLATES', $a_manifest_templates);
$viewer->assign('LIST_DIR_TEMPLATES', $a_dir_templates);
$viewer->assign('a_block', $a_block);
$viewer->assign('a_languages', $a_languages);
echo $viewer->view('EditBlockPopup.tpl', $qualifiedModuleName, true);
}
示例11: process
public function process(Vtiger_Request $request)
{
$recordId = $request->get('record');
$qualifiedModuleName = $request->getModule(false);
$response = new Vtiger_Response();
if ($recordId) {
$status = Settings_SMSNotifier_Module_Model::deleteRecords(array($recordId));
if ($status) {
$response->setResult(array(vtranslate('LBL_DELETED_SUCCESSFULLY'), $qualifiedModuleName));
} else {
$response->setError(vtranslate('LBL_DELETE_FAILED', $qualifiedModuleName));
}
} else {
$response->setError(vtranslate('LBL_INVALID_RECORD', $qualifiedModuleName));
}
$response->emit();
}
示例12: process
public function process(Vtiger_Request $request)
{
$response = new Vtiger_Response();
$qualifiedModuleName = $request->getModule(false);
$updatedFields = $request->get('updatedFields');
$moduleModel = Settings_Vtiger_ConfigModule_Model::getInstance();
if ($updatedFields) {
$moduleModel->set('updatedFields', $updatedFields);
$status = $moduleModel->save();
if ($status === true) {
$response->setResult(array($status));
} else {
$response->setError(vtranslate($status, $qualifiedModuleName));
}
} else {
$response->setError(vtranslate('LBL_FIELDS_INFO_IS_EMPTY', $qualifiedModuleName));
}
$response->emit();
}
示例13: process
public function process(Vtiger_Request $request)
{
$recordId = $request->get('record');
$qualifiedModuleName = $request->getModule(false);
$recordModel = Settings_MailConverter_Record_Model::getInstanceById($recordId);
$status = $recordModel->scanNow();
$response = new Vtiger_Response();
if (is_bool($status) && $status) {
$result = array('message' => vtranslate('LBL_SCANNED_SUCCESSFULLY', $qualifiedModuleName));
$result['id'] = $recordModel->getId();
$response->setResult($result);
} else {
if ($status) {
$response->setError($status);
} else {
$response->setError(vtranslate($request->getModule(), $qualifiedModuleName) . ' ' . vtranslate('LBL_IS_IN_RUNNING_STATE', $qualifiedModuleName));
}
}
$response->emit();
}
示例14: maxCreatedOn
protected function maxCreatedOn(Vtiger_Request $request)
{
$modelInstance = Settings_ExtensionStore_Extension_Model::getInstance();
$promotions = $modelInstance->getMaxCreatedOn('Promotion', 'max', 'createdon');
$response = new Vtiger_Response();
if ($promotions['success'] != 'true') {
$response->setError('', $promotions['error']);
} else {
$response->setResult($promotions['response']);
}
$response->emit();
}
示例15: process
public function process(Vtiger_Request $request)
{
$response = new Vtiger_Response();
$recordId = $request->get('record');
if (!empty($recordId)) {
$record = Settings_SPCMLConnector_Record_Model::getInstance($recordId);
$record->delete();
} else {
$response->setError(NULL, 'not record id');
}
$response->emit();
}