Expression engine: Maximum number of entries allowed per membrr group - expressionengine

Is it possible to limit the number of channel entries a member can create?
I would like to set a max number per member group.
Thanks

Yes, but it would require writing an extension. The logic would be something like this (assuming you're talking about limiting on the back-end ... from the front-end, if you're using a Safecracker entry form for example, you'd need to take a different approach):
use the sessions_end hook
check to make sure you're in the control panel ($this->EE->input->get('D') == 'cp')
check to make sure you're on the publish screen ($this->EE->input->get('C') ==
'content_publish')
query the database to see how many entries in exp_channel_titles with the channel_id of $this->EE->input->get('channel_id') belong to $this->EE->session->userdata('member_id')
if the result is greater than your allowed maximum, show them an error
That should get you started.

Related

stripe how to set limit for the expandable objects

In stripe, we have the option to expand some of the child object when the property has the expandable option. And the expandable property is not shown by default. For example in customer object, we have the sources list which is not shown by default. But we need to expand it when retrieving the customer by adding the expand parameter - "sources" as below.
var customer = this.stripeService.getCustomer(stripeCustomerId(), List.of("sources", "default_source.card"));
Now since sources is a list it by defaults shows only 10 cards. But I wanted to limit that to more number say 20. How can we do this on the expandable property?
I Still did not find a way to set the limit but we can fetch all the items without the default limit of 10 using the following code. The key is autoPagingIterable that brings all the data without paging
var customer = this.stripeService.getCustomer(stripeCustomerId(), List.of("sources", "default_source.card"));
if(customer.getSources().getHasMore()){
List<PaymentSource> paymentSources = new ArrayList<>();
customer.getSources().autoPagingIterable().forEach(paymentSource -> {
paymentSources.add(paymentSource);
});
customer.getSources().setData(paymentSources);
customer.getSources().setHasMore(false);
customer.getSources().setUrl(null);
}
Reference -> https://stackoverflow.com/a/64173387/12752873
The autoPagingIterable is the right approach but it's best to be used on the correct API endpoint.
From Stripe's docs:
The sources property on Customers is no longer included by default. You can expand the list but for performance reasons we recommended against doing so unless needed.
If you want to get a customer’s sources you should call the separate endpoint.

Passing More than 1000 parameters in RESTful api

Our Dashboard have dropdown which consist of more than 8k products and we have such 4-5 dropdowns.
I want to filter data based on this dropdowns.
But if I selecting all products then restful api url is breaking.
Can i use azure bus service or similar message broker service to pass this complex and multiple parameters via service and which then consumed by all apis??
While I do understand what your need is I will suggest to re-think your approach as that will lead to a better user experience.
I will use a first drop down, completely empty, that will fill in options while the user types in whatever product list you have, that way, there is only a group of items that are filled in that the user is interested in.
I will also suggest not to load anything on that drop down until the user has entered, let's say, 5 characters.
After that let the user select an item from the dropdown, and filter the second drop down and continue to use the same technique with all drop downs you have.
Let me know if you have any questions around this approach and I will be more than happy to provide an example if you don't know how to do it.
Edit:
Including samples for load dropdown lists dynamically and also another post with an example on how to return some JSON from an Azure Function that can return the data in a dynamic way like you need.
From what I can see I think it'll be helpful for you to go through several different examples that can bring you progressive knowledge to what you need to achieve, first of all it'll be nice if you know how to load items dynamically on a dropdown list:
That is a nice example, you can have an entry where the user can type
whatever products you have and then they type, lets say, more than 5
characters go and search for that data.
https://www.codebyamir.com/blog/populate-a-select-dropdown-list-with-json
This other example shows you how to return data from an azure function
with the data that you need to show the users. This is not exactly
what you need as you need to receive a parameter with what the user
typed and search in your database for the items that match that search
and return that data in a JSON format so you can use it on your web
page to show the dropdown list. I will suggest to initially hard code
a few items and return those to check that the functionality is there
and once you have that up and running move to get the actual data from
the database.
How to return a JSON object from an Azure Function with Node.js

Kentico Event Calendars in multiple locations

