Jump to content

[SOLVED] return a variable in an existing function.


spdwrench

Recommended Posts

I do not know where this function is called in the script... but can I return the $login variable somehow within this function? like could I set a global $theloginwas    and record the value of $login in the function?

 

I am looking for a quick way to modify this function so I can read the $login variable outside of the function

 

please help

 

function doImport($importer_class,$login,$name)
{
global $_CONFIG;
$oRespX = new xajaxResponse();
$classFile = $_CONFIG['BASE_DIR'].'/include/classes/importer/'.$importer_class.'.php';
if (file_exists($classFile)) {
	require_once($classFile);
	$oImporter = new $importer_class();
	$bImporter = true;	
}
else{
	$bImporter = false;
}	

$sTxt = '';

if($bImporter){
	$result_array = $oImporter->run($login,$name);//array()

	if(is_array($result_array))
	{
		$names = array_shift($result_array);		
		$emails = array_shift($result_array);
		if(count($emails)>0){			

			$sTxt .= '<form action="" onsubmit="javascript:do_send(this);return false;" id="send_form" name="send_form">
			<table width="100%" border="0" cellspacing="0" cellpadding="2" style="background-color: #e9e9e9;">
			  <tr> 
			    <td width="25%" align="left"><input type="checkbox" name="all1"  id="all1" value="1" onclick="select_all(this);" checked="true"> 
			      <b>Select All</b></td>
			    <td width="50%" align="left"><b>Email Address</b></td>
			    <td width="25%" align="left"><b>Name</b></td>
			  </tr>
			  <tr> 
						<td bgcolor="#FFFFFF" height="1" colspan="3"></td>
			  </tr>
			  ';
			for ($i = 0; $i < count($emails) ; $i++) {
				if(strpos($emails[$i], '@')){

				$sTxt .='<tr> 
					    <td align="left">
					    <input type=checkbox name="email_array[]" id="email_array[]" value="'.$emails[$i].'" checked="true">
					    </td>
					    <td align="left">
					    '.$emails[$i].'
					    </td>
					    <td align="left">
					    '.$names[$i].'
					    </td>
					</tr>
					<tr> 
						<td bgcolor="#FFFFFF" height="1" colspan="3"></td>
					</tr>
					';					
			}
			}
		$sTxt .= '<tr> 
				    <td align="left"><input type="checkbox" name="all2"  id="all2" value="1" onclick="select_all(this);" checked="true"> 
				      <b>Select All</b></td>
				    <td> </td>
				    <td> </td>
				  </tr>
				  <tr> 
					<td bgcolor="#FFFFFF" height="1" colspan="3"></td>
				  </tr>
				  <tr> 
				    <td><div align="right"><b>Subject</b></div></td>
				    <td colspan="2"><div align="left">
				        <input type="text" name="subject" readonly id="subject" value="'.$_CONFIG['MAIL_SUBJECT'].'" size="50">
				      </div></td>
				  </tr>
				  <tr>
				    <td valign="top"><div align="right"><b>Content</b></div></td>
				    <td colspan="2" valign="top"><div align="left">
				        <textarea name="body" id="body" readonly cols="50" rows="15">'.$_CONFIG['MAIL_BODY'].'</textarea>
				      </div></td>
				  </tr>
				  <tr> 
				    <td> </td>
				    <td colspan="2" align="left"> <input type="submit" name="send_bn" value="Send">
				          
				        <input name="send_bn2" type="reset" id="send_bn2" value="Reset"> </td>
				  </tr>
				</table>
				</form>
				';

		}else{

			$sTxt .= '<p>not any contact on your account.</p>';

		}
	}
	else if($result_array==1)
	{
		$sTxt .= '<p>Invalid login name or password.</p>';
	}
	else
	{		
		$sTxt .= '<p>An Unknown error has occurred .</p>';
	}


}
else
{
	$sTxt .= '<p>Not this webmail importer installed.</p>';
}
$sTxt .= '';	

$oRespX->addAssign("login_form_div","innerHTML", $sTxt);	

return $oRespX;

}

Link to comment
Share on other sites

Yes, Neptunus, you could, but it would likely mess up the other code that uses the function, as it is expecting a class.

 

The function accepts the variable $login, so if you find where the function is called, it will already have the value you are looking for in that scope. Something like: doImport($aclass, $alogin, $aname); You can use $aname as the login that is passed to that function.

Link to comment
Share on other sites

ok I am on to a fix for my problem

 

the function asigns an outgoing email to be sent... I need to squeez the $login variable into this and I will have achieved my goal... the following line is returned in part of the function.

 

<input type="text" name="subject" readonly id="subject" value="'.$login.'" size="50">

 

this puts the $login variable in the subject line of the outgoing email my only problem now is I need it to say

 

for example if $login=paul

 

value needs to be: paul has invited you..

 

how can I ad invited you to the end of the $login when setting the value? I tried . and " and all kinds of ways but cant seem to get it.....

 

also how would I set a value like if I wanted login in the middle of some text also...

 

thanks guys... if I get this im all set to modify the function easily.

 

Paul

Link to comment
Share on other sites

yea ... if that works... I was just having a problem with the actual sytanx...

 

If figured another way to do it in the meantime but I was going to ask if there was an easier way.....

 

this is how I got it to work

 

$ssub=$login." Has Invited You";

 

and I used $ssub  as the value... hehe anyway thanks I will use your method...

 

Paul

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.