Пример #1
0
    function drawBody()
    {
        $where = array('ms.uid' => $this->um->uid, '^1' => "AND m.mid=ms.mid AND flag<>'deleted' AND", 'folder' => $this->folder);
        $res = $this->db->select('*, m.uid sender, ms.uid recipient', 'sitebar_message m, sitebar_message_folder ms', $where);
        $midRecs = $this->db->fetchRecords($res);
        $command = SB_reqVal('command');
        $webMids = SB_reqVal('mid');
        $seenMid = array();
        foreach ($midRecs as $rec) {
            $mid = $rec['mid'];
            $uid = $rec['sender'];
            $fromuser = $this->um->getUser($uid);
            $role = $rec['role'];
            $to = $rec['to_label'];
            $date = $rec['sent'];
            $expires = $rec['expires'];
            $from = '';
            $subject = $rec['subject'];
            $message = $rec['message'];
            $format = $rec['format'];
            $folder = $rec['folder'];
            $flag = $rec['flag'];
            if (isset($seenMid[$mid])) {
                continue;
            }
            $seenMid[$mid] = 1;
            if (isset($webMids[$mid])) {
                if ($this->folder == 'outbox') {
                    if (isset($command['back'])) {
                        $this->db->delete('sitebar_message', array('mid' => $mid));
                        $this->db->delete('sitebar_message_folder', array('mid' => $mid));
                        continue;
                    }
                    if (isset($command['expire'])) {
                        $this->db->update('sitebar_message_folder', array('flag' => 'expired'), array('mid' => $mid));
                    }
                    if (isset($command['delete'])) {
                        $this->update($mid, 'outbox', 'deleted');
                        continue;
                    }
                } else {
                    if (isset($command['mark'])) {
                        $flag = 'read';
                        $this->update($mid, 'inbox', 'read');
                        if ($this->ajax) {
                            echo $mid . ';read';
                        }
                    }
                    if (isset($command['unmark'])) {
                        $flag = 'seen';
                        $this->update($mid, 'inbox', 'seen');
                        if ($this->ajax) {
                            echo $mid . ';new';
                        }
                    }
                    if (isset($command['save'])) {
                        $this->update($mid, 'saved');
                        continue;
                    }
                    if (isset($command['delete'])) {
                        $this->update($mid, null, 'deleted');
                        continue;
                    }
                }
            }
            switch ($as) {
                case 'admins':
                    $from = SB_T('Administrators') . ' (' . $fromuser['fullname'] . ')';
                    break;
                case 'moderator':
                    $gid = intval($this->db->getData('messenger', $mid . '_gid'));
                    if (!$this->um->isModerator($gid)) {
                        continue;
                    }
                    $group = $this->um->getGroup($gid);
                    $from = SB_T('Moderator of %s Group', $group['name']) . ' (' . $fromuser['fullname'] . ')';
                    break;
                default:
                    $from = $fromuser['fullname'];
                    break;
            }
            if ($this->folder == 'inbox' || $this->folder == 'saved') {
                $from = "<a title='" . SB_T('Reply') . "' href='command.php?command=Send Message to User&uid={$uid}&inre={$mid}'>" . $from . "</a>";
            }
            if ($format == 'html') {
                $message = stripslashes($message);
            } else {
                $message = "<pre>" . $message . "</pre>";
            }
            $highlight = '';
            $isnew = false;
            if ($folder == 'inbox' && ($flag == 'new' || $flag == 'seen')) {
                $this->displayedNew++;
                $highlight = ' highlight';
                $isnew = true;
                if ($flag == 'new') {
                    $this->update($mid, 'inbox', 'seen');
                }
            }
            $img = SB_Page::relBaseUrl() . sprintf('skins/msg_%s.gif', $isnew ? 'new' : 'read');
            $checkbox = "<input class='checkBox' type='checkbox' name='mid[{$mid}]'>";
            if (!$this->ajax) {
                ?>
<div id='message<?php 
                echo $mid;
                ?>
' class='message'>
<table class='cmnMenu'>
<tr>
    <td class='icon'><img id="img<?php 
                echo $mid;
                ?>
" src="<?php 
                echo $img;
                ?>
" <?php 
                if ($this->folder == 'inbox') {
                    ?>
onclick='SB_messengerToggleItem(this,<?php 
                    echo $mid;
                    ?>
)'<?php 
                }
                ?>
></td>
    <td class='cmnMenuItem<?php 
                echo $highlight;
                ?>
'><?php 
                echo SB_T('From');
                ?>
</td>
    <td><?php 
                echo $from;
                ?>
</td>
</tr>
<?php 
                if ($this->folder == 'outbox' && $to) {
                    ?>
<tr>
    <td class='check'><?php 
                    echo $checkbox;
                    $checkbox = '&nbsp;';
                    ?>
</td>
    <td class='cmnMenuItem<?php 
                    echo $highlight;
                    ?>
'><?php 
                    echo SB_T('To');
                    ?>
</td>
    <td><?php 
                    echo $to;
                    ?>
</td>
</tr>
<?php 
                }
                ?>
<tr>
    <td class='check'><?php 
                echo $checkbox;
                ?>
</td>
    <td class='cmnMenuItem<?php 
                echo $highlight;
                ?>
'><?php 
                echo SB_T('Date');
                ?>
</td>
    <td><?php 
                echo $date;
                ?>
</td>
</tr>
<tr>
    <td class='status'>&nbsp;</td>
    <td class='cmnMenuItem<?php 
                echo $highlight;
                ?>
'><?php 
                echo SB_T('Subject');
                ?>
</td>
    <td>
<?php 
                echo stripslashes($subject);
                ?>
    </td>
</tr>
<?php 
                if ($this->folder == 'outbox') {
                    if ($expires != '0000-00-00 00:00:00') {
                        ?>
<tr>
    <td class='check'>&nbsp;</td>
    <td class='cmnMenuItem'><?php 
                        echo SB_T('Expiration');
                        ?>
</td>
    <td><?php 
                        echo $expires;
                        ?>
</td>
</tr>
<?php 
                    }
                    $states = array('inbox_new' => 'messenger::state_unread', 'inbox_seen' => 'messenger::state_seen', 'inbox_read' => 'messenger::state_read', 'saved' => 'messenger::state_saved', 'deleted' => 'messenger::state_deleted', 'expired' => 'messenger::state_expired');
                    $statesWhere = array('inbox_new' => "folder='inbox' AND flag='new'", 'inbox_seen' => "folder='inbox' AND flag='seen'", 'inbox_read' => "folder='inbox' AND flag='read'", 'saved' => "folder='saved'", 'deleted' => "folder='trash'", 'expired' => "folder='expired'");
                    $breakdown = '';
                    foreach ($states as $status => $label) {
                        $res = $this->db->select('count(*) count', 'sitebar_message_folder', "mid={$mid} AND " . $statesWhere[$status]);
                        $countRec = $this->db->fetchRecord($res);
                        if ($countRec['count'] > 0) {
                            if (SB_reqVal('drill') == $status && is_string($webMids) && $mid == $webMids) {
                                if ($breakdown != '') {
                                    $breakdown .= '<br>';
                                }
                                $breakdown .= SB_P($label) . ": ";
                                $res = $this->db->select('uid', 'sitebar_message_folder', "mid={$mid} AND " . $statesWhere[$status]);
                                foreach ($this->db->fetchRecords($res) as $uidRec) {
                                    $user = $this->um->getUser($uidRec['uid']);
                                    if ($this->um->isAdmin()) {
                                        $breakdown .= '<a href="command.php?command=Modify%20User&amp;uid=' . $uidRec['uid'] . '">' . $user['username'] . '</a> ';
                                    } else {
                                        $breakdown .= $user['username'] . ' ';
                                    }
                                }
                                $breakdown .= "<br>";
                            } else {
                                $breakdown .= '<a class="states" href="' . $this->getUrl(array('folder' => $this->folder, 'mid' => $mid, 'drill' => $status)) . '">' . SB_P($label) . '</a> [' . $countRec['count'] . '] ';
                            }
                        }
                    }
                    ?>
<tr>
    <td class='status'>&nbsp;</td>
    <td class='cmnMenuItem'><?php 
                    echo SB_T("Status");
                    ?>
</td>
    <td><?php 
                    echo $breakdown;
                    ?>
</td>
</tr>
<?php 
                }
                ?>
<tr>
    <td class='message' colspan='3'><?php 
                echo $message;
                ?>
</td>
</tr>
</table>
</div>
<?php 
            }
        }
        if ($this->folder == 'inbox' && is_array($command)) {
            $this->db->lock($tables = array('sitebar_data' => 'WRITE', 'sitebar_user_data' => 'WRITE'));
            $this->db->setUserData('messenger', $this->um->uid, 'new', $this->displayedNew);
            $this->db->unlock();
        }
    }
