steffen: server/kolab-horde-fbview/kolab-horde-fbview/fbview/services/portal edit.php, NONE, 1.1 index.php, NONE, 1.1 menu.php, NONE, 1.1 mobile.php, NONE, 1.1 rpcsum.php, NONE, 1.1

cvs at intevation.de cvs at intevation.de
Mon Oct 31 12:43:35 CET 2005


Author: steffen

Update of /kolabrepository/server/kolab-horde-fbview/kolab-horde-fbview/fbview/services/portal
In directory doto:/tmp/cvs-serv18388/kolab-horde-fbview/kolab-horde-fbview/fbview/services/portal

Added Files:
	edit.php index.php menu.php mobile.php rpcsum.php 
Log Message:
Fbview in separate package

--- NEW FILE: edit.php ---
<?php
/**
 * $Horde: horde/services/portal/edit.php,v 1.39 2004/04/07 14:43:45 chuck Exp $
 *
 * Copyright 1999-2004 Chuck Hagenbuch <chuck at horde.org>
 * Copyright 2003-2004 Mike Cochrane <mike at graftonhall.co.nz>
 * Copyright 2003-2004 Jan Schneider <jan at horde.org>
 *
 * See the enclosed file COPYING for license information (LGPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 */

@define('HORDE_BASE', dirname(__FILE__) . '/../..');
require_once HORDE_BASE . '/lib/base.php';
require_once 'Horde/Block.php';
require_once 'Horde/Block/Collection.php';
require_once 'Horde/Block/Layout.php';
require_once 'Horde/Identity.php';
require_once 'Horde/Menu.php';
require_once 'Horde/Help.php';

if (!Auth::isAuthenticated()) {
    Horde::authenticationFailureRedirect();
}

// Get form values
$col = (int)Util::getFormData('col');
$row = (int)Util::getFormData('row');
$action = Util::getFormData('action');
$edit_row = null;
$edit_col = null;

// Get full name for title
$identity = &Identity::singleton();
$fullname = $identity->getValue('fullname');
if (empty($fullname)) {
    $fullname = Auth::getAuth();
}

// Instantiate the blocks objects.
$blocks = &Horde_Block_Collection::singleton();
$layout = &Horde_Block_Layout::singleton();

// Handle requested actions
switch ($action) {
case 'moveUp':
case 'moveDown':
case 'moveLeft':
case 'moveRight':
case 'expandUp':
case 'expandDown':
case 'expandLeft':
case 'expandRight':
case 'shrinkLeft':
case 'shrinkRight':
case 'shrinkUp':
case 'shrinkDown':
case 'removeBlock':
    $result = call_user_func(array(&$layout, $action), $row, $col);
    if (is_a($result, 'PEAR_Error')) {
        $notification->push($result);
    } else {
        $layout->save();
    }
    break;

// Save the changes made to a block.
case 'save':
// Save the changes made to a block and continue editing.
case 'save-resume':
    // Get requested block type.
    list($newapp, $newtype) = explode(':', Util::getFormData('app'));

    // Make sure there is somewhere to put it.
    if ($layout->isEmpty($row, $col) || 
        !$layout->rowExists($row) || 
        !$layout->colExists($col)) {
        $layout->addBlock($row, $col);
        $layout->setBlockInfo($row, $col, array('app' => $newapp, 'block' => $newtype));
    } elseif ($layout->isBlock($row, $col)) {
        // Get target block info.
        $info = $layout->getBlockInfo($row, $col);

        if ($info['app'] != $newapp || $info['block'] != $newtype) {
            // Change app or type.
            $info = array();
            $info['app'] = $newapp;
            $info['block'] = $newtype;
            $info['params'] = Util::getFormData('params');
            $params = $blocks->getParams($newapp, $newtype);
            foreach ($params as $newparam) {
                if (is_null($info['params'][$newparam])) {
                    $info['params'][$newparam] = $blocks->getDefaultValue($newapp, $newtype, $newparam);
                }
            }
            $layout->setBlockInfo($row, $col, $info);
        } else {
            // Change values.
            $layout->setBlockInfo($row, $col, array('params' => Util::getFormData('params', array())));
        }
    }
    $layout->save();
    if ($action == 'save') {
        break;
    }

// Make a block the current block for editing.
case 'edit':
    $edit_row = $row;
    $edit_col = $col;
    break;
}

