]> git.mxchange.org Git - friendica.git/blobdiff - mod/profiles.php
Merge pull request #3769 from annando/show-forum-posts
[friendica.git] / mod / profiles.php
index b73c46e71c5d6c87322328e8e8fcefaeffc51c70..4a1d1ad93479033342ec504ff7cfa949b3f0ce78 100644 (file)
@@ -1,6 +1,11 @@
 <?php
-require_once("include/Contact.php");
-require_once('include/Probe.php');
+
+use Friendica\App;
+use Friendica\Core\System;
+use Friendica\Network\Probe;
+
+require_once 'include/Contact.php';
+require_once 'include/socgraph.php';
 
 function profiles_init(App $a) {
 
@@ -103,13 +108,7 @@ function profiles_init(App $a) {
                $r1[0]['net-publish'] = 0;
                $r1[0]['profile-name'] = dbesc($name);
 
-               dbm::esc_array($r1[0], true);
-
-               $r2 = dbq("INSERT INTO `profile` (`"
-                       . implode("`, `", array_keys($r1[0]))
-                       . "`) VALUES ("
-                       . implode(", ", array_values($r1[0]))
-                       . ")" );
+               dba::insert('profile', $r1[0]);
 
                $r3 = q("SELECT `id` FROM `profile` WHERE `uid` = %d AND `profile-name` = '%s' LIMIT 1",
                        intval(local_user()),
@@ -193,7 +192,7 @@ function profiles_post(App $a) {
                        return;
                }
 
-               $dob = $_POST['dob'] ? escape_tags(trim($_POST['dob'])) : '0000-00-00'; // FIXME: Needs to be validated?
+               $dob = $_POST['dob'] ? escape_tags(trim($_POST['dob'])) : '0001-01-01'; // FIXME: Needs to be validated?
 
                $y = substr($dob, 0, 4);
                if ((! ctype_digit($y)) || ($y < 1900)) {
@@ -201,15 +200,15 @@ function profiles_post(App $a) {
                } else {
                        $ignore_year = false;
                }
-               if ($dob != '0000-00-00') {
-                       if (strpos($dob, '0000-') === 0) {
+               if (!in_array($dob, array('0000-00-00', '0001-01-01'))) {
+                       if (strpos($dob, '0000-') === 0 || strpos($dob, '0001-') === 0) {
                                $ignore_year = true;
                                $dob = substr($dob, 5);
                        }
                        $dob = datetime_convert('UTC', 'UTC', (($ignore_year) ? '1900-' . $dob : $dob), (($ignore_year) ? 'm-d' : 'Y-m-d'));
 
                        if ($ignore_year) {
-                               $dob = '0000-' . $dob;
+                               $dob = '0001-' . $dob;
                        }
                }
 
@@ -501,8 +500,7 @@ function profiles_post(App $a) {
                                proc_run(PRIORITY_LOW, "include/directory.php", $url);
                        }
 
-                       require_once('include/profile_update.php');
-                       profile_change();
+                       proc_run(PRIORITY_LOW, 'include/profile_update.php', local_user());
 
                        // Update the global contact for the user
                        update_gcontact_for_user(local_user());
@@ -526,7 +524,7 @@ function profile_activity($changed, $value) {
                return;
        }
 
-       require_once('include/items.php');
+       require_once 'include/items.php';
 
        $self = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
                intval(local_user())
@@ -620,14 +618,14 @@ function profiles_content(App $a) {
                        return;
                }
 
-               require_once('include/profile_selectors.php');
+               require_once 'include/profile_selectors.php';
 
 
                $a->page['htmlhead'] .= replace_macros(get_markup_template('profed_head.tpl'), array(
-                       '$baseurl' => App::get_baseurl(true),
+                       '$baseurl' => System::baseUrl(true),
                ));
                $a->page['end'] .= replace_macros(get_markup_template('profed_end.tpl'), array(
-                       '$baseurl' => App::get_baseurl(true),
+                       '$baseurl' => System::baseUrl(true),
                ));
 
                $opt_tpl = get_markup_template("profile-hide-friends.tpl");
@@ -637,7 +635,7 @@ function profiles_content(App $a) {
                                t('Hide contacts and friends:'), //Label
                                !!$r[0]['hide-friends'], //Value
                                '', //Help string
-                               array(t('No'),t('Yes')) //Off - On strings
+                               array(t('No'), t('Yes')) //Off - On strings
                        ),
                        '$desc' => t('Hide your contact/friend list from viewers of this profile?'),
                        '$yes_str' => t('Yes'),
@@ -704,7 +702,7 @@ function profiles_content(App $a) {
                        '$lbl_ex2' => t('Example: fishing photography software'),
 
                        '$disabled' => (($is_default) ? 'onclick="return false;" style="color: #BBBBFF;"' : ''),
-                       '$baseurl' => App::get_baseurl(true),
+                       '$baseurl' => System::baseUrl(true),
                        '$profile_id' => $r[0]['id'],
                        '$profile_name' => array('profile_name', t('Profile Name:'), $r[0]['profile-name'], t('Required'), '*'),
                        '$is_default'   => $is_default,
@@ -739,7 +737,7 @@ function profiles_content(App $a) {
                        '$tv' => array('tv', t('Television'), $r[0]['tv']),
                        '$film' => array('film', t('Film/dance/culture/entertainment'), $r[0]['film']),
                        '$interest' => array('interest', t('Hobbies/Interests'), $r[0]['interest']),
-                       '$romance' => array('romance',t('Love/romance'), $r[0]['romance']),
+                       '$romance' => array('romance', t('Love/romance'), $r[0]['romance']),
                        '$work' => array('work', t('Work/employment'), $r[0]['work']),
                        '$education' => array('education', t('School/education'), $r[0]['education']),
                        '$contact' => array('contact', t('Contact information and Social Networks'), $r[0]['contact']),