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;
}
Exemple #2
0
function viewMemberList($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf)
{
    $pEmailList = new paloSantoEmailList($pDB);
    $id_list = getParameter("id");
    if (!$pEmailList->listExistsbyId($id_list)) {
        $smarty->assign("mb_title", _tr("Validation Error"));
        $smarty->assign("mb_message", _tr("The List entered does not exist"));
        return reportEmailList($smarty, $module_name, $local_templates_dir, $pDB, $arrConf);
    }
    $field_type = getParameter("filter_type");
    $field_pattern = getParameter("filter_txt");
    $smarty->assign("IDEMAILLIST", $id_list);
    $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"));
    $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("/modules/{$module_name}/images/email.png");
    $oGrid->pagingShow(true);
    $offset = $oGrid->calculateOffset();
    $url = array('menu' => $module_name, 'action' => 'view_memberlist', 'id' => $id_list, 'filter_type' => $field_type, 'filter_txt' => $field_pattern);
    $oGrid->setURL($url);
    $arrColumns = array(_tr("Member name"), _tr("Member email"));
    $oGrid->setColumns($arrColumns);
    $arrResult = $pEmailList->getMembers($limit, $offset, $id_list, $field_type, $field_pattern);
    $arrData = null;
    if (is_array($arrResult) && $totalMembers > 0) {
        foreach ($arrResult as $key => $value) {
            $arrTmp[0] = $value["namemember"];
            $arrTmp[1] = $value["mailmember"];
            $arrData[] = $arrTmp;
        }
    }
    $oGrid->setData($arrData);
    $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"));
    $oGrid->customAction("?menu={$module_name}&action=export&id={$id_list}&rawmode=yes", _tr("Export Members"), null, true);
    //$arrFiltro = array("filter_type"=>$field_type,"filter_txt"=>$field_pattern);
    $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();
    if (strpos($content, '<form') === FALSE) {
        $content = "<form  method='POST' style='margin-bottom:0;' action=" . construirURL($url) . ">{$content}</form>";
    }
    return $content;
}