Version 5.0.13

This commit is contained in:
Neo committed 2025-12-19 19:04:57 -08:00
1 parent b89858b2ff
commit 5efe744c5f
1407 files changed
+69690 -30177

No files matched your search

@@ -413,4 +413,64 @@ class Assignment extends ActiveRecord
parent::delete();
}
/**
* Get output for API
*
* @param Member|NULL $authorizedMember The member making the API request or NULL for API Key / client_credentials
* @param bool $includeItem Should the assigned item be attached to the response?
* @return array
* @apiresponse int id ID
* @apiresponse int date Date of assignment
* @apiresponse \IPS\Member assigned_by Member who assigned the item
* @apiresponse string time_first_reply Time for the first reply
* @apiresponse [\IPS\Member] assigned_to Assigned Members
* @apiresponse string item_class Content Class
* @apiresponse int item_id Content ID
* @apiresponse [\IPS\Content\Item|\IPS\Content\Comment] content Content Object
*/
public function apiOutput( Member $authorizedMember = NULL, bool $includeItem = true ): array
{
$item = $this->item;
$response = [];
$response['id'] = $this->id;
$response['date'] = DateTime::ts( $this->date )->rfc3339();
$response['assigned_by'] = Member::load($this->by )->apiOutput( $authorizedMember);
$response['time_first_reply'] = $this->timeToFirstReply();
$assignedTo = $this->assignedTo();
if( $assignedTo )
{
$members = [];
if( $assignedTo instanceof Team )
{
foreach( $assignedTo->members() as $member )
{
$members[] = $member->apiOutput( $authorizedMember );
}
}
else
{
$members[] = $assignedTo->apiOutput( $authorizedMember );
}
}
else
{
$members = [];
}
$response['assigned_to'] = $members;
$response['item_class'] = $this->item_class;
$response['item_id'] = $this->item_id;
if( $includeItem and $item )
{
$response['content'] = $item->apiOutput( $authorizedMember );
}
else
{
$response['content'] = NULL;
}
return $response;
}
}