Example #1
0
 function get()
 {
     $o = '';
     $channel = \App::get_channel();
     if (!local_channel()) {
         notice(t('Permission denied.') . EOL);
         return;
     }
     require_once 'include/channel.php';
     $profile_fields_basic = get_profile_fields_basic();
     $profile_fields_advanced = get_profile_fields_advanced();
     if (argc() > 1 && intval(argv(1)) || !feature_enabled(local_channel(), 'multi_profiles')) {
         if (feature_enabled(local_channel(), 'multi_profiles')) {
             $id = \App::$argv[1];
         } else {
             $x = q("select id from profile where uid = %d and is_default = 1", intval(local_channel()));
             if ($x) {
                 $id = $x[0]['id'];
             }
         }
         $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($id), intval(local_channel()));
         if (!count($r)) {
             notice(t('Profile not found.') . EOL);
             return;
         }
         $editselect = 'none';
         \App::$page['htmlhead'] .= replace_macros(get_markup_template('profed_head.tpl'), array('$baseurl' => z_root(), '$editselect' => $editselect));
         $advanced = feature_enabled(local_channel(), 'advanced_profiles') ? true : false;
         if ($advanced) {
             $fields = $profile_fields_advanced;
         } else {
             $fields = $profile_fields_basic;
         }
         $hide_friends = array('hide_friends', t('Hide your connections list from viewers of this profile'), $r[0]['hide_friends'], '', array(t('No'), t('Yes')));
         $q = q("select * from profdef where true");
         if ($q) {
             $extra_fields = array();
             foreach ($q as $qq) {
                 $mine = q("select v from profext where k = '%s' and hash = '%s' and channel_id = %d limit 1", dbesc($qq['field_name']), dbesc($r[0]['profile_guid']), intval(local_channel()));
                 if (array_key_exists($qq['field_name'], $fields)) {
                     $extra_fields[] = array($qq['field_name'], $qq['field_desc'], $mine ? $mine[0]['v'] : '', $qq['field_help']);
                 }
             }
         }
         //logger('extra_fields: ' . print_r($extra_fields,true));
         $f = get_config('system', 'birthday_input_format');
         if (!$f) {
             $f = 'ymd';
         }
         $is_default = $r[0]['is_default'] ? 1 : 0;
         $tpl = get_markup_template("profile_edit.tpl");
         $o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("profile_edit"), '$profile_clone_link' => feature_enabled(local_channel(), 'multi_profiles') ? 'profiles/clone/' . $r[0]['id'] . '?t=' . get_form_security_token("profile_clone") : '', '$profile_drop_link' => 'profiles/drop/' . $r[0]['id'] . '?t=' . get_form_security_token("profile_drop"), '$fields' => $fields, '$guid' => $r[0]['profile_guid'], '$banner' => t('Edit Profile Details'), '$submit' => t('Submit'), '$viewprof' => t('View this profile'), '$editvis' => t('Edit visibility'), '$tools_label' => t('Profile Tools'), '$coverpic' => t('Change cover photo'), '$profpic' => t('Change profile photo'), '$cr_prof' => t('Create a new profile using these settings'), '$cl_prof' => t('Clone this profile'), '$del_prof' => t('Delete this profile'), '$addthing' => t('Add profile things'), '$personal' => t('Personal'), '$location' => t('Location'), '$relation' => t('Relation'), '$miscellaneous' => t('Miscellaneous'), '$exportable' => feature_enabled(local_channel(), 'profile_export'), '$lbl_import' => t('Import profile from file'), '$lbl_export' => t('Export profile to file'), '$lbl_gender' => t('Your gender'), '$lbl_marital' => t('Marital status'), '$lbl_sexual' => t('Sexual preference'), '$baseurl' => z_root(), '$profile_id' => $r[0]['id'], '$profile_name' => array('profile_name', t('Profile name'), $r[0]['profile_name'], t('Required'), '*'), '$is_default' => $is_default, '$default' => t('This is your default profile.') . EOL . translate_scope(map_scope($channel['channel_r_profile'])), '$advanced' => $advanced, '$name' => array('name', t('Your full name'), $r[0]['fullname'], t('Required'), '*'), '$pdesc' => array('pdesc', t('Title/Description'), $r[0]['pdesc']), '$dob' => dob($r[0]['dob']), '$hide_friends' => $hide_friends, '$address' => array('address', t('Street address'), $r[0]['address']), '$locality' => array('locality', t('Locality/City'), $r[0]['locality']), '$region' => array('region', t('Region/State'), $r[0]['region']), '$postal_code' => array('postal_code', t('Postal/Zip code'), $r[0]['postal_code']), '$country_name' => array('country_name', t('Country'), $r[0]['country_name']), '$gender' => gender_selector($r[0]['gender']), '$gender_min' => gender_selector_min($r[0]['gender']), '$marital' => marital_selector($r[0]['marital']), '$marital_min' => marital_selector_min($r[0]['marital']), '$with' => array('with', t("Who (if applicable)"), $r[0]['partner'], t('Examples: cathy123, Cathy Williams, cathy@example.com')), '$howlong' => array('howlong', t('Since (date)'), $r[0]['howlong'] === NULL_DATE ? '' : datetime_convert('UTC', date_default_timezone_get(), $r[0]['howlong'])), '$sexual' => sexpref_selector($r[0]['sexual']), '$sexual_min' => sexpref_selector_min($r[0]['sexual']), '$about' => array('about', t('Tell us about yourself'), $r[0]['about']), '$homepage' => array('homepage', t('Homepage URL'), $r[0]['homepage']), '$hometown' => array('hometown', t('Hometown'), $r[0]['hometown']), '$politic' => array('politic', t('Political views'), $r[0]['politic']), '$religion' => array('religion', t('Religious views'), $r[0]['religion']), '$keywords' => array('keywords', t('Keywords used in directory listings'), $r[0]['keywords'], t('Example: fishing photography software')), '$likes' => array('likes', t('Likes'), $r[0]['likes']), '$dislikes' => array('dislikes', t('Dislikes'), $r[0]['dislikes']), '$music' => array('music', t('Musical interests'), $r[0]['music']), '$book' => array('book', t('Books, literature'), $r[0]['book']), '$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']), '$work' => array('work', t('Work/Employment'), $r[0]['employment']), '$education' => array('education', t('School/Education'), $r[0]['education']), '$contact' => array('contact', t('Contact information and social networks'), $r[0]['contact']), '$channels' => array('channels', t('My other channels'), $r[0]['channels']), '$extra_fields' => $extra_fields));
         $arr = array('profile' => $r[0], 'entry' => $o);
         call_hooks('profile_edit', $arr);
         return $o;
     } else {
         $r = q("SELECT * FROM `profile` WHERE `uid` = %d", local_channel());
         if ($r) {
             $tpl = get_markup_template('profile_entry.tpl');
             foreach ($r as $rr) {
                 $profiles .= replace_macros($tpl, array('$photo' => $rr['thumb'], '$id' => $rr['id'], '$alt' => t('Profile Image'), '$profile_name' => $rr['profile_name'], '$visible' => $rr['is_default'] ? '<strong>' . translate_scope(map_scope($channel['channel_r_profile'])) . '</strong>' : '<a href="' . z_root() . '/profperm/' . $rr['id'] . '" />' . t('Edit visibility') . '</a>'));
             }
             $tpl_header = get_markup_template('profile_listing_header.tpl');
             $o .= replace_macros($tpl_header, array('$header' => t('Edit Profiles'), '$cr_new' => t('Create New'), '$cr_new_link' => 'profiles/new?t=' . get_form_security_token("profile_new"), '$profiles' => $profiles));
         }
         return $o;
     }
 }