$title = _("My Portal Layout");
require HORDE_TEMPLATES . '/common-header.inc';
require HORDE_TEMPLATES . '/portal/menu.inc';
$notification->notify(array('listeners' => 'status'));
require HORDE_TEMPLATES . '/portal/edit.inc';
require HORDE_TEMPLATES . '/common-footer.inc';

--- NEW FILE: index.php ---
<?php
/**
 * $Horde: horde/services/portal/index.php,v 1.33 2004/05/29 16:06:27 jan Exp $
 *
 * Copyright 2003-2004 Mike Cochrane <mike at graftonhall.co.nz>
 *
 * See the enclosed file COPYING for license information (LGPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 */

@define('HORDE_BASE', dirname(__FILE__) . '/../..');
require_once HORDE_BASE . '/lib/base.php';
require_once 'Horde/Block.php';
require_once 'Horde/Identity.php';
require_once 'Horde/Menu.php';
require_once 'Horde/Help.php';

if (!Auth::isAuthenticated()) {
    Horde::authenticationFailureRedirect();
}

// Get full name for title
$identity = &Identity::singleton();
$fullname = $identity->getValue('fullname');
if (empty($fullname)) {
    $fullname = Auth::getAuth();
}

// Get refresh interval.
if ($prefs->getValue('summary_refresh_time')) {
    $refresh_time = $prefs->getValue('summary_refresh_time');
    $refresh_url = Horde::applicationUrl('services/portal/');
}

// Load layout from preferences.
$layout_pref = @unserialize($prefs->getValue('portal_layout'));
if (!is_array($layout_pref)) {
    $layout_pref = array();
}

// Store the apps we need to load stylesheets for.
$cssApps = array();
foreach ($layout_pref as $row) {
    foreach ($row as $item) {
        if (is_array($item) && !in_array($item['app'], $cssApps)) {
            $cssApps[] = $item['app'];
        }
    }
}

$title = _("My Portal");
$cssApp = 'app[]=' . implode(ini_get('arg_separator.output') . 'app[]=', $cssApps);
require HORDE_TEMPLATES . '/common-header.inc';
require HORDE_TEMPLATES . '/portal/menu.inc';
Help::javascript();
$notification->notify(array('listeners' => 'status'));
require HORDE_TEMPLATES . '/portal/header.inc';

$covered = array();
foreach ($layout_pref as $row_num => $row) {
    $width = floor(100 / count($row));
    echo "<tr>\n";
    foreach ($row as $col_num => $item) {
        if (isset($covered[$row_num]) && isset($covered[$row_num][$col_num])) {
            continue;
        }
        if (is_array($item)) {
            $block = $registry->callByPackage($item['app'], 'block', $item['params']);
            if (is_a($block, 'Horde_Block')) {
                $rowspan = $item['height'];
                $colspan = $item['width'];
                $header  = $block->getTitle();
                $content = $block->getContent();
                require HORDE_TEMPLATES . '/portal/block.inc';
                for ($i = 0; $i < $item['height']; $i++) {
                    if (!isset($covered[$row_num + $i])) {
                        $covered[$row_num + $i] = array();
                    }
                    for ($j = 0; $j < $item['width']; $j++) {
                        $covered[$row_num + $i][$col_num + $j] = true;
                    }
                }
            } else {
                require HORDE_TEMPLATES . '/portal/empty.inc';
            }
        } else {
            require HORDE_TEMPLATES . '/portal/empty.inc';
        }
    }
    echo "</tr>\n";
}