I've been asked if the internal sales site i built can support multiple event calendars. What they would like is a calendar for each group and a global. So the global calendar will shows global and events from each group. The Group Calendars would only show their relevant events.
So i added folders to my Event node, and added some test pages. They show in the global event since it's path is ./%. Great.
For a group (Compliance), it's path is /events/compliance/%. This works, and the Compliance calendar only shows events in within the specified folder.
But.
Each event node's url is based on the global path so /event/compliance/event-1.aspx. This takes the user out of the group section and breaks the user flow. I'd like the group specific events to still apear with their URL stucture. So like this, /Our-Company/Compliance/Calendar-of-Events/event-1.aspx.
I could have the group specific events with their node, but then i loose all the vents on the global calendar. So is there a way for a single calendar to pull events from multiple locations within the tree?
You have a couple options:
Use linked pages. This would allow you to have a global location and simply have a "copy" in a different location (for navigation purposes really). Nice part is if update one of those linked pages, it updates them all so no worries about outdated content.
Categorize your events. Little more effort involved with this one but will work the same.
Set the WHERE statement to filter on the NodeAliasPath. You'd do something like this
Path = /%
Where = "NodeAliasPath LIKE '/GlobalEvents/%' OR NodeAliasPath LIKE '/Groups/Compliance/Events/%'"
3 is probably your best bet and if you want to make it more dynamic you can use macros in your where condition.
I agree with Brenden especially #2. #2 is going to give you the most flexibility and control over querying global items into multiple areas, but also gives you a single management location. We use that method on almost all of our projects and is both easy to manage but also easy to teach your content contributors how to use it the best.
The only other recommendation I would give is also include some kind of flag field where you can prioritize those items on a calendar list view. We often have a requirement that things do not only show up by date order, but also that certain calendar events take priority in sorting. Where you might not use that upfront, having that available down the road is some good forward thinking.

Clearing the "Group by" drop down on the Application Insights portal

I have a new Windows Application that I am adding Application Insights to. Adding a new chart gives the ability to Group on specific custom properties using a drop down. This drop down has 65 properties that AI must have added at some point. There were not specifically added.
We have a main AppInsights that takes all events. We've also created a AppInsight for development. The list of custom properties in the drop down is different between these two, even though the source code is the same.
It makes me suspect that there is some process that creates the drop down contents based on the incoming data.
The problem here is that the code has changed, and some properties are no longer available. We want to eliminate these values from the drop down, and add the new ones.
I am perfectly happy just deleting the entire list. Is there a way to do this?
The items that are available in the group by are properties that have ever been received by the back end in data you've sent, and aren't editable.
for custom properties/metrics, there's a limit on how many properties the backend will allow before it stops collecting new named custom properties. Conceptually, think of it as the backend storing an array of 200 elements for each telemetry item you sent, and mapping each custom property name to an index, and that mapping lasts forever. (i believe at the current time that limit is 200 each, but we're working on expanding that)
so if developers did things in your dev portal, even sent one item with custom property "foo", then that property will be there forever, and takes up one of those 200 slots. They can't be deleted or cleared at the moment.
Also, the contents of the group by box is also limited to events that have sent less than some threshold of distinct values, too. (I'm not sure on that exact value, but i believe it < 100 distinct values.) So fields like Id fields, or guids, etc, will eventually stop showing up as group by options, because the group by would create N distinct buckets of 1 item.
It seems like this would be something already mentioned in the App Insights UserVoice site, or documented in the azure documentation for group by but i'm not seeing it.
The only real workaround at this time is to create a new application insights resource in azure, and start submitting data to that new resource instead of your old one. And then you have to be proactive about never submitting custom properties that you're never going to use, or mixing case, as "Property1" and "property1" will be distinct properties...
If this is a big issue for you, i'd suggest submitting it to microsoft connect as a bug, or entering a uservoice suggestion above. I'll pass this on as something that really needs to be documented in the group by thing in the azure docs, too.

Using the search module to display entries based on custom fields

I have a profile weblog that contains all our users details (fields seperate from the membership).
These users can submit application forms with the use of a SAEF (stand alone entry form), which will be stored in an applications weblog. Inside this applications weblog, I have a relationship field which assigns a profile to an application.
Inside this application, radio buttons are contained to allow an admin to change the status of that application (an example, a judge views an application for Joe Bloggs and sets this application to “winner”).
What I essentially need to do is filter out all the profiles that have not been set to a number of status’. So if I apply for an application and the judge is yet to view this application, my profile should not appear in the search results. My idea of this is that I would somehow have to intertwine search results with a reverse related entry tag, and as my knowledge of the search module is limited I am at a complete loss if this is even possible.
As you can see, not only do I need to search by custom field, but the profiles that will be displayed should be determined on custom fields contained in the application entry.
I would suggest using the "status" option instead of the radio custom field.
Why? Because you can accomplish the same thing you want to do with the radio field and you can set what entries you want to return in your search results.
For example, you have a status group called: "Application", which is assigned to the that weblog/channel
Within the status group, you will have three options: Pending (waiting to be looked at), Loser (judge sets it to this because it is not a winner, or just as pending), Winner (judge considers that application a winner).
Then in the search tag, you would set what statuses it will return in the search results
so if you want to only return applications/profiles that were marked winner, you would set the status="status_id" (this will be the id of "Winner" status)

Resources