vtiger Forum Index vtiger
The Honest Open Source CRM
 

Variables in custom views
Click here to go to the original topic

 
       vtiger Forum Index -> Help - 5.0.2
Previous topic :: Next topic  
Author Message
sumanrs



Joined: 29 May 2006
Posts: 5
Location: New York, USA

Posted: Fri Apr 11, 2008 7:30 pm    Post subject: Variables in custom views  

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 Code: $current_user variable sometimes works and sometimes does not. :( Does anyone know why it seems to work sometimes and not at other times?

Thanks,
SRS
Back to top  
prasad.a



Joined: 01 Aug 2007
Posts: 968

Posted: Fri Apr 11, 2008 7:50 pm    Post subject: Variables in custom views<br /><a href="viewto  

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
Back to top  
sumanrs



Joined: 29 May 2006
Posts: 5
Location: New York, USA

Posted: Sat Apr 12, 2008 5:17 pm    Post subject: Re: Variables in custom views  

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")
Back to top  
prasad.a



Joined: 01 Aug 2007
Posts: 968

Posted: Sat Apr 12, 2008 5:26 pm    Post subject: Re: Variables in custom views  

Hi sumanrs,

Thank you for sharing the details.

Would be nice if you can update the author about the same.

Regards,
Prasad
vtiger Team
Back to top  
 
       vtiger Forum Index -> Help - 5.0.2
Page 1 of 1


Powered by phpBB Search Engine Indexer
Powered by phpBB 2.0.15 © 2001, 2002 phpBB Group