<?php
namespace Claromentis\People\Entity;

$GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"] = (@$GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"] ?: array()) + array("_7f628626dd1d55c7" . "1b1fc0932ffd1d2c" => base64_decode("aXN" . "fYX" . "JyY" . "Xk="), "_4bce3a08782de108b3737" . "e94bd8e2956" => base64_decode("cGFzc3dvcmRfcm" . "VzZXQ="), "_50f3d86f" . "340336be6" . "72ef20f6b" . "0f501c" => base64_decode("YmxvY2t" . "lZA=="), "_2516886eb9" . "700de90ff51" . "80e49aa933f" => base64_decode("c3Vy" . "bmFt" . "ZQ=="), "_21d8d15" . "ff5e12a2" . "4e0d59a4" . "dead984a" . "e" => base64_decode("YXJyYXlfaW5zZXJ0X" . "2FmdGVy"), "_3b1c56066ee" . "6134b4364b61" . "8bca373d6" => base64_decode("bmFtZV9kaXNw" . "bGF5"), "i" . "d" => base64_decode("aW" . "Q="), "_fb165c2da46a4af4ff808" . "510c1c42522" => base64_decode("bGFzdF90aW1lX" . "3VzZWQ="), "_7309594781d" . "f221c773926c" . "720238ef8" => base64_decode("ZnVsbG" . "5hbWU="));
use Analogue\ORM\Entity;
use Analogue\ORM\EntityCollection;
use Claromentis\Core\ORM\Behaviors;
use Claromentis\Core\ORM\Entity\Metadata as MetadataEntity;
use Claromentis\People\Entity\Map\UserMap;
use User as LegacyUser;



























