public static function initialize(aohs\AssetOperationHandlerService $service) { try { $service->listMessages(); if ($service->isSuccessful()) { $messages = $service->getListedMessages(); $temp_msg = array(); if (!($messages->message == NULL)) { if (!is_array($messages->message)) { $temp_msg[] = $messages->message; } else { $temp_msg = $messages->message; } foreach ($temp_msg as $message) { $id = $message->id; $to = $message->to; $from = $message->from; $date = $message->date; $subject = trim($message->subject); $body = $message->body; self::$all_message_ids[] = $id; $message_obj = new Message($message); // store all messages self::$all_messages[] = $message_obj; self::$id_obj_map[$id] = $message_obj; // from whom? if (!isset($message_ids_from[$from])) { self::$message_ids_from[$from] = array(); } self::$message_ids_from[$from][] = $id; if ($from != 'system') { self::$non_system_messages[] = $message_obj; } if (self::DEBUG) { u\DebugUtility::out($message_obj->getType()); } if ($message_obj->getType() == Message::TYPE_EXPIRATION) { self::$asset_expiration_message[] = $message_obj; self::$asset_expiration_message_ids[] = $id; } else { if ($message_obj->getType() == Message::TYPE_PUBLISH) { self::$publish_messages[] = $message_obj; self::$publish_message_ids[] = $id; // no issues if (strpos($subject, "(0 issue(s))") !== false) { if (self::DEBUG) { echo "L::121 " . $id . BR; } self::$publish_message_ids_without_issues[] = $id; self::$publish_messages_without_issues[] = $message_obj; } else { if (self::DEBUG) { echo "L::124 " . $id . BR; } self::$publish_message_ids_with_issues[] = $id; self::$publish_messages_with_issues[] = $message_obj; } } else { if ($message_obj->getType() == Message::TYPE_UNPUBLISH) { self::$unpublish_messages[] = $message_obj; self::$unpublish_message_ids[] = $id; // no issues if (strpos($subject, "(0 issue(s))") !== false) { self::$unpublish_message_ids_without_issues[] = $id; self::$unpublish_messages_without_issues[] = $message_obj; } else { self::$unpublish_message_ids_with_issues[] = $id; self::$unpublish_messages_with_issues[] = $message_obj; } } else { if ($message_obj->getType() == Message::TYPE_SUMMARY) { self::$summary_messages[] = $message_obj; self::$summary_message_ids[] = $id; // 0 failures if (strpos($subject, "(0 failures)") !== false) { self::$summary_message_ids_no_failures[] = $id; self::$summary_messages_no_failures[] = $message_obj; } else { self::$summary_message_ids_with_failures[] = $id; self::$summary_messages_with_failures[] = $message_obj; } } else { if ($message_obj->getType() == Message::TYPE_WORKFLOW) { self::$workflow_messages[] = $message_obj; self::$workflow_message_ids[] = $id; // is complete if (strpos($subject, "is complete") !== false) { self::$workflow_message_ids_is_complete[] = $id; self::$workflow_messages_complete[] = $message_obj; } else { self::$workflow_message_ids_other[] = $id; self::$workflow_messages_other[] = $message_obj; } } else { self::$other_messages[] = $message_obj; self::$other_message_ids[] = $id; } } } } } // date } usort(self::$all_messages, self::NAME_SPACE . "\\" . 'Message::compare'); usort(self::$publish_messages, self::NAME_SPACE . "\\" . 'Message::compare'); usort(self::$unpublish_messages, self::NAME_SPACE . "\\" . 'Message::compare'); usort(self::$workflow_messages, self::NAME_SPACE . "\\" . 'Message::compare'); usort(self::$other_messages, self::NAME_SPACE . "\\" . 'Message::compare'); usort(self::$publish_messages_with_issues, self::NAME_SPACE . "\\" . 'Message::compare'); usort(self::$unpublish_messages_with_issues, self::NAME_SPACE . "\\" . 'Message::compare'); usort(self::$workflow_messages_other, self::NAME_SPACE . "\\" . 'Message::compare'); usort(self::$non_system_messages, self::NAME_SPACE . "\\" . 'Message::compare'); } //var_dump( $workflow_message_ids_is_complete ); } else { echo "Failed to list messages. " . $service->getMessage(); } } catch (\Exception $e) { echo S_PRE . $e . E_PRE; } }
public static function compare(Message $m1, Message $m2) { if ($m1->getDate() == $m2->getDate()) { return 0; } else { if ($m1->getDate() < $m2->getDate()) { return 1; } else { return -1; } } }