コード例 #1
0
ファイル: faqAdapter.php プロジェクト: trabisdementia/xuups
function manage()
{
    global $oAdminButton, $imagearray;
    $faqAdapters =& xhelpFaqAdapterFactory::installedAdapters();
    $myAdapter =& xhelpFaqAdapterFactory::getFaqAdapter();
    xoops_cp_header();
    echo $oAdminButton->renderButtons('manFaqAdapters');
    echo "<form method='post' action='" . XHELP_ADMIN_URL . "/faqAdapter.php?op=updateActive'>";
    echo "<table width='100%' cellspacing='1' class='outer'>";
    if (!empty($faqAdapters)) {
        echo "<tr><th colspan='5'>" . _AM_XHELP_MENU_MANAGE_FAQ . "</th></tr>";
        echo "<tr class='head'>\r\n                  <td>" . _AM_XHELP_TEXT_NAME . "</td>\r\n                  <td>" . _AM_XHELP_TEXT_PLUGIN_VERSION . "</td>\r\n                  <td>" . _AM_XHELP_TEXT_TESTED_VERSIONS . "</td>\r\n                  <td>" . _AM_XHELP_TEXT_AUTHOR . "</td>\r\n                  <td>" . _AM_XHELP_TEXT_ACTIVE . "</td>\r\n              </tr>";
        $activeAdapter = xhelpGetMeta('faq_adapter');
        foreach ($faqAdapters as $name => $oAdapter) {
            $modname = $name;
            $author = $oAdapter->meta['author'];
            $author_name = $author;
            if ($oAdapter->meta['url'] != '') {
                // If a website is specified
                $name = "<a href='" . $oAdapter->meta['url'] . "'>" . $oAdapter->meta['name'] . "</a>";
                // Add link to module name
            }
            if ($oAdapter->meta['author_email'] != '') {
                $author = "<a href='mailto:" . $oAdapter->meta['author_email'] . "'>" . $author_name . "</a>";
                // Add link to email author
            }
            echo "<tr class='even'>\r\n                      <td>" . $name . "</td>\r\n                      <td>" . $oAdapter->meta['version'] . "</td>\r\n                      <td>" . $oAdapter->meta['tested_versions'] . "</td>\r\n                      <td>" . $author . "</td>\r\n                      <td>\r\n                          <input type='image' src='" . ($activeAdapter == $modname ? XHELP_IMAGE_URL . '/on.png' : XHELP_IMAGE_URL . '/off.png') . "' name='modname' value='" . $modname . "' style='border:0;background:transparent' />\r\n                      </td>\r\n                  </tr>";
        }
    } else {
        // Display "no adapters found" message
        echo "<tr><th>" . _AM_XHELP_MENU_MANAGE_FAQ . "</th></tr>";
        echo "<tr><td class='even'>" . _AM_XHELP_TEXT_NO_FILES . "</td></tr>";
    }
    echo "</table></form>";
    if (is_object($myAdapter)) {
        $faq = $myAdapter->createFaq();
    }
    xhelpAdminFooter();
    xoops_cp_footer();
}
コード例 #2
0
    //echo "</div>";
}
function list_groups()
{
    global $xoopsModule, $block_arr;
    $myts =& MyTextSanitizer::getInstance();
    //smartclient_collapsableBar('bottomtable', 'bottomtableicon');
    foreach (array_keys($block_arr) as $i) {
        $item_list[$block_arr[$i]->getVar("bid")] = $block_arr[$i]->getVar("title");
    }
    $form = new MyXoopsGroupPermForm('', 1, 'block_read', "<img id='bottomtableicon' src=" . XOOPS_URL . "/modules/" . $xoopsModule->dirname() . "/images/icon/close12.gif alt='' /></a>&nbsp;" . _AM_SCLIENT_GROUPS . "</h3><div id='bottomtable'><span style=\"color: #567; margin: 3px 0 0 0; font-size: small; display: block; \">" . _AM_SCLIENT_GROUPSINFO . "</span>");
    $form->addAppendix('module_admin', $xoopsModule->mid(), $myts->displayTarea($xoopsModule->name()) . ' ' . _AM_ACTIVERIGHTS);
    $form->addAppendix('module_read', $xoopsModule->mid(), $myts->displayTarea($xoopsModule->name()) . ' ' . _AM_ACCESSRIGHTS);
    foreach ($item_list as $item_id => $item_name) {
        $form->addItem($item_id, $myts->displayTarea($item_name));
    }
    echo $form->render();
    echo "</div>";
}
if (!empty($_POST['submit'])) {
    include_once "{$xoops_system_path}/language/{$language}/admin.php";
    redirect_header(XOOPS_URL . "/modules/" . $xoopsModule->dirname() . "/admin/myblocksadmin.php", 1, _AM_DBUPDATED);
}
if (!ob_get_length()) {
    xoops_cp_header();
}
echo $oAdminButton->renderButtons();
list_blocks();
//list_groups() ;
xhelpAdminFooter();
xoops_cp_footer();
コード例 #3
0
ファイル: department.php プロジェクト: trabisdementia/xuups
function manageDepartments()
{
    global $xoopsModule, $oAdminButton, $aSortBy, $aOrderBy, $aLimitBy, $order, $limit, $start, $sort, $dept_search;
    $module_id = $xoopsModule->getVar('mid');
    $hGroups =& xoops_gethandler('group');
    $hGroupPerm =& xoops_gethandler('groupperm');
    if (isset($_POST['addDept'])) {
        $hasErrors = false;
        $errors = array();
        $groups = isset($_POST['groups']) ? $_POST['groups'] : array();
        $hDepartments =& xhelpGetHandler('department');
        //Department Name supplied?
        if (trim($_POST['newDept']) == '') {
            $hasErrors = true;
            $errors['newDept'][] = _AM_XHELP_MESSAGE_NO_DEPT;
        } else {
            //Department Name unique?
            $crit = new Criteria('department', $_POST['newDept']);
            if ($existingDepts = $hDepartments->getCount($crit)) {
                $hasErrors = true;
                $errors['newDept'][] = _XHELP_MESSAGE_DEPT_EXISTS;
            }
        }
        if ($hasErrors) {
            $session =& Session::singleton();
            //Store existing dept info in session, reload addition page
            $aDept = array();
            $aDept['newDept'] = $_POST['newDept'];
            $aDept['groups'] = $groups;
            $session->set('xhelp_addDepartment', $aDept);
            $session->set('xhelp_addDepartmentErrors', $errors);
            header('Location: ' . xhelpMakeURI(XHELP_ADMIN_URL . '/department.php', array('op' => 'manageDepartments'), false));
            exit;
        }
        $department =& $hDepartments->create();
        $department->setVar('department', $_POST['newDept']);
        if ($hDepartments->insert($department)) {
            $deptID = $department->getVar('id');
            foreach ($groups as $group) {
                // Add new group permissions
                $hGroupPerm->addRight(_XHELP_GROUP_PERM_DEPT, $deptID, $group, $module_id);
            }
            // Set as default department?
            if (isset($_POST['defaultDept']) && $_POST['defaultDept'] == 1) {
                xhelpSetMeta("default_department", $deptID);
            }
            $hStaff =& xhelpGetHandler('staff');
            $allDeptStaff =& $hStaff->getByAllDepts();
            if (count($allDeptStaff) > 0) {
                $hMembership =& xhelpGetHandler('membership');
                if ($hMembership->addStaffToDept($allDeptStaff, $department->getVar('id'))) {
                    $message = _XHELP_MESSAGE_ADD_DEPT;
                } else {
                    $message = _AM_XHELP_MESSAGE_STAFF_UPDATE_ERROR;
                }
            } else {
                $message = _XHELP_MESSAGE_ADD_DEPT;
            }
            // Add configoption for new department
            $hConfig =& xoops_gethandler('config');
            $hConfigOption =& xoops_gethandler('configoption');
            $crit = new Criteria('conf_name', 'xhelp_defaultDept');
            $config =& $hConfig->getConfigs($crit);
            if (count($config) > 0) {
                $newOption =& $hConfigOption->create();
                $newOption->setVar('confop_name', $department->getVar('department'));
                $newOption->setVar('confop_value', $department->getVar('id'));
                $newOption->setVar('conf_id', $config[0]->getVar('conf_id'));
                if (!$hConfigOption->insert($newOption)) {
                    redirect_header(XHELP_ADMIN_URL . "/department.php?op=manageDepartments", 3, _AM_XHELP_MSG_ADD_CONFIG_ERR);
                }
            }
            _clearAddSessionVars();
            header("Location: " . XHELP_ADMIN_URL . "/department.php?op=manageDepartments");
        } else {
            $message = _XHELP_MESSAGE_ADD_DEPT_ERROR . $department->getHtmlErrors();
        }
        $deptID = $department->getVar('id');
        /* Not sure if this is needed. Already exists in if block above (ej)
           foreach($groups as $group){
           $hGroupPerm->addRight(_XHELP_GROUP_PERM_DEPT, $deptID, $group, $module_id);
           }
           */
        redirect_header(XHELP_ADMIN_URL . '/department.php?op=manageDepartments', 3, $message);
    } else {
        $hDepartments =& xhelpGetHandler('department');
        if ($dept_search == false) {
            $crit = new Criteria('', '');
        } else {
            $crit = new Criteria('department', "%{$dept_search}%", 'LIKE');
        }
        $crit->setOrder($order);
        $crit->setSort($sort);
        $crit->setLimit($limit);
        $crit->setStart($start);
        $total = $hDepartments->getCount($crit);
        $departmentInfo =& $hDepartments->getObjects($crit);
        $nav = new XoopsPageNav($total, $limit, $start, 'start', "op=manageDepartments&amp;limit={$limit}");
        // Get list of all groups
        $crit = new Criteria('', '');
        $crit->setSort('name');
        $crit->setOrder('ASC');
        $groups =& $hGroups->getObjects($crit, true);
        $aGroups = array();
        foreach ($groups as $group_id => $group) {
            $aGroups[$group_id] = $group->getVar('name');
        }
        asort($aGroups);
        // Set groups in alphabetical order
        xoops_cp_header();
        echo $oAdminButton->renderButtons('manDept');
        $session =& Session::singleton();
        $sess_dept = $session->get('xhelp_addDepartment');
        $sess_errors = $session->get('xhelp_addDepartmentErrors');
        //Display any form errors
        if (!$sess_errors === false) {
            xhelpRenderErrors($sess_errors, xhelpMakeURI(XHELP_ADMIN_URL . '/department.php', array('op' => 'clearAddSession'), false));
        }
        if (!$sess_dept === false) {
            $fld_newDept = $sess_dept['newDept'];
            $fld_groups = $sess_dept['groups'];
        } else {
            $fld_newDept = '';
            $fld_groups = array();
        }
        echo "<form method='post' action='" . XHELP_ADMIN_URL . "/department.php?op=manageDepartments'>";
        echo "<table width='100%' cellspacing='1' class='outer'>\r\n              <tr><th colspan='2'><label for='newDept'>" . _AM_XHELP_LINK_ADD_DEPT . " </label></th></tr>";
        echo "<tr><td class='head' width='20%' valign='top'>" . _AM_XHELP_TEXT_NAME . "</td><td class='even'>";
        echo "<input type='text' id='newDept' name='newDept' class='formButton' value='{$fld_newDept}' /></td></tr>";
        echo "<tr><td class='head' width='20%' valign='top'>" . _AM_XHELP_TEXT_EDIT_DEPT_PERMS . "</td><td class='even'>";
        echo "<select name='groups[]' multiple='multiple'>";
        foreach ($aGroups as $group_id => $group) {
            if (in_array($group_id, $fld_groups, true)) {
                echo "<option value='{$group_id}' selected='selected'>{$group}</option>";
            } else {
                echo "<option value='{$group_id}'>{$group}</option>";
            }
        }
        echo "</select></td></tr>";
        echo "<tr><td class='head' width='20%' valign='top'>" . _AM_XHELP_TEXT_DEFAULT_DEPT . "?</td>\r\n                  <td class='even'><input type='checkbox' name='defaultDept' id='defaultDept' value='1' /></td></tr>";
        echo "<tr><td class='foot' colspan='2'><input type='submit' name='addDept' value='" . _AM_XHELP_BUTTON_SUBMIT . "' class='formButton' /></td></tr>";
        echo "</table><br />";
        echo "</form>";
        if ($total > 0) {
            // Make sure there are departments
            echo "<form action='" . XHELP_ADMIN_URL . "/department.php?op=manageDepartments' style='margin:0; padding:0;' method='post'>";
            echo "<table width='100%' cellspacing='1' class='outer'>";
            echo "<tr><td align='right'>" . _AM_XHELP_BUTTON_SEARCH . "\r\n                          <input type='text' name='dept_search' value='{$dept_search}'/>\r\n                        &nbsp;&nbsp;&nbsp;\r\n                        " . _AM_XHELP_TEXT_SORT_BY . "\r\n                          <select name='sort'>";
            foreach ($aSortBy as $value => $text) {
                $sort == $value ? $selected = "selected='selected'" : ($selected = '');
                echo "<option value='{$value}' {$selected}>{$text}</option>";
            }
            echo "</select>\r\n                        &nbsp;&nbsp;&nbsp;\r\n                          " . _AM_XHELP_TEXT_ORDER_BY . "\r\n                          <select name='order'>";
            foreach ($aOrderBy as $value => $text) {
                $order == $value ? $selected = "selected='selected'" : ($selected = '');
                echo "<option value='{$value}' {$selected}>{$text}</option>";
            }
            echo "</select>\r\n                          &nbsp;&nbsp;&nbsp;\r\n                          " . _AM_XHELP_TEXT_NUMBER_PER_PAGE . "\r\n                          <select name='limit'>";
            foreach ($aLimitBy as $value => $text) {
                $limit == $value ? $selected = "selected='selected'" : ($selected = '');
                echo "<option value='{$value}' {$selected}>{$text}</option>";
            }
            echo "</select>\r\n                          <input type='submit' name='dept_sort' id='dept_sort' value='" . _AM_XHELP_BUTTON_SUBMIT . "' />\r\n                      </td>\r\n                  </tr>";
            echo "</table></form>";
            echo "<table width='100%' cellspacing='1' class='outer'>\r\n                  <tr><th colspan='4'>" . _AM_XHELP_EXISTING_DEPARTMENTS . "</th></tr>\r\n                  <tr><td class='head'>" . _AM_XHELP_TEXT_ID . "</td><td class='head'>" . _AM_XHELP_TEXT_DEPARTMENT . "</td><td class='head'>" . _AM_XHELP_TEXT_DEFAULT . "</td><td class='head'>" . _AM_XHELP_TEXT_ACTIONS . "</td></tr>";
            if (isset($departmentInfo)) {
                $defaultDept = xhelpGetMeta("default_department");
                foreach ($departmentInfo as $dept) {
                    echo "<tr><td class='even'>" . $dept->getVar('id') . "</td><td class='even'>" . $dept->getVar('department') . "</td>";
                    if ($dept->getVar('id') != $defaultDept) {
                        echo "<td class='even' width='10%'><a href='" . XHELP_ADMIN_URL . "/department.php?op=updateDefault&amp;id=" . $dept->getVar('id') . "'><img src='" . XHELP_IMAGE_URL . "/off.png' alt='" . _AM_XHELP_TEXT_MAKE_DEFAULT_DEPT . "' title='" . _AM_XHELP_TEXT_MAKE_DEFAULT_DEPT . "' /></a></td>";
                    } else {
                        echo "<td class='even' width='10%'><img src='" . XHELP_IMAGE_URL . "/on.png'</td>";
                    }
                    //echo "<td class='even' width='10%'><img src='".XHELP_IMAGE_URL."/". (($dept->getVar('id') == $defaultDept) ? "on.png" : "off.png")."'</td>";
                    echo "<td class='even' width='70'><a href='" . XHELP_ADMIN_URL . "/department.php?op=editDepartment&amp;deptid=" . $dept->getVar('id') . "'><img src='" . XOOPS_URL . "/modules/xhelp/images/button_edit.png' title='" . _AM_XHELP_TEXT_EDIT . "' name='editDepartment' /></a>&nbsp;&nbsp;";
                    echo "<a href='" . XHELP_ADMIN_URL . "/delete.php?deleteDept=1&amp;deptid=" . $dept->getVar('id') . "'><img src='" . XOOPS_URL . "/modules/xhelp/images/button_delete.png' title='" . _AM_XHELP_TEXT_DELETE . "' name='deleteDepartment' /></a></td></tr>";
                }
            }
        }
        echo "</td></tr></table>";
        echo "<div id='dept_nav'>" . $nav->renderNav() . "</div>";
        xhelpAdminFooter();
        xoops_cp_footer();
    }
}
コード例 #4
0
ファイル: status.php プロジェクト: trabisdementia/xuups
function manageStatus()
{
    global $oAdminButton, $aSortBy, $aOrderBy, $aLimitBy, $order, $limit, $start, $sort;
    $hStatus =& xhelpGetHandler('status');
    if (isset($_POST['changeDefaultStatus'])) {
        xhelpSetMeta("default_status", $_POST['default']);
    }
    if (isset($_POST['newStatus'])) {
        if ($_POST['desc'] == '') {
            // If no description supplied
            $message = _AM_XHELP_MESSAGE_NO_DESC;
            redirect_header(XHELP_ADMIN_URL . "/status.php?op=manageStatus", 3, $message);
        }
        $newStatus =& $hStatus->create();
        $newStatus->setVar('state', intval($_POST['state']));
        $newStatus->setVar('description', $_POST['desc']);
        if ($hStatus->insert($newStatus)) {
            header("Location: " . XHELP_ADMIN_URL . "/status.php?op=manageStatus");
        } else {
            $message = _AM_MESSAGE_ADD_STATUS_ERR;
            redirect_header(XHELP_ADMIN_URL . "/status.php?op=manageStatus", 3, $message);
        }
    }
    xoops_cp_header();
    echo $oAdminButton->renderButtons('manStatus');
    echo "<form method='post' action='" . XHELP_ADMIN_URL . "/status.php?op=manageStatus'>";
    echo "<table width='100%' cellspacing='1' class='outer'>\r\n          <tr><th colspan='2'><label>" . _AM_XHELP_TEXT_ADD_STATUS . "</label></th></tr>";
    echo "<tr><td class='head' width='20%'>" . _AM_XHELP_TEXT_DESCRIPTION . "</td>\r\n              <td class='even'>\r\n                  <input type='text' name='desc' value='' class='formButton' />\r\n              </td>\r\n          </tr>";
    echo "<tr><td class='head' width='20%'>" . _AM_XHELP_TEXT_STATE . "</td><td class='even'>\r\n              <select name='state'>\r\n              <option value='1'>" . xhelpGetState(1) . "</option>\r\n              <option value='2'>" . xhelpGetState(2) . "</option>\r\n          </select></td></tr>";
    echo "<tr><td class='foot' colspan='2'><input type='submit' name='newStatus' value='" . _AM_XHELP_TEXT_ADD_STATUS . "' class='formButton' /></td></tr>";
    echo "</table></form>";
    // Get list of existing statuses
    $crit = new Criteria('', '');
    $crit->setOrder($order);
    $crit->setSort($sort);
    $crit->setLimit($limit);
    $crit->setStart($start);
    $statuses =& $hStatus->getObjects($crit);
    $total = $hStatus->getCount($crit);
    $aStatuses = array();
    foreach ($statuses as $status) {
        $aStatuses[$status->getVar('id')] = $status->getVar('description');
    }
    if (!($default_status = xhelpGetMeta("default_status"))) {
        xhelpSetMeta("default_status", "1");
        $default_status = 1;
    }
    $form = new xhelpForm(_AM_XHELP_TEXT_DEFAULT_STATUS, 'default_status', xhelpMakeURI(XHELP_ADMIN_URL . '/status.php', array('op' => 'manageStatus')));
    $status_select = new XoopsFormSelect(_AM_XHELP_TEXT_STATUS, 'default', $default_status);
    $status_select->addOptionArray($aStatuses);
    $btn_tray = new XoopsFormElementTray('');
    $btn_tray->addElement(new XoopsFormButton('', 'changeDefaultStatus', _AM_XHELP_BUTTON_SUBMIT, 'submit'));
    $form->addElement($status_select);
    $form->addElement($btn_tray);
    $form->setLabelWidth('20%');
    echo $form->render();
    $nav = new XoopsPageNav($total, $limit, $start, 'start', "op=manageStatus&amp;limit={$limit}");
    echo "<form action='" . XHELP_ADMIN_URL . "/status.php?op=manageStatus' style='margin:0; padding:0;' method='post'>";
    echo "<table width='100%' cellspacing='1' class='outer'>";
    echo "<tr><td align='right'>" . _AM_XHELP_TEXT_SORT_BY . "\r\n                  <select name='sort'>";
    foreach ($aSortBy as $value => $text) {
        $sort == $value ? $selected = "selected='selected'" : ($selected = '');
        echo "<option value='{$value}' {$selected}>{$text}</option>";
    }
    echo "</select>\r\n                &nbsp;&nbsp;&nbsp;\r\n                  " . _AM_XHELP_TEXT_ORDER_BY . "\r\n                  <select name='order'>";
    foreach ($aOrderBy as $value => $text) {
        $order == $value ? $selected = "selected='selected'" : ($selected = '');
        echo "<option value='{$value}' {$selected}>{$text}</option>";
    }
    echo "</select>\r\n                  &nbsp;&nbsp;&nbsp;\r\n                  " . _AM_XHELP_TEXT_NUMBER_PER_PAGE . "\r\n                  <select name='limit'>";
    foreach ($aLimitBy as $value => $text) {
        $limit == $value ? $selected = "selected='selected'" : ($selected = '');
        echo "<option value='{$value}' {$selected}>{$text}</option>";
    }
    echo "</select>\r\n                  <input type='submit' name='status_sort' id='status_sort' value='" . _AM_XHELP_BUTTON_SUBMIT . "' />\r\n              </td>\r\n          </tr>";
    echo "</table></form>";
    echo "<table width='100%' cellspacing='1' class='outer'>\r\n          <tr><th colspan='4'><label>" . _AM_XHELP_TEXT_MANAGE_STATUSES . "</label></th></tr>";
    echo "<tr class='head'>\r\n              <td>" . _AM_XHELP_TEXT_ID . "</td>\r\n              <td>" . _AM_XHELP_TEXT_DESCRIPTION . "</td>\r\n              <td>" . _AM_XHELP_TEXT_STATE . "</td>\r\n              <td>" . _AM_XHELP_TEXT_ACTIONS . "</td>\r\n          </tr>";
    foreach ($statuses as $status) {
        echo "<tr class='even'><td>" . $status->getVar('id') . "</td><td>" . $status->getVar('description') . "</td>\r\n              <td>" . xhelpGetState($status->getVar('state')) . "</td>\r\n              <td>\r\n                  <a href='status.php?op=editStatus&amp;statusid=" . $status->getVar('id') . "'><img src='" . XHELP_IMAGE_URL . "/button_edit.png' title='" . _AM_XHELP_TEXT_EDIT . "' name='editStatus' /></a>&nbsp;\r\n                  <a href='status.php?op=deleteStatus&amp;statusid=" . $status->getVar('id') . "'><img src='" . XHELP_IMAGE_URL . "/button_delete.png' title='" . _AM_XHELP_TEXT_DELETE . "' name='deleteStatus' /></a></td></tr>\r\n              </td></tr>";
    }
    echo "</table>";
    echo "<div id='status_nav'>" . $nav->renderNav() . "</div>";
    xhelpAdminFooter();
    xoops_cp_footer();
}
コード例 #5
0
ファイル: mimetypes.php プロジェクト: trabisdementia/xuups
function search()
{
    global $oAdminButton, $hMime, $limit, $start, $imagearray, $aSearchBy, $aOrderBy, $aLimitBy, $aSortBy;
    if (isset($_POST['deleteMimes'])) {
        $aMimes = $_POST['mimes'];
        $crit = new Criteria('mime_id', "(" . implode($aMimes, ',') . ")", "IN");
        if ($hMime->deleteAll($crit)) {
            header("Location: " . XHELP_ADMIN_URL . "/mimetypes.php?limit={$limit}&start={$start}");
        } else {
            redirect_header(XHELP_ADMIN_URL . "/mimetypes.php?limit={$limit}&start={$start}", 3, _AM_XHELP_MESSAGE_DELETE_MIME_ERROR);
        }
    }
    if (isset($_POST['add_mime'])) {
        header("Location: " . XHELP_ADMIN_URL . "/mimetypes.php?op=add&start={$start}&limit={$limit}");
        exit;
    }
    if (isset($_REQUEST['order'])) {
        $order = $_REQUEST['order'];
    } else {
        $order = "ASC";
    }
    if (isset($_REQUEST['sort'])) {
        $sort = $_REQUEST['sort'];
    } else {
        $sort = "mime_name";
    }
    xoops_cp_header();
    echo $oAdminButton->renderButtons('mimetypes');
    if (!isset($_REQUEST['mime_search'])) {
        echo "<form action='mimetypes.php?op=search' method='post'>";
        echo "<table width='100%' cellspacing='1' class='outer'>";
        echo "<tr><th colspan='2'>" . _AM_XHELP_TEXT_SEARCH_MIME . "</th></tr>";
        echo "<tr><td class='head' width='20%'>" . _AM_XHELP_TEXT_SEARCH_BY . "</td>\r\n                  <td class='even'>\r\n                      <select name='search_by'>";
        foreach ($aSortBy as $value => $text) {
            echo "<option value='{$value}'>{$text}</option>";
        }
        echo "</select>\r\n                  </td>\r\n              </tr>";
        echo "<tr><td class='head'>" . _AM_XHELP_TEXT_SEARCH_TEXT . "</td>\r\n                  <td class='even'>\r\n                      <input type='text' name='search_text' id='search_text' value='' />\r\n                  </td>\r\n              </tr>";
        echo "<tr class='foot'>\r\n                  <td colspan='2'>\r\n                      <input type='submit' name='mime_search' id='mime_search' value='" . _AM_XHELP_BUTTON_SEARCH . "' />\r\n                  </td>\r\n              </tr>";
        echo "</table></form>";
    } else {
        $search_field = $_REQUEST['search_by'];
        $search_text = $_REQUEST['search_text'];
        $crit = new Criteria($search_field, "%{$search_text}%", 'LIKE');
        $crit->setSort($sort);
        $crit->setOrder($order);
        $crit->setLimit($limit);
        $crit->setStart($start);
        $mime_count =& $hMime->getCount($crit);
        $mimetypes =& $hMime->getObjects($crit);
        $nav = new XoopsPageNav($mime_count, $limit, $start, 'start', "op=search&amp;limit={$limit}&amp;order={$order}&amp;sort={$sort}&amp;mime_search=1&amp;search_by={$search_field}&amp;search_text={$search_text}");
        // Display results
        echo '<script type="text/javascript" src="' . XHELP_BASE_URL . '/include/functions.js"></script>';
        echo "<table width='100%' cellspacing='1' class='outer'>";
        echo "<tr><td colspan='6' align='right'>";
        echo "<form action='" . XHELP_ADMIN_URL . "/mimetypes.php?op=search' style='margin:0; padding:0;' method='post'>";
        echo "<table>";
        echo "<tr>";
        echo "<td align='right'>" . _AM_XHELP_TEXT_SEARCH_BY . "</td>";
        echo "<td align='left'><select name='search_by'>";
        foreach ($aSearchBy as $value => $text) {
            $search_field == $value ? $selected = "selected='selected'" : ($selected = '');
            echo "<option value='{$value}' {$selected}>{$text}</option>";
        }
        echo "</select></td>";
        echo "<td align='right'>" . _AM_XHELP_TEXT_SEARCH_TEXT . "</td>";
        echo "<td align='left'><input type='text' name='search_text' id='search_text' value='{$search_text}' /></td>";
        echo "<td><input type='submit' name='mime_search' id='mime_search' value='" . _AM_XHELP_BUTTON_SEARCH . "' /></td>";
        echo "</tr></table></form></td></tr>";
        echo "<tr><td colspan='6'>";
        echo "<form action='" . XHELP_ADMIN_URL . "/mimetypes.php?op=search' style='margin:0; padding:0;' method='post'>";
        echo "<table width='100%'>";
        echo "<tr><td align='right'>" . _AM_XHELP_TEXT_SORT_BY . "\r\n                  <select name='sort'>";
        foreach ($aSortBy as $value => $text) {
            $sort == $value ? $selected = "selected='selected'" : ($selected = '');
            echo "<option value='{$value}' {$selected}>{$text}</option>";
        }
        echo "</select>\r\n                &nbsp;&nbsp;&nbsp;\r\n                  " . _AM_XHELP_TEXT_ORDER_BY . "\r\n                  <select name='order'>";
        foreach ($aOrderBy as $value => $text) {
            $order == $value ? $selected = "selected='selected'" : ($selected = '');
            echo "<option value='{$value}' {$selected}>{$text}</option>";
        }
        echo "</select>\r\n                  &nbsp;&nbsp;&nbsp;\r\n                  " . _AM_XHELP_TEXT_NUMBER_PER_PAGE . "\r\n                  <select name='limit'>";
        foreach ($aLimitBy as $value => $text) {
            $limit == $value ? $selected = "selected='selected'" : ($selected = '');
            echo "<option value='{$value}' {$selected}>{$text}</option>";
        }
        echo "</select>\r\n                  <input type='submit' name='mime_sort' id='mime_sort' value='" . _AM_XHELP_BUTTON_SUBMIT . "' />\r\n                  <input type='hidden' name='mime_search' id='mime_search' value='1' />\r\n                  <input type='hidden' name='search_by' id='search_by' value='{$search_field}' />\r\n                  <input type='hidden' name='search_text' id='search_text' value='{$search_text}' />\r\n              </td>\r\n          </tr>";
        echo "</table>";
        echo "</td></tr>";
        if (count($mimetypes) > 0) {
            echo "<tr><th colspan='6'>" . _AM_XHELP_TEXT_SEARCH_MIME . "</th></tr>";
            echo "<tr class='head'>\r\n                      <td>" . _AM_XHELP_MIME_ID . "</td>\r\n                      <td>" . _AM_XHELP_MIME_NAME . "</td>\r\n                      <td>" . _AM_XHELP_MIME_EXT . "</td>\r\n                      <td>" . _AM_XHELP_MIME_ADMIN . "</td>\r\n                      <td>" . _AM_XHELP_MIME_USER . "</td>\r\n                      <td>" . _AM_XHELP_MINDEX_ACTION . "</td>\r\n                  </tr>";
            foreach ($mimetypes as $mime) {
                echo "<tr class='even'>\r\n                          <td><input type='checkbox' name='mimes[]' value='" . $mime->getVar('mime_id') . "' />" . $mime->getVar('mime_id') . "</td>\r\n                          <td>" . $mime->getVar('mime_name') . "</td>\r\n                          <td>" . $mime->getVar('mime_ext') . "</td>\r\n                          <td>\r\n                              <a href='" . XHELP_ADMIN_URL . "/mimetypes.php?op=updateMimeValue&amp;id=" . $mime->getVar('mime_id') . "&amp;mime_admin=" . $mime->getVar('mime_admin') . "&amp;limit=" . $limit . "&amp;start=" . $start . "'>\r\n                              " . ($mime->getVar('mime_admin') ? $imagearray['online'] : $imagearray['offline']) . "</a>\r\n                          </td>\r\n                          <td>\r\n                              <a href='" . XHELP_ADMIN_URL . "/mimetypes.php?op=updateMimeValue&amp;id=" . $mime->getVar('mime_id') . "&amp;mime_user="******"&amp;limit=" . $limit . "&amp;start=" . $start . "'>\r\n                              " . ($mime->getVar('mime_user') ? $imagearray['online'] : $imagearray['offline']) . "</a>\r\n                          </td>\r\n                          <td>\r\n                              <a href='" . XHELP_ADMIN_URL . "/mimetypes.php?op=edit&amp;id=" . $mime->getVar('mime_id') . "&amp;limit=" . $limit . "&amp;start=" . $start . "'>" . $imagearray['editimg'] . "</a>\r\n                              <a href='" . XHELP_ADMIN_URL . "/mimetypes.php?op=delete&amp;id=" . $mime->getVar('mime_id') . "&amp;limit=" . $limit . "&amp;start=" . $start . "'>" . $imagearray['deleteimg'] . "</a>\r\n                          </td>\r\n                      </tr>";
            }
            echo "<tr class='foot'>\r\n                      <td colspan='6' valign='top'>\r\n                          <a href='http://www.filext.com' style='float: right' target='_blank'>" . _AM_XHELP_MIME_FINDMIMETYPE . "</a>\r\n                          <input type='checkbox' name='checkAllMimes' value='0' onclick='selectAll(this.form,\"mimes[]\",this.checked);' />\r\n                          <input type='submit' name='deleteMimes' id='deleteMimes' value='" . _AM_XHELP_BUTTON_DELETE . "' />\r\n                          <input type='submit' name='add_mime' id='add_mime' value='" . _AM_XHELP_MIME_CREATEF . "' class='formButton' />\r\n                      </td>\r\n                  </tr>";
        } else {
            echo "<tr><th>" . _AM_XHELP_TEXT_SEARCH_MIME . "</th></tr>";
            echo "<tr class='even'>\r\n                      <td>" . _AM_XHELP_TEXT_NO_RECORDS . "</td>\r\n                  </tr>";
        }
        echo "</table>";
        echo "<div id='pagenav'>" . $nav->renderNav() . "</div>";
    }
    xhelpAdminFooter();
    xoops_cp_footer();
}
コード例 #6
0
ファイル: upgrade.php プロジェクト: trabisdementia/xuups
function upgradeDB()
{
    global $xoopsModule, $oAdminButton;
    $xoopsDB =& Database::getInstance();
    //1. Determine previous release
    //   *** Update this in sql/mysql.sql for each release **
    if (!xhelpTableExists('xhelp_meta')) {
        $ver = '0.5';
    } else {
        if (!($ver = xhelpGetMeta('version'))) {
            exit(_AM_XHELP_VERSION_ERR);
        }
    }
    $hStaff =& xhelpGetHandler('staff');
    $hMember =& xhelpGetHandler('membership');
    $hTicket =& xhelpGetHandler('ticket');
    $hXoopsMember =& xoops_gethandler('member');
    $hRole =& xhelpGetHandler('role');
    $mid = $xoopsModule->getVar('mid');
    xoops_cp_header();
    echo $oAdminButton->renderButtons('');
    echo "<h2>" . _AM_XHELP_UPDATE_DB . "</h2>";
    $ret = true;
    //2. Do All Upgrades necessary to make current
    //   Break statements are omitted on purpose
    switch ($ver) {
        case '0.5':
            set_time_limit(60);
            printf("<h3>" . _AM_XHELP_UPDATE_TO . "</h3>", '0.6');
            echo "<ul>";
            //Create meta table
            $ret = $ret && _runQuery(sprintf("CREATE TABLE %s (metakey varchar(50) NOT NULL default '', metavalue varchar(255) NOT NULL default '', PRIMARY KEY (metakey)) ENGINE=MyISAM;", $xoopsDB->prefix('xhelp_meta')), sprintf(_AM_XHELP_MSG_ADDTABLE, 'xhelp_meta'), sprintf(_AM_XHELP_MSG_ADDTABLE_ERR, 'xhelp_meta'));
            //Insert Current Version into table
            $qry = $xoopsDB->query(sprintf("INSERT INTO %s values('version', %s)", $xoopsDB->prefix('xhelp_meta'), $xoopsDB->quoteString($ver)));
            //Update xhelp_responses table
            $ret = $ret && _runQuery(sprintf("ALTER TABLE %s ADD private INT(11) NOT NULL DEFAULT '0'", $xoopsDB->prefix('xhelp_responses')), sprintf(_AM_XHELP_MSG_MODIFYTABLE, 'xhelp_responses'), sprintf(_AM_XHELP_MSG_MODIFYTABLE_ERR, 'xhelp_responses'));
            //Retrieve uid's of all staff members
            $qry = $xoopsDB->query('SELECT uid FROM ' . $xoopsDB->prefix('xhelp_staff') . ' ORDER BY uid');
            //Get email addresses in user profile
            $staff = array();
            while ($arr = $xoopsDB->fetchArray($qry)) {
                $staff[$arr['uid']] = '';
            }
            $xoopsDB->freeRecordSet($qry);
            $query = 'SELECT uid, email FROM ' . $xoopsDB->prefix('users') . ' WHERE uid IN (' . implode(array_keys($staff), ',') . ')';
            $qry = $xoopsDB->query($query);
            while ($arr = $xoopsDB->fetchArray($qry)) {
                $staff[$arr['uid']] = $arr['email'];
            }
            $xoopsDB->freeRecordSet($qry);
            //Update xhelp_staff table
            $ret = $ret && _runQuery(sprintf("ALTER TABLE %s ADD email varchar(255) NOT NULL default '' AFTER uid, ADD notify int(11) NOT NULL default '0'", $xoopsDB->prefix('xhelp_staff')), sprintf(_AM_XHELP_MSG_MODIFYTABLE, 'xhelp_staff'), sprintf(_AM_XHELP_MSG_MODIFYTABLE_ERR, 'xhelp_staff'));
            //Update existing staff records
            $staff_tbl = $xoopsDB->prefix('xhelp_staff');
            $notif_tbl = $xoopsDB->prefix('xoopsnotifications');
            $email_tpl = $xoopsModule->getInfo('_email_tpl');
            foreach ($staff as $uid => $email) {
                //get notifications for current user
                $usernotif = 0;
                $qry = $xoopsDB->query(sprintf("SELECT DISTINCT not_category, not_event FROM %s WHERE not_uid = %u AND not_category='dept' AND not_modid=%u", $notif_tbl, $uid, $mid));
                while ($arr = $xoopsDB->fetchArray($qry)) {
                    //Look for current event information in $email_tpl
                    foreach ($email_tpl as $tpl) {
                        if ($tpl['name'] == $arr['not_event'] && $tpl['category'] == $arr['not_category']) {
                            $usernotif = $usernotif | pow(2, $tpl['bit_value']);
                            break;
                        }
                    }
                }
                //Update xhelp_staff with user notifications & email address
                $ret = $ret && _runQuery(sprintf("UPDATE %s SET email = %s, notify = %u WHERE uid = %u", $staff_tbl, $xoopsDB->quoteString($email), $usernotif, $uid), sprintf(_AM_XHELP_MSG_UPDATESTAFF, $uid), sprintf(_AM_XHELP_MSG_UPDATESTAFF_ERR, $uid));
            }
            echo "</ul>";
        case '0.6':
            set_time_limit(60);
            //Do DB updates to make 0.7
            printf("<h3>" . _AM_XHELP_UPDATE_TO . "</h3>", '0.7');
            echo "<ul>";
            // change table names to lowercase
            $ret = $ret && _renameTable('xhelp_logMessages', 'xhelp_logmessages');
            $ret = $ret && _renameTable('xhelp_responseTemplates', 'xhelp_responsetemplates');
            $ret = $ret && _renameTable('xhelp_jStaffDept', 'xhelp_jstaffdept');
            $ret = $ret && _renameTable('xhelp_staffReview', 'xhelp_staffreview');
            $ret = $ret && _renameTable('xhelp_emailTpl', 'xhelp_emailtpl');
            // Remove unused table - xhelp_emailtpl
            $ret = $ret && _runQuery(sprintf("DROP TABLE %s", $xoopsDB->prefix('xhelp_emailtpl')), sprintf(_AM_XHELP_MSG_REMOVE_TABLE, 'xhelp_emailtpl'), sprintf(_AM_XHELP_MSG_NOT_REMOVE_TABLE, 'xhelp_emailtpl'));
            // xhelp_staff table - permTimestamp
            $ret = $ret && _runQuery(sprintf("ALTER TABLE %s ADD permTimestamp INT(11) NOT NULL DEFAULT '0'", $xoopsDB->prefix('xhelp_staff')), sprintf(_AM_XHELP_MSG_MODIFYTABLE, 'xhelp_staff'), sprintf(_AM_XHELP_MSG_MODIFYTABLE_ERR, 'xhelp_staff'));
            //Update xhelp_tickets table
            $ret = $ret && _runQuery(sprintf("ALTER TABLE %s MODIFY subject VARCHAR(100) NOT NULL default ''", $xoopsDB->prefix('xhelp_tickets')), sprintf(_AM_XHELP_MSG_MODIFYTABLE, 'xhelp_tickets'), sprintf(_AM_XHELP_MSG_MODIFYTABLE_ERR, 'xhelp_tickets'));
            $ret = $ret && _runQuery(sprintf("ALTER TABLE %s ADD (serverid INT(11) DEFAULT NULL,\r\n                                                             emailHash VARCHAR(100) DEFAULT NULL,\r\n                                                             email VARCHAR(100) DEFAULT NULL,\r\n                                                             overdueTime INT(11) NOT NULL DEFAULT '0',\r\n                                                             KEY emailHash (emailHash))", $xoopsDB->prefix('xhelp_tickets')), sprintf(_AM_XHELP_MSG_MODIFYTABLE, 'xhelp_tickets'), sprintf(_AM_XHELP_MSG_MODIFYTABLE_ERR, 'xhelp_tickets'));
            // Create xhelp_department_mailbox table
            $ret = $ret && _runQuery(sprintf("CREATE TABLE %s (id int(11) NOT NULL auto_increment,\r\n                                                          departmentid int(11) default NULL,\r\n                                                          emailaddress varchar(255) default NULL,\r\n                                                          server varchar(50) default NULL,\r\n                                                          serverport int(11) default NULL,\r\n                                                          username varchar(50) default NULL,\r\n                                                          password varchar(50) default NULL,\r\n                                                          priority tinyint(4) default NULL,\r\n                                                          mboxtype int(11) NOT NULL default 1,\r\n                                                          PRIMARY KEY  (id),\r\n                                                          UNIQUE KEY id (id),\r\n                                                          KEY departmentid (departmentid),\r\n                                                          KEY emailaddress (emailaddress),\r\n                                                          KEY mboxtype (mboxtype)\r\n                                                         )ENGINE=MyISAM;", $xoopsDB->prefix('xhelp_department_mailbox')), sprintf(_AM_XHELP_MSG_ADDTABLE, 'xhelp_department_mailbox'), sprintf(_AM_XHELP_MSG_ADDTABLE_ERR, 'xhelp_department_mailbox'));
            // Create xhelp_mailevent table
            $ret = $ret && _runQuery(sprintf("CREATE TABLE %s (id int(11) NOT NULL auto_increment,\r\n                                                           mbox_id int(11) NOT NULL default '0',\r\n                                                           event_desc text,\r\n                                                           event_class int(11) NOT NULL default '0',\r\n                                                           posted int(11) NOT NULL default '0',\r\n                                                           PRIMARY KEY(id)\r\n                                                          )ENGINE=MyISAM;", $xoopsDB->prefix('xhelp_mailevent')), sprintf(_AM_XHELP_MSG_ADDTABLE, 'xhelp_mailevent'), sprintf(_AM_XHELP_MSG_ADDTABLE_ERR, 'xhelp_mailevent'));
            // Create xhelp_roles table
            $ret = $ret && _runQuery(sprintf("CREATE TABLE %s (id int(11) NOT NULL auto_increment,\r\n                                                          name varchar(35) NOT NULL default '',\r\n                                                          description mediumtext,\r\n                                                          tasks int(11) NOT NULL default '0',\r\n                                                          PRIMARY KEY(id)\r\n                                                         )ENGINE=MyISAM;", $xoopsDB->prefix('xhelp_roles')), sprintf(_AM_XHELP_MSG_ADDTABLE, 'xhelp_roles'), sprintf(_AM_XHELP_MSG_ADDTABLE_ERR, 'xhelp_roles'));
            // Create xhelp_staffroles table
            $ret = $ret && _runQuery(sprintf("CREATE TABLE %s (uid int(11) NOT NULL default '0',\r\n                                                         roleid int(11) NOT NULL default '0',\r\n                                                         deptid int(11) NOT NULL default '0',\r\n                                                         PRIMARY KEY(uid, roleid, deptid)\r\n                                                        )ENGINE=MyISAM;", $xoopsDB->prefix('xhelp_staffroles')), sprintf(_AM_XHELP_MSG_ADDTABLE, 'xhelp_staffroles'), sprintf(_AM_XHELP_MSG_ADDTABLE_ERR, 'xhelp_staffroles'));
            // Add default roles to db
            if (!($hasRoles = xhelpCreateRoles())) {
                echo "<li>" . _AM_XHELP_MESSAGE_DEF_ROLES_ERROR . "</li>";
            } else {
                echo "<li>" . _AM_XHELP_MESSAGE_DEF_ROLES . "</li>";
            }
            // Set all staff members to have admin permission role
            if ($staff =& $hStaff->getObjects()) {
                foreach ($staff as $stf) {
                    $uid = $stf->getVar('uid');
                    $depts = $hMember->membershipByStaff($uid, true);
                    if ($hStaff->addStaffRole($uid, 1, 0)) {
                        echo "<li>" . sprintf(_AM_XHELP_MSG_GLOBAL_PERMS, $uid) . "</li>";
                    }
                    foreach ($depts as $dept) {
                        $deptid = $dept->getVar('id');
                        if ($hStaff->addStaffRole($uid, 1, $deptid)) {
                            // Departmental permissions
                            echo "<li>" . sprintf(_AM_XHELP_MSG_UPD_PERMS, $uid, $dept->getVar('department')) . "</li>";
                        }
                    }
                    $stf->setVar('permTimestamp', time());
                    // Set initial value for permTimestamp field
                    if (!$hStaff->insert($stf)) {
                        echo "<li>" . sprintf(_AM_XHELP_MSG_UPDATESTAFF_ERR, $uid) . "</li>";
                    } else {
                        echo "<li>" . sprintf(_AM_XHELP_MSG_UPDATESTAFF, $uid) . "</li>";
                    }
                }
            }
            echo "</ul>";
        case '0.7':
            set_time_limit(60);
            //Do DB updates to make 0.71
            printf("<h3>" . _AM_XHELP_UPDATE_TO . "</h3>", '0.71');
            echo "<ul>";
            echo "</ul>";
        case '0.71':
            set_time_limit(60);
            //Do DB updates to make 0.75
            printf("<h3>" . _AM_XHELP_UPDATE_TO . "</h3>", '0.75');
            echo "<ul>";
            //Changes for php5 compabibility
            $ret = $ret && _runQuery(sprintf("ALTER TABLE %s MODIFY lastUpdated int(11) NOT NULL default '0'", $xoopsDB->prefix('xhelp_logmessages')), sprintf(_AM_XHELP_MSG_MODIFYTABLE, 'xhelp_logmessages'), sprintf(_AM_XHELP_MSG_MODIFYTABLE_ERR, 'xhelp_logmessages'));
            $ret = $ret && _runQuery(sprintf("ALTER TABLE %s MODIFY department int(11) NOT NULL default '0'", $xoopsDB->prefix('xhelp_jstaffdept')), sprintf(_AM_XHELP_MSG_MODIFYTABLE, 'xhelp_jstaffdept'), sprintf(_AM_XHELP_MSG_MODIFYTABLE_ERR, 'xhelp_jstaffdept'));
            // Create table for email template information
            $ret = $ret && _runQuery(sprintf("CREATE TABLE %s (notif_id int(11) NOT NULL default '0',\r\n                                                           staff_setting int(11) NOT NULL default '0',\r\n                                                           user_setting int(11) NOT NULL default '0',\r\n                                                           staff_options mediumtext NOT NULL,\r\n                                                           PRIMARY KEY (notif_id)\r\n                                                          )ENGINE=MyISAM;", $xoopsDB->prefix('xhelp_notifications')), sprintf(_AM_XHELP_MSG_ADDTABLE, 'xhelp_notifications'), sprintf(_AM_XHELP_MSG_ADDTABLE_ERR, 'xhelp_notifications'));
            // Add xhelp_status table
            $ret = $ret && _runQuery(sprintf("CREATE TABLE %s (id int(11) NOT NULL auto_increment,\r\n                                                           state int(11) NOT NULL default '0',\r\n                                                           description varchar(50) NOT NULL default '',\r\n                                                           PRIMARY KEY(id),\r\n                                                           KEY state (state)\r\n                                                          )ENGINE=MyISAM;", $xoopsDB->prefix('xhelp_status')), sprintf(_AM_XHELP_MSG_ADDTABLE, 'xhelp_status'), sprintf(_AM_XHELP_MSG_ADDTABLE_ERR, 'xhelp_status'));
            // Give default statuses for upgrade
            $hStatus =& xhelpGetHandler('status');
            $startStatuses = array(_XHELP_STATUS0 => 1, _XHELP_STATUS1 => 1, _XHELP_STATUS2 => 2);
            $count = 1;
            set_time_limit(60);
            foreach ($startStatuses as $desc => $state) {
                $newStatus =& $hStatus->create();
                $newStatus->setVar('id', $count);
                $newStatus->setVar('description', $desc);
                $newStatus->setVar('state', $state);
                if (!$hStatus->insert($newStatus)) {
                    echo "<li>" . sprintf(_AM_XHELP_MSG_ADD_STATUS_ERR, $desc) . "</li>";
                } else {
                    echo "<li>" . sprintf(_AM_XHELP_MSG_ADD_STATUS, $desc) . "</li>";
                }
                $count++;
            }
            // Change old status values to new status values
            $oldStatuses = array(2 => 3, 1 => 2, 0 => 1);
            foreach ($oldStatuses as $cStatus => $newStatus) {
                $crit = new Criteria('status', $cStatus);
                $success = $hTicket->updateAll('status', $newStatus, $crit);
            }
            if ($success) {
                echo "<li>" . _AM_XHELP_MSG_CHANGED_STATUS . "</li>";
            } else {
                echo "<li>" . _AM_XHELP_MSG_CHANGED_STATUS_ERR . "</li>";
            }
            // Add xhelp_ticket_submit_emails table
            $ret = $ret && _runQuery(sprintf("CREATE TABLE %s (ticketid int(11) NOT NULL default '0',\r\n                                                           uid int(11) NOT NULL default '0',\r\n                                                           email varchar(100) NOT NULL default '',\r\n                                                           suppress int(11) NOT NULL default '0',\r\n                                                           PRIMARY KEY(ticketid, email)\r\n                                                          )ENGINE=MyISAM;", $xoopsDB->prefix('xhelp_ticket_submit_emails')), sprintf(_AM_XHELP_MSG_ADDTABLE, 'xhelp_ticket_submit_emails'), sprintf(_AM_XHELP_MSG_ADDTABLE_ERR, 'xhelp_ticket_submit_emails'));
            // Add records to xhelp_ticket_submit_emails for existing tickets
            $count = $hTicket->getCount();
            $batchsize = 100;
            $crit = new Criteria('', '');
            $crit->setLimit($batchsize);
            $i = 0;
            while ($i <= $count) {
                set_time_limit(60);
                $crit->setStart($i);
                $tickets =& $hTicket->getObjects($crit);
                $all_users = array();
                foreach ($tickets as $ticket) {
                    $all_users[$ticket->getVar('uid')] = $ticket->getVar('uid');
                }
                $crit = new Criteria('uid', "(" . implode(array_keys($all_users), ',') . ")", 'IN');
                $users =& $hXoopsMember->getUsers($crit, true);
                foreach ($users as $user) {
                    $all_users[$user->getVar('uid')] = $user->getVar('email');
                }
                unset($users);
                foreach ($tickets as $ticket) {
                    set_time_limit(60);
                    $ticket_uid = $ticket->getVar('uid');
                    if (array_key_exists($ticket_uid, $all_users)) {
                        $ticket_email = $all_users[$ticket_uid];
                        $success = $ticket->addSubmitter($ticket_email, $ticket_uid);
                    }
                }
                unset($tickets);
                //increment
                $i += $batchsize;
            }
            set_time_limit(60);
            // Update xhelp_roles Admin record with new value (2047)
            $crit = new Criteria('tasks', 511);
            $admin_roles =& $hRole->getObjects($crit);
            foreach ($admin_roles as $role) {
                $role->setVar('tasks', 2047);
                if ($hRole->insert($role)) {
                    echo "<li>" . sprintf(_AM_XHELP_MSG_UPDATE_ROLE, $role->getVar('name')) . "</li>";
                } else {
                    echo "<li>" . sprintf(_AM_XHELP_MSG_UPDATE_ROLE_ERR, $role->getVar('name')) . "</li>";
                }
            }
            set_time_limit(60);
            $ret = $ret && _runQuery(sprintf("ALTER TABLE %s ADD (active INT(11) NOT NULL DEFAULT 1,\r\n                                                          KEY active (active))", $xoopsDB->prefix('xhelp_department_mailbox')), sprintf(_AM_XHELP_MSG_MODIFYTABLE, 'xhelp_department_mailbox'), sprintf(_AM_XHELP_MSG_MODIFYTABLE_ERR, 'xhelp_department_mailbox'));
            // Add xhelp_saved_searches table
            $ret = $ret && _runQuery(sprintf("CREATE TABLE %s (id int(11) NOT NULL auto_increment,\r\n                                                           uid int(11) NOT NULL default '0',\r\n                                                           name varchar(50) NOT NULL default '',\r\n                                                           search mediumtext NOT NULL,\r\n                                                           pagenav_vars mediumtext NOT NULL,\r\n                                                           PRIMARY KEY(id)\r\n                                                          )ENGINE=MyISAM;", $xoopsDB->prefix('xhelp_saved_searches')), sprintf(_AM_XHELP_MSG_ADDTABLE, 'xhelp_saved_searches'), sprintf(_AM_XHELP_MSG_ADDTABLE_ERR, 'xhelp_saved_searches'));
            set_time_limit(60);
            $ret = $ret && _runQuery(sprintf("CREATE TABLE %s (fieldid int(11) NOT NULL default '0',\r\n                                                           deptid int(11) NOT NULL default '0',\r\n                                                           PRIMARY KEY  (fieldid, deptid)\r\n                                                          )ENGINE=MyISAM;", $xoopsDB->prefix('xhelp_ticket_field_departments')), sprintf(_AM_XHELP_MSG_ADDTABLE, 'xhelp_ticket_field_departments'), sprintf(_AM_XHELP_MSG_ADDTABLE_ERR, 'xhelp_ticket_field_departments'));
            $ret = $ret && _runQuery(sprintf("CREATE TABLE %s (ticketid int(11) NOT NULL default '0',\r\n                                                           PRIMARY KEY  (ticketid)\r\n                                                          )ENGINE=MyISAM;", $xoopsDB->prefix('xhelp_ticket_values')), sprintf(_AM_XHELP_MSG_ADDTABLE, 'xhelp_ticket_values'), sprintf(_AM_XHELP_MSG_ADDTABLE_ERR, 'xhelp_ticket_values'));
            set_time_limit(60);
            $ret = $ret && _runQuery(sprintf("CREATE TABLE %s (id int(11) NOT NULL auto_increment,\r\n                                                           name varchar(64) NOT NULL default '',\r\n                                                           description tinytext NOT NULL,\r\n                                                           fieldname varchar(64) NOT NULL default '',\r\n                                                           controltype int(11) NOT NULL default '0',\r\n                                                           datatype varchar(64) NOT NULL default '',\r\n                                                           required tinyint(1) NOT NULL default '0',\r\n                                                           fieldlength int(11) NOT NULL default '0',\r\n                                                           weight int(11) NOT NULL default '0',\r\n                                                           fieldvalues mediumtext NOT NULL,\r\n                                                           defaultvalue varchar(100) NOT NULL default '',\r\n                                                           validation mediumtext NOT NULL,\r\n                                                           PRIMARY KEY (id),\r\n                                                           KEY weight (weight)\r\n                                                          )ENGINE=MyISAM;", $xoopsDB->prefix('xhelp_ticket_fields')), sprintf(_AM_XHELP_MSG_ADDTABLE, 'xhelp_ticket_fields'), sprintf(_AM_XHELP_MSG_ADDTABLE_ERR, 'xhelp_ticket_fields'));
            set_time_limit(60);
            // Add notifications to new table
            set_time_limit(60);
            $hasNotifications = xhelpCreateNotifications();
            // Make all departments visible to all groups
            $hasDeptVisibility = xhelpCreateDepartmentVisibility();
            // Update staff permTimestamp
            $hStaff->updateAll('permTimestamp', time());
            set_time_limit(60);
            //Update xhelp_tickets table
            set_time_limit(60);
            $ret = $ret && _runQuery(sprintf("ALTER TABLE %s MODIFY subject VARCHAR(255) NOT NULL default ''", $xoopsDB->prefix('xhelp_tickets')), sprintf(_AM_XHELP_MSG_MODIFYTABLE, 'xhelp_tickets'), sprintf(_AM_XHELP_MSG_MODIFYTABLE_ERR, 'xhelp_tickets'));
        case '0.75':
            set_time_limit(60);
            // Set default department
            $xoopsModuleConfig =& xhelpGetModuleConfig();
            if (isset($xoopsModuleConfig['xhelp_defaultDept']) && $xoopsModuleConfig['xhelp_defaultDept'] != 0) {
                $ret = xhelpSetMeta('default_department', $xoopsModuleConfig['xhelp_defaultDept']);
            } else {
                $hDepartments =& xhelpGetHandler('department');
                $depts =& $hDepartments->getObjects();
                $aDepts = array();
                foreach ($depts as $dpt) {
                    $aDepts[] = $dpt->getVar('id');
                }
                $ret = xhelpSetMeta("default_department", $aDepts[0]);
            }
            $qry = $xoopsDB->query(sprintf("ALTER TABLE %s DROP PRIMARY KEY", $xoopsDB->prefix('xhelp_ticket_submit_emails')));
            $ret = $ret && _runQuery(sprintf("ALTER TABLE %s ADD PRIMARY KEY(ticketid, uid, email)", $xoopsDB->prefix('xhelp_ticket_submit_emails')), sprintf(_AM_XHELP_MSG_MODIFYTABLE, 'xhelp_ticket_submit_emails'), sprintf(_AM_XHELP_MSG_MODIFYTABLE_ERR, 'xhelp_ticket_submit_emails'));
            $ret = $ret && _runQuery(sprintf("ALTER TABLE %s MODIFY department int(11) NOT NULL default '0'", $xoopsDB->prefix('xhelp_jstaffdept')), sprintf(_AM_XHELP_MSG_MODIFYTABLE, 'xhelp_jstaffdept'), sprintf(_AM_XHELP_MSG_MODIFYTABLE_ERR, 'xhelp_jstaffdept'));
            echo "<li>" . _AM_XHELP_MSG_CHANGED_DEFAULT_DEPT . "</li>";
            // Add field to xhelp_saved_searches to determine if custom fields table is needed
            $ret = $ret && _runQuery(sprintf("ALTER TABLE %s ADD (hasCustFields int(11) NOT NULL default '0')", $xoopsDB->prefix('xhelp_saved_searches')), sprintf(_AM_XHELP_MSG_MODIFYTABLE, 'xhelp_saved_searches'), sprintf(_AM_XHELP_MSG_MODIFYTABLE_ERR, 'xhelp_saved_searches'));
            // Take existing saved searches and add 'query' field
            $hSavedSearch =& xhelpGetHandler('savedSearch');
            $savedSearches =& $hSavedSearch->getObjects();
            foreach ($savedSearches as $savedSearch) {
                set_time_limit(60);
                $crit =& unserialize($savedSearch->getVar('search'));
                if (is_object($crit)) {
                    $savedSearch->setVar('query', $crit->render());
                    if ($hSavedSearch->insert($savedSearch)) {
                        echo "<li>" . sprintf(_AM_XHELP_MSG_UPDATE_SEARCH, $savedSearch->getVar('id')) . "</li>";
                    } else {
                        echo "<li>" . sprintf(_AM_XHELP_MSG_UPDATE_SEARCH_ERR, $savedSearch->getVar('id')) . "</li>";
                    }
                }
            }
            unset($savedSearches);
            // Add ticket list table
            set_time_limit(60);
            $ret = $ret && _runQuery(sprintf("CREATE TABLE %s (id int(11) NOT NULL auto_increment,\r\n                                                           uid int(11) NOT NULL default '0',\r\n                                                           searchid int(11) NOT NULL default '0',\r\n                                                           weight int(11) NOT NULL default '0',\r\n                                                           PRIMARY KEY (id),\r\n                                                           KEY ticketList (uid, searchid)\r\n                                                          )ENGINE=MyISAM;", $xoopsDB->prefix('xhelp_ticket_lists')), sprintf(_AM_XHELP_MSG_ADDTABLE, 'xhelp_ticket_lists'), sprintf(_AM_XHELP_MSG_ADDTABLE_ERR, 'xhelp_ticket_lists'));
            // Add global ticket lists for staff members
            xhelpCreateDefaultTicketLists();
            set_time_limit(60);
            // Update xhelp_roles Admin record with new value (4095)
            $crit = new Criteria('tasks', 2047);
            $admin_roles =& $hRole->getObjects($crit);
            foreach ($admin_roles as $role) {
                $role->setVar('tasks', 4095);
                if ($hRole->insert($role)) {
                    echo "<li>" . sprintf(_AM_XHELP_MSG_UPDATE_ROLE, $role->getVar('name')) . "</li>";
                } else {
                    echo "<li>" . sprintf(_AM_XHELP_MSG_UPDATE_ROLE_ERR, $role->getVar('name')) . "</li>";
                }
            }
        case '0.77':
            // No schema changes for 0.78
        // No schema changes for 0.78
        case '0.78':
            echo "</ul>";
    }
    $newversion = round($xoopsModule->getVar('version') / 100, 2);
    //if successful, update xhelp_meta table with new ver
    if ($ret) {
        printf(_AM_XHELP_UPDATE_OK, $newversion);
        $ret = xhelpSetMeta('version', $newversion);
    } else {
        printf(_AM_XHELP_UPDATE_ERR, $newversion);
    }
    xhelpAdminFooter();
    xoops_cp_footer();
}
コード例 #7
0
function modifyEmlTpl()
{
    global $xoopsConfig, $oAdminButton, $_xhelpSession;
    if (is_dir(XOOPS_ROOT_PATH . '/modules/xhelp/language/' . $xoopsConfig['language'] . '/mail_template')) {
        $opendir = opendir(XOOPS_ROOT_PATH . '/modules/xhelp/language/' . $xoopsConfig['language'] . '/mail_template/');
        $dir = XOOPS_ROOT_PATH . '/modules/xhelp/language/' . $xoopsConfig['language'] . '/mail_template/';
        $url = XOOPS_URL . '/modules/xhelp/language/' . $xoopsConfig['language'] . '/mail_template/';
    } else {
        $opendir = opendir(XOOPS_ROOT_PATH . '/modules/xhelp/language/english/mail_template/');
        $dir = XOOPS_ROOT_PATH . '/modules/xhelp/language/english/mail_template/';
        $url = XOOPS_URL . '/modules/xhelp/language/english/mail_template/';
    }
    $notNames = array(_MI_XHELP_DEPT_NEWTICKET_NOTIFYTPL => array(_MI_XHELP_DEPT_NEWTICKET_NOTIFY, _MI_XHELP_DEPT_NEWTICKET_NOTIFYDSC, _MI_XHELP_DEPT_NEWTICKET_NOTIFYTPL), _MI_XHELP_DEPT_REMOVEDTICKET_NOTIFYTPL => array(_MI_XHELP_DEPT_REMOVEDTICKET_NOTIFY, _MI_XHELP_DEPT_REMOVEDTICKET_NOTIFYDSC, _MI_XHELP_DEPT_REMOVEDTICKET_NOTIFYTPL), _MI_XHELP_DEPT_NEWRESPONSE_NOTIFYTPL => array(_MI_XHELP_DEPT_NEWRESPONSE_NOTIFY, _MI_XHELP_DEPT_NEWRESPONSE_NOTIFYDSC, _MI_XHELP_DEPT_NEWRESPONSE_NOTIFYTPL), _MI_XHELP_DEPT_MODIFIEDRESPONSE_NOTIFYTPL => array(_MI_XHELP_DEPT_MODIFIEDRESPONSE_NOTIFY, _MI_XHELP_DEPT_MODIFIEDRESPONSE_NOTIFYDSC, _MI_XHELP_DEPT_MODIFIEDRESPONSE_NOTIFYTPL), _MI_XHELP_DEPT_MODIFIEDTICKET_NOTIFYTPL => array(_MI_XHELP_DEPT_MODIFIEDTICKET_NOTIFY, _MI_XHELP_DEPT_MODIFIEDTICKET_NOTIFYDSC, _MI_XHELP_DEPT_MODIFIEDTICKET_NOTIFYTPL), _MI_XHELP_DEPT_CHANGEDSTATUS_NOTIFYTPL => array(_MI_XHELP_DEPT_CHANGEDSTATUS_NOTIFY, _MI_XHELP_DEPT_CHANGEDSTATUS_NOTIFYDSC, _MI_XHELP_DEPT_CHANGEDSTATUS_NOTIFYTPL), _MI_XHELP_DEPT_CHANGEDPRIORITY_NOTIFYTPL => array(_MI_XHELP_DEPT_CHANGEDPRIORITY_NOTIFY, _MI_XHELP_DEPT_CHANGEDPRIORITY_NOTIFYDSC, _MI_XHELP_DEPT_CHANGEDPRIORITY_NOTIFYTPL), _MI_XHELP_DEPT_NEWOWNER_NOTIFYTPL => array(_MI_XHELP_DEPT_NEWOWNER_NOTIFY, _MI_XHELP_DEPT_NEWOWNER_NOTIFYDSC, _MI_XHELP_DEPT_NEWOWNER_NOTIFYTPL), _MI_XHELP_DEPT_CLOSETICKET_NOTIFYTPL => array(_MI_XHELP_DEPT_CLOSETICKET_NOTIFY, _MI_XHELP_DEPT_CLOSETICKET_NOTIFYDSC, _MI_XHELP_DEPT_CLOSETICKET_NOTIFYTPL), _MI_XHELP_TICKET_NEWOWNER_NOTIFYTPL => array(_MI_XHELP_TICKET_NEWOWNER_NOTIFY, _MI_XHELP_TICKET_NEWOWNER_NOTIFYDSC, _MI_XHELP_TICKET_NEWOWNER_NOTIFYTPL), _MI_XHELP_TICKET_REMOVEDTICKET_NOTIFYTPL => array(_MI_XHELP_TICKET_REMOVEDTICKET_NOTIFY, _MI_XHELP_TICKET_REMOVEDTICKET_NOTIFYDSC, _MI_XHELP_TICKET_REMOVEDTICKET_NOTIFYTPL), _MI_XHELP_TICKET_MODIFIEDTICKET_NOTIFYTPL => array(_MI_XHELP_TICKET_MODIFIEDTICKET_NOTIFY, _MI_XHELP_TICKET_MODIFIEDTICKET_NOTIFYDSC, _MI_XHELP_TICKET_MODIFIEDTICKET_NOTIFYTPL), _MI_XHELP_TICKET_NEWRESPONSE_NOTIFYTPL => array(_MI_XHELP_TICKET_NEWRESPONSE_NOTIFY, _MI_XHELP_TICKET_NEWRESPONSE_NOTIFYDSC, _MI_XHELP_TICKET_NEWRESPONSE_NOTIFYTPL), _MI_XHELP_TICKET_MODIFIEDRESPONSE_NOTIFYTPL => array(_MI_XHELP_TICKET_MODIFIEDRESPONSE_NOTIFY, _MI_XHELP_TICKET_MODIFIEDRESPONSE_NOTIFYDSC, _MI_XHELP_TICKET_MODIFIEDRESPONSE_NOTIFYTPL), _MI_XHELP_TICKET_CHANGEDSTATUS_NOTIFYTPL => array(_MI_XHELP_TICKET_CHANGEDSTATUS_NOTIFY, _MI_XHELP_TICKET_CHANGEDSTATUS_NOTIFYDSC, _MI_XHELP_TICKET_CHANGEDSTATUS_NOTIFYTPL), _MI_XHELP_TICKET_CHANGEDPRIORITY_NOTIFYTPL => array(_MI_XHELP_TICKET_CHANGEDPRIORITY_NOTIFY, _MI_XHELP_TICKET_CHANGEDPRIORITY_NOTIFYDSC, _MI_XHELP_TICKET_CHANGEDPRIORITY_NOTIFYTPL), _MI_XHELP_TICKET_NEWTICKET_NOTIFYTPL => array(_MI_XHELP_TICKET_NEWTICKET_NOTIFY, _MI_XHELP_TICKET_NEWTICKET_NOTIFYDSC, _MI_XHELP_TICKET_NEWTICKET_NOTIFYTPL), _MI_XHELP_TICKET_NEWTICKET_EMAIL_NOTIFYTPL => array(_MI_XHELP_TICKET_NEWTICKET_EMAIL_NOTIFY, _MI_XHELP_TICKET_NEWTICKET_EMAIL_NOTIFYDSC, _MI_XHELP_TICKET_NEWTICKET_EMAIL_NOTIFYTPL), _MI_XHELP_TICKET_CLOSETICKET_NOTIFYTPL => array(_MI_XHELP_TICKET_CLOSETICKET_NOTIFY, _MI_XHELP_TICKET_CLOSETICKET_NOTIFYDSC, _MI_XHELP_TICKET_CLOSETICKET_NOTIFYTPL), _MI_XHELP_TICKET_NEWUSER_NOTIFYTPL => array(_MI_XHELP_TICKET_NEWUSER_NOTIFY, _MI_XHELP_TICKET_NEWUSER_NOTIFYDSC, _MI_XHELP_TICKET_NEWUSER_NOTIFYTPL), _MI_XHELP_TICKET_NEWUSER_ACT1_NOTIFYTPL => array(_MI_XHELP_TICKET_NEWUSER_ACT1_NOTIFY, _MI_XHELP_TICKET_NEWUSER_ACT1_NOTIFYDSC, _MI_XHELP_TICKET_NEWUSER_ACT1_NOTIFYTPL), _MI_XHELP_TICKET_NEWUSER_ACT2_NOTIFYTPL => array(_MI_XHELP_TICKET_NEWUSER_ACT2_NOTIFY, _MI_XHELP_TICKET_NEWUSER_ACT2_NOTIFYDSC, _MI_XHELP_TICKET_NEWUSER_ACT2_NOTIFYTPL), _MI_XHELP_TICKET_EMAIL_ERROR_NOTIFYTPL => array(_MI_XHELP_TICKET_EMAIL_ERROR_NOTIFY, _MI_XHELP_TICKET_EMAIL_ERROR_NOTIFYDSC, _MI_XHELP_TICKET_EMAIL_ERROR_NOTIFYTPL), _MI_XHELP_DEPT_MERGE_TICKET_NOTIFYTPL => array(_MI_XHELP_DEPT_MERGE_TICKET_NOTIFY, _MI_XHELP_DEPT_MERGE_TICKET_NOTIFYDSC, _MI_XHELP_DEPT_MERGE_TICKET_NOTIFYTPL), _MI_XHELP_TICKET_MERGE_TICKET_NOTIFYTPL => array(_MI_XHELP_TICKET_MERGE_TICKET_NOTIFY, _MI_XHELP_TICKET_MERGE_TICKET_NOTIFYDSC, _MI_XHELP_TICKET_MERGE_TICKET_NOTIFYTPL));
    $notKeys = array_keys($notNames);
    while (($file = readdir($opendir)) != null) {
        //Do not Display .
        if (is_dir($file)) {
            continue;
        }
        if (!in_array($file, $notKeys)) {
            continue;
        }
        $aFile = array();
        $aFile['name'] = $notNames[$file][0];
        $aFile['desc'] = $notNames[$file][1];
        $aFile['filename'] = $notNames[$file][2];
        $aFile['url'] = "index.php?op=modifyEmlTpl&amp;file={$file}";
        $aFiles[] = $aFile;
    }
    if (!isset($_GET['file'])) {
        xoops_cp_header();
        echo $oAdminButton->renderButtons('manNotify');
        echo "<table width='100%' border='0' cellspacing='1' class='outer'>\r\n              <tr><th colspan='2'><label>" . _AM_XHELP_MENU_MODIFY_EMLTPL . "</label></th></tr>\r\n              <tr class='head'><td>" . _AM_XHELP_TEXT_TEMPLATE_NAME . "</td><td>" . _AM_XHELP_TEXT_DESCRIPTION . "</td></tr>";
        foreach ($aFiles as $file) {
            static $rowSwitch = 0;
            if ($rowSwitch == 0) {
                echo "<tr class='odd'><td><a href='" . $file['url'] . "'>" . $file['name'] . "</a></td><td>" . $file['desc'] . "</td></tr>";
                $rowSwitch = 1;
            } else {
                echo "<tr class='even'><td><a href='" . $file['url'] . "'>" . $file['name'] . "</a></td><td>" . $file['desc'] . "</td></tr>";
                $rowSwitch = 0;
            }
        }
        echo "</table>";
    } else {
        xoops_cp_header();
        echo $oAdminButton->renderButtons('manNotify');
        foreach ($aFiles as $file) {
            if ($_GET['file'] == $file['filename']) {
                $myFileName = $file['filename'];
                $myFileDesc = $file['desc'];
                $myName = $file['name'];
                break;
            }
        }
        if (!($has_write = is_writable($dir . $myFileName))) {
            $message = _AM_XHELP_MESSAGE_FILE_READONLY;
            $handle = fopen($dir . $myFileName, 'r');
            $fileSize = filesize($dir . $myFileName);
        } elseif (isset($_POST['editTemplate'])) {
            $handle = fopen($dir . $myFileName, 'w+');
        } else {
            $handle = fopen($dir . $myFileName, 'r+');
            $fileSize = filesize($dir . $myFileName);
        }
        if (isset($_POST['editTemplate'])) {
            if (isset($_POST['templateText'])) {
                $text = $_POST['templateText'];
                // Get new text for template
            } else {
                $text = '';
            }
            if (!($returnPage =& $_xhelpSession->get("xhelp_return_page"))) {
                $returnPage = false;
            }
            if (fwrite($handle, $text)) {
                $message = _AM_XHELP_MESSAGE_FILE_UPDATED;
                $fileSize = filesize($dir . $myFileName);
                fclose($handle);
                if ($returnPage) {
                    header("Location: " . XHELP_ADMIN_URL . "/{$returnPage}");
                } else {
                    header("Location: " . XHELP_ADMIN_URL . "/notifications.php");
                }
            } else {
                $message = _AM_XHELP_MESSAGE_FILE_UPDATED_ERROR;
                $fileSize = filesize($dir . $myFileName);
                fclose($handle);
                if ($returnPage) {
                    redirect_header("Location: " . XHELP_ADMIN_URL . "/{$returnPage}", 3, $message);
                } else {
                    redirect_header("Location: " . XHELP_ADMIN_URL . "/notifications.php", 3, $message);
                }
            }
        }
        if (!$has_write) {
            echo "<div id='readOnly' class='errorMsg'>";
            echo $message;
            echo "</div>";
        }
        echo "<form action='" . XHELP_ADMIN_URL . "/notifications.php?op=modifyEmlTpl&amp;file=" . $myFileName . "' method='post'>";
        echo "<table width='100%' border='0' cellspacing='1' class='outer'>\r\n              <tr><th colspan='2'>" . $myName . "</th></tr>\r\n              <tr><td colspan='2' class='head'>" . $myFileDesc . "</td></tr>";
        echo "<tr class='odd'>\r\n                  <td><textarea name='templateText' cols='40' rows='40'>" . fread($handle, $fileSize) . "</textarea></td>\r\n                  <td valign='top'>\r\n                      <b>" . _AM_XHELP_TEXT_GENERAL_TAGS . "</b>\r\n                      <ul>\r\n                        <li>" . _AM_XHELP_TEXT_GENERAL_TAGS1 . "</li>\r\n                        <li>" . _AM_XHELP_TEXT_GENERAL_TAGS2 . "</li>\r\n                        <li>" . _AM_XHELP_TEXT_GENERAL_TAGS3 . "</li>\r\n                        <li>" . _AM_XHELP_TEXT_GENERAL_TAGS4 . "</li>\r\n                        <li>" . _AM_XHELP_TEXT_GENERAL_TAGS5 . "</li>\r\n                      </ul>\r\n                      <br />\r\n                      <u>" . _AM_XHELP_TEXT_TAGS_NO_MODIFY . "</u>\r\n                  </td>\r\n              </tr>";
        if ($has_write) {
            echo "<tr><td class='foot' colspan='2'><input type='submit' name='editTemplate' value='" . _AM_XHELP_BUTTON_UPDATE . "' class='formButton' /></td></tr>";
        }
        echo "</table></form>";
    }
    xhelpAdminFooter();
    xoops_cp_footer();
}
コード例 #8
0
ファイル: staff.php プロジェクト: trabisdementia/xuups
function manageStaff()
{
    global $xoopsModule, $xoopsUser, $oAdminButton, $displayName, $aLimitByS, $aLimitByD;
    require_once XHELP_CLASS_PATH . '/session.php';
    $_xhelpSession = new Session();
    $_xhelpSession->del("xhelp_return_page");
    $start = $limit = 0;
    $dstart = $dlimit = 0;
    $staff_search = false;
    $dept_search = false;
    if (isset($_POST['addRole'])) {
        header("Location: " . XHELP_ADMIN_URL . "/staff.php?op=addRole");
        exit;
    }
    if (isset($_POST['clearRoles'])) {
        header("Location: " . XHELP_ADMIN_URL . "/staff.php?op=clearRoles");
        exit;
    }
    if (isset($_REQUEST['limit'])) {
        $limit = intval($_REQUEST['limit']);
    }
    if (isset($_REQUEST['start'])) {
        $start = intval($_REQUEST['start']);
    }
    if (isset($_REQUEST['staff_search'])) {
        $staff_search = $_REQUEST['staff_search'];
    }
    if (isset($_REQUEST['dept_search'])) {
        $dept_search = $_REQUEST['dept_search'];
    }
    if (!$limit) {
        $limit = 20;
    }
    if (isset($_REQUEST['dlimit'])) {
        $dlimit = intval($_REQUEST['dlimit']);
    }
    if (isset($_REQUEST['dstart'])) {
        $dstart = intval($_REQUEST['dstart']);
    }
    if (!$dlimit) {
        $dlimit = 10;
    }
    $_xhelpSession->set("xhelp_return_op", "manageStaff");
    if (!isset($_POST['addStaff'])) {
        $member_handler =& xoops_gethandler('member');
        // Get member handler
        $hStaff =& xhelpGetHandler('staff');
        // Get staff handler
        $hDepartments =& xhelpGetHandler('department');
        // Get department handler
        $hRoles =& xhelpGetHandler('role');
        //Get List of depts in system
        $crit = new Criteria('', '');
        $crit->setSort('department');
        $crit->setOrder('ASC');
        $dept_count = $hDepartments->getCount($crit);
        $dept_obj =& $hDepartments->getObjects($crit);
        xoops_cp_header();
        echo $oAdminButton->renderButtons('manStaff');
        if (isset($_GET['uid'])) {
            $userid = intval($_GET['uid']);
            $uname = $xoopsUser->getUnameFromId($userid);
        } else {
            $userid = 0;
            $uname = '';
        }
        if ($dept_count > 0) {
            $userid = isset($_GET['uid']) ? intval($_GET['uid']) : 0;
            //Get List of staff members
            $crit = new Criteria('', '');
            $crit->setStart($start);
            $crit->setLimit($limit);
            $staff_obj =& $hStaff->getObjects($crit);
            $staff_count = $hStaff->getCount($crit);
            $user_count = $member_handler->getUserCount();
            $nav = new xhelpPageNav($staff_count, $limit, $start, 'start', "op=manageStaff&amp;limit={$limit}");
            //Get List of Staff Roles
            $crit = new Criteria('', '');
            $crit->setOrder('ASC');
            $crit->setSort('name');
            $roles =& $hRoles->getObjects($crit);
            echo '<script type="text/javascript" src="' . XOOPS_URL . '/modules/xhelp/include/functions.js"></script>';
            echo "<form method='post' id='manageStaff' name='manageStaff' action='staff.php?op=manageStaff'>";
            echo "<table width='100%' cellspacing='1' class='outer'>\r\n                  <tr><th colspan='2'>" . _AM_XHELP_ADD_STAFF . "</th></tr>";
            echo "<tr><td class='head' width='20%'>" . _AM_XHELP_TEXT_USER . "</td>\r\n                      <td class='even'>\r\n                          <input type='text' id='fullname' name='fullname' class='formButton' value='" . $uname . "' disabled='disabled' style='background-color:#E1E1E1;' onchange=\"window.location='staff.php?op=manageStaff&amp;uid='+user_id.value;\" />\r\n                          <input type='hidden' id='user_id' name='user_id' class='formButton' value='" . $userid . "' />";
            echo "&nbsp;<a href=\"javascript:openWithSelfMain('" . XHELP_BASE_URL . "/lookup.php?admin=1', 'lookup',400, 300);\" title='" . _AM_XHELP_TEXT_FIND_USERS . "'>" . _AM_XHELP_TEXT_FIND_USERS . "</a>\r\n                      </td>\r\n                  </tr>";
            echo "</td></tr>";
            echo "<tr><td class='head' width='20%'>" . _AM_XHELP_TEXT_ROLES . "</td>\r\n                      <td class='even'><table width='75%'>";
            if ($mainRoles = $_xhelpSession->get("xhelp_mainRoles")) {
                foreach ($roles as $role) {
                    if (!in_array($role->getVar('id'), $mainRoles)) {
                        echo "<tr><td><input type='checkbox' name='roles[]' value='" . $role->getVar('id') . "' onclick=\"xhelpRoleCustOnClick('manageStaff', 'roles[]', 'xhelp_role', '&amp;', 'xhelp_dept_cust');\" />\r\n                              <a href='staff.php?op=editRole&amp;id=" . $role->getVar('id') . "&amp;uid=" . $userid . "'>" . $role->getVar('name') . "</a> - " . $role->getVar('description') . "</td></tr>";
                    } else {
                        echo "<tr><td><input type='checkbox' name='roles[]' value='" . $role->getVar('id') . "' checked='checked' onclick=\"xhelpRoleCustOnClick('manageStaff', 'roles[]', 'xhelp_role', '&amp;', 'xhelp_dept_cust');\" />\r\n                              <a href='staff.php?op=editRole&amp;id=" . $role->getVar('id') . "&amp;uid=" . $userid . "'>" . $role->getVar('name') . "</a> - " . $role->getVar('description') . "</td></tr>";
                    }
                }
            } else {
                foreach ($roles as $role) {
                    echo "<tr><td><input type='checkbox' name='roles[]' value='" . $role->getVar('id') . "' onclick=\"xhelpRoleCustOnClick('manageStaff', 'roles[]', 'xhelp_role', '&amp;', 'xhelp_dept_cust');\" />\r\n                          <a href='staff.php?op=editRole&amp;id=" . $role->getVar('id') . "&amp;uid=" . $userid . "'>" . $role->getVar('name') . "</a> - " . $role->getVar('description') . "</td></tr>";
                }
            }
            echo "<tr><td><input type='checkbox' name='checkallRoles' value='0' onclick='selectAll(this.form,\"roles[]\",this.checked); xhelpRoleCustOnClick(\"manageStaff\", \"roles[]\", \"xhelp_role\", \"&amp;\", \"xhelp_dept_cust\");' /><b>" . _AM_XHELP_TEXT_SELECT_ALL . "</b></td></tr>";
            echo "</table></td></tr>";
            echo "<tr><td class='head' width='20%'>" . _AM_XHELP_TEXT_DEPARTMENTS . "</td>\r\n                  <td class='even' width='50%'><table width='75%'>";
            if ($mainDepts =& $_xhelpSession->get("xhelp_mainDepts")) {
                foreach ($dept_obj as $dept) {
                    $deptid = $dept->getVar('id');
                    $aDept = $_xhelpSession->get("xhelp_dept_{$deptid}");
                    $aDeptRoles = $aDept['roleNames'];
                    if (!empty($aDeptRoles) && is_array($aDeptRoles)) {
                        $deptRoles = implode(", ", $aDeptRoles);
                    } else {
                        $deptRoles = '';
                    }
                    if (!in_array($dept->getVar('id'), $mainDepts)) {
                        echo "<tr><td>\r\n                              <input type='checkbox' name='departments[]' value='" . $dept->getVar('id') . "' onclick=\"xhelpRoleCustOnClick('manageStaff', 'departments[]', 'xhelp_depts', '&amp;', 'xhelp_dept_cust');\" />\r\n                              " . $dept->getVar('department') . " [<a href='staff.php?op=customDept&amp;deptid=" . $dept->getVar('id') . "&amp;uid=" . $userid . "' class='xhelp_dept_cust'>" . _AM_XHELP_TEXT_CUSTOMIZE . "</a>] <i>" . $deptRoles . "</i>\r\n                              </td></tr>";
                    } else {
                        echo "<tr><td>\r\n                              <input type='checkbox' name='departments[]' checked='checked' value='" . $dept->getVar('id') . "' onclick=\"xhelpRoleCustOnClick('manageStaff', 'departments[]', 'xhelp_depts', '&amp;', 'xhelp_dept_cust');\" />\r\n                              " . $dept->getVar('department') . " [<a href='staff.php?op=customDept&amp;deptid=" . $dept->getVar('id') . "&amp;uid=" . $userid . "' class='xhelp_dept_cust'>" . _AM_XHELP_TEXT_CUSTOMIZE . "</a>] <i>" . $deptRoles . "</i>\r\n                              </td></tr>";
                    }
                }
            } else {
                foreach ($dept_obj as $dept) {
                    $deptid = $dept->getVar('id');
                    $aDept = $_xhelpSession->get("xhelp_dept_{$deptid}");
                    $aDeptRoles = $aDept['roleNames'];
                    if (!empty($aDeptRoles)) {
                        $deptRoles = implode(", ", $aDeptRoles);
                    } else {
                        $deptRoles = '';
                    }
                    echo "<tr><td>\r\n                          <input type='checkbox' name='departments[]' value='" . $dept->getVar('id') . "' onclick=\"xhelpRoleCustOnClick('manageStaff', 'departments[]', 'xhelp_depts', '&amp;', 'xhelp_dept_cust');\" />\r\n                          " . $dept->getVar('department') . " [<a href='staff.php?op=customDept&amp;deptid=" . $dept->getVar('id') . "&amp;uid=" . $userid . "' class='xhelp_dept_cust'>" . _AM_XHELP_TEXT_CUSTOMIZE . "</a>] <i>" . $deptRoles . "</i>\r\n                          </td></tr>";
                }
            }
            echo "<tr><td><input type='checkbox' name='checkallDepts' value='0' onclick='selectAll(this.form,\"departments[]\",this.checked);xhelpRoleCustOnClick(\"manageStaff\", \"departments[]\", \"xhelp_depts\", \"&amp;\", \"xhelp_dept_cust\");' /><b>" . _AM_XHELP_TEXT_SELECT_ALL . "</b></td></tr>";
            echo "</table></td></tr>";
            echo "<tr><td colspan='2' class='foot'>\r\n                  <input type='submit' name='addStaff' value='" . _AM_XHELP_BUTTON_ADDSTAFF . "' />\r\n                  <input type='submit' name='addRole' value='" . _AM_XHELP_BUTTON_CREATE_ROLE . "' class='formButton' />\r\n                  <input type='submit' name='clearRoles' value='" . _AM_XHELP_BUTTON_CLEAR_PERMS . "' class='formButton' />\r\n                  </td></tr>";
            echo "</table></form>";
            echo "<form method='post' id='cleanStaff' name='cleanStaff' action='staff.php?op=clearOrphanedStaff'>";
            echo "<table width='100%' cellspacing='1' class='outer'>\r\n                  <tr><th colspan='2'>" . _AM_XHELP_TEXT_MAINTENANCE . "</th></tr>";
            echo "<tr><td class='head' width='40%'>" . _AM_XHELP_TEXT_ORPHANED . "</td>\r\n                      <td class='even'><input type='submit' name='cleanStaff' value='" . _AM_XHELP_BUTTON_SUBMIT . "' /></td>\r\n                  </tr>";
            echo "</table></form>";
            if ($staff_count > 0) {
                //Get User Information for each staff member
                $staff_uids = array();
                foreach ($staff_obj as $obj) {
                    $staff_uids[] = $obj->getVar('uid');
                }
                if ($staff_search == false) {
                    $crit = new Criteria('uid', '(' . implode(',', $staff_uids) . ')', 'IN');
                } else {
                    $crit = new CriteriaCompo(new Criteria('uname', "%{$staff_search}%", 'LIKE'), 'OR');
                    $crit->add(new Criteria('name', "%{$staff_search}%", 'LIKE'), 'OR');
                    $crit->add(new Criteria('email', "%{$staff_search}%", 'LIKE'), 'OR');
                }
                $staff_users = $member_handler->getUsers($crit);
                if ($dept_search == false) {
                    $crit = new Criteria('', '');
                } else {
                    $crit = new Criteria('department', "%{$dept_search}%", 'LIKE');
                }
                $crit->setStart($dstart);
                $crit->setLimit($dlimit);
                $allDepts = $hDepartments->getObjects($crit, true);
                $dnav = new xhelpPageNav($hDepartments->getCount($crit), $dlimit, $dstart, 'dstart', "op=manageStaff&amp;start={$start}&amp;limit={$limit}&amp;dlimit={$dlimit}", "tblManageStaff");
                echo "<form action='" . XHELP_ADMIN_URL . "/staff.php?op=manageStaff' style='margin:0; padding:0;' method='post'>";
                echo "<table width='100%' cellspacing='1' class='outer'>";
                echo "<tr><td align='right'>" . _AM_XHELP_TEXT_STAFF . ": " . _AM_XHELP_BUTTON_SEARCH . " <input type='text' name='staff_search' value='{$staff_search}' />\r\n                          " . _AM_XHELP_TEXT_NUMBER_PER_PAGE . "<select name='limit'>";
                foreach ($aLimitByS as $value => $text) {
                    $limit == $value ? $selected = "selected='selected'" : ($selected = '');
                    echo "<option value='{$value}' {$selected}>{$text}</option>";
                }
                echo "</select>\r\n                            &nbsp;&nbsp;&nbsp;\r\n                            " . _AM_XHELP_TEXT_DEPARTMENTS . ": " . _AM_XHELP_BUTTON_SEARCH . " \r\n                              <input type='text' name='dept_search' value='{$dept_search}' />\r\n                            " . _AM_XHELP_TEXT_NUMBER_PER_PAGE . "\r\n                              <select name='dlimit'>";
                foreach ($aLimitByD as $value => $text) {
                    $dlimit == $value ? $selected = "selected='selected'" : ($selected = '');
                    echo "<option value='{$value}' {$selected}>{$text}</option>";
                }
                echo "</select>\r\n                            &nbsp;&nbsp;\r\n                              <input type='submit' name='staff_select' id='staff_select' value='" . _AM_XHELP_BUTTON_SUBMIT . "' />\r\n                          </td>\r\n                      </tr>";
                echo "</table></form>";
                echo "<table width='100%' cellspacing='1' class='outer' id='tblManageStaff'>\r\n                      <tr><th colspan='" . (3 + count($allDepts)) . "'><label>" . _AM_XHELP_MANAGE_STAFF . "</label></th></tr>";
                echo "<tr class='head'><td rowspan='2'>" . _AM_XHELP_TEXT_ID . "</td><td rowspan='2'>" . _AM_XHELP_TEXT_USER . "</td><td colspan='" . count($allDepts) . "'>" . _AM_XHELP_TEXT_DEPARTMENTS . " " . $dnav->renderNav() . "</td><td rowspan='2'>" . _AM_XHELP_TEXT_ACTIONS . "</td></tr>";
                echo "<tr class='head'>";
                foreach ($allDepts as $thisdept) {
                    echo "<td>" . $thisdept->getVar('department') . "</td>";
                }
                echo "</tr>";
                $hMembership =& xhelpGetHandler('membership');
                $hStaffRole =& xhelpGetHandler('staffRole');
                foreach ($staff_users as $staff) {
                    $departments = $hMembership->membershipByStaff($staff->getVar('uid'), true);
                    echo "<tr class='even'><td>" . $staff->getVar('uid') . "</td><td>" . $staff->getVar('uname') . "</td>";
                    foreach ($allDepts as $thisdept) {
                        echo "<td><img src='" . XOOPS_URL . "/modules/xhelp/images/";
                        echo array_key_exists($thisdept->getVar('id'), $departments) ? "on" : "off";
                        echo ".png' /></td>";
                    }
                    echo "<td><a href='staff.php?op=editStaff&amp;uid=" . $staff->getVar('uid') . "'><img src='" . XOOPS_URL . "/modules/xhelp/images/button_edit.png' title='" . _AM_XHELP_TEXT_EDIT . "' name='editStaff' /></a>&nbsp;\r\n                              <a href='delete.php?deleteStaff=1&amp;uid=" . $staff->getVar('uid') . "'><img src='" . XOOPS_URL . "/modules/xhelp/images/button_delete.png' title='" . _AM_XHELP_TEXT_DELETE . "' name='deleteStaff' /></a>\r\n                          </td></tr>";
                }
                echo "</table><br />";
                echo "<div id='staff_nav'>" . $nav->renderNav() . "</div>";
            }
        } else {
            echo "<div id='readOnly' class='errorMsg'>";
            echo _AM_XHELP_TEXT_MAKE_DEPTS;
            echo "</div>";
            echo "<br /><a href='department.php?op=manageDepartments'>" . _AM_XHELP_LINK_ADD_DEPT . "</a>";
        }
        xhelpAdminFooter();
        xoops_cp_footer();
    } else {
        $uid = $_POST['user_id'];
        $depts = $_POST['departments'];
        $roles = $_POST['roles'];
        //$selectAll = $_POST['selectall'];
        $hStaff =& xhelpGetHandler('staff');
        if (!isset($uid) || $uid == '') {
            redirect_header(XHELP_ADMIN_URL . '/staff.php?op=manageStaff', 3, _AM_XHELP_STAFF_ERROR_USERS);
        }
        if (!isset($depts)) {
            redirect_header(XHELP_ADMIN_URL . '/staff.php?op=manageStaff', 3, _AM_XHELP_STAFF_ERROR_DEPTARTMENTS);
        }
        if (!isset($roles)) {
            redirect_header(XHELP_ADMIN_URL . '/staff.php?op=manageStaff', 3, _AM_XHELP_STAFF_ERROR_ROLES);
        }
        if ($hStaff->isStaff($uid)) {
            redirect_header(XHELP_ADMIN_URL . '/staff.php?op=manageStaff', 3, _AM_XHELP_STAFF_EXISTS);
        }
        $member_handler =& xoops_gethandler('member');
        // Get member handler
        $newUser =& $member_handler->getUser($uid);
        $email = $newUser->getVar('email');
        if ($hStaff->addStaff($uid, $email)) {
            // $selectAll
            $message = _XHELP_MESSAGE_ADDSTAFF;
            $hMembership =& xhelpGetHandler('membership');
            //Set Department Membership
            if ($hMembership->addDeptToStaff($depts, $uid)) {
                $message = _XHELP_MESSAGE_ADDSTAFF;
            } else {
                $message = _XHELP_MESSAGE_ADDSTAFF_ERROR;
            }
            //Set Global Roles
            foreach ($roles as $role) {
                $hStaff->addStaffRole($uid, $role, 0);
            }
            //Set Department Roles
            foreach ($depts as $dept) {
                if ($custRoles = $_xhelpSession->get("xhelp_dept_{$dept}")) {
                    if ($custRoles['roles'] != -1) {
                        foreach ($custRoles['roles'] as $role) {
                            $hStaff->addStaffRole($uid, $role, $dept);
                        }
                    } else {
                        // If dept still checked, but no custom depts, give global roles to dept
                        foreach ($roles as $role) {
                            $hStaff->addStaffRole($uid, $role, $dept);
                        }
                    }
                } else {
                    foreach ($roles as $role) {
                        $hStaff->addStaffRole($uid, $role, $dept);
                    }
                }
            }
            $hTicketList =& xhelpGetHandler('ticketList');
            $hasTicketLists = $hTicketList->createStaffGlobalLists($uid);
            header("Location: " . XHELP_ADMIN_URL . "/staff.php?op=clearRoles");
        } else {
            $message = _XHELP_MESSAGE_ADDSTAFF_ERROR;
            redirect_header(XHELP_ADMIN_URL . '/staff.php?op=clearRoles', 3, $message);
        }
    }
    //end if
}
コード例 #9
0
ファイル: index.php プロジェクト: trabisdementia/xuups
function xhelp_default()
{
    global $xoopsModuleConfig, $oAdminButton;
    xoops_cp_header();
    echo $oAdminButton->renderButtons('index');
    $displayName =& $xoopsModuleConfig['xhelp_displayName'];
    // Determines if username or real name is displayed
    $stylePath = XHELP_BASE_URL . '/styles/xhelp.css';
    echo '<link rel="stylesheet" type="text/css" media="all" href="' . $stylePath . '" /><!--[if gte IE 5.5000]><script src="iepngfix.js" language="JavaScript" type="text/javascript"></script><![endif]-->';
    global $xoopsUser, $xoopsDB;
    $hTickets =& xhelpGetHandler('ticket');
    $hStatus =& xhelpGetHandler('status');
    $crit = new Criteria('', '');
    $crit->setSort('description');
    $crit->setOrder('ASC');
    $statuses =& $hStatus->getObjects($crit);
    $table_class = array('odd', 'even');
    echo "<table border='0' width='100%'>";
    echo "<tr><td width='50%' valign='top'>";
    echo "<div id='ticketInfo'>";
    echo "<table border='0' width='95%' cellspacing='1' class='outer'>\r\n          <tr><th colspan='2'>" . _AM_XHELP_TEXT_TICKET_INFO . "</th></tr>";
    $class = "odd";
    $totalTickets = 0;
    foreach ($statuses as $status) {
        $crit = new Criteria('status', $status->getVar('id'));
        $numTickets =& $hTickets->getCount($crit);
        $totalTickets += $numTickets;
        echo "<tr class='" . $class . "'><td>" . $status->getVar('description') . "</td><td>" . $numTickets . "</td></tr>";
        if ($class == "odd") {
            $class = "even";
        } else {
            $class = "odd";
        }
    }
    echo "<tr class='foot'><td>" . _AM_XHELP_TEXT_TOTAL_TICKETS . "</td><td>" . $totalTickets . "</td></tr>";
    echo "</table></div><br />";
    $hStaff =& xhelpGetHandler('staff');
    $hResponses =& xhelpGetHandler('responses');
    echo "</td><td valign='top'>";
    // Outer table
    echo "<div id='timeSpent'>";
    // Start inner top-left cell
    echo "<table border='0' width='100%' cellspacing='1' class='outer'>\r\n          <tr><th colspan='2'>" . _AM_XHELP_TEXT_RESPONSE_TIME . "</th></tr>";
    $sql = sprintf('SELECT u.uid, u.uname, u.name, (s.responseTime / s.ticketsResponded) as AvgResponseTime FROM %s u INNER JOIN %s s ON u.uid = s.uid WHERE ticketsResponded > 0 ORDER BY AvgResponseTime', $xoopsDB->prefix('users'), $xoopsDB->prefix('xhelp_staff'));
    $ret = $xoopsDB->query($sql, MAX_STAFF_RESPONSETIME);
    $i = 0;
    while (list($uid, $uname, $name, $avgResponseTime) = $xoopsDB->fetchRow($ret)) {
        $class = $table_class[$i % 2];
        echo "<tr class='{$class}'><td>" . xhelpGetDisplayName($displayName, $name, $uname) . "</td><td align='right'>" . xhelpFormatTime($avgResponseTime) . "</td></tr>";
        $i++;
    }
    echo "</table></div><br />";
    // End inner top-left cell
    echo "</td></tr><tr><td valign='top'>";
    // End first, start second cell
    //Get Calls Closed block
    $sql = sprintf('SELECT SUM(callsClosed) FROM %s', $xoopsDB->prefix('xhelp_staff'));
    $ret = $xoopsDB->query($sql);
    if (list($totalStaffClosed) = $xoopsDB->fetchRow($ret)) {
        if ($totalStaffClosed) {
            $sql = sprintf('SELECT u.uid, u.uname, u.name, s.callsClosed FROM %s u INNER JOIN %s s ON u.uid = s.uid WHERE s.callsClosed > 0 ORDER BY s.callsClosed DESC', $xoopsDB->prefix('users'), $xoopsDB->prefix('xhelp_staff'));
            $ret = $xoopsDB->query($sql, MAX_STAFF_CALLSCLOSED);
            echo "<div id='callsClosed'>";
            echo "<table border='0' width='95%' cellspacing='1' class='outer'>\r\n                  <tr><th colspan='2'>" . _AM_XHELP_TEXT_TOP_CLOSERS . "</th></tr>";
            $i = 0;
            while (list($uid, $uname, $name, $callsClosed) = $xoopsDB->fetchRow($ret)) {
                $class = $table_class[$i % 2];
                echo "<tr class='{$class}'><td>" . xhelpGetDisplayName($displayName, $name, $uname) . "</td><td align='right'>" . $callsClosed . ' (' . round($callsClosed / $totalStaffClosed * 100, 2) . "%)</td></tr>";
                $i++;
            }
            echo "</table></div><br />";
            // End inner table top row
            echo "</td><td valign='top'>";
            // End top row of outer table
            $sql = sprintf('SELECT u.uid, u.uname, u.name, (s.responseTime / s.ticketsResponded) as AvgResponseTime FROM %s u INNER JOIN %s s ON u.uid = s.uid WHERE ticketsResponded > 0 ORDER BY AvgResponseTime DESC', $xoopsDB->prefix('users'), $xoopsDB->prefix('xhelp_staff'));
            $ret = $xoopsDB->query($sql, MAX_STAFF_RESPONSETIME);
            echo "<div id='leastCallsClosed'>";
            echo "<table border='0' width='100%' cellspacing='1' class='outer'>\r\n                  <tr><th colspan='2'>" . _AM_XHELP_TEXT_RESPONSE_TIME_SLOW . "</th></tr>";
            $i = 0;
            while (list($uid, $uname, $name, $avgResponseTime) = $xoopsDB->fetchRow($ret)) {
                $class = $table_class[$i % 2];
                echo "<tr class='{$class}'><td>" . xhelpGetDisplayName($displayName, $name, $uname) . "</td><td align='right'>" . xhelpFormatTime($avgResponseTime) . "</td></tr>";
                $i++;
            }
            echo "</table></div>";
            // End first cell, second row of inner table
        }
    }
    echo "</td></tr></table><br />";
    // End second cell, second row of inner table
    $crit = new Criteria('state', '2', '<>', 's');
    $crit->setSort('priority');
    $crit->setOrder('ASC');
    $crit->setLimit(10);
    $highPriority =& $hTickets->getObjects($crit);
    $has_highPriority = count($highPriority) > 0;
    if ($has_highPriority) {
        echo "<div id='highPriority'>";
        echo "<table border='0' width='100%' cellspacing='1' class='outer'>\r\n              <tr><th colspan='8'>" . _AM_XHELP_TEXT_HIGH_PRIORITY . "</th></tr>";
        echo "<tr class='head'><td>" . _AM_XHELP_TEXT_PRIORITY . "</td><td>" . _AM_XHELP_TEXT_ELAPSED . "</td><td>" . _AM_XHELP_TEXT_STATUS . "</td><td>" . _AM_XHELP_TEXT_SUBJECT . "</td><td>" . _AM_XHELP_TEXT_DEPARTMENT . "</td><td>" . _AM_XHELP_TEXT_OWNER . "</td><td>" . _AM_XHELP_TEXT_LAST_UPDATED . "</td><td>" . _AM_XHELP_TEXT_LOGGED_BY . "</td></tr>";
        $i = 0;
        foreach ($highPriority as $ticket) {
            if ($ticket->isOverdue()) {
                $class = $table_class[$i % 2] . " overdue";
            } else {
                $class = $table_class[$i % 2];
            }
            $priority_url = "<img src='" . XHELP_IMAGE_URL . "/priority" . $ticket->getVar('priority') . ".png' alt='" . $ticket->getVar('priority') . "' />";
            $subject_url = sprintf("<a href='" . XHELP_BASE_URL . "/ticket.php?id=" . $ticket->getVar('id') . "' target='_BLANK'>%s</a>", $ticket->getVar('subject'));
            if ($dept = $ticket->getDepartment()) {
                $dept_url = sprintf("<a href='" . XHELP_BASE_URL . "/index.php?op=staffViewAll&amp;dept=" . $dept->getVar('id') . "' target='_BLANK'>%s</a>", $dept->getVar('department'));
            } else {
                $dept_url = _AM_XHELP_TEXT_NO_DEPT;
            }
            if ($ticket->getVar('ownership') != 0) {
                $owner_url = sprintf("<a href='" . XOOPS_URL . "/userinfo.php?uid=" . $ticket->getVar('uid') . "' target='_BLANK'>%s</a>", xhelpGetUsername($ticket->getVar('ownership'), $displayName));
            } else {
                $owner_url = _AM_XHELP_TEXT_NO_OWNER;
            }
            $user_url = sprintf("<a href='" . XOOPS_URL . "/userinfo.php?uid=" . $ticket->getVar('uid') . "' target='_BLANK'>%s</a>", xhelpGetUsername($ticket->getVar('uid'), $displayName));
            echo "<tr class='{$class}'><td>" . $priority_url . "</td>\r\n                         <td>" . $ticket->elapsed() . "</td>\r\n                         <td>" . xhelpGetStatus($ticket->getVar('status')) . "</td>\r\n                         <td>" . $subject_url . "</td>\r\n                         <td>" . $dept_url . "</td>\r\n                         <td>" . $owner_url . " </td>\r\n                         <td>" . $ticket->lastUpdated() . "</td>\r\n                         <td>" . $user_url . "</td>\r\n                     </tr>";
            $i++;
        }
        echo "</table></div>";
    }
    pathConfiguration();
    xhelpAdminFooter();
    xoops_cp_footer();
}
コード例 #10
0
ファイル: fields.php プロジェクト: trabisdementia/xuups
function editField()
{
    global $oAdminButton;
    $eventsrv =& xhelpNewEventService();
    $session =& Session::singleton();
    $regex_array =& _getRegexArray();
    if (!isset($_REQUEST['id'])) {
        redirect_header(xhelpMakeURI(XHELP_ADMIN_URL . '/fields.php', array('op' => 'manageDepartments'), false), 3, _AM_XHELP_MESSAGE_NO_FIELD);
    }
    $fld_id = intval($_REQUEST['id']);
    $hField =& xhelpGetHandler('ticketField');
    if (!($field =& $hField->get($fld_id))) {
        redirect_header(xhelpMakeURI(XHELP_ADMIN_URL . '/fields.php', array('op' => 'manageDepartments'), false), 3, _AM_XHELP_MESSAGE_NO_FIELD);
    }
    if (!isset($_POST['editField'])) {
        //Get Custom Field From session (if exists)
        $field_info = $session->get('xhelp_editField_' . $fld_id);
        $field_errors = $session->get('xhelp_editFieldErrors_' . $fld_id);
        if (!$field_info === false) {
            $fld_controltype = $field_info['controltype'];
            $fld_datatype = $field_info['datatype'];
            $fld_departments = $field_info['departments'];
            $fld_name = $field_info['name'];
            $fld_fieldname = $field_info['fieldname'];
            $fld_description = $field_info['description'];
            $fld_required = $field_info['required'];
            $fld_length = $field_info['length'];
            $fld_weight = $field_info['weight'];
            $fld_defaultvalue = $field_info['defaultvalue'];
            $fld_values = $field_info['values'];
            $fld_validation = $field_info['validation'];
        } else {
            $hFDept =& xhelpGetHandler('ticketFieldDepartment');
            $depts =& $hFDept->departmentsByField($field->getVar('id'), true);
            $fld_controltype = $field->getVar('controltype');
            $fld_datatype = $field->getVar('datatype');
            $fld_departments = array_keys($depts);
            $fld_name = $field->getVar('name');
            $fld_fieldname = $field->getVar('fieldname');
            $fld_description = $field->getVar('description');
            $fld_required = $field->getVar('required');
            $fld_length = $field->getVar('fieldlength');
            $fld_weight = $field->getVar('weight');
            $fld_defaultvalue = $field->getVar('defaultvalue');
            $fld_values = _formatValues($field->getVar('fieldvalues'));
            $fld_validation = $field->getVar('validation');
        }
        //Display Field modification
        xoops_cp_header();
        echo $oAdminButton->renderButtons('manfields');
        //Edit Field Form
        $controls = xhelpGetControlArray();
        $control_select = new XoopsFormSelect(_AM_XHELP_TEXT_CONTROLTYPE, 'fld_controltype', $fld_controltype);
        $control_select->setDescription(_AM_XHELP_TEXT_CONTROLTYPE_DESC);
        foreach ($controls as $key => $control) {
            $control_select->addOption($key, $control['label']);
        }
        $datatypes = array(_XHELP_DATATYPE_TEXT => _XHELP_DATATYPE_TEXT, _XHELP_DATATYPE_NUMBER_INT => _XHELP_DATATYPE_NUMBER_INT, _XHELP_DATATYPE_NUMBER_DEC => _XHELP_DATATYPE_NUMBER_DEC);
        $datatype_select = new XoopsFormSelect(_AM_XHELP_TEXT_DATATYPE, 'fld_datatype', $fld_datatype);
        $datatype_select->setDescription(_AM_XHELP_TEXT_DATATYPE_DESC);
        $datatype_select->addOptionArray($datatypes);
        $hDepts =& xhelpGetHandler('department');
        $depts =& $hDepts->getObjects();
        $dept_select = new XoopsFormSelect(_AM_XHELP_TEXT_DEPARTMENTS, 'fld_departments', $fld_departments, 5, true);
        $dept_select->setDescription(_AM_XHELP_TEXT_DEPT_DESC);
        foreach ($depts as $obj) {
            $dept_select->addOption($obj->getVar('id'), $obj->getVar('department'));
        }
        unset($depts);
        if (!$field_errors === false) {
            xhelpRenderErrors($field_errors, xhelpMakeURI(XHELP_ADMIN_URL . '/fields.php', array('op' => 'clearEditSession', 'id' => $fld_id)));
        }
        $form = new xhelpForm(_AM_XHELP_EDIT_FIELD, 'edit_field', xhelpMakeURI(XHELP_ADMIN_URL . '/fields.php', array('op' => 'editfield', 'id' => $fld_id)));
        $nameEle = new XoopsFormText(_AM_XHELP_TEXT_NAME, 'fld_name', 30, 64, $fld_name);
        $nameEle->setDescription(_AM_XHELP_TEXT_NAME_DESC);
        $form->addElement($nameEle);
        $fieldnameEle = new XoopsFormText(_AM_XHELP_TEXT_FIELDNAME, 'fld_fieldname', 30, 64, $fld_fieldname);
        $fieldnameEle->setDescription(_AM_XHELP_TEXT_FIELDNAME_DESC);
        $form->addElement($fieldnameEle);
        $descriptionEle = new XoopsFormTextArea(_AM_XHELP_TEXT_DESCRIPTION, 'fld_description', $fld_description, 5, 60);
        $descriptionEle->setDescription(_AM_XHELP_TEXT_DESCRIPTION_DESC);
        $form->addElement($descriptionEle);
        $form->addElement($dept_select);
        $form->addElement($control_select);
        $form->addElement($datatype_select);
        $required = new XoopsFormRadioYN(_AM_XHELP_TEXT_REQUIRED, 'fld_required', $fld_required);
        $required->setDescription(_AM_XHELP_TEXT_REQUIRED_DESC);
        $form->addElement($required);
        $lengthEle = new XoopsFormText(_AM_XHELP_TEXT_LENGTH, 'fld_length', 5, 5, $fld_length);
        $lengthEle->setDescription(_AM_XHELP_TEXT_LENGTH_DESC);
        $form->addElement($lengthEle);
        $widthEle = new XoopsFormText(_AM_XHELP_TEXT_WEIGHT, 'fld_weight', 5, 5, $fld_weight);
        $widthEle->setDescription(_AM_XHELP_TEXT_WEIGHT_DESC);
        $form->addElement($widthEle);
        $regex_control = new xhelpFormRegex(_AM_XHELP_TEXT_VALIDATION, 'fld_valid', $fld_validation);
        $regex_control->setDescription(_AM_XHELP_TEXT_VALIDATION_DESC);
        $regex_control->addOptionArray($regex_array);
        $form->addElement($regex_control);
        $defaultValueEle = new XoopsFormText(_AM_XHELP_TEXT_DEFAULTVALUE, 'fld_defaultvalue', 30, 100, $fld_defaultvalue);
        $defaultValueEle->setDescription(_AM_XHELP_TEXT_DEFAULTVALUE_DESC);
        $form->addElement($defaultValueEle);
        $values = new XoopsFormTextArea(_AM_XHELP_TEXT_FIELDVALUES, 'fld_values', $fld_values, 5, 60);
        $values->setDescription(_AM_XHELP_TEXT_FIELDVALUES_DESC);
        $form->addElement($values);
        $btn_tray = new XoopsFormElementTray('');
        $btn_tray->addElement(new XoopsFormButton('', 'editField', _AM_XHELP_BUTTON_SUBMIT, 'submit'));
        $btn_tray->addElement(new XoopsFormButton('', 'cancel', _AM_XHELP_BUTTON_CANCEL));
        $btn_tray->addElement(new XoopsFormHidden('id', $fld_id));
        $form->addElement($btn_tray);
        echo $form->render();
        xhelpAdminFooter();
        xoops_cp_footer();
    } else {
        //Validate Field Information
        $has_errors = false;
        $errors = array();
        $values =& _parseValues($_POST['fld_values']);
        if (!($control = xhelpGetControl($_POST['fld_controltype']))) {
            $has_errors = true;
            $errors['fld_controltype'][] = _AM_XHELP_VALID_ERR_CONTROLTYPE;
        }
        $fld_needslength = $control['needs_length'];
        $fld_needsvalues = $control['needs_values'];
        //name field filled?
        if (trim($_POST['fld_name']) == '') {
            $has_errors = true;
            $errors['fld_name'][] = _AM_XHELP_VALID_ERR_NAME;
        }
        //fieldname filled
        if (trim($_POST['fld_fieldname']) == '') {
            $has_errors = true;
            $errors['fld_fieldname'][] = _AM_XHELP_VALID_ERR_FIELDNAME;
        }
        //fieldname unique?
        $crit = new CriteriaCompo(new Criteria('id', $fld_id, '!='));
        $crit->add(new Criteria('fieldname', $_POST['fld_fieldname']));
        if ($hField->getCount($crit)) {
            $has_errors = true;
            $errors['fld_fieldname'][] = _AM_XHELP_VALID_ERR_FIELDNAME_UNIQUE;
        }
        //Length filled
        if (intval($_POST['fld_length']) == 0 && $fld_needslength == true) {
            $has_errors = true;
            $errors['fld_length'][] = sprintf(_AM_XHELP_VALID_ERR_LENGTH, _XHELP_FIELD_MINLEN, _XHELP_FIELD_MAXLEN);
        }
        //default value in value set?
        if (count($values)) {
            if (!in_array($_POST['fld_defaultvalue'], $values, true) && !array_key_exists($_POST['fld_defaultvalue'], $values)) {
                $has_errors = true;
                $errors['fld_defaultvalue'][] = _AM_XHELP_VALID_ERR_DEFAULTVALUE;
            }
            //length larger than longest value?
            $length = intval($_POST['fld_length']);
            foreach ($values as $key => $value) {
                if (strlen($key) > $length) {
                    $has_errors = true;
                    $errors['fld_values'][] = sprintf(_AM_XHELP_VALID_ERR_VALUE_LENGTH, htmlentities($key), $length);
                }
            }
        } elseif ($fld_needsvalues) {
            $has_errors = true;
            $errors['fld_values'][] = _AM_XHELP_VALID_ERR_VALUE;
        }
        if ($has_errors) {
            $afield = array();
            $afield['name'] = $_POST['fld_name'];
            $afield['description'] = $_POST['fld_description'];
            $afield['fieldname'] = $_POST['fld_fieldname'];
            $afield['departments'] = $_POST['fld_departments'];
            $afield['controltype'] = $_POST['fld_controltype'];
            $afield['datatype'] = $_POST['fld_datatype'];
            $afield['required'] = $_POST['fld_required'];
            $afield['weight'] = $_POST['fld_weight'];
            $afield['defaultvalue'] = $_POST['fld_defaultvalue'];
            $afield['values'] = $_POST['fld_values'];
            $afield['length'] = $_POST['fld_length'];
            $afield['validation'] = $_POST['fld_valid_select'] == $_POST['fld_valid_txtbox'] ? $_POST['fld_valid_select'] : $_POST['fld_valid_txtbox'];
            $session->set('xhelp_editField_' . $fld_id, $afield);
            $session->set('xhelp_editFieldErrors_' . $fld_id, $errors);
            //Redirect to edit page (display errors);
            header('Location: ' . xhelpMakeURI(XHELP_ADMIN_URL . '/fields.php', array('op' => 'editfield', 'id' => $fld_id), false));
            exit;
        }
        //Store Modified Field info
        $field->setVar('name', $_POST['fld_name']);
        $field->setVar('description', $_POST['fld_description']);
        $field->setVar('fieldname', $_POST['fld_fieldname']);
        $field->setVar('controltype', $_POST['fld_controltype']);
        $field->setVar('datatype', $_POST['fld_datatype']);
        $field->setVar('fieldlength', $_POST['fld_length']);
        $field->setVar('required', $_POST['fld_required']);
        $field->setVar('weight', $_POST['fld_weight']);
        $field->setVar('defaultvalue', $_POST['fld_defaultvalue']);
        $field->setVar('validation', $_POST['fld_valid_select'] == $_POST['fld_valid_txtbox'] ? $_POST['fld_valid_select'] : $_POST['fld_valid_txtbox']);
        $field->setValues($values);
        $field->addDepartments($_POST['fld_departments']);
        if ($hField->insert($field)) {
            _clearEditSessionVars($fld_id);
            redirect_header(xhelpMakeURI(XHELP_ADMIN_URL . '/fields.php'), 3, _AM_XHELP_MSG_FIELD_UPD_OK);
        } else {
            redirect_header(xhelpMakeURI(XHELP_ADMIN_URL . '/fields.php', array('op' => 'editfield', 'id' => $fld_id), false), 3, _AM_XHELP_MSG_FIELD_UPD_ERR);
        }
    }
}
コード例 #11
0
ファイル: file.php プロジェクト: trabisdementia/xuups
function manageFiles()
{
    global $oAdminButton, $aSortBy, $aOrderBy, $aLimitBy, $order, $limit, $start, $sort;
    $xhelpUploadDir = XHELP_UPLOAD_PATH;
    $dir_status =& xhelp_admin_getPathStatus($xhelpUploadDir, true);
    if ($dir_status == -1) {
        $can_upload = xhelp_admin_mkdir($xhelpUploadDir);
    }
    $hFile =& xhelpGetHandler('file');
    if (isset($_POST['deleteFiles'])) {
        // Delete all selected files
        $aFiles = $_POST['files'];
        $crit = new Criteria('id', "(" . implode($aFiles, ',') . ")", "IN");
        if ($hFile->deleteAll($crit)) {
            header("Location: " . XHELP_ADMIN_URL . "/file.php?op=manageFiles");
        }
        redirect_header(XHELP_ADMIN_URL . "/file.php?op=manageFiles", 3, _XHELP_MESSAGE_DELETE_FILE_ERR);
    }
    xoops_cp_header();
    echo $oAdminButton->renderButtons('manFiles');
    echo '<script type="text/javascript" src="' . XOOPS_URL . '/modules/xhelp/include/functions.js"></script>';
    echo "<form method='post' action='" . XHELP_ADMIN_URL . "/file.php?op=manageFiles'>";
    echo "<table width='100%' cellspacing='1' class='outer'>\r\n          <tr><th colspan='2'><label>" . _AM_XHELP_TEXT_TOTAL_USED_SPACE . "</label></th></tr>";
    echo "<tr><td class='head' width='20%'>" . _AM_XHELP_TEXT_ALL_ATTACH . "</td>\r\n              <td class='even'>" . xhelpDirsize($xhelpUploadDir) . "\r\n              </td>\r\n          </tr>";
    $resolvedSize = xhelpDirsize($xhelpUploadDir, true);
    echo "<tr><td class='head'>" . _AM_XHELP_TEXT_RESOLVED_ATTACH . "</td>\r\n              <td class='even'>";
    if ($resolvedSize > 0) {
        echo $resolvedSize . " <b>(" . _AM_XHELP_TEXT_DELETE_RESOLVED . "\r\n                  <a href='" . XHELP_ADMIN_URL . "/file.php?op=deleteResolved'><img src='" . XHELP_IMAGE_URL . "/button_delete.png' title='" . _AM_XHELP_TEXT_DELETE . "' name='deleteFile' /></a>)</b>";
    } else {
        echo $resolvedSize;
    }
    echo "</td>\r\n          </tr>";
    echo "</table></form>";
    $crit = new Criteria('', '');
    $crit->setOrder($order);
    $crit->setSort($sort);
    $crit->setLimit($limit);
    $crit->setStart($start);
    $files =& $hFile->getObjects($crit);
    $total = $hFile->getCount($crit);
    $nav = new XoopsPageNav($total, $limit, $start, 'start', "op=manageFiles&amp;limit={$limit}");
    echo "<form action='" . XHELP_ADMIN_URL . "/file.php?op=manageFiles' style='margin:0; padding:0;' method='post'>";
    echo "<table width='100%' cellspacing='1' class='outer'>";
    echo "<tr><td align='right'>" . _AM_XHELP_TEXT_SORT_BY . "\r\n                  <select name='sort'>";
    foreach ($aSortBy as $value => $text) {
        $sort == $value ? $selected = "selected='selected'" : ($selected = '');
        echo "<option value='{$value}' {$selected}>{$text}</option>";
    }
    echo "</select>\r\n                &nbsp;&nbsp;&nbsp;\r\n                  " . _AM_XHELP_TEXT_ORDER_BY . "\r\n                  <select name='order'>";
    foreach ($aOrderBy as $value => $text) {
        $order == $value ? $selected = "selected='selected'" : ($selected = '');
        echo "<option value='{$value}' {$selected}>{$text}</option>";
    }
    echo "</select>\r\n                  &nbsp;&nbsp;&nbsp;\r\n                  " . _AM_XHELP_TEXT_NUMBER_PER_PAGE . "\r\n                  <select name='limit'>";
    foreach ($aLimitBy as $value => $text) {
        $limit == $value ? $selected = "selected='selected'" : ($selected = '');
        echo "<option value='{$value}' {$selected}>{$text}</option>";
    }
    echo "</select>\r\n                  <input type='submit' name='file_sort' id='file_sort' value='" . _AM_XHELP_BUTTON_SUBMIT . "' />\r\n              </td>\r\n          </tr>";
    echo "</table></form>";
    echo "<form method='post' action='" . XHELP_ADMIN_URL . "/file.php?op=manageFiles'>";
    echo "<table width='100%' cellspacing='1' class='outer'>\r\n          <tr><th colspan='6'><label>" . _AM_XHELP_TEXT_MANAGE_FILES . "</label></th></tr>";
    if ($total != 0) {
        echo "<tr class='head'>\r\n                  <td>" . _AM_XHELP_TEXT_ID . "</td>\r\n                  <td>" . _AM_XHELP_TEXT_TICKETID . "</td>\r\n                  <td>" . _AM_XHELP_TEXT_FILENAME . "</td>\r\n                  <td>" . _AM_XHELP_TEXT_SIZE . "</td>\r\n                  <td>" . _AM_XHELP_TEXT_MIMETYPE . "</td>\r\n                  <td>" . _AM_XHELP_TEXT_ACTIONS . "</td>\r\n              </tr>";
        foreach ($files as $file) {
            $filepath = XHELP_BASE_URL . '/viewFile.php?id=' . $file->getVar('id');
            $ticketpath = XHELP_BASE_URL . '/ticket.php?id=' . $file->getVar('ticketid');
            $filesize = filesize($xhelpUploadDir . '/' . $file->getVar('filename'));
            echo "<tr class='even'>\r\n                      <td><input type='checkbox' name='files[]' value='" . $file->getVar('id') . "' /> " . $file->getVar('id') . "</td>\r\n                      <td><a href='" . $ticketpath . "' target='_BLANK'>" . $file->getVar('ticketid') . "</a></td>\r\n                      <td><a href='" . $filepath . "'>" . $file->getVar('filename') . "</a></td>\r\n                      <td>" . xhelpPrettyBytes($filesize) . "</td>\r\n                      <td>" . $file->getVar('mimetype') . "</td>\r\n                      <td>\r\n                          <a href='" . XHELP_ADMIN_URL . "/file.php?op=deleteFile&amp;fileid=" . $file->getVar('id') . "'><img src='" . XOOPS_URL . "/modules/xhelp/images/button_delete.png' title='" . _AM_XHELP_TEXT_DELETE . "' name='deleteFile' /></a>\r\n                      </td>\r\n                 </tr>";
        }
        echo "<tr class='foot'><td colspan='6'>\r\n                                   <input type='checkbox' name='checkAllFiles' value='0' onclick='selectAll(this.form,\"files[]\",this.checked);' />\r\n                                   <input type='submit' name='deleteFiles' id='deleteFiles' value='" . _AM_XHELP_BUTTON_DELETE . "' /></td></tr>";
        echo "</table></form>";
        echo "<div id='status_nav'>" . $nav->renderNav() . "</div>";
    } else {
        echo "<tr class='even'<td colspan='6'>" . _AM_XHELP_TEXT_NO_FILES . "</td></tr>";
        echo "</table></form>";
    }
    xhelpAdminFooter();
    xoops_cp_footer();
}