Example #1
0
 /**
  * Import a character from the Helden Software xml export.
  *
  * @return \Model\Character
  */
 public function import()
 {
     $simplexml = simplexml_load_string($this->xml);
     /* @var $characterXml \SimpleXMLElement */
     $characterXml = $simplexml->held;
     $characterAttributes = $characterXml->attributes();
     $character = array('user' => \SmartWork\User::getUserById($_SESSION['userId']), 'key' => $characterAttributes['key'], 'lastUpdate' => \DateTime::createFromFormat('U', intval(floatval($characterAttributes['stand']) / 1000)), 'name' => $characterAttributes['name'], 'bowMaking' => 0, 'precisionMechanics' => 0, 'blacksmith' => 0, 'woodworking' => 0, 'leatherworking' => 0, 'tailoring' => 0);
     /* @var $talents \SimpleXMLElement */
     $talents = $characterXml->talentliste;
     /* @var $talent \SimpleXMLElement */
     foreach ($talents->talent as $talent) {
         $talentAttributes = $talent->attributes();
         if (array_key_exists(strval($talentAttributes['name']), $this->talentMapping)) {
             $character[$this->talentMapping[strval($talentAttributes['name'])]] = intval($talentAttributes['value']);
         }
     }
     return \Model\Character::create($character);
 }
Example #2
0
 /**
  * Set the admin status of the given user to $status.
  *
  * @param integer $userId
  * @param boolean $status
  *
  * @return void
  */
 protected function changeAdminStatus($userId, $status)
 {
     $user = \SmartWork\User::getUserById($userId);
     $user->setAdmin($status);
 }
Example #3
0
 /**
  * Set the used template.
  */
 public function __construct()
 {
     parent::__construct('options');
     $this->user = \SmartWork\User::getUserById($_SESSION['userId']);
 }