require HORDE_TEMPLATES . '/portal/footer.inc';
require HORDE_TEMPLATES . '/common-footer.inc';

--- NEW FILE: menu.php ---
<?php
/**
 * $Horde: horde/services/portal/menu.php,v 2.82 2004/05/26 17:29:56 eraserhd Exp $
 *
 * Copyright 1999-2004 Charles J. Hagenbuch <chuck at horde.org>
 * Copyright 1999-2004 Jon Parise <jon at horde.org>
 * Copyright 2003-2004 Michael Pawlowsky <mjpawlowsky at yahoo.com>
 *
 * See the enclosed file COPYING for license information (LGPL).  If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 */

/**
 * Builds the menu structure depending on application permissions.
 */
function buildMenu()
{
    global $registry, $perms;

    $children = array();
    foreach ($registry->applications as $app => $params) {
        if (isset($params['menu_parent'])) {
            /* Make sure the is a $children entry for each parent
             * group. */
            if (!isset($children[$params['menu_parent']])) {
                $children[$params['menu_parent']] = array();
            }
        }

        /* Don't show the application if it's not installed. */
        if (isset($params['fileroot']) && !is_dir($params['fileroot'])) {
            continue;
        }

        /* Check if the current user has permisson to see this
         * application, and if the application is
         * active. Administrators always see all applications. Anyone
         * with SHOW permissions can see an application, but READ is
         * needed to actually use the application. You can use this
         * distinction to show applications to guests that they need
         * to log in to use. If you don't want them to see apps they
         * can't use, then don't give guests SHOW permissions to
         * anything. */
        if ((Auth::isAdmin() &&
             ($params['status'] == 'active' ||
              $params['status'] == 'admin')) ||
            (($perms->exists($app) ? $perms->hasPermission($app, Auth::getAuth(), PERMS_SHOW) : Auth::getAuth()) &&
             $params['status'] == 'active')) {
            if (isset($params['menu_parent'])) {
                $children[$params['menu_parent']][$app] = $params;
            }
        } else {
            if ($params['status'] != 'heading') {
                $registry->applications[$app]['status'] = 'inactive';
            }
        }
    }

    $tmp = array();
    foreach ($registry->applications as $app => $params) {
        /* Filter out all parents without children. */
        if (isset($children[$app])) {
            if (count($children[$app])) {
                $tmp[$app] = $params;
                $tmp[$app]['children'] = true;
            }
        } else {
            $tmp[$app] = $params;
        }
    }

    $registry->applications = $tmp;
}

@define('AUTH_HANDLER', true);
@define('HORDE_BASE', dirname(__FILE__) . '/../..');
require_once HORDE_BASE . '/lib/base.php';
require_once 'Horde/Menu.php';
require_once 'Horde/Help.php';

if (!Auth::getAuth() && !$conf['menu']['always']) {
    Horde::authenticationFailureRedirect();
}

Horde::addScriptFile('menu.js');

if ($browser->hasQuirk('scrollbar_in_way')) {
    $notification->push('correctWidthForScrollbar()', 'javascript');
}
$bodyClass = 'sidebar';
if (Util::getFormData('mozbar')) {
    $target = '_content';
    $bodyClass .= ' nomargin';
} else {
    $target = 'horde_main';
}
require HORDE_TEMPLATES . '/common-header.inc';

// Build the array so we have parents and children all lined up.
buildMenu();

// Loop through the registry and create the <div>s.
$menutext = '';    // Variable for the HTML output.
$i = 0;            // Counter for looping through the registry.
$last_group = -1;  // To track groups of menus to make <div>s.
$last_parent = 0;  // Track the last parent we used.

