xoops forums

deka87

Friend of XOOPS
Posted on: 2009/1/4 12:24
deka87
deka87 (Show more)
Friend of XOOPS
Posts: 1124
Since: 2007/10/5
#1

Your email visible in Profile module

Hi,

Is there a way to create some kind of contact form (e.g. those used to contact administrator or in the catads module when you are contacting an ad poster) to implement into the profile module as a way to contact the user instead of PM and direct emails. The thing is that showing a user's email address is not good for his/her privacy and PM is not enough 'cos anonymous can't use it and it doesnt send a message to an email adress directly.

Maybe I could use for example Contact Us module and replace the admin email adress with something like $thisUser->getVar('email')? I am not sure how to do this tho'
Mind anchors

deka87

Friend of XOOPS
Posted on: 2009/1/4 12:29
deka87
deka87 (Show more)
Friend of XOOPS
Posts: 1124
Since: 2007/10/5
#2

Re: Your email visible in Profile module

and one more thing. when you do any search in profile/search.php it shows users' emails in the results. How do I hide it?
Mind anchors

ghia

Community Support Member
Posted on: 2009/1/4 13:20
ghia
ghia (Show more)
Community Support Member
Posts: 4954
Since: 2008/7/3 1
#3

Re: Your email visible in Profile module

Maybe one of the member modules have such a funtionality?
Quote:
when you do any search in profile/search.php it shows users' emails in the results.
It should only show email addresses from users, which wanted that the email address in their profile is visible.

deka87

Friend of XOOPS
Posted on: 2009/1/4 16:32
deka87
deka87 (Show more)
Friend of XOOPS
Posts: 1124
Since: 2007/10/5
#4

Re: Your email visible in Profile module

Quote:
It should only show email addresses from users, which wanted that the email address in their profile is visible.


yeah, but how do I hide the whole column containing emails in the search results?
Mind anchors

deka87

Friend of XOOPS
Posted on: 2009/1/4 17:39
deka87
deka87 (Show more)
Friend of XOOPS
Posts: 1124
Since: 2007/10/5
#5

Re: Your email visible in Profile module

as in regard to the contact form...

I took the guts from catads module contact scripts and got this: http://7.pdvop2sz.z8.ru/modules/profile/userinfo.php?uid=1 (please click email icon to see it in action) but as you can see it doesnt load the form. here is a working sample in catads module: http://7.pdvop2sz.z8.ru/modules/catads/adsitem.php?ads_id=12. I seem to change all variables but it doesn't work. Could you please check the final scripts? Seems like it requires 2 files: contact.php and form_contact.inc.php.

contact.php

$op 'form';
foreach (
$_POST as $k => $v) {${$k} = $v;}
foreach (
$_GET as $k => $v) {${$k} = $v;}

if ( isset(
$preview)) {
    
$op 'preview';
} elseif ( isset(
$post) ) {
    
$op 'post';
}

function 
displaypost($title$content) {
    echo 
'<table cellpadding="4" cellspacing="1" width="98%" class="outer"><tr><td class="head">'.$title.'</td></tr><tr><td><br />'.$content.'<br /></td></tr></table>';
}

