]> git.mxchange.org Git - friendica.git/blobdiff - mod/profiles.php
Fix formatting in mod/settings
[friendica.git] / mod / profiles.php
index b787bc154886c2372173bcf5cb4c89c236924cf8..75023beb64180038cc09c15b20cebaa166efba26 100644 (file)
@@ -1,14 +1,16 @@
 <?php
-
+/**
+ * @file mod/profiles.php
+ */
 use Friendica\App;
 use Friendica\Core\Config;
 use Friendica\Core\PConfig;
 use Friendica\Core\System;
 use Friendica\Core\Worker;
+use Friendica\Database\DBM;
+use Friendica\Model\GlobalContact;
 use Friendica\Network\Probe;
-
-require_once 'include/Contact.php';
-require_once 'include/socgraph.php';
+use Friendica\Object\Profile;
 
 function profiles_init(App $a) {
 
@@ -23,7 +25,7 @@ function profiles_init(App $a) {
                        intval($a->argv[2]),
                        intval(local_user())
                );
-               if (! dbm::is_result($r)) {
+               if (! DBM::is_result($r)) {
                        notice( t('Profile not found.') . EOL);
                        goaway('profiles');
                        return; // NOTREACHED
@@ -42,7 +44,7 @@ function profiles_init(App $a) {
                        intval($a->argv[2]),
                        intval(local_user())
                );
-               if (dbm::is_result($r)) {
+               if (DBM::is_result($r)) {
                        info(t('Profile deleted.').EOL);
                }
 
@@ -57,7 +59,7 @@ function profiles_init(App $a) {
                $r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d",
                        intval(local_user()));
 
-               $num_profiles = (dbm::is_result($r0) ? count($r0) : 0);
+               $num_profiles = (DBM::is_result($r0) ? count($r0) : 0);
 
                $name = t('Profile-') . ($num_profiles + 1);
 
@@ -79,7 +81,7 @@ function profiles_init(App $a) {
                );
 
                info( t('New profile created.') . EOL);
-               if (dbm::is_result($r3) && count($r3) == 1) {
+               if (DBM::is_result($r3) && count($r3) == 1) {
                        goaway('profiles/' . $r3[0]['id']);
                }
 
@@ -93,14 +95,14 @@ function profiles_init(App $a) {
                $r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d",
                        intval(local_user()));
 
-               $num_profiles = (dbm::is_result($r0) ? count($r0) : 0);
+               $num_profiles = (DBM::is_result($r0) ? count($r0) : 0);
 
                $name = t('Profile-') . ($num_profiles + 1);
                $r1 = q("SELECT * FROM `profile` WHERE `uid` = %d AND `id` = %d LIMIT 1",
                        intval(local_user()),
                        intval($a->argv[2])
                );
-               if(! dbm::is_result($r1)) {
+               if(! DBM::is_result($r1)) {
                        notice( t('Profile unavailable to clone.') . EOL);
                        killme();
                        return;
@@ -118,7 +120,7 @@ function profiles_init(App $a) {
                        dbesc($name)
                );
                info( t('New profile created.') . EOL);
-               if ((dbm::is_result($r3)) && (count($r3) == 1)) {
+               if ((DBM::is_result($r3)) && (count($r3) == 1)) {
                        goaway('profiles/'.$r3[0]['id']);
                }
 
@@ -133,7 +135,7 @@ function profiles_init(App $a) {
                        intval($a->argv[1]),
                        intval(local_user())
                );
-               if (! dbm::is_result($r)) {
+               if (! DBM::is_result($r)) {
                        notice( t('Profile not found.') . EOL);
                        killme();
                        return;
@@ -180,7 +182,7 @@ function profiles_post(App $a) {
                        intval($a->argv[1]),
                        intval(local_user())
                );
-               if (! dbm::is_result($orig)) {
+               if (! DBM::is_result($orig)) {
                        notice( t('Profile not found.') . EOL);
                        return;
                }
@@ -274,13 +276,13 @@ function profiles_post(App $a) {
                                                dbesc($newname),
                                                intval(local_user())
                                        );
-                                       if (! dbm::is_result($r)) {
+                                       if (! DBM::is_result($r)) {
                                                $r = q("SELECT * FROM `contact` WHERE `nick` = '%s' AND `uid` = %d LIMIT 1",
                                                        dbesc($lookup),
                                                        intval(local_user())
                                                );
                                        }
-                                       if (dbm::is_result($r)) {
+                                       if (DBM::is_result($r)) {
                                                $prf = $r[0]['url'];
                                                $newname = $r[0]['name'];
                                        }
@@ -487,7 +489,7 @@ function profiles_post(App $a) {
                }
 
                if ($is_default) {
-                       $location = formatted_location(array("locality" => $locality, "region" => $region, "country-name" => $country_name));
+                       $location = Profile::formatLocation(array("locality" => $locality, "region" => $region, "country-name" => $country_name));
 
                        q("UPDATE `contact` SET `about` = '%s', `location` = '%s', `keywords` = '%s', `gender` = '%s' WHERE `self` AND `uid` = %d",
                                dbesc($about),
@@ -500,13 +502,13 @@ function profiles_post(App $a) {
                        // Update global directory in background
                        $url = $_SESSION['my_url'];
                        if ($url && strlen(Config::get('system', 'directory'))) {
-                               Worker::add(PRIORITY_LOW, "directory", $url);
+                               Worker::add(PRIORITY_LOW, "Directory", $url);
                        }
 
-                       Worker::add(PRIORITY_LOW, 'profile_update', local_user());
+                       Worker::add(PRIORITY_LOW, 'ProfileUpdate', local_user());
 
                        // Update the global contact for the user
-                       update_gcontact_for_user(local_user());
+                       GlobalContact::updateForUser(local_user());
                }
        }
 }
@@ -533,7 +535,7 @@ function profile_activity($changed, $value) {
                intval(local_user())
        );
 
-       if (! dbm::is_result($self)) {
+       if (! DBM::is_result($self)) {
                return;
        }
 
@@ -597,7 +599,7 @@ function profile_activity($changed, $value) {
 
        $i = item_store($arr);
        if ($i) {
-               Worker::add(PRIORITY_HIGH, "notifier", "activity", $i);
+               Worker::add(PRIORITY_HIGH, "Notifier", "activity", $i);
        }
 }
 
@@ -616,7 +618,7 @@ function profiles_content(App $a) {
                        intval($a->argv[1]),
                        intval(local_user())
                );
-               if (! dbm::is_result($r)) {
+               if (! DBM::is_result($r)) {
                        notice( t('Profile not found.') . EOL);
                        return;
                }
@@ -751,13 +753,12 @@ function profiles_content(App $a) {
 
                return $o;
        } else {
-
                // If we don't support multi profiles, don't display this list.
                if (!feature_enabled(local_user(), 'multi_profiles')) {
                        $r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default`=1",
                                local_user()
                        );
-                       if (dbm::is_result($r)) {
+                       if (DBM::is_result($r)) {
                                //Go to the default profile.
                                goaway('profiles/' . $r[0]['id']);
                        }
@@ -766,7 +767,7 @@ function profiles_content(App $a) {
                $r = q("SELECT * FROM `profile` WHERE `uid` = %d",
                        local_user());
 
-               if (dbm::is_result($r)) {
+               if (DBM::is_result($r)) {
 
                        $tpl = get_markup_template('profile_entry.tpl');