Hi,

I'm trying to modify this module to add a "users" list to select the users to send the information. I think that this module doesn't support this feature yet, isn't?

The companies and their contacts have a property that tells if they like to receive emails or not.
I have to show in the 'select' the companies and their contacts who want to receive emails.
When I try to add the select to the form, drupal crashes with the memory overflow error...

Can you help me to do the following code more efficient?

Thanks


   else {
      // Otherwise, just use the default category.
      $form['cid'] = array(
        '#type'  => 'value',
        '#value' => $default_category, // This must be an array, otherwise the code breaks upon submit.
      );
      $form['cid-info'] = array(
        '#type'  => 'markup',
        '#value' => '<p>Sending to all users subscribed to the '. $default_category_name .' category.</p>',
      );
	  
	  
/*
the code starts here line 851
*/	  
	  $destinations = array();
	  // select companies that want to receive emails
	  $companies= db_query("SELECT n.nid, n.title FROM node n, content_type_t_agente c WHERE n.type = '%s' AND n.nid = c.nid AND c.field_agente_difusion_value = '%s'","t_agente","0");
	  while ($company= db_fetch_object($companies))
	  {
		
		$elems = count ($destination);
		$destinations[$elems++] = $company;
		$contacts= db_query("SELECT n.nid, n.title, cf.nid FROM node n, content_field_agente_contactos cf, content_type_t_contacto ct WHERE cf.field_agente_contactos_nid = n.nid AND n.nid = ct.nid AND ct.field_contacto_permite_difusion_value = '%s' AND cf.nid = %d","0",$agente->nid);
		unset($company);
		// select contacts from the company who want to receive the email
		while ($contact= db_fetch_object($contacts))
		{
			$destinations[$elems++] = $contact;
			unset($contact);
		}
	  }
	  
	  mysql_free_result($companies);
	  mysql_free_result($contacts);
	  
	  
	  $form['users'] = array(
	  '#type' => 'select',
	  '#title' => t('Select users to send the information'),
	  '#options' => $destinations,
	  '#required' => TRUE,
	  '#multiple' => TRUE,
	  );
	  unset($destinations);
	  unset($elems);

Comments

oadaeh’s picture

Version: 6.x-1.0-beta2 » 7.x-1.x-dev
Component: Code » Categories

Thanks to ygerasimov, the 7.x-1.x version of Mass Contact now utilizes the Chaos tools suite (ctools) plugin system. I will reexamine this and realted issues with that plugin system in mind to determine whether to create a plugin for this request or not.