 |
vtiger The Honest Open Source CRM
|
| Previous topic :: Next topic |
| Author |
Message |
ales
Joined: 13 Jun 2006
Posts: 18
Location: Slovenia
|
| Posted: Thu Jul 27, 2006 12:10 pm Post subject: Custom View 4.2.x |
|
|
1. Default sort field
2. Check field for other can view
3. Admin sees/can edit all views
4. Copy from existing
Here is copy-paste code from files
a) First you must create table needed for feature to work
DROP TABLE IF EXISTS `customviewsettings`;
CREATE TABLE `customviewsettings` (
`cvid` int(19) unsigned NOT NULL default '0',
`orderby` varchar(255) default NULL,
`sorder` varchar(45) NOT NULL default 'ASC',
`owner` varchar(45) NOT NULL default '',
`publicview` tinyint(3) unsigned NOT NULL default '0',
PRIMARY KEY (`cvid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
b) In file ../modules/CustomView/EditView.html where {CHECKED} and {MCHECKED} is replaye lines with (for new check box Public View):
..
<td class='dataLabel'></td>
<td>
<input class='textField' {CHECKED} type='checkbox' name='setDefault' value="">{MOD.LBL_SETDEFAULT}
</td>
<td width="35%">
<input class='textField' {MCHECKED} type='checkbox' name='setMetrics' value="">{MOD.LBL_LIST_IN_METRICS}
</td>
<td>
<input class='textField' {CVPCHECKED} type='checkbox' name='setPublic' value="">{MOD.LBL_SETPUBLIC}
</td>
..
c) Ad to file ../modules/CustomView/language/en_us.lang.php at the end of the file (for labels):
..
'LBL_SETPUBLIC'=>'Public View',
'LBL_SORTBY'=>'Sort by field',
'LBL_SORDER'=>'Sort order',
..
d) In file ../modules/CustomView/EditView.php add under if($recordid == "") after //step4 next lines:
..
//step5
//order by fields
$xtpl->assign("CVORDERBY",$choosecolhtml);
//set sort order
$sorder_html = "<option value='ASC' selected>ASC</option><option value='DESC'>DESC</option>";
$xtpl->assign("CVSORDER",$sorder_html);
..
e) In file ../modules/CustomView/EditView.php add after $xtpl->assign("VIEWNAME",$customviewdtls["viewname"]); next lines (for get data from database):
..
/**
*
* Get default CustomView settings for the 'order_by' , 'sorder' , 'owner' and 'public'
*
*/
$customviewsettings = $oCustomView->getCustomViewSettingsByCvid($recordid);
$vtlog->logthis('CustomView :: Successfully got ViewSettingsDetails for the Viewid'.$recordid,'info');
//default if no record is returned
$order_by = '1';
$sorder = 'ASC';
$publicview = 0;
$owner = '';
if( $customviewsettings["cvid"] ) {
$order_by = $customviewsettings["orderby"];
$sorder = $customviewsettings["sorder"];
$owner = $customviewsettings["owner"];
$publicview = $customviewsettings["publicview"];
}
/* end */
..
f) In the same file as above add after if($customviewdtls["publicview"] == 1) similar if after public view (for template assign):
..
//public view
if($publicview == 1)
{
$xtpl->assign("CVPCHECKED","checked");
}
..
g) Add in the same file as above after for($i=1;$i<10;$i++) {} .. next lines (for setting the right order by and sort order and template assign):
..
//set order by
if( isset($order_by) ) {
$choosecolhtml = getByModule_ColumnsHTML($cv_module,$modulecollist,$order_by);
}else{
$choosecolhtml = getByModule_ColumnsHTML($cv_module,$modulecollist,$selectedcolumnslist[1]);
}
$xtpl->assign("CVORDERBY",$choosecolhtml);
//set sort order
if( $sorder == "ASC" ) {
$sorder_html = "<option value='ASC' selected>ASC</option><option value='DESC'>DESC</option>";
}else{
$sorder_html = "<option value='ASC'>ASC</option><option value='DESC' selected>DESC</option>";
}
$xtpl->assign("CVSORDER",$sorder_html);
..
h) Add to file ../modules/CustomView/CustomView.php public property and new function:
..
var $customviewsettings = Array("cvid"=>0,"OrderBy"=>"","SOrder"=>"","Owner"=>"","PublicView"=>"");
..
function getCustomViewSettingsByCvid($cvid)
{
global $adb;
$ssql = "select * from customviewsettings";
$ssql .= " where cvid=".$cvid;
$result = $adb->query($ssql);
while($cvrow=$adb->fetch_array($result))
{
$customviewsettings["cvid"] = $cvrow["cvid"];
$customviewsettings["orderby"] = $cvrow["orderby"];
$customviewsettings["sorder"] = $cvrow["sorder"];
$customviewsettings["owner"] = $cvrow["owner"];
$customviewsettings["publicview"] = $cvrow["publicview"];
}
return $customviewsettings;
}
..
i) Add to file ../modules/CustomView/Save.php under if($cvmodule != "") after if(isset($_REQUEST["setMetrics"])) next lines (for save new data):
..
//custom view settings
if(isset($_REQUEST["orderby"]))
{
$orderby = $_REQUEST["orderby"];
}else
{
$orderby = "";
}
if(isset($_REQUEST["sorder"]))
{
$sorder = $_REQUEST["sorder"];
}else
{
$sorder = "";
}
if(isset($_REQUEST["setPublic"]))
{
$setpublic = 1;
}else
{
$setpublic = 0;
}
..
j) In the same file as above ad under if($cvid == "") after $cvid = $genCVid; } next lines (for save):
..
$cv_sql = "insert into customviewsettings (cvid,orderby,sorder,owner,publicview) values (";
$cv_sql .= $genCVid.",'".$orderby."','".$sorder."','".$current_user->user_name."',".$setpublic.");";
$cv_res = $adb->query($cv_sql);
$vtlog->logthis("CustomView :: Save :: cvviewsettings created successfully","info");
..
and under else after $vtlog->logthis("CustomView :: Save :: cvadvfilter update successfully".$genCVid,"info"); } } add next lines:
..
$cv_sql = "update customviewsettings set";
$cv_sql .= " orderby='".$orderby."',sorder='".$sorder."',owner='".$current_user->user_name."',publicview=".$setpublic;
$cv_sql .= " where cvid = ".$genCVid;
$cv_res = $adb->query($cv_sql);
$vtlog->logthis("CustomView :: Save :: cvviewsettings created successfully","info");
..
k) In file ../modules/CustomView/Delete.php ad under if(isset($cvid) && $cvid != '') next lines (for delete):
..
$cv_sql = "delete from customviewsettings where cvid =".$cvid;
$cv_result = $adb->query($deletesql);
..
l) In file ../modules/Activities/ListView.php under if($viewid == 0) and under else add next lines (for in module to CV maintenance):
..
/**
*
* Get default CustomView settings 'owner' and user type 'is_admin'
*
*/
$cv_sql = "select * from customviewsettings where cvid = ".$viewid.";";
$cv_res = $adb->query($cv_sql);
if( $cv_array = $adb->fetch_array($cv_res) ) {
$cv_owner = $cv_array['owner'];
}
$cv_sql = "select * from users where user_name = '".$current_user->user_name."';";
$cv_res = $adb->query($cv_sql);
if( $cv_array = $adb->fetch_array($cv_res) ) {
$cv_viewer_is_admin = $cv_array['is_admin'];
}
/* end */
..
and to the end of else ..} replace lines with:
..
if( $cv_owner == $current_user->user_name || $cv_viewer_is_admin == "on" ) {
$cvHTML = '<a href="index.php?module=Activities&action=CustomView&record='.$viewid.'" class="link">'.$app_strings['LNK_CV_EDIT'].'</a>
<span class="sep">|</span>
<a href="index.php?module=CustomView&action=Delete&dmodule=Activities&record='.$viewid.'" onclick="if (window.confirm("'.$app_strings['LNK_CV_DELETECONFIRM'].'")) {window.location="index.php?module=CustomView&action=Delete&dmodule=Activities&record='.$viewid.'"; return(false) } else {return(false)}" class="link">'.$app_strings['LNK_CV_DELETE'].'</a>
<span class="sep">|</span>
<a href="index.php?module=Activities&action=CustomView" class="link">'.$app_strings['LNK_CV_CREATEVIEW'].'</a>';
}else{
$cvHTML = '<span class="bodyText disabled">'.$app_strings['LNK_CV_EDIT'].'</span>
<span class="sep">|</span>
<span class="bodyText disabled">'.$app_strings['LNK_CV_DELETE'].'</span>
<span class="sep">|</span>
<a href="index.php?module=Activities&action=CustomView" class="link">'.$app_strings['LNK_CV_CREATEVIEW'].'</a>';
}
..
and by the if(isset($order_by) && $order_by != '') replace all under {..}else{..} with lines:
..
if(isset($order_by) && $order_by != '')
{
$list_query .= ' ORDER BY '.$order_by.' '.$sorder;
}else{
/**
*
* Get default CustomView settings for the 'order_by' and 'sorder' and 'public'
*
*/
$cv_sql = "select * from customviewsettings where cvid = ".$viewid.";";
$cv_res = $adb->query($cv_sql);
$order_by = '1';
$sorder = 'ASC';
$publicview = 0;
if( $cv_array = $adb->fetch_array($cv_res) ) {
$order_by_array = explode( ":", $cv_array['orderby'] );
$order_by = $order_by_array[1];
$sorder = $cv_array['sorder'];
$publicview = $cv_array['publicview'];
}
$list_query .= ' ORDER BY '.$order_by.' '.$sorder;
/* end */
}
..
m) In file ../include/language/eu_en.lang.php you add after 'LNK_CV_CREATEVIEW'=>'Create View' add new line (for label):
..
'LNK_CV_CREATECOPY'=>'Copy View',
..
n) In file ../modules/CustomView/EditView.php add after $recordid = $_REQUEST['record']; next lines:
..
//if copy view is to be done
if( isset($_REQUEST['CopyView']) ) {
$copyview = $_REQUEST['CopyView'];
}else{
$copyview = "";
}
..
and replace $xtpl->assign("CUSTOMVIEWID",$recordid); with:
..
//if copy view is to be done
if( $copyview == 1 ) {
$xtpl->assign("CUSTOMVIEWID","");
}else{
$xtpl->assign("CUSTOMVIEWID",$recordid);
}
..
and replace $xtpl->assign("VIEWNAME",$customviewdtls["viewname"]); with:
..
//if copy view is to be done
if( $copyview == 1 ) {
$xtpl->assign("VIEWNAME","");
}else{
$xtpl->assign("VIEWNAME",$customviewdtls["viewname"]);
}
..
FOR EVERY NEXT MODULE YOU MUST ADD/MODIFY LINES
Changing for ACCOUNTS
1. In file ../modules/Accounts/ListView.php replace $query with:
..
$list_query
..
.. i think this is default in all modules if not it should be
..in the same file replace and under if($viewid == 0) with else .. replace with:
..
if($viewid == 0)
{
$cvHTML = '<span class="bodyText disabled">'.$app_strings['LNK_CV_EDIT'].'</span>
<span class="sep">|</span>
<span class="bodyText disabled">'.$app_strings['LNK_CV_DELETE'].'</span><span class="sep">|</span>
<a href="index.php?module=Accounts&action=CustomView" class="link">'.$app_strings['LNK_CV_CREATEVIEW'].'</a>';
}else
{
/**
*
* Get default CustomView settings 'owner' and user type 'is_admin'
*
*/
$cv_sql = "select * from customviewsettings where cvid = ".$viewid.";";
$cv_res = $adb->query($cv_sql);
if( $cv_array = $adb->fetch_array($cv_res) ) {
$cv_owner = $cv_array['owner'];
}
$cv_sql = "select * from users where user_name = '".$current_user->user_name."';";
$cv_res = $adb->query($cv_sql);
if( $cv_array = $adb->fetch_array($cv_res) ) {
$cv_viewer_is_admin = $cv_array['is_admin'];
}
/* end */
$cvHTML = '<a href="index.php?module=Accounts&action=CustomView&record='.$viewid.'" class="link">'.$app_strings['LNK_CV_EDIT'].'</a>
<span class="sep">|</span>
<a href="index.php?module=CustomView&action=Delete&dmodule=Accounts&record='.$viewid.'" onclick="if (window.confirm("'.$app_strings['LNK_CV_DELETECONFIRM'].'")) {window.location="index.php?module=CustomView&action=Delete&dmodule=Accounts&record='.$viewid.'"; return(false) } else {return(false)}" class="link">'.$app_strings['LNK_CV_DELETE'].'</a>
<span class="sep">|</span>
<a href="index.php?module=Accounts&action=CustomView" class="link">'.$app_strings['LNK_CV_CREATEVIEW'].'</a>';
if( $cv_owner == $current_user->user_name || $cv_viewer_is_admin == "on" ) {
$cvHTML = '<a href="index.php?module=Accounts&action=CustomView&record='.$viewid.'" class="link">'.$app_strings['LNK_CV_EDIT'].'</a>
<span class="sep">|</span>
<a href="index.php?module=CustomView&action=Delete&dmodule=Accounts&record='.$viewid.'" onclick="if (window.confirm("'.$app_strings['LNK_CV_DELETECONFIRM'].'")) {window.location="index.php?module=CustomView&action=Delete&dmodule=Accounts&record='.$viewid.'"; return(false) } else {return(false)}" class="link">'.$app_strings['LNK_CV_DELETE'].'</a>
<span class="sep">|</span>
<a href="index.php?module=Accounts&action=CustomView" class="link">'.$app_strings['LNK_CV_CREATEVIEW'].'</a>';
}else{
$cvHTML = '<span class="bodyText disabled">'.$app_strings['LNK_CV_EDIT'].'</span>
<span class="sep">|</span>
<span class="bodyText disabled">'.$app_strings['LNK_CV_DELETE'].'</span>
<span class="sep">|</span>
<a href="index.php?module=Accounts&action=CustomView" class="link">'.$app_strings['LNK_CV_CREATEVIEW'].'</a>';
}
$cvHTML .= '<span class="sep">|</span>
<a href="index.php?module=Accounts&action=CustomView&record='.$viewid.'&CopyView=1" class="link">'.$app_strings['LNK_CV_CREATECOPY'].'</a>';
}
..
..replace if(isset($order_by) && $order_by != '') with else .. with lines:
..
if(isset($order_by) && $order_by != '')
{
$list_query .= ' ORDER BY '.$order_by.' '.$sorder;
}else{
/**
*
* Get default CustomView settings for the 'order_by' and 'sorder' and 'public'
*
*/
$cv_sql = "select * from customviewsettings where cvid = ".$viewid.";";
$cv_res = $adb->query($cv_sql);
$order_by = '1';
$sorder = 'ASC';
$publicview = 0;
if( $cv_array = $adb->fetch_array($cv_res) ) {
$order_by_array = explode( ":", $cv_array['orderby'] );
$order_by = $order_by_array[1];
$sorder = $cv_array['sorder'];
$publicview = $cv_array['publicview'];
}
$list_query .= ' ORDER BY '.$order_by.' '.$sorder;
/* end */
}
..
THAT'S ALL
Yes it is messy but it works.
Some day patch will be available, til then.
A |
|
| Back to top |
|
ales
Joined: 13 Jun 2006
Posts: 18
Location: Slovenia
|
| Posted: Thu Jul 27, 2006 5:17 pm Post subject: Custom View 4.2.x |
|
|
1. Set default sort field for CV
2. Checkbox field for other can view CV or not
3. Admin sees/can edit all CV
4. Copy from existing CV
Here is copy-paste code from files
a) First you must create table needed for feature to work
DROP TABLE IF EXISTS `customviewsettings`;
CREATE TABLE `customviewsettings` (
`cvid` int(19) unsigned NOT NULL default '0',
`orderby` varchar(255) default NULL,
`sorder` varchar(45) NOT NULL default 'ASC',
`owner` varchar(45) NOT NULL default '',
`publicview` tinyint(3) unsigned NOT NULL default '0',
PRIMARY KEY (`cvid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
b) In file ../modules/CustomView/EditView.html where {CHECKED} and {MCHECKED} is replaye lines with (for new check box Public View):
..
<td class='dataLabel'></td>
<td>
<input class='textField' {CHECKED} type='checkbox' name='setDefault' value="">{MOD.LBL_SETDEFAULT}
</td>
<td width="35%">
<input class='textField' {MCHECKED} type='checkbox' name='setMetrics' value="">{MOD.LBL_LIST_IN_METRICS}
</td>
<td>
<input class='textField' {CVPCHECKED} type='checkbox' name='setPublic' value="">{MOD.LBL_SETPUBLIC}
</td>
..
c) Ad to file ../modules/CustomView/language/en_us.lang.php at the end of the file (for labels):
..
'LBL_SETPUBLIC'=>'Public View',
'LBL_SORTBY'=>'Sort by field',
'LBL_SORDER'=>'Sort order',
..
d) In file ../modules/CustomView/EditView.php add under if($recordid == "") after //step4 next lines:
..
//step5
//order by fields
$xtpl->assign("CVORDERBY",$choosecolhtml);
//set sort order
$sorder_html = "<option value='ASC' selected>ASC</option><option value='DESC'>DESC</option>";
$xtpl->assign("CVSORDER",$sorder_html);
..
e) In file ../modules/CustomView/EditView.php add after $xtpl->assign("VIEWNAME",$customviewdtls["viewname"]); next lines (for get data from database):
..
/**
*
* Get default CustomView settings for the 'order_by' , 'sorder' , 'owner' and 'public'
*
*/
$customviewsettings = $oCustomView->getCustomViewSettingsByCvid($recordid);
$vtlog->logthis('CustomView :: Successfully got ViewSettingsDetails for the Viewid'.$recordid,'info');
//default if no record is returned
$order_by = '1';
$sorder = 'ASC';
$publicview = 0;
$owner = '';
if( $customviewsettings["cvid"] ) {
$order_by = $customviewsettings["orderby"];
$sorder = $customviewsettings["sorder"];
$owner = $customviewsettings["owner"];
$publicview = $customviewsettings["publicview"];
}
/* end */
..
f) In the same file as above add after if($customviewdtls["publicview"] == 1) similar if after public view (for template assign):
..
//public view
if($publicview == 1)
{
$xtpl->assign("CVPCHECKED","checked");
}
..
g) Add in the same file as above after for($i=1;$i<10;$i++) {} .. next lines (for setting the right order by and sort order and template assign):
..
//set order by
if( isset($order_by) ) {
$choosecolhtml = getByModule_ColumnsHTML($cv_module,$modulecollist,$order_by);
}else{
$choosecolhtml = getByModule_ColumnsHTML($cv_module,$modulecollist,$selectedcolumnslist[1]);
}
$xtpl->assign("CVORDERBY",$choosecolhtml);
//set sort order
if( $sorder == "ASC" ) {
$sorder_html = "<option value='ASC' selected>ASC</option><option value='DESC'>DESC</option>";
}else{
$sorder_html = "<option value='ASC'>ASC</option><option value='DESC' selected>DESC</option>";
}
$xtpl->assign("CVSORDER",$sorder_html);
..
h) Add to file ../modules/CustomView/CustomView.php public property and new function:
..
var $customviewsettings = Array("cvid"=>0,"OrderBy"=>"","SOrder"=>"","Owner"=>"","PublicView"=>"");
..
function getCustomViewSettingsByCvid($cvid)
{
global $adb;
$ssql = "select * from customviewsettings";
$ssql .= " where cvid=".$cvid;
$result = $adb->query($ssql);
while($cvrow=$adb->fetch_array($result))
{
$customviewsettings["cvid"] = $cvrow["cvid"];
$customviewsettings["orderby"] = $cvrow["orderby"];
$customviewsettings["sorder"] = $cvrow["sorder"];
$customviewsettings["owner"] = $cvrow["owner"];
$customviewsettings["publicview"] = $cvrow["publicview"];
}
return $customviewsettings;
}
..
i) Add to file ../modules/CustomView/Save.php under if($cvmodule != "") after if(isset($_REQUEST["setMetrics"])) next lines (for save new data):
..
//custom view settings
if(isset($_REQUEST["orderby"]))
{
$orderby = $_REQUEST["orderby"];
}else
{
$orderby = "";
}
if(isset($_REQUEST["sorder"]))
{
$sorder = $_REQUEST["sorder"];
}else
{
$sorder = "";
}
if(isset($_REQUEST["setPublic"]))
{
$setpublic = 1;
}else
{
$setpublic = 0;
}
..
j) In the same file as above ad under if($cvid == "") after $cvid = $genCVid; } next lines (for save):
..
$cv_sql = "insert into customviewsettings (cvid,orderby,sorder,owner,publicview) values (";
$cv_sql .= $genCVid.",'".$orderby."','".$sorder."','".$current_user->user_name."',".$setpublic.");";
$cv_res = $adb->query($cv_sql);
$vtlog->logthis("CustomView :: Save :: cvviewsettings created successfully","info");
..
and under else after $vtlog->logthis("CustomView :: Save :: cvadvfilter update successfully".$genCVid,"info"); } } add next lines:
..
$cv_sql = "update customviewsettings set";
$cv_sql .= " orderby='".$orderby."',sorder='".$sorder."',owner='".$current_user->user_name."',publicview=".$setpublic;
$cv_sql .= " where cvid = ".$genCVid;
$cv_res = $adb->query($cv_sql);
$vtlog->logthis("CustomView :: Save :: cvviewsettings created successfully","info");
..
k) In file ../modules/CustomView/Delete.php ad under if(isset($cvid) && $cvid != '') next lines (for delete):
..
$cv_sql = "delete from customviewsettings where cvid =".$cvid;
$cv_result = $adb->query($deletesql);
..
l) In file ../modules/Activities/ListView.php under if($viewid == 0) and under else add next lines (for in module to CV maintenance):
..
/**
*
* Get default CustomView settings 'owner' and user type 'is_admin'
*
*/
$cv_sql = "select * from customviewsettings where cvid = ".$viewid.";";
$cv_res = $adb->query($cv_sql);
if( $cv_array = $adb->fetch_array($cv_res) ) {
$cv_owner = $cv_array['owner'];
}
$cv_sql = "select * from users where user_name = '".$current_user->user_name."';";
$cv_res = $adb->query($cv_sql);
if( $cv_array = $adb->fetch_array($cv_res) ) {
$cv_viewer_is_admin = $cv_array['is_admin'];
}
/* end */
..
and to the end of else ..} replace lines with:
..
if( $cv_owner == $current_user->user_name || $cv_viewer_is_admin == "on" ) {
$cvHTML = '<a href="index.php?module=Activities&action=CustomView&record='.$viewid.'" class="link">'.$app_strings['LNK_CV_EDIT'].'</a>
<span class="sep">|</span>
<a href="index.php?module=CustomView&action=Delete&dmodule=Activities&record='.$viewid.'" onclick="if (window.confirm("'.$app_strings['LNK_CV_DELETECONFIRM'].'")) {window.location="index.php?module=CustomView&action=Delete&dmodule=Activities&record='.$viewid.'"; return(false) } else {return(false)}" class="link">'.$app_strings['LNK_CV_DELETE'].'</a>
<span class="sep">|</span>
<a href="index.php?module=Activities&action=CustomView" class="link">'.$app_strings['LNK_CV_CREATEVIEW'].'</a>';
}else{
$cvHTML = '<span class="bodyText disabled">'.$app_strings['LNK_CV_EDIT'].'</span>
<span class="sep">|</span>
<span class="bodyText disabled">'.$app_strings['LNK_CV_DELETE'].'</span>
<span class="sep">|</span>
<a href="index.php?module=Activities&action=CustomView" class="link">'.$app_strings['LNK_CV_CREATEVIEW'].'</a>';
}
..
and by the if(isset($order_by) && $order_by != '') replace all under {..}else{..} with lines:
..
if(isset($order_by) && $order_by != '')
{
$list_query .= ' ORDER BY '.$order_by.' '.$sorder;
}else{
/**
*
* Get default CustomView settings for the 'order_by' and 'sorder' and 'public'
*
*/
$cv_sql = "select * from customviewsettings where cvid = ".$viewid.";";
$cv_res = $adb->query($cv_sql);
$order_by = '1';
$sorder = 'ASC';
$publicview = 0;
if( $cv_array = $adb->fetch_array($cv_res) ) {
$order_by_array = explode( ":", $cv_array['orderby'] );
$order_by = $order_by_array[1];
$sorder = $cv_array['sorder'];
$publicview = $cv_array['publicview'];
}
$list_query .= ' ORDER BY '.$order_by.' '.$sorder;
/* end */
}
..
m) In file ../include/language/eu_en.lang.php you add after 'LNK_CV_CREATEVIEW'=>'Create View' add new line (for label):
..
'LNK_CV_CREATECOPY'=>'Copy View',
..
n) In file ../modules/CustomView/EditView.php add after $recordid = $_REQUEST['record']; next lines:
..
//if copy view is to be done
if( isset($_REQUEST['CopyView']) ) {
$copyview = $_REQUEST['CopyView'];
}else{
$copyview = "";
}
..
and replace $xtpl->assign("CUSTOMVIEWID",$recordid); with:
..
//if copy view is to be done
if( $copyview == 1 ) {
$xtpl->assign("CUSTOMVIEWID","");
}else{
$xtpl->assign("CUSTOMVIEWID",$recordid);
}
..
and replace $xtpl->assign("VIEWNAME",$customviewdtls["viewname"]); with:
..
//if copy view is to be done
if( $copyview == 1 ) {
$xtpl->assign("VIEWNAME","");
}else{
$xtpl->assign("VIEWNAME",$customviewdtls["viewname"]);
}
..
FOR EVERY NEXT MODULE YOU MUST ADD/MODIFY LINES
Changing for ACCOUNTS
1. In file ../modules/Accounts/ListView.php replace $query with:
..
$list_query
..
.. i think this is default in all modules if not it should be
..in the same file replace and under if($viewid == 0) with else .. replace with:
..
if($viewid == 0)
{
$cvHTML = '<span class="bodyText disabled">'.$app_strings['LNK_CV_EDIT'].'</span>
<span class="sep">|</span>
<span class="bodyText disabled">'.$app_strings['LNK_CV_DELETE'].'</span><span class="sep">|</span>
<a href="index.php?module=Accounts&action=CustomView" class="link">'.$app_strings['LNK_CV_CREATEVIEW'].'</a>';
}else
{
/**
*
* Get default CustomView settings 'owner' and user type 'is_admin'
*
*/
$cv_sql = "select * from customviewsettings where cvid = ".$viewid.";";
$cv_res = $adb->query($cv_sql);
if( $cv_array = $adb->fetch_array($cv_res) ) {
$cv_owner = $cv_array['owner'];
}
$cv_sql = "select * from users where user_name = '".$current_user->user_name."';";
$cv_res = $adb->query($cv_sql);
if( $cv_array = $adb->fetch_array($cv_res) ) {
$cv_viewer_is_admin = $cv_array['is_admin'];
}
/* end */
$cvHTML = '<a href="index.php?module=Accounts&action=CustomView&record='.$viewid.'" class="link">'.$app_strings['LNK_CV_EDIT'].'</a>
<span class="sep">|</span>
<a href="index.php?module=CustomView&action=Delete&dmodule=Accounts&record='.$viewid.'" onclick="if (window.confirm("'.$app_strings['LNK_CV_DELETECONFIRM'].'")) {window.location="index.php?module=CustomView&action=Delete&dmodule=Accounts&record='.$viewid.'"; return(false) } else {return(false)}" class="link">'.$app_strings['LNK_CV_DELETE'].'</a>
<span class="sep">|</span>
<a href="index.php?module=Accounts&action=CustomView" class="link">'.$app_strings['LNK_CV_CREATEVIEW'].'</a>';
if( $cv_owner == $current_user->user_name || $cv_viewer_is_admin == "on" ) {
$cvHTML = '<a href="index.php?module=Accounts&action=CustomView&record='.$viewid.'" class="link">'.$app_strings['LNK_CV_EDIT'].'</a>
<span class="sep">|</span>
<a href="index.php?module=CustomView&action=Delete&dmodule=Accounts&record='.$viewid.'" onclick="if (window.confirm("'.$app_strings['LNK_CV_DELETECONFIRM'].'")) {window.location="index.php?module=CustomView&action=Delete&dmodule=Accounts&record='.$viewid.'"; return(false) } else {return(false)}" class="link">'.$app_strings['LNK_CV_DELETE'].'</a>
<span class="sep">|</span>
<a href="index.php?module=Accounts&action=CustomView" class="link">'.$app_strings['LNK_CV_CREATEVIEW'].'</a>';
}else{
$cvHTML = '<span class="bodyText disabled">'.$app_strings['LNK_CV_EDIT'].'</span>
<span class="sep">|</span>
<span class="bodyText disabled">'.$app_strings['LNK_CV_DELETE'].'</span>
<span class="sep">|</span>
<a href="index.php?module=Accounts&action=CustomView" class="link">'.$app_strings['LNK_CV_CREATEVIEW'].'</a>';
}
$cvHTML .= '<span class="sep">|</span>
<a href="index.php?module=Accounts&action=CustomView&record='.$viewid.'&CopyView=1" class="link">'.$app_strings['LNK_CV_CREATECOPY'].'</a>';
}
..
..replace if(isset($order_by) && $order_by != '') with else .. with lines:
..
if(isset($order_by) && $order_by != '')
{
$list_query .= ' ORDER BY '.$order_by.' '.$sorder;
}else{
/**
*
* Get default CustomView settings for the 'order_by' and 'sorder' and 'public'
*
*/
$cv_sql = "select * from customviewsettings where cvid = ".$viewid.";";
$cv_res = $adb->query($cv_sql);
$order_by = '1';
$sorder = 'ASC';
$publicview = 0;
if( $cv_array = $adb->fetch_array($cv_res) ) {
$order_by_array = explode( ":", $cv_array['orderby'] );
$order_by = $order_by_array[1];
$sorder = $cv_array['sorder'];
$publicview = $cv_array['publicview'];
}
$list_query .= ' ORDER BY '.$order_by.' '.$sorder;
/* end */
}
..
THAT'S ALL
Suggestion: if you plan to do integrate this feature do the CustomView module first and then just go to first prefered module, it is quite simple you'll see.
Yes it is messy but it works.
Some day patch will be available, til then.
Ales |
|
| Back to top |
|
ales
Joined: 13 Jun 2006
Posts: 18
Location: Slovenia
|
| Posted: Thu Jul 27, 2006 5:22 pm Post subject: Custom View 4.2.x |
|
|
Hi all, sorry for last post I was editing and forgot that forum has no delete my own message ?!
If MODERATOR is near by can you please delete first post not seccond, because it is updatet from first.
By Ales |
|
| Back to top |
|
Bushwack
Joined: 23 Aug 2005
Posts: 236
|
| Posted: Fri Jul 28, 2006 3:27 pm Post subject: Custom View 4.2.x |
|
|
Thanks Ales,
I look forward to seeing a patch file. |
|
| Back to top |
|
| |
|