Пример #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;
     }
 }
Пример #2
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;
    }
}