'created', self::ACTION_CLOSE => 'closed', self::ACTION_UPDATE => 'updated', self::ACTION_ASSIGN => 'assigned', self::ACTION_REASSIGN => 'reassigned', self::ACTION_COMMENT => 'commented on', self::ACTION_CC => 'updated cc\'s of', self::ACTION_PRIORITY => 'changed the priority of', self::ACTION_PROJECT => 'modified projects of', self::ACTION_TITLE => 'updated title of', self::ACTION_DESCRIPTION => 'updated description of', self::ACTION_ATTACH => 'attached something to', self::ACTION_REOPEN => 'reopened', ); return idx($map, $action, "brazenly {$action}'d"); } /** * If a group of transactions contain several actions, select the "strongest" * action. For instance, a close is stronger than an update, because we want * to render "User U closed task T" instead of "User U updated task T" when * a user closes a task. */ public static function selectStrongestAction(array $actions) { static $strengths = array( self::ACTION_UPDATE => 0, self::ACTION_CC => 1, self::ACTION_PROJECT => 2, self::ACTION_DESCRIPTION => 3, self::ACTION_TITLE => 4, self::ACTION_ATTACH => 5, self::ACTION_COMMENT => 6, self::ACTION_PRIORITY => 7, self::ACTION_REASSIGN => 8, self::ACTION_ASSIGN => 9, self::ACTION_REOPEN => 10, self::ACTION_CREATE => 11, self::ACTION_CLOSE => 12, ); $strongest = null; $strength = -1; foreach ($actions as $action) { if ($strengths[$action] > $strength) { $strength = $strengths[$action]; $strongest = $action; } } return $strongest; } }