Example #1
0
 /**
  * @param array $data
  * @return bool
  * @throws \Exception
  */
 public function registerNewUser(array $data, $groupId = 0, $sendVerfificationMail = true)
 {
     $salt = Unique::createSalt(25);
     if (Cunity::get("settings")->getSetting("core.fullname")) {
         $name = $data['firstname'] . " " . $data['lastname'];
     } else {
         $name = $data['username'];
     }
     $result = $this->insert(["email" => trim($data['email']), "userhash" => $this->createUniqueHash(), "username" => $data['username'], "groupid" => $groupId, "password" => sha1(trim($data['password']) . $salt), "salt" => $salt, "name" => $name, "firstname" => $data['firstname'], "lastname" => $data['lastname']]);
     if (array_key_exists('field', $_POST)) {
         $profileFieldsUser = new ProfileFieldsUsers([], $this->search('userid', $result));
         $profileFieldsUser->update($_REQUEST['field'], '');
     }
     if ($result && $sendVerfificationMail) {
         new VerifyMail(["name" => $name, "email" => $data['email']], $salt);
         return true;
     }
     return false;
 }
Example #2
0
 /**
  * @return array
  */
 public function getAll()
 {
     $query = $this->getAdapter()->select()->from(["pf" => $this->getTableName()])->order("pf.sorting");
     $result = $this->getAdapter()->fetchAll($query);
     foreach ($result as $_key => $_result) {
         $values = [];
         switch (self::$types[$_result['type_id']]) {
             case 'select':
                 $queryValues = $this->getAdapter()->select()->from(["pfv" => $this->_dbprefix . "profilefields_values"])->where('profilefield_id = ' . $_result['id'])->order("pfv.sorting");
                 $values = $queryValues->getAdapter()->fetchAll($queryValues);
                 break;
             default:
                 break;
         }
         $value = new ProfileFieldsUsers([], $_SESSION['user']);
         $res = $value->getByProfileFieldIdAndUserId($_result['id']);
         $result[$_key]['label'] = $_result['value'];
         $result[$_key]['value'] = $res['value'];
         $result[$_key]['values'] = $values;
         $result[$_key]['type'] = self::$types[$_result['type_id']];
     }
     return $result;
 }
Example #3
0
 /**
  * @return bool|mixed
  */
 public function save()
 {
     if (isset($this->_modifiedFields['username']) || isset($this->_modifiedFields['firstname']) || isset($this->_modifiedFields['lastname'])) {
         $currentUsername = $this->username;
         $result = parent::save();
         $searchindex = new Process();
         return $result && $searchindex->updateUser($currentUsername, $this->username, $this->firstname . " " . $this->lastname);
     } elseif (array_key_exists('field', $_POST)) {
         $profileFieldsUser = new ProfileFieldsUsers([], $this);
         return $profileFieldsUser->update($_POST['field'], '');
     } else {
         return parent::save();
     }
 }