what is the code for other browser in vtigercrm - vtiger

this works only in IE
what is the code,if we want to use mail merge feature in other browser
<script>
if (window.ActiveXObject){
try
{
ovtigerVM = eval("new ActiveXObject('vtigerCRM.ActiveX');");
if(ovtigerVM)
{
var filename = "<?php echo $filename?>";
if(filename != "")
{
if(objMMPage.bDLTempDoc("<?php echo $site_URL?>/test/wordtemplatedownload/<?php echo $filename?>","MMTemplate.doc"))
{
try
{
if(objMMPage.Init())
{
objMMPage.vLTemplateDoc();
objMMPage.bBulkHDSrc("<?php echo $site_URL;?>/test/wordtemplatedownload/<?php echo $datafilename ?>");
objMMPage.vBulkOpenDoc();
objMMPage.UnInit()
window.history.back();
}
}catch(errorObject)
{
document.write("Error while processing mail merge operation");
}
}else
{
document.write("Cannot get template document");
}
}
}
}
catch(e) {
document.write("Requires to download ActiveX Control from vtigerCRM. Please, ensure that you have administration privilage");
}
}
</script>

Simply you can't, cause of the ActiveX Control.
But on github, there is a mod to accomplish the same task, generating an OpenOffice Document (compatible with Word).
It works only on vtiger 5.4
https://github.com/tsolucio/corebos/commit/21a33c071777a312ca6ce11e4b13889994dc52a4

Related

Not getting transactResponse event when using IFrameCommunicator (sandbox)

I am using Authorize.net hosted payment page in sandbox using iframe method. I implemented IFrameCommunicator mechanism to receive messages. My page gets resize events and cancel event. I am not getting transactResponse event on completed transaction.
Wondering whether transactResponse event is available in the sandbox environment?
you should set 'hostedProfileIFrameCommunicatorUrl' value. eg:
$setting = new AnetAPI\SettingType();
$setting->setSettingName("hostedProfileIFrameCommunicatorUrl");
$url = 'your url';
$setting->setSettingValue($url);
$request->addToHostedProfileSettings($setting);
$controller = new AnetController\GetHostedProfilePageController($request);
$response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX);
function callParentFunction(str) {
var referrer = document.referrer;
var s = {qstr : str , parent : referrer};
//console.log(s); str include response .
if(referrer == 'https://test.authorize.net/customer/addPayment'){
switch(str){
case 'action=successfulSave' :
//your code
break;
}
}
}
function receiveMessage(event) {
if (event && event.data) {
callParentFunction(event.data);
}
}
if (window.addEventListener) {
window.addEventListener("message", receiveMessage, false);
} else if (window.attachEvent) {
window.attachEvent("onmessage", receiveMessage);
}
if (window.location.hash && window.location.hash.length > 1) {
callParentFunction(window.location.hash.substring(1));
}

Redirecting URL in WordPress

