What i have :
Sugarcrm enterprise 6.5.14
I have set the inbound email to automatically generate cases under some conditions.
(it is set in Sugar's administration > Inbound email, it's native, i didn't write any code, juste setting it up).
I saw on /modules/InboundEmail/InboundEmail.php the function handleCreateCase() which i think (but please, confirm it) is used to generate cases.
What i want :
When a case is generated by an inbound email, the function handleCreateCase() is searching for contact ids and retrieves the good contact with this id :
snippet of handleCreateCases() :
if($contactIds = $this->getRelatedId($contactAddr, 'contacts')) {
if(!empty($contactIds) && $c->load_relationship('contacts')) {
$c->contacts->add($contactIds);
} // if
} // if
Now, i would like to add a "Else" condition : if there is no related contact, then create one.
My question is..
How do i code that? Could i customize the InboundEmail module? Will it be taken by Sugar?
Thanks a lot for your patience and your time.
Related
In WordPress, I have custom registration site for new users. Upon registration, there is an optional checkbox to subscribe to our newsletter. As far as I understand it, it adds the value of the checkbox to the user_meta table (the whole thing has been coded by a company in India, which I woould very much prefer to not involve again, since they delayed their work time and time again and didn't do good work after all).
The corresponding code snippet in my child theme's functions.php looks like this:
<?php echo '<div class="form-row form-row-wide">
<input type="checkbox" name="inter_offers" value="yes"> '; _e('I would like to subscribe to the Kurth Electronic newsletter.','kurth-child'); echo '<br></div>';
return $fields; ?>
add_action('woocommerce_created_customer','adding_extra_reg_fields');
function adding_extra_reg_fields($user_id) {
extract($_POST);
update_user_meta($user_id, 'billing_inter_offers',$inter_offers);
} ?>
(I have left out lines irrelevant to this issue.)
Now, this value is saved internally, but not displayed to me. I would like to show the value in an E-Mail or notification generated by WordPress when the user completes registration, so that we can manually add them to our newsletter list whenever someone chooses to subscribe to the newsletter. The problem is that I only have a limited knowledge of PHP and I don't know where to start.
I should also note that this is not done via the standard WorPress registration form, but by a WooCommerce registration form (I have disabled the standard WordPress registration for security reasons).
I tried using the "Better Notifications" plugin (https://wordpress.org/plugins/bnfw/) for custom notifications whenever a new user completes their registration, but it ignores any php code that I add to the custom notifications body to display the user_meta data.
Any help would be appreciated.
Because the registration is done via woocomerce you may have to look for a notification PlugIN that works with woocomerce, the one you have may just work properly with wordpress core version!
You also could generate a mail via php in the function, so that you get a message with the user mail adress, but i think without php knowledge it is not that easy to use the built in php mailer... (You may need an api there!)
But wouldn't it be better to automatically sign them into your newsletter software? For example for Mailchimp or other systems like that there are quite good wordpress plugins!
You may also be able to include the forms of these PlugIns in your registration form, but without a closer look at this woocomerce registration i can't tell for sure!
I think this will do the trick, it will notify you every time a new user is created and also tell you if they subscribed or not.
function new_customer_registered_send_email_admin($user_login, $user_email) {
ob_start();
do_action('woocommerce_email_header', 'New customer registered');
$email_header = ob_get_clean();
ob_start();
do_action('woocommerce_email_footer');
$email_footer = ob_get_clean();
$user = get_user_by( 'email', $user_email );
$subscribed = get_user_meta( $user->ID, 'billing_inter_offers', true );
woocommerce_mail(
get_bloginfo('admin_email'),
get_bloginfo('name').' - New customer registered',
$email_header.'<p>The user '.esc_html( $user_login ).' created an account ' . ( $subscribed ? ' and subscribed to the newsletter.' : '.' ) . '<br>Email:'.esc_html( $user_email ).'</p>'.$email_footer
);
}
add_action('new_customer_registered', 'new_customer_registered_send_email_admin', 10, 2);
I ended up using the plugin amr users to generate a userlist of all users who had a certain metadata tag set to a certain value (in my case, if they want to recieve a newsletter - the previous developers never bothered to make the data actually readable without extra effort). It is a little clunky to use and not what I originally intended, but it got the job done.
I am trying to add a Logic Hook for Emails synced from IMAP Mail server.
In the end i want trigger a hook when a new mail gets synced and check the senders mail if its saved in one of the accounts.
The problem is that the Synced Mails dont get saved (at least not in InboundMail or Emails module) so the after/before_save does not trigger.
Here is my hook from logic_hooks.php:
$hook_array['after_save'][] = Array(1, 'Create Lead', 'custom/modules/InboundEmail/LeadLogicHook.php', 'LeadLogicHook', 'handleLead');
It does not work in InboundEmail and Email Module.
And the LeadLogicHook:
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
class LeadLogicHook
{
function handleLead($bean, $event, $arguments)
{
_ppl("Test");
}
}
Is this even possible with logic hooks?
EDIT: Added some Code
No need for logic hook or any other custom code. Sugar/SuiteCRM use a scheduler job to fetch email from IMAP server. You can check scheduler job function (function::pollMonitoredInboxes) which fetch emails. That contain code which is used for email fetching. track back code and you will find everything you want.
What version of sugar are you using?
You can, for example, generate an after_save hook in the E-mail module instead of inboundEmail
Would be like this:
$hook_array ['after_save'] [] = Array (1,'Create Lead','custom/modules/Emails/LeadLogicHook.php','LeadLogicHook','handleLead');
Do this and see if the email fires!
Another possibility would be to use the after_relationship_add, because usually, the email is associated with some lead, account, or contact. try to create a hook in the module that your email is associating with and generate the operation from there
one last possibility (I do not recommend this) is to create a trigger in your database for when the data enters the table, perform the check and take some action
I think it's possible, if after/before_save not triggering then try some similar logic hooks. The following are some logic hooks that I think could help.
before_retrieve
after_retrieve
before_restore
after_restore
server_roundtrip
after_session_start
after_entry_point
Comment if you want more details, like how to use logic hooks e.t.c.
Hi guys I'm building a contacts application using the Zend Framework 1. I have a contacts table and a contact_data table.
Contact
|NAME|DESCRIPTION|...
CONTACT DATA
|TYPE|LOCATION|DETAILS|CONTACT_ID
ADDRESS
STREET|ZIP|CITY|STATE|COUNTRY|CONTACT_ID
The Contact Data holds all contact details such as Phone, Email, Fax etc and the address table is self explanatory. The trick is that I need to set it up so that I can add unlimited contact data and addresses. I've accomplished this earlier on by pretty much working on customised views however thats putting a lot of code logic within the view which I don't want. So I'm redoing it using Zend_Form but am stuck with regards to setting up the add/edit/remove multiple contact details from the same form part.
I have the javascript worked out and know how to get it done using views - but I need to get this done using Zend Forms here. I've looked at the idea of subforms however in my case I need to do the following:
My form is stuctured as follows:
Text and INputs for all contact details listed out
A special contact Data region with links to Add a Phone, Add a Fax, Add an address. Clicking on these links would open up and add a set of inputs to the table eg add an address link adds a street, city, country and state set of input to the table.
I've been hacking at this for an hour and am pretty lost here. Any ideas on how can i handle this?
I think the best way to solve this problem is creating new Elements. One for contact data and one for address. Each of those elements should have custom viewHelper to render your complex interface. Each of view helpers can assign javascript file to handle dynamic adding / removing.
class Form_Element_Contact extends Zend_Form_Element_Xhtml {
public $helper = 'contact';
}
class Zend_View_Helper_Contact extends Zend_View_Helper_FormElement {
public function contact($name, $value = null, $attribs = null, $options = null) {
$this->view->headScript()->appendFile("/js/dynamicInterfaceForContacts.js");
$info = $this->_getInfo($name, $value, $attribs, $options);
$html = $this->generateHtml(); // elements should be part of an array
return $html;
}
}
If you need more details let me know.
Our policy for people who are terminated/separated or who go on leave of absence involves a handful of changes to their AD account for record keeping purposes and security. One of these changes is renaming the account (login name, display name and dn) to a value that includes the original name with the help desk ticket number appended.
I have been able to use ldap_rename() to change the active directory "name" attribute, thus changing the DN. I can change the displayName attribute using either ldap_modify() or ldap_mod_replace(). What I cannot seem to do is change the samAccountName using any of these. Below is the core of the code I'm using. The errors I get are dependent upon which function I use, and are listed below.
I know there are some nuances to using PHP LDAP with Active Directory, but I find it hard to believe that I have been able to do everything up to and including changing passwords and I can't change the samAccountName... help?
<?php
$connection=ldap_connect(domain.local,389);
ldap_set_option($connection,LDAP_OPT_PROTOCOL_VERSION,3);
ldap_set_option($connection,LDAP_OPT_REFERRALS,0);
ldap_start_tls($connection);
ldap_bind($connection,$username,$password);
$accountName=$_POST["accountName"];
$ticketNumber=$_POST["ticketNumber"];
$baseDn="dc=domain,dc=local";
$attribs=array("samaccountname","dn","name","displayname","description","info","memberof");
$search=ldap_search($connection,$baseDn,"(samaccountname=".$accountName.")",$attribs);
$result=ldap_get_entries($connection,$search);
// ldap_modify returns error 80: Internal (implementation specific) error.
foreach ($result as $account) {
$newValues=array("samaccountname"=>$account["samaccountname"][0]."-".$ticketNumber)
ldap_modify($connection,$account["dn"],$newValues);
}
// ldap_mod_replace returns error 80: Internal (implementation specific) error.)
foreach ($result as $account) {
$newValues=array("samaccountname"=>$account["samaccountname"][0]."-".$ticketNumber)
ldap_mod_replace($connection,$account["dn"],$newValues);
}
?>
So yeah, what is it I'm supposed to be doing to make this happen?
The "implementation specific" error message you're receiving means that your sAMAccountName is invalid because it doesn't meet specific AD restrictions on it. The sAMAccountName attribute cannot be more than 20 characters and cannot contain any of the following: " [ ] : ; | = + * ? < > / \ ,. It might be helpful to see an example username with the ticket number appended.
I am making an application in CodeIgniter and I need a Messaging Library Module there and I got a Library name Mahana. The Link is as follows.
https://github.com/jrmadsen67/Mahana-Messaging-library-for-CodeIgniter/tree/master/application
But I am unable to apply it as it has no controller and View portion. I am very new to CodeIgniter. Can any one provide me any link of total Mahana Librery or any other Messaging Library for CodeIgniter
Thank You
What's your problem ?
First you must create in the db, the tables from the dump mahana.sql,
and after use the variable that are in the configuration file config/mahana.php (USER_TABLE_TABLENAME, USER_TABLE_ID, and USER_TABLE_USERNAME) to integrate with a fast table access.
To use the library just put in your controller :
$this->load->library('mahana_messaging');
after that, when you want to get a message, create an object, and put in the method *get_message* the message id, and sender id, it will return a single message, including the status for specified user.
$mahana = new Mahana_messaging();
$msg = $mahana->get_message($msg_id, $sender_id);
U can also get the full thread of conversation using the method *get_full_thread*, it will return a entire thread conversation. To send a new internal message, that create a new thread, you must use the method *send_new_message* and pass the sender id, the recipient, the subject, the body, and finally the priority (this information, usually will be get from a web form, that you have created previously)
function send_new_message($sender_id, $recipients, $subject='', $body='', $priority=PRIORITY_NORMAL)
and so on ... there are other functions that permit you to reply a message, get partecipant...
Good work
Does this help at all????