);
$fnname = 'string_plural_select_' . $lang;
- $out = 'if(! function_exists("' . $fnname . '")) {' . "\n";
+ $out = 'if(! function_exists("' . $fnname . '")) {' . "\n";
$out .= 'function ' . $fnname . '($n){' . "\n";
$out .= ' $n = intval($n);' . "\n";
$out .= ' ' . $return . "\n";
if ($q === false || $s < $q) {
list($then, $else) = explode(':', $string, 2);
- $node['then'] = $then;
- $parsedElse = [];
+ $node['then'] = $then;
+ $parsedElse = [];
self::parse($else, $parsedElse);
$node['else'] = $parsedElse;
} else {
list($if, $thenelse) = explode('?', $string, 2);
- $node['if'] = $if;
+ $node['if'] = $if;
self::parse($thenelse, $node);
}
}
private static function render($tree): string
{
if (is_array($tree)) {
- $if = trim($tree['if']);
+ $if = trim($tree['if']);
$then = trim($tree['then']);
$else = self::render($tree['else']);
$BaseCollection = parent::_selectByBoundaries(
['`uid` = ? AND NOT `ignore`',$uid],
['order' => ['id' => 'DESC']],
- $min_id, $max_id, $limit);
+ $min_id,
+ $max_id,
+ $limit
+ );
} catch (\Exception $e) {
throw new IntroductionPersistenceException(sprintf('Cannot select Introductions for used %d', $uid), $e);
}
$uids = array_column($users, 'uid');
$usercondition = ['uid' => $uids];
- $condition = DBA::mergeConditions($usercondition, ["`languages` != ? AND `include-tags` = ? AND `full-text-search` = ? AND `circle` = ?", '', '', '', 0]);
+ $condition = DBA::mergeConditions($usercondition, ["`languages` != ? AND `include-tags` = ? AND `full-text-search` = ? AND `circle` = ?", '', '', '', 0]);
foreach ($this->select($condition) as $channel) {
if (!empty($channel->languages) && in_array($language, $channel->languages)) {
return true;
}
}
- $search = '';
+ $search = '';
$condition = DBA::mergeConditions($usercondition, ["`full-text-search` != ? AND `circle` = ? AND `valid`", '', 0]);
foreach ($this->select($condition) as $channel) {
$search .= '(' . $channel->fullTextSearch . ') ';
{
$condition = $this->getUserCondition();
$condition = DBA::mergeConditions($condition, ["`account-type` IN (?, ?) AND `uid` != ?", User::ACCOUNT_TYPE_RELAY, User::ACCOUNT_TYPE_COMMUNITY, 0]);
- $users = $this->db->selectToArray('user', ['uid'], $condition);
+ $users = $this->db->selectToArray('user', ['uid'], $condition);
if (empty($users)) {
return [];
}
?UriInterface $publisherImage = null,
?string $blurhash = null,
int $id = null
- )
- {
+ ) {
$this->uriId = $uriId;
$this->url = $url;
$this->type = $type;
if ($newWidth && $newHeight && $size) {
$dimensionts = Images::getScalingDimensions($newWidth, $newHeight, Proxy::getPixelsFromSize($size));
- $newWidth = $dimensionts['width'];
- $newHeight = $dimensionts['height'];
+ $newWidth = $dimensionts['width'];
+ $newHeight = $dimensionts['height'];
}
return new self(
// Peertube videos are delivered in many different resolutions. We pick a moderate one.
// Since only Peertube provides a "height" parameter, this wouldn't be executed
// when someone for example on Mastodon was sharing multiple videos in a single post.
- $heights[$PostMedia->height] = (string)$PostMedia->url;
+ $heights[$PostMedia->height] = (string)$PostMedia->url;
$video[(string) $PostMedia->url] = $PostMedia;
} else {
$attachments['visual'][] = $PostMedia;
public static function loadHooks()
{
self::$hooks = [];
- $stmt = DBA::select('hook', ['hook', 'file', 'function'], [], ['order' => ['priority' => 'desc', 'file']]);
+ $stmt = DBA::select('hook', ['hook', 'file', 'function'], [], ['order' => ['priority' => 'desc', 'file']]);
while ($hook = DBA::fetch($stmt)) {
self::add($hook['hook'], $hook['file'], $hook['function']);
protected $server_info = '';
/** @var PDO|mysqli|null */
protected $connection;
- protected $driver = '';
+ protected $driver = '';
protected $pdo_emulate_prepares = false;
- private $error = '';
- private $errorno = 0;
- private $affected_rows = 0;
- protected $in_transaction = false;
- protected $in_retrial = false;
- protected $testmode = false;
- private $relation = [];
+ private $error = '';
+ private $errorno = 0;
+ private $affected_rows = 0;
+ protected $in_transaction = false;
+ protected $in_retrial = false;
+ protected $testmode = false;
+ private $relation = [];
/** @var DbaDefinition */
protected $dbaDefinition;
/** @var ViewDefinition */
$this->viewDefinition = $viewDefinition;
// Use dummy values - necessary for the first factory call of the logger itself
- $this->logger = new NullLogger();
+ $this->logger = new NullLogger();
$this->profiler = new Profiler($config);
$this->connect();
} elseif (is_string($args[$param])) {
$param_types .= 's';
} elseif (is_object($args[$param]) && method_exists($args[$param], '__toString')) {
- $param_types .= 's';
+ $param_types .= 's';
$args[$param] = (string)$args[$param];
} else {
$param_types .= 'b';
}
$this->logger->error('DB Error', [
- 'code' => $errorno,
- 'error' => $error,
- 'params' => $this->replaceParameters($sql, $args),
+ 'code' => $errorno,
+ 'error' => $error,
+ 'params' => $this->replaceParameters($sql, $args),
]);
// On a lost connection we try to reconnect - but only once.
}
$this->logger->error('DB Error', [
- 'code' => $errorno,
- 'error' => $error,
- 'params' => $this->replaceParameters($sql, $params),
+ 'code' => $errorno,
+ 'error' => $error,
+ 'params' => $this->replaceParameters($sql, $params),
]);
// On a lost connection we simply quit.
return true;
}
- $fields = $this->castFields($table, $fields);
+ $fields = $this->castFields($table, $fields);
$direct_fields = [];
foreach ($fields as $key => $value) {
* @return \Friendica\Object\Api\Mastodon\Attachment
* @throws InternalServerErrorException
*/
- private function createFromMediaArray(array $attachment): \Friendica\Object\Api\Mastodon\Attachment
+ private function createFromMediaArray(array $attachment): \Friendica\Object\Api\Mastodon\Attachment
{
$filetype = !empty($attachment['mimetype']) ? strtolower(substr($attachment['mimetype'], 0, strpos($attachment['mimetype'], '/'))) : '';
*/
private function createFromArray(array $item, int $uid, bool $include_entities): \Friendica\Object\Api\Twitter\Status
{
- $item = Post\Media::addHTMLAttachmentToItem($item);
+ $item = Post\Media::addHTMLAttachmentToItem($item);
$author = $this->twitterUser->createFromContactId($item['author-id'], $uid, true);
if (!empty($item['causer-id']) && ($item['post-reason'] == Item::PR_ANNOUNCEMENT)) {
$entities = [];
}
- return new \Friendica\Object\Api\Twitter\Status($text, $statusnetHtml, $friendicaHtml, $item, $author, $owner, $retweeted, $quoted, $geo, $friendica_activities, $entities, $attachments, $friendica_comments, $liked);
+ return new \Friendica\Object\Api\Twitter\Status($text, $statusnetHtml, $friendicaHtml, $item, $author, $owner, $retweeted, $quoted, $geo, $friendica_activities, $entities, $attachments, $friendica_comments, $liked);
}
}
$item_id = $this->parameters['id'] ?? 0;
$term = trim($request['term'] ?? '');
- $cat = trim($request['cat'] ?? '');
+ $cat = trim($request['cat'] ?? '');
if (!empty($cat)) {
$type = Post\Category::CATEGORY;
$values = [$uid];
$type_condition = '';
- $notify_type = $this->pconfig->get($uid, 'system', 'notify_type');
+ $notify_type = $this->pconfig->get($uid, 'system', 'notify_type');
if (!is_null($notify_type)) {
$type_condition = 'AND `type` & ? != 0';
- $values[] = $notify_type | UserNotification::TYPE_SHARED | UserNotification::TYPE_FOLLOW;
+ $values[] = $notify_type | UserNotification::TYPE_SHARED | UserNotification::TYPE_FOLLOW;
}
$like_condition = '';
if (!$this->pconfig->get($uid, 'system', 'notify_like')) {
$like_condition = 'AND NOT `vid` IN (?, ?)';
- $values[] = Verb::getID(Activity::LIKE);
- $values[] = Verb::getID(Activity::DISLIKE);
+ $values[] = Verb::getID(Activity::LIKE);
+ $values[] = Verb::getID(Activity::DISLIKE);
}
$announce_condition = '';
if (!$this->pconfig->get($uid, 'system', 'notify_announce')) {
$announce_condition = 'AND vid != ?';
- $values[] = Verb::getID(Activity::ANNOUNCE);
+ $values[] = Verb::getID(Activity::ANNOUNCE);
}
$rows = $this->db->p("
public function deleteForItem(int $itemUriId): bool
{
$conditionTarget = [
- 'vid' => Verb::getID(Activity::POST),
+ 'vid' => Verb::getID(Activity::POST),
'target-uri-id' => $itemUriId,
];
$conditionParent = [
- 'vid' => Verb::getID(Activity::POST),
+ 'vid' => Verb::getID(Activity::POST),
'parent-uri-id' => $itemUriId,
];
public function __construct(array $data = [])
{
- $this->label = $data['label'] ?? '';
- $this->type = $data['str_type'] ?? '';
- $this->intro_id = $data['intro_id'] ?? -1;
- $this->madeBy = $data['madeBy'] ?? '';
- $this->madeByUrl = $data['madeByUrl'] ?? '';
- $this->madeByZrl = $data['madeByZrl'] ?? '';
- $this->madeByAddr = $data['madeByAddr'] ?? '';
- $this->contactId = $data['contactId'] ?? -1;
- $this->photo = $data['photo'] ?? '';
- $this->name = $data['name'] ?? '';
- $this->url = $data['url'] ?? '';
- $this->zrl = $data['zrl'] ?? '';
- $this->hidden = $data['hidden'] ?? false;
+ $this->label = $data['label'] ?? '';
+ $this->type = $data['str_type'] ?? '';
+ $this->intro_id = $data['intro_id'] ?? -1;
+ $this->madeBy = $data['madeBy'] ?? '';
+ $this->madeByUrl = $data['madeByUrl'] ?? '';
+ $this->madeByZrl = $data['madeByZrl'] ?? '';
+ $this->madeByAddr = $data['madeByAddr'] ?? '';
+ $this->contactId = $data['contactId'] ?? -1;
+ $this->photo = $data['photo'] ?? '';
+ $this->name = $data['name'] ?? '';
+ $this->url = $data['url'] ?? '';
+ $this->zrl = $data['zrl'] ?? '';
+ $this->hidden = $data['hidden'] ?? false;
$this->postNewFriend = $data['postNewFriend'] ?? '';
- $this->knowYou = $data['knowYou'] ?? false;
- $this->note = $data['note'] ?? '';
- $this->request = $data['request'] ?? '';
+ $this->knowYou = $data['knowYou'] ?? false;
+ $this->note = $data['note'] ?? '';
+ $this->request = $data['request'] ?? '';
$this->dfrnId = -1;
- $this->addr = $data['addr'] ?? '';
- $this->network = $data['network'] ?? '';
- $this->uid = $data['uid'] ?? -1;
+ $this->addr = $data['addr'] ?? '';
+ $this->network = $data['network'] ?? '';
+ $this->uid = $data['uid'] ?? -1;
$this->keywords = $data['keywords'] ?? '';
$this->location = $data['location'] ?? '';
- $this->about = $data['about'] ?? '';
+ $this->about = $data['about'] ?? '';
}
public function getLabel(): string
}
}
- $this->redirectUrl = (string)Uri::fromParts((array)$redirect_parts);
- $this->isRedirectUrl = true;
+ $this->redirectUrl = (string)Uri::fromParts((array)$redirect_parts);
+ $this->isRedirectUrl = true;
$this->redirectIsPermanent = $this->returnCode == 301 || $this->returnCode == 308;
} else {
- $this->isRedirectUrl = false;
+ $this->isRedirectUrl = false;
$this->redirectIsPermanent = false;
}
}
$this->date_rel = Temporal::getRelativeDate($this->date);
try {
- $this->msg_html = BBCode::convertForUriId($notify->uriId, $this->msg, BBCode::EXTERNAL);
+ $this->msg_html = BBCode::convertForUriId($notify->uriId, $this->msg, BBCode::EXTERNAL);
} catch (\Exception $e) {
- $this->msg_html = '';
+ $this->msg_html = '';
}
try {
$this->msg_plain = explode("\n", trim(HTML::toPlaintext($this->msg_html, 0)))[0];
} catch (\Exception $e) {
- $this->msg_plain = '';
+ $this->msg_plain = '';
}
}
}
public function __construct(string $name, string $value)
{
- $this->name = $name;
+ $this->name = $name;
$this->value = $value;
// Link verification unsupported
$this->verified_at = null;
$uriId,
new DateTime($contact['created'] ?? 'now', new DateTimeZone('UTC')),
$interacting_count ?? 0,
- $interacted_count ?? 0,
- $post_count ?? 0
+ $interacted_count ?? 0,
+ $post_count ?? 0
);
$DiasporaContact = $this->save($DiasporaContact);
$circle_ids = [];
if (!empty($user_contact_str) && $this->db->exists('contact', [
- 'id' => $cid,
- 'uid' => $uid,
+ 'id' => $cid,
+ 'uid' => $uid,
'blocked' => false
])) {
$circle_ids = Circle::getIdsByContactId($cid);
*/
public static function getPermissionsSQLByUserId(int $owner_id, bool $accessible = false)
{
- $local_user = DI::userSession()->getLocalUserId();
+ $local_user = DI::userSession()->getLocalUserId();
$remote_contact = DI::userSession()->getRemoteContactID($owner_id);
- $acc_sql = '';
+ $acc_sql = '';
if ($accessible) {
$acc_sql = ' OR `accessible`';
}
- /*
- * Construct permissions
- *
- * default permissions - anonymous user
- */
+ // Construct permissions: default permissions - anonymous user
$sql = " AND (allow_cid = ''
AND allow_gid = ''
AND deny_cid = ''
AND deny_gid = ''" . $acc_sql . ") ";
- /*
- * Profile owner - everything is visible
- */
if ($local_user && $local_user == $owner_id) {
+ // Profile owner - everything is visible
$sql = '';
- /*
- * Authenticated visitor. Load the circles the visitor belongs to.
- */
} elseif ($remote_contact) {
+ // Authenticated visitor. Load the circles the visitor belongs to.
$circleIds = '<<>>'; // should be impossible to match
foreach (Circle::getIdsByContactId($remote_contact) as $circleId) {