class User extends Entity
{
    use Behaviors\Casts;
    use Behaviors\Metadata;
    
    
    
    
    const AGGREGATION = 27;
    
    
    
    
    
    
    const STATUS_ACTIVE = 'yes';
    
    
    
    
    
    
    const STATUS_INACTIVE = 'no';
    
    
    
    
    
    
    protected $hidden = ['intranetuser', 'password', 'a1_hash', 'password_policy', 'pp_change_next_time', 'pp_default', 'password_last_change', 'login_frozen_time', 'login_attempts', 'login_frozen_until', 'easy_find_num', 'skin', 'default_skin', 'whats_new_list', 'notify_on_checkin', 'notification_method'];
    
    
    
    
    
    
    protected $casts = ['id' => 'int', 'intranetuser' => 'string', 'username' => 'string', 'password' => 'string', 'password_reset' => 'bool', 'a1_hash' => 'string', 'firstname' => 'string', 'surname' => 'string', 'email' => 'string', 'company' => 'string', 'extranet_id' => 'int', 'job_title' => 'string', 'last_time_login' => 'date', 'last_time_used' => 'date', 'user_code' => 'string', 'notify_on_checkin' => 'int', 'notification_method' => 'int', 'language' => 'string', 'easy_find_num' => 'int', 'skin' => 'string', 'default_skin' => 'int', 'password_policy' => 'string', 'pp_change_next_time' => 'int', 'pp_default' => 'int', 'password_last_change' => 'int', 'ldap_guid' => 'string', 'login_frozen_time' => 'date', 'login_attempts' => 'int', 'login_frozen_until' => 'int', 'whats_new_list' => 'string', 'ext_type' => 'string', 'ext_id' => 'string'];
    protected $nullable = ['company', 'job_title', 'last_time_login', 'last_time_used', 'user_code', 'default_skin', 'password_last_change', 'ldap_guid', 'whats_new_list', 'ext_type', 'ext_id'];
    protected $attributes = ['id' => 0, 'intranetuser' => 'yes', 'username' => '', 'password' => '', 'a1_hash' => '', 'firstname' => '', 'surname' => '', 'email' => '', 'company' => null, 'job_title' => null, 'last_time_login' => '0', 'last_time_used' => '0', 'user_code' => null, 'notify_on_checkin' => 1, 'notification_method' => 2, 'language' => 'en', 'easy_find_num' => 10, 'skin' => '', 'default_skin' => 0, 'password_policy' => '0_0_30_5', 'pp_change_next_time' => 0, 'pp_default' => 1, 'password_last_change' => '0', 'ldap_guid' => null, 'login_frozen_time' => '0', 'login_attempts' => 0, 'login_frozen_until' => 0, 'whats_new_list' => '', 'ext_type' => null, 'ext_id' => null, 'extranet_id' => 0];
    
    
    
    
    
    
    public function toLegacy()
    {
        $_bf131e3349c5c1596b45ed6d97a16bdd = new UserMap();
        $attributes = $_bf131e3349c5c1596b45ed6d97a16bdd->getColumnNamesFromAttributes($this->attributes);
        $_24e0e36600d6af77406a44bb618a6253 = new LegacyUser($this->id, true);
        $_24e0e36600d6af77406a44bb618a6253->LoadFromArray($attributes);
        
        
        
        if (!isset($this->metadata)) {
            $_b255ebafd5b8bb45110cd2db0604fa44 = $this->getMetadataAttribute(null);
            
            
            
            if ($_b255ebafd5b8bb45110cd2db0604fa44->elements->count() > 0) {
                foreach ($_b255ebafd5b8bb45110cd2db0604fa44->getFieldNames() as $_66dc8b21e839a9a4739443a621ecc45a) {
                    $values = $this->metadata->getValue($_66dc8b21e839a9a4739443a621ecc45a);
                    if (!$GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_7f628626dd1d55c71b1fc0932" . "ffd1d2c"]($values)) {
                        $values = [$values];
                    }
                    foreach ($values as $value) {
                        $_24e0e36600d6af77406a44bb618a6253->SetValue($_66dc8b21e839a9a4739443a621ecc45a, $value);
                    }
                }
            }
        }
        return $_24e0e36600d6af77406a44bb618a6253;
    }
    
    
    
    
    
    
    public function getMetadataAggregation() : int
    {
        return static::AGGREGATION;
    }
    
    
    
    
    
    
    public function getFullname() : string
    {
        return $this->getFullnameAttribute();
    }
    
    
    
    
    
    
    public function isActive() : bool
    {
        return $this->intranetuser === self::STATUS_ACTIVE;
    }
    
    
    
    
    
    
    public function isBlocked() : bool
    {
        return $this->intranetuser === self::STATUS_INACTIVE;
    }
    
    
    
    
    
    
    public function toArray()
    {
        $_fd62bc4eaaf7d58dea9bada3e30443b9 = parent::toArray();
        $_fd62bc4eaaf7d58dea9bada3e30443b9 = $GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_21d8d15ff5e12a24e0d59a4de" . "ad984ae"]($_fd62bc4eaaf7d58dea9bada3e30443b9, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["i" . "d"], [$GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_50f3d86f340336be6" . "72ef20f6b0f501c"] => $this->isBlocked()]);
        $_fd62bc4eaaf7d58dea9bada3e30443b9 = $GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_21d8d15ff5e12a24e0d59" . "a4dead984ae"]($_fd62bc4eaaf7d58dea9bada3e30443b9, $GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_2516886eb" . "9700de90ff" . "5180e49aa9" . "33f"], [$GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_7309594781df221c773926" . "c720238ef8"] => $this->fullname]);
        $_fd62bc4eaaf7d58dea9bada3e30443b9 = $GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_21d8d15ff5e12a24e0d" . "59a4dead984ae"]($_fd62bc4eaaf7d58dea9bada3e30443b9, $GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_fb165c2da46a4af4ff808510c" . "1c42522"], [$GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_4bce3a0878" . "2de108b3737" . "e94bd8e2956"] => $this->getPasswordResetAttribute()]);
        return $_fd62bc4eaaf7d58dea9bada3e30443b9;
    }
    
    
    
    
    
    
    public function getFullnameAttribute()
    {
        return $GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_3b1c56066ee6134b43" . "64b618bca373d6"]($this->firstname, $this->surname);
    }
    
    
    
    
    
    
    public function getBlockedAttribute()
    {
        return $this->intranetuser === self::STATUS_INACTIVE;
    }
    
    
    
    
    
    
    public function setBlockedAttribute($_50f3d86f340336be672ef20f6b0f501c)
    {
        $_50f3d86f340336be672ef20f6b0f501c = (bool) $_50f3d86f340336be672ef20f6b0f501c;
        $this->intranetuser = $_50f3d86f340336be672ef20f6b0f501c ? self::STATUS_INACTIVE : self::STATUS_ACTIVE;
    }
    
    
    
    
    
    
    public function getPasswordResetAttribute() : bool
    {
        return (bool) $this->pp_change_next_time;
    }
    
    
    
    
    
    
    public function setPasswordResetAttribute(bool $_7af2f69e108c996717dac46d7412162c) : void
    {
        $this->pp_change_next_time = (int) $_7af2f69e108c996717dac46d7412162c;
    }
}