 |
| << | February 2010 | >> |
| Su |
Mo |
Tu |
We |
Th |
Fr |
Sa |
| |
1 |
2 |
3 |
4 |
5 |
6 |
| 7 |
8 |
9 |
10 |
11 |
12 |
13 |
| 14 |
15 |
16 |
17 |
18 |
19 |
20 |
| 21 |
22 |
23 |
24 |
25 |
26 |
27 |
| 28 |
|
|
|
|
|
 |
 |
|
|
sumanrs Post subject: Variables in custom views
|
Fri Apr 11, 2008 7:30 pm Posts: 5 Location: New York, USA
|
| |
|
Hi,
I've been looking at enhancing custom views using variables. For example, allowing a view called "My Leads" in leads in which the "Assigned To" field can be set to a variable called CURRENTUSER, and anyone who chooses this custom view will see the leads belonging only to him or her.
I notice that this blog post Customizing vTiger custom views with dynamic “variables” - II is what I need.
However, it appears that the variable sometimes works and sometimes does not. Does anyone know why it seems to work sometimes and not at other times?
Thanks,
SRS
|
|
|
|
|
 |
prasad.a Post subject: Variables in custom views<br /><a href="viewto Senior Member
|
Fri Apr 11, 2008 7:50 pm Posts: 1586
|
| |
|
Hi sumanrs,
$current_user is set in index.php. If it is being used in anyother files, preferably it should be declared first as
| Code: | | global $current_user |
Regards,
Prasad
vtiger Team
|
|
|
|
sumanrs Post subject: Re: Variables in custom views
|
Sat Apr 12, 2008 5:17 pm Posts: 5 Location: New York, USA
|
| |
|
Hi Prasad,
Thanks a lot - I was indeed using that, but that didn't work using the "hack" I was using for the Custom Views.
I found out the reason - the SQL being generated for the username is actually being taken from the function getRealValues() in the same file (/modules/CustomView/CustomView.php), so I made one additional change to get the current user variable to work (changes inbetween comments that say HACK):
| Code: |
function getRealValues($tablename,$fieldname,$comparator,$value,$datatype)
{
if($fieldname == "smownerid" || $fieldname == "inventorymanager")
{
/* HACK - to get current user */
global $current_user;
if ($value == "CURRENTUSER")
$value = $current_user->user_name;
/* End HACK */
$value = $tablename.".".$fieldname.$this->getAdvComparator($comparator,getUserId_Ol($value),$datatype);
}else if($fieldname == "parentid")
|
|
|
|
|
prasad.a Post subject: Re: Variables in custom views Senior Member
|
Sat Apr 12, 2008 5:26 pm Posts: 1586
|
| |
|
Hi sumanrs,
Thank you for sharing the details.
Would be nice if you can update the author about the same.
Regards,
Prasad
vtiger Team
|
|
|
|
|
|
| |