I want to redirect a URL in the form of
http://a_domain_name.com/2013/08/link_name/feed to http://a_domain_name.com/link_name/feed. I am a WordPress beginner and finding it hard to do this . Whats the best way to do this ?
I tried using the safe redirection plugin with http://domain_name.com/%year%/%monthnum%/%postname%/feed to http://domain_name.com/%postname%/feed but it's not working
The Proper Way
Log into wordpress admin panel and go to the settings>permalinks page.
From here, select the second to last option, ie:
http://domain.com/blogname/blog/sample-post/
Alternatively, you can create a redirect file. This involves hacking up wordpress a bit. I wouldn't recommend this if you're not comfortable with wordpress & php. To do this, first:
Open the setting>permalinks page in the admin panel:
Select the last option in the list (custom) and enter something like this:
/redirect.php?p=%post_id%&a=%author%&c=%category%
You'll also need to change the two optional forms below to:
Category base
/redirect.php?c=
Tag base
/redirect.php?t=
Now, let's create a redirect php file. Place this in /yourblogname/blog/
<?php
$total=0;
$string = 'http://www.yourdomain.com/';
$fetch = '';
if (isset($_GET['p'])&&!is_null($_GET['p']))
{
$p = $_GET['p'];
if ($total ==0) {
$string.='?p='.$p;
} else {
$string.='&p='.$p;
}
$total++;
}
if (isset($_GET['t'])&&!is_null($_GET['t']))
{
$t = str_replace('/','',$_GET['t']);
if ($total ==0) {
$string.='?tag='.$t;
} else {
$string.='&tag='.$t;
}
$total++;
}
if (isset($_GET['a'])&&!is_null($_GET['a']))
{
$a = $_GET['a'];
if ($total ==0) {
$string.='?a='.$a;
} else {
$string.='&a='.$a;
}
$total++;
}
if (isset($_GET['s'])&&!is_null($_GET['s']))
{
$s = $_GET['s'];
if ($total ==0) {
$string.='?s='.$s;
} else {
$string.='&s='.$s;
}
$total++;
}
if (isset($_GET['c'])&&!is_null($_GET['c']))
{
$c = str_replace('/','',$_GET['c']);
if ($total ==0) {
$string.='?category_name='.$c;
} else {
$string.='&category_name='.$c;
}
$total++;
}
echo '<head><meta http-equiv="Refresh" content="0; URL='.$string.'">';
?>
<style>
html {
background:black;
color:white;
}
</style>
</head>
<body>
<div id=cont>
<p align=center><div style='font-size:72px;text-align:center;' ><?php echo "redirecting..."; ?></p></div>
</div>
</body>
We're not done yet. We need to adjust the page we're redirecting to now... (index.php)
if (!isset($_GET['p'])) {
if (!isset($_GET['category_name']) && !isset($_GET['tag']) && !isset($_GET['s']) && !isset($_GET['search']) ) {
include('newhome.php'); //frontpage with no special redirect
} else {
include('listabbrposts.php'); //a list of abbreviated posts for browsing
}
} else {
include('entry.php'); // a page with a single article
}
For a working example, you can check out my page where I use this technique: http://www.artfuladvection.com click on a topic or tag from the left to see the redirect.

HowTo: send app request, and get data from request (to redirec to to a specific link) without user accepting the app?

