OpenSips Remove Header Value - sip

I'm new to OpenSips.
I have a requirement to remove a single value from header values.
Now it has
Allow: INVITE,REFER,ACK,NOTIFY
We need to remove REFER from Allow header and leave the rest
Expected Result
Allow: INVITE,ACK,NOTIFY
I have written custom logic to get the header value & remove REFER, then Remove entire header & add new header without REFER.
But, is there any predefined functions available to achieve above requirement?

Related

How to replace the user/contact form in Sulu?

I want to know how to change/replace the user/contact form in Sulu i.e. https://sulu.rocks/admin/#/contacts/1/details.
I want to remove the fields for Addresses, Bank accounts, etc.
I tried to copy the vendor/sulu/sulu/src/Sulu/Bundle/ContactBundle/Resources/config/forms/account_details.xml into config/forms and removed the unnecessary fields. But that not working.
I can't find something to this in the documentation or it's hidden :D
If you add a form with the exact same key as the form you want to override, the contents of both forms are merged. In your case, the key would be contact_details. Now you can add completely new properties to the form or override existing ones by just creating a property with the same name. If you want to hide a property, you have to override it and set visibleCondition="false".
You can also have a look at this example pull request.

How to set a custom header using phpmailer

I am using phpmailer for sending emails, but I want to make a custom header for my company, by adding a textarea field that contain any custom header for example using a header like this one:
exemple of header
or any other header types..
How can I do this , thanks in advance.
You will need to do some discovery and modification of the default headers set by PHPmailer for this to be achieved.
You will need to use different functions to set/edit headers depending on the type of header you want to set/edit. Here are a few examples:
From:
$mail->setFrom('from#example.com', 'Mailer');
Subject:
$mail->Subject = 'Here is the subject';
Custom:
$mail->addCustomHeader('X-custom-header', 'custom-value');
In short, It is quite an effort to do this when the headers are free-typed in a text box. It is however doable with detection and validation on your side.

AEM/CQ - Sling script resolution - what script to use?

We have requirement wherein we are required to create some URLs that will be using selectors. The URL that we use currently is
<company>/<domain>/home.html
In addition to the above URL we will be having three more URLs of type:
URL 1 - <company>/<domain>/home.<brand>.html
There can be three possible values of brand. Let's say A, B and C.
Now the template (sling:resourceType --> /apps/components/page/basepage) that <company>/<domain>/home.html uses has sling:resourceSuperType set as foundation/components/page.
/apps/components/page/basepage has only body.jsp.
The body.jsp includes components like footer and header using cq:include. Depending upon the selector used in the URL, some minor changes have to be reflected in the footer and header. Like header image and some text in the footer.
How can I achieve this ?
Thanks in advance
The solution is pretty simple. All we need to do is include the scripts A.jsp, B.jsp and C.jsp under the component nodes. So, that means under the footer and header component nodes. There will be three more jsps now.

GTM Reduce number of tags

GTM up and running, main UA tag in place along with a ClickListener tag.
To reduce the number of macros, i use dataLayer variable Macros for event category, action, label, value & interaction, so they can be used for many rules and tags.
So i want to collect data from one link/button (Add to Fav), i add a rule to listen for the click using {{event}} equals gtm.click and {{Event Label}} equals Add_to_Fav (the label i push to the DL via onclick.
All good so far, but i need to create another UA tag (Track Type - event) that fires on the rule made previously. And this is my question, using this method seems to create many tags. If i have another 20 links that i want to collect data from, do i need to keep creating tags like this. Surely, this will affect page load speed with many tags firing on all pages.
Hope thats all clear.
If you need to retrieve the link text to use it as an event label you do not need many many event tracking tags, that would be horribly verbose. Instead you can use a custom javascript macro - the cool thing about them being that you can use existing macros inside your custom function.
If you create a click listener or link click listener this will create a few macros - one of them is {{element}}, which is the DOM element that received a click.
Now you create a macro of the type "custom java script", which must contain an anonymous function with a return value.
The barebones version of a function that retrieves the text of a clicked link would be
function() {
var el = {{element}};
return el.innerText;
}
(actually you do not need the variable assigment, you could use {{element}}.innerText directly).
You name the macro e.g. Linktext and use the macro {{Linktext}} in your single event tracking tag where it will dynamically be set to the value of the text of the clicked link (although you might want to check cross browser support for innerText, or maybe use innerHTML instead which serves in you use case probably the same purpose).

Zend form change elements required options to false at runtime

I have a form and having two file upload elements. it is like
$data_file_one = $this->createElement('file','data_file_one');
$data_file_one->setRequired(true)
->addValidator('Extension', false, 'csv')
->setDestination($filepath);
Both are set to required true. I use the same form for new post and edit posts. When it is used for editing the file upload should not be mandatory and must be set to required false. So, I need to change
setRequired(true) to setRequired(false)
How can I do when edit action is called to load form and change this element option?
Thanks in advance.
Zend_Forms have a method called getElement that allow you to retrieve an element from a form by its name. This gives you the ability to modify an element's default value before rendering it to the user.
For example, to change a field from being required to being optional, you can do the following:
$form->getElement('data_file_one')->setRequired(false);