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