let's say user send app requests to his friends,
this request will be targeting something /my_app/catalog.php?ID=25
(not the index page)
the only way to store specific link in app request is to use "data" field of the request.
when user follow app request it will end up on index.php (not catalog.php?ID=25)
how could i extract data field from request without knowing user id? (and without him accepting the app ?)
i can get request_ids and also app_token (not user_access_tocken)
by using
https://graph.facebook.com/oauth/access_token?client_id=".$GLOBALS['app_id']."&client_secret=".$GLOBALS['app_secret']."&grant_type=client_credentials
but without the user id and him accepting the app it is impossible to get "data" field
so instead of user been able to see a product in my app that his friend recommended him , he sees auth forms and accept the app dialogs whiout knoing what is this app about.
this is not a right behavor and to my undestanding first user had to see a link on my page and later on if he want to do actions or my app need permissions for user's info - only when should the "accept dialog" be used.
UPDATE:
I guess Juicy right and where is no other way to get app request url but to either store it in your own database or require user to accept the app
in case if someone else looking for this workaround
here is some usefull stuff:
//to deal with app requests: (this is part of overall page output preparation)
$rqlink="";
if((strlen($_REQUEST['request_ids'])>0)&&(strlen($user->id)>0))//user is logged no need for database
{
if(($rq=getfbres("https://graph.facebook.com/?ids=".$_REQUEST['request_ids']."&access_token=".$_SESSION['access_token'] ))!==false)
{
$rqj = json_decode($rq);
$request_ids = explode(',', $_REQUEST['request_ids']);
foreach ($request_ids as $request_id)
{
$full_request_id=$request_id.'_'.$user->id;
if(isset($rqj->$request_id->data)) $rqlink=$rqj->$request_id->data;
//if(getfbres("https://graph.facebook.com/$full_request_id?method=delete&access_token=".$_SESSION['access_token'])===false)
//{ echo "delete request error:". $GLOBALS['err']; exit;}
break;
}
}
}
elseif(strlen($_REQUEST['request_ids'])>0) //user is not logged, try to extract url from database
{
$request_ids = explode(',', urldecode($_REQUEST['request_ids']));
foreach ($request_ids as $request_id)
{
if(!isset($conn)){include_once "conn.php"; $conn=init_conn();}
if(!($rez=mysql_query("select * from ff_app_rq where rq='".str_replace("'","''",$request_id)."'",$conn))) die ("Database error");
if(mysql_num_rows($rez)>0)
{
$row=mysql_fetch_assoc($rez);
$rqlink=$row['url'];
mysql_free_result($rez);
break;
}
else //request not found for some reason and user is not authorized
{ //force pop-up authorization in order not to loose req_ids
mysql_free_result($rez);
echo("<script LANGUAGE='javascript'>window.open('/fblogin.php','_blank','width=900,height=450');</script>");
break;
}
}
}
if(strlen($rqlink)>0)
{
session_write_close();
echo("<script LANGUAGE='javascript'>document.location.href='".$rqlink."';</script>");
// echo("<script LANGUAGE='javascript'>top.location.href='http".(getenv("HTTPS") == 'on'?"s":"")."://apps.facebook.com/".$GLOBALS['app_namespace']."/".$rqlink."';</script>");
exit;
}
this is how you promote:
function fire_promo()
{
FB.init({appId:'<?php echo $GLOBALS['app_id'];?>',status:true,cookie:true,frictionlessRequests:true,oauth:true});
//(this will display popup with list of fb friends)
getpage('ajforms.php?ID=<?php echo $id;?>&stage=promote_app','subcontent,-100,10,560,500,2,zzz');
return false;
}
function sendRequestToManyRecipients()
{
var f=document.send_inv; //(this form lists all checked users)
var ids="";
for(var z=0;z<f.length;z++) if(f[z].name=='p') if(f[z].checked) {if(ids.length>0) ids+=',';ids+=f[z].value;}
FB.ui({method:'apprequests',data:'catalog.php?ID=<?php echo $id;?>',message:'You have been invited to bla-bla',to:"'"+ids+"'"}, requestCallback);
}
here is app request javascript callback:
function requestCallback(response)
{
if(response === undefined) return;
//if(response.request===undefined) return;
var req = getconn(); if(req) {req.open("HEAD",'fb_req.php?rq='+response.request+'&url='+encodeURIComponent('catalog.php?ID=<?php echo $id;?>',true));req.send(null);}
//console.log(response.request);
if(response.to.length === undefined) {} else if(response.to.length>0) alert('You have successfully promoted to '+response.to.length+' friends.\nThank You!');
}
(getconn is a standart ajax function to initialize ajax communications)
here is fb_req.php to log app requests:
<?php
if((strlen($_REQUEST['rq'])>0)&&(strlen($_REQUEST['url'])>0))
{
include_once "conn.php";
$conn=init_conn();
$rez=mysql_query("insert into my_app_rq_table (rq,url,rq_date) VALUES('".str_replace("'","''",$_REQUEST['rq'])."','".str_replace("'","''",urldecode($_REQUEST['url']))."',now())",$conn);
//if(!$rez) die ("Database error".mysql_error());
}
exit;
?>
and finnaly here is fblogin.php for pop-up authorization and when refreshing opener window:
<?php
session_start();
include_once "params.php";
$code = $_REQUEST["code"];
if(strlen($code)>2)
{
$my_url = "http".(getenv("HTTPS")=='on'?"s":"")."://".getdom().((($_SERVER['SERVER_PORT']=="80")||($_SERVER['SERVER_PORT']=="443"))?(""):(":".$_SERVER['SERVER_PORT']))."/fblogin.php?fb_redirect_url=".urlencode($_REQUEST['fb_redirect_url']);
$token_url = "https://graph.facebook.com/oauth/access_token?client_id=".$GLOBALS['app_id']."&redirect_uri=".urlencode($my_url)."&client_secret=".$GLOBALS['app_secret']."&code=".$code;
$access_token = getfbres($token_url);
$graph_url = "https://graph.facebook.com/me?".$access_token;
$rr=strpos($access_token,"&");
if($rr>0) $access_token=substr($access_token,0,$rr);
$access_token=str_replace("access_token=","",$access_token);
$user = json_decode(getfbres($graph_url));
if(strlen($user->id)>0)
{
$_SESSION['access_token']=$access_token;
if(strlen($_REQUEST['fb_redirect_url'])>0)
echo "<SCRIPT LANGUAGE='javascript'>\nwindow.opener.location.href='".urldecode($_REQUEST['fb_redirect_url'])."';\nwindow.close();</script>";
else
echo "<SCRIPT LANGUAGE='javascript'>\nwindow.opener.location.reload(true);\nwindow.close();</script>";
exit;
}
}
if(strlen($_SESSION['access_token'])>2)
{
$graph_url = "https://graph.facebook.com/me?access_token=".$_SESSION['access_token'];
$user = json_decode(getfbres($graph_url));
if(strlen($user->id)>0)
{
if(strlen($_REQUEST['fb_redirect_url'])>0)
echo "<SCRIPT LANGUAGE='javascript'>\nwindow.opener.location.href='".urldecode($_REQUEST['fb_redirect_url'])."';\nwindow.close();</script>";
else
echo "<SCRIPT LANGUAGE='javascript'>\nwindow.opener.location.reload(true);\nwindow.close();</script>";
exit;
}
}
$my_url = "http".(getenv("HTTPS")=='on'?"s":"")."://".getdom().((($_SERVER['SERVER_PORT']=="80")||($_SERVER['SERVER_PORT']=="443"))?(""):(":".$_SERVER['SERVER_PORT']))."/fblogin.php?fb_redirect_url=".urlencode($_REQUEST['fb_redirect_url']);
$dialog_url = "http://www.facebook.com/dialog/oauth?client_id=".$GLOBALS['app_id']."&redirect_uri=".urlencode($my_url).$GLOBALS['app_scope'];
//echo "<h1>".$_SESSION['log_attempts']."</h1>";
$_SESSION['log_attempts']=intval("0".$_SESSION['log_attempts'])+1;
if(intval("0".$_SESSION['log_attempts'])<5)
echo("<script>document.location.href='".$dialog_url."';</script>");
else echo "<center><br><br><br><h1>Facebook Login failed</h1><br>Please refresh web page and try again.</center>";
exit;
function getdom()
{
return strtolower(str_replace("www.","",$_SERVER['SERVER_NAME']));
}
function getfbres($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
if(curl_error($ch)) $err=curl_error($ch); else $err="";
curl_close($ch);
//echo "<pre>info:<br>"; var_dump($info); echo "<br>output:<br>"; echo $output; if (strlen($err)>0) echo "<br>error:<br>$err"; echo "</pre><br>";
if ($output === false || $info['http_code'] != 200)
{
// $GLOBALS['err']=$output."\nhttp code:".$info['http_code']."\n".$err;
// echo "<pre>info:<br>"; var_dump($info); echo "<br>output:<br>"; echo $output; if (strlen($err)>0) echo "<br>error:<br>$err"; echo "</pre><br>";
// exit;
return false;
}
return $output;
}
?>
Event if the data cannot be retrieved (which should not be the case according to my tests using application access_token in older format APP_ID|APP_SECRET) you can easily save this details at your end linked to request id you get while sending it to user and later issue redirection based on data you already have.

