You can simply install it through PEAR: `pear install PHP_CodeSniffer`
Once it is installed and available in your PATH, here's the command to run before committing your work:
- $> phpcs --standard=PSR2 <file or directory>
+ $> phpcs --standard=ruleset.xml <file or directory>
The output is a list of all the coding standards violations that you should fix before committing your work.
Additionally, `phpcs` integrates with a few IDEs (Eclipse, Netbeans, PHPStorm...) so that you don't have to fiddle with the command line.
Thankfully, PHP Code Sniffer is shipped with an automatic code fixer that can take care of the tedious task for you.
Here's the command to automatically fix the files you created/modified:
- $> phpcbf --standard=PSR2 <file or directory>
+ $> phpcbf --standard=ruleset.xml <file or directory>
If the command-line tools `diff` and `patch` are unavailabe for you, `phpcbf` can use slightly slower PHP equivalents by using the `--no-patch` argument.
* **[Where can I find the source code of friendica, addons and themes?](help/FAQ#sources)**
* **[I've changed the my email address now the admin panel is gone?](help/FAQ#adminaccount1)**
* **[Can there be more then just one admin for a node?](help/FAQ#adminaccount2)**
+* **[The Database structure seems not to be updated. What can I do?](help/FAQ#dbupdate)**
User
--------
-*****
<a name="ssl"></a>
-
### Why do I get warnings about SSL certificates?
SSL (Secure Socket Layer) is a technology to encrypt data transfer between computers.
We recommend to talk to the admin(s) of the affected friendica server. (Admins, please see the respective section of the [admin manual](help/SSL).)
<a name="upload"></a>
-
### How can I upload images, files, links, videos and sound files to posts?
You can upload images from your computer using the [editor](help/Text_editor).
See Wikipedia for more of them ([video](http://en.wikipedia.org/wiki/HTML5_video), [audio](http://en.wikipedia.org/wiki/HTML5_audio)).
<a name="avatars"></a>
-
### Is it possible to have different avatars per profile?
Yes. On your Edit/Manage Profiles page, you will find a "change profile photo" link.
To avoid privacy leakage, we only display the photograph associated with your default profile as the avatar in your posts.
<a name="contacts"></a>
-
### What is the difference between blocked|ignored|archived|hidden contacts?
We prevent direct communication with **blocked contacts**.
However a hidden contact will appear normally in conversations and this may expose his/her hidden status to anybody who can see the conversation.
<a name="removed"></a>
-
### What happens when an account is removed? Is it truly deleted?
If you delete your account, we will immediately remove all your content on **your** server.
After that, your account is deleted.
<a name="hashtag"></a>
-
### Can I follow a hashtag?
No. The act of 'following' a hashtags is an interesting technology, but presents a few issues.
Instead, we offer other mechanisms for wide-area conversations while retaining a 'level playing ground' for both large and small sites, such as forums and community pages and shared tags.
<a name="rss"></a>
-
### How to create a RSS feed of the stream?
If you want to share your public page via rss you can use one of the following links:
-RSS feed of your posts
+#### RSS feed of your posts
- basic-url.com/**dfrn_poll/profilename
+ basic-url.com//feed/[nickname]/posts
- Example: Friendica Support
+Example: Friendica Support
- https://forum.friendi.ca/dfrn_poll/helpers
+ https://forum.friendi.ca/feed/helpers/posts
-RSS feed of the conversations at your site
+#### RSS feed of the conversations at your site
- basic-url.com/dfrn_poll/profilename/converse
+ basic-url.com/feed/profilename/comments
- Example: Friendica Support
+Example: Friendica Support
- https://forum.friendi.ca/dfrn_poll/helpers/converse
+ https://forum.friendi.ca/feed/helpers/comments
<a name="clients"></a>
-
### Are there any clients for friendica I can use?
Friendica is using a [Twitter/GNU Social compatible API](help/api), which means you can use any Twitter/GNU Social client for your plattform as long as you can change the API path in its settings.
Admin
--------
-*****
-<a name="multiple"></a>
+<a name="multiple"></a>
### Can I configure multiple domains with the same code instance?
No, this function is no longer supported as of Friendica 3.3 onwards.
<a name="sources"></a>
-
### Where can I find the source code of friendica, addons and themes?
You can find the main respository [here](https://github.com/friendica/friendica).
<a name="adminaccount2"></a>
### Can there be more then one admin for a node?
-Yes. You just have to list more then one email address in the
-<tt>.htconfig.php</tt> file. The listed emails need to be separated by a comma.
+Yes.
+You just have to list more then one email address in the
+<tt>.htconfig.php</tt> file.
+The listed emails need to be separated by a comma.
+
+<a name="dbupdate">
+### The Database structure seems not to be updated. What can I do?
+
+Please have a look at the Admin panel under [DB updates](/admin/dbsync/) and follow the link to *check database structure*.
+This will start a background process to check if the structure is up to the current definition.
+
+You can manually execute the structure update from the CLI in the base directory of your Friendica installation by running the following script:
+
+ scripts/dbstructure.php update
+
+if there occur any errors, please contact the [support forum](https://forum.friendi.ca/profile/helpers).
With Apache, enable the modules rewrite and ssl (with a shared hosting provider, this should be enabled already):
- sudo a2enmod rewrite ssl
+ sudo a2enmod rewrite ssl
Add the following lines to the .htaccess file in the root folder of your Friendica instance (thanks to [url=https://github.com/AlfredSK]AlfredSK[/url]):
Table gserver
=============
-| Field | Description | Type | Null | Key | Default | Extra |
-|-----------------|------------------|------------------|------|-----|---------------------|----------------|
-| id | sequential ID | int(10) unsigned | NO | PRI | NULL | auto_increment |
-| url | | varchar(255) | NO | | | |
-| nurl | | varchar(255) | NO | MUL | | |
-| version | | varchar(255) | NO | | | |
-| site_name | | varchar(255) | NO | | | |
-| info | | text | NO | | NULL | |
-| register_policy | | tinyint(1) | NO | | 0 | |
-| poco | | varchar(255) | NO | | | |
-| noscrape | | varchar(255) | NO | | | |
-| network | | varchar(32) | NO | | | |
-| platform | | varchar(255) | NO | | | |
-| created | | datetime | NO | | 0001-01-01 00:00:00 | |
-| last_poco_query | | datetime | YES | | 0001-01-01 00:00:00 | |
-| last_contact | | datetime | YES | | 0001-01-01 00:00:00 | |
-| last_failure | | datetime | YES | | 0001-01-01 00:00:00 | |
+| Field | Description | Type | Null | Key | Default | Extra |
+|------------------|---------------------------|------------------|------|-----|---------------------|----------------|
+| id | sequential ID | int(10) unsigned | NO | PRI | NULL | auto_increment |
+| url | | varchar(255) | NO | | | |
+| nurl | | varchar(255) | NO | MUL | | |
+| version | | varchar(255) | NO | | | |
+| site_name | | varchar(255) | NO | | | |
+| info | | text | NO | | NULL | |
+| register_policy | | tinyint(1) | NO | | 0 | |
+| registered-users |Number of registered users | int(10) | NO | | 0 | |
+| poco | | varchar(255) | NO | | | |
+| noscrape | | varchar(255) | NO | | | |
+| network | | varchar(32) | NO | | | |
+| platform | | varchar(255) | NO | | | |
+| created | | datetime | NO | | 0001-01-01 00:00:00 | |
+| last_poco_query | | datetime | YES | | 0001-01-01 00:00:00 | |
+| last_contact | | datetime | YES | | 0001-01-01 00:00:00 | |
+| last_failure | | datetime | YES | | 0001-01-01 00:00:00 | |
Return to [database documentation](help/database)
* **[Kann ich mehrere Domains mit den selben Dateien aufsetzen?](help/FAQ#multiple)**
* **[Wo kann ich den Quellcode von Friendica, Addons und Themes finden?](help/FAQ#sources)**
+* **[Ich habe meine E-Mail Adresse geändern und jetzt ist das Admin Panel verschwunden?](help/FAQ#adminaccount1)**
+* **[Kann es mehr als einen Admin auf einer Friendica Instanz geben?](help/FAQ#adminaccount2)**
+* **[Die Datenbank Struktur schein nicht aktuell zu sein. Was kann ich tun?](help/FAQ#dbupdate)**
Nutzer
--------
-****
-<a name="ssl"></a>
-**Warum erhalte ich Warnungen über fehlende Zertifikate?**
+<a name="ssl"></a>
+### Warum erhalte ich Warnungen über fehlende Zertifikate?
Manchmal erhältst Du eine Browser-Warnung über fehlende Zertifikate.
Diese Warnungen können drei Gründe haben:
Andere erlauben nur kostenpflichtige Zertifikate als eigenes Angebot bzw. von anderen Anbietern.
<a name="upload"></a>
-
-**Wie kann ich Bilder, Dateien, Links, Video und Audio in Beiträge einfügen?**
+### Wie kann ich Bilder, Dateien, Links, Video und Audio in Beiträge einfügen?
Bilder können direkt im [Beitragseditor](help/Text_editor) vom Computer hochgeladen werden.
Eine Ãœbersicht aller Bilder, die auf Deinem Server liegen, findest Du unter <i>deineSeite.de/photos/profilname</i>.
Zum Konvertieren von Videos in das lizenfreie Videoformat WebM gibt es unter Windows das kostenlose Programm [Xmedia-Recode](http://www.xmedia-recode.de/).
<a name="avatars"></a>
-
-**Ist es möglich, bei mehreren Profilen verschiedene Avatare (Nutzerbilder) zu haben?**
+### Ist es möglich, bei mehreren Profilen verschiedene Avatare (Nutzerbilder) zu haben?
Ja.
Auf Deiner ["Profile verwalten/editieren"-Seite](../profiles) wählst Du zunächst das gewünschte Profil aus.
Um Deine privaten Daten zu schützen, wird in Beiträgen nur das Bild aus Deinem öffentlichen Profil angezeigt.
<a name="contacts"></a>
-
-**Was ist der Unterschied zwischen blockierten|ignorierten|archivierten|versteckten Kontakten?**
+### Was ist der Unterschied zwischen blockierten|ignorierten|archivierten|versteckten Kontakten?
Wir verhindern direkte Kommunikation mit blockierten Kontakten.
Sie gehören nicht zu den Empfängern beim Versand von Beiträgen und deren Beiträge werden auch nicht importiert.
Trotzdem wird ein versteckter Kontakt normal in Unterhaltungen angezeigt - was für andere Kontakte ein Hinweis sein kann, dass diese Person als versteckter Kontakt in Deiner Liste ist.
<a name="removed"></a>
-
-**Was passiert, wenn ein Account gelöscht ist? Ist dieser richtig gelöscht?**
+### Was passiert, wenn ein Account gelöscht ist? Ist dieser richtig gelöscht?
Wenn Du Deinen Account löschst, wird sofort der gesamte Inhalt auf Deinem Server gelöscht und ein Löschbefehl an alle Deine Kontakte verschickt.
Dadurch wirst Du ebenfalls aus dem globalen Verzeichnis gelöscht.
Wir können also Dein Profil blockieren und es so erscheinen lassen, als wären alle Daten sofort gelöscht, allerdings warten wir 24 Stunden (bzw. bis alle Deine Kontakte informiert wurden), bevor wir die Daten auch physikalisch löschen.
<a name="hashtag"></a>
-
-**Kann ich einem hashtag folgen?**
+### Kann ich einem hashtag folgen?
Nein.
Die Möglichkeit, einem hashtag zu folgen, ist eine interessante Technik, führt aber zu einigen Schwierigkeiten.
Hierzu gehören Foren, Gruppen und geteilte tags.
<a name="rss"></a>
-
-**Wie kann ich einen RSS-Feed meiner Netzwerkseite (Stream) erstellen?**
+### Wie kann ich einen RSS-Feed meiner Netzwerkseite (Stream) erstellen?
Wenn Du die Beiträge Deines Accounts mit RSS teilen willst, dann kannst Du einen der folgenden Links nutzen:
-RSS-Feed Deiner Beiträge
+#### RSS-Feed Deiner Beiträge
- deineSeite.de/**dfrn_poll/profilname
+ deineSeite.de/feed/[profilname]/posts
- Beispiel: Friendica Support
+Beispiel: Friendica Support
- https://forum.friendi.ca/dfrn_poll/helpers
+ https://forum.friendi.ca/feed/helpers/posts
-RSS-Feed aller Unterhaltungen auf Deiner Seite
+#### RSS-Feed all deiner Beiträge und Antworten
- deineSeite.de/dfrn_poll/profilname/converse
+ deineSeite.de/dfrn_poll/feed/[profilname]/comments
- Beispiel: Friendica Support
+Beispiel: Friendica Support
- https://forum.friendi.ca/dfrn_poll/helpers/converse
+ https://forum.friendi.ca/feeds/helpers/comments
-<a name="clients">
+#### RSS-Feed all deiner Aktivitäten
+ deineSeite.de/feed/[profilname]/
+
+<a name="clients">
### Gibt es Clients für Friendica?
Friendica verwendet eine [Twitter/GNU Social](help/api) kompatible API.
* Hotot
<a name="help"></a>
-
-**Wo finde ich Hilfe?**
+### Wo finde ich Hilfe?
Wenn Du Probleme mit Deiner Friendica-Seite hast, dann kannst Du die Community in der [Friendica-Support-Gruppe](https://forum.friendi.ca/profile/helpers) oder im [deutschen Friendica-Support-Forum](http://toktan.org/profile/wiki) fragen oder Dir das [deutsche Wiki](http://wiki.toktan.org/doku.php) anschauen.
Wenn Du Deinen Account nicht nutzen kannst, kannst Du entweder einen [Testaccount](https://tryfriendica.de) bzw. einen Account auf einer öffentlichen Seite ([Liste](https://dir.friendica.social/servers)) nutzen, oder Du wählst die Librelist-mailing-Liste.
Admin
--------
-*****
-<a name="multiple"></a>
-**Kann ich mehrere Domains mit den selben Dateien aufsetzen?**
+<a name="multiple"></a>
+### Kann ich mehrere Domains mit den selben Dateien aufsetzen?
Ja, das ist möglich.
Es ist allerdings nicht möglich, eine Datenbank durch zwei Domains zu nutzen.
Alle Cache-Aspekte und der Zugriffsschutz können pro Instanz konfiguriert werden.
<a name="sources"></a>
-
-**Wo kann ich den Quellcode von Friendica, Addons und Themes finden?**
+### Wo kann ich den Quellcode von Friendica, Addons und Themes finden?
Du kannst den Friendica-Quellcode [hier](https://github.com/friendica/friendica) finden.
Dort findest Du immer die aktuellste stabile Version von Friendica.
Addons findest Du auf [dieser Seite](https://github.com/friendica/friendica-addons).
Wenn Du neue Themen suchst, findest Du sie auf [Friendica-Themes.com](http://friendica-themes.com/).
+
+<a name="adminaccount1"></a>
+### Ich habe meine E-Mail Adresse geändern und jetzt ist das Admin Panel verschwunden?
+
+Bitte aktualisiere deine E-Mail Adresse in der <tt>.htconfig.php</tt> Datei.
+
+<a name="adminaccount2"></a>
+### Kann es mehr als einen Admin auf einer Friendica Instanz geben?
+
+Ja.
+Du kannst in der <tt>.htconfig.php</tt> Datei mehrere E-Mail Adressen auflisten.
+Die aufgelisteten Adressen werden mit Kommata von einander getrennt.
+
+<a name="dbupdate">
+### Die Datenbank Struktur schein nicht aktuell zu sein. Was kann ich tun?
+
+Rufe bitte im Admin Panel den Punkt [DB Updates](/admin/dbsync/) auf und folge dem Link *Datenbank Struktur überprüfen*.
+Damit wird ein Hintergrundprozess gestartet der die Struktur deiner Datenbank überprüft und gegebenenfalls aktualisiert.
+
+Du kannst das Struktur Updatee auch manuell auf der Kommandoeingabe ausführen.
+Starte dazu bitte vom Grundverzeichnis deiner Friendica Instanz folgendes Skript:
+
+ scripts/dbstructure.php update
+
+sollten bei der Ausführung Fehler auftreten, kontaktiere bitte das [Support Forum](https://forum.friendi.ca/profile/helpers).
* [Zur Startseite der Hilfe](help)
-Disclaimer
----
+## Disclaimer
+
**Dieses Dokument wurde im November 2016 aktualisiert.
SSL-Verschlüsselung ist sicherheitskritisch.
Das bedeutet, dass sich die empfohlenen Einstellungen schnell verändern.
Halte deine Installation auf dem aktuellen Stand und verlasse dich nicht darauf, dass dieses Dokument genau so schnell aktualisiert wird, wie sich Technologien verändern!**
-Einleitung
----
+## Einleitung
Wenn du deine eigene Friendica-Seite betreibst, willst du vielleicht SSL (https) nutzen, um die Kommunikation zwischen den Servern und zwischen dir und deinem Server zu verschlüsseln.
Es gibt aber Möglichkeiten, ein vertrauenswürdiges Zertifikat umsonst zu bekommen.
-Wähle deinen Domainnamen
----
+## Wähle deinen Domainnamen
Dein SSL-Zertifikat wird für eine bestimmte Domain gültig sein oder sogar nur für eine Subdomain.
Entscheide dich endgültig für einen Domainnamen, *bevor* du ein Zertifikat bestellst.
Wenn du das Zertifikat hast, brauchst du ein neues, wenn du den Domainnamen ändern möchtest.
-Gehosteter Webspace
----
+## Gehosteter Webspace
Wenn deine Friendica-Instanz auf einem gehosteten Webspace läuft, solltest du dich bei deinem Hosting-Provider informieren.
Dort bekommst du Instruktionen, wie es dort läuft.
Wenn ja, dann lies weiter.
-Let's encrypt
----
+## Let's encrypt
Wenn du einen eigenen Server betreibst und den Nameserver kontrollierst, könnte auch die Initiative "Let's encrypt" interessant für dich werden.
Sie bietet nicht nur freie SSL Zertifikate sondern auch einen automatisierten Prozess zum Erneuern der Zertifikate.
Eine Anleitung zum offiziellen Client findet du [hier](https://certbot.eff.org/).
Falls du dir andere Clients anschauen willst, kannst du einen Blick in diese [Liste von alternativen letsencrypt Clients](https://letsencrypt.org/docs/client-options/).
-Webserver-Einstellungen
----
+## Webserver-Einstellungen
Im [Wiki von Mozilla](https://wiki.mozilla.org/Security/Server_Side_TLS) gibt es Anleitungen für die Konfiguration sicherer Webserver.
Dort findest du Empfehlungen, die auf [verschiedene Webserver](https://wiki.mozilla.org/Security/Server_Side_TLS#Recommended_Server_Configurations) zugeschnitten sind.
-Teste deine SSL-Einstellungen
----
+## Teste deine SSL-Einstellungen
Wenn du fertig bist, kannst du auf der Testseite [SSL-Labs](https://www.ssllabs.com/ssltest/) prüfen lassen, ob Du alles richtig gemacht hast.
+## Friendica Konfigurieren
+Wenn du deine Friendica Instanz über https erreichen kannst solltest du ein paar Einstellungen vornehmen um sicher zu stellen, dass deine Nutzer ausschließlich über https zugreifen können.
+### Webserver-Umleitungen
+Dies ist der einfachste Weg den Zugriff für die ganze Webseite abzusichern.
+Jedes Mal wenn ein Nutzer Friendica aufruft wird er permanent vom Webserver auf die abgesicherte Seite umgeleitet.
+Wenn du den Apache Webserver verwendest, aktiviere die Module rewrite und ssl (bei einem Shared-Hosting Prider sollte dies bereits der Fall sein):
+ sudo a2enmod rewrite ssl
+und füge die folgenden Zeilen zur .htaccess Datei im Wurzelverzeichnis deiner Friendica Instanz hinzu:
+ RewriteEngine On
+ RewriteCond %{SERVER_PORT} 80
+ RewriteRule ^(.*)$ https://your.friendica.domain/$1 [R=301,L]
+(Dank an [url=https://github.com/AlfredSK]AlfredSK[/url]).
+Bei nginx solltest du deinen Server folgendermaßen konfigurieren ([documentation](https://www.nginx.com/blog/creating-nginx-rewrite-rules/)):
+ server {
+ listen 80;
+ server_name your.friendica.domain;
+ return 301 https://$server_name$request_uri;
+ }
+### SSL Einstellungen
+Im Admin-Panel gibt es drei Einstellungen, die SSL betreffen:
-
-
-
-
-
+1. **Regeln für SSL Links**: Diese Einstellung betrifft wie Friendica interne Links erzeugt. Wenn deine SSL Installation erfolgreich war, empfehlen wir die Einstellung "SSL für alle Links erzwingen".
+2. **Erzwinge SSL**: Mit dieser Einstellung werden alle externen Links auf HTTPS gesetzt. Dies kann bei Mixed-Content Problemen helfen, allerdings unterstützen noch nicht alle Webseiten HTTPS. Benutzung auf eigene Gefahr.
+3. **SSL überprüfen**: Wenn diese Einstellung aktiv ist, wird Friendica nicht mehr mit Instanzen interagieren, die über ein selbst signiertes Zertifikat verfügen. Da selbst signierte Zertifikate ein Hinweis auf Man-in-the.Middle Angriffe sein können, empfehlen wir dies zu tun.
use Friendica\Model\Contact;
use Friendica\Model\GContact;
-require_once "include/contact_selectors.php";
require_once "include/contact_widgets.php";
require_once "mod/proxy.php";
* @todo Automatically detect if incoming data is HTML or BBCode
*/
use Friendica\App;
+use Friendica\Content\ContactSelector;
use Friendica\Content\Feature;
use Friendica\Core\System;
use Friendica\Core\Config;
require_once 'mod/share.php';
require_once 'mod/item.php';
require_once 'include/security.php';
-require_once 'include/contact_selectors.php';
require_once 'include/html2bbcode.php';
require_once 'mod/wall_upload.php';
require_once 'mod/proxy.php';
}
if (DBM::is_result($r)) {
- $network_name = network_to_name($r[0]['network'], $r[0]['url']);
+ $network_name = ContactSelector::networkToName($r[0]['network'], $r[0]['url']);
// If no nick where given, extract it from the address
if (($r[0]['nick'] == "") || ($r[0]['name'] == $r[0]['nick'])) {
$uinfo[0]['nick'] = api_get_nick($uinfo[0]["url"]);
}
- $network_name = network_to_name($uinfo[0]['network'], $uinfo[0]['url']);
+ $network_name = ContactSelector::networkToName($uinfo[0]['network'], $uinfo[0]['url']);
$pcontact_id = Contact::getIdForURL($uinfo[0]['url'], 0, true);
}
if (($lastwall['item_network'] != "") && ($status["source"] == 'web')) {
- $status_info["source"] = network_to_name($lastwall['item_network'], $user_info['url']);
- } elseif (($lastwall['item_network'] != "") && (network_to_name($lastwall['item_network'], $user_info['url']) != $status_info["source"])) {
- $status_info["source"] = trim($status_info["source"].' ('.network_to_name($lastwall['item_network'], $user_info['url']).')');
+ $status_info["source"] = ContactSelector::networkToName($lastwall['item_network'], $user_info['url']);
+ } elseif (($lastwall['item_network'] != "") && (ContactSelector::networkToName($lastwall['item_network'], $user_info['url']) != $status_info["source"])) {
+ $status_info["source"] = trim($status_info["source"].' ('.ContactSelector::networkToName($lastwall['item_network'], $user_info['url']).')');
}
// "uid" and "self" are only needed for some internal stuff, so remove it from here
}
if (($lastwall['item_network'] != "") && ($user_info["status"]["source"] == 'web')) {
- $user_info["status"]["source"] = network_to_name($lastwall['item_network'], $user_info['url']);
+ $user_info["status"]["source"] = ContactSelector::networkToName($lastwall['item_network'], $user_info['url']);
}
- if (($lastwall['item_network'] != "") && (network_to_name($lastwall['item_network'], $user_info['url']) != $user_info["status"]["source"])) {
- $user_info["status"]["source"] = trim($user_info["status"]["source"] . ' (' . network_to_name($lastwall['item_network'], $user_info['url']) . ')');
+ if (($lastwall['item_network'] != "") && (ContactSelector::networkToName($lastwall['item_network'], $user_info['url']) != $user_info["status"]["source"])) {
+ $user_info["status"]["source"] = trim($user_info["status"]["source"] . ' (' . ContactSelector::networkToName($lastwall['item_network'], $user_info['url']) . ')');
}
}
}
if (($item['item_network'] != "") && ($status["source"] == 'web')) {
- $status["source"] = network_to_name($item['item_network'], $user_info['url']);
- } elseif (($item['item_network'] != "") && (network_to_name($item['item_network'], $user_info['url']) != $status["source"])) {
- $status["source"] = trim($status["source"].' ('.network_to_name($item['item_network'], $user_info['url']).')');
+ $status["source"] = ContactSelector::networkToName($item['item_network'], $user_info['url']);
+ } elseif (($item['item_network'] != "") && (ContactSelector::networkToName($item['item_network'], $user_info['url']) != $status["source"])) {
+ $status["source"] = trim($status["source"].' ('.ContactSelector::networkToName($item['item_network'], $user_info['url']).')');
}
+++ /dev/null
-<?php
-
-use Friendica\Database\DBM;
-use Friendica\Protocol\Diaspora;
-
-function contact_profile_assign($current,$foreign_net) {
-
- $o = '';
-
- $disabled = (($foreign_net) ? ' disabled="true" ' : '');
-
- $o .= "<select id=\"contact-profile-selector\" class=\"form-control\" $disabled name=\"profile-assign\" >\r\n";
-
- $r = q("SELECT `id`, `profile-name`, `is-default` FROM `profile` WHERE `uid` = %d",
- intval($_SESSION['uid']));
-
- if (DBM::is_result($r)) {
- foreach ($r as $rr) {
- $selected = (($rr['id'] == $current || ($current == 0 && $rr['is-default'] == 1)) ? " selected=\"selected\" " : "");
- $o .= "<option value=\"{$rr['id']}\" $selected >{$rr['profile-name']}</option>\r\n";
- }
- }
- $o .= "</select>\r\n";
- return $o;
-}
-
-
-function contact_reputation($current) {
-
- $o = '';
- $o .= "<select id=\"contact-reputation-selector\" name=\"reputation\" />\r\n";
-
- $rep = array(
- 0 => t('Unknown | Not categorised'),
- 1 => t('Block immediately'),
- 2 => t('Shady, spammer, self-marketer'),
- 3 => t('Known to me, but no opinion'),
- 4 => t('OK, probably harmless'),
- 5 => t('Reputable, has my trust')
- );
-
- foreach ($rep as $k => $v) {
- $selected = (($k == $current) ? " selected=\"selected\" " : "");
- $o .= "<option value=\"$k\" $selected >$v</option>\r\n";
- }
- $o .= "</select>\r\n";
- return $o;
-}
-
-
-function contact_poll_interval($current, $disabled = false) {
-
- $dis = (($disabled) ? ' disabled="disabled" ' : '');
- $o = '';
- $o .= "<select id=\"contact-poll-interval\" name=\"poll\" $dis />" . "\r\n";
-
- $rep = array(
- 0 => t('Frequently'),
- 1 => t('Hourly'),
- 2 => t('Twice daily'),
- 3 => t('Daily'),
- 4 => t('Weekly'),
- 5 => t('Monthly')
- );
-
- foreach ($rep as $k => $v) {
- $selected = (($k == $current) ? " selected=\"selected\" " : "");
- $o .= "<option value=\"$k\" $selected >$v</option>\r\n";
- }
- $o .= "</select>\r\n";
- return $o;
-}
-
-
-function network_to_name($s, $profile = "") {
-
- $nets = array(
- NETWORK_DFRN => t('Friendica'),
- NETWORK_OSTATUS => t('OStatus'),
- NETWORK_FEED => t('RSS/Atom'),
- NETWORK_MAIL => t('Email'),
- NETWORK_DIASPORA => t('Diaspora'),
- NETWORK_FACEBOOK => t('Facebook'),
- NETWORK_ZOT => t('Zot!'),
- NETWORK_LINKEDIN => t('LinkedIn'),
- NETWORK_XMPP => t('XMPP/IM'),
- NETWORK_MYSPACE => t('MySpace'),
- NETWORK_GPLUS => t('Google+'),
- NETWORK_PUMPIO => t('pump.io'),
- NETWORK_TWITTER => t('Twitter'),
- NETWORK_DIASPORA2 => t('Diaspora Connector'),
- NETWORK_STATUSNET => t('GNU Social Connector'),
- NETWORK_PNUT => t('pnut'),
- NETWORK_APPNET => t('App.net')
- );
-
- call_hooks('network_to_name', $nets);
-
- $search = array_keys($nets);
- $replace = array_values($nets);
-
- $networkname = str_replace($search, $replace, $s);
-
- if ((in_array($s, array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) && ($profile != "")) {
- $r = dba::fetch_first("SELECT `gserver`.`platform` FROM `gcontact`
- INNER JOIN `gserver` ON `gserver`.`nurl` = `gcontact`.`server_url`
- WHERE `gcontact`.`nurl` = ? AND `platform` != ''", normalise_link($profile));
-
- if (DBM::is_result($r)) {
- $networkname = $r['platform'];
- }
- }
-
- return $networkname;
-}
<?php
-
/**
* @file include/contact_widgets.php
*/
+use Friendica\Content\ContactSelector;
use Friendica\Content\Feature;
use Friendica\Core\System;
use Friendica\Core\Config;
use Friendica\Database\DBM;
use Friendica\Model\GContact;
-require_once 'include/contact_selectors.php';
-
function follow_widget($value = "")
{
return replace_macros(get_markup_template('follow.tpl'), array(
while ($rr = dba::fetch($r)) {
/// @TODO If 'network' is not there, this triggers an E_NOTICE
if ($rr['network']) {
- $nets[] = array('ref' => $rr['network'], 'name' => network_to_name($rr['network']), 'selected' => (($selected == $rr['network']) ? 'selected' : '' ));
+ $nets[] = array('ref' => $rr['network'], 'name' => ContactSelector::networkToName($rr['network']), 'selected' => (($selected == $rr['network']) ? 'selected' : '' ));
}
}
dba::close($r);
* @file include/conversation.php
*/
use Friendica\App;
+use Friendica\Content\ContactSelector;
use Friendica\Content\Feature;
use Friendica\Core\Config;
use Friendica\Core\PConfig;
'id' => (($preview) ? 'P0' : $item['item_id']),
'guid' => (($preview) ? 'Q0' : $item['guid']),
'network' => $item['item_network'],
- 'network_name' => network_to_name($item['item_network'], $profile_link),
+ 'network_name' => ContactSelector::networkToName($item['item_network'], $profile_link),
'linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])),
'profile_url' => $profile_link,
'item_photo_menu' => item_photo_menu($item),
+++ /dev/null
-<?php
-
-function create_files_from_item($itemid)
-{
- $messages = q("SELECT `guid`, `uid`, `id`, `edited`, `deleted`, `file`, `parent` FROM `item` WHERE `id` = %d LIMIT 1", intval($itemid));
- if (!$messages) {
- return;
- }
-
- $message = $messages[0];
-
- // Clean up all tags
- q("DELETE FROM `term` WHERE `otype` = %d AND `oid` = %d AND `type` IN (%d, %d)",
- intval(TERM_OBJ_POST),
- intval($itemid),
- intval(TERM_FILE),
- intval(TERM_CATEGORY));
-
- if ($message["deleted"])
- return;
-
- if (preg_match_all("/\[(.*?)\]/ism", $message["file"], $files)) {
- foreach ($files[1] as $file) {
- q("INSERT INTO `term` (`uid`, `oid`, `otype`, `type`, `term`) VALUES (%d, %d, %d, %d, '%s')",
- intval($message["uid"]), intval($itemid), intval(TERM_OBJ_POST), intval(TERM_FILE), dbesc($file));
- }
- }
-
- if (preg_match_all("/\<(.*?)\>/ism", $message["file"], $files)) {
- foreach ($files[1] as $file) {
- q("INSERT INTO `term` (`uid`, `oid`, `otype`, `type`, `term`) VALUES (%d, %d, %d, %d, '%s')",
- intval($message["uid"]), intval($itemid), intval(TERM_OBJ_POST), intval(TERM_CATEGORY), dbesc($file));
- }
- }
-}
-
-function create_files_from_itemuri($itemuri, $uid)
-{
- $messages = q("SELECT `id` FROM `item` WHERE uri ='%s' AND uid=%d", dbesc($itemuri), intval($uid));
-
- if (count($messages)) {
- foreach ($messages as $message)
- create_files_from_item($message["id"]);
- }
-}
-
-function update_files_for_items()
-{
- $messages = q("SELECT `id` FROM `item` where file !=''");
-
- foreach ($messages as $message) {
- echo $message["id"] . "\n";
- create_files_from_item($message["id"]);
- }
-}
+++ /dev/null
-<?php
-
-/**
- * @file include/follow.php
- */
-use Friendica\App;
-use Friendica\Core\Config;
-use Friendica\Core\System;
-use Friendica\Core\Worker;
-use Friendica\Database\DBM;
-use Friendica\Model\Contact;
-use Friendica\Model\Group;
-use Friendica\Model\User;
-use Friendica\Network\Probe;
-use Friendica\Protocol\Diaspora;
-use Friendica\Protocol\OStatus;
-use Friendica\Protocol\PortableContact;
-use Friendica\Protocol\Salmon;
-
-function update_contact($id)
-{
- /*
- Warning: Never ever fetch the public key via Probe::uri and write it into the contacts.
- This will reliably kill your communication with Friendica contacts.
- */
-
- $r = q("SELECT `url`, `nurl`, `addr`, `alias`, `batch`, `notify`, `poll`, `poco`, `network` FROM `contact` WHERE `id` = %d", intval($id));
- if (!$r) {
- return false;
- }
-
- $ret = Probe::uri($r[0]["url"]);
-
- // If Probe::uri fails the network code will be different
- if ($ret["network"] != $r[0]["network"]) {
- return false;
- }
-
- $update = false;
-
- // make sure to not overwrite existing values with blank entries
- foreach ($ret AS $key => $val) {
- if (isset($r[0][$key]) && ($r[0][$key] != "") && ($val == ""))
- $ret[$key] = $r[0][$key];
-
- if (isset($r[0][$key]) && ($ret[$key] != $r[0][$key]))
- $update = true;
- }
-
- if (!$update) {
- return true;
- }
-
- q("UPDATE `contact` SET `url` = '%s', `nurl` = '%s', `addr` = '%s', `alias` = '%s', `batch` = '%s', `notify` = '%s', `poll` = '%s', `poco` = '%s' WHERE `id` = %d",
- dbesc($ret['url']),
- dbesc(normalise_link($ret['url'])),
- dbesc($ret['addr']),
- dbesc($ret['alias']),
- dbesc($ret['batch']),
- dbesc($ret['notify']),
- dbesc($ret['poll']),
- dbesc($ret['poco']),
- intval($id)
- );
-
- // Update the corresponding gcontact entry
- PortableContact::lastUpdated($ret["url"]);
-
- return true;
-}
-
-/**
- * Takes a $uid and a url/handle and adds a new contact
- * Currently if the contact is DFRN, interactive needs to be true, to redirect to the
- * dfrn_request page.
- *
- * Otherwise this can be used to bulk add statusnet contacts, twitter contacts, etc.
- *
- * Returns an array
- * $return['success'] boolean true if successful
- * $return['message'] error text if success is false.
- *
- * @brief Takes a $uid and a url/handle and adds a new contact
- * @param int $uid
- * @param string $url
- * @param bool $interactive
- * @param string $network
- * @return boolean|string
- */
-function new_contact($uid, $url, $interactive = false, $network = '')
-{
- $result = array('cid' => -1, 'success' => false, 'message' => '');
-
- $a = get_app();
-
- // remove ajax junk, e.g. Twitter
- $url = str_replace('/#!/', '/', $url);
-
- if (!allowed_url($url)) {
- $result['message'] = t('Disallowed profile URL.');
- return $result;
- }
-
- if (blocked_url($url)) {
- $result['message'] = t('Blocked domain');
- return $result;
- }
-
- if (!$url) {
- $result['message'] = t('Connect URL missing.');
- return $result;
- }
-
- $arr = array('url' => $url, 'contact' => array());
-
- call_hooks('follow', $arr);
-
- if (x($arr['contact'], 'name')) {
- $ret = $arr['contact'];
- } else {
- $ret = Probe::uri($url, $network, $uid, false);
- }
-
- if (($network != '') && ($ret['network'] != $network)) {
- logger('Expected network ' . $network . ' does not match actual network ' . $ret['network']);
- return result;
- }
-
- if ($ret['network'] === NETWORK_DFRN) {
- if ($interactive) {
- if (strlen($a->path)) {
- $myaddr = bin2hex(System::baseUrl() . '/profile/' . $a->user['nickname']);
- } else {
- $myaddr = bin2hex($a->user['nickname'] . '@' . $a->get_hostname());
- }
-
- goaway($ret['request'] . "&addr=$myaddr");
-
- // NOTREACHED
- }
- } elseif (Config::get('system', 'dfrn_only')) {
- $result['message'] = t('This site is not configured to allow communications with other networks.') . EOL;
- $result['message'] != t('No compatible communication protocols or feeds were discovered.') . EOL;
- return $result;
- }
-
- // This extra param just confuses things, remove it
- if ($ret['network'] === NETWORK_DIASPORA) {
- $ret['url'] = str_replace('?absolute=true', '', $ret['url']);
- }
-
- // do we have enough information?
-
- if (!((x($ret, 'name')) && (x($ret, 'poll')) && ((x($ret, 'url')) || (x($ret, 'addr'))))) {
- $result['message'] .= t('The profile address specified does not provide adequate information.') . EOL;
- if (!x($ret, 'poll')) {
- $result['message'] .= t('No compatible communication protocols or feeds were discovered.') . EOL;
- }
- if (!x($ret, 'name')) {
- $result['message'] .= t('An author or name was not found.') . EOL;
- }
- if (!x($ret, 'url')) {
- $result['message'] .= t('No browser URL could be matched to this address.') . EOL;
- }
- if (strpos($url, '@') !== false) {
- $result['message'] .= t('Unable to match @-style Identity Address with a known protocol or email contact.') . EOL;
- $result['message'] .= t('Use mailto: in front of address to force email check.') . EOL;
- }
- return $result;
- }
-
- if ($ret['network'] === NETWORK_OSTATUS && Config::get('system', 'ostatus_disabled')) {
- $result['message'] .= t('The profile address specified belongs to a network which has been disabled on this site.') . EOL;
- $ret['notify'] = '';
- }
-
- if (!$ret['notify']) {
- $result['message'] .= t('Limited profile. This person will be unable to receive direct/personal notifications from you.') . EOL;
- }
-
- $writeable = ((($ret['network'] === NETWORK_OSTATUS) && ($ret['notify'])) ? 1 : 0);
-
- $subhub = (($ret['network'] === NETWORK_OSTATUS) ? true : false);
-
- $hidden = (($ret['network'] === NETWORK_MAIL) ? 1 : 0);
-
- if (in_array($ret['network'], array(NETWORK_MAIL, NETWORK_DIASPORA))) {
- $writeable = 1;
- }
-
- // check if we already have a contact
- // the poll url is more reliable than the profile url, as we may have
- // indirect links or webfinger links
-
- $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `poll` IN ('%s', '%s') AND `network` = '%s' LIMIT 1",
- intval($uid),
- dbesc($ret['poll']),
- dbesc(normalise_link($ret['poll'])),
- dbesc($ret['network'])
- );
-
- if (!DBM::is_result($r)) {
- $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' AND `network` = '%s' LIMIT 1",
- intval($uid), dbesc(normalise_link($url)), dbesc($ret['network'])
- );
- }
-
- if (DBM::is_result($r)) {
- // update contact
- $new_relation = (($r[0]['rel'] == CONTACT_IS_FOLLOWER) ? CONTACT_IS_FRIEND : CONTACT_IS_SHARING);
-
- $fields = array('rel' => $new_relation, 'subhub' => $subhub, 'readonly' => false);
- dba::update('contact', $fields, array('id' => $r[0]['id']));
- } else {
- $new_relation = ((in_array($ret['network'], array(NETWORK_MAIL))) ? CONTACT_IS_FRIEND : CONTACT_IS_SHARING);
-
- // create contact record
- q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `addr`, `alias`, `batch`, `notify`, `poll`, `poco`, `name`, `nick`, `network`, `pubkey`, `rel`, `priority`,
- `writable`, `hidden`, `blocked`, `readonly`, `pending`, `subhub` )
- VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, 0, 0, 0, %d ) ",
- intval($uid),
- dbesc(datetime_convert()),
- dbesc($ret['url']),
- dbesc(normalise_link($ret['url'])),
- dbesc($ret['addr']),
- dbesc($ret['alias']),
- dbesc($ret['batch']),
- dbesc($ret['notify']),
- dbesc($ret['poll']),
- dbesc($ret['poco']),
- dbesc($ret['name']),
- dbesc($ret['nick']),
- dbesc($ret['network']),
- dbesc($ret['pubkey']),
- intval($new_relation),
- intval($ret['priority']),
- intval($writeable),
- intval($hidden),
- intval($subhub)
- );
- }
-
- $r = q("SELECT * FROM `contact` WHERE `url` = '%s' AND `network` = '%s' AND `uid` = %d LIMIT 1",
- dbesc($ret['url']),
- dbesc($ret['network']),
- intval($uid)
- );
-
- if (!DBM::is_result($r)) {
- $result['message'] .= t('Unable to retrieve contact information.') . EOL;
- return $result;
- }
-
- $contact = $r[0];
- $contact_id = $r[0]['id'];
- $result['cid'] = $contact_id;
-
- Group::addMember(User::getDefaultGroup($uid, $contact["network"]), $contact_id);
-
- // Update the avatar
- Contact::updateAvatar($ret['photo'], $uid, $contact_id);
-
- // pull feed and consume it, which should subscribe to the hub.
-
- Worker::add(PRIORITY_HIGH, "OnePoll", $contact_id, "force");
-
- $r = q("SELECT `contact`.*, `user`.* FROM `contact` INNER JOIN `user` ON `contact`.`uid` = `user`.`uid`
- WHERE `user`.`uid` = %d AND `contact`.`self` LIMIT 1",
- intval($uid)
- );
-
- if (DBM::is_result($r)) {
- if (($contact['network'] == NETWORK_OSTATUS) && (strlen($contact['notify']))) {
- // create a follow slap
- $item = array();
- $item['verb'] = ACTIVITY_FOLLOW;
- $item['follow'] = $contact["url"];
- $slap = OStatus::salmon($item, $r[0]);
- Salmon::slapper($r[0], $contact['notify'], $slap);
- }
-
- if ($contact['network'] == NETWORK_DIASPORA) {
- $ret = Diaspora::sendShare($a->user, $contact);
- logger('share returns: ' . $ret);
- }
- }
-
- $result['success'] = true;
- return $result;
-}
use Friendica\Model\Contact;
use Friendica\Model\GContact;
use Friendica\Model\Group;
+use Friendica\Model\Term;
use Friendica\Model\User;
use Friendica\Object\Image;
use Friendica\Protocol\DFRN;
require_once 'include/bbcode.php';
require_once 'include/tags.php';
-require_once 'include/files.php';
require_once 'include/text.php';
require_once 'include/threads.php';
require_once 'include/plaintext.php';
* This is not perfect - but a workable solution until we found the reason for the problem.
*/
create_tags_from_item($current_post);
- create_files_from_item($current_post);
+ Term::createFromItem($current_post);
/*
* If this is now the last-child, force all _other_ children of this parent to *not* be last-child
array('id' => $item['id']));
create_tags_from_item($item['id']);
- create_files_from_item($item['id']);
+ Term::createFromItem($item['id']);
delete_thread($item['id'], $item['parent-uri']);
// clean up categories and tags so they don't end up as orphans
array('parent-uri' => $item['parent-uri'], 'uid' => $item['uid']));
create_tags_from_itemuri($item['parent-uri'], $item['uid']);
- create_files_from_itemuri($item['parent-uri'], $item['uid']);
+ Term::createFromItemURI($item['parent-uri'], $item['uid']);
delete_thread_uri($item['parent-uri'], $item['uid']);
// ignore the result
} else {
* @file include/text.php
*/
use Friendica\App;
+use Friendica\Content\ContactSelector;
use Friendica\Content\Feature;
use Friendica\Content\Smilies;
use Friendica\Core\Config;
use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Database\DBM;
+use Friendica\Model\Term;
use Friendica\Util\Map;
require_once "include/friendica_smarty.php";
}
/**
- * search box
+ * Search box.
*
- * @param string $s search query
- * @param string $id html id
- * @param string $url search url
- * @param boolean $savedsearch show save search button
+ * @param string $s Search query.
+ * @param string $id HTML id
+ * @param string $url Search url.
+ * @param bool $save Show save search button.
+ * @param bool $aside Display the search widgit aside.
+ *
+ * @return string Formatted HTML.
*/
-function search($s, $id = 'search-box', $url = 'search', $save = false, $aside = true) {
+function search($s, $id = 'search-box', $url = 'search', $save = false, $aside = true)
+{
+ $mode = 'text';
+
+ if (strpos($s, '#') === 0) {
+ $mode = 'tag';
+ }
+ $save_label = $mode === 'text' ? t('Save') : t('Follow');
+
$values = array(
'$s' => htmlspecialchars($s),
'$id' => $id,
'$action_url' => $url,
'$search_label' => t('Search'),
- '$save_label' => t('Save'),
+ '$save_label' => $save_label,
'$savedsearch' => Feature::isEnabled(local_user(),'savedsearch'),
'$search_hint' => t('@name, !forum, #tags, content'),
+ '$mode' => $mode
);
if (!$aside) {
return true;
}
-function file_tag_save_file($uid, $item, $file) {
- require_once "include/files.php";
-
+function file_tag_save_file($uid, $item, $file)
+{
if (! intval($uid)) {
return false;
}
);
}
- create_files_from_item($item);
+ Term::createFromItem($item);
$saved = PConfig::get($uid, 'system', 'filetags');
if (!strlen($saved) || !stristr($saved, '[' . file_tag_encode($file) . ']')) {
return true;
}
-function file_tag_unsave_file($uid, $item, $file, $cat = false) {
- require_once "include/files.php";
-
+function file_tag_unsave_file($uid, $item, $file, $cat = false)
+{
if (! intval($uid)) {
return false;
}
intval($uid)
);
- create_files_from_item($item);
+ Term::createFromItem($item);
$r = q("SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d",
dbesc($file),
*/
function format_network_name($network, $url = 0) {
if ($network != "") {
- require_once 'include/contact_selectors.php';
if ($url != "") {
- $network_name = '<a href="'.$url.'">'.network_to_name($network, $url)."</a>";
+ $network_name = '<a href="'.$url.'">'.ContactSelector::networkToName($network, $url)."</a>";
} else {
- $network_name = network_to_name($network);
+ $network_name = ContactSelector::networkToName($network);
}
return $network_name;
}
-
}
/**
* @file mod/allfriends.php
*/
use Friendica\App;
+use Friendica\Content\ContactSelector;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
-require_once 'include/contact_selectors.php';
require_once 'mod/contacts.php';
function allfriends_content(App $a)
'tags' => $contact_details['keywords'],
'about' => $contact_details['about'],
'account_type' => Contact::getAccountType($contact_details),
- 'network' => network_to_name($contact_details['network'], $contact_details['url']),
+ 'network' => ContactSelector::networkToName($contact_details['network'], $contact_details['url']),
'photo_menu' => $photo_menu,
'conntxt' => t('Connect'),
'connlnk' => $connlnk,
* @file include/common.php
*/
use Friendica\App;
+use Friendica\Content\ContactSelector;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
-require_once 'include/contact_selectors.php';
require_once 'mod/contacts.php';
function common_content(App $a)
'tags' => $contact_details['keywords'],
'about' => $contact_details['about'],
'account_type' => Contact::getAccountType($contact_details),
- 'network' => network_to_name($contact_details['network'], $contact_details['url']),
+ 'network' => ContactSelector::networkToName($contact_details['network'], $contact_details['url']),
'photo_menu' => $photo_menu,
'id' => ++$id,
);
<?php
-
/**
* @file mod/contacts.php
*/
use Friendica\App;
+use Friendica\Content\ContactSelector;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Model\Group;
use Friendica\Network\Probe;
-require_once 'include/contact_selectors.php';
require_once 'include/contact_widgets.php';
-require_once 'include/follow.php';
require_once 'mod/proxy.php';
function contacts_init(App $a)
$uid = $contact["uid"];
if ($r[0]["network"] == NETWORK_OSTATUS) {
- $result = new_contact($uid, $contact["url"], false, $contact["network"]);
+ $result = Contact::createFromProbe($uid, $contact["url"], false, $contact["network"]);
if ($result['success']) {
q("UPDATE `contact` SET `subhub` = 1 WHERE `id` = %d", intval($contact_id));
$update = array();
if ($data["network"] == NETWORK_OSTATUS) {
- $result = new_contact($uid, $data["url"], false);
+ $result = Contact::createFromProbe($uid, $data["url"], false);
if ($result['success']) {
$update["subhub"] = true;
'$baseurl' => System::baseUrl(true),
));
- require_once 'include/contact_selectors.php';
-
$dir_icon = '';
$relation_text = '';
switch ($contact['rel']) {
$poll_enabled = in_array($contact['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_FEED, NETWORK_MAIL));
- $nettype = t('Network type: %s', network_to_name($contact['network'], $contact["url"]));
+ $nettype = t('Network type: %s', ContactSelector::networkToName($contact['network'], $contact["url"]));
// tabs
$tab_str = contacts_tab($a, $contact_id, 2);
$poll_interval = null;
if (in_array($contact['network'], array(NETWORK_FEED, NETWORK_MAIL))) {
- $poll_interval = contact_poll_interval($contact['priority'], (!$poll_enabled));
+ $poll_interval = ContactSelector::pollInterval($contact['priority'], (!$poll_enabled));
}
$profile_select = null;
if ($contact['network'] == NETWORK_DFRN) {
- $profile_select = contact_profile_assign($contact['profile-id'], (($contact['network'] !== NETWORK_DFRN) ? true : false));
+ $profile_select = ContactSelector::profileAssign($contact['profile-id'], (($contact['network'] !== NETWORK_DFRN) ? true : false));
}
$follow = '';
$tpl = get_markup_template("contacts-template.tpl");
$o .= replace_macros($tpl, array(
'$baseurl' => System::baseUrl(),
- '$header' => t('Contacts') . (($nets) ? ' - ' . network_to_name($nets) : ''),
+ '$header' => t('Contacts') . (($nets) ? ' - ' . ContactSelector::networkToName($nets) : ''),
'$tabs' => $t,
'$total' => $total,
'$search' => $search_hdr,
'sparkle' => $sparkle,
'itemurl' => (($rr['addr'] != "") ? $rr['addr'] : $rr['url']),
'url' => $url,
- 'network' => network_to_name($rr['network'], $rr['url']),
+ 'network' => ContactSelector::networkToName($rr['network'], $rr['url']),
);
}
use Friendica\Database\DBM;
use Friendica\Model\Contact;
-require_once 'include/contact_selectors.php';
require_once 'mod/contacts.php';
function crepair_init(App $a)
* @file mod/dirfind.php
*/
use Friendica\App;
+use Friendica\Content\ContactSelector;
use Friendica\Core\Config;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Protocol\PortableContact;
require_once 'include/contact_widgets.php';
-require_once 'include/contact_selectors.php';
require_once 'mod/contacts.php';
function dirfind_init(App $a) {
'tags' => $contact_details['keywords'],
'about' => $contact_details['about'],
'account_type' => Contact::getAccountType($contact_details),
- 'network' => network_to_name($jj->network, $jj->url),
+ 'network' => ContactSelector::networkToName($jj->network, $jj->url),
'id' => ++$id,
);
$entries[] = $entry;
<?php
-
+/**
+ * @file mod/follow.php
+ */
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\System;
use Friendica\Model\Contact;
use Friendica\Network\Probe;
-require_once 'include/follow.php';
-require_once 'include/contact_selectors.php';
function follow_post(App $a) {
// This is just a precaution if maybe this page is called somewhere directly via POST
$_SESSION["fastlane"] = $url;
- $result = new_contact($uid,$url,true);
+ $result = Contact::createFromProbe($uid, $url, true);
if ($result['success'] == false) {
if ($result['message']) {
<?php
-
+/**
+ * @file mod/fsuggest.php
+ */
use Friendica\App;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
-require_once 'include/follow.php';
-
function fsuggest_post(App $a) {
if (! local_user()) {
require_once 'include/enotify.php';
require_once 'include/tags.php';
-require_once 'include/files.php';
require_once 'include/threads.php';
require_once 'include/text.php';
require_once 'include/items.php';
* @file mod/nogroup.php
*/
use Friendica\App;
+use Friendica\Content\ContactSelector;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Group;
-require_once 'include/contact_selectors.php';
-
function nogroup_init(App $a)
{
if (! local_user()) {
'about' => $contact_details['about'],
'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
'url' => $rr['url'],
- 'network' => network_to_name($rr['network'], $rr['url']),
+ 'network' => ContactSelector::networkToName($rr['network'], $rr['url']),
);
}
}
<?php
-
/**
* @file mod/notifications.php
* @brief The notifications module
*/
-
use Friendica\App;
+use Friendica\Content\ContactSelector;
use Friendica\Core\NotificationsManager;
use Friendica\Core\System;
use Friendica\Database\DBM;
-require_once("include/contact_selectors.php");
-require_once("include/network.php");
+require_once "include/network.php";
function notifications_post(App $a) {
if ($it["addr"] != "")
$header .= " <".$it["addr"].">";
- $header .= " (".network_to_name($it['network'], $it['url']).")";
+ $header .= " (".ContactSelector::networkToName($it['network'], $it['url']).")";
if ($it['network'] != NETWORK_DIASPORA) {
$discard = t('Discard');
'$addr' => $it['addr'],
'$lbl_knowyou' => $lbl_knowyou,
'$lbl_network' => t('Network:'),
- '$network' => network_to_name($it['network'], $it['url']),
+ '$network' => ContactSelector::networkToName($it['network'], $it['url']),
'$knowyou' => $knowyou,
'$approve' => t('Approve'),
'$note' => $it['note'],
<?php
-
+/**
+ * @file mod/ostatus_subscribe.php
+ */
use Friendica\App;
use Friendica\Core\PConfig;
use Friendica\Core\System;
+use Friendica\Model\Contact;
use Friendica\Network\Probe;
-require_once 'include/follow.php';
-
function ostatus_subscribe_content(App $a) {
if (! local_user()) {
$data = Probe::uri($url);
if ($data["network"] == NETWORK_OSTATUS) {
- $result = new_contact($uid, $url, true, NETWORK_OSTATUS);
+ $result = Contact::createFromProbe($uid, $url, true, NETWORK_OSTATUS);
if ($result["success"]) {
$o .= " - ".t("success");
} else {
<?php
-
+/**
+ * @file mod/repair_ostatus.php
+ */
use Friendica\App;
use Friendica\Core\System;
-
-require_once 'include/follow.php';
+use Friendica\Model\Contact;
function repair_ostatus_content(App $a) {
$o .= "<p>".t("Keep this window open until done.")."</p>";
- $result = new_contact($uid,$r[0]["url"],true);
+ $result = Contact::createFromProbe($uid,$r[0]["url"],true);
$a->page['htmlhead'] = '<meta http-equiv="refresh" content="1; URL='.System::baseUrl().'/repair_ostatus?counter='.$counter.'">';
use Friendica\App;
use Friendica\Core\PConfig;
use Friendica\Database\DBM;
+use Friendica\Model\Contact;
use Friendica\Protocol\OStatus;
use Friendica\Protocol\Salmon;
use Friendica\Util\Crypto;
require_once 'include/items.php';
-require_once 'include/follow.php';
function salmon_return($val) {
if (! DBM::is_result($r)) {
logger('mod-salmon: Author unknown to us.');
if(PConfig::get($importer['uid'],'system','ostatus_autofriend')) {
- $result = new_contact($importer['uid'],$author_link);
+ $result = Contact::createFromProbe($importer['uid'], $author_link);
if($result['success']) {
$r = q("SELECT * FROM `contact` WHERE `network` = '%s' AND ( `url` = '%s' OR `alias` = '%s')
AND `uid` = %d LIMIT 1",
* @file mod/suggest.php
*/
use Friendica\App;
+use Friendica\Content\ContactSelector;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
return $o;
}
- require_once 'include/contact_selectors.php';
-
foreach ($r as $rr) {
$connlnk = System::baseUrl() . '/follow/?url=' . (($rr['connect']) ? $rr['connect'] : $rr['url']);
'connlnk' => $connlnk,
'photo_menu' => $photo_menu,
'ignore' => t('Ignore/Hide'),
- 'network' => network_to_name($rr['network'], $rr['url']),
+ 'network' => ContactSelector::networkToName($rr['network'], $rr['url']),
'id' => ++$id,
);
$entries[] = $entry;
<?php
-
+/**
+ * @file mod/unfollow.php
+ */
use Friendica\App;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
-require_once 'include/follow.php';
-require_once 'include/contact_selectors.php';
-
function unfollow_post(App $a) {
if (!local_user()) {
<?php
use Friendica\App;
+use Friendica\Content\ContactSelector;
use Friendica\Core\Config;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
-require_once('include/contact_selectors.php');
-
function viewcontacts_init(App $a) {
if((Config::get('system','block_public')) && (! local_user()) && (! remote_user())) {
'url' => $url,
'sparkle' => '',
'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
- 'network' => network_to_name($rr['network'], $rr['url']),
+ 'network' => ContactSelector::networkToName($rr['network'], $rr['url']),
);
}
--- /dev/null
+<?xml version="1.0"?>
+<ruleset name="Friendica">
+ <description>Friendica Coding Standards: PSR2 with tabs instead of spaces</description>
+ <arg name="tab-width" value="4"/>
+ <rule ref="PSR2">
+ <exclude name="Generic.WhiteSpace.DisallowTabIndent"/>
+ </rule>
+ <rule ref="Generic.WhiteSpace.DisallowSpaceIndent"/>
+ <rule ref="Generic.WhiteSpace.ScopeIndent">
+ <properties>
+ <property name="indent" value="4"/>
+ <property name="tabIndent" value="true"/>
+ </properties>
+ </rule>
+</ruleset>
--- /dev/null
+<?php
+/**
+ * @file src/Content/ContactSelector.php
+ */
+namespace Friendica\Content;
+
+use Friendica\Database\DBM;
+use Friendica\Protocol\Diaspora;
+use dba;
+
+/**
+ * @brief ContactSelector class
+ */
+class ContactSelector
+{
+ /**
+ * @param string $current current
+ * @param string $foreign_net network
+ */
+ public static function profileAssign($current, $foreign_net)
+ {
+ $o = '';
+
+ $disabled = (($foreign_net) ? ' disabled="true" ' : '');
+
+ $o .= "<select id=\"contact-profile-selector\" class=\"form-control\" $disabled name=\"profile-assign\" >\r\n";
+
+ $s = dba::select('profile', ['id', 'profile-name', 'is-default'], ['uid' => $$_SESSION['uid']]);
+ $r = dba::inArray($s);
+
+ if (DBM::is_result($r)) {
+ foreach ($r as $rr) {
+ $selected = (($rr['id'] == $current || ($current == 0 && $rr['is-default'] == 1)) ? " selected=\"selected\" " : "");
+ $o .= "<option value=\"{$rr['id']}\" $selected >{$rr['profile-name']}</option>\r\n";
+ }
+ }
+ $o .= "</select>\r\n";
+ return $o;
+ }
+
+ /**
+ * @param string $current current
+ * @param boolean $disabled optional, default false
+ * @return object
+ */
+ public static function pollInterval($current, $disabled = false)
+ {
+ $dis = (($disabled) ? ' disabled="disabled" ' : '');
+ $o = '';
+ $o .= "<select id=\"contact-poll-interval\" name=\"poll\" $dis />" . "\r\n";
+
+ $rep = array(
+ 0 => t('Frequently'),
+ 1 => t('Hourly'),
+ 2 => t('Twice daily'),
+ 3 => t('Daily'),
+ 4 => t('Weekly'),
+ 5 => t('Monthly')
+ );
+
+ foreach ($rep as $k => $v) {
+ $selected = (($k == $current) ? " selected=\"selected\" " : "");
+ $o .= "<option value=\"$k\" $selected >$v</option>\r\n";
+ }
+ $o .= "</select>\r\n";
+ return $o;
+ }
+
+ /**
+ * @param string $s network
+ * @param string $profile optional, default empty
+ * @return string
+ */
+ public static function networkToName($s, $profile = "")
+ {
+ $nets = array(
+ NETWORK_DFRN => t('Friendica'),
+ NETWORK_OSTATUS => t('OStatus'),
+ NETWORK_FEED => t('RSS/Atom'),
+ NETWORK_MAIL => t('Email'),
+ NETWORK_DIASPORA => t('Diaspora'),
+ NETWORK_FACEBOOK => t('Facebook'),
+ NETWORK_ZOT => t('Zot!'),
+ NETWORK_LINKEDIN => t('LinkedIn'),
+ NETWORK_XMPP => t('XMPP/IM'),
+ NETWORK_MYSPACE => t('MySpace'),
+ NETWORK_GPLUS => t('Google+'),
+ NETWORK_PUMPIO => t('pump.io'),
+ NETWORK_TWITTER => t('Twitter'),
+ NETWORK_DIASPORA2 => t('Diaspora Connector'),
+ NETWORK_STATUSNET => t('GNU Social Connector'),
+ NETWORK_PNUT => t('pnut'),
+ NETWORK_APPNET => t('App.net')
+ );
+
+ call_hooks('network_to_name', $nets);
+
+ $search = array_keys($nets);
+ $replace = array_values($nets);
+
+ $networkname = str_replace($search, $replace, $s);
+
+ if ((in_array($s, array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) && ($profile != "")) {
+ $r = dba::fetch_first("SELECT `gserver`.`platform` FROM `gcontact`
+ INNER JOIN `gserver` ON `gserver`.`nurl` = `gcontact`.`server_url`
+ WHERE `gcontact`.`nurl` = ? AND `platform` != ''", normalise_link($profile));
+
+ if (DBM::is_result($r)) {
+ $networkname = $r['platform'];
+ }
+ }
+
+ return $networkname;
+ }
+}
namespace Friendica\Model;
use Friendica\BaseObject;
+use Friendica\Core\Config;
use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Protocol\Diaspora;
use Friendica\Protocol\DFRN;
use Friendica\Protocol\OStatus;
+use Friendica\Protocol\PortableContact;
use Friendica\Protocol\Salmon;
use dba;
return $data;
}
+
+ /**
+ * @param integer $id contact id
+ * @return boolean
+ */
+ public static function updateFromProbe($id)
+ {
+ /*
+ Warning: Never ever fetch the public key via Probe::uri and write it into the contacts.
+ This will reliably kill your communication with Friendica contacts.
+ */
+
+ $r = dba::select('contact', ['url', 'nurl', 'addr', 'alias', 'batch', 'notify', 'poll', 'poco', 'network'], ['id' => $id], ['limit' => 1]);
+ if (!DBM::is_result($r)) {
+ return false;
+ }
+
+ $ret = Probe::uri($r["url"]);
+
+ // If Probe::uri fails the network code will be different
+ if ($ret["network"] != $r["network"]) {
+ return false;
+ }
+
+ $update = false;
+
+ // make sure to not overwrite existing values with blank entries
+ foreach ($ret as $key => $val) {
+ if (isset($r[$key]) && ($r[$key] != "") && ($val == ""))
+ $ret[$key] = $r[$key];
+
+ if (isset($r[$key]) && ($ret[$key] != $r[$key]))
+ $update = true;
+ }
+
+ if (!$update) {
+ return true;
+ }
+
+ dba::update(
+ 'contact',
+ [
+ 'url' => $ret['url'],
+ 'nurl' => normalise_link($ret['url']),
+ 'addr' => $ret['addr'],
+ 'alias' => $ret['alias'],
+ 'batch' => $ret['batch'],
+ 'notify' => $ret['notify'],
+ 'poll' => $ret['poll'],
+ 'poco' => $ret['poco']
+ ],
+ ['id' => $id]
+ );
+
+ // Update the corresponding gcontact entry
+ PortableContact::lastUpdated($ret["url"]);
+
+ return true;
+ }
+
+ /**
+ * Takes a $uid and a url/handle and adds a new contact
+ * Currently if the contact is DFRN, interactive needs to be true, to redirect to the
+ * dfrn_request page.
+ *
+ * Otherwise this can be used to bulk add statusnet contacts, twitter contacts, etc.
+ *
+ * Returns an array
+ * $return['success'] boolean true if successful
+ * $return['message'] error text if success is false.
+ *
+ * @brief Takes a $uid and a url/handle and adds a new contact
+ * @param int $uid
+ * @param string $url
+ * @param bool $interactive
+ * @param string $network
+ * @return boolean|string
+ */
+ public static function createFromProbe($uid, $url, $interactive = false, $network = '')
+ {
+ $result = array('cid' => -1, 'success' => false, 'message' => '');
+
+ $a = get_app();
+
+ // remove ajax junk, e.g. Twitter
+ $url = str_replace('/#!/', '/', $url);
+
+ if (!allowed_url($url)) {
+ $result['message'] = t('Disallowed profile URL.');
+ return $result;
+ }
+
+ if (blocked_url($url)) {
+ $result['message'] = t('Blocked domain');
+ return $result;
+ }
+
+ if (!$url) {
+ $result['message'] = t('Connect URL missing.');
+ return $result;
+ }
+
+ $arr = array('url' => $url, 'contact' => array());
+
+ call_hooks('follow', $arr);
+
+ if (x($arr['contact'], 'name')) {
+ $ret = $arr['contact'];
+ } else {
+ $ret = Probe::uri($url, $network, $uid, false);
+ }
+
+ if (($network != '') && ($ret['network'] != $network)) {
+ logger('Expected network ' . $network . ' does not match actual network ' . $ret['network']);
+ return result;
+ }
+
+ if ($ret['network'] === NETWORK_DFRN) {
+ if ($interactive) {
+ if (strlen($a->path)) {
+ $myaddr = bin2hex(System::baseUrl() . '/profile/' . $a->user['nickname']);
+ } else {
+ $myaddr = bin2hex($a->user['nickname'] . '@' . $a->get_hostname());
+ }
+
+ goaway($ret['request'] . "&addr=$myaddr");
+
+ // NOTREACHED
+ }
+ } elseif (Config::get('system', 'dfrn_only')) {
+ $result['message'] = t('This site is not configured to allow communications with other networks.') . EOL;
+ $result['message'] != t('No compatible communication protocols or feeds were discovered.') . EOL;
+ return $result;
+ }
+
+ // This extra param just confuses things, remove it
+ if ($ret['network'] === NETWORK_DIASPORA) {
+ $ret['url'] = str_replace('?absolute=true', '', $ret['url']);
+ }
+
+ // do we have enough information?
+
+ if (!((x($ret, 'name')) && (x($ret, 'poll')) && ((x($ret, 'url')) || (x($ret, 'addr'))))) {
+ $result['message'] .= t('The profile address specified does not provide adequate information.') . EOL;
+ if (!x($ret, 'poll')) {
+ $result['message'] .= t('No compatible communication protocols or feeds were discovered.') . EOL;
+ }
+ if (!x($ret, 'name')) {
+ $result['message'] .= t('An author or name was not found.') . EOL;
+ }
+ if (!x($ret, 'url')) {
+ $result['message'] .= t('No browser URL could be matched to this address.') . EOL;
+ }
+ if (strpos($url, '@') !== false) {
+ $result['message'] .= t('Unable to match @-style Identity Address with a known protocol or email contact.') . EOL;
+ $result['message'] .= t('Use mailto: in front of address to force email check.') . EOL;
+ }
+ return $result;
+ }
+
+ if ($ret['network'] === NETWORK_OSTATUS && Config::get('system', 'ostatus_disabled')) {
+ $result['message'] .= t('The profile address specified belongs to a network which has been disabled on this site.') . EOL;
+ $ret['notify'] = '';
+ }
+
+ if (!$ret['notify']) {
+ $result['message'] .= t('Limited profile. This person will be unable to receive direct/personal notifications from you.') . EOL;
+ }
+
+ $writeable = ((($ret['network'] === NETWORK_OSTATUS) && ($ret['notify'])) ? 1 : 0);
+
+ $subhub = (($ret['network'] === NETWORK_OSTATUS) ? true : false);
+
+ $hidden = (($ret['network'] === NETWORK_MAIL) ? 1 : 0);
+
+ if (in_array($ret['network'], array(NETWORK_MAIL, NETWORK_DIASPORA))) {
+ $writeable = 1;
+ }
+
+ // check if we already have a contact
+ // the poll url is more reliable than the profile url, as we may have
+ // indirect links or webfinger links
+
+ $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `poll` IN ('%s', '%s') AND `network` = '%s' LIMIT 1",
+ intval($uid),
+ dbesc($ret['poll']),
+ dbesc(normalise_link($ret['poll'])),
+ dbesc($ret['network'])
+ );
+
+ if (!DBM::is_result($r)) {
+ $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' AND `network` = '%s' LIMIT 1",
+ intval($uid), dbesc(normalise_link($url)), dbesc($ret['network'])
+ );
+ }
+
+ if (DBM::is_result($r)) {
+ // update contact
+ $new_relation = (($r[0]['rel'] == CONTACT_IS_FOLLOWER) ? CONTACT_IS_FRIEND : CONTACT_IS_SHARING);
+
+ $fields = array('rel' => $new_relation, 'subhub' => $subhub, 'readonly' => false);
+ dba::update('contact', $fields, array('id' => $r[0]['id']));
+ } else {
+ $new_relation = ((in_array($ret['network'], array(NETWORK_MAIL))) ? CONTACT_IS_FRIEND : CONTACT_IS_SHARING);
+
+ // create contact record
+ dba::insert(
+ 'contact',
+ [
+ 'uid' => $uid,
+ 'created' => datetime_convert(),
+ 'url' => $ret['url'],
+ 'nurl' => normalise_link($ret['url']),
+ 'addr' => $ret['addr'],
+ 'alias' => $ret['alias'],
+ 'batch' => $ret['batch'],
+ `notify` => $ret['notify'],
+ `poll` => $ret['poll'],
+ `poco` => $ret['poco'],
+ `name` => $ret['name'],
+ `nick` => $ret['nick'],
+ `network` => $ret['network'],
+ `pubkey` => $ret['pubkey'],
+ `rel` => $new_relation,
+ `priority` => $ret['priority'],
+ `writable` => $writeable,
+ `hidden` => $hidden,
+ `blocked` => 0,
+ `readonly` => 0,
+ `pending` => 0,
+ `subhub` => $subhub
+ ]
+ );
+ }
+
+ $r = dba::select('contact', ['url' => $ret['url'], 'network' => $ret['network'], 'uid' => $uid], ['limit' => 1]);
+
+ if (!DBM::is_result($r)) {
+ $result['message'] .= t('Unable to retrieve contact information.') . EOL;
+ return $result;
+ }
+
+ $contact = $r;
+ $contact_id = $r['id'];
+ $result['cid'] = $contact_id;
+
+ Group::addMember(User::getDefaultGroup($uid, $contact["network"]), $contact_id);
+
+ // Update the avatar
+ self::updateAvatar($ret['photo'], $uid, $contact_id);
+
+ // pull feed and consume it, which should subscribe to the hub.
+
+ Worker::add(PRIORITY_HIGH, "OnePoll", $contact_id, "force");
+
+ $r = q("SELECT `contact`.*, `user`.* FROM `contact` INNER JOIN `user` ON `contact`.`uid` = `user`.`uid`
+ WHERE `user`.`uid` = %d AND `contact`.`self` LIMIT 1",
+ intval($uid)
+ );
+
+ if (DBM::is_result($r)) {
+ if (($contact['network'] == NETWORK_OSTATUS) && (strlen($contact['notify']))) {
+ // create a follow slap
+ $item = array();
+ $item['verb'] = ACTIVITY_FOLLOW;
+ $item['follow'] = $contact["url"];
+ $slap = OStatus::salmon($item, $r[0]);
+ Salmon::slapper($r[0], $contact['notify'], $slap);
+ }
+
+ if ($contact['network'] == NETWORK_DIASPORA) {
+ $ret = Diaspora::sendShare($a->user, $contact);
+ logger('share returns: ' . $ret);
+ }
+ }
+
+ $result['success'] = true;
+ return $result;
+ }
}
namespace Friendica\Model;
use Friendica\Core\Worker;
+use Friendica\Model\Term;
use dba;
require_once 'include/tags.php';
-require_once 'include/files.php';
require_once 'include/threads.php';
class Item
}
create_tags_from_item($item['id']);
- create_files_from_item($item['id']);
+ Term::createFromItem($item['id']);
update_thread($item['id']);
Worker::add(PRIORITY_HIGH, "Notifier", 'edit_post', $item['id']);
--- /dev/null
+<?php
+/**
+ * @file src/Model/Term
+ */
+namespace Friendica\Model;
+
+use dba;
+
+require_once "include/dba.php";
+
+class Term
+{
+ /**
+ * @param integer $itemid item id
+ * @return void
+ */
+ public static function createFromItem($itemid)
+ {
+ $messages = dba::select('item', ['uid', 'deleted', 'file'], ['id' => $itemid], ['limit' => 1]);
+ if (!$messages) {
+ return;
+ }
+
+ $message = $messages[0];
+
+ // Clean up all tags
+ q("DELETE FROM `term` WHERE `otype` = %d AND `oid` = %d AND `type` IN (%d, %d)",
+ intval(TERM_OBJ_POST),
+ intval($itemid),
+ intval(TERM_FILE),
+ intval(TERM_CATEGORY));
+
+ if ($message["deleted"])
+ return;
+
+ if (preg_match_all("/\[(.*?)\]/ism", $message["file"], $files)) {
+ foreach ($files[1] as $file) {
+ dba::insert('term', ['uid' => $message["uid"], 'oid' => $itemid, 'otype' => TERM_OBJ_POST, 'type' => TERM_FILE, 'term' => $file]);
+ }
+ }
+
+ if (preg_match_all("/\<(.*?)\>/ism", $message["file"], $files)) {
+ foreach ($files[1] as $file) {
+ dba::insert('term', ['uid' => $message["uid"], 'oid' => $itemid, 'otype' => TERM_OBJ_POST, 'type' => TERM_CATEGORY, 'term' => $file]);
+ }
+ }
+ }
+
+ /**
+ * @param string $itemuri item uri
+ * @param integer $uid uid
+ * @return void
+ */
+ public static function createFromItemURI($itemuri, $uid)
+ {
+ $messages = q("SELECT `id` FROM `item` WHERE uri ='%s' AND uid=%d", dbesc($itemuri), intval($uid));
+
+ if (count($messages)) {
+ foreach ($messages as $message) {
+ self::createFromItem($message["id"]);
+ }
+ }
+ }
+}
<?php
-
/**
* @file src/Object/Post.php
*/
-
namespace Friendica\Object;
use Friendica\BaseObject;
+use Friendica\Content\ContactSelector;
use Friendica\Content\Feature;
use Friendica\Core\PConfig;
use Friendica\Database\DBM;
'thread_level' => $thread_level,
'edited' => $edited,
'network' => $item["item_network"],
- 'network_name' => network_to_name($item['item_network'], $profile_link),
+ 'network_name' => ContactSelector::networkToName($item['item_network'], $profile_link),
'received' => $item['received'],
'commented' => $item['commented'],
'created_date' => $item['created'],
use Friendica\Model\GContact;
use Friendica\Model\Group;
use Friendica\Model\Profile;
+use Friendica\Model\Term;
use Friendica\Model\User;
use Friendica\Object\Image;
use Friendica\Protocol\OStatus;
require_once "include/threads.php";
require_once "include/items.php";
require_once "include/tags.php";
-require_once "include/files.php";
require_once "include/event.php";
require_once "include/text.php";
require_once "include/html2bbcode.php";
intval($importer["uid"])
);
create_tags_from_itemuri($uri, $importer["uid"]);
- create_files_from_itemuri($uri, $importer["uid"]);
+ Term::createFromItemURI($uri, $importer["uid"]);
update_thread_uri($uri, $importer["uid"]);
} else {
$r = q(
intval($importer["uid"])
);
create_tags_from_itemuri($uri, $importer["uid"]);
- create_files_from_itemuri($uri, $importer["uid"]);
+ Term::createFromItemURI($uri, $importer["uid"]);
update_thread_uri($uri, $importer["importer_uid"]);
if ($item["last-child"]) {
// ensure that last-child is set in case the comment that had it just got wiped.
require_once 'include/items.php';
require_once 'mod/share.php';
require_once 'include/enotify.php';
-require_once 'include/follow.php';
require_once 'include/api.php';
require_once 'mod/proxy.php';
use dba;
require_once 'include/dba.php';
-require_once 'include/follow.php';
Class OnePoll
{
return;
}
- if (!update_contact($contact["id"])) {
+ if (!Contact::updateFromProbe($contact["id"])) {
Contact::markForArchival($contact);
logger('Contact is marked dead');
-<?xml version="1.0"?>
-<ruleset name="PEAR-textlanguagedetect">
- <rule ref="PEAR">
- <!-- we keep the old php4-style variable names for now -->
- <exclude name="PEAR.NamingConventions.ValidFunctionName.PublicUnderscore"/>
- <exclude name="PEAR.NamingConventions.ValidVariableName.PublicUnderscore"/>
- <exclude name="PEAR.NamingConventions.ValidVariableName.PrivateNoUnderscore"/>
- <exclude name="PEAR.NamingConventions.ValidFunctionName.PrivateNoUnderscore"/>
- <exclude name="PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps"/>
- <exclude name="PEAR.WhiteSpace.ScopeIndent.IncorrectExact"/>
- <exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps"/>
- </rule>
- <description>PSR2 with tabs instead of spaces.</description>
- <arg name="tab-width" value="4"/>
- <rule ref="PSR2">
- <exclude name="Generic.WhiteSpace.DisallowTabIndent"/>
- <exclude name="Generic.Commenting.DocComment.MissingShort"/>
- </rule>
- <rule ref="Generic.WhiteSpace.DisallowSpaceIndent"/>
- <rule ref="Generic.WhiteSpace.ScopeIndent">
- <properties>
- <property name="indent" value="4"/>
- <property name="tabIndent" value="true"/>
- </properties>
- </rule>
-</ruleset>
+<?xml version="1.0"?>\r
+<ruleset name="PEAR-textlanguagedetect">\r
+ <rule ref="PEAR">\r
+ <!-- we keep the old php4-style variable names for now -->\r
+ <exclude name="PEAR.NamingConventions.ValidFunctionName.PublicUnderscore"/>\r
+ <exclude name="PEAR.NamingConventions.ValidVariableName.PublicUnderscore"/>\r
+ </rule>\r
+</ruleset>\r
{{if $savedsearch}}
<form id="search-save-form" action="{{$action_url}}" method="get" >
<input type="hidden" name="search" value="{{$s}}" />
- <button class="btn btn-primary btn-sm btn-main pull-right" type="submit" name="save" id="search-save" value="{{$save_label}}"><i class="fa fa-floppy-o fa-2x" aria-hidden="true"></i></button>
+ {{* In dependence of the search content we show different buttons *}}
+ {{if $mode == "tag"}}
+ <button class="btn btn-primary btn-sm btn-main pull-right" type="submit" name="save" id="search-save" title="{{$save_label}}" value="{{$save_label}}" data-toggle="tooltip"><i class="fa fa-plus fa-2x" aria-hidden="true"></i></button>
+ {{else}}
+ <button class="btn btn-primary btn-sm btn-main pull-right" type="submit" name="save" id="search-save" title="{{$save_label}}" value="{{$save_label}}" data-toggle="tooltip"><i class="fa fa-floppy-o fa-2x" aria-hidden="true"></i></button>
+ {{/if}}
</form>
{{/if}}
</div>