switch(
$op) {
    
case 
"post":
    global 
$xoopsConfig;
    include(
"../../mainfile.php");
    
$ts =& MyTextSanitizer::getInstance();
 
        
$fullmsg _MD_CATADS_FROMUSER.$name_user "._MD_CATADS_YOURADS." ".$xoopsConfig['sitename']." :nn";
        
$fullmsg .= $title."n";
        
$fullmsg .= "-----------------------------------------------------------------n";
        
$fullmsg .= "$messagenn";
        
$fullmsg .= "-----------------------------------------------------------------nn";
        
$fullmsg .= _MD_CATADS_CANJOINT.$email_user";
        if (
$phone !='')
            
$fullmsg .= 'n'._MD_CATADS_ORAT.$phone";
            
        
$xoopsMailer =& getMailer();
        
$xoopsMailer->useMail();
        
$xoopsMailer->setFromEmail($email_user);
        
$xoopsMailer->setFromName($xoopsConfig['sitename']);
        
$xoopsMailer->setToEmails($email_author);
        
$xoopsMailer->setSubject(_MD_CATADS_CONTACTAFTERADS);
        
$xoopsMailer->setBody($fullmsg);
        
$msgsend "<div style='text-align:center;'><br /><br />";
        if ( !
$xoopsMailer->send()) {
            
$msgsend .= $xoopsMailer->getErrors();
        } else {
            
$msgsend .= "<h4>"._MD_CATADS_MSGSEND."</h4>";
        }
        
$msgsend .= "<br /><br /><a href="javascript:window.close();">"._PM_ORCLOSEWINDOW."</a></div>";
        echo 
$msgsend;
    break;
    
case 
"preview":
    include(
"../../mainfile.php");
    
$ts =& MyTextSanitizer::getInstance();
    
xoops_header();

    
$p_title $title;
//    $p_title = $myts->makeTboxData4Preview($p_title);
    
$p_title $ts->htmlSpecialChars($ts->stripSlashesGPC($p_title));
    
$p_msg _MD_CATADS_FROMUSER.$name_user "._MD_CATADS_YOURADS." ".$xoopsConfig['sitename']." :<br />";
        
$p_msg .= $title.'<br />';
        
$p_msg .= "-----------------------------------------------------------------<br />";
        
$p_msg .= $message.'<br /><br />';
        
$p_msg .= "-----------------------------------------------------------------<br />";
        
$p_msg .= _MD_CATADS_CANJOINT.$email_user";
        if (
$phone !='')
            
$p_msg .= '<br />'._MD_CATADS_ORAT.$phone";

    
$p_msg .= '<br />';
    
displaypost($p_title$p_msg);

    
$title =  $ts->htmlSpecialChars($ts->stripSlashesGPC($title));
    
$message =  $ts->htmlSpecialChars($ts->stripSlashesGPC($message));
    
    include 
"include/form_contact.inc.php";
    
xoops_footer();
    break;
    
case 
"form":
default:

    include(
"../../mainfile.php");
    
xoops_header();
       
$member_handler =& xoops_gethandler('member');
    
$thisUser =& $member_handler->getUser($uid);
    
// initialisation variables    
    
$message '';    
    
$phone '';    
    
$name_user '';    
    
$email_user ='';
    
$email_author $thisUser->getVar('email''E');
    
$title "Regarding your profile on FreelancerSupport.com";
    if(
$xoopsUser) {
        
$name_user = ($xoopsUser->getVar('name')!='')? $xoopsUser->getVar("name") : $xoopsUser->getVar("uname");
        
$email_user $xoopsUser->getVar("email""E");
    }

    include 
"include/form_contact.inc.php";
    
xoops_footer();
break;
}


form_contact.inc.php:

include XOOPS_ROOT_PATH."/class/xoopsformloader.php";

$form_contact = new XoopsThemeForm(_MD_CATADS_CONTACTAUTOR"form_contact""contact.php");

$title_text = new XoopsFormText(_MD_CATADS_TITLE"title"52100$title);
$form_contact->addElement($title_texttrue);

$name_text = new XoopsFormText(_MD_CATADS_YOURNAME.'*'"name_user"50100$name_user);
$form_contact->addElement($name_texttrue);

$email_text = new XoopsFormText(_MD_CATADS_YOUREMAIL.'*'"email_user"50100$email_user);
$form_contact->addElement($email_text,true);

$phone_text = new XoopsFormText(_MD_CATADS_YOURPHONE"phone"2020,$phone);
$form_contact->addElement($phone_textfalse);

$annonce_text = new XoopsFormTextArea(_MD_CATADS_YOURMESSAGE.'*'"message"$message);
$form_contact->addElement($annonce_texttrue);