SWFobject embedded swf, ExternalInterface.Call returns null

im working on a flash game with django backend using swfobject to embed the swf into the view,
however when i do externalinterface.call() from flash in InternetExplorer(Chrome and Firefox are fine), it returns null
the flash game itself works perfectly
Django view and embed code:
<div id="game_container">
<div id='flashContent'></div>
</div>
<script type="text/javascript" src="swfobject.js"></script>
<script type='text/javascript'>
var flashvars={{flashvars|safe}};
var params={wmode:"opaque", allowscriptaccess:"always" };
var attributes={id:"flashContent", name:"flashContent"};
swfobject.embedSWF("{{SWF_URL}}", "flashContent", "{{ appsettings.SWF_WIDTH }}", "{{ appsettings.SWF_HEIGHT }}", "10.0.0", false, flashvars, params, attributes);
</script>
function fqlearn_isEventInteresting(data) {
ln_log(['isEventInteresting',data]);
if (!BASE_URL) BASE_URL = data.baseURL;
ln_log(['got lesson?',fqlearn_findLearningModule(data) != null]);
return fqlearn_findLearningModule(data) != null;
//shuld return either true or false.
}
Flash AS3 code:
var isInteresting:Object = false;
try {
isInteresting = ExternalInterface.call('fqlearn_isEventInteresting', data);
} catch (e:Error) {
trace("error calling external interface");
// Container does not support outgoing calls :/
rpc.forceLogUncaughtError("ExternalInterface.call problem",
e.name, e.toString(), e.getStackTrace());
rest.apply(restThis);
return;
} catch (e:SecurityError) {
// Security sandbox nonsense :/
throw e;
}
if (isInteresting == null) {
// Something went wrong :/
rpc.forceLogUncaughtError("ExternalInterface.call problem", "JS_returned_null_error");
}
if (isInteresting) {
trace("showing learning blackout")
dispatch(CoordinationEvent.newLEARNING_ABOUT_TO_SHOW());
learningPendingData = {
rest: rest,
restThis: restThis
};
ExternalInterface.call() from Flash in InternetExplorer(Chrome and Firefox are fine), it returns null . how do i fix this?
Fixed it: console.debug was choking up Internet Explorer. I removed those and it worked.

Load PHP file with document.createElement()

How could I make this work? I want to load a php file like this:
Click button.
Call Javascript function.
In Javascript function create an img with src file.php.
This should force the loading of the php. Here is the code.
<script type="text/javascript">
var d;
function callSave() {
alert ('calling');
if (d) document.body.removeChild(d);
// d = document.createElement("script");
d = document.createElement("img");
d.src = "savepages.php";
//d.type = "text/javascript";
document.body.appendChild(d);
}
</script>
Then in savepages.php I do another alert to verify that the php is called and it isn't. Here is the savepages.php.
<?php
echo "alert('from the php');";
?>
The alert from the php doesn't happen. Is there a different element type that will force loading of the php? I don't have ajax installed, so I need a workaround like this.
Thanks.
You could use an iframe element
<script type="text/javascript">
var d;
function callSave() {
alert ('calling');
if (d) document.body.removeChild(d);
d = document.createElement("iframe");
d.src = "savepages.php";
document.body.appendChild(d);
}
</script>
Found out the better way to handle this. There is this simple code that explains how to call a javascript function from a form event and from that javascript function load a PHP file. The code found at http://daniel.lorch.cc/docs/ajax_simple/ is also given here:
<script type="text/javascript">
var http = false;
if(navigator.appName == "Microsoft Internet Explorer") {
http = new ActiveXObject("Microsoft.XMLHTTP");
} else {
http = new XMLHttpRequest();
}
function validate(user) {
http.abort();
http.open("GET", "validate.php?name=" + user, true);
http.onreadystatechange=function() {
if(http.readyState == 4) {
document.getElementById('msg').innerHTML = http.responseText;
}
}
http.send(null);
}
</script>
<h1>Please choose your username:</h1>
<form>
<input type="text" onkeyup="validate(this.value)" />
<div id="msg"></div>
</form>
validate.php
<?php
function validate($name) {
if($name == '') {
return '';
}
if(strlen($name) < 3) {
return "<span id=\"warn\">Username too short</span>\n";
}
switch($name) {
case 'bob':
case 'jim':
case 'joe':
case 'carol':
return "<span id=\"warn\">Username already taken</span>\n";
}
return "<span id=\"notice\">Username ok!</span>\n";
}
echo validate(trim($_REQUEST['name']));
?>