The following warnings occurred:
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
File Line Function
/global.php 783 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
File Line Function
/global.php 783 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined variable $newpmmsg - Line: 40 - File: global.php(841) : eval()'d code PHP 8.1.31 (Linux)
File Line Function
/global.php(841) : eval()'d code 40 errorHandler->error
/global.php 841 eval
/printthread.php 16 require_once
Warning [2] Undefined array key "style" - Line: 909 - File: global.php PHP 8.1.31 (Linux)
File Line Function
/global.php 909 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined property: MyLanguage::$lang_select_default - Line: 5024 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 5024 errorHandler->error
/global.php 909 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions.php 5044 is_member
/global.php 909 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1370 fetch_forum_permissions
/printthread.php 76 forum_permissions
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error



Form Tools
Can I Programmatically Create a New View? - Printable Version

+- Form Tools (https://forums.formtools.org)
+-- Forum: Form Tools (https://forums.formtools.org/forumdisplay.php?fid=1)
+--- Forum: General Discussion (https://forums.formtools.org/forumdisplay.php?fid=5)
+--- Thread: Can I Programmatically Create a New View? (/showthread.php?tid=1555)



Can I Programmatically Create a New View? - russellfeeed - Aug 23rd, 2011

Hi

I'd like to create a client account using ft_api_create_client_account(), but then I'd like to give them their own view, with a filter specific to them.

Each client would be looking into the same form, but they can only see some submission, as specified by the filter.

I'm not sure how I'd go about creating the view and associating it with a client.

In global/code/views.php, there is
function ft_create_new_view($form_id, $create_from_view_id = "")
which looks like it will create the view base on another view, which is what I need, but this isn't exposed in the API.

Then function _ft_update_view_filter_settings($view_id, $info) looks like it'll be useful for setting my filter. I'd need to work out the format of $info but it looks like is should be something like...
$info["form_id"] = 27;
$info["standard_filter_1_field_id"] = 'myfieldname';
$info["standard_filter_1_operator"] = 'equals'
$info["standard_filter_1_filter_values"] = 'stringtomatch';

But again, this is not exposed in the API.

I've sort of reached a dead end with how to assign a view to a client.

Any pointers?

Thanks
Russell


RE: Can I Programmatically Create a New View? - Ben - Aug 23rd, 2011

Hey Russell,

Quote:...but this isn't exposed in the API.

No, but I wouldn't worry too much in this case. The API mostly just contains functions that are for common use; I didn't think people would need this function - go right ahead and use it, I doubt it will be changing for a long, long time.

For the filter settings function, that's fine too; however, that's more likely to change. That's the problem with referencing core functions: there's no guarantee they won't change. I wish I could, but I can't!

For assigning a View to a client, all you need is for (a) the View to have Public / Private access type and (b) to insert a brand new row in the ft_client_views table (account_id, view_id). You might want to just write a separate function to handle that, rather than using any of the Core code.

Good luck! Let me know how it goes.

- Ben


RE: Can I Programmatically Create a New View? - russellfeeed - Aug 24th, 2011

Thanks for the pointers Ben.
Hopefully I'll be able to try this next week.

Cheers
Russell