| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- <?php
- namespace MGModule\DNSManager2\models\whmcs\servers;
- use MGModule\DNSManager2 as main;
- /**
- * Server Model
- * @Table(name=tblservers,preventUpdate,prefixed=false)
- * @author Michal Czech <michael@modulesgarden.com>
- */
- class server extends main\mgLibs\models\orm {
- /**
- * @Column()
- * @var int
- */
- public $id;
-
- /**
- * @Column()
- * @var string
- */
- public $hostname;
-
- /**
- * @Column(name=ipaddress)
- * @var string
- */
- public $ip;
-
- /**
- *
- * @Column()
- * @var string
- */
- public $username;
-
- /**
- *
- * @Column(as=passwordEncrypted)
- * @var string
- */
- public $password;
-
- /**
- *
- * @Column()
- * @var string
- */
- public $accesshash;
-
- /**
- * @Column()
- * @var string
- */
- public $secure;
-
- /**
- * @Column(notRequired)
- * @var string
- */
- public $disabled;
-
- /**
- * Load Server Data
- *
- * @author Michal Czech <michael@modulesgarden.com>
- * @param int $id
- * @param array $data
- */
- function __construct($id = false,$data = array()) {
- if($id !== false && empty($data))
- {
- $data = main\mgLibs\MySQL\query::select(
- self::fieldDeclaration()
- , self::tableName()
- ,array(
- 'id' => $id
- )
- )->fetch();
-
- if(empty($data))
- {
- throw new main\mgLibs\exceptions\system('Unable to find Item with ID:'.$id);
- }
- }
- if(isset($data['passwordEncrypted']))
- {
- $data['password'] = decrypt($data['passwordEncrypted']);
- }
-
- if(!empty($data))
- {
- $this->fillProperties($data);
- }
- }
-
-
- function save($data = array()){
- parent::save(array(
- 'password' => encrypt($this->password)
- ));
- }
- }
|