* @param int $uid The user ID.
* @param string $token
* @param string $meta
- *
* @return boolean
* @throws \Exception
*/
*
* @param string $type Verify type.
* @param string $interval SQL compatible time interval
+ * @return void
* @throws \Exception
*/
public static function purge(string $type, string $interval)
* Returns a formatted location string from the given profile array
*
* @param array $profile Profile array (Generated from the "profile" table)
- *
* @return string Location string
*/
public static function formatLocation(array $profile): string
/**
* Return the list of pending registrations
*
- * @param int $start Start count (Default is 0)
+ * @param int $start Start count (Default is 0)
* @param int $count Count of the items per page (Default is @see Pager::ITEMS_PER_PAGE)
- *
- * @return array
+ * @return array|bool Array on succes, false on failure
* @throws \Exception
*/
- public static function getPending($start = 0, $count = Pager::ITEMS_PER_PAGE)
+ public static function getPending(int $start = 0, int $count = Pager::ITEMS_PER_PAGE)
{
return DBA::selectToArray('pending-view', [], [], ['limit' => [$start, $count]]);
}
*
* @param int $uid The user id
*
- * @return array The pending user information
- *
+ * @return array|bool Array on succes, false on failure
* @throws \Exception
*/
public static function getPendingForUser(int $uid)
* @return int
* @throws \Exception
*/
- public static function getPendingCount()
+ public static function getPendingCount(): int
{
return DBA::count('pending-view', ['self' => true]);
}
* Returns the register record associated with the provided hash
*
* @param string $hash
- * @return array
+ * @return array|bool Array on succes, false on failure
* @throws \Exception
*/
- public static function getByHash($hash)
+ public static function getByHash(string $hash)
{
return DBA::selectFirst('register', [], ['hash' => $hash]);
}
* @return boolean
* @throws \Exception
*/
- public static function existsByHash($hash)
+ public static function existsByHash(string $hash): bool
{
return DBA::exists('register', ['hash' => $hash]);
}
* @return string
* @throws \Exception
*/
- public static function createForInvitation()
+ public static function createForInvitation(): string
{
$code = Strings::getRandomName(8) . random_int(1000, 9999);
* @return boolean
* @throws \Exception
*/
- public static function createForApproval($uid, $language, $note = '')
+ public static function createForApproval(int $uid, string $language, string $note = ''): bool
{
$hash = Strings::getRandomHex();
* @return boolean
* @throws \Exception
*/
- public static function deleteByHash($hash)
+ public static function deleteByHash(string $hash): bool
{
return DBA::delete('register', ['hash' => $hash]);
}
* Returns the list of user defined tags (e.g. #Friendica)
*
* @return array
- *
* @throws \Exception
*/
- public static function getUserTags()
+ public static function getUserTags(): array
{
$termsStmt = DBA::p("SELECT DISTINCT(`term`) FROM `search`");
* @param int $applicationid
* @param int $uid
* @param array $fields
- *
- * @return bool Does it exist?
+ * @return array|bool Array on success, false on failure
*/
public static function select(int $applicationid, int $uid, array $fields = [])
{
*
* @return bool Does it exist?
*/
- public static function exists(int $applicationid, int $uid)
+ public static function exists(int $applicationid, int $uid): bool
{
return DBA::exists('subscription', ['application-id' => $applicationid, 'uid' => $uid]);
}
* @param int $applicationid
* @param int $uid
* @param array $fields subscription fields
- *
* @return bool result of update
*/
- public static function update(int $applicationid, int $uid, array $fields)
+ public static function update(int $applicationid, int $uid, array $fields): bool
{
return DBA::update('subscription', $fields, ['application-id' => $applicationid, 'uid' => $uid]);
}
* Insert or replace a subscription record
*
* @param array $fields subscription fields
- *
* @return bool result of replace
*/
- public static function replace(array $fields)
+ public static function replace(array $fields): bool
{
return DBA::replace('subscription', $fields);
}
* @param int $uid
* @return bool
*/
- public static function delete(int $applicationid, int $uid)
+ public static function delete(int $applicationid, int $uid): bool
{
return DBA::delete('subscription', ['application-id' => $applicationid, 'uid' => $uid]);
}
/**
* Prepare push notification
*
- * @param int $nid
+ * @param Notification $Notification Notification instance
* @return void
*/
- public static function pushByNotification(Entity\Notification $Notification)
+ public static function pushByNotification(Entity\Notification $notification)
{
- $type = \Friendica\Factory\Api\Mastodon\Notification::getType($Notification);
+ $type = \Friendica\Factory\Api\Mastodon\Notification::getType($notification);
- if (DI::notify()->NotifyOnDesktop($Notification, $type)) {
- DI::notify()->createFromNotification($Notification);
+ if (DI::notify()->NotifyOnDesktop($notification, $type)) {
+ DI::notify()->createFromNotification($notification);
}
if (empty($type)) {
return;
}
- $subscriptions = DBA::select('subscription', [], ['uid' => $Notification->uid, $type => true]);
+ $subscriptions = DBA::select('subscription', [], ['uid' => $notification->uid, $type => true]);
while ($subscription = DBA::fetch($subscriptions)) {
Logger::info('Push notification', ['id' => $subscription['id'], 'uid' => $subscription['uid'], 'type' => $type]);
- Worker::add(PRIORITY_HIGH, 'PushSubscription', $subscription['id'], $Notification->id);
+ Worker::add(PRIORITY_HIGH, 'PushSubscription', $subscription['id'], $notification->id);
}
DBA::close($subscriptions);
}
switch ($accounttype) {
case 'person':
return User::ACCOUNT_TYPE_PERSON;
+
case 'organisation':
return User::ACCOUNT_TYPE_ORGANISATION;
+
case 'news':
return User::ACCOUNT_TYPE_NEWS;
+
case 'community':
return User::ACCOUNT_TYPE_COMMUNITY;
- default:
- return null;
- break;
+
}
+ return null;
}
/**
/**
* Get a user based on its email
*
- * @param string $email
- * @param array $fields
- *
+ * @param string $email
+ * @param array $fields
* @return array|boolean User record if it exists, false otherwise
- *
* @throws Exception
*/
- public static function getByEmail($email, array $fields = [])
+ public static function getByEmail(string $email, array $fields = [])
{
return DBA::selectFirst('user', $fields, ['email' => $email]);
}
* @throws HTTPException\ForbiddenException
* @throws HTTPException\NotFoundException
*/
- public static function getIdFromPasswordAuthentication($user_info, string $password, bool $third_party = false)
+ public static function getIdFromPasswordAuthentication($user_info, string $password, bool $third_party = false): int
{
// Addons registered with the "authenticate" hook may create the user on the
// fly. `getAuthenticationInfo` will fail if the user doesn't exist yet. If
$type = Images::getMimeTypeByData($img_str, $photo, $type);
- $Image = new Image($img_str, $type);
- if ($Image->isValid()) {
- $Image->scaleToSquare(300);
+ $image = new Image($img_str, $type);
+ if ($image->isValid()) {
+ $image->scaleToSquare(300);
$resource_id = Photo::newResource();
// Not using Photo::PROFILE_PHOTOS here, so that it is discovered as translateble string
$profile_album = DI::l10n()->t('Profile Photos');
- $r = Photo::store($Image, $uid, 0, $resource_id, $filename, $profile_album, 4);
+ $r = Photo::store($image, $uid, 0, $resource_id, $filename, $profile_album, 4);
if ($r === false) {
$photo_failure = true;
}
- $Image->scaleDown(80);
+ $image->scaleDown(80);
- $r = Photo::store($Image, $uid, 0, $resource_id, $filename, $profile_album, 5);
+ $r = Photo::store($image, $uid, 0, $resource_id, $filename, $profile_album, 5);
if ($r === false) {
$photo_failure = true;
}
- $Image->scaleDown(48);
+ $image->scaleDown(48);
- $r = Photo::store($Image, $uid, 0, $resource_id, $filename, $profile_album, 6);
+ $r = Photo::store($image, $uid, 0, $resource_id, $filename, $profile_album, 6);
if ($r === false) {
$photo_failure = true;
* @param string $email The user's email address
* @param string $nick The user's nick name
* @param string $lang The user's language (default is english)
- *
* @return bool True, if the user was created successfully
* @throws HTTPException\InternalServerErrorException
* @throws ErrorException
* @param string $type The type of users, which should get (all, bocked, removed)
* @param string $order Order of the user list (Default is 'contact.name')
* @param bool $descending Order direction (Default is ascending)
- *
* @return array|bool The list of the users
* @throws Exception
*/
$condition['account_removed'] = false;
$condition['blocked'] = false;
break;
+
case 'blocked':
$condition['account_removed'] = false;
$condition['blocked'] = true;
$condition['verified'] = true;
break;
+
case 'removed':
$condition['account_removed'] = true;
break;
* @return integer verb id
* @throws \Exception
*/
- public static function getID(string $verb)
+ public static function getID(string $verb): int
{
if (empty($verb)) {
return 0;
* @param integer $id
* @return string verb
*/
- public static function getByID(int $id)
+ public static function getByID(int $id): string
{
if (empty($id)) {
return '';