foreach ($registry->applications as $app => $params) {
    /* Don't show the application if it's not installed. */
    if (isset($params['fileroot']) && !is_dir($params['fileroot'])) {
        continue;
    }

    $params['name'] = _($params['name']);
    if ($params['status'] == 'active' || $params['status'] == 'heading' ||
        ($params['status'] == 'admin' && Auth::isAdmin())) {
        $i++;
        $group = isset($params['menu_parent']) ? $params['menu_parent'] : null;
        $attr  = '';

        // When we switch groups close up the <div>.
        if (($i != 1) && ($group != $last_group)) {
            $menutext .= "</table></div>\n";
        }

        // Headings have no webroot; they're just containers for other
        // menu items.
        if ($params['status'] == 'heading' || !array_key_exists('webroot', $params)) {
            $url = '#';
        } else {
            $url = Horde::url($params['webroot'] . '/' . (isset($params['initial_page']) ? $params['initial_page'] : ''));
        }
        if (!array_key_exists('menu_parent', $params)) {
            // Standalone link or container heading.
            $menutext .= '<div class="head"><table border="0" cellpadding="0" cellspacing="0" width="100%">';
            if (array_key_exists('children', $params) && $params['status'] == 'heading') {
                $link = Horde::link($url, $params['name'], 'menuitem sidebaritem', $target,
                                    "toggle('" . $app . "'); this.blur(); return false;", $params['name']);
                $image = $link . Horde::img($params['icon'], $params['name'], '', '') . '</a>';
                $text = $link . $params['name'] . Horde::img('tree/arrow-collapsed.gif', '', 'id="arrow_' . $app . '"') . '</a>';
            } else {
                $link = Horde::link($url, $params['name'], 'menuitem sidebaritem', isset($params['target']) ? $params['target'] : $target, 'this.blur()', $params['name']);
                $image = $link . Horde::img($params['icon'], $params['name'], '', '') . '</a>';
                $text = $link . $params['name'] . '</a>';
            }
        } else {
            // Subitem.
            if ($group != $last_group) {
                $menutext .= '<div class="para" id="menu_' . $group . '"><table border="0" cellpadding="0" cellspacing="0" width="100%">';
                $last_group = $group;
            }

            $link  = Horde::link($url, $params['name'], 'menuitem sidebaritem', isset($params['target']) ? $params['target'] : $target, 'this.blur()', $params['name']);
            $image = Horde::img('tree/blank.gif', $params['name'], 'width="28" height="16"');
            $attr  = ' height="20" width="28" align="center"';
            $text  = $link . Horde::img($params['icon'], $params['name'], '', '') . '</a></td><td>';
            $text .= $link . $params['name'] . '</a>';
        }

        $menutext .= '<tr><td align="center" width="28" height="20">' . $image . '</td><td' . $attr . '>' . $text . '</td></tr>';
    }
}

$menutext .= '</table></div>';

/* Add the administration link if the user is an admin. */
if (Auth::isAdmin()) {
    $menutext .= '<div class="head"><table border="0" cellpadding="0" cellspacing="0" width="100%">';
    $link = Horde::link('#', _("Administration"), 'menuitem sidebaritem', null,
                        "toggle('administration'); this.blur(); return false;", _("Administration"));
    $menutext .= '<tr><td align="center" width="28" height="20">' . $link . Horde::img('administration.gif', _("Administration")) . '</a></td><td>' . $link . _("Administration") . Horde::img('tree/arrow-collapsed.gif', '', 'id="arrow_administration"') . '</a></td></tr></table>';

    $menutext .= '<div class="para" id="menu_administration"><table border="0" cellpadding="0" cellspacing="0">';

    foreach ($registry->listApps() as $app) {
        if ($registry->hasMethod('admin_list', $app)) {
            $list = $registry->callByPackage($app, 'admin_list');
            if (!is_a($list, 'PEAR_Error')) {
                foreach ($list as $method => $vals) {
                    if ($app != 'horde') {
                        $name = $registry->getParam('name', $app);
                        if (!empty($vals['name'])) {
                            $name .= ' ' . $vals['name'];
                        }
                    } else {
                        $name = $vals['name'];
                    }
                    $img = isset($vals['icon']) ? $registry->getParam('graphics', $app) . '/' . $vals['icon'] : $registry->getParam('icon', $app);

                    $menutext .= '<tr><td align="center" width="28" height="20">' . Horde::img('tree/blank.gif', $name, 'width="16" height="16"') . '</td>';
                    $link = Horde::link(Horde::url($registry->applicationWebPath($vals['link'], $app)),
                                        $name, 'menuitem sidebaritem', $target, 'this.blur()', $name);
                    $menutext .= '<td width="28" align="center">' . $link . Horde::img($img, $name, '', '') . '</a></td><td>' . $link . $name . '</a></td></tr>';
                }
            }
        }
    }

    $menutext .= '</table></div></div>';
}

