Ejemplo n.º 1
0
function ownddns_generateActivatedCustomers($tpl, $resellerId)
{
    /** @var $cfg iMSCP_Config_Handler_File */
    $cfg = iMSCP_Registry::get('config');
    $rowsPerPage = $cfg->DOMAIN_ROWS_PER_PAGE;
    if (isset($_GET['psi']) && $_GET['psi'] == 'last') {
        unset($_GET['psi']);
    }
    $startIndex = isset($_GET['psi']) ? (int) $_GET['psi'] : 0;
    $countQuery = "\n\t\tSELECT COUNT(`t1`.`admin_id`) AS `cnt` \n\t\tFROM \n\t\t\t`admin` AS `t1`\n\t\tLEFT JOIN\n\t\t\t`ownddns` AS `t2` ON(`t2`.`admin_id` = `t1`.`admin_id`)\n\t\tWHERE\n\t\t\t`t1`.`created_by` = ?\n\t\tAND\n\t\t\t`t1`.`admin_id` IN (SELECT `admin_id` FROM `ownddns`)\n\t";
    $stmt = exec_query($countQuery, $resellerId);
    $recordsCount = $stmt->fields['cnt'];
    $query = "\n\t\tSELECT\n\t\t\t`t2`.*\n\t\tFROM\n\t\t\t`admin` AS `t1`\n\t\tLEFT JOIN\n\t\t\t`ownddns` AS `t2` ON(`t2`.`admin_id` = `t1`.`admin_id`)\n\t\tWHERE\n\t\t\t`t1`.`created_by` = ?\n\t\tAND\n\t\t\t`t1`.`admin_id` IN (SELECT `admin_id` FROM `ownddns`)\n\t\tORDER BY\n\t\t\t`t2`.`admin_name` ASC\n\t\tLIMIT\n\t\t\t{$startIndex}, {$rowsPerPage}\n\t";
    $stmt = exec_query($query, $resellerId);
    if ($recordsCount > 0) {
        $prevSi = $startIndex - $rowsPerPage;
        if ($startIndex == 0) {
            $tpl->assign('SCROLL_PREV', '');
        } else {
            $tpl->assign(array('SCROLL_PREV_GRAY' => '', 'PREV_PSI' => $prevSi));
        }
        $nextSi = $startIndex + $rowsPerPage;
        if ($nextSi + 1 > $recordsCount) {
            $tpl->assign('SCROLL_NEXT', '');
        } else {
            $tpl->assign(array('SCROLL_NEXT_GRAY' => '', 'NEXT_PSI' => $nextSi));
        }
        while ($data = $stmt->fetchRow()) {
            if ($data['ownddns_status'] == $cfg->ITEM_OK_STATUS) {
                $statusIcon = 'ok';
            } elseif ($data['ownddns_status'] == $cfg->ITEM_DISABLED_STATUS) {
                $statusIcon = 'disabled';
            } elseif ($data['ownddns_status'] == $cfg->ITEM_TOADD_STATUS || $data['ownddns_status'] == $cfg->ITEM_TOCHANGE_STATUS || $data['ownddns_status'] == $cfg->ITEM_TODELETE_STATUS || ($data['ownddns_status'] == $cfg->ITEM_TOADD_STATUS || $data['ownddns_status'] == $cfg->ITEM_TORESTORE_STATUS || $data['ownddns_status'] == $cfg->ITEM_TOCHANGE_STATUS || $data['ownddns_status'] == $cfg->ITEM_TOENABLE_STATUS || $data['ownddns_status'] == $cfg->ITEM_TODISABLE_STATUS || $data['ownddns_status'] == $cfg->ITEM_TODELETE_STATUS)) {
                $statusIcon = 'reload';
            } else {
                $statusIcon = 'error';
            }
            $tpl->assign(array('OWNDDNS_CUSTOMER_NAME' => decode_idna($data['admin_name']), 'OWNDDNS_STATUS' => translate_dmn_status($data['ownddns_status']), 'OWNDDNS_ACCOUNT_LIMIT' => get_ownddnsAccountLimit($data['admin_id']), 'OWNDDNS_ADMIN_ID' => $data['admin_id'], 'STATUS_ICON' => $statusIcon));
            $tpl->parse('OWNDDNS_CUSTOMER_ITEM', '.ownddns_customer_item');
        }
        $tpl->assign('OWNDDNS_NO_CUSTOMER_ITEM', '');
    } else {
        $tpl->assign(array('OWNDDNS_CUSTOMER_LIST' => '', 'SCROLL_PREV' => '', 'SCROLL_PREV_GRAY' => '', 'SCROLL_NEXT' => '', 'SCROLL_NEXT_GRAY' => ''));
    }
    $tpl->assign('OWNDDNS_EDIT', '');
}
Ejemplo n.º 2
0
            if ($accountID != '') {
                if (ownddns_EditAccount($tpl, $_SESSION['user_id'], $accountID)) {
                    set_page_message(tr('OwnDDNS account successfully scheduled for update'), 'success');
                    redirectTo('ownddns.php');
                }
            }
        } elseif ($action === 'delete') {
            $accountID = isset($_GET['ownddns_account_id']) ? clean_input($_GET['ownddns_account_id']) : '';
            if ($accountID != '') {
                if (ownddns_DeleteAccount($tpl, $pluginManager, $_SESSION['user_id'], $accountID)) {
                    set_page_message(tr('OwnDDNS account successfully scheduled for deletion'), 'success');
                    redirectTo('ownddns.php');
                }
            }
        } else {
            showBadRequestErrorPage();
        }
    }
    generateNavigation($tpl);
    get_ownddnsAccountLimit($tpl, $_SESSION['user_id']);
    ownddns_generateSelect($tpl, $_SESSION['user_id']);
    if (!isset($_REQUEST['action']) || isset($_REQUEST['action']) && clean_input($_REQUEST['action']) !== 'edit') {
        ownddns_generateAccountsList($tpl, $pluginManager, $_SESSION['user_id']);
    }
    generatePageMessage($tpl);
    $tpl->parse('LAYOUT_CONTENT', 'page');
    iMSCP_Events_Manager::getInstance()->dispatch(iMSCP_Events::onClientScriptEnd, array('templateEngine' => $tpl));
    $tpl->prnt();
} else {
    showBadRequestErrorPage();
}