function ListofLists($current, $fieldname, $subselect) { $categoryhtml = array(); ## add a hidden field, so that all checkboxes can be unchecked while keeping the field in POST to process it # $categoryhtml['unselect'] = '<input type="hidden" name="'.$fieldname.'[unselect]" value="1" />'; $categoryhtml['selected'] = ''; $categoryhtml['all'] = ' <li><input type="hidden" name="' . $fieldname . '[unselect]" value="-1" /><input type="checkbox" name="' . $fieldname . '[all]"'; if (!empty($current["all"])) { $categoryhtml['all'] .= "checked"; } $categoryhtml['all'] .= ' />' . $GLOBALS['I18N']->get('All Lists') . '</li>'; $categoryhtml['all'] .= '<li><input type="checkbox" name="' . $fieldname . '[allactive]"'; if (!empty($current["allactive"])) { $categoryhtml['all'] .= 'checked="checked"'; } $categoryhtml['all'] .= ' />' . $GLOBALS['I18N']->get('All Active Lists') . '</li>'; ## need a better way to suppress this if ($_GET['page'] != 'send') { $categoryhtml['all'] .= '<li>' . PageLinkDialog('addlist', $GLOBALS['I18N']->get('Add a list')) . '</li>'; } $result = Sql_query('select * from ' . $GLOBALS['tables']['list'] . $subselect . ' order by category, name'); $numLists = Sql_Affected_Rows(); while ($list = Sql_fetch_array($result)) { if (empty($list['category'])) { if ($numLists < 5) { ## for a small number of lists, add them to the @ tab $list['category'] = 'all'; } else { $list['category'] = $GLOBALS['I18N']->get('Uncategorised'); } } if (!isset($categoryhtml[$list['category']])) { $categoryhtml[$list['category']] = ''; } if (isset($current[$list["id"]]) && $current[$list["id"]]) { $list['category'] = 'selected'; } $categoryhtml[$list['category']] .= sprintf('<li><input type=checkbox name="' . $fieldname . '[%d]" value="%d" ', $list["id"], $list["id"]); # check whether this message has been marked to send to a list (when editing) if (isset($current[$list["id"]]) && $current[$list["id"]]) { $categoryhtml[$list['category']] .= "checked"; } $categoryhtml[$list['category']] .= " />" . htmlspecialchars(stripslashes($list["name"])); if ($list["active"]) { $categoryhtml[$list['category']] .= ' (<span class="activelist">' . $GLOBALS['I18N']->get('Public list') . '</span>)'; } else { $categoryhtml[$list['category']] .= ' (<span class="inactivelist">' . $GLOBALS['I18N']->get('Private list') . '</span>)'; } if (!empty($list["description"])) { $desc = nl2br(stripslashes($list["description"])); $categoryhtml[$list['category']] .= "<br />{$desc}"; } $categoryhtml[$list['category']] .= "</li>"; $some = 1; } if (empty($categoryhtml['selected'])) { unset($categoryhtml['selected']); } return $categoryhtml; }
function ListofLists($current, $fieldname, $subselect) { ## @@TODO, this is slow on more than 150 lists. We should add caching or optimise $GLOBALS['systemTimer']->interval(); $categoryhtml = array(); ## add a hidden field, so that all checkboxes can be unchecked while keeping the field in POST to process it # $categoryhtml['unselect'] = '<input type="hidden" name="'.$fieldname.'[unselect]" value="1" />'; $categoryhtml['selected'] = ''; $categoryhtml['all'] = ' <li><input type="hidden" name="' . $fieldname . '[unselect]" value="-1" /><input type="checkbox" name="' . $fieldname . '[all]"'; if (!empty($current['all'])) { $categoryhtml['all'] .= 'checked'; } $categoryhtml['all'] .= ' />' . s('All Lists') . '</li>'; $categoryhtml['all'] .= '<li><input type="checkbox" name="' . $fieldname . '[allactive]"'; if (!empty($current['allactive'])) { $categoryhtml['all'] .= 'checked="checked"'; } $categoryhtml['all'] .= ' />' . s('All Public Lists') . '</li>'; ## need a better way to suppress this if ($_GET['page'] != 'send') { $categoryhtml['all'] .= '<li>' . PageLinkDialog('addlist', s('Add a list')) . '</li>'; } $result = Sql_query('select * from ' . $GLOBALS['tables']['list'] . $subselect . ' order by category, name'); $numLists = Sql_Affected_Rows(); while ($list = Sql_fetch_array($result)) { if (empty($list['category'])) { if ($numLists < 5) { ## for a small number of lists, add them to the @ tab $list['category'] = 'all'; } else { $list['category'] = s('Uncategorised'); } } if (!isset($categoryhtml[$list['category']])) { $categoryhtml[$list['category']] = ''; } if (isset($current[$list['id']]) && $current[$list['id']]) { $list['category'] = 'selected'; } $categoryhtml[$list['category']] .= sprintf('<li><input type="checkbox" name="' . $fieldname . '[%d]" value="%d" ', $list['id'], $list['id']); # check whether this message has been marked to send to a list (when editing) if (isset($current[$list['id']]) && $current[$list['id']]) { $categoryhtml[$list['category']] .= 'checked'; } $categoryhtml[$list['category']] .= ' />' . htmlspecialchars(stripslashes($list['name'])); if ($list['active']) { $categoryhtml[$list['category']] .= ' <span class="activelist">' . s('Public list') . '</span>'; } else { $categoryhtml[$list['category']] .= ' <span class="inactivelist">' . s('Private list') . '</span>'; } if (!empty($list['description'])) { $desc = nl2br(stripslashes($list['description'])); $categoryhtml[$list['category']] .= "<br />{$desc}"; } $categoryhtml[$list['category']] .= '</li>'; $some = 1; } if (empty($categoryhtml['selected'])) { unset($categoryhtml['selected']); } # file_put_contents('/tmp/timer.log','ListOfLists '.$GLOBALS['systemTimer']->interval(). "\n",FILE_APPEND); return $categoryhtml; }
} function addUserForm($listid) { //nizar 'value' $html = formStart(' class="membersAdd" ') . '<input type="hidden" name="listid" value="' . $listid . '" /> ' . $GLOBALS['I18N']->get("Add a user") . ': <input type="text" name="new" value="" size="40" id="emailsearch"/> <input class="submit" type="submit" name="add" value="' . $GLOBALS['I18N']->get('Add') . '" /> </form>'; return $html; } if (!empty($id)) { print "<h3>" . $GLOBALS['I18N']->get("Members of") . " " . ListName($id) . "</h3>"; print '<div class="actions">'; echo PageLinkButton("editlist", $GLOBALS['I18N']->get("edit list details"), "id={$id}", 'pill-l'); echo PageLinkButton("export&list={$id}", $GLOBALS['I18N']->get("Download subscribers"), '', 'pill-c'); echo PageLinkDialog("importsimple&list={$id}", $GLOBALS['I18N']->get("Import Subscribers to this list"), '', 'pill-r'); print '</div>'; } else { Redirect('list'); } if (!empty($_POST['importcontent'])) { include dirname(__FILE__) . '/importsimple.php'; } if (isset($_REQUEST["processtags"]) && $access != "view") { $msg = $GLOBALS['I18N']->get("Processing") . " .... <br/>"; if (isset($_POST["tagaction"]) && !empty($_POST["user"]) && is_array($_POST["user"])) { switch ($_POST["tagaction"]) { case "move": $cnt = 0; foreach ($_POST["user"] as $key => $val) { Sql_query(sprintf('delete from %s where listid = %d and userid = %d', $tables["listuser"], $id, $key));