Пример #2
0
    function drawToolBar()
    {
        // There must not be any place between the images, therefore
        // those funny tag endings.
        $coloring = 'onmousedown="SB_buttonDown(this);" ' . 'onmouseup="SB_buttonUp(this);" ' . 'onmouseover="SB_buttonOver(this);' . ($this->useToolTips ? 'SB_toolTip(this,event);' : '') . '" ' . 'onmouseout="SB_buttonOut(this);' . ($this->useToolTips ? 'SB_toolTipHide()' : '') . ';"';
        $title = $this->useToolTips ? 'x_title' : 'title';
        $favicon = '';
        if ($this->um->getParam('user', 'use_search_engine')) {
            $favicon = $this->um->getParamB64('user', 'search_engine_ico');
            if ($this->um->getParam('config', 'use_favicon_cache')) {
                $favicon = SB_Page::cdnBaseUrl() . "favicon.php?" . md5($favicon) . '=' . base64_encode($favicon);
            }
        }
        $usefilter = true;
        ?>
<div id="toolbarPlace" class="hidden"></div>
<div id="toolbar" class="cmnSubTitle">
    <div id="tlbSearch"><input id="fldSearch" class="siteBarPageBackground" type="text"
             onkeyup="SB_storeSearch(this); var e=(event?event:window.event); if (e.keyCode==13) SB_defaultSearch('<?php 
        echo SB_Page::targetWindow();
        ?>
','<?php 
        echo $this->um->getParam('user', 'default_search_tool');
        ?>
');"
             value="<?php 
        echo SB_safeVal($_COOKIE, 'SB3SEARCH');
        ?>
"><?php 
        if ($usefilter) {
            ?>
<img id="btnFilter" src="<?php 
            echo SB_Skin::imgsrc('filter');
            ?>
"
             <?php 
            echo $title;
            ?>
="<?php 
            echo SB_T('Filter Loaded Bookmarks');
            ?>
"
             onclick="SB_filter(true)" <?php 
            echo $coloring;
            ?>
 alt="F"
       ><?php 
        }
        if (!$this->um->getParam('user', 'hide_xslt') || $this->um->getParam('user', 'use_search_engine')) {
            ?>
<a href="<?php 
            echo SB_Page::absBaseUrl();
            ?>
search.php" <?php 
            echo SB_Page::target();
            ?>
            ><img id="btnSearch" src="<?php 
            echo SB_Skin::imgsrc('search');
            ?>
"
             <?php 
            echo $title;
            ?>
="<?php 
            echo SB_T('Backend Bookmark Search');
            ?>
"
             <?php 
            echo $coloring;
            ?>
 alt=""
       ></a><?php 
        }
        if ($this->um->getParam('user', 'use_search_engine')) {
            ?>
<a href="<?php 
            echo SB_Page::absBaseUrl();
            ?>
search.php?web=1"
             <?php 
            echo SB_Page::target();
            ?>
><img id="btnSearchWeb" src="<?php 
            echo $favicon;
            ?>
"
             <?php 
            echo $title;
            ?>
="<?php 
            echo SB_T('Search Web');
            ?>
"
             <?php 
            echo $coloring;
            ?>
 alt=""
      ></a><?php 
        }
        ?>
</div>
      <div id="tlbOther"><img id="btnCollapse" src="<?php 
        echo SB_Skin::imgsrc('collapse');
        ?>
"
             <?php 
        echo $title;
        ?>
="<?php 
        echo SB_T('Collapse/Expand All');
        ?>
"
             onclick="SB_collapseAll();" <?php 
        echo $coloring;
        ?>
 alt=""
       ><?php 
        if ($this->um->getParam('user', 'use_hiding')) {
            ?>
<img id="btnReloadAll" src="<?php 
            echo SB_Skin::imgsrc('reload_all');
            ?>
"
             <?php 
            echo $title;
            ?>
="<?php 
            echo SB_T('Reload with Hidden Folders');
            ?>
"
             onclick="SB_reloadAll();" <?php 
            echo $coloring;
            ?>
 alt=""
       ><?php 
        }
        ?>
<img id="btnReload" src="<?php 
        echo SB_Skin::imgsrc('reload');
        ?>
"
             <?php 
        echo $title;
        ?>
="<?php 
        echo SB_T('Reload');
        ?>
"
             onclick="SB_reloadPage();" <?php 
        echo $coloring;
        ?>
 alt=""
       ></div>
</div>
<?php 
        $msgFile = "./inc/message.inc.php";
        if (is_file($msgFile)) {
            include $msgFile;
        }
        foreach ($this->um->plugins as $plugin) {
            if (isset($plugin['message']) && $plugin['message']) {
                include $plugin['dir'] . '/message.inc.php';
            }
        }
        $messageCountNew = $this->um->messengerGetNewCount();
        if ($messageCountNew != 0) {
            $readurl = SB_Page::relBaseUrl() . 'messenger.php';
            $target = SB_Page::target();
            $img = SB_Page::relBaseUrl() . 'skins/msg_new.gif';
            $message = '';
            if ($messageCountNew == 1) {
                $message = SB_T("You have a new message!");
            } else {
                $message = SB_T("You have %d new messages!", array($messageCountNew));
            }
            echo <<<_DOC
<div class="cmnSubTitle" id="messengerInformation">
<a style="width:100%; color:black; text-decoration:none;" href="{$readurl}" {$target}>{$message}<img src="{$img}"></a>
</div>
_DOC;
        }
        $groups = $this->um->getPendingGroups();
        if (!$this->um->isAnonymous() && count($groups)) {
            echo <<<_DOC
<div class="cmnSubTitle" id="pendingInvitation">
_DOC;
            foreach ($groups as $gid => $rec) {
                $user = $this->um->getUser($rec['invitator']);
                $message = SB_P('sitebar::invitation', array($user['fullname'], $rec['name']));
                $ahref = SB_Page::absBaseUrl() . 'command.php?command=Accept Membership&amp;do=yes&amp;gid=' . $gid;
                $atext = SB_T('Accept');
                $rhref = SB_Page::absBaseUrl() . 'command.php?command=Reject Membership&amp;do=yes&amp;gid=' . $gid;
                $rtext = SB_T('Reject');
                echo <<<_DOC
<div>
    <table>
        <tr>
          <td class='pendingInvitationLabel'>{$message}</td>
          <td class='pendingInvitationButtons'>
              <span class='accept'><a href='{$ahref}'>{$atext}</a></span><br>
              <span class='reject'><a href='{$rhref}'>{$rtext}</a></span>
          </td>
        </tr>
    </table>
</div>
_DOC;
            }
        }
        echo "</div>\n";
    }
Пример #3
0
 function head()
 {
     // We must have it on one line for MS IE
     echo '<div id="logo"><a href="' . SB_Page::relBaseUrl() . 'integrator.php" ' . SB_Page::target() . '><img title="SiteBar Integrator" src="' . SB_Skin::imgsrc('logo') . '" alt=""></a></div>' . "\r";
 }
Пример #4
0
    function _buildSharingList($params)
    {
        $groups = $this->um->getGroups();
        // We may display a subset here
        $ownGroups = $this->um->getOwnGroups();
        $myGroups = $this->um->getUserGroups();
        $publicGroups = $this->um->getParamArray('config', 'public_groups');
        $node = $params['node'];
        if (count($ownGroups) == 0 && $node->isMyTree()) {
            $groups = $this->um->getParamArray('config', 'default_groups');
            foreach ($groups as $groupname) {
                $group = array('uid' => $this->um->uid, 'name' => $groupname);
                $this->um->addGroup($group);
            }
            $groups = $this->um->getGroups();
            // We may display a subset here
            $ownGroups = $this->um->getOwnGroups();
            $myGroups = $this->um->getUserGroups();
        }
        $expertMode = $this->um->getParam('user', 'expert_mode');
        // Should we use expert mode?
        foreach ($groups as $gid => $rec) {
            $acl = $node->getGroupACL($gid);
            $parentACL = $node->getParentACL($gid);
            if (!$acl) {
                $acl = $parentACL;
            }
            $aclSum = $acl['allow_insert'] + $acl['allow_update'] + $acl['allow_delete'];
            $parentSum = $parentACL['allow_insert'] + $parentACL['allow_update'] + $parentACL['allow_delete'];
            if ($aclSum > 0 && $aclSum < 3 || $parentSum > 0 && $parentSum < 3) {
                $expertMode = true;
            }
        }
        ?>
    <table cellpadding='1'>
        <tr>
<?php 
        if ($expertMode) {
            ?>
            <th class="group"><?php 
            echo SB_T('Group');
            ?>
</th>
            <th class="right"><?php 
            echo SB_T('R');
            ?>
</th>
            <th class="right"><?php 
            echo SB_T('A');
            ?>
</th>
            <th class="right"><?php 
            echo SB_T('M');
            ?>
</th>
            <th class="right"><?php 
            echo SB_T('D');
            ?>
</th>
<?php 
        } else {
            ?>
            <th class="group"><?php 
            echo SB_T('Group');
            ?>
</th>
            <th class="right"><?php 
            echo SB_T('Read');
            ?>
</th>
            <th class="right"><?php 
            echo SB_T('Write');
            ?>
</th>
<?php 
        }
        ?>
        </tr>
<?php 
        foreach ($groups as $gid => $rec) {
            $isMyGroup = isset($myGroups[$gid]);
            $isOwnGroup = isset($ownGroups[$gid]);
            $isPublic = in_array($rec['name'], $publicGroups);
            $acl = $node->getGroupACL($gid);
            $parentACL = $node->getParentACL($gid);
            if (!$acl) {
                $acl = $parentACL;
            }
            $aclSum = $acl['allow_select'] + $acl['allow_insert'] + $acl['allow_update'] + $acl['allow_delete'];
            $memberCanShare = $isOwnGroup || $isMyGroup && $myGroups[$gid]['share'];
            $memberCanUnShare = $isOwnGroup || $isMyGroup && $myGroups[$gid]['moderator'];
            $canShare = $node->isMyTree() && $memberCanShare;
            $canUnShare = $aclSum && ($node->isMyTree() || $memberCanUnShare);
            if (!$canShare && !$canUnShare && !$isMyGroup) {
                continue;
            }
            $showGroup = false;
            $hasMembers = false;
            if ($memberCanUnShare) {
                $members = $this->um->getMembers($gid);
                $hasMembers = count($members);
                $members = null;
            }
            $params = "nid_acl={$node->id}&amp;command_gid={$gid}";
            $commands = array(array('command' => 'Send Message to User', 'enabled' => !$isOwnGroup, 'icon' => 'command_message', 'label' => SB_T('Send message to group owner'), 'uriparams' => 'uid=' . $rec['uid']), array('command' => 'Invite Members', 'enabled' => !$isPublic && $memberCanUnShare, 'icon' => 'command_invite_members', 'uriparams' => $params), array('command' => 'Edit Members', 'enabled' => !$isPublic && $memberCanUnShare && $hasMembers, 'icon' => 'command_edit_members', 'uriparams' => $params), array('command' => 'Leave Group', 'enabled' => !$isPublic && !$isOwnGroup && $isMyGroup, 'icon' => 'command_leave_group', 'uriparams' => $params));
            ?>
        <tr id="group<?php 
            echo $gid;
            ?>
a" class="group" style="visibility:collapse">
            <td rowspan=<?php 
            echo $expertMode ? 2 : 1;
            ?>
 class="group iconcommands">
<?php 
            foreach ($commands as $command) {
                if (!isset($command['label'])) {
                    $command['label'] = SB_T($command['command']);
                }
                $img = '<img src="' . SB_Page::relBaseUrl() . 'skins/' . $command['icon'] . ($command['enabled'] ? '' : '_inactive') . '.png" ' . ($linkopen = "");
                $linkclose = "";
                if ($command['enabled']) {
                    $img .= 'onmousedown="SB_buttonDown(this,true);" ' . 'onmouseup="SB_buttonUp(this,true);" ' . 'onmouseover="SB_buttonOver(this,true);' . ($this->useToolTips ? 'SB_toolTip(this,event);' : '') . '" ' . 'onmouseout="SB_buttonOut(this,true);' . ($this->useToolTips ? 'SB_toolTipHide()' : '') . ';" ' . ($this->useToolTips ? 'x_title' : 'title') . '="' . $command['label'] . '" ';
                    $linkopen = '<a class="iconcommand" href="command.php?command=' . $command['command'] . '&amp;' . $command['uriparams'] . '">';
                    $linkclose = '</a> ';
                } else {
                    $img .= $this->getToolTip(array('title' => $command['label']));
                }
                echo $linkopen . $img . ' />' . $linkclose . ' ';
            }
            ?>
                <br><?php 
            echo $isOwnGroup ? $rec['name'] : $rec['completenamehtml'];
            ?>
            </td>

<?php 
            if ($expertMode) {
                foreach ($this->tree->rights as $right) {
                    if ($parentACL && $parentACL['allow_' . $right]) {
                        $showGroup = true;
                    }
                    ?>
            <td class="right">
                <input type="checkbox" disabled <?php 
                    echo $parentACL && $parentACL['allow_' . $right] ? 'checked' : '';
                    ?>
>
            </td>
<?php 
                }
            } else {
                $readOnly = $parentACL && $parentACL['allow_select'];
                $readWrite = $parentACL && $parentACL['allow_insert'] && $parentACL['allow_update'] && $parentACL['allow_delete'];
                if ($readOnly || $readWrite) {
                    $showGroup = true;
                }
            }
            if ($expertMode) {
                ?>
        </tr>
        <tr id="group<?php 
                echo $gid;
                ?>
b" style="visibility:collapse">
<?php 
                foreach ($this->tree->rights as $right) {
                    $isSet = $acl && $acl['allow_' . $right];
                    $canChange = (!$isSet && $canShare || $isSet && $canUnShare) && ($right == 'select' || !$isPublic);
                    if ($isSet || $canChange) {
                        $showGroup = true;
                    }
                    ?>
            <td class='right'>
                <input type='checkbox' value='1' <?php 
                    echo $canChange ? '' : 'disabled';
                    ?>
                    name='<?php 
                    echo $right . '_' . $gid;
                    ?>
' <?php 
                    echo $isSet ? 'checked' : '';
                    ?>
>
            </td>
<?php 
                }
            } else {
                $isSetRO = $acl && $acl['allow_select'];
                // Other rights must be set the same way when we are here
                $isSetRW = $acl && $acl['allow_update'];
                $canChangeRO = !$isSetRO && $canShare || $isSetRO && $canUnShare;
                $canChangeRW = !$isPublic && (!$isSetRW && $canShare) || $isSetRW && $canUnShare;
                if ($isSetRO || $canChangeRO || ($isSetRW || $canChangeRW)) {
                    $showGroup = true;
                }
                ?>
            <td class='right'>
               <input type='checkbox' value='1' <?php 
                echo $canChangeRO ? '' : 'disabled';
                ?>
                    onchange='if (!this.checked) this.form.<?php 
                echo 'rw_' . $gid;
                ?>
.checked=false;'
                    name='<?php 
                echo 'select_' . $gid;
                ?>
' <?php 
                echo $isSetRO ? 'checked' : '';
                ?>
>
            </td>
            <td class='right'>
               <input type='checkbox' value='1' <?php 
                echo $canChangeRW ? '' : 'disabled';
                ?>
                    onchange='if (this.checked) this.form.<?php 
                echo 'select_' . $gid;
                ?>
.checked=true;'
                    name='<?php 
                echo 'rw_' . $gid;
                ?>
' <?php 
                echo $isSetRW ? 'checked' : '';
                ?>
>
            </td>
<?php 
            }
            ?>
        </tr>
<?php 
            if ($showGroup) {
                echo "<script>SB_showShareGroup({$gid});</script>";
            }
        }
        ?>
    </table>
<?php 
        if ($expertMode) {
            ?>
    <div class="legend"><?php 
            echo SB_P('command::security_legend');
            ?>
</div>
<?php 
        }
    }