| @@ -63,8 +63,14 @@ | ||
| 63 | 63 | if (isset($valueKeys[1])) { |
| 64 | 64 | $defaultValue = trim($valueKeys[1]); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | + // Before the empty-data guard: with no agent (unassigned ticket, closed by | |
| 68 | + // a workflow) the signature is empty, not a literal {{agent.signature}}. | |
| 69 | + if ($dataKey == 'agent' && $valueKey == 'signature') { | |
| 70 | + return $this->getAgentSignature($data); | |
| 71 | + } | |
| 72 | + | |
| 67 | 73 | if(empty($data[$dataKey])) { |
| 68 | 74 | return $matches[0]; |
| 69 | 75 | } |
| 70 | 76 | |
| @@ -88,8 +94,35 @@ | ||
| 88 | 94 | |
| 89 | 95 | return apply_filters('fluentsupport/smartcode_fallback_callback_' . $dataKey, $matches[0], $valueKey, $defaultValue, $data); |
| 90 | 96 | } |
| 91 | 97 | |
| 98 | + /** Set while a signature renders: a signature naming itself, in any spelling, renders empty. */ | |
| 99 | + private static $renderingSignature = false; | |
| 100 | + | |
| 101 | + /** | |
| 102 | + * {{agent.signature}}: the agent's signature when enabled, otherwise empty. | |
| 103 | + * Its own smartcodes are filled from the same data. | |
| 104 | + */ | |
| 105 | + protected function getAgentSignature($data) | |
| 106 | + { | |
| 107 | + if (self::$renderingSignature || empty($data['agent'])) { | |
| 108 | + return ''; | |
| 109 | + } | |
| 110 | + | |
| 111 | + $signature = \FluentSupport\App\Services\Tickets\ResponseService::getAppendedSignature($data['agent']); | |
| 112 | + | |
| 113 | + if ($signature === '') { | |
| 114 | + return ''; | |
| 115 | + } | |
| 116 | + | |
| 117 | + self::$renderingSignature = true; | |
| 118 | + try { | |
| 119 | + return $this->parse($signature, $data); | |
| 120 | + } finally { | |
| 121 | + self::$renderingSignature = false; | |
| 122 | + } | |
| 123 | + } | |
| 124 | + | |
| 92 | 125 | protected function getTicketData($ticket, $valueKey, $defaultValue) |
| 93 | 126 | { |
| 94 | 127 | $valueKeys = explode('.', $valueKey); |
| 95 | 128 | |
| @@ -99,8 +132,12 @@ | ||
| 99 | 132 | } |
| 100 | 133 | |
| 101 | 134 | if($valueKey == 'admin_url') { |
| 102 | 135 | return Helper::getTicketAdminUrl($ticket); |
| 136 | + } | |
| 137 | + | |
| 138 | + if($valueKey == 'public_id') { | |
| 139 | + return $ticket->display_ticket_number; | |
| 103 | 140 | } |
| 104 | 141 | |
| 105 | 142 | $accesors = ['id', 'title', 'content', 'priority', 'client_priority', 'status', 'created_at']; |
| 106 | 143 | if(in_array($valueKey, $accesors)) { |