<?php

/*
 * @component UserPoints
 * @copyright Copyright (C) 2024 Martin Brampton
 * @license : GNU/GPL
 * @Website : https://remository.com
 */

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');

use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Plugin\CMSPlugin;
use BlackSheepResearch\Component\UserPoints\Site\UserPoints;

/**
 * UserPoints EDocman Document Upload Plugin
 *
 * @package		Joomla
 * @subpackage	UserPoints
 * @since 		1.6
 */
class plgEDocmanUp_document extends CMSPlugin {

    protected $autoloadLanguage = true;

    public function onDocumentAfterSave($context, $row, $isNew) {
        if (class_exists(UserPoints::class) AND 'com_edocman' == substr($context,0,strlen('com_edocman')) AND $isNew) {
            UserPoints::newpoints('up_edocman_up', '', 'edocman_upload_' . $row->id, sprintf(Text::_('PLG_EDOCMAN_UP_UPLOAD_ONE_FILE'), $row->title));
        }
    }
}
