]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/User.php
Merge pull request #4160 from annando/community
[friendica.git] / src / Model / User.php
index d09d670a4bffffb5b85dbcfb560962e1c31145de..4f294f6e8939eed672d4f03c7b15fe9f5bc66bef 100644 (file)
@@ -16,11 +16,12 @@ use Friendica\Model\Contact;
 use Friendica\Model\Group;
 use Friendica\Model\Photo;
 use Friendica\Object\Image;
+use Friendica\Util\Crypto;
 use dba;
 use Exception;
 
 require_once 'boot.php';
-require_once 'include/crypto.php';
+require_once 'include/dba.php';
 require_once 'include/enotify.php';
 require_once 'include/network.php';
 require_once 'library/openid.php';
@@ -32,6 +33,37 @@ require_once 'include/text.php';
  */
 class User
 {
+       /**
+        * @brief Get owner data by user id
+        *
+        * @param int $uid
+        * @return boolean|array
+        */
+       public static function getOwnerDataById($uid) {
+               $r = dba::fetch_first("SELECT
+                       `contact`.*,
+                       `user`.`prvkey` AS `uprvkey`,
+                       `user`.`timezone`,
+                       `user`.`nickname`,
+                       `user`.`sprvkey`,
+                       `user`.`spubkey`,
+                       `user`.`page-flags`,
+                       `user`.`account-type`,
+                       `user`.`prvnets`
+                       FROM `contact`
+                       INNER JOIN `user`
+                               ON `user`.`uid` = `contact`.`uid`
+                       WHERE `contact`.`uid` = ?
+                       AND `contact`.`self`
+                       LIMIT 1",
+                       $uid
+               );
+               if (!DBM::is_result($r)) {
+                       return false;
+               }
+               return $r;
+       }
+
        /**
         * @brief Returns the default group for a given user and network
         *
@@ -186,7 +218,7 @@ class User
                                $_SESSION['register'] = 1;
                                $_SESSION['openid'] = $openid_url;
 
-                               $openid = new LightOpenID;
+                               $openid = new \LightOpenID;
                                $openid->identity = $openid_url;
                                $openid->returnUrl = System::baseUrl() . '/openid';
                                $openid->required = array('namePerson/friendly', 'contact/email', 'namePerson');
@@ -267,7 +299,7 @@ class User
 
                $return['password'] = $new_password;
 
-               $keys = new_keypair(4096);
+               $keys = Crypto::newKeypair(4096);
                if ($keys === false) {
                        throw new Exception(t('SERIOUS ERROR: Generation of security keys failed.'));
                }
@@ -276,7 +308,7 @@ class User
                $pubkey = $keys['pubkey'];
 
                // Create another keypair for signing/verifying salmon protocol messages.
-               $sres = new_keypair(512);
+               $sres = Crypto::newKeypair(512);
                $sprvkey = $sres['prvkey'];
                $spubkey = $sres['pubkey'];