/** * Adds a new list with the specified name * @param string $name The name of the new list * @param bool $private TRUE if new list is private, else FALSE */ function gu_ajax_list_add($name, $private) { if (($list = gu_list::create($name, $private)) != FALSE) { gu_success(t('New list <b><i>%</i></b> added', array($list->get_name()))); gu_ajax_return('gu_ajax_on_list_add(' . $list->get_id() . ', "' . $list->get_name() . '", ' . ($list->is_private() ? 'true' : 'false') . ')'); } }
/** * Imports an address list from a CSV file * @param string $name The list name * @param string $path The path of the CSV file * @return mixed The new list if it was successfully created, else FALSE */ public static function import_csv($name, $path) { $csv = @fopen($path, 'r'); if ($csv == FALSE) { return gu_error(t("Unable to open CSV file for reading")); } // Read addresses from first cell on each line $addresses = array(); while (!feof($csv)) { $vals = explode(',', fgets($csv)); $address = trim($vals[0]); if (strlen($address) > 0 && strlen($address) <= GUTUMA_MAX_ADDRESS_LEN) { $addresses[] = $address; } } fclose($csv); // Sort addresses alphabetically natcasesort($addresses); return gu_list::create($name, FALSE, $addresses); }