*/
class User
{
+ /**
+ * @brief Get owner data by user id
+ *
+ * @param int $uid
+ * @return boolean|array
+ */
+ public static function getOwnerDataById($uid) {
+ $r = dba::p("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` = 1
+ LIMIT 1",
+ $uid
+ );
+ if (!DBM::is_result($r)) {
+ return false;
+ }
+ return $r[0];
+ }
+
/**
* @brief Returns the default group for a given user and network
*
return;
}
- $r = dba::p("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` = 1
- LIMIT 1",
- $uid
- );
- if (!DBM::is_result($r)) {
+ $owner = User::getOwnerDataById($uid);
+ if (!$owner) {
return;
}
- $owner = $r[0];
if (!$recips) {
$recips = q(
use Friendica\Core\Config;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
+use Friendica\Model\User;
use Friendica\Protocol\Diaspora;
use Friendica\Protocol\DFRN;
use Friendica\Protocol\Email;
}
}
- $r = q("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` = %d AND `contact`.`self` = 1 LIMIT 1",
- intval($uid)
- );
-
- if (!DBM::is_result($r)) {
+ $owner = User::getOwnerDataById($uid);
+ if (!$owner) {
return;
}
- $owner = $r[0];
-
$walltowall = (($top_level && ($owner['id'] != $items[0]['contact-id'])) ? true : false);
$public_message = true;