Example #2
0
function profiles_content(&$a)
{
    $o = '';
    nav_set_selected('profiles');
    if (!local_user()) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    if ($a->argc > 2 && $a->argv[1] === "drop" && intval($a->argv[2])) {
        $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d AND `is-default` = 0 LIMIT 1", intval($a->argv[2]), intval(local_user()));
        if (!count($r)) {
            notice(t('Profile not found.') . EOL);
            goaway($a->get_baseurl() . '/profiles');
            return;
            // NOTREACHED
        }
        // move every contact using this profile as their default to the user default
        $r = q("UPDATE `contact` SET `profile-id` = (SELECT `profile`.`id` AS `profile-id` FROM `profile` WHERE `profile`.`is-default` = 1 AND `profile`.`uid` = %d LIMIT 1) WHERE `profile-id` = %d AND `uid` = %d ", intval(local_user()), intval($a->argv[2]), intval(local_user()));
        $r = q("DELETE FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($a->argv[2]), intval(local_user()));
        if ($r) {
            info(t('Profile deleted.') . EOL);
        }
        goaway($a->get_baseurl() . '/profiles');
        return;
        // NOTREACHED
    }
    if ($a->argc > 1 && $a->argv[1] === 'new') {
        $r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d", intval(local_user()));
        $num_profiles = count($r0);
        $name = t('Profile-') . ($num_profiles + 1);
        $r1 = q("SELECT `name`, `photo`, `thumb` FROM `profile` WHERE `uid` = %d AND `is-default` = 1 LIMIT 1", intval(local_user()));
        $r2 = q("INSERT INTO `profile` (`uid` , `profile-name` , `name`, `photo`, `thumb`)\n\t\t\tVALUES ( %d, '%s', '%s', '%s', '%s' )", intval(local_user()), dbesc($name), dbesc($r1[0]['name']), dbesc($r1[0]['photo']), dbesc($r1[0]['thumb']));
        $r3 = q("SELECT `id` FROM `profile` WHERE `uid` = %d AND `profile-name` = '%s' LIMIT 1", intval(local_user()), dbesc($name));
        info(t('New profile created.') . EOL);
        if (count($r3) == 1) {
            goaway($a->get_baseurl() . '/profiles/' . $r3[0]['id']);
        }
        goaway($a->get_baseurl() . '/profiles');
    }
    if ($a->argc > 2 && $a->argv[1] === 'clone') {
        $r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d", intval(local_user()));
        $num_profiles = count($r0);
        $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 (!count($r1)) {
            notice(t('Profile unavailable to clone.') . EOL);
            return;
        }
        unset($r1[0]['id']);
        $r1[0]['is-default'] = 0;
        $r1[0]['publish'] = 0;
        $r1[0]['net-publish'] = 0;
        $r1[0]['profile-name'] = dbesc($name);
        dbesc_array($r1[0]);
        $r2 = dbq("INSERT INTO `profile` (`" . implode("`, `", array_keys($r1[0])) . "`) VALUES ('" . implode("', '", array_values($r1[0])) . "')");
        $r3 = q("SELECT `id` FROM `profile` WHERE `uid` = %d AND `profile-name` = '%s' LIMIT 1", intval(local_user()), dbesc($name));
        info(t('New profile created.') . EOL);
        if (count($r3) == 1) {
            goaway($a->get_baseurl() . '/profiles/' . $r3[0]['id']);
        }
        goaway($a->get_baseurl() . '/profiles');
        return;
        // NOTREACHED
    }
    if ($a->argc > 1 && intval($a->argv[1])) {
        $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($a->argv[1]), intval(local_user()));
        if (!count($r)) {
            notice(t('Profile not found.') . EOL);
            return;
        }
        profile_load($a, $a->user['nickname'], $r[0]['id']);
        require_once 'include/profile_selectors.php';
        $tpl = get_markup_template('profed_head.tpl');
        $opt_tpl = get_markup_template("profile-hide-friends.tpl");
        $hide_friends = replace_macros($opt_tpl, array('$desc' => t('Hide your contact/friend list from viewers of this profile?'), '$yes_str' => t('Yes'), '$no_str' => t('No'), '$yes_selected' => $r[0]['hide-friends'] ? " checked=\"checked\" " : "", '$no_selected' => $r[0]['hide-friends'] == 0 ? " checked=\"checked\" " : ""));
        $a->page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl()));
        $a->page['htmlhead'] .= "<script type=\"text/javascript\" src=\"js/country.js\" ></script>";
        $f = get_config('system', 'birthday_input_format');
        if (!$f) {
            $f = 'ymd';
        }
        $is_default = $r[0]['is-default'] ? 1 : 0;
        $tpl = get_markup_template("profile_edit.tpl");
        $o .= replace_macros($tpl, array('$banner' => t('Edit Profile Details'), '$submit' => t('Submit'), '$viewprof' => t('View this profile'), '$cr_prof' => t('Create a new profile using these settings'), '$cl_prof' => t('Clone this profile'), '$del_prof' => t('Delete this profile'), '$lbl_profname' => t('Profile Name:'), '$lbl_fullname' => t('Your Full Name:'), '$lbl_title' => t('Title/Description:'), '$lbl_gender' => t('Your Gender:'), '$lbl_bd' => sprintf(t("Birthday (%s):"), datesel_format($f)), '$lbl_address' => t('Street Address:'), '$lbl_city' => t('Locality/City:'), '$lbl_zip' => t('Postal/Zip Code:'), '$lbl_country' => t('Country:'), '$lbl_region' => t('Region/State:'), '$lbl_marital' => t('<span class="heart">&hearts;</span> Marital Status:'), '$lbl_with' => t("Who: (if applicable)"), '$lbl_ex1' => t('Examples: cathy123, Cathy Williams, cathy@example.com'), '$lbl_sexual' => t('Sexual Preference:'), '$lbl_homepage' => t('Homepage URL:'), '$lbl_politic' => t('Political Views:'), '$lbl_religion' => t('Religious Views:'), '$lbl_pubkey' => t('Public Keywords:'), '$lbl_prvkey' => t('Private Keywords:'), '$lbl_ex2' => t('Example: fishing photography software'), '$lbl_pubdsc' => t("(Used for suggesting potential friends, can be seen by others)"), '$lbl_prvdsc' => t("(Used for searching profiles, never shown to others)"), '$lbl_about' => t('Tell us about yourself...'), '$lbl_hobbies' => t('Hobbies/Interests'), '$lbl_social' => t('Contact information and Social Networks'), '$lbl_music' => t('Musical interests'), '$lbl_book' => t('Books, literature'), '$lbl_tv' => t('Television'), '$lbl_film' => t('Film/dance/culture/entertainment'), '$lbl_love' => t('Love/romance'), '$lbl_work' => t('Work/employment'), '$lbl_school' => t('School/education'), '$disabled' => $is_default ? 'onclick="return false;" style="color: #BBBBFF;"' : '', '$baseurl' => $a->get_baseurl(), '$profile_id' => $r[0]['id'], '$profile_name' => $r[0]['profile-name'], '$default' => $is_default ? '<p id="profile-edit-default-desc">' . t('This is your <strong>public</strong> profile.<br />It <strong>may</strong> be visible to anybody using the internet.') . '</p>' : "", '$name' => $r[0]['name'], '$pdesc' => $r[0]['pdesc'], '$dob' => dob($r[0]['dob']), '$hide_friends' => $hide_friends, '$address' => $r[0]['address'], '$locality' => $r[0]['locality'], '$region' => $r[0]['region'], '$postal_code' => $r[0]['postal-code'], '$country_name' => $r[0]['country-name'], '$age' => intval($r[0]['dob']) ? '(' . t('Age: ') . age($r[0]['dob'], $a->user['timezone'], $a->user['timezone']) . ')' : '', '$gender' => gender_selector($r[0]['gender']), '$marital' => marital_selector($r[0]['marital']), '$with' => strip_tags($r[0]['with']), '$sexual' => sexpref_selector($r[0]['sexual']), '$about' => $r[0]['about'], '$homepage' => $r[0]['homepage'], '$politic' => $r[0]['politic'], '$religion' => $r[0]['religion'], '$pub_keywords' => $r[0]['pub_keywords'], '$prv_keywords' => $r[0]['prv_keywords'], '$music' => $r[0]['music'], '$book' => $r[0]['book'], '$tv' => $r[0]['tv'], '$film' => $r[0]['film'], '$interest' => $r[0]['interest'], '$romance' => $r[0]['romance'], '$work' => $r[0]['work'], '$education' => $r[0]['education'], '$contact' => $r[0]['contact']));
        $arr = array('profile' => $r[0], 'entry' => $o);
        call_hooks('profile_edit', $arr);
        return $o;
    } else {
        $r = q("SELECT * FROM `profile` WHERE `uid` = %d", local_user());
        if (count($r)) {
            $tpl_header = get_markup_template('profile_listing_header.tpl');
            $o .= replace_macros($tpl_header, array('$header' => t('Edit/Manage Profiles'), '$chg_photo' => t('Change profile photo'), '$cr_new' => t('Create New Profile')));
            $tpl = get_markup_template('profile_entry.tpl');
            foreach ($r as $rr) {
                $o .= replace_macros($tpl, array('$photo' => $rr['thumb'], '$id' => $rr['id'], '$alt' => t('Profile Image'), '$profile_name' => $rr['profile-name'], '$visible' => $rr['is-default'] ? '<strong>' . t('visible to everybody') . '</strong>' : '<a href="' . $a->get_baseurl() . '/profperm/' . $rr['id'] . '" />' . t('Edit visibility') . '</a>'));
            }
        }
        return $o;
    }
}
Example #3
0
function profiles_content(&$a)
{
    $o = '';
    $channel = $a->get_channel();
    if (!local_channel()) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    require_once 'include/identity.php';
    $profile_fields_basic = get_profile_fields_basic();
    $profile_fields_advanced = get_profile_fields_advanced();
    if (argc() > 1 && intval(argv(1)) || !feature_enabled(local_channel(), 'multi_profiles')) {
        if (feature_enabled(local_channel(), 'multi_profiles')) {
            $id = $a->argv[1];
        } else {
            $x = q("select id from profile where uid = %d and is_default = 1", intval(local_channel()));
            if ($x) {
                $id = $x[0]['id'];
            }
        }
        $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($id), intval(local_channel()));
        if (!count($r)) {
            notice(t('Profile not found.') . EOL);
            return;
        }
        require_once 'include/profile_selectors.php';
        $editselect = 'none';
        //		if(feature_enabled(local_channel(),'richtext'))
        //			$editselect = 'textareas';
        $a->page['htmlhead'] .= replace_macros(get_markup_template('profed_head.tpl'), array('$baseurl' => $a->get_baseurl(true), '$editselect' => $editselect));
        $advanced = feature_enabled(local_channel(), 'advanced_profiles') ? true : false;
        if ($advanced) {
            $fields = $profile_fields_advanced;
        } else {
            $fields = $profile_fields_basic;
        }
        $opt_tpl = get_markup_template("profile_hide_friends.tpl");
        $hide_friends = replace_macros($opt_tpl, array('$field' => array('hide_friends', t('Hide your contact/friend list from viewers of this profile?'), $r[0]['hide_friends'], '')));
        $q = q("select * from profdef where true");
        if ($q) {
            $extra_fields = array();
            foreach ($q as $qq) {
                $mine = q("select v from profext where k = '%s' and hash = '%s' and channel_id = %d limit 1", dbesc($qq['field_name']), dbesc($r[0]['profile_guid']), intval(local_channel()));
                if (array_key_exists($qq['field_name'], $fields)) {
                    $extra_fields[] = array($qq['field_name'], $qq['field_desc'], $mine ? $mine[0]['v'] : '', $qq['field_help']);
                }
            }
        }
        //logger('extra_fields: ' . print_r($extra_fields,true));
        $f = get_config('system', 'birthday_input_format');
        if (!$f) {
            $f = 'ymd';
        }
        $is_default = $r[0]['is_default'] ? 1 : 0;
        $tpl = get_markup_template("profile_edit.tpl");
        $o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("profile_edit"), '$profile_clone_link' => feature_enabled(local_channel(), 'multi_profiles') ? 'profiles/clone/' . $r[0]['id'] . '?t=' . get_form_security_token("profile_clone") : '', '$profile_drop_link' => 'profiles/drop/' . $r[0]['id'] . '?t=' . get_form_security_token("profile_drop"), '$fields' => $fields, '$guid' => $r[0]['profile_guid'], '$banner' => t('Edit Profile Details'), '$submit' => t('Submit'), '$viewprof' => t('View this profile'), '$editvis' => t('Edit visibility'), '$profpic' => t('Change Profile Photo'), '$cr_prof' => t('Create a new profile using these settings'), '$cl_prof' => t('Clone this profile'), '$del_prof' => t('Delete this profile'), '$exportable' => feature_enabled(local_channel(), 'profile_export'), '$lbl_import' => t('Import profile from file'), '$lbl_export' => t('Export profile to file'), '$lbl_profname' => t('Profile Name:'), '$lbl_fullname' => t('Your Full Name:'), '$lbl_title' => t('Title/Description:'), '$lbl_gender' => t('Your Gender:'), '$lbl_bd' => t("Birthday :"), '$lbl_address' => t('Street Address:'), '$lbl_city' => t('Locality/City:'), '$lbl_zip' => t('Postal/Zip Code:'), '$lbl_country' => t('Country:'), '$lbl_region' => t('Region/State:'), '$lbl_marital' => t('<span class="heart">&hearts;</span> Marital Status:'), '$lbl_with' => t("Who: (if applicable)"), '$lbl_ex1' => t('Examples: cathy123, Cathy Williams, cathy@example.com'), '$lbl_howlong' => t('Since [date]:'), '$lbl_sexual' => t('Sexual Preference:'), '$lbl_homepage' => t('Homepage URL:'), '$lbl_hometown' => t('Hometown:'), '$lbl_politic' => t('Political Views:'), '$lbl_religion' => t('Religious Views:'), '$lbl_pubkey' => t('Keywords:'), '$lbl_likes' => t('Likes:'), '$lbl_dislikes' => t('Dislikes:'), '$lbl_ex2' => t('Example: fishing photography software'), '$lbl_pubdsc' => t("Used in directory listings"), '$lbl_about' => t('Tell us about yourself...'), '$lbl_hobbies' => t('Hobbies/Interests'), '$lbl_social' => t('Contact information and Social Networks'), '$lbl_channels' => t('My other channels'), '$lbl_music' => t('Musical interests'), '$lbl_book' => t('Books, literature'), '$lbl_tv' => t('Television'), '$lbl_film' => t('Film/dance/culture/entertainment'), '$lbl_love' => t('Love/romance'), '$lbl_work' => t('Work/employment'), '$lbl_school' => t('School/education'), '$disabled' => $is_default ? 'onclick="return false;" style="color: #BBBBFF;"' : '', '$baseurl' => $a->get_baseurl(true), '$profile_id' => $r[0]['id'], '$profile_name' => $r[0]['profile_name'], '$is_default' => $is_default, '$default' => t('This is your default profile.') . EOL . translate_scope(map_scope($channel['channel_r_profile'])), '$advanced' => $advanced, '$name' => $r[0]['name'], '$pdesc' => $r[0]['pdesc'], '$dob' => dob($r[0]['dob']), '$hide_friends' => $hide_friends, '$address' => $r[0]['address'], '$locality' => $r[0]['locality'], '$region' => $r[0]['region'], '$postal_code' => $r[0]['postal_code'], '$country_name' => $r[0]['country_name'], '$age' => intval($r[0]['dob']) ? '(' . t('Age: ') . age($r[0]['dob'], $a->user['timezone'], $a->user['timezone']) . ')' : '', '$gender' => gender_selector($r[0]['gender']), '$gender_min' => gender_selector_min($r[0]['gender']), '$marital' => marital_selector($r[0]['marital']), '$marital_min' => marital_selector_min($r[0]['marital']), '$with' => $r[0]['with'], '$howlong' => $r[0]['howlong'] === NULL_DATE ? '' : datetime_convert('UTC', date_default_timezone_get(), $r[0]['howlong']), '$sexual' => sexpref_selector($r[0]['sexual']), '$sexual_min' => sexpref_selector_min($r[0]['sexual']), '$about' => $r[0]['about'], '$homepage' => $r[0]['homepage'], '$hometown' => $r[0]['hometown'], '$politic' => $r[0]['politic'], '$religion' => $r[0]['religion'], '$keywords' => $r[0]['keywords'], '$likes' => $r[0]['likes'], '$dislikes' => $r[0]['dislikes'], '$music' => $r[0]['music'], '$book' => $r[0]['book'], '$tv' => $r[0]['tv'], '$film' => $r[0]['film'], '$interest' => $r[0]['interest'], '$romance' => $r[0]['romance'], '$work' => $r[0]['work'], '$education' => $r[0]['education'], '$contact' => $r[0]['contact'], '$channels' => $r[0]['channels'], '$extra_fields' => $extra_fields));
        $arr = array('profile' => $r[0], 'entry' => $o);
        call_hooks('profile_edit', $arr);
        return $o;
    } else {
        $r = q("SELECT * FROM `profile` WHERE `uid` = %d", local_channel());
        if (count($r)) {
            $tpl_header = get_markup_template('profile_listing_header.tpl');
            $o .= replace_macros($tpl_header, array('$header' => t('Edit/Manage Profiles'), '$addstuff' => t('Add profile things'), '$stuff_desc' => t('Include desirable objects in your profile'), '$chg_photo' => t('Change profile photo'), '$cr_new' => t('Create New Profile'), '$cr_new_link' => 'profiles/new?t=' . get_form_security_token("profile_new")));
            $tpl = get_markup_template('profile_entry.tpl');
            foreach ($r as $rr) {
                $o .= replace_macros($tpl, array('$photo' => $rr['thumb'], '$id' => $rr['id'], '$alt' => t('Profile Image'), '$profile_name' => $rr['profile_name'], '$visible' => $rr['is_default'] ? '<strong>' . translate_scope(map_scope($channel['channel_r_profile'])) . '</strong>' : '<a href="' . $a->get_baseurl(true) . '/profperm/' . $rr['id'] . '" />' . t('Edit visibility') . '</a>'));
            }
        }
        return $o;
    }
}
Example #4
0
function profiles_content(&$a)
{
    if (!local_user()) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    $o = '';
    if ($a->argc > 1 && intval($a->argv[1])) {
        $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($a->argv[1]), intval(local_user()));
        if (!count($r)) {
            notice(t('Profile not found.') . EOL);
            return;
        }
        require_once 'include/profile_selectors.php';
        /*		$editselect = 'textareas';
        		if( intval(get_pconfig(local_user(),'system','plaintext')) || !feature_enabled(local_user(),'richtext') )
        			$editselect = 'none';*/
        $editselect = 'none';
        if (feature_enabled(local_user(), 'richtext')) {
            $editselect = 'textareas';
        }
        $a->page['htmlhead'] .= replace_macros(get_markup_template('profed_head.tpl'), array('$baseurl' => $a->get_baseurl(true), '$editselect' => $editselect));
        $a->page['end'] .= replace_macros(get_markup_template('profed_end.tpl'), array('$baseurl' => $a->get_baseurl(true), '$editselect' => $editselect));
        $opt_tpl = get_markup_template("profile-hide-friends.tpl");
        $hide_friends = replace_macros($opt_tpl, array('$yesno' => array('hide-friends', t('Hide contacts and friends:'), !!$r[0]['hide-friends'], '', array(t('No'), t('Yes'))), '$desc' => t('Hide your contact/friend list from viewers of this profile?'), '$yes_str' => t('Yes'), '$no_str' => t('No'), '$yes_selected' => $r[0]['hide-friends'] ? " checked=\"checked\" " : "", '$no_selected' => $r[0]['hide-friends'] == 0 ? " checked=\"checked\" " : ""));
        $f = get_config('system', 'birthday_input_format');
        if (!$f) {
            $f = 'ymd';
        }
        $is_default = $r[0]['is-default'] ? 1 : 0;
        $tpl = get_markup_template("profile_edit.tpl");
        $o .= replace_macros($tpl, array('$multi_profiles' => feature_enabled(local_user(), 'multi_profiles'), '$form_security_token' => get_form_security_token("profile_edit"), '$form_security_token_photo' => get_form_security_token("profile_photo"), '$profile_clone_link' => 'profiles/clone/' . $r[0]['id'] . '?t=' . get_form_security_token("profile_clone"), '$profile_drop_link' => 'profiles/drop/' . $r[0]['id'] . '?t=' . get_form_security_token("profile_drop"), '$banner' => t('Edit Profile Details'), '$submit' => t('Submit'), '$profpic' => t('Change Profile Photo'), '$viewprof' => t('View this profile'), '$cr_prof' => t('Create a new profile using these settings'), '$cl_prof' => t('Clone this profile'), '$del_prof' => t('Delete this profile'), '$lbl_basic_section' => t('Basic information'), '$lbl_picture_section' => t('Profile picture'), '$lbl_location_section' => t('Location'), '$lbl_preferences_section' => t('Preferences'), '$lbl_status_section' => t('Status information'), '$lbl_about_section' => t('Additional information'), '$lbl_interests_section' => t('Interests'), '$lbl_profile_photo' => t('Upload Profile Photo'), '$lbl_profname' => t('Profile Name:'), '$lbl_fullname' => t('Your Full Name:'), '$lbl_title' => t('Title/Description:'), '$lbl_gender' => t('Your Gender:'), '$lbl_bd' => t("Birthday :"), '$lbl_address' => t('Street Address:'), '$lbl_city' => t('Locality/City:'), '$lbl_zip' => t('Postal/Zip Code:'), '$lbl_country' => t('Country:'), '$lbl_region' => t('Region/State:'), '$lbl_marital' => t('<span class="heart">&hearts;</span> Marital Status:'), '$lbl_with' => t("Who: (if applicable)"), '$lbl_ex1' => t('Examples: cathy123, Cathy Williams, cathy@example.com'), '$lbl_howlong' => t('Since [date]:'), '$lbl_sexual' => t('Sexual Preference:'), '$lbl_homepage' => t('Homepage URL:'), '$lbl_hometown' => t('Hometown:'), '$lbl_politic' => t('Political Views:'), '$lbl_religion' => t('Religious Views:'), '$lbl_pubkey' => t('Public Keywords:'), '$lbl_prvkey' => t('Private Keywords:'), '$lbl_likes' => t('Likes:'), '$lbl_dislikes' => t('Dislikes:'), '$lbl_ex2' => t('Example: fishing photography software'), '$lbl_pubdsc' => t("(Used for suggesting potential friends, can be seen by others)"), '$lbl_prvdsc' => t("(Used for searching profiles, never shown to others)"), '$lbl_about' => t('Tell us about yourself...'), '$lbl_hobbies' => t('Hobbies/Interests'), '$lbl_social' => t('Contact information and Social Networks'), '$lbl_music' => t('Musical interests'), '$lbl_book' => t('Books, literature'), '$lbl_tv' => t('Television'), '$lbl_film' => t('Film/dance/culture/entertainment'), '$lbl_love' => t('Love/romance'), '$lbl_work' => t('Work/employment'), '$lbl_school' => t('School/education'), '$disabled' => $is_default ? 'onclick="return false;" style="color: #BBBBFF;"' : '', '$baseurl' => $a->get_baseurl(true), '$profile_id' => $r[0]['id'], '$profile_name' => $r[0]['profile-name'], '$default' => $is_default ? '<p id="profile-edit-default-desc">' . t('This is your <strong>public</strong> profile.<br />It <strong>may</strong> be visible to anybody using the internet.') . '</p>' : "", '$name' => $r[0]['name'], '$pdesc' => $r[0]['pdesc'], '$dob' => dob($r[0]['dob']), '$hide_friends' => $hide_friends, '$address' => $r[0]['address'], '$locality' => $r[0]['locality'], '$region' => $r[0]['region'], '$postal_code' => $r[0]['postal-code'], '$country_name' => $r[0]['country-name'], '$age' => intval($r[0]['dob']) ? '(' . t('Age: ') . age($r[0]['dob'], $a->user['timezone'], $a->user['timezone']) . ')' : '', '$gender' => gender_selector($r[0]['gender']), '$marital' => marital_selector($r[0]['marital']), '$with' => strip_tags($r[0]['with']), '$howlong' => $r[0]['howlong'] === '0000-00-00 00:00:00' ? '' : datetime_convert('UTC', date_default_timezone_get(), $r[0]['howlong']), '$sexual' => sexpref_selector($r[0]['sexual']), '$about' => $r[0]['about'], '$homepage' => $r[0]['homepage'], '$hometown' => $r[0]['hometown'], '$politic' => $r[0]['politic'], '$religion' => $r[0]['religion'], '$pub_keywords' => $r[0]['pub_keywords'], '$prv_keywords' => $r[0]['prv_keywords'], '$likes' => $r[0]['likes'], '$dislikes' => $r[0]['dislikes'], '$music' => $r[0]['music'], '$book' => $r[0]['book'], '$tv' => $r[0]['tv'], '$film' => $r[0]['film'], '$interest' => $r[0]['interest'], '$romance' => $r[0]['romance'], '$work' => $r[0]['work'], '$education' => $r[0]['education'], '$contact' => $r[0]['contact']));
        $arr = array('profile' => $r[0], 'entry' => $o);
        call_hooks('profile_edit', $arr);
        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 (count($r)) {
                //Go to the default profile.
                goaway($a->get_baseurl(true) . '/profiles/' . $r[0]['id']);
            }
        }
        $r = q("SELECT * FROM `profile` WHERE `uid` = %d", local_user());
        if (count($r)) {
            $tpl_header = get_markup_template('profile_listing_header.tpl');
            $o .= replace_macros($tpl_header, array('$header' => t('Edit/Manage Profiles'), '$chg_photo' => t('Change profile photo'), '$cr_new' => t('Create New Profile'), '$cr_new_link' => 'profiles/new?t=' . get_form_security_token("profile_new")));
            $tpl = get_markup_template('profile_entry.tpl');
            foreach ($r as $rr) {
                $o .= replace_macros($tpl, array('$photo' => $a->get_cached_avatar_image($rr['thumb']), '$id' => $rr['id'], '$alt' => t('Profile Image'), '$profile_name' => $rr['profile-name'], '$visible' => $rr['is-default'] ? '<strong>' . t('visible to everybody') . '</strong>' : '<a href="' . $a->get_baseurl(true) . '/profperm/' . $rr['id'] . '" />' . t('Edit visibility') . '</a>'));
            }
        }
        return $o;
    }
}
Example #5
0
function profiles_content(&$a)
{
    if (!local_user()) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    if ($a->argc > 2 && $a->argv[1] == "drop" && intval($a->argv[2])) {
        $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `is-default` = 0 AND `self` = 0 LIMIT 1", intval($a->argv[2]));
        if (!count($r)) {
            notice(t('Profile not found.') . EOL);
            goaway($a->get_baseurl() . '/profiles');
            return;
            // NOTREACHED
        }
        // move every contact using this profile as their default to the user default
        $r = q("UPDATE `contact` SET `profile-id` = (SELECT `profile`.`id` AS `profile-id` FROM `profile` WHERE `profile`.`is-default` = 1 LIMIT 1) WHERE `profile-id` = %d ", intval($a->argv[2]));
        $r = q("DELETE FROM `profile` WHERE `id` = %d LIMIT 1", intval($a->argv[2]));
        if ($r) {
            notice(t('Profile deleted.') . EOL);
        }
        goaway($a->get_baseurl() . '/profiles');
        return;
        // NOTREACHED
    }
    if ($a->argc > 1 && $a->argv[1] == 'new') {
        $r0 = q("SELECT `id` FROM `profile` WHERE 1");
        $num_profiles = count($r0);
        $name = t('Profile-') . ($num_profiles + 1);
        $r1 = q("SELECT `name`, `photo`, `thumb` FROM `profile` WHERE `is-default` = 1 LIMIT 1");
        $r2 = q("INSERT INTO `profile` (`profile-name` , `name`, `photo`, `thumb`)\n\t\t\tVALUES ( '%s', '%s', '%s', '%s' )", dbesc($name), dbesc($r1[0]['name']), dbesc($r1[0]['photo']), dbesc($ra[0]['thumb']));
        $r3 = q("SELECT `id` FROM `profile` WHERE `profile-name` = '%s' LIMIT 1", dbesc($name));
        notice(t('New profile created.') . EOL);
        if (count($r3) == 1) {
            goaway($a->get_baseurl() . '/profiles/' . $r3[0]['id']);
        }
        goaway($a->get_baseurl() . '/profiles');
    }
    if ($a->argc > 2 && $a->argv[1] == 'clone') {
        $r0 = q("SELECT `id` FROM `profile` WHERE 1");
        $num_profiles = count($r0);
        $name = t('Profile-') . ($num_profiles + 1);
        $r1 = q("SELECT * FROM `profile` WHERE `id` = %d LIMIT 1", intval($a->argv[2]));
        if (!count($r1)) {
            notice(t('Profile unavailable to clone.') . EOL);
            return;
        }
        unset($r1[0]['id']);
        $r1[0]['is-default'] = 0;
        $r1[0]['publish'] = 0;
        $r1[0]['net-publish'] = 0;
        $r1[0]['profile-name'] = dbesc($name);
        dbesc_array($r1[0]);
        $r2 = q("INSERT INTO `profile` (`" . implode("`, `", array_keys($r1[0])) . "`) VALUES ('" . implode("', '", array_values($r1[0])) . "')");
        $r3 = q("SELECT `id` FROM `profile` WHERE `profile-name` = '%s' LIMIT 1", dbesc($name));
        notice(t('New profile created.') . EOL);
        if (count($r3) == 1) {
            goaway($a->get_baseurl() . '/profiles/' . $r3[0]['id']);
        }
        goaway($a->get_baseurl() . '/profiles');
        return;
        // NOTREACHED
    }
    if (intval($a->argv[1])) {
        $r = q("SELECT * FROM `profile` WHERE `id` = %d LIMIT 1", intval($a->argv[1]));
        if (!count($r)) {
            notice(t('Profile not found.') . EOL);
            return;
        }
        require_once 'mod/profile.php';
        profile_load($a, $a->user['nickname'], $r[0]['id']);
        require_once 'view/profile_selectors.php';
        $tpl = file_get_contents('view/profed_head.tpl');
        $opt_tpl = file_get_contents("view/profile-hide-friends.tpl");
        $hide_friends = replace_macros($opt_tpl, array('$yes_selected' => $r[0]['hide-friends'] ? " checked=\"checked\" " : "", '$no_selected' => $r[0]['hide-friends'] == 0 ? " checked=\"checked\" " : ""));
        $a->page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl()));
        $a->page['htmlhead'] .= "<script type=\"text/javascript\" src=\"include/country.js\" ></script>";
        $is_default = $r[0]['is-default'] ? 1 : 0;
        $tpl = file_get_contents("view/profile_edit.tpl");
        $o .= replace_macros($tpl, array('$disabled' => $is_default ? 'onclick="return false;" style="color: #BBBBFF;"' : '', '$baseurl' => $a->get_baseurl(), '$profile_id' => $r[0]['id'], '$profile_name' => $r[0]['profile-name'], '$default' => $is_default ? '<p id="profile-edit-default-desc">' . t('This is your <strong>public</strong> profile.<br />It <strong>may</strong> be visible to anybody using the internet.') . '</p>' : "", '$name' => $r[0]['name'], '$dob' => dob($r[0]['dob']), '$hide_friends' => $hide_friends, '$address' => $r[0]['address'], '$locality' => $r[0]['locality'], '$region' => $r[0]['region'], '$postal_code' => $r[0]['postal-code'], '$country_name' => $r[0]['country-name'], '$age' => intval($r[0]['dob']) ? '(' . t('Age: ') . age($r[0]['dob'], $a->user['timezone'], $a->user['timezone']) . ')' : '', '$gender' => gender_selector($r[0]['gender']), '$marital' => marital_selector($r[0]['marital']), '$sexual' => sexpref_selector($r[0]['sexual']), '$about' => $r[0]['about'], '$homepage' => $r[0]['homepage'], '$politic' => $r[0]['politic'], '$religion' => $r[0]['religion'], '$music' => $r[0]['music'], '$book' => $r[0]['book'], '$tv' => $r[0]['tv'], '$film' => $r[0]['film'], '$interest' => $r[0]['interest'], '$romance' => $r[0]['romance'], '$work' => $r[0]['work'], '$education' => $r[0]['education'], '$contact' => $r[0]['contact']));
        return $o;
    } else {
        $r = q("SELECT * FROM `profile` WHERE 1");
        if (count($r)) {
            $o .= file_get_contents('view/profile_listing_header.tpl');
            $tpl_default = file_get_contents('view/profile_entry_default.tpl');
            $tpl = file_get_contents('view/profile_entry.tpl');
            foreach ($r as $rr) {
                $template = $rr['is-default'] ? $tpl_default : $tpl;
                $o .= replace_macros($template, array('$photo' => $rr['thumb'], '$id' => $rr['id'], '$profile_name' => $rr['profile-name']));
            }
        }
        return $o;
    }
}