if (Auth::isAuthenticated()) {
    /* Add an options link. */
    $link = Horde::link(Horde::applicationUrl('services/prefs.php'), _("Options"), 'menuitem sidebaritem', $target,
                        null, _("Options"));
    $label = _("Options");
    $icon = 'prefs.gif';
    $menutext .= '<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td align="center" width="28" height="20">' . $link . Horde::img($icon, $label) . '</a></td><td>' . $link . $label . '</a></td></tr></table>';

    /* Add a logout link. */
    $link = Horde::link(Auth::addLogoutParameters(Horde::applicationUrl('login.php'), AUTH_REASON_LOGOUT), _("Logout"), 'menuitem sidebaritem', $conf['menu']['always'] ? $target : '_parent',
                        null, sprintf(_("Log out of %s"), $registry->getParam('name')));
    $label = _("Logout");
    $icon = 'logout.gif';
} else {
    /* Add a login link. */
    $link = Horde::link(Horde::applicationUrl('login.php'), _("Login"), 'menuitem sidebaritem', $target,
                        null, sprintf(_("Log in to %s"), $registry->getParam('name')));
    $label = _("Login");
    $icon = 'login.gif';
}
$menutext .= '<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td align="center" width="28" height="20">' . $link . Horde::img($icon, $label) . '</a></td><td>' . $link . $label . '</a></td></tr></table>';

require HORDE_TEMPLATES . '/horde/menu.inc';
require HORDE_TEMPLATES . '/common-footer.inc';

--- NEW FILE: mobile.php ---
<?php
/**
 * $Horde: horde/services/portal/mobile.php,v 2.13 2004/04/07 14:43:45 chuck Exp $
 *
 * Copyright 2002-2004 Chuck Hagenbuch <chuck at horde.org>
 *
 * See the enclosed file COPYING for license information (LGPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 */

@define('HORDE_BASE', dirname(__FILE__) . '/../..');
require_once HORDE_BASE . '/lib/base.php';
require_once 'Horde/Identity.php';
require_once 'Horde/Mobile.php';

if (!Auth::getAuth()) {
    header('Location: ' . Util::addParameter(Horde::applicationUrl('login.php', true),
                                             'url', Horde::selfUrl()));
    exit;
}

$identity = &Identity::singleton();
$fullname = $identity->getValue('fullname');
if (empty($fullname)) {
    $fullname = Auth::getAuth();
}

$m = &new Horde_Mobile(_("Welcome"));
$m->add(new Horde_Mobile_text(sprintf(_("Welcome, %s"), $fullname)));

// Messy way of linking to active apps that support mobile
// devices. Should be made more elegant at some point.
if (!empty($registry->applications['mimp']['status']) &&
    $registry->applications['mimp']['status'] != 'inactive') {
    $m->add(new Horde_Mobile_link($registry->getParam('name', 'mimp'),
                                  Horde::url($registry->getParam('webroot', 'mimp') . '/'),
                                  $registry->getParam('name', 'mimp')));
}

$m->display();

