protected function specific_definition($mform) { global $CFG, $OUTPUT; $image = '<a href="http://www.sebsoft.nl" target="_new"><img src="' . $OUTPUT->pix_url('logo', 'blocks_mailchimp') . '" /></a>'; $mform->addElement('header', 'configheader', get_string('promo', 'block_mailchimp')); $mform->addElement('html', get_string('promodesc', 'block_mailchimp', $image)); $mailchimplists = \block_mailchimp\helper::call_api_lists(); // If we're having trouble loading mailing lists. if ($mailchimplists === false) { $mform->addElement('html', "<b>" . get_string('error:load_api_lists', 'block_mailchimp') . "</b>"); // Or if we simply have no lists yet. } else { if (empty($mailchimplists)) { $mform->addElement('html', "<b>" . get_string('missing_mailing_lists', 'block_mailchimp') . "</b>"); } } }
'; $helpbuttoninterest = ' <span class="helplink"> <a class="tooltip" aria-haspopup="true" href="' . $CFG->wwwroot . '/help.php?identifier=interest&component=block_mailchimp&lang=' . $userlang . '"> <img class="iconhelp" src="' . $CFG->wwwroot . '/pix/help.png"> </a> </span> '; $helpbuttonprofilefield = ' <span class="helplink"> <a class="tooltip" aria-haspopup="true" href="' . $CFG->wwwroot . '/help.php?identifier=linked_profile_field&component=block_mailchimp&lang=' . $userlang . '"> <img class="iconhelp" src="' . $CFG->wwwroot . '/pix/help.png"> </a> </span> '; $mailchimplists = \block_mailchimp\helper::call_api_lists(); $mailchimpinterests = \block_mailchimp\helper::call_interests(); $strheader = ""; // If we can't make any connection with mailchimp. if ($mailchimplists === false) { $mailchimplists = array(); $strheader = "<p><b>" . get_string("error:load_api_lists", 'block_mailchimp') . "</b></p>"; // If we simply have no mailing lists in mailchimp yet. } else { if (empty($mailchimplists)) { $mailchimplists = array('' => get_string('no_lists', 'block_mailchimp')); $strheader = "<p><b>" . get_string("missing_mailing_lists", 'block_mailchimp') . "</b></p>"; } } if ($mailchimpinterests === false) { $mailchimpinterests = array();
/** * Validate data before storage * @param string data * @return mixed true if ok string if error found */ public function validate($data) { global $CFG; $listcall = \block_mailchimp\helper::call_api_lists($data); if (!$listcall) { //There was an error calling the lists. return get_string('error:save_api_code', 'block_mailchimp'); } return true; }