get('formData'); $userCredentials = new ITS4YouGoogleCalendarSync_UserCredentials_Model(); $userCredentials->setType($formData['credentials_type']); $userCredentials->setClientId(trim($formData['clientId'])); $userCredentials->setClientSecret(trim($formData['clientSecret'])); $userCredentials->setSyncDirection(trim($formData['sync_direction'])); $userCredentials->save(); $currentUser = Users_Record_Model::getCurrentUserModel(); // check if value was saved $adb = PearDatabase::getInstance(); $sql = "SELECT client_id FROM its4you_google_credentials WHERE userid = ?"; $result = $adb->pquery($sql, array($currentUser->getId())); $success = false; if ($adb->num_rows($result) > 0) { $success = true; } $result = array( 'success' => $success, 'title' => vtranslate('LBL_SUCCESS', $this->getModuleName()), 'text' => vtranslate('LBL_CREDENTIALS_SAVED', $this->getModuleName()) ); $response = new Vtiger_Response(); $response->setResult($result); $response->emit(); } /** * @return string */ public function getModuleName() { return $this->moduleName; } }