--- NEW FILE: rpcsum.php ---
<?php
/**
 * $Horde: horde/services/portal/rpcsum.php,v 2.22 2004/04/07 14:43:45 chuck Exp $
 *
 * Copyright 2001-2004 Jan Schneider <jan at horde.org>
 *
 * See the enclosed file COPYING for license information (LGPL).  If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 */

function _returnToPrefs()
{
    $url = Horde::applicationUrl('services/prefs.php', true);
    header('Location: ' . Util::addParameter($url, 'group', 'display'));
    exit;
}

define('RPC_EDIT',   1);
define('RPC_SAVE',   2);
define('RPC_DELETE', 3);
define('HORDE_BASE', dirname(__FILE__) . '/../..');
require_once HORDE_BASE . '/lib/base.php';
require_once 'Horde/RPC.php';

if (!Auth::isAuthenticated()) {
    Horde::authenticationFailureRedirect();
}

$rpc_servers = @unserialize($prefs->getValue('remote_summaries'));
if (!is_array($rpc_servers)) {
    $rpc_servers = array();
}

$actionID = Util::getFormData('actionID');

// Handle clients without javascript.
if (is_null($actionID)) {
    if (Util::getPost('edit')) {
        $actionID = RPC_EDIT;
    } elseif (Util::getPost('save')) {
        $actionID = RPC_SAVE;
    } elseif (Util::getPost('delete')) {
        $actionID = RPC_DELETE;
    } elseif (Util::getPost('back')) {
        _returnToPrefs();
    }
}

/* Run through the action handlers */
switch ($actionID) {
 case RPC_SAVE:
    if (($to_edit = Util::getFormData('edit_server')) == null) {
        $to_edit = count($rpc_servers);
        $rpc_servers[] = array();
    }
    $rpc_servers[$to_edit]['url']    = Util::getFormData('url');
    $rpc_servers[$to_edit]['user']   = Util::getFormData('user');
    $rpc_servers[$to_edit]['passwd'] = Util::getFormData('passwd');
    $prefs->setValue('remote_summaries', serialize($rpc_servers));
    $prefs->store();
    $notification->push(sprintf(_("The server \"%s\" has been saved."), $rpc_servers[$to_edit]['url']), 'horde.success');
    break;

 case RPC_DELETE:
    $to_delete = Util::getFormData('server');
    if ($to_delete != -1) {
        $deleted_server = $rpc_servers[$to_delete]['url'];
        $server_list = array();
        for ($i = 0; $i < count($rpc_servers); $i++) {
            if ($i == $to_delete) {
                continue;
            }
            $server_list[] = $rpc_servers[$i];
        }
        $prefs->setValue('remote_summaries', serialize($server_list));
        $chosenColumns = explode(';', $prefs->getValue('show_summaries'));
        if ($chosenColumns != array('')) {
            $newColumns = array();
            foreach ($chosenColumns as $chosenColumn) {
                $chosenColumn = explode(',', $chosenColumn);
                $remote = explode('|', $chosenColumn[0]);
                if (count($remote) != 3 || $remote[2] == $deleted_server) {
                    $newColumns[] = implode(',', $chosenColumn);
                }
            }
            $prefs->setValue('show_summaries', implode(';', $newColumns));
        }
        $prefs->store();
        $rpc_servers = $server_list;
        $notification->push(sprintf(_("The server \"%s\" has been deleted."), $deleted_server), 'horde.success');
    } else {
        $notification->push(_("You must select an server to be deleted."), 'horde.warning');
    }
    break;

}

/* Show the header. */
require_once 'Horde/Prefs/UI.php';
require HORDE_BASE . '/config/prefs.php';
Prefs_UI::generateHeader('remote');

require HORDE_TEMPLATES . '/rpcsum/javascript.inc';
require HORDE_TEMPLATES . '/rpcsum/manage.inc';
require HORDE_TEMPLATES . '/common-footer.inc';





More information about the commits mailing list