I have a view and I want to get it's results.
$nview = views_get_view('tasks');
$nview->set_display('page');
$nview->pre_execute();
$nview->execute();
If I have 'nid' filter added to my view, I can modify it and get my view filtered.
$nview = views_get_view('tasks');
$nview->set_display('page');
$nview->pre_execute();
$nview->display['page']->handler->handlers['filter']['nid']->value['value']=180;
$nview->display['page']->handler->handlers['filter']['nid']->operator='=';
$nview->execute();
But what do I need write to add a filter if no filter present in view settings of my view?
$nview = views_get_view('tasks');
$nview->set_display('page');
$nview->pre_execute();
//some code here
$nview->execute();
UPD: Unfortunately, I can't use hook_views_query_alter because I need to use my code in my custom function which accepts view's name as an argument. My target is to alter any view which name passed as an argument to my custom function. So I need to alter filter/query only if I need get view's result and the view executes from my function. But if the view executes from it's page or block it needs to be executed without altering.