vtiger.com - Home of vtiger CRM
Home Products Downloads Support Buy Support Partners Company  Community Forums Blogs   Extensions  
Call Us : +1 408-733-3229
 
Log in

Register | Forgot password ?
<<September 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 29 30

 Search this forum

SourceForge.net Logo


Variables in custom views Bug Tracker | Installation | Webmail
Post new topic   Reply to topic  Forum Home -> Help - 5.0.2 Previous topic :: Next topic

Post  sumanrs   Post subject: Variables in custom views
     
Fri Apr 11, 2008 7:30 pm 
Posts: 5 
Location: New York, USA 
  Reply with quote
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. Sad Does anyone know why it seems to work sometimes and not at other times?

Thanks,
SRS

    View user's profile Send private message

Post  prasad.a   Post subject: Variables in custom views<br /><a href="viewto
     Senior Member
Fri Apr 11, 2008 7:50 pm 
Posts: 1690 
 
  Reply with quote
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

    View user's profile Send private message

Post  sumanrs   Post subject: Re: Variables in custom views
     
Sat Apr 12, 2008 5:17 pm 
Posts: 5 
Location: New York, USA 
  Reply with quote
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")

    View user's profile Send private message

Post  prasad.a   Post subject: Re: Variables in custom views
     Senior Member
Sat Apr 12, 2008 5:26 pm 
Posts: 1690 
 
  Reply with quote
Hi sumanrs,

Thank you for sharing the details.

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

Regards,
Prasad
vtiger Team

    View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    vtiger Forum Index -> Help - 5.0.2 All times are GMT
Leave a Testimonial
Page 1 of 1

Jump to: