function reportMemberList($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { global $arrPermission; $pEmailList = new paloSantoEmailList($pDB); $id_list = getParameter("id"); if ($credentials['userlevel'] == 'superadmin') { $emailList = $pEmailList->getEmailList($id_list); } else { $emailList = $pEmailList->getEmailList($id_list, $credentials['domain']); } if ($emailList == false) { $smarty->assign("mb_title", _tr("Error")); $error = $emailList === false ? _tr("Couldn't be retrieved Email List data") : _tr("Email List does not exist"); $smarty->assign("mb_message", $error); return reportEmailList($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } $field_type = getParameter("filter_type"); $field_pattern = getParameter("filter_txt"); $smarty->assign("IDEMAILLIST", $id_list); $smarty->assign("ACTION", 'view_memberlist'); $smarty->assign("SHOW", _tr("Show")); $smarty->assign("RETURN", _tr("Return")); $smarty->assign("LINK", "?menu={$module_name}&action=export&id={$id_list}&rawmode=yes"); $smarty->assign("EXPORT", _tr("Export Members")); $edit_permission = in_array('edit_list', $arrPermission); $totalMembers = $pEmailList->getTotalMembers($id_list); $oGrid = new paloSantoGrid($smarty); $limit = 20; $oGrid->setLimit($limit); $oGrid->setTotal($totalMembers); $oGrid->setTitle(_tr("List Members of") . " " . $pEmailList->getListName($id_list)); $oGrid->setIcon("web/apps/{$module_name}/images/email.png"); $oGrid->pagingShow(true); $offset = $oGrid->calculateOffset(); $url['menu'] = $module_name; $url['action'] = 'view_memberlist'; $url['id'] = $id_list; $url['filter_type'] = $field_type; $url['filter_txt'] = $field_pattern; $oGrid->setURL($url); if ($edit_permission) { $arrColumns[] = ''; } $arrColumns[] = _tr("Member name"); $arrColumns[] = _tr("Member email"); $oGrid->setColumns($arrColumns); $arrResult = $pEmailList->getMembers($limit, $offset, $id_list, $field_type, $field_pattern); $arrData = null; //print_r($arrResult); if (is_array($arrResult) && $totalMembers > 0) { foreach ($arrResult as $list) { $arrTmp = array(); if ($edit_permission) { $arrTmp[] = "<input type='checkbox' name='del_emailmembers[{$list["mailmember"]}]'>"; } $arrTmp[] = $list["namemember"]; $arrTmp[] = $list["mailmember"]; $arrData[] = $arrTmp; } } $arrFormFilterMembers = createFieldFilterViewMembers(); $oFilterForm = new paloForm($smarty, $arrFormFilterMembers); $arrType = array("name" => _tr("Name"), "email" => _tr("Email")); if (!is_null($field_type)) { $nameField = $arrType[$field_type]; } else { $nameField = ""; } $oGrid->customAction("return", _tr("Return")); if ($edit_permission) { $oGrid->addNew("new_memberlist", _tr("Add Member(s) to List")); $oGrid->deleteList(_tr("Are you sure you wish to delete the Email List(s)."), "remove_memberlist", _tr("Delete")); } $oGrid->customAction("?menu={$module_name}&action=export&id={$id_list}&rawmode=yes", _tr("Export Members"), null, true); $oGrid->addFilterControl(_tr("Filter applied: ") . $nameField . " = " . $field_pattern, $_POST, array("filter_type" => "name", "filter_txt" => "")); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/view_members.tpl", "", $_POST); $oGrid->showFilter(trim($htmlFilter)); $content = $oGrid->fetchGrid(array(), $arrData); return $content; }
function exportMembers($smarty, $module_name, $local_templates_dir, $pDB, $arrConf) { $pEmailList = new paloSantoEmailList($pDB); $id_list = getParameter("id"); $listName = $pEmailList->getListName($id_list); $text = ""; if (!is_null($listName)) { $totalMembers = $pEmailList->getTotalMembers($id_list); $members = $pEmailList->getMembers($totalMembers, 0, $id_list, null, ""); foreach ($members as $key => $value) { if ($text != "") { $text .= "\n"; } if (isset($value["namemember"]) && $value["namemember"] != "") { $text .= $value["namemember"] . " <{$value['mailmember']}>"; } else { $text .= $value["mailmember"]; } } } else { $listName = ""; } header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: public"); header("Content-Description: txt file"); header("Content-Type: application/download"); header("Content-Disposition: attachment; filename={$listName}" . "_members.txt"); header("Content-Transfer-Encoding: binary"); header("Content-length: " . strlen($text)); echo $text; }