Wednesday, May 15, 2013

How To Disable Right Click On Your Blog

How To Disable Right Click On Your Blog ?

If you own a blog or a website then you always want to prevent other malicious bloggers from copying the content from your blog. 


You might have written an article with great efforts and lots of research and other just copy/paste it on their blog.

To prevent such users from copying content from your blog i will show you Javascript Trick to disable right click on your blog. So lets get started.





1. Go your blogger Layout dashboard.

2. Add gadget and select HTML/JavaScript.


3. Copy & paste below code.


<script language='JavaScript'>


function disableselect(e){
     return false
}
function reEnable(){
    return true
}
document.onselectstart=new Function ("return false")
   if (window.sidebar){
        document.onmousedown=disableselect
        document.onclick=reEnable
   }
</script>


4. Save and test your blog.

Cheers...!!!

Tuesday, May 14, 2013

Related List in vTiger CRM



Creating or Deleting a Related List in vTiger CRM:-

“More Information” tab in the Detail View of record associates one particular module with multiple records of any other module.

How to create a New Related ListView:-
<?php
include_once('vtlib/Vtiger/Module.php');
//Where you want to add the realted module.
//Source Module Name
$moduleInstance = Vtiger_Module::getInstance('Products');
//Target Module Name
$targetModule = Vtiger_Module::getInstance('Vendors');
//Target Module Relationship Label.
$relationLabel  = 'Vendors';
//call back function name.
$function_name = 'get_vendors';
//Create a relation ship.
$moduleInstance->setRelatedList($targetModule, $relationLabel, Array('ADD','SELECT'),$function_name);
?>

(Note: Take the code above to any text editor and name it to ‘Related_moduleName.php’ while saving and save it under root directory of vtigerCRM. After saving run this file on server (either localhost or your own server) which will add UI under source module. ModuleName referred above is the name of module.)

This function stated above is to be defined in <SOURCE MODULE> class and will generate the entries of listview to be displayed. In addition to this an entry in ‘vtiger_crmentityrel’ table will be made which will track the relation between all the modules and their corresponding records. All primary modules in vTigerCRM handles relation in tables separately and undergo JOIN which fetching the data specific to every module.

Delete the Related ListView:-

<?php
include_once('vtlib/Vtiger/Module.php');
//Where you want to add the realted module.
//Source Module Name
$moduleInstance = Vtiger_Module::getInstance('Products');
//Target Module Name
$targetModule = Vtiger_Module::getInstance('Vendors');
//Target Module Relationship Label.
$relationLabel  = 'Vendors';
//call back function name.
$function_name = 'get_vendors';
//Delete a relation ship.
$moduleInstance->unsetRelatedList($targetModule,$relationLabel,$function_name);?>


Create a New UItype in VtigerCRM


Creating a New Popup UItype in VtigerCRM5.1.0 for a Newly Created Module.

Here things are explained using Locations Module. Locations is a new module that we have already created and is functioning well.

I assume that the newly created UItype is 1001 for Locations popup selector.

1. First  I added a method to: include/utils/CommonUtils.php

function getLocationName($location_id)
{
global $log;
$log->debug("Entering getLocationName(".$location_id.") method ...");
$log->info("in getlocationname ".$location_id);

global $adb;
$sql = "select locationname from vtiger_locations where locationsid=?";
    $result = $adb->pquery($sql, array($location_id));
$locationname = $adb->query_result($result,0,"locationname");
$log->debug("Exiting getLocationName method ...");
return $locationname;
}

2.Added an elseif condition in else if ladder of file:  include/utils/EditViewUtils.php

elseif($uitype == 1001)
{
if($value != '')
{
$location_name = getLocationName($value);
}
elseif(isset($_REQUEST['location_id']) && $_REQUEST['location_id'] != '')
{
$value = $_REQUEST['location_id'];
$location_name = getLocationName($value);
}
$pop_type = 'specific';
$editview_label[]=getTranslatedString($fieldlabel, $module_name);
$fieldvalue[] = $location_name;
$fieldvalue[] = $value;
}

3.Added an elseif condition in else if ladder of file::  include/utils/EditViewUtils.php
elseif($uitype == 1001)
   {
$label_fld[] =getTranslatedString($fieldlabel, $module);
           $location_id = $col_fields[$fieldname];
           if($location_id != '')
           {
                  $location_name = getLocationName($location_id);
           }
          $label_fld[] = $location_name;
$label_fld["secid"] = $location_id;
$label_fld["link"] = "index.php?module=Locations&action=DetailView&record=".$location_id;
   }
Edited Smarty (.tpl) files.
1.Smarty/templates/DetailViewFields.tpl
Replaced following else if
{elseif $keyid eq '50' || $keyid eq '73' || $keyid eq '51' || $keyid eq '57' || $keyid eq '59' || $keyid eq '75' || $keyid eq '81' || $keyid eq '76' || $keyid eq '78' || $keyid eq '80'}

with
{elseif $keyid eq '50' || $keyid eq '73' || $keyid eq '51' || $keyid eq '57' || $keyid eq '59' || $keyid eq '75' || $keyid eq '1001' || $keyid eq '81' || $keyid eq '76' || $keyid eq '78' || $keyid eq '80'}
2.Smarty/templates/EditViewUI.tpl
Added the following in {elseif} ladder
{elseif $uitype eq 1001}
<td width="20%" class="dvtCellLabel" align=right>
{assign var="pop_type" value="specific"}
<font color="red">{$mandatory_field}</font>{$usefldlabel} {if $MASS_EDIT eq '1'}
<input type="checkbox" name="{$fldname}_mass_edit_check" id="{$fldname}_mass_edit_check" class="small" >{/if}
</td>
<td width="30%" align=left class="dvtCellInfo">
<input name="location_name" readonly type="text" style="border:1px solid #bababa;" value="{$fldvalue}"><input name="{$fldname}" type="hidden" value="{$secondvalue}">&nbsp;<img src="{'select.gif'|@vtiger_imageurl:$THEME}" alt="{$APP.LBL_SELECT}" title="{$APP.LBL_SELECT}" LANGUAGE=javascript onclick='return window.open("index.php?module=Locations&action=Popup&html=Popup_picker&popuptype={$pop_typ e}&form=EditView&fromlink={$fromlink}","test","width=640,height=602,resizable=0,scrollbars=0");' align="absmiddle" style='cursor:hand;cursor:pointer'>
<input type="image" tabindex="{$vt_tab}" src="{'clear_field.gif'|@vtiger_imageurl:$THEME}" alt="{$APP.LBL_CLEAR}" title="{$APP.LBL_CLEAR}" LANGUAGE=javascript onClick="this.form.location_id.value='';this.form.location_name.value='';return false;" align="absmiddle" style='cursor:hand;cursor:pointer'>
</td>

3.Smarty/templates/DetailViewUI.tpl
Added the following in {elseif} ladder
{elseif $keyid eq '1001'} <!--LocationPopup-->
<td width=25% class="dvtCellInfo" align="left" id="mouseArea_{$label}">&nbsp;<a href="{$keyseclink}">{$keyval}</a> </td>    
And Finally:
Added the following in {elseif} ladder : include/js/dtlviewajax.js
else if(uitype == '1001') {
getObj(dtlView).innerHTML = "<a href=\"index.php?module=Locations&action=DetailView&record="+tagValue+"\">"+popObj.value+"&nbs p;</a>";
}
Added a method to: modules/Locations/Locations.js
document.write("<script type='text/javascript' src='include/js/Mail.js'></"+"script>");
document.write("<script type='text/javascript' src='include/js/Merge.js'></"+"script>");

function set_return_specific(location_id, location_name)
{
       //getOpenerObj used for DetailView
       var fldName = getOpenerObj("location_name");
       var fldId = getOpenerObj("location_id");
       fldName.value = location_name;
       fldId.value = location_id;
}