Source of file DifferentuserValidator.php

Size: 1,486 Bytes - Last Modified: 2016-05-18T03:08:27+02:00

buildproject/core/module_system/system/validators/DifferentuserValidator.php

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
<?php
/*"******************************************************************************************************
*   (c) 2007-2016 by Kajona, www.kajona.de                                                              *
*       Published under the GNU LGPL v2.1, see /system/licence_lgpl.txt                                 *
*-------------------------------------------------------------------------------------------------------*
*	$Id$                                   *
********************************************************************************************************/

namespace Kajona\System\System\Validators;

use Kajona\System\System\Carrier;
use Kajona\System\System\UserUser;


/**
 * Checks if the selected user is the user which is currently logged in.
 *
 * @author stefan.meyer1@yahoo.de
 * @since 4.5
 * @package module_system
 */
class DifferentuserValidator extends UserValidator {

    /**
     * Validates the passed chunk of data.
     * In most cases, this'll be a string-object.
     *
     * @param string $objValue
     * @return bool
     */
    public function validate($objValue) {
        if(!parent::validate($objValue)) {
            return false;
        }

        //check if user exists and if it is the logged in user
        $objUser = new UserUser($objValue);
        if($objUser->getStrUsername() != "" && $objValue == Carrier::getInstance()->getObjSession()->getUserID()) {
            return false;
        }

        return true;
    }

}