@@ -1107,4 +1107,184 @@ public function mailquota_get_by_user($session_id, $client_id)
11071107
11081108}
11091109
1110+ //** xmpp functions -----------------------------------------------------------------------------------
1111+
1112+ public function xmpp_domain_get ($ session_id , $ primary_id )
1113+ {
1114+ global $ app ;
1115+
1116+ if (!$ this ->checkPerm ($ session_id , 'xmpp_domain_get ' )) {
1117+ throw new SoapFault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
1118+ return false ;
1119+ }
1120+ $ app ->uses ('remoting_lib ' );
1121+ $ app ->remoting_lib ->loadFormDef ('../mail/form/xmpp_domain.tform.php ' );
1122+ return $ app ->remoting_lib ->getDataRecord ($ primary_id );
1123+ }
1124+
1125+ public function xmpp_domain_add ($ session_id , $ client_id , $ params )
1126+ {
1127+ if (!$ this ->checkPerm ($ session_id , 'xmpp_domain_add ' )) {
1128+ throw new SoapFault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
1129+ return false ;
1130+ }
1131+ $ primary_id = $ this ->insertQuery ('../mail/form/xmpp_domain.tform.php ' , $ client_id , $ params );
1132+ return $ primary_id ;
1133+ }
1134+
1135+ public function xmpp_domain_update ($ session_id , $ client_id , $ primary_id , $ params )
1136+ {
1137+ if (!$ this ->checkPerm ($ session_id , 'xmpp_domain_update ' )) {
1138+ throw new SoapFault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
1139+ return false ;
1140+ }
1141+ $ affected_rows = $ this ->updateQuery ('../mail/form/xmpp_domain.tform.php ' , $ client_id , $ primary_id , $ params );
1142+ return $ affected_rows ;
1143+ }
1144+
1145+ public function xmpp_domain_delete ($ session_id , $ primary_id )
1146+ {
1147+ if (!$ this ->checkPerm ($ session_id , 'xmpp_domain_delete ' )) {
1148+ throw new SoapFault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
1149+ return false ;
1150+ }
1151+ $ affected_rows = $ this ->deleteQuery ('../mail/form/xmpp_domain.tform.php ' , $ primary_id );
1152+ return $ affected_rows ;
1153+ }
1154+
1155+ public function xmpp_user_get ($ session_id , $ primary_id )
1156+ {
1157+ global $ app ;
1158+
1159+ if (!$ this ->checkPerm ($ session_id , 'xmpp_user_get ' )) {
1160+ throw new SoapFault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
1161+ return false ;
1162+ }
1163+ $ app ->uses ('remoting_lib ' );
1164+ $ app ->remoting_lib ->loadFormDef ('../mail/form/xmpp_user.tform.php ' );
1165+ return $ app ->remoting_lib ->getDataRecord ($ primary_id );
1166+ }
1167+
1168+ public function xmpp_user_add ($ session_id , $ client_id , $ params ){
1169+ global $ app ;
1170+
1171+ if (!$ this ->checkPerm ($ session_id , 'xmpp_user_add ' )){
1172+ throw new SoapFault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
1173+ return false ;
1174+ }
1175+
1176+ $ jid_parts = explode ('@ ' , $ params ['jid ' ]);
1177+ $ tmp = $ app ->db ->queryOneRecord ("SELECT domain FROM xmpp_domain WHERE domain = ? " , $ jid_parts [1 ]);
1178+ if ($ tmp ['domain ' ] != $ jid_parts [1 ]) {
1179+ throw new SoapFault ('xmpp_domain_does_not_exist ' , 'XMPP domain - ' .$ jid_parts [1 ].' - does not exist. ' );
1180+ return false ;
1181+ }
1182+
1183+ $ affected_rows = $ this ->insertQuery ('../mail/form/xmpp_user.tform.php ' , $ client_id , $ params );
1184+ return $ affected_rows ;
1185+ }
1186+
1187+ public function xmpp_user_update ($ session_id , $ client_id , $ primary_id , $ params )
1188+ {
1189+ global $ app ;
1190+
1191+ if (!$ this ->checkPerm ($ session_id , 'xmpp_user_update ' ))
1192+ {
1193+ throw new SoapFault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
1194+ return false ;
1195+ }
1196+
1197+ $ jid_parts = explode ('@ ' , $ jid_parts ['jid ' ]);
1198+ $ tmp = $ app ->db ->queryOneRecord ("SELECT domain FROM xmpp_domain WHERE domain = ? " , $ jid_parts [1 ]);
1199+ if ($ tmp ['domain ' ] != $ jid_parts [1 ]) {
1200+ throw new SoapFault ('xmpp_domain_does_not_exist ' , 'Mail domain - ' .$ jid_parts [1 ].' - does not exist. ' );
1201+ return false ;
1202+ }
1203+
1204+ $ affected_rows = $ this ->updateQuery ('../mail/form/xmpp_user.tform.php ' , $ client_id , $ primary_id , $ params );
1205+ return $ affected_rows ;
1206+ }
1207+
1208+ public function xmpp_user_delete ($ session_id , $ primary_id )
1209+ {
1210+ if (!$ this ->checkPerm ($ session_id , 'xmpp_user_delete ' ))
1211+ {
1212+ throw new SoapFault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
1213+ return false ;
1214+ }
1215+ $ affected_rows = $ this ->deleteQuery ('../mail/form/xmpp_user.tform.php ' , $ primary_id );
1216+ return $ affected_rows ;
1217+ }
1218+
1219+ public function xmpp_domain_get_by_domain ($ session_id , $ domain ) {
1220+ global $ app ;
1221+ if (!$ this ->checkPerm ($ session_id , 'xmpp_domain_get_by_domain ' )) {
1222+ throw new SoapFault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
1223+ return false ;
1224+ }
1225+ if (!empty ($ domain )) {
1226+ $ sql = "SELECT * FROM xmpp_domain WHERE domain = ? " ;
1227+ $ result = $ app ->db ->queryAllRecords ($ sql , $ domain );
1228+ return $ result ;
1229+ }
1230+ return false ;
1231+ }
1232+
1233+ public function xmpp_domain_set_status ($ session_id , $ primary_id , $ status ) {
1234+ global $ app ;
1235+ if (!$ this ->checkPerm ($ session_id , 'xmpp_domain_set_status ' )) {
1236+ throw new SoapFault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
1237+ return false ;
1238+ }
1239+ if (in_array ($ status , array ('active ' , 'inactive ' ))) {
1240+ if ($ status == 'active ' ) {
1241+ $ status = 'y ' ;
1242+ } else {
1243+ $ status = 'n ' ;
1244+ }
1245+ $ sql = "UPDATE xmpp_domain SET active = ? WHERE domain_id = ? " ;
1246+ $ app ->db ->query ($ sql , $ status , $ primary_id );
1247+ $ result = $ app ->db ->affectedRows ();
1248+ return $ result ;
1249+ } else {
1250+ throw new SoapFault ('status_undefined ' , 'The status is not available ' );
1251+ return false ;
1252+ }
1253+ }
1254+
1255+ public function xmpp_user_get_by_domain ($ session_id , $ domain ) {
1256+ global $ app ;
1257+ if (!$ this ->checkPerm ($ session_id , 'xmpp_user_get_by_domain ' )) {
1258+ throw new SoapFault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
1259+ return false ;
1260+ }
1261+ if (!empty ($ domain )) {
1262+ $ sql = "SELECT * FROM xmpp_user WHERE domain = ? " ;
1263+ $ result = $ app ->db ->queryAllRecords ($ sql , $ domain );
1264+ return $ result ;
1265+ }
1266+ return false ;
1267+ }
1268+
1269+ public function xmpp_user_set_status ($ session_id , $ primary_id , $ status ) {
1270+ global $ app ;
1271+ if (!$ this ->checkPerm ($ session_id , 'xmpp_user_set_status ' )) {
1272+ throw new SoapFault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
1273+ return false ;
1274+ }
1275+ if (in_array ($ status , array ('active ' , 'inactive ' ))) {
1276+ if ($ status == 'active ' ) {
1277+ $ status = 'y ' ;
1278+ } else {
1279+ $ status = 'n ' ;
1280+ }
1281+ $ sql = "UPDATE xmpp_user SET active = ? WHERE domain_id = ? " ;
1282+ $ app ->db ->query ($ sql , $ status , $ primary_id );
1283+ $ result = $ app ->db ->affectedRows ();
1284+ return $ result ;
1285+ } else {
1286+ throw new SoapFault ('status_undefined ' , 'The status is not available ' );
1287+ return false ;
1288+ }
1289+ }
11101290?>
0 commit comments