Esempio n. 1
0
 public function process(Vtiger_Request $request)
 {
     $tablePrefix = 'vtiger_';
     $unique_keyword = $request->get('unique_keyword');
     $sourceModule = $request->getForSql('source_module');
     $record = $request->getForSql('record');
     $feildName = $request->getForSql('field_name');
     $moduleName = $tablePrefix . $sourceModule;
     $db = PearDatabase::getInstance();
     $ExcludeSql = empty($record) || $record == 'null' ? '' : " AND " . $this->getKeyField($sourceModule) . " != " . $record;
     $sql = "SELECT {$feildName} FROM {$moduleName} WHERE {$feildName} = '" . $unique_keyword . "'" . $ExcludeSql;
     $result = $db->query($sql);
     $result = $db->num_rows($result);
     $response = new Vtiger_Response();
     $response->setEmitType(Vtiger_Response::$EMIT_JSON);
     if (!$result) {
         $response->setResult(array('success' => true, 'message' => vtranslate('LBL_RECORD_NONE')));
     } else {
         //存在重复记录
         $response->setResult(array('success' => false, 'message' => vtranslate('LBL_RECORD_EXIST')));
     }
     $response->emit();
 }