Exemple #1
0
/**
 * Shows thread for me with some user
 * 
 * @param string $threadUser  user to show thread
 * 
 * @return string
 */
function im_ThreadShow($threadUser)
{
    global $ubillingConfig;
    $altCfg = $ubillingConfig->getAlter();
    $me = whoami();
    @($employeeNames = unserialize(ts_GetAllEmployeeLoginsCached()));
    $threadUser = mysql_real_escape_string($threadUser);
    $adminName = isset($employeeNames[$threadUser]) ? $employeeNames[$threadUser] : $threadUser;
    $result = __('No conversations with') . ' ' . $adminName . ' ' . __('yet') . wf_delimiter();
    $rows = '';
    $query = "SELECT * from `ub_im` WHERE (`to`='" . $me . "' AND `from`='" . $threadUser . "')  OR (`to`='" . $threadUser . "' AND `from`='" . $me . "') ORDER BY `date` DESC";
    $alldata = simple_queryall($query);
    if (!empty($alldata)) {
        foreach ($alldata as $io => $each) {
            //read icon
            $readIcon = $each['read'] == '0' ? wf_img("skins/icon_inactive.gif", __('Unread message')) : '';
            $fromName = isset($employeeNames[$each['from']]) ? $employeeNames[$each['from']] : $each['from'];
            $cells = wf_TableCell(wf_tag('b') . $fromName . wf_tag('b', true), '20%', '', 'align="center"');
            $cells .= wf_TableCell($each['date'] . ' ' . $readIcon, '80%');
            $rows .= wf_TableRow($cells, 'row2');
            $messageText = nl2br($each['text']);
            if (!isset($altCfg['UBIM_NO_LINKIFY'])) {
                $messageText = im_linkify($messageText);
            } else {
                if (!$altCfg['UBIM_NO_LINKIFY']) {
                    $messageText = im_linkify($messageText);
                }
            }
            $cells = wf_TableCell(gravatar_ShowAdminAvatar($each['from'], '64'), '', 'row3', 'align="center"');
            $cells .= wf_TableCell($messageText, '', 'row3');
            $rows .= wf_TableRow($cells);
        }
        $result = wf_TableBody($rows, '100%', '0');
        //mark all unread messages as read now
        im_ThreadMarkAsRead($threadUser);
    }
    return $result;
}
 /**
  * Returns list of available comments for some item
  * 
  * @param string $item
  * @return string
  */
 public function renderComments($item)
 {
     $this->setItem($item);
     $this->loadComments();
     $this->commentSaver();
     @($employeeLogins = unserialize(ts_GetAllEmployeeLoginsCached()));
     $result = '';
     $rows = '';
     if (!empty($this->data)) {
         foreach ($this->data as $io => $each) {
             $authorRealname = isset($employeeLogins[$each['admin']]) ? $employeeLogins[$each['admin']] : $each['admin'];
             $authorName = wf_tag('center') . wf_tag('b') . $authorRealname . wf_tag('b', true) . wf_tag('center', true);
             $authorAvatar = wf_tag('center') . @gravatar_ShowAdminAvatar($each['admin'], '64') . wf_tag('center', true);
             $commentController = wf_tag('center') . $this->commentControls($each['id']) . wf_tag('center', true);
             $authorPanel = $authorName . wf_tag('br') . $authorAvatar . wf_tag('br') . $commentController;
             $commentText = nl2br($each['text']);
             if (wf_CheckPost(array('adcommentseditid'))) {
                 if ($_POST['adcommentseditid'] == $each['id']) {
                     $commentText = $this->commentEditForm($each['id']);
                 } else {
                     $commentText = nl2br($each['text']);
                 }
             }
             $cells = wf_TableCell('', '20%');
             $cells .= wf_TableCell($each['date']);
             $rows .= wf_TableRow($cells, 'row2');
             $cells = wf_TableCell($authorPanel);
             $cells .= wf_TableCell($commentText);
             $rows .= wf_TableRow($cells, 'row3');
         }
         $result .= wf_TableBody($rows, '100%', '0', '');
     }
     $result .= $this->commentAddForm();
     return $result;
 }
/**
 * Renders ticket, all of replies and all needed controls/forms for they
 * 
 * @param int $ticketid
 * 
 * @return string
 */
function web_TicketDialogue($ticketid)
{
    $ticketid = vf($ticketid, 3);
    $ticketdata = zb_TicketGetData($ticketid);
    $ticketreplies = zb_TicketGetReplies($ticketid);
    $result = wf_tag('p', false, '', 'align="right"') . wf_Link('?module=ticketing', 'Back to tickets list', true, 'ubButton') . wf_tag('p', true);
    if (!empty($ticketdata)) {
        $alladdress = zb_AddressGetFulladdresslist();
        $allrealnames = zb_UserGetAllRealnames();
        $alltariffs = zb_TariffsGetAllUsers();
        $allcash = zb_CashGetAllUsers();
        $allcredits = zb_CreditGetAllUsers();
        $alluserips = zb_UserGetAllIPs();
        if ($ticketdata['status']) {
            $actionlink = wf_Link('?module=ticketing&openticket=' . $ticketdata['id'], 'Open', false, 'ubButton');
        } else {
            $actionlink = wf_Link('?module=ticketing&closeticket=' . $ticketdata['id'], 'Close', false, 'ubButton');
        }
        $tablecells = wf_TableCell(__('ID'));
        $tablecells .= wf_TableCell(__('Date'));
        $tablecells .= wf_TableCell(__('Login'));
        $tablecells .= wf_TableCell(__('Real Name'));
        $tablecells .= wf_TableCell(__('Full address'));
        $tablecells .= wf_TableCell(__('IP'));
        $tablecells .= wf_TableCell(__('Tariff'));
        $tablecells .= wf_TableCell(__('Balance'));
        $tablecells .= wf_TableCell(__('Credit'));
        $tablecells .= wf_TableCell(__('Processed'));
        $tablerows = wf_TableRow($tablecells, 'row1');
        $tablecells = wf_TableCell($ticketdata['id']);
        $tablecells .= wf_TableCell($ticketdata['date']);
        $profilelink = wf_Link('?module=userprofile&username='******'from'], web_profile_icon() . ' ' . $ticketdata['from']);
        $tablecells .= wf_TableCell($profilelink);
        $tablecells .= wf_TableCell(@$allrealnames[$ticketdata['from']]);
        $tablecells .= wf_TableCell(@$alladdress[$ticketdata['from']]);
        $tablecells .= wf_TableCell(@$alluserips[$ticketdata['from']]);
        $tablecells .= wf_TableCell(@$alltariffs[$ticketdata['from']]);
        $tablecells .= wf_TableCell(@$allcash[$ticketdata['from']]);
        $tablecells .= wf_TableCell(@$allcredits[$ticketdata['from']]);
        $tablecells .= wf_TableCell(web_bool_led($ticketdata['status']));
        $tablerows .= wf_TableRow($tablecells, 'row3');
        $result .= wf_TableBody($tablerows, '100%', '0');
        //ticket body
        $tickettext = strip_tags($ticketdata['text']);
        $tickettext = nl2br($tickettext);
        $tablecells = wf_TableCell('', '20%');
        $tablecells .= wf_TableCell($ticketdata['date']);
        $tablerows = wf_TableRow($tablecells, 'row2');
        $ticketauthor = wf_tag('center') . wf_tag('b') . @$allrealnames[$ticketdata['from']] . wf_tag('b', true) . wf_tag('center', true);
        $ticketavatar = wf_tag('center') . wf_img('skins/userava.png') . wf_tag('center', true);
        $ticketpanel = $ticketauthor . wf_tag('br') . $ticketavatar;
        $tablecells = wf_TableCell($ticketpanel);
        $tablecells .= wf_TableCell($tickettext);
        $tablerows .= wf_TableRow($tablecells, 'row3');
        $result .= wf_TableBody($tablerows, '100%', '0', 'glamour');
        $result .= $actionlink;
    }
    if (!empty($ticketreplies)) {
        $result .= wf_tag('h2') . __('Replies') . wf_tag('h2', true);
        $result .= wf_CleanDiv();
        foreach ($ticketreplies as $io => $eachreply) {
            //reply
            if ($eachreply['admin']) {
                $replyauthor = wf_tag('center') . wf_tag('b') . $eachreply['admin'] . wf_tag('b', true) . wf_tag('center', true);
                $replyavatar = wf_tag('center') . gravatar_ShowAdminAvatar($eachreply['admin'], '64') . wf_tag('center', true);
            } else {
                $replyauthor = wf_tag('center') . wf_tag('b') . @$allrealnames[$eachreply['from']] . wf_tag('b', true) . wf_tag('center', true);
                $replyavatar = wf_tag('center') . wf_img('skins/userava.png') . wf_tag('center', true);
            }
            $replyactions = wf_tag('center');
            $replyactions .= wf_JSAlert('?module=ticketing&showticket=' . $ticketdata['id'] . '&deletereply=' . $eachreply['id'], web_delete_icon(), 'Removing this may lead to irreparable results') . ' ';
            $replyactions .= wf_JSAlert('?module=ticketing&showticket=' . $ticketdata['id'] . '&editreply=' . $eachreply['id'], web_edit_icon(), 'Are you serious');
            $replyactions .= wf_tag('center', true);
            // reply body
            if (isset($_GET['editreply'])) {
                if ($_GET['editreply'] == $eachreply['id']) {
                    //is this reply editing?
                    $replytext = web_TicketReplyEditForm($eachreply['id']);
                } else {
                    //not this ticket edit
                    $replytext = strip_tags($eachreply['text']);
                }
            } else {
                //normal text by default
                $replytext = strip_tags($eachreply['text']);
                $replytext = nl2br($replytext);
            }
            $replypanel = $replyauthor . wf_tag('br') . $replyavatar . wf_tag('br') . $replyactions;
            $tablecells = wf_TableCell('', '20%');
            $tablecells .= wf_TableCell($eachreply['date']);
            $tablerows = wf_TableRow($tablecells, 'row2');
            $tablecells = wf_TableCell($replypanel);
            $tablecells .= wf_TableCell($replytext);
            $tablerows .= wf_TableRow($tablecells, 'row3');
            $result .= wf_TableBody($tablerows, '100%', '0', 'glamour');
            $result .= wf_CleanDiv();
        }
    }
    //reply form and previous tickets
    $allprevious = zb_TicketsGetAllByUser($ticketdata['from']);
    $previoustickets = '';
    if (!empty($allprevious)) {
        $previoustickets = wf_tag('h2') . __('All tickets by this user') . wf_tag('h2', true);
        foreach ($allprevious as $io => $eachprevious) {
            $tablecells = wf_TableCell($eachprevious['date']);
            $tablecells .= wf_TableCell(web_bool_led($eachprevious['status']));
            $prevaction = wf_Link('?module=ticketing&showticket=' . $eachprevious['id'], 'Show', false, 'ubButton');
            $tablecells .= wf_TableCell($prevaction);
            $tablerows = wf_TableRow($tablecells, 'row3');
            $previoustickets .= wf_TableBody($tablerows, '100%', '0');
        }
    }
    $tablecells = wf_TableCell(web_TicketReplyForm($ticketid), '50%', '', 'valign="top"');
    $tablecells .= wf_TableCell($previoustickets, '50%', '', 'valign="top"');
    $tablerows = wf_TableRow($tablecells);
    $result .= wf_TableBody($tablerows, '100%', '0', 'glamour');
    $result .= wf_CleanDiv();
    return $result;
}