File "assignees.php"

Full Path: /home/romayxjt/public_html/wp-content/plugins/vikbooking/admin/helpers/src/history/detector/assignees.php
File size: 1.6 KB
MIME-type: text/x-php
Charset: utf-8

<?php
/** 
 * @package     VikBooking
 * @subpackage  core
 * @author      E4J s.r.l.
 * @copyright   Copyright (C) 2025 E4J s.r.l. All Rights Reserved.
 * @license     http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 * @link        https://vikwp.com
 */

// No direct access
defined('ABSPATH') or die('No script kiddies please!');

/**
 * Item assignees changes detector class.
 * 
 * @since 1.18 (J) - 1.8 (WP)
 */
abstract class VBOHistoryDetectorAssignees extends VBOHistoryDetectorArray
{
    /**
     * Class constructor.
     */
    public function __construct(?string $propertyName = null)
    {
        parent::__construct($propertyName ?: 'assignees');
    }

    /**
     * @inheritDoc
     */
    protected function describeAddedItems(array $added)
    {
        $last = array_pop($added);

        if (!$added) {
            // only one item
            return JText::sprintf('VBO_HISTORY_TRACKER_ASSIGNEE_ADDED', $last);
        }
        
        // 2 or more items
        return JText::sprintf('VBO_HISTORY_TRACKER_ASSIGNEES_ADDED', implode(', ', $added), $last);
    }

    /**
     * @inheritDoc
     */
    protected function describeRemovedItems(array $removed)
    {
        $last = array_pop($removed);

        if (!$removed) {
            // only one item
            return JText::sprintf('VBO_HISTORY_TRACKER_ASSIGNEE_REMOVED', $last);
        }
        
        // 2 or more items
        return JText::sprintf('VBO_HISTORY_TRACKER_ASSIGNEES_REMOVED', implode(', ', $removed), $last);
    }

    /**
     * @inheritDoc
     */
    public function getIcon()
    {
        return VikBookingIcons::i('user');
    }
}