$button_tray = new XoopsFormElementTray('' ,'');
$button_tray->addElement(new XoopsFormButton('''preview'_PREVIEW'submit'));
$button_tray->addElement(new XoopsFormButton('''post'_SEND'submit'));
$button_cancel = new XoopsFormButton('''cancel'_CANCEL'button');
$button_cancel->setExtra("' onclick='javascript:window.close();'");
$button_tray->addElement($button_cancel);

$form_contact->addElement($button_tray);

$form_contact->addElement(new XoopsFormHidden('email_author'$email_author));

$form_contact->display();


maybe I missed something...
Mind anchors

trabis

Core Developer
Posted on: 2009/1/4 18:33
trabis
trabis (Show more)
Core Developer
Posts: 2268
Since: 2006/9/1 1
#6

Re: Your email visible in Profile module

where are the files located?
this works
http://7.pdvop2sz.z8.ru/modules/catads/contact.php?ads_id=12

and this will not(this is what your javascript is loading)
http://7.pdvop2sz.z8.ru/modules/catads/contact.php?ads_id=1
because there is no ad number 1

so where are this files you made?
Should not the javascript be pointing to modules/profile/contact.php ?

deka87

Friend of XOOPS
Posted on: 2009/1/4 19:35
deka87
deka87 (Show more)
Friend of XOOPS
Posts: 1124
Since: 2007/10/5
#7

Re: Your email visible in Profile module

So i forgot to change the link in the userinfo.php. to modules/profile/contact.php. now it's being loaded alright. anothe rproblem is that it doesn't send emails. guess i messed somethign up in the finla part of contact.php:

default:

    include(
"../../mainfile.php");
    
xoops_header();
       
$member_handler =& xoops_gethandler('member');
    
$thisUser =& $member_handler->getUser($uid);
    
// initialisation variables    
    
$message '';    
    
$phone '';    
    
$name_user '';    
    
$email_user ='';
    
$email_author $thisUser->getVar('email');
    
$title "Regarding your profile on FreelancerSupport.com";
    if(
$xoopsUser) {
        
$name_user = ($xoopsUser->getVar('name')!='')? $xoopsUser->getVar("name") : $xoopsUser->getVar("uname");
        
$email_user $xoopsUser->getVar("email""E");
    }

    include 
"include/form_contact.inc.php";
    
xoops_footer();
break;
}


$email_author is what we are looking for.

do you see any mistakes?
Mind anchors

trabis

Core Developer
Posted on: 2009/1/4 21:05
trabis
trabis (Show more)
Core Developer
Posts: 2268
Since: 2006/9/1 1
#8

Re: Your email visible in Profile module

Must do 2 things.
First change ads_id= to uid= in the link, looks nicer!

Second, add this line in the form:
$form_contact->addElement(new XoopsFormHidden('uid', $uid));

This should be enough

deka87

Friend of XOOPS
Posted on: 2009/1/5 7:26
deka87
deka87 (Show more)
Friend of XOOPS
Posts: 1124
Since: 2007/10/5
#9

Re: Your email visible in Profile module

cool, now it can send emails.

but what about hiding emails column in the profile/search.php? or maybe replacing those emails with the contact links like <a href=\"javascript:openWithSelfMain('".XOOPS_URL."/modules/profile/contact.php?uid=".$uid."', 'contact', 600, 450);\"><img src=\"".XOOPS_URL."/modules/".$xoopsModule->getVar('dirname')."/images/email.gif\" alt=\""._MD_CATADS_BYMAIL."\" /></a>?
Mind anchors

deka87

Friend of XOOPS
Posted on: 2009/1/5 9:39
deka87
deka87 (Show more)
Friend of XOOPS
Posts: 1124
Since: 2007/10/5
#10

Re: Your email visible in Profile module

solved. here is the final result: http://freelancersupport.com/modules/ ... sh-to-Russian-translators

so now nobody can see users' email address and the only way to contact them is via the website. privacy is ok now =)
Mind anchors