Beispiel #1
0
 /**
  * Create an array with mailchimps interest fields
  *
  * @param   string  $listId  - the list id
  *
  * @return array|bool
  */
 public static function getInterestsFields($listId)
 {
     $api = new cmcHelperChimp();
     $interests = $api->listInterestGroupings($listId);
     $key = 'id';
     $val = 'name';
     $options = false;
     if ($interests) {
         foreach ($interests as $interest) {
             if ($interest['form_field'] != 'hidden') {
                 $groups = '';
                 foreach ($interest['groups'] as $ig) {
                     $groups .= $ig['name'] . '##' . $ig['name'] . '####';
                 }
                 $groups = substr($groups, 0, -4);
                 $options[] = array($key => $interest[$key] . ';' . $interest['form_field'] . ';' . $interest['name'] . ';' . $groups, $val => $interest[$val]);
             }
         }
     }
     return $options;
 }
Beispiel #2
0
 /**
  * Loads the interests
  *
  * @return  mixed|string
  */
 public function loadInterests()
 {
     $plugin = GetCmcTab::getPlugin();
     $listid = $plugin->params->get('listid', "");
     if (empty($listid)) {
         $content = '<div style="float:left;">' . JText::_('PLG_CMCCB_NO_INTEREST_GROUPS') . '</div>';
         return $content;
     }
     $api = new cmcHelperChimp();
     $interests = $api->listInterestGroupings($listid);
     $key = 'id';
     $val = 'name';
     $options = false;
     if ($interests) {
         foreach ($interests as $interest) {
             if ($interest['form_field'] != 'hidden') {
                 $groups = '';
                 foreach ($interest['groups'] as $ig) {
                     $groups .= $ig['name'] . '##' . $ig['name'] . '####';
                 }
                 $groups = substr($groups, 0, -4);
                 $options[] = array($key => $interest[$key] . ';' . $interest['form_field'] . ';' . $interest['name'] . ';' . $groups, $val => $interest[$val]);
             }
         }
     }
     $attribs = 'multiple="multiple" size="8"';
     if ($options) {
         $content = JHtml::_('select.genericlist', $options, 'params[interests][]', $attribs, $key, $val, explode("|*|", $plugin->params->get('interests', "")));
     } else {
         $content = '<div style="float:left;">' . JText::_('PLG_CMCCB_NO_INTEREST_GROUPS') . '</div>';
     }
     return $content;
 }