+
+/**
+ * @brief Backward-compatible XML formatting for ping.php output
+ * @deprecated
+ *
+ * @param array $data The initial ping data array
+ * @param int $sysnotify_count Number of unseen system notifications
+ * @param array $notifs Complete list of notification
+ * @param array $sysmsgs List of system notice messages
+ * @param array $sysmsgs_info List of system info messages
+ * @param int $groups_unseen Number of unseen group items
+ * @param int $forums_unseen Number of unseen forum items
+ * @return array XML-transform ready data array
+ */
+function ping_format_xml_data($data, $sysnotify, $notifs, $sysmsgs, $sysmsgs_info, $groups_unseen, $forums_unseen)
+{
+ $notifications = array();
+ foreach($notifs as $key => $notif) {
+ $notifications[$key . ':note'] = $notif['message'];
+
+ $notifications[$key . ':@attributes'] = array(
+ 'id' => $notif['id'],
+ 'href' => $notif['href'],
+ 'name' => $notif['name'],
+ 'url' => $notif['url'],
+ 'photo' => $notif['photo'],
+ 'date' => $notif['date'],
+ 'seen' => $notif['seen'],
+ 'timestamp' => $notif['timestamp']
+ );
+ }
+
+ $sysmsg = array();
+ foreach ($sysmsgs as $key => $m){
+ $sysmsg[$key . ':notice'] = $m;
+ }
+ foreach ($sysmsgs_info as $key => $m){
+ $sysmsg[$key . ':info'] = $m;
+ }
+
+ $data['notif'] = $notifications;
+ $data['@attributes'] = array('count' => $sysnotify_count + $data['intro'] + $data['mail'] + $data['register']);
+ $data['sysmsgs'] = $sysmsg;
+
+ if ($data['register'] == 0) {
+ unset($data['register']);
+ }
+
+ $groups = array();
+ if (count($groups_unseen)) {
+ foreach ($groups_unseen as $key => $item) {
+ $groups[$key . ':group'] = $item['count'];
+ $groups[$key . ':@attributes'] = array('id' => $item['id']);
+ }
+ $data['groups'] = $groups;
+ }
+
+ $forums = array();
+ if (count($forums_unseen)) {
+ foreach ($forums_unseen as $key => $item) {
+ $forums[$count . ':forum'] = $item['count'];
+ $forums[$count . ':@attributes'] = array('id' => $item['id']);
+ }
+ $data['forums'] = $forums;
+ }
+
+ return $data;
+}