Renamed LiveSupport to Campcaster. Got rid of copyright notice in files, we will just have one that covers all files at the root of the package. Converted comments to Phpdocumentor format. Added @author, @version, @package, and @subpackage doc tags. Reformatted code to Campware PHP coding conventions.

This commit is contained in:
paul 2006-10-16 18:20:28 +00:00
parent a181a9991a
commit 9370f5c88d
36 changed files with 1277 additions and 959 deletions

View file

@ -1,29 +1,6 @@
#!/usr/bin/php #!/usr/bin/php
#-------------------------------------------------------------------------------
# Copyright (c) 2004 Media Development Loan Fund
#
# This file is part of the Campcaster project.
# http://campcaster.campware.org/
# To report bugs, send an e-mail to bugs@campware.org
#
# Campcaster is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Campcaster is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Campcaster; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#
# Author : $Author$ # Author : $Author$
# Version : $Revision$ # Version : $Revision$
# Location : $URL$
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# This script configures php for the htmlUI # This script configures php for the htmlUI

View file

@ -8,7 +8,7 @@
<body> <body>
<h1>Preface</h1> <h1>Preface</h1>
This document is part of the This document is part of the
<a href="http://livesupport.campware.org/">LiveSupport</a> <a href="http://campcaster.campware.org/">Campcaster</a>
project, Copyright © 2004 <a href="http://www.mdlf.org/">Media project, Copyright © 2004 <a href="http://www.mdlf.org/">Media
Development Loan Fund</a>, under the GNU <a Development Loan Fund</a>, under the GNU <a
href="http://www.gnu.org/licenses/gpl.html">GPL</a>.<br> href="http://www.gnu.org/licenses/gpl.html">GPL</a>.<br>

View file

@ -91,4 +91,3 @@ $mask = array(
) )
); );
?> ?>

View file

@ -850,3 +850,4 @@ $ui_fmask = array(
) )
) )
); );
?>

View file

@ -60,3 +60,4 @@ $relations = array(
'ls:url' => 'Stream URL' 'ls:url' => 'Stream URL'
); );
?>

View file

@ -1,3 +1,3 @@
<?php <?php
header('LOCATION: /livesupport/htmlUI/var/html/ui_browser.php'); header('LOCATION: /campcaster/htmlUI/var/html/ui_browser.php');
?> ?>

View file

@ -1,10 +1,9 @@
<?php <?php
function login(&$data) function login(&$data)
{ {
include(dirname(__FILE__).'/../../../storageServer/var/conf.php');
include dirname(__FILE__).'/../../../storageServer/var/conf.php'; include_once(dirname(__FILE__).'/../../../storageServer/var/GreenBox.php');
include_once dirname(__FILE__).'/../../../storageServer/var/GreenBox.php'; include_once('DB.php');
include_once 'DB.php';
$dbc = DB::connect($config['dsn'], TRUE); $dbc = DB::connect($config['dsn'], TRUE);
@ -15,7 +14,6 @@ function login(&$data)
$dbc->setFetchMode(DB_FETCHMODE_ASSOC); $dbc->setFetchMode(DB_FETCHMODE_ASSOC);
$gb =& new GreenBox($dbc, $config); $gb =& new GreenBox($dbc, $config);
if (!$data['PHP_AUTH_USER'] || !$data['PHP_AUTH_PW']) { if (!$data['PHP_AUTH_USER'] || !$data['PHP_AUTH_PW']) {
return FALSE; return FALSE;
} }
@ -34,7 +32,7 @@ function login(&$data)
$id = $gb->getObjId($data['PHP_AUTH_USER'], $gb->storId); $id = $gb->getObjId($data['PHP_AUTH_USER'], $gb->storId);
if(PEAR::isError($id)) { if (PEAR::isError($id)) {
return FALSE; return FALSE;
} }

View file

@ -1,37 +1,44 @@
<?php <?php
/** /**
* _parseArr2Form * Add elements/rules/groups to an given HTML_QuickForm object
* *
* Add elements/rules/groups to an given HTML_QuickForm object * @param HTML_Quickform $form
* * @param array $mask
* @param form object, reference to HTML_QuickForm object * array defining form elements
* @param mask array, reference to array defining to form elements * @param string $sid
* @param side string, side where the validation should beeing * side where the validation should happen ('client', 'server')
*/ */
function parseArr2Form(&$form, $mask, $side='client') function parseArr2Form(&$form, $mask, $side='client')
{ {
foreach($mask as $k=>$v) { foreach($mask as $k=>$v) {
## add elements ######################## ## add elements ########################
if ($v['type']=='radio') { if ($v['type'] == 'radio') {
foreach($v['options'] as $rk=>$rv) { foreach ($v['options'] as $rk => $rv) {
$radio[] =& $form->createElement($v['type'], NULL, NULL, $rv, $rk, $v['attributes']); $radio[] =& $form->createElement($v['type'], NULL, NULL, $rv, $rk, $v['attributes']);
} }
$form->addGroup($radio, $v['element'], tra($v['label'])); $form->addGroup($radio, $v['element'], tra($v['label']));
unset($radio); unset($radio);
} elseif ($v['type']=='select') { } elseif ($v['type'] == 'select') {
$elem[$v['element']] =& $form->createElement($v['type'], $v['element'], tra($v['label']), $v['options'], $v['attributes']); $elem[$v['element']] =& $form->createElement($v['type'], $v['element'], tra($v['label']), $v['options'], $v['attributes']);
$elem[$v['element']]->setMultiple($v['multiple']); $elem[$v['element']]->setMultiple($v['multiple']);
if (isset($v['selected'])) $elem[$v['element']]->setSelected($v['selected']); if (isset($v['selected'])) {
if (!$v['groupit']) $form->addElement($elem[$v['element']]); $elem[$v['element']]->setSelected($v['selected']);
}
} elseif ($v['type']=='date') { if (!$v['groupit']) {
$form->addElement($elem[$v['element']]);
}
} elseif ($v['type'] == 'date') {
$elem[$v['element']] =& $form->createElement($v['type'], $v['element'], tra($v['label']), $v['options'], $v['attributes']); $elem[$v['element']] =& $form->createElement($v['type'], $v['element'], tra($v['label']), $v['options'], $v['attributes']);
if (!$v['groupit']) $form->addElement($elem[$v['element']]); if (!$v['groupit']) {
$form->addElement($elem[$v['element']]);
}
} elseif ($v['type']=='checkbox' || $v['type']=='static') { } elseif (($v['type'] == 'checkbox') || ($v['type'] == 'static')) {
$elem[$v['element']] =& $form->createElement($v['type'], $v['element'], tra($v['label']), $v['text'], $v['attributes']); $elem[$v['element']] =& $form->createElement($v['type'], $v['element'], tra($v['label']), $v['text'], $v['attributes']);
if (!$v['groupit']) $form->addElement($elem[$v['element']]); if (!$v['groupit']) {
$form->addElement($elem[$v['element']]);
}
} elseif (isset($v['type'])) { } elseif (isset($v['type'])) {
$elem[$v['element']] =& $form->createElement($v['type'], $v['element'], tra($v['label']), $elem[$v['element']] =& $form->createElement($v['type'], $v['element'], tra($v['label']),
@ -39,25 +46,27 @@ function parseArr2Form(&$form, $mask, $side='client')
($v['type']=='textarea' ? array_merge(array('rows'=>UI_TEXTAREA_STANDART_ROWS, 'cols'=>UI_TEXTAREA_STANDART_COLS), $v['attributes']) : ($v['type']=='textarea' ? array_merge(array('rows'=>UI_TEXTAREA_STANDART_ROWS, 'cols'=>UI_TEXTAREA_STANDART_COLS), $v['attributes']) :
($v['type']=='button' || $v['type']=='submit' || $v['type']=='reset' ? array_merge(array('class'=>UI_BUTTON_STYLE), $v['attributes']) : $v['attributes'])) ($v['type']=='button' || $v['type']=='submit' || $v['type']=='reset' ? array_merge(array('class'=>UI_BUTTON_STYLE), $v['attributes']) : $v['attributes']))
); );
if (!$v['groupit']) $form->addElement($elem[$v['element']]); if (!$v['groupit']) {
$form->addElement($elem[$v['element']]);
}
} }
## add required rule ################### // add required rule ###################
if ($v['required']) { if ($v['required']) {
$form->addRule($v['element'], isset($v['requiredmsg']) ? tra($v['requiredmsg']) : tra('Missing value for $1', tra($v['label'])), 'required', NULL, $side); $form->addRule($v['element'], isset($v['requiredmsg']) ? tra($v['requiredmsg']) : tra('Missing value for $1', tra($v['label'])), 'required', NULL, $side);
} }
## add constant value ################## // add constant value ##################
if (isset($v['constant'])) { if (isset($v['constant'])) {
$form->setConstants(array($v['element']=>$v['constant'])); $form->setConstants(array($v['element']=>$v['constant']));
} }
## add default value ################### // add default value ###################
if (isset($v['default'])) { if (isset($v['default'])) {
$form->setDefaults(array($v['element']=>$v['default'])); $form->setDefaults(array($v['element']=>$v['default']));
} }
## add other rules ##################### // add other rules #####################
if ($v['rule']) { if ($v['rule']) {
$form->addRule($v['element'], isset($v['rulemsg']) ? tra($v['rulemsg']) : tra('$1 must be $2', tra($v['element']), tra($v['rule'])), $v['rule'] ,$v['format'], $side); $form->addRule($v['element'], isset($v['rulemsg']) ? tra($v['rulemsg']) : tra('$1 must be $2', tra($v['element']), tra($v['rule'])), $v['rule'] ,$v['format'], $side);
} }
## add group ########################### // add group ###########################
if (is_array($v['group'])) { if (is_array($v['group'])) {
foreach($v['group'] as $val) { foreach($v['group'] as $val) {
$groupthose[] =& $elem[$val]; $groupthose[] =& $elem[$val];

View file

@ -1,3 +1,3 @@
<?php <?php
header('LOCATION: /livesupport/htmlUI/var/html/ui_browser.php'); header('LOCATION: /campcaster/htmlUI/var/html/ui_browser.php');
?> ?>

View file

@ -3,7 +3,7 @@
<html> <html>
<head> <head>
<title>LIVESUPPORT</title> <title>Campcaster</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
{* <link rel="stylesheet" href="styles.css"> *} {* <link rel="stylesheet" href="styles.css"> *}

View file

@ -71,11 +71,11 @@ if (window.attachEvent) window.attachEvent("onload", sfHover);
{if $SUBJECTS->isMemberOf('StationPrefs')} {if $SUBJECTS->isMemberOf('StationPrefs')}
<li><a href="{$UI_BROWSER}?act=changeStationPrefs">##Station Settings##</a></li> <li><a href="{$UI_BROWSER}?act=changeStationPrefs">##Station Settings##</a></li>
{/if} {/if}
{if $SUBJECTS->isMemberOf('Subjects')} {*if $SUBJECTS->isMemberOf('Subjects')*}
<li><a href="{$UI_BROWSER}?act=SUBJECTS">##User/Groups##</a></li> <li><a href="{$UI_BROWSER}?act=SUBJECTS">##User/Groups##</a></li>
{else} {*else*}
<li><a href="{$UI_BROWSER}?act=SUBJECTS.chgPasswd&id={$USER.userid}">##Change Password##</a></li> <li><a href="{$UI_BROWSER}?act=SUBJECTS.chgPasswd&id={$USER.userid}">##Change Password##</a></li>
{/if} {*/if*}
{if $SUBJECTS->isMemberOf('Admins')} {if $SUBJECTS->isMemberOf('Admins')}
<li><a href="{$UI_BROWSER}?act=fileList&id={$START.fid}">##File List##</a></li> <li><a href="{$UI_BROWSER}?act=fileList&id={$START.fid}">##File List##</a></li>
{/if} {/if}

View file

@ -3,7 +3,7 @@
<html> <html>
<head> <head>
<title>LIVESUPPORT</title> <title>Campcaster</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="styles_popup.css" rel="stylesheet" type="text/css" /> <link href="styles_popup.css" rel="stylesheet" type="text/css" />

View file

@ -2,7 +2,7 @@
<head> <head>
<meta http-equiv=Content-Type content="text/html; charset=utf-8"> <meta http-equiv=Content-Type content="text/html; charset=utf-8">
<title>LiveSupport Help</title> <title>Campcaster Help</title>
<style> <style>
{literal} {literal}
@ -91,7 +91,7 @@ DIV.blockquote
<H2>Navigation</H2> <H2>Navigation</H2>
<H3>Context menus</H3> <H3>Context menus</H3>
<P>The LiveSupport web client uses context menus extensively <P>The Campcaster web client uses context menus extensively
throughout the program. For example, by clicking on the ScratchPad, throughout the program. For example, by clicking on the ScratchPad,
you can perform a number of operations on your file, including you can perform a number of operations on your file, including
adding it to a playlist and removing it from the ScratchPad. &nbsp; adding it to a playlist and removing it from the ScratchPad. &nbsp;
@ -113,7 +113,7 @@ DIV.blockquote
and this which isn't opened will appear in normal text. and this which isn't opened will appear in normal text.
</P> </P>
<H2>Playlists</H2> <H2>Playlists</H2>
<P>Playlists are at the core of how LiveSupport works. You add sound <P>Playlists are at the core of how Campcaster works. You add sound
files to a playlist, and then schedule that playlist to be played at files to a playlist, and then schedule that playlist to be played at
a date and time of your choosing. Playlists are edited in the a date and time of your choosing. Playlists are edited in the
Playlist Editor. You can include an unlimited number of playlists Playlist Editor. You can include an unlimited number of playlists
@ -127,7 +127,7 @@ DIV.blockquote
</P> </P>
<H3>Changing file order in the playlist</H3> <H3>Changing file order in the playlist</H3>
<P>You can change a file's order in the playlist by clicking on the <P>You can change a file's order in the playlist by clicking on the
up or down arrows on the right.<BR>As of LiveSupport 1.0.1, you can up or down arrows on the right.<BR>As of Campcaster 1.0.1, you can
drag and drop playlist items to change their order. This can be done drag and drop playlist items to change their order. This can be done
by &quot;;Re-arrange playlist&quot;; in the playlist editor. &nbsp; by &quot;;Re-arrange playlist&quot;; in the playlist editor. &nbsp;
</P> </P>
@ -169,13 +169,13 @@ DIV.blockquote
will remain in the system. will remain in the system.
</P> </P>
<H2>Files</H2> <H2>Files</H2>
<P>Sound files are added to the LiveSupport system in two steps.</P> <P>Sound files are added to the Campcaster system in two steps.</P>
<H3>Uploading and analyzing</H3> <H3>Uploading and analyzing</H3>
<P>The first step is to select the sound file you want to upload <P>The first step is to select the sound file you want to upload
into the LiveSupport system. This is handled in the Upload -&gt; New into the Campcaster system. This is handled in the Upload -&gt; New
file menu. You select the file to upload by clicking on the &quot;Browse&quot; file menu. You select the file to upload by clicking on the &quot;Browse&quot;
button, choosing your sound file, then clicking &quot;Submit&quot;. button, choosing your sound file, then clicking &quot;Submit&quot;.
LiveSupport automatically analyzes the sound file for any Campcaster automatically analyzes the sound file for any
information that may be stored in ID3 tags.<BR>See the information that may be stored in ID3 tags.<BR>See the
&quot;Troubleshooting&quot; section if you cannot upload files. &quot;Troubleshooting&quot; section if you cannot upload files.
</P> </P>
@ -270,15 +270,15 @@ DIV.blockquote
<H3>File Upload</H3> <H3>File Upload</H3>
<P>If you encounter the message <i>The uploadet filer is bigger than allowed in system settings.</i> most probably the file size is bigger than <P>If you encounter the message <i>The uploadet filer is bigger than allowed in system settings.</i> most probably the file size is bigger than
allowed in the PHP system settings of the machine you are running allowed in the PHP system settings of the machine you are running
LiveSupport on. Please increase the settings of Campcaster on. Please increase the settings of
&quot;upload_max_filesize&quot; and &quot;post_max_size&quot; in &quot;upload_max_filesize&quot; and &quot;post_max_size&quot; in
php.ini. For more information, consult the <A HREF="http://code.campware.org/manuals/livesupport/1.0/index.php?id=42" TARGET="_blank">LiveSupport php.ini. For more information, consult the <A HREF="http://code.campware.org/manuals/campcaster/1.0/index.php?id=42" TARGET="_blank">Campcaster
manual</A> chapter 4.12. manual</A> chapter 4.12.
</P> </P>
<H2>Where to go for help</H2> <H2>Where to go for help</H2>
<P>LiveSupport has a mailing list for support-related questions at <P>Campcaster has a mailing list for support-related questions at
<A HREF="mailto:ls-support@campware.org">ls-support@campware.org</A>, <A HREF="mailto:ls-support@campware.org">ls-support@campware.org</A>,
or you can visit the LiveSupport forums at <A HREF="http://www.campware.org/" TARGET="_blank">http://www.campware.org</A></P> or you can visit the Campcaster forums at <A HREF="http://www.campware.org/" TARGET="_blank">http://www.campware.org</A></P>
</P> </P>
{if tra('_Name of translator') !== '_Name of translator'} {if tra('_Name of translator') !== '_Name of translator'}

View file

@ -7,6 +7,7 @@ function jscom_wrapper($object, $parent, $method) {
return call_user_func_array(array(&$GLOBALS[$object]->$parent, "$method"), $args); return call_user_func_array(array(&$GLOBALS[$object]->$parent, "$method"), $args);
} }
function errCallBack($err) function errCallBack($err)
{ {
echo "<pre>gm:\n".$err->getMessage()."\ndi:\n".$err->getDebugInfo()."\nui:\n".$err->getUserInfo()."\n"; echo "<pre>gm:\n".$err->getMessage()."\ndi:\n".$err->getDebugInfo()."\nui:\n".$err->getUserInfo()."\n";
@ -32,11 +33,14 @@ function _getLanguages()
return $languages; return $languages;
} }
/** /**
* Translate the given string using localisation files. * Translate the given string using localization files.
* *
* @param string $input - string to translate * @param string $input
* @return string, translated string * string to translate
* @return string
* translated string
*/ */
function tra($input) function tra($input)
{ {
@ -104,23 +108,13 @@ function _getNumArr($start, $end, $step=1)
/** /**
* uiBase class * HTML User Interface module
* * @package Campcaster
* LiveSupport HTML User Interface module * @subpackage htmlUI
* * @version $Revision$
*/ */
class uiBase class uiBase
{ {
// --- class constructor ---
/**
* uiBase
*
* Initialize a new Basis Class including:
* - database initialation
* - GreenBox initialation
*
* @param $config array, configurartion data
*/
var $redirUrl; var $redirUrl;
var $alertMsg; var $alertMsg;
var $dbc; var $dbc;
@ -149,6 +143,16 @@ class uiBase
var $TRANSFERS; var $TRANSFERS;
var $_self_; var $_self_;
/**
* uiBase
*
* Initialize a new Basis Class including:
* - database initialation
* - GreenBox initialation
*
* @param array $config
* configurartion data
*/
function uiBase(&$config) function uiBase(&$config)
{ {
$this->dbc = DB::connect($config['dsn'], TRUE); $this->dbc = DB::connect($config['dsn'], TRUE);
@ -230,9 +234,12 @@ class uiBase
* *
* Add elements/rules/groups to an given HTML_QuickForm object * Add elements/rules/groups to an given HTML_QuickForm object
* *
* @param HTML_Quickform $form - reference to HTML_QuickForm object * @param HTML_Quickform $form
* @param array $mask - reference to array defining the form elements * reference to HTML_QuickForm object
* @param string $side - can be 'client' or 'server' - this is where the form validation occurs. * @param array $mask
* reference to array defining the form elements
* @param string $side
* can be 'client' or 'server' - this is where the form validation occurs.
*/ */
function _parseArr2Form(&$form, &$mask, $side='client') function _parseArr2Form(&$form, &$mask, $side='client')
{ {
@ -346,7 +353,8 @@ class uiBase
/** /**
* Converts date-array from form into string * Converts date-array from form into string
* *
* @param array $input - array of form-elements * @param array $input
* array of form-elements
*/ */
function _dateArr2Str(&$input) function _dateArr2Str(&$input)
{ {
@ -366,10 +374,11 @@ class uiBase
/** /**
* Call getid3 library to analyze media file and show some results * Call getid3 library to analyze media file and show some results
* *
* @param int $id local ID of file * @param int $id
* @param string $format * local ID of file
* @param string $format
*/ */
function _analyzeFile($id, $format) function _analyzeFile($id, $format)
{ {
@ -387,7 +396,7 @@ class uiBase
xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:ls="http://mdlf.org/livesupport/elements/1.0/" xmlns:ls="http://mdlf.org/campcaster/elements/1.0/"
> >
<dc:title>'.$this->_getFileTitle($id).'</dc:title> <dc:title>'.$this->_getFileTitle($id).'</dc:title>
<dcterms:extent>'.$extent.'</dcterms:extent> <dcterms:extent>'.$extent.'</dcterms:extent>
@ -416,6 +425,7 @@ class uiBase
/** /**
* Add an alert message to the session var. * Add an alert message to the session var.
* @todo Fix this to use call_user_func()
* *
* @param string $msg * @param string $msg
* @param string $p1 * @param string $p1

View file

@ -1,4 +1,9 @@
<?php <?php
/**
* @package Campcaster
* @subpackage htmlUI
* @version $Revision$
*/
class uiBrowse class uiBrowse
{ {
var $Base; // uiBase object var $Base; // uiBase object
@ -7,6 +12,7 @@ class uiBrowse
var $criteria; var $criteria;
var $reloadUrl; var $reloadUrl;
function uiBrowse(&$uiBase) function uiBrowse(&$uiBase)
{ {
$this->Base =& $uiBase; $this->Base =& $uiBase;
@ -135,8 +141,6 @@ class uiBrowse
/** /**
* Enter description here...
*
* @param array $parm * @param array $parm
*/ */
function setValue($parm) function setValue($parm)

View file

@ -1,13 +1,19 @@
<?php <?php
/**
* @package Campcaster
* @subpackage htmlUI
* @version $Revision$
*/
class uiBrowser extends uiBase { class uiBrowser extends uiBase {
var $alertMsg; var $alertMsg;
// --- class constructor --- // --- class constructor ---
/** /**
* Initialize a new Browser Class. * Initialize a new Browser Class.
* Call uiBase constructor. * Call uiBase constructor.
* *
* @param $config array, configurartion data * @param array $config
* configurartion data
*/ */
function uiBrowser(&$config) function uiBrowser(&$config)
{ {
@ -16,11 +22,13 @@ class uiBrowser extends uiBase {
/** /**
* Perform a frontend action. * Perform a frontend action.
* Map to a function called action_<actionName>.inc.php * Map to a function called action_<actionName>.inc.php
* *
* @param string $actionName - name of an action * @param string $actionName
* @param array $params - request vars * name of an action
* @param array $params
* request vars
*/ */
function performAction( $actionName, $params ) function performAction( $actionName, $params )
{ {
@ -37,9 +45,9 @@ class uiBrowser extends uiBase {
// --- error handling --- // --- error handling ---
/** /**
* Extracts the error message from the session var. * Extracts the error message from the session var.
* *
* @return string * @return string
*/ */
function getAlertMsg() function getAlertMsg()
{ {
@ -54,10 +62,11 @@ class uiBrowser extends uiBase {
// --- template feed --- // --- template feed ---
/** /**
* Create a login-form. * Create a login-form.
* *
* @param array $mask - an array of all webforms in the system * @param array $mask
* @return array * an array of all webforms in the system
* @return array
*/ */
function login($mask) function login($mask)
{ {
@ -73,9 +82,10 @@ class uiBrowser extends uiBase {
/** /**
* Get info about logged in user. * Get info about logged in user.
* *
* @return array (uname=>user_name, uid=>user_id) * @return array
* (uname=>user_name, uid=>user_id)
*/ */
function getUserInfo() function getUserInfo()
{ {
@ -87,8 +97,10 @@ class uiBrowser extends uiBase {
/** /**
* Get directory-structure * Get directory-structure
* *
* @param int $id - local ID of start-directory * @param int $id
* @return array - tree of directory with subs * local ID of start-directory
* @return array
* tree of directory with subs
*/ */
function getStructure($id) function getStructure($id)
{ {
@ -122,10 +134,10 @@ class uiBrowser extends uiBase {
/** /**
* Create a form for file-upload. * Create a form for file-upload.
* *
* @param array $params * @param array $params
* @return array * @return array
*/ */
function fileForm($parms) function fileForm($parms)
{ {
@ -149,11 +161,12 @@ class uiBrowser extends uiBase {
/** /**
* Create a form to add a Webstream. * Create a form to add a Webstream.
* *
* @param int local $id of directory to store stream * @param int $id
* * local of directory to store stream
* @eturn string (html) * @return string
* HTML string
*/ */
function webstreamForm($parms) function webstreamForm($parms)
{ {
@ -195,11 +208,11 @@ class uiBrowser extends uiBase {
/** /**
* Get permissions for local object ID. * Get permissions for local object ID.
* *
* @param $id int local ID (file/folder) * @param int $id
* * local ID (file/folder)
* @return array * @return array
*/ */
function permissions($id) function permissions($id)
{ {
@ -214,11 +227,12 @@ class uiBrowser extends uiBase {
/** /**
* Call access method and show access path. * Call access method and show access path.
* Example only - not really useable. * Example only - not really useable.
* TODO: resource should be released by release method call * TODO: resource should be released by release method call
* *
* @param id int, local id of accessed file * @param id int
* local id of accessed file
*/ */
function getFile($id) function getFile($id)
{ {
@ -232,12 +246,13 @@ class uiBrowser extends uiBase {
/** /**
* Get file's metadata as XML * Get file's metadata as XML
* *
* Note: this does not work right with multiple languages * Note: this does not work right with multiple languages
* *
* @param id int, local id of stored file * @param id int
* @return array * local id of stored file
* @return array
*/ */
function getMdata($id) function getMdata($id)
{ {
@ -287,10 +302,11 @@ class uiBrowser extends uiBase {
/** /**
* Create a form to edit Metadata. * Create a form to edit Metadata.
* *
* @param array $parms * @param array $parms
* @return string (html) * @return string
* HTML string
*/ */
function metaDataForm($parms) function metaDataForm($parms)
{ {
@ -319,7 +335,9 @@ class uiBrowser extends uiBase {
// values from database. // values from database.
foreach ($mask['pages'] as $key => $val) { foreach ($mask['pages'] as $key => $val) {
foreach ($mask['pages'][$key] as $k=>$v) { foreach ($mask['pages'][$key] as $k=>$v) {
if (!is_array($mask['pages'][$key][$k]['attributes'])) $mask['pages'][$key][$k]['attributes'] = array(); if (!is_array($mask['pages'][$key][$k]['attributes'])) {
$mask['pages'][$key][$k]['attributes'] = array();
}
$mask['pages'][$key][$k]['element'] = $key.'___'.$this->_formElementEncode($v['element']); $mask['pages'][$key][$k]['element'] = $key.'___'.$this->_formElementEncode($v['element']);
$mask['pages'][$key][$k]['attributes'] = array_merge($mask['pages'][$key][$k]['attributes'], array('onChange' => "spread(this, '".$this->_formElementEncode($v['element'])."')")); $mask['pages'][$key][$k]['attributes'] = array_merge($mask['pages'][$key][$k]['attributes'], array('onChange' => "spread(this, '".$this->_formElementEncode($v['element'])."')"));
## load data from GreenBox ## load data from GreenBox
@ -359,10 +377,11 @@ class uiBrowser extends uiBase {
/** /**
* Test if URL seems to be valid * Test if URL seems to be valid
* *
* @param url string, full URL to test * @param url string
* @return array() * full URL to test
* @return array()
*/ */
function testStream($url) function testStream($url)
{ {

View file

@ -1,4 +1,9 @@
<?php <?php
/**
* @package Campcaster
* @subpackage htmlUI
* @version $Revision$
*/
class uiCalendar class uiCalendar
{ {
var $Decade; var $Decade;
@ -86,7 +91,7 @@ class uiCalendar
require_once 'Calendar/Week.php'; require_once 'Calendar/Week.php';
$Week = new Calendar_Week ($this->curr['year'], $this->curr['month'], $this->curr['day'], UI_SCHEDULER_FIRSTWEEKDAY); $Week = new Calendar_Week($this->curr['year'], $this->curr['month'], $this->curr['day'], UI_SCHEDULER_FIRSTWEEKDAY);
$Week->build($this->_scheduledDays('week')); $Week->build($this->_scheduledDays('week'));
while ($Day = $Week->fetch()) { while ($Day = $Week->fetch()) {
$corrMonth = $Day->thisMonth()<=12 ? sprintf('%02d', $Day->thisMonth()) : '01'; ## due to bug in $corrMonth = $Day->thisMonth()<=12 ? sprintf('%02d', $Day->thisMonth()) : '01'; ## due to bug in
@ -112,7 +117,7 @@ class uiCalendar
return; return;
} }
require_once 'Calendar/Day.php'; require_once('Calendar/Day.php');
$Day = new Calendar_Day ($this->curr['year'], $this->curr['month'], $this->curr['day']); $Day = new Calendar_Day ($this->curr['year'], $this->curr['month'], $this->curr['day']);
$Day->build(); $Day->build();
@ -138,9 +143,9 @@ class uiCalendar
{ {
if (is_array($this->Hour)) return; if (is_array($this->Hour)) return;
require_once 'Calendar/Hour.php'; require_once('Calendar/Hour.php');
$Hour = new Calendar_Hour ($this->curr['year'], $this->curr['month'], $this->curr['day'], $this->curr['hour']); $Hour = new Calendar_Hour($this->curr['year'], $this->curr['month'], $this->curr['day'], $this->curr['hour']);
$Hour->build(); $Hour->build();
while ($Min = $Hour->fetch()) { while ($Min = $Hour->fetch()) {
$this->Hour[] = array( $this->Hour[] = array(

View file

@ -7,11 +7,13 @@ define('UI_VERBOSE', FALSE);
define('UI_WARNING', TRUE); define('UI_WARNING', TRUE);
define('UI_ERROR', TRUE); define('UI_ERROR', TRUE);
if (UI_DEBUG) error_reporting(E_ALL); if (UI_DEBUG) {
error_reporting(E_ALL);
}
define('UI_VERSION', 'LiveSupport 1.1.0'); define('UI_VERSION', 'Campcaster 1.1.0');
define('UI_VERSION_FULLNAME', 'LiveSupport 1.1.0'); define('UI_VERSION_FULLNAME', 'Campcaster 1.1.0');
define('UI_TESTSTREAM_MU3_TMP', 'img/listen.m3u'); define('UI_TESTSTREAM_MU3_TMP', 'img/listen.m3u');
## Local settings ## Local settings

View file

@ -7,15 +7,16 @@ define('UI_VERBOSE', FALSE);
define('UI_WARNING', TRUE); define('UI_WARNING', TRUE);
define('UI_ERROR', TRUE); define('UI_ERROR', TRUE);
if (UI_DEBUG) error_reporting(E_ALL); if (UI_DEBUG) {
error_reporting(E_ALL);
}
define('UI_VERSION', 'Campcaster 1.1.0');
define('UI_VERSION', 'LiveSupport 1.1.0'); define('UI_VERSION_FULLNAME', 'Campcaster 1.1.0');
define('UI_VERSION_FULLNAME', 'LiveSupport 1.1.0');
define('UI_TESTSTREAM_MU3_TMP', 'img/listen.m3u'); define('UI_TESTSTREAM_MU3_TMP', 'img/listen.m3u');
## Scheduler ## Scheduler
define('UI_SCHEDULER_DAEMON_CMD', '/etc/init.d/livesupport-station start >/tmp/scheduler.log 2>&1 &'); ## adjust the start-command here define('UI_SCHEDULER_DAEMON_CMD', '/etc/init.d/campcaster-station start >/tmp/scheduler.log 2>&1 &'); ## adjust the start-command here
define('UI_SCHEDULER_DAEMON_NAME', 'scheduler'); ## this is name of scheduler process to grep in process list for it define('UI_SCHEDULER_DAEMON_NAME', 'scheduler'); ## this is name of scheduler process to grep in process list for it
## Local settings ## Local settings

View file

@ -1,11 +1,20 @@
<?php <?php
/**
* @package Campcaster
* @subpackage htmlUI
* @version $Revision$
*/
class uiExchange class uiExchange
{ {
var $Base;
var $file;
var $folder;
function uiExchange(&$uiBase) function uiExchange(&$uiBase)
{ {
$this->Base =& $uiBase; $this->Base =& $uiBase;
$this->file =& $_SESSION['EXCHANGE']['file']; $this->file =& $_SESSION['EXCHANGE']['file'];
$this->folder =& $_SESSION['EXCHANGE']['folder']; $this->folder =& $_SESSION['EXCHANGE']['folder'];
if (empty($this->folder)) { if (empty($this->folder)) {
$this->folder = '/tmp'; $this->folder = '/tmp';
} }
@ -20,60 +29,52 @@ class uiExchange
if (PEAR::isError($token)) { if (PEAR::isError($token)) {
return false; return false;
} }
return $token; return $token;
} }
function createBackupOpen() function createBackupOpen()
{ {
$criteria = array('filetype' => UI_FILETYPE_ANY); $criteria = array('filetype' => UI_FILETYPE_ANY);
$token = $this->Base->gb->createBackupOpen($this->Base->sessid, $criteria); $token = $this->Base->gb->createBackupOpen($this->Base->sessid, $criteria);
if (PEAR::isError($token)) { if (PEAR::isError($token)) {
$this->Base->_retMsg('Error initializing backup: $1', $token->getMessage()); $this->Base->_retMsg('Error initializing backup: $1', $token->getMessage());
return false; return false;
} }
$this->createBackupCheck(); $this->createBackupCheck();
$this->Base->gb->savePref($this->Base->sessid, UI_BACKUPTOKEN_KEY, $token['token']); $this->Base->gb->savePref($this->Base->sessid, UI_BACKUPTOKEN_KEY, $token['token']);
return true; return true;
} }
function createBackupCheck() function createBackupCheck()
{ {
$token = $this->getBackupToken(); $token = $this->getBackupToken();
if ($token === false) { if ($token === false) {
return false; return false;
} }
$res = $this->Base->gb->createBackupCheck($token); $res = $this->Base->gb->createBackupCheck($token);
if (PEAR::isError($res)) { if (PEAR::isError($res)) {
$this->Base->_retMsg('Unable to check backup status: $1', $res->getMessage()); $this->Base->_retMsg('Unable to check backup status: $1', $res->getMessage());
return false; return false;
} }
return $res; return $res;
} }
// Download the backup // Download the backup
function createBackupDownload() function createBackupDownload()
{ {
$check = $this->createBackupCheck(); $check = $this->createBackupCheck();
header('Content-Length: '.filesize($check['tmpfile'])); header('Content-Length: '.filesize($check['tmpfile']));
header("Content-Transfer-Encoding: binary"); header("Content-Transfer-Encoding: binary");
$newname='backup_'.date("Ymd", filectime($check['tmpfile'])).'.tar'; $newname='backup_'.date("Ymd", filectime($check['tmpfile'])).'.tar';
header('Content-Disposition: attachment; filename="'.$newname.'"'); header('Content-Disposition: attachment; filename="'.$newname.'"');
readfile($check['tmpfile']); readfile($check['tmpfile']);
} }
function createBackupClose() function createBackupClose()
{ {
$token = $this->getBackupToken(); $token = $this->getBackupToken();
@ -82,34 +83,39 @@ class uiExchange
$this->Base->_retMsg('Token not available'); $this->Base->_retMsg('Token not available');
return false; return false;
} }
$status = $this->Base->gb->createBackupClose($token); $status = $this->Base->gb->createBackupClose($token);
if (PEAR::isError($status)) { if (PEAR::isError($status)) {
$this->Base->_retMsg('Error closing backup: $1', $status->getMessage()); $this->Base->_retMsg('Error closing backup: $1', $status->getMessage());
return false; return false;
} }
if ($status === true) { if ($status === true) {
$this->Base->gb->delPref($this->Base->sessid, UI_BACKUPTOKEN_KEY); $this->Base->gb->delPref($this->Base->sessid, UI_BACKUPTOKEN_KEY);
} }
return $status; return $status;
} }
// backup schduler methods // backup schduler methods
/**
* @return array
*/
function getScheduleBackupForm() function getScheduleBackupForm()
{ {
include 'formmask/exchange.inc.php'; include('formmask/exchange.inc.php');
$form = new HTML_QuickForm('BACKUP_Schedule', UI_STANDARD_FORM_METHOD, UI_HANDLER); $form = new HTML_QuickForm('BACKUP_Schedule', UI_STANDARD_FORM_METHOD, UI_HANDLER);
$this->Base->_parseArr2Form($form, $mask['BACKUP.schedule']); $this->Base->_parseArr2Form($form, $mask['BACKUP.schedule']);
$renderer =& new HTML_QuickForm_Renderer_Array(true, true); $renderer =& new HTML_QuickForm_Renderer_Array(true, true);
$form->accept($renderer); $form->accept($renderer);
return $renderer->toArray(); return $renderer->toArray();
} }
/**
* Copy a file or directory.
*
* @param string $target - path to file or directory
* @return boolean
*/
function copy2target($target) function copy2target($target)
{ {
if (is_dir($target)) { if (is_dir($target)) {
@ -128,7 +134,6 @@ class uiExchange
return false; return false;
} }
$check = $this->createBackupCheck(); $check = $this->createBackupCheck();
if ($check['status'] === 'success') { if ($check['status'] === 'success') {
@ -154,60 +159,54 @@ class uiExchange
return $token; return $token;
} }
/**
* @param unknown_type $backupFile
* @return boolean
*/
function backupRestoreOpen($backupFile) function backupRestoreOpen($backupFile)
{ {
$token = $this->Base->gb->backupRestoreOpen($this->Base->sessid,$backupFile); $token = $this->Base->gb->backupRestoreOpen($this->Base->sessid,$backupFile);
if (PEAR::isError($token)) { if (PEAR::isError($token)) {
$this->Base->_retMsg('Error initializing backup restore: $1', $token->getMessage()); $this->Base->_retMsg('Error initializing backup restore: $1', $token->getMessage());
return false; return false;
} }
#$this->backupRestoreCheck(); //? #$this->backupRestoreCheck(); //?
$this->Base->gb->savePref($this->Base->sessid, UI_RESTORETOKEN_KEY, $token['token']); $this->Base->gb->savePref($this->Base->sessid, UI_RESTORETOKEN_KEY, $token['token']);
return true; return true;
} }
function backupRestoreCheck() function backupRestoreCheck()
{ {
$token = $this->getRestoreToken(); $token = $this->getRestoreToken();
if ($token === false) { if ($token === false) {
return false; return false;
} }
$res = $this->Base->gb->backupRestoreCheck($token); $res = $this->Base->gb->backupRestoreCheck($token);
if (PEAR::isError($res)) { if (PEAR::isError($res)) {
$this->Base->_retMsg('Unable to check backup restore status: $1', $res->getMessage()); $this->Base->_retMsg('Unable to check backup restore status: $1', $res->getMessage());
return false; return false;
} }
return $res; return $res;
} }
function backupRestoreClose() function backupRestoreClose()
{ {
$token = $this->getRestoreToken(); $token = $this->getRestoreToken();
if ($token === false) { if ($token === false) {
$this->Base->_retMsg('Backup restore token is not available'); $this->Base->_retMsg('Backup restore token is not available');
return false; return false;
} }
$status = $this->Base->gb->backupRestoreClose($token); $status = $this->Base->gb->backupRestoreClose($token);
if (PEAR::isError($status)) { if (PEAR::isError($status)) {
$this->Base->_retMsg('Error closing restore backup: $1', $status->getMessage()); $this->Base->_retMsg('Error closing restore backup: $1', $status->getMessage());
return false; return false;
} }
if ($status === true) { if ($status === true) {
$this->Base->gb->delPref($this->Base->sessid, UI_RESTORETOKEN_KEY); $this->Base->gb->delPref($this->Base->sessid, UI_RESTORETOKEN_KEY);
} }
return $status; return $status;
} }
@ -231,6 +230,7 @@ class uiExchange
$this->folder = $newfolder; $this->folder = $newfolder;
} }
function setFile($file) function setFile($file)
{ {
if (is_writable($this->folder.'/'.$file)) { if (is_writable($this->folder.'/'.$file)) {

View file

@ -3,38 +3,32 @@
define('ACTION_BASE', '/actions' ) ; define('ACTION_BASE', '/actions' ) ;
/** /**
* uiHandler class * HTML User Interface module
* * @package Campcaster
* Campcaster HTML User Interface module * @subpackage htmlUI
* @version $Revision$
*/ */
class uiHandler extends uiBase { class uiHandler extends uiBase {
# var $redirUrl; var $uiBase;
# var $alertMsg; var $redirUrl;
// --- class constructor ---
/** /**
* uiBrowser * Initialize a new Browser Class
* Call uiBase constructor
* *
* Initialize a new Browser Class * @param array $config
* Call uiBase constructor * configurartion data
*
* @param $config array, configurartion data
*/ */
function uiHandler($config) function uiHandler($config)
{ {
$this->uiBase($config); $this->uiBase($config);
} } // constructor
// --- authentication --- // --- authentication ---
/** /**
* login * Login to the storageServer.
* * It set sessid to the cookie with name defined in ../conf.php
* Login to the storageServer.
* It set sessid to the cookie with name defined in ../conf.php
*
* @param login string, username
* @param pass string, password
*/ */
function login($formdata, $mask) function login($formdata, $mask)
{ {
@ -77,15 +71,14 @@ class uiHandler extends uiBase {
$this->redirUrl = UI_BROWSER.'?popup[]=_2SCHEDULER&popup[]=_close'; $this->redirUrl = UI_BROWSER.'?popup[]=_2SCHEDULER&popup[]=_close';
return TRUE; return TRUE;
} } // fn login
/** /**
* logout * Logut from storageServer, takes sessid from cookie
*
* Logut from storageServer, takes sessid from cookie
*
* @param $trigger_login boolean, trigger login popup after logout
* *
* @param boolean $trigger_login
* trigger login popup after logout
*/ */
function logout($trigger_login = FALSE) function logout($trigger_login = FALSE)
{ {
@ -95,24 +88,27 @@ class uiHandler extends uiBase {
ob_clean(); ob_clean();
session_destroy(); session_destroy();
if ($trigger_login) if ($trigger_login) {
$this->redirUrl = UI_BROWSER.'?popup[]=_clear_parent&popup[]=login'; $this->redirUrl = UI_BROWSER.'?popup[]=_clear_parent&popup[]=login';
else $this->redirUrl = UI_BROWSER.'?popup[]=_clear_parent&popup[]=_close'; } else {
} $this->redirUrl = UI_BROWSER.'?popup[]=_clear_parent&popup[]=_close';
}
} // fn logout
// --- files --- // --- files ---
/** /**
* uploadFile * Provides file upload and store it to the storage
* *
* Provides file upload and store it to the storage * @param array $formdata
* * submitted text and file
* @param formdata array, submitted text and file
* @param id int, destination folder id
*/ */
function uploadFile($formdata, $mask, $replace=NULL) function uploadFile($formdata, $mask, $replace=NULL)
{ {
if ($this->test4audioType($formdata['mediafile']['name']) === FALSE) { if ($this->test4audioType($formdata['mediafile']['name']) === FALSE) {
if (UI_ERROR) $this->_retMsg('"$1" uses an unsupported file type.', $formdata['mediafile']['name']); if (UI_ERROR) {
$this->_retMsg('"$1" uses an unsupported file type.', $formdata['mediafile']['name']);
}
$this->redirUrl = UI_BROWSER."?act=addFileData&folderId=".$formdata['folderId']; $this->redirUrl = UI_BROWSER."?act=addFileData&folderId=".$formdata['folderId'];
return FALSE; return FALSE;
} }
@ -148,28 +144,37 @@ class uiHandler extends uiBase {
$this->_setMDataValue($r, UI_MDATA_KEY_TITLE, $formdata['mediafile']['name']); $this->_setMDataValue($r, UI_MDATA_KEY_TITLE, $formdata['mediafile']['name']);
$this->transMData($r); $this->transMData($r);
if (UI_UPLOAD_LANGID !== UI_DEFAULT_LANGID) { // set records in default language too // set records in default language too
if (UI_UPLOAD_LANGID !== UI_DEFAULT_LANGID) {
$this->_setMDataValue($r, UI_MDATA_KEY_TITLE, $formdata['mediafile']['name'], UI_UPLOAD_LANGID); $this->_setMDataValue($r, UI_MDATA_KEY_TITLE, $formdata['mediafile']['name'], UI_UPLOAD_LANGID);
$this->transMData($r, UI_UPLOAD_LANGID); $this->transMData($r, UI_UPLOAD_LANGID);
} }
$this->redirUrl = UI_BROWSER."?act=addFileMData&id=$r"; $this->redirUrl = UI_BROWSER."?act=addFileMData&id=$r";
if (UI_VERBOSE) $this->_retMsg('Data of audiclip saved.'); if (UI_VERBOSE) {
$this->_retMsg('Data of audiclip saved.');
}
return $r; return $r;
} } // fn uploadFile
function test4audioType($filename) function test4audioType($filename)
{ {
foreach ($this->config['file_types'] as $t) { foreach ($this->config['file_types'] as $t) {
if (preg_match('/'.str_replace('/', '\/', $t).'$/i', $filename)) if (preg_match('/'.str_replace('/', '\/', $t).'$/i', $filename)) {
return TRUE; return TRUE;
}
} }
return FALSE; return FALSE;
} } // fn test4AudioType
/**
* @todo Rename this function.
* @param unknown_type $id
* @param unknown_type $langid
* @return void
*/
function transMData($id, $langid=UI_DEFAULT_LANGID) function transMData($id, $langid=UI_DEFAULT_LANGID)
{ {
include dirname(__FILE__).'/formmask/metadata.inc.php'; include dirname(__FILE__).'/formmask/metadata.inc.php';
@ -179,10 +184,18 @@ class uiHandler extends uiBase {
$this->_setMDataValue($id, UI_MDATA_KEY_FORMAT, UI_MDATA_VALUE_FORMAT_FILE); $this->_setMDataValue($id, UI_MDATA_KEY_FORMAT, UI_MDATA_VALUE_FORMAT_FILE);
// some data from raw audio // some data from raw audio
if ($ia['audio']['channels']) $this->_setMDataValue($id, UI_MDATA_KEY_CHANNELS, $ia['audio']['channels']); if ($ia['audio']['channels']) {
if ($ia['audio']['sample_rate'])$this->_setMDataValue($id, UI_MDATA_KEY_SAMPLERATE, $ia['audio']['sample_rate']); $this->_setMDataValue($id, UI_MDATA_KEY_CHANNELS, $ia['audio']['channels']);
if ($ia['audio']['bitrate']) $this->_setMDataValue($id, UI_MDATA_KEY_BITRATE, $ia['audio']['bitrate']); }
if ($ia['audio']['codec']) $this->_setMDataValue($id, UI_MDATA_KEY_ENCODER, $ia['audio']['codec']); if ($ia['audio']['sample_rate']) {
$this->_setMDataValue($id, UI_MDATA_KEY_SAMPLERATE, $ia['audio']['sample_rate']);
}
if ($ia['audio']['bitrate']) {
$this->_setMDataValue($id, UI_MDATA_KEY_BITRATE, $ia['audio']['bitrate']);
}
if ($ia['audio']['codec']) {
$this->_setMDataValue($id, UI_MDATA_KEY_ENCODER, $ia['audio']['codec']);
}
// from id3 Tags // from id3 Tags
foreach ($mask['pages'] as $key=>$val) { ## loop main, music, talk foreach ($mask['pages'] as $key=>$val) { ## loop main, music, talk
@ -201,12 +214,10 @@ class uiHandler extends uiBase {
/** /**
* addWebstream * Provides file upload and store it to the storage
* *
* Provides file upload and store it to the storage * @param array $formdata, submitted text and file
* * @param unknown $mask
* @param formdata array, submitted text and file
* @param id int, destination folder id
*/ */
function addWebstream($formdata, $mask) function addWebstream($formdata, $mask)
{ {
@ -225,7 +236,7 @@ class uiHandler extends uiBase {
$r = $this->gb->storeWebstream($folderId, $formdata['title'], NULL, $this->sessid, NULL, $formdata['url']); $r = $this->gb->storeWebstream($folderId, $formdata['title'], NULL, $this->sessid, NULL, $formdata['url']);
if(PEAR::isError($r)) { if (PEAR::isError($r)) {
$this->_retMsg($r->getMessage()); $this->_retMsg($r->getMessage());
$this->redirUrl = UI_BROWSER."?act=editWebstream&id=".$id; $this->redirUrl = UI_BROWSER."?act=editWebstream&id=".$id;
return FALSE; return FALSE;
@ -238,9 +249,11 @@ class uiHandler extends uiBase {
$this->_setMDataValue($r, UI_MDATA_KEY_FORMAT, UI_MDATA_VALUE_FORMAT_STREAM); $this->_setMDataValue($r, UI_MDATA_KEY_FORMAT, UI_MDATA_VALUE_FORMAT_STREAM);
$this->redirUrl = UI_BROWSER."?act=addWebstreamMData&id=$r"; $this->redirUrl = UI_BROWSER."?act=addWebstreamMData&id=$r";
if (UI_VERBOSE) $this->_retMsg('Stream data saved.'); if (UI_VERBOSE) {
$this->_retMsg('Stream data saved.');
}
return $r; return $r;
} } // fn addWebstream
function editWebstream($formdata, $mask) function editWebstream($formdata, $mask)
@ -257,118 +270,140 @@ class uiHandler extends uiBase {
$this->_setMDataValue($id, UI_MDATA_KEY_DURATION, $extent); $this->_setMDataValue($id, UI_MDATA_KEY_DURATION, $extent);
$this->redirUrl = UI_BROWSER.'?act=editItem&id='.$formdata['id']; $this->redirUrl = UI_BROWSER.'?act=editItem&id='.$formdata['id'];
if (UI_VERBOSE) $this->_retMsg('Stream data saved.'); if (UI_VERBOSE) {
$this->_retMsg('Stream data saved.');
}
return TRUE; return TRUE;
} } // fn editWebstream
/**
* @todo Rename this function to "editMetadata".
* @param unknown_type $formdata
*/
function editMetaData($formdata) function editMetaData($formdata)
{ {
include dirname(__FILE__).'/formmask/metadata.inc.php'; include(dirname(__FILE__).'/formmask/metadata.inc.php');
$id = $formdata['id']; $id = $formdata['id'];
$curr_langid = $formdata['curr_langid']; $curr_langid = $formdata['curr_langid'];
$this->redirUrl = UI_BROWSER."?act=editItem&id=$id&curr_langid=".$formdata['target_langid']; $this->redirUrl = UI_BROWSER."?act=editItem&id=$id&curr_langid=".$formdata['target_langid'];
foreach ($mask['pages'] as $key=>$val) { foreach ($mask['pages'] as $key => $val) {
foreach ($mask['pages'][$key] as $k=>$v) { foreach ($mask['pages'][$key] as $k => $v) {
$formdata[$key.'___'.$this->_formElementEncode($v['element'])] ? $mData[$this->_formElementDecode($v['element'])] = $formdata[$key.'___'.$this->_formElementEncode($v['element'])] : NULL; $formdata[$key.'___'.$this->_formElementEncode($v['element'])] ? $mData[$this->_formElementDecode($v['element'])] = $formdata[$key.'___'.$this->_formElementEncode($v['element'])] : NULL;
} }
} }
if (!count($mData)) return; if (!count($mData)) {
return;
}
foreach ($mData as $key=>$val) { foreach ($mData as $key => $val) {
$r = $this->_setMDataValue($id, $key, $val, $curr_langid); $r = $this->_setMDataValue($id, $key, $val, $curr_langid);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
$this->_retMsg('Unable to set "$1" to value "$2".', $key, $val); $this->_retMsg('Unable to set "$1" to value "$2".', $key, $val);
} }
} }
if (UI_VERBOSE) $this->_retMsg('Metadata saved.'); if (UI_VERBOSE) {
} $this->_retMsg('Metadata saved.');
}
} // fn editMetadata
/** /**
* newFolder * Create new folder in the storage
* *
* Create new folder in the storage * @param string $name
* * name for the new folder
* @param newname string, name for the new folder * @param int $id
* @param id int, local id to create folder in * local id to create folder in
*/ */
function newFolder($name, $id) function newFolder($name, $id)
{ {
$r = $this->gb->createFolder($id, $name, $this->sessid); $r = $this->gb->createFolder($id, $name, $this->sessid);
if(PEAR::isError($r)) if (PEAR::isError($r)) {
$this->_retMsg($r->getMessage()); $this->_retMsg($r->getMessage());
}
$this->redirUrl = UI_BROWSER.'?act=fileList&id='.$this->id; $this->redirUrl = UI_BROWSER.'?act=fileList&id='.$this->id;
} } // fn newFolder
/** /**
* rename * Change the name of file or folder
* *
* Change the name of file or folder * @param string $newname
* * new name for the file or folder
* @param newname string, new name for the file or folder * @param int $id
* @param id int, destination folder id * destination folder id
*/ */
function rename($newname, $id) function rename($newname, $id)
{ {
$r = $this->gb->renameFile($id, $newname, $this->sessid); $r = $this->gb->renameFile($id, $newname, $this->sessid);
if(PEAR::isError($r)) $this->_retMsg($r->getMessage()); if (PEAR::isError($r)) {
$this->_retMsg($r->getMessage());
}
$this->redirUrl = UI_BROWSER."?act=fileList&id=".$this->pid; $this->redirUrl = UI_BROWSER."?act=fileList&id=".$this->pid;
} } // fn rename
/** /**
* move * Move file to another folder
* *
* Move file to another folder * @todo format of destination path should be properly defined
* TODO: format of destinantion path should be properly defined
* *
* @param newPath string, destination relative path * @param string $newPath
* @param id int, destination folder id * destination relative path
* @param int $id
* destination folder id
*/ */
function move($newPath, $id) function move($newPath, $id)
{ {
$newPath = urldecode($newPath); $newPath = urldecode($newPath);
$did = $this->gb->getObjIdFromRelPath($id, $newPath); $did = $this->gb->getObjIdFromRelPath($id, $newPath);
$r = $this->gb->moveFile($id, $did, $this->sessid); $r = $this->gb->moveFile($id, $did, $this->sessid);
if(PEAR::isError($r)){ if (PEAR::isError($r)) {
$this->_retMsg($r->getMessage()); $this->_retMsg($r->getMessage());
$this->redirUrl = UI_BROWSER."?act=fileList&id=".$this->pid; $this->redirUrl = UI_BROWSER."?act=fileList&id=".$this->pid;
} else {
$this->redirUrl = UI_BROWSER."?act=fileList&id=".$did;
} }
else $this->redirUrl = UI_BROWSER."?act=fileList&id=".$did; } // fn move
}
/** /**
* copy
*
* Copy file to another folder * Copy file to another folder
* TODO: format of destinantion path should be properly defined
* *
* @param newPath string, destination relative path * @todo format of destinantion path should be properly defined
* @param id int, destination folder id *
* @param string $newPath
* destination relative path
* @param int $id
* destination folder id
*/ */
function copy($newPath, $id) function copy($newPath, $id)
{ {
$newPath = urldecode($newPath); $newPath = urldecode($newPath);
$did = $this->gb->getObjIdFromRelPath($id, $newPath); $did = $this->gb->getObjIdFromRelPath($id, $newPath);
$r = $this->gb->copyFile($id, $did, $this->sessid); $r = $this->gb->copyFile($id, $did, $this->sessid);
if(PEAR::isError($r)){ if (PEAR::isError($r)) {
$this->_retMsg($r->getMessage()); $this->_retMsg($r->getMessage());
$this->redirUrl = UI_BROWSER."?act=fileList&id=".$this->pid; $this->redirUrl = UI_BROWSER."?act=fileList&id=".$this->pid;
} else {
$this->redirUrl = UI_BROWSER."?act=fileList&id=".$did;
} }
else $this->redirUrl = UI_BROWSER."?act=fileList&id=".$did; } // fn copy
}
/** /**
* delete * Delete a stored file.
* *
* Delete of stored file * @param mixed $id
* * either an int or an array of ints which are
* @param id int, local id of deleted file or folder * IDs of files or folders to delete.
* @param delOverride int, local id od folder which can deleted if not empty * @param boolean $delOverride
* this parameter is not used
* @return boolean
*/ */
function delete($id, $delOverride=FALSE) function delete($id, $delOverride=FALSE)
{ {
@ -383,8 +418,11 @@ class uiHandler extends uiBase {
} }
*/ */
if (is_array($id)) $ids = $id; if (is_array($id)) {
else $ids[] = $id; $ids = $id;
} else {
$ids[] = $id;
}
foreach ($ids as $id) { foreach ($ids as $id) {
if ($this->gb->getFileType($id) == 'playlist') { if ($this->gb->getFileType($id) == 'playlist') {
@ -393,38 +431,40 @@ class uiHandler extends uiBase {
$r = $this->gb->deleteFile($id, $this->sessid); $r = $this->gb->deleteFile($id, $this->sessid);
} }
if(PEAR::isError($r)) { if (PEAR::isError($r)) {
$this->_retMsg($r->getMessage()); $this->_retMsg($r->getMessage());
return FALSE; return FALSE;
} }
} }
return TRUE; return TRUE;
} } // fn delete
/** /**
* getFile * Call access method and show access path.
* Example only - not really useable.
* @todo resource should be released by release method call
* *
* Call access method and show access path. * @param int $id
* Example only - not really useable. * local id of accessed file
* TODO: resource should be released by release method call
*
* @param id int, local id of accessed file
*/ */
function getFile($id) function getFile($id)
{ {
$r = $this->gb->access($id, $this->sessid); $r = $this->gb->access($id, $this->sessid);
if(PEAR::isError($r)) $this->_retMsg($r->getMessage()); if (PEAR::isError($r)) {
else echo $r; $this->_retMsg($r->getMessage());
} } else {
echo $r;
}
} // fn getFile
/** /**
* getMdata * Show file's metadata as XML
* *
* Show file's metadata as XML * @param int $id
* * local id of stored file
* @param id int, local id of stored file
*/ */
function getMdata($id) function getMdata($id)
{ {
@ -433,16 +473,20 @@ class uiHandler extends uiBase {
print_r($r); print_r($r);
} }
// --- perms --- // --- perms ---
/** /**
* addPerm * Add new permission record
* *
* Add new permission record * @param int $subj
* * local user/group id
* @param subj int, local user/group id * @param string $permAction
* @param permAction string, type of action from set predefined in conf.php * type of action from set predefined in conf.php
* @param id int, local id of file/object * @param int $id
* @param allowDeny char, A or D * local id of file/object
* @param char $allowDeny
* 'A' or 'D'
* @return boolean
*/ */
function addPerm($subj, $permAction, $id, $allowDeny) function addPerm($subj, $permAction, $id, $allowDeny)
{ {
@ -456,15 +500,16 @@ class uiHandler extends uiBase {
} }
$this->redirUrl = UI_BROWSER.'?act=permissions&id='.$id; $this->redirUrl = UI_BROWSER.'?act=permissions&id='.$id;
return TRUE; return TRUE;
} } // fn addPerm
/** /**
* removePerm * Remove permission record
* *
* Remove permission record * @param int $permid
* * local id of permission record
* @param permid int, local id of permission record * @param int $oid
* @param oid int, local id of object to handle * local id of object to handle
*/ */
function removePerm($permid, $oid) function removePerm($permid, $oid)
{ {
@ -474,12 +519,10 @@ class uiHandler extends uiBase {
} }
$this->redirUrl = UI_BROWSER.'?act=permissions&id='.$oid; $this->redirUrl = UI_BROWSER.'?act=permissions&id='.$oid;
return TRUE; return TRUE;
} } // fn removePerm
/** /**
* Enter description here...
*
* @param unknown_type $formdata * @param unknown_type $formdata
* @param array $mask * @param array $mask
* @return boolean * @return boolean
@ -536,9 +579,14 @@ class uiHandler extends uiBase {
} }
} */ } */
return TRUE; return TRUE;
} } // fn _validateForm
/**
* @param unknown_type $formdata
* @param unknown_type $mask
* @return boolean
*/
function changeStationPrefs($formdata, $mask) function changeStationPrefs($formdata, $mask)
{ {
$this->redirUrl = UI_BROWSER; $this->redirUrl = UI_BROWSER;
@ -547,7 +595,7 @@ class uiHandler extends uiBase {
$this->_retMsg('Error while saving settings.'); $this->_retMsg('Error while saving settings.');
return FALSE; return FALSE;
} }
foreach($mask as $key=>$val) { foreach ($mask as $key => $val) {
if (isset($val['isPref']) && $val['isPref']) { if (isset($val['isPref']) && $val['isPref']) {
if (strlen($formdata[$val['element']])) { if (strlen($formdata[$val['element']])) {
if (PEAR::isError($this->gb->saveGroupPref($this->sessid, 'StationPrefs', $val['element'], $formdata[$val['element']]))) if (PEAR::isError($this->gb->saveGroupPref($this->sessid, 'StationPrefs', $val['element'], $formdata[$val['element']])))

View file

@ -1,6 +1,12 @@
<?php <?php
/**
* @package Campcaster
* @subpackage htmlUI
* @version $Revision$
*/
class uiHubBrowse extends uiBrowse class uiHubBrowse extends uiBrowse
{ {
function uiHubBrowse(&$uiBase) function uiHubBrowse(&$uiBase)
{ {
$this->Base =& $uiBase; $this->Base =& $uiBase;
@ -10,27 +16,34 @@ class uiHubBrowse extends uiBrowse
#$this->results =& $_SESSION[UI_HUBBROWSE_SESSNAME]['results']; #$this->results =& $_SESSION[UI_HUBBROWSE_SESSNAME]['results'];
$this->reloadUrl = UI_BROWSER.'?popup[]=_reload_parent&popup[]=_close'; $this->reloadUrl = UI_BROWSER.'?popup[]=_reload_parent&popup[]=_close';
if (empty($this->criteria['limit'])) $this->criteria['limit'] = UI_BROWSE_DEFAULT_LIMIT; if (empty($this->criteria['limit'])) {
if (empty($this->criteria['filetype'])) $this->criteria['filetype'] = UI_FILETYPE_ANY; $this->criteria['limit'] = UI_BROWSE_DEFAULT_LIMIT;
}
if (empty($this->criteria['filetype'])) {
$this->criteria['filetype'] = UI_FILETYPE_ANY;
}
if (!is_array($this->col)) { if (!is_array($this->col)) {
## init Categorys ## init Categorys
$this->setDefaults(); $this->setDefaults();
} }
} } // constructor
function getResult() function getResult()
{ {
$this->getSearchResults($this->searchDB()); $this->getSearchResults($this->searchDB());
//return $this->searchDB(); //return $this->searchDB();
return $this->results; return $this->results;
} } // fn getResult
function searchDB() function searchDB()
{ {
$trtokid = $this->Base->gb->globalSearch($this->criteria); $trtokid = $this->Base->gb->globalSearch($this->criteria);
return $trtokid; return $trtokid;
} } // fn searchDB
function getSearchResults($trtokid) { function getSearchResults($trtokid) {
$this->results = array('page' => $this->criteria['offset']/$this->criteria['limit']); $this->results = array('page' => $this->criteria['offset']/$this->criteria['limit']);
@ -47,6 +60,7 @@ class uiHubBrowse extends uiBrowse
// echo '<XMP>this->results:'; print_r($this->results); echo "</XMP>\n"; // echo '<XMP>this->results:'; print_r($this->results); echo "</XMP>\n";
// echo '<XMP>results:'; print_r($results); echo "</XMP>\n"; // echo '<XMP>results:'; print_r($results); echo "</XMP>\n";
return is_array($results); return is_array($results);
} } // fn getSearchResults
}
} // fn uiHubBrowse
?> ?>

View file

@ -1,6 +1,11 @@
<?php <?php
class uiHubSearch extends uiSearch /**
{ * @package Campcaster
* @subpackage htmlUI
* @version $Revision$
*/
class uiHubSearch extends uiSearch {
function uiHubSearch(&$uiBase) function uiHubSearch(&$uiBase)
{ {
$this->Base =& $uiBase; $this->Base =& $uiBase;
@ -9,8 +14,11 @@ class uiHubSearch extends uiSearch
$this->criteria =& $_SESSION[UI_HUBSEARCH_SESSNAME]['criteria']; $this->criteria =& $_SESSION[UI_HUBSEARCH_SESSNAME]['criteria'];
$this->reloadUrl = UI_BROWSER.'?popup[]=_reload_parent&popup[]=_close'; $this->reloadUrl = UI_BROWSER.'?popup[]=_reload_parent&popup[]=_close';
if (empty($this->criteria['limit'])) $this->criteria['limit'] = UI_BROWSE_DEFAULT_LIMIT; if (empty($this->criteria['limit'])) {
} $this->criteria['limit'] = UI_BROWSE_DEFAULT_LIMIT;
}
} // constructor
function getResult() function getResult()
{ {
@ -20,7 +28,8 @@ class uiHubSearch extends uiSearch
return $this->results; return $this->results;
} }
return false; return false;
} } // fn getResult
function newSearch(&$formdata) function newSearch(&$formdata)
{ {
@ -33,8 +42,8 @@ class uiHubSearch extends uiSearch
$this->criteria['limit'] = $formdata['limit']; $this->criteria['limit'] = $formdata['limit'];
$this->criteria['counter'] = 0; $this->criteria['counter'] = 0;
// $criteria['form'] is used for retransfer to form
$this->criteria['form']['operator'] = $formdata['operator']; ## $criteria['form'] is used for retransfer to form ## $this->criteria['form']['operator'] = $formdata['operator'];
$this->criteria['form']['filetype'] = $formdata['filetype']; $this->criteria['form']['filetype'] = $formdata['filetype'];
$this->criteria['form']['limit'] = $formdata['limit']; $this->criteria['form']['limit'] = $formdata['limit'];
@ -56,17 +65,17 @@ class uiHubSearch extends uiSearch
$trtokid = $this->Base->gb->globalSearch($this->criteria); $trtokid = $this->Base->gb->globalSearch($this->criteria);
$this->Base->redirUrl = UI_BROWSER.'?popup[]='.$this->prefix.'.getResults&trtokid='.$trtokid; $this->Base->redirUrl = UI_BROWSER.'?popup[]='.$this->prefix.'.getResults&trtokid='.$trtokid;
} } // fn newSearch
function searchDB() function searchDB()
{ {
if (count($this->criteria) === 0) if (count($this->criteria) === 0) {
return FALSE; return FALSE;
}
$this->results = array('page' => $this->criteria['offset'] / $this->criteria['limit']); $this->results = array('page' => $this->criteria['offset'] / $this->criteria['limit']);
#print_r($this->criteria); //print_r($this->criteria);
$results = $this->Base->gb->localSearch($this->criteria, $this->Base->sessid); $results = $this->Base->gb->localSearch($this->criteria, $this->Base->sessid);
if (PEAR::isError($results)) { if (PEAR::isError($results)) {
#print_r($results); #print_r($results);
@ -78,11 +87,12 @@ class uiHubSearch extends uiSearch
} }
$this->results['cnt'] = $results['cnt']; $this->results['cnt'] = $results['cnt'];
#print_r($this->results); //print_r($this->results);
$this->pagination($results); $this->pagination($results);
return TRUE; return TRUE;
} } // fn searchDB
function getSearchResults($trtokid) { function getSearchResults($trtokid) {
$this->results = array('page' => $this->criteria['offset']/$this->criteria['limit']); $this->results = array('page' => $this->criteria['offset']/$this->criteria['limit']);
@ -99,7 +109,7 @@ class uiHubSearch extends uiSearch
//echo '<XMP>this->results:'; print_r($this->results); echo "</XMP>\n"; //echo '<XMP>this->results:'; print_r($this->results); echo "</XMP>\n";
//echo '<XMP>results:'; print_r($results); echo "</XMP>\n"; //echo '<XMP>results:'; print_r($results); echo "</XMP>\n";
return is_array($results); return is_array($results);
} } // fn getSearchResults
} } // class uiHubSearch
?> ?>

View file

@ -1,50 +1,78 @@
<?php <?php
class jscom{ /**
* @package Campcaster
* @subpackage htmlUI
* @version $Revision$
*/
class jscom {
var $prefix = 'jsc_'; var $prefix = 'jsc_';
var $callables = array(); var $callables = array();
var $method = 'POST'; var $method = 'POST';
var $uri = ''; var $uri = '';
function jscom($calls = NULL, $pars = NULL){ function jscom($calls = NULL, $pars = NULL)
{
$this->uri = $_SERVER['REQUEST_URI']; $this->uri = $_SERVER['REQUEST_URI'];
if(!is_null($calls)) $this->addCallables($calls); if (!is_null($calls)) {
if(is_array($pars)){ $this->addCallables($calls);
foreach($pars as $parname=>$par){ }
if(!is_null($par)) $this->setPar($parname, $par); if (is_array($pars)) {
foreach ($pars as $parname=>$par) {
if (!is_null($par)) {
$this->setPar($parname, $par);
}
} }
} }
} }
function noCacheHeader () function noCacheHeader ()
{ {
header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header ("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header ("Cache-Control: no-cache, must-revalidate"); header("Cache-Control: no-cache, must-revalidate");
header ("Pragma: no-cache"); header("Pragma: no-cache");
} }
function handler() function handler()
{ {
$args = array(); $args = array();
$mode = ''; $mode = '';
if(!empty($_GET[$this->prefix."mn"])){ $mode = 'get'; $rqst = $_GET; $this->noCacheHeader(); } if (!empty($_GET[$this->prefix."mn"])) {
if(!empty($_POST[$this->prefix."mn"])){ $mode = 'post'; $rqst = $_POST; } $mode = 'get';
if(empty($mode)){ return; } $rqst = $_GET;
$this->noCacheHeader();
}
if (!empty($_POST[$this->prefix."mn"])) {
$mode = 'post';
$rqst = $_POST;
}
if (empty($mode)) {
return;
}
$methodName = $rqst[$this->prefix.'mn']; $methodName = $rqst[$this->prefix.'mn'];
$args = $rqst[$this->prefix.'args']; $args = $rqst[$this->prefix.'args'];
if(in_array($methodName, $this->callables)){ if (in_array($methodName, $this->callables)) {
$res = call_user_func_array($methodName, $args); $res = call_user_func_array($methodName, $args);
}else{ }else{
$res = "ERROR: $methodName not callable"; $res = "ERROR: $methodName not callable";
} }
if(is_array($res)){ if (is_array($res)) {
$r = array(); $r = array();
foreach($res as $k=>$v){ $r[] = "'$v'"; } foreach ($res as $k=>$v) {
$r[] = "'$v'";
}
$res = "[".join(', ', $r)."]"; $res = "[".join(', ', $r)."]";
} }
echo $res; echo $res;
exit; exit;
} }
function genJsCode(){
function genJsCode()
{
ob_start(); ob_start();
?> ?>
var method = "<?php echo $this->method; ?>"; var method = "<?php echo $this->method; ?>";
@ -53,16 +81,16 @@ class jscom{
var co; var co;
try{ try{
co = new ActiveXObject("Msxml2.XMLHTTP"); co = new ActiveXObject("Msxml2.XMLHTTP");
}catch(err1){ }catch(err1) {
try{ try{
co = new ActiveXObject("Microsoft.XMLHTTP"); co = new ActiveXObject("Microsoft.XMLHTTP");
}catch(err2) { }catch(err2) {
co = null; co = null;
} }
} }
if(!co && typeof XMLHttpRequest != "undefined") if (!co && typeof XMLHttpRequest != "undefined")
co = new XMLHttpRequest(); co = new XMLHttpRequest();
if(!co){ if (!co) {
alert("Could not create connection object."); alert("Could not create connection object.");
} }
return co; return co;
@ -76,11 +104,15 @@ class jscom{
uri = "<?php echo $this->uri; ?>"; uri = "<?php echo $this->uri; ?>";
arstr = "<?php echo$this->prefix; ?>mn="+escape(methodName); arstr = "<?php echo$this->prefix; ?>mn="+escape(methodName);
for (i = 0; i < args.length; i++){ arstr += "&<?php echo$this->prefix; ?>args[]=" + escape(args[i]); } for (i = 0; i < args.length; i++) {
if(method == "GET"){ arstr += "&<?php echo$this->prefix; ?>args[]=" + escape(args[i]);
}
if (method == "GET") {
uri += ((uri.indexOf("?") == -1) ? "?" : "&" ) + arstr; uri += ((uri.indexOf("?") == -1) ? "?" : "&" ) + arstr;
uri += "&<?php echo$this->prefix; ?>x=" + new Date().getTime(); uri += "&<?php echo$this->prefix; ?>x=" + new Date().getTime();
}else{ post_data = arstr; } } else {
post_data = arstr;
}
comObj = createComObj(); comObj = createComObj();
comObj.callbackOrId = callbackOrId; comObj.callbackOrId = callbackOrId;
@ -90,27 +122,29 @@ class jscom{
comObj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); comObj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
} }
comObj.onreadystatechange = function() { comObj.onreadystatechange = function() {
if(comObj.readyState != 4) return; if (comObj.readyState != 4) {
return;
}
var data = comObj.responseText; var data = comObj.responseText;
if(typeof comObj.callbackOrId == "function"){ if (typeof comObj.callbackOrId == "function") {
callbackOrId(data); callbackOrId(data);
}else if(typeof comObj.callbackOrId == "object"){ } else if (typeof comObj.callbackOrId == "object") {
eval("res="+data); eval("res="+data);
for(i=0; i<comObj.callbackOrId.length; i++){ for (i = 0; i < comObj.callbackOrId.length; i++) {
setResult(comObj.callbackOrId[i], res[i]) setResult(comObj.callbackOrId[i], res[i])
} }
}else if(typeof comObj.callbackOrId != "undefined"){ } else if (typeof comObj.callbackOrId != "undefined") {
setResult(comObj.callbackOrId, data) setResult(comObj.callbackOrId, data)
}else{ } else {
alert('result from server: '+data); alert('result from server: '+data);
} }
} }
comObj.send(post_data); comObj.send(post_data);
delete comObj; delete comObj;
} }
function setResult(id, data){ function setResult(id, data) {
var el = document.getElementById(id) ; var el = document.getElementById(id) ;
if(el.tagName == 'INPUT'){ el.value = data; } if (el.tagName == 'INPUT') { el.value = data; }
else{ el.innerHTML = data; } else{ el.innerHTML = data; }
} }
@ -119,18 +153,27 @@ class jscom{
ob_end_clean(); ob_end_clean();
return $code; return $code;
} }
function addCallables() {
function addCallables()
{
$n = func_num_args(); $n = func_num_args();
for ($i = 0; $i < $n; $i++) { for ($i = 0; $i < $n; $i++) {
$a = func_get_arg($i); $a = func_get_arg($i);
if(is_array($a)) $this->callables = array_merge($this->callables, $a); if (is_array($a)) {
else $this->callables[] = $a; $this->callables = array_merge($this->callables, $a);
} else {
$this->callables[] = $a;
}
} }
} }
function setPar($parName, $value = NULL) {
switch($parName){
case"method": function setPar($parName, $value = NULL)
case"uri": {
switch ($parName) {
case "method":
case "uri":
$this->{$parName} = $value; $this->{$parName} = $value;
break; break;
} }

View file

@ -1,41 +1,62 @@
<?php <?php
/**
* @package Campcaster
* @subpackage htmlUI
* @version $Revision$
*/
class uiPlaylist class uiPlaylist
{ {
var $Base;
var $activeId;
var $changed;
var $title;
var $duration;
var $token;
var $reloadUrl;
var $redirectUrl;
var $returnUrl;
function uiPlaylist(&$uiBase) function uiPlaylist(&$uiBase)
{ {
$this->Base =& $uiBase; $this->Base =& $uiBase;
$this->activeId =& $_SESSION[UI_PLAYLIST_SESSNAME]['activeId']; $this->activeId =& $_SESSION[UI_PLAYLIST_SESSNAME]['activeId'];
$this->changed =& $_SESSION[UI_PLAYLIST_SESSNAME]['changed']; $this->changed =& $_SESSION[UI_PLAYLIST_SESSNAME]['changed'];
$this->title = $this->Base->_getMDataValue($this->activeId, UI_MDATA_KEY_TITLE); $this->title = $this->Base->_getMDataValue($this->activeId, UI_MDATA_KEY_TITLE);
$this->duration = $this->Base->_getMDataValue($this->activeId, UI_MDATA_KEY_DURATION); $this->duration = $this->Base->_getMDataValue($this->activeId, UI_MDATA_KEY_DURATION);
$this->token =& $_SESSION[UI_PLAYLIST_SESSNAME]['token']; $this->token =& $_SESSION[UI_PLAYLIST_SESSNAME]['token'];
$this->reloadUrl = UI_BROWSER.'?popup[]=_reload_parent&popup[]=_close'; $this->reloadUrl = UI_BROWSER.'?popup[]=_reload_parent&popup[]=_close';
$this->redirectUrl = UI_BROWSER.'?popup[]=_2PL.simpleManagement&popup[]=_close'; $this->redirectUrl = UI_BROWSER.'?popup[]=_2PL.simpleManagement&popup[]=_close';
$this->returnUrl = UI_BROWSER.'?act=PL.simpleManagement'; $this->returnUrl = UI_BROWSER.'?act=PL.simpleManagement';
} } // constructor
function setReload() function setReload()
{ {
$this->Base->redirUrl = $this->reloadUrl; $this->Base->redirUrl = $this->reloadUrl;
} } // fn setReload
function setRedirect($target=FALSE) function setRedirect($target=FALSE)
{ {
if ($target!==FALSE) if ($target !== FALSE) {
$this->Base->redirUrl = UI_BROWSER."?popup[]=$target&popup[]=_close"; $this->Base->redirUrl = UI_BROWSER."?popup[]=$target&popup[]=_close";
else } else {
$this->Base->redirUrl = $this->redirectUrl; $this->Base->redirUrl = $this->redirectUrl;
} }
} // fn setRedirect
function setReturn() function setReturn()
{ {
$this->Base->redirUrl = $this->returnUrl; $this->Base->redirUrl = $this->returnUrl;
} } // fn setReturn
function getPLArray($id) function getPLArray($id)
{ {
return $this->Base->gb->getPlaylistArray($id, $this->Base->sessid); return $this->Base->gb->getPlaylistArray($id, $this->Base->sessid);
} } // fn getPLArray
function getActiveArr() function getActiveArr()
{ {
@ -44,7 +65,8 @@ class uiPlaylist
} }
#echo '<pre><div align="left">'; print_r( $this->Base->gb->getPlaylistArray($this->activeId, $this->Base->sessid)); echo '</div></pre>'; #echo '<pre><div align="left">'; print_r( $this->Base->gb->getPlaylistArray($this->activeId, $this->Base->sessid)); echo '</div></pre>';
return $this->getPLArray($this->activeId); return $this->getPLArray($this->activeId);
} } // fn getActiveArr
function getActiveId() function getActiveId()
{ {
@ -52,7 +74,8 @@ class uiPlaylist
return FALSE; return FALSE;
} }
return $this->activeId; return $this->activeId;
} } // fn getActiveId
function activate($plid, $msg=TRUE) function activate($plid, $msg=TRUE)
{ {
@ -61,51 +84,68 @@ class uiPlaylist
# store access token to ls_pref abd session # store access token to ls_pref abd session
# load PL into session # load PL into session
if ($this->token) { if ($this->token) {
if (UI_WARNING) $this->Base->_retMsg('You already have an open playlist. Close it first.'); if (UI_WARNING) {
$this->Base->_retMsg('You already have an open playlist. Close it first.');
}
return FALSE; return FALSE;
} }
if(($userid = $this->Base->gb->playlistIsAvailable($plid, $this->Base->sessid)) !== TRUE) { if (($userid = $this->Base->gb->playlistIsAvailable($plid, $this->Base->sessid)) !== TRUE) {
if (UI_WARNING) $this->Base->_retMsg('Playlist has been locked by "$1".', $this->Base->gb->getSubjName($userid)); if (UI_WARNING) {
$this->Base->_retMsg('Playlist has been locked by "$1".', $this->Base->gb->getSubjName($userid));
}
return FALSE; return FALSE;
} }
$token = $this->Base->gb->lockPlaylistForEdit($plid, $this->Base->sessid); $token = $this->Base->gb->lockPlaylistForEdit($plid, $this->Base->sessid);
if (PEAR::isError($token)) { if (PEAR::isError($token)) {
if (UI_VERBOSE === TRUE) print_r($token); if (UI_VERBOSE === TRUE) {
print_r($token);
}
$this->Base->_retMsg('Unable to open playlist "$1".', $this->Base->_getMDataValue($plid, UI_MDATA_KEY_TITLE)); $this->Base->_retMsg('Unable to open playlist "$1".', $this->Base->_getMDataValue($plid, UI_MDATA_KEY_TITLE));
return FALSE; return FALSE;
} }
$this->token = $token; $this->token = $token;
$this->Base->gb->savePref($this->Base->sessid, UI_PL_ACCESSTOKEN_KEY, $plid.':'.$this->token); $this->Base->gb->savePref($this->Base->sessid, UI_PL_ACCESSTOKEN_KEY, $plid.':'.$this->token);
$this->activeId = $plid; $this->activeId = $plid;
if ($msg && UI_VERBOSE) $this->Base->_retMsg('Playlist "$1" opened.', $this->Base->_getMDataValue($plid, UI_MDATA_KEY_TITLE)); if ($msg && UI_VERBOSE) {
$this->Base->_retMsg('Playlist "$1" opened.', $this->Base->_getMDataValue($plid, UI_MDATA_KEY_TITLE));
}
return TRUE; return TRUE;
} }
function release($msg=TRUE) function release($msg=TRUE)
{ {
# get token from ls_pref # get token from ls_pref
# release PL # release PL
# delete PL from session # delete PL from session
# remove token from ls_pref # remove token from ls_pref
if(!$this->token) { if (!$this->token) {
if (UI_WARNING) $this->Base->_retMsg('There is no playlist available to unlock.'); if (UI_WARNING) {
$this->Base->_retMsg('There is no playlist available to unlock.');
}
return FALSE; return FALSE;
} }
$plgunid = $this->Base->gb->releaseLockedPlaylist($this->token, $this->Base->sessid); $plgunid = $this->Base->gb->releaseLockedPlaylist($this->token, $this->Base->sessid);
if (PEAR::isError($plgunid)) { if (PEAR::isError($plgunid)) {
if (UI_VERBOSE === TRUE) print_r($plgunid); if (UI_VERBOSE === TRUE) {
if (UI_WARNING) $this->Base->_retMsg('Unable to release playlist.'); print_r($plgunid);
}
if (UI_WARNING) {
$this->Base->_retMsg('Unable to release playlist.');
}
return FALSE; return FALSE;
} }
if ($msg && UI_VERBOSE) $this->Base->_retMsg('Playlist "$1" released.', $this->Base->_getMDataValue($this->Base->gb->_idFromGunid($plgunid), UI_MDATA_KEY_TITLE)); if ($msg && UI_VERBOSE) {
$this->Base->_retMsg('Playlist "$1" released.', $this->Base->_getMDataValue($this->Base->gb->_idFromGunid($plgunid), UI_MDATA_KEY_TITLE));
}
$this->activeId = NULL; $this->activeId = NULL;
$this->token = NULL; $this->token = NULL;
$this->Base->gb->delPref($this->Base->sessid, UI_PL_ACCESSTOKEN_KEY); $this->Base->gb->delPref($this->Base->sessid, UI_PL_ACCESSTOKEN_KEY);
$this->changed = FALSE; $this->changed = FALSE;
return TRUE; return TRUE;
} } // fn release
function save() function save()
@ -114,51 +154,66 @@ class uiPlaylist
$this->release(FALSE); $this->release(FALSE);
$this->activate($tmpid, FALSE); $this->activate($tmpid, FALSE);
$this->changed = FALSE; $this->changed = FALSE;
if (UI_VERBOSE) $this->Base->_retMsg('Playlist "$1" saved.', $this->Base->_getMDataValue($tmpid, UI_MDATA_KEY_TITLE)); if (UI_VERBOSE) {
$this->Base->_retMsg('Playlist "$1" saved.', $this->Base->_getMDataValue($tmpid, UI_MDATA_KEY_TITLE));
}
return $this->activeId; return $this->activeId;
} } // fn save
function revert() function revert()
{ {
if(!$this->token) { if (!$this->token) {
if (UI_WARNING) $this->Base->_retMsg('No playlists have been locked by you.'); if (UI_WARNING) {
$this->Base->_retMsg('No playlists have been locked by you.');
}
return FALSE; return FALSE;
} }
$plgunid = $this->Base->gb->revertEditedPlaylist($this->token, $this->Base->sessid); $plgunid = $this->Base->gb->revertEditedPlaylist($this->token, $this->Base->sessid);
if (PEAR::isError($plgunid)) { if (PEAR::isError($plgunid)) {
if (UI_VERBOSE === TRUE) print_r($plgunid); if (UI_VERBOSE === TRUE) {
if (UI_WARNING) $this->Base->_retMsg('Unable to revert to locked state.'); print_r($plgunid);
}
if (UI_WARNING) {
$this->Base->_retMsg('Unable to revert to locked state.');
}
return FALSE; return FALSE;
} }
if (UI_VERBOSE) $this->Base->_retMsg('Playlist "$1" reverted.', $this->Base->_getMDataValue($this->Base->gb->_idFromGunid($plgunid), UI_MDATA_KEY_TITLE)); if (UI_VERBOSE) {
$this->Base->_retMsg('Playlist "$1" reverted.', $this->Base->_getMDataValue($this->Base->gb->_idFromGunid($plgunid), UI_MDATA_KEY_TITLE));
}
$this->activeId = NULL; $this->activeId = NULL;
$this->token = NULL; $this->token = NULL;
$this->Base->gb->delPref($this->Base->sessid, UI_PL_ACCESSTOKEN_KEY); $this->Base->gb->delPref($this->Base->sessid, UI_PL_ACCESSTOKEN_KEY);
if ($this->activate($this->Base->gb->_idFromGunid($plgunid), FALSE) !== TRUE) if ($this->activate($this->Base->gb->_idFromGunid($plgunid), FALSE) !== TRUE) {
return FALSE; return FALSE;
}
$this->changed = FALSE; $this->changed = FALSE;
return $this->activeId; return $this->activeId;
} } // fn revert
function reportLookedPL($setMsg=FALSE) function reportLookedPL($setMsg=FALSE)
{ {
if(is_string($this->Base->gb->loadPref($this->Base->sessid, UI_PL_ACCESSTOKEN_KEY))) { if (is_string($this->Base->gb->loadPref($this->Base->sessid, UI_PL_ACCESSTOKEN_KEY))) {
if ($setMsg == TRUE) $this->Base->_retMsg('Found locked playlist.'); if ($setMsg == TRUE) {
$this->Base->_retMsg('Found locked playlist.');
}
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
} } // fn reportLookedPL
function loadLookedFromPref() function loadLookedFromPref()
{ {
$this->changed = TRUE; $this->changed = TRUE;
if(is_string($saved = $this->Base->gb->loadPref($this->Base->sessid, UI_PL_ACCESSTOKEN_KEY))) { if (is_string($saved = $this->Base->gb->loadPref($this->Base->sessid, UI_PL_ACCESSTOKEN_KEY))) {
list ($plid, $token) = explode (':', $saved); list ($plid, $token) = explode (':', $saved);
if (!$this->Base->gb->existsPlaylist($plid, $this->Base->sessid)) { if (!$this->Base->gb->existsPlaylist($plid, $this->Base->sessid)) {
@ -168,23 +223,26 @@ class uiPlaylist
return FALSE; return FALSE;
} }
$this->activeId = $plid; $this->activeId = $plid;
$this->token = $token; $this->token = $token;
$this->Base->redirUrl = UI_BROWSER.'?popup[]=_2PL.simpleManagement&popup[]=_close'; $this->Base->redirUrl = UI_BROWSER.'?popup[]=_2PL.simpleManagement&popup[]=_close';
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
} } // fn loadLookedFromPref
function addItem($elemIds, $duration=null) function addItem($elemIds, $duration=null)
{ {
$this->changed = TRUE; $this->changed = TRUE;
$fadeIn = null; $fadeIn = null;
$fadeOut = null; $fadeOut = null;
$pause = null; $pause = null;
if (!$elemIds) { if (!$elemIds) {
if (UI_WARNING) $this->Base->_retMsg('No item(s) selected.'); if (UI_WARNING) {
$this->Base->_retMsg('No item(s) selected.');
}
return FALSE; return FALSE;
} }
if (!is_array($elemIds)) { if (!is_array($elemIds)) {
@ -196,20 +254,25 @@ class uiPlaylist
foreach ($elemIds as $elemId) { foreach ($elemIds as $elemId) {
$r = $this->Base->gb->addAudioClipToPlaylist($this->token, $elemId, $this->Base->sessid, $fadeIn, $fadeOut, $length, $pause); $r = $this->Base->gb->addAudioClipToPlaylist($this->token, $elemId, $this->Base->sessid, $fadeIn, $fadeOut, $length, $pause);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
if (UI_VERBOSE === TRUE) print_r($r); if (UI_VERBOSE === TRUE) {
print_r($r);
}
$this->Base->_retMsg('Error while trying to add item to playlist.'); $this->Base->_retMsg('Error while trying to add item to playlist.');
return FALSE; return FALSE;
} }
} }
return TRUE; return TRUE;
} } // fn addItem
function removeItem($elemIds) function removeItem($elemIds)
{ {
$this->changed = TRUE; $this->changed = TRUE;
if (!$elemIds) { if (!$elemIds) {
if (UI_WARNING) $this->Base->_retMsg('No item(s) selected.'); if (UI_WARNING) {
$this->Base->_retMsg('No item(s) selected.');
}
return FALSE; return FALSE;
} }
if (!is_array($elemIds)) if (!is_array($elemIds))
@ -222,7 +285,8 @@ class uiPlaylist
} }
} }
return TRUE; return TRUE;
} } // fn removeItem
function create($ids) function create($ids)
{ {
@ -256,7 +320,7 @@ class uiPlaylist
#$this->redirUrl = UI_BRWOSER.'?popup=_2PL.simpleManagement';<br> #$this->redirUrl = UI_BRWOSER.'?popup=_2PL.simpleManagement';<br>
return $plid; return $plid;
} } // fn create
function getFlat($id) function getFlat($id)
@ -275,7 +339,7 @@ class uiPlaylist
} else { } else {
return array(); return array();
} }
} } // fn getFlat
function _plwalk($arr, $parent=0, $attrs=0) function _plwalk($arr, $parent=0, $attrs=0)
@ -298,7 +362,7 @@ class uiPlaylist
$this->flat[$parent]['fadeout_ms'] = $sub['attrs'][UI_PL_ELEM_FADEOUT] ? GreenBox::_plTimeToSecs($sub['attrs'][UI_PL_ELEM_FADEOUT]) * 1000 : 0; $this->flat[$parent]['fadeout_ms'] = $sub['attrs'][UI_PL_ELEM_FADEOUT] ? GreenBox::_plTimeToSecs($sub['attrs'][UI_PL_ELEM_FADEOUT]) * 1000 : 0;
} }
} }
} } // fn _plwalk
function changeTransition($id, $type, $duration) function changeTransition($id, $type, $duration)
@ -348,7 +412,9 @@ class uiPlaylist
$r = $this->Base->gb->changeFadeInfo($this->token, $i, $val[UI_PL_ELEM_FADEIN], $val[UI_PL_ELEM_FADEOUT], $this->Base->sessid); $r = $this->Base->gb->changeFadeInfo($this->token, $i, $val[UI_PL_ELEM_FADEIN], $val[UI_PL_ELEM_FADEOUT], $this->Base->sessid);
#print_r($r); #print_r($r);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
if (UI_VERBOSE === TRUE) print_r($r); if (UI_VERBOSE === TRUE) {
print_r($r);
}
$this->Base->_retMsg('Changing fade information failed.'); $this->Base->_retMsg('Changing fade information failed.');
return FALSE; return FALSE;
} }
@ -359,14 +425,16 @@ class uiPlaylist
$r = $this->Base->gb->changeFadeInfo($this->token, $v['attrs']['id'], $type==='pause'?$pause:$xfade, $type==='pause'?$pause:$xfade, $this->Base->sessid); $r = $this->Base->gb->changeFadeInfo($this->token, $v['attrs']['id'], $type==='pause'?$pause:$xfade, $type==='pause'?$pause:$xfade, $this->Base->sessid);
#print_r($r); #print_r($r);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
if (UI_VERBOSE === TRUE) print_r($r); if (UI_VERBOSE === TRUE) {
print_r($r);
}
$this->Base->_retMsg('Changing fade information failed.'); $this->Base->_retMsg('Changing fade information failed.');
return FALSE; return FALSE;
} }
} }
} }
return TRUE; return TRUE;
} } // fn changeTransition
function moveItem($id, $pos) function moveItem($id, $pos)
@ -375,31 +443,37 @@ class uiPlaylist
$r = $this->Base->gb->moveAudioClipInPlaylist($this->token, $id, $pos, $this->Base->sessid); $r = $this->Base->gb->moveAudioClipInPlaylist($this->token, $id, $pos, $this->Base->sessid);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
if (UI_VERBOSE === TRUE) print_r($r); if (UI_VERBOSE === TRUE) {
print_r($r);
}
$this->Base->_retMsg('Cannot move item.'); $this->Base->_retMsg('Cannot move item.');
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
} } // fn moveItem
function reOrder($items) function reOrder($items)
{ {
$this->changed = TRUE; $this->changed = TRUE;
asort($items); # just to be sure items are in right order // just to be sure items are in right order
asort($items);
$pos = 0; $pos = 0;
foreach($items as $id=>$v) { foreach ($items as $id => $v) {
$pos++; $pos++;
$r = $this->Base->gb->moveAudioClipInPlaylist($this->token, $id, $pos, $this->Base->sessid); $r = $this->Base->gb->moveAudioClipInPlaylist($this->token, $id, $pos, $this->Base->sessid);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
if (UI_VERBOSE === TRUE) print_r($r); if (UI_VERBOSE === TRUE) {
print_r($r);
}
$this->Base->_retMsg('Cannot move item.'); $this->Base->_retMsg('Cannot move item.');
return FALSE; return FALSE;
} }
} }
return TRUE; return TRUE;
} } // fn reorder
function getCurrElement($id) function getCurrElement($id)
{ {
@ -410,7 +484,7 @@ class uiPlaylist
} }
next($arr); next($arr);
} }
} } // fn getCurrElement
function getPrevElement($id) function getPrevElement($id)
@ -422,7 +496,7 @@ class uiPlaylist
} }
next($arr); next($arr);
} }
} } // fn getPrevElement
function getNextElement($id) function getNextElement($id)
@ -434,7 +508,7 @@ class uiPlaylist
} }
next($arr); next($arr);
} }
} } // fn getNextElement
function changeTransitionForm($id, $type, $mask) function changeTransitionForm($id, $type, $mask)
@ -466,7 +540,7 @@ class uiPlaylist
$renderer =& new HTML_QuickForm_Renderer_Array(true, true); $renderer =& new HTML_QuickForm_Renderer_Array(true, true);
$form->accept($renderer); $form->accept($renderer);
return $renderer->toArray(); return $renderer->toArray();
} } // fn changeTransitionForm
function changeAllTransitionsForm($mask) function changeAllTransitionsForm($mask)
@ -477,7 +551,8 @@ class uiPlaylist
$renderer =& new HTML_QuickForm_Renderer_Array(true, true); $renderer =& new HTML_QuickForm_Renderer_Array(true, true);
$form->accept($renderer); $form->accept($renderer);
return $renderer->toArray(); return $renderer->toArray();
} } // fn changeAllTransitionsForm
function setItemPlaylengthForm($id, $elemId, $mask) function setItemPlaylengthForm($id, $elemId, $mask)
{ {
@ -499,7 +574,7 @@ class uiPlaylist
$renderer =& new HTML_QuickForm_Renderer_Array(true, true); $renderer =& new HTML_QuickForm_Renderer_Array(true, true);
$form->accept($renderer); $form->accept($renderer);
return $renderer->toArray(); return $renderer->toArray();
} } // fn setItemPlaylengthForm
function metaDataForm($langid) function metaDataForm($langid)
@ -537,73 +612,87 @@ class uiPlaylist
#print_r($output); #print_r($output);
return $output; return $output;
} } // fn metadataForm
function editMetaData($formdata) function editMetaData($formdata)
{ {
$this->changed = TRUE; $this->changed = TRUE;
include dirname(__FILE__).'/formmask/metadata.inc.php'; include(dirname(__FILE__).'/formmask/metadata.inc.php');
$id = $this->activeId; $id = $this->activeId;
$curr_langid = $formdata['curr_langid']; $curr_langid = $formdata['curr_langid'];
## if language switched stay on metadataform ## ## if language switched stay on metadataform ##
if ($curr_langid === $formdata['target_langid']) if ($curr_langid === $formdata['target_langid']) {
$this->Base->redirUrl = UI_BROWSER."?act=PL.simpleManagement"; $this->Base->redirUrl = UI_BROWSER."?act=PL.simpleManagement";
else } else {
$this->Base->redirUrl = UI_BROWSER."?act=PL.editMetaData&id=$id&curr_langid=".$formdata['target_langid']; $this->Base->redirUrl = UI_BROWSER."?act=PL.editMetaData&id=$id&curr_langid=".$formdata['target_langid'];
}
foreach ($mask['playlist'] as $k=>$v) { foreach ($mask['playlist'] as $k=>$v) {
$formdata[$this->Base->_formElementEncode($v['element'])] ? $mData[$this->Base->_formElementDecode($v['element'])] = $formdata[$this->Base->_formElementEncode($v['element'])] : NULL; $formdata[$this->Base->_formElementEncode($v['element'])] ? $mData[$this->Base->_formElementDecode($v['element'])] = $formdata[$this->Base->_formElementEncode($v['element'])] : NULL;
} }
if (!count($mData)) return; if (!count($mData)) {
return;
}
foreach ($mData as $key=>$val) { foreach ($mData as $key => $val) {
$r = $this->Base->gb->setMDataValue($id, $key, $this->Base->sessid, $val, $curr_langid); $r = $this->Base->gb->setMDataValue($id, $key, $this->Base->sessid, $val, $curr_langid);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
if (UI_VERBOSE === TRUE) print_r($r); if (UI_VERBOSE === TRUE) {
print_r($r);
}
$this->Base->_retMsg('Unable to set "$1" to value "$2".', $key, $val); $this->Base->_retMsg('Unable to set "$1" to value "$2".', $key, $val);
} }
} }
if (UI_VERBOSE) $this->Base->_retMsg('Metadata saved.'); if (UI_VERBOSE) {
} $this->Base->_retMsg('Metadata saved.');
}
} // fn editMetadata
function deleteActive() function deleteActive()
{ {
$id = $this->activeId; $id = $this->activeId;
$this->release(FALSE); $this->release(FALSE);
if ($this->Base->delete($id)) if ($this->Base->delete($id)) {
return $id; return $id;
}
$this->Base->_retMsg('Cannot delete this playlist.'); $this->Base->_retMsg('Cannot delete this playlist.');
return FALSE; return FALSE;
} } // fn deleteActive
function isAvailable($id) function isAvailable($id)
{ {
if ($this->Base->gb->getFileType($id) !== UI_FILETYPE_PLAYLIST) if ($this->Base->gb->getFileType($id) !== UI_FILETYPE_PLAYLIST) {
return TRUE; return TRUE;
}
if ($this->Base->gb->playlistIsAvailable($id, $this->Base->sessid) === TRUE) if ($this->Base->gb->playlistIsAvailable($id, $this->Base->sessid) === TRUE) {
return TRUE; return TRUE;
}
return FALSE; return FALSE;
} } // fn isAvailable
function isUsedBy($id) function isUsedBy($id)
{ {
if ($this->Base->gb->getFileType($id) !== UI_FILETYPE_PLAYLIST) if ($this->Base->gb->getFileType($id) !== UI_FILETYPE_PLAYLIST) {
return FALSE; return FALSE;
}
if (($userid = $this->Base->gb->playlistIsAvailable($id, $this->Base->sessid)) !== TRUE) if (($userid = $this->Base->gb->playlistIsAvailable($id, $this->Base->sessid)) !== TRUE) {
return $this->Base->gb->getSubjName($userid); return $this->Base->gb->getSubjName($userid);
}
return FALSE; return FALSE;
} } // fn isUsedBy
function exportForm($id,$mask) function exportForm($id,$mask)
{ {
@ -614,7 +703,8 @@ class uiPlaylist
$renderer =& new HTML_QuickForm_Renderer_Array(true, true); $renderer =& new HTML_QuickForm_Renderer_Array(true, true);
$form->accept($renderer); $form->accept($renderer);
return $renderer->toArray(); return $renderer->toArray();
} } // fn exportForm
function importForm($id, $mask) function importForm($id, $mask)
{ {
@ -624,6 +714,7 @@ class uiPlaylist
$renderer =& new HTML_QuickForm_Renderer_Array(true, true); $renderer =& new HTML_QuickForm_Renderer_Array(true, true);
$form->accept($renderer); $form->accept($renderer);
return $renderer->toArray(); return $renderer->toArray();
} } // fn importForm
}
} // class uiPlaylist
?> ?>

View file

@ -1,6 +1,10 @@
<?php <?php
class uiScheduler extends uiCalendar /**
{ * @package Campcaster
* @subpackage htmlUI
* @version $Revision$
*/
class uiScheduler extends uiCalendar {
var $curr; var $curr;
var $scheduleAtTime; var $scheduleAtTime;
var $schedulePrev; var $schedulePrev;
@ -11,6 +15,7 @@ class uiScheduler extends uiCalendar
var $closeUrl; var $closeUrl;
var $firstDayOfWeek; var $firstDayOfWeek;
function uiScheduler(&$uiBase) function uiScheduler(&$uiBase)
{ {
$this->curr =& $_SESSION[UI_CALENDAR_SESSNAME]['current']; $this->curr =& $_SESSION[UI_CALENDAR_SESSNAME]['current'];
@ -168,12 +173,12 @@ class uiScheduler extends uiCalendar
$stampTarget = strtotime("-1 day", $stampNow); $stampTarget = strtotime("-1 day", $stampNow);
} }
$this->curr['year'] = strftime("%Y", $stampTarget); $this->curr['year'] = strftime("%Y", $stampTarget);
$this->curr['month'] = strftime("%m", $stampTarget); $this->curr['month'] = strftime("%m", $stampTarget);
$this->curr['week'] = strftime("%V", $stampTarget); $this->curr['week'] = strftime("%V", $stampTarget);
$this->curr['day'] = strftime("%d", $stampTarget); $this->curr['day'] = strftime("%d", $stampTarget);
$this->curr['hour'] = strftime("%H", $stampTarget); $this->curr['hour'] = strftime("%H", $stampTarget);
$this->curr['dayname'] = strftime("%A", $stampTarget); $this->curr['dayname'] = strftime("%A", $stampTarget);
$this->curr['monthname'] = strftime("%B", $stampTarget); $this->curr['monthname'] = strftime("%B", $stampTarget);
if ($this->curr['year'] === strftime("%Y") && $this->curr['month'] === strftime("%m") && $this->curr['day'] === strftime("%d")) { if ($this->curr['year'] === strftime("%Y") && $this->curr['month'] === strftime("%m") && $this->curr['day'] === strftime("%d")) {
@ -181,7 +186,7 @@ class uiScheduler extends uiCalendar
} else { } else {
$this->curr['isToday'] = FALSE; $this->curr['isToday'] = FALSE;
} }
#print_r($this->curr); //print_r($this->curr);
} // fn set } // fn set
@ -198,17 +203,17 @@ class uiScheduler extends uiCalendar
{ {
extract($arr); extract($arr);
$this->schedulePrev['hour'] = 0; $this->schedulePrev['hour'] = 0;
$this->schedulePrev['minute'] = 0; $this->schedulePrev['minute'] = 0;
$this->schedulePrev['second'] = 0; $this->schedulePrev['second'] = 0;
#$thisDay = $this->scheduleAtTime['year']."-".$this->scheduleAtTime['month']."-".$this->scheduleAtTime['day']; //$thisDay = $this->scheduleAtTime['year']."-".$this->scheduleAtTime['month']."-".$this->scheduleAtTime['day'];
#$nextDayStamp = strtotime('+1 day', strtotime($thisDay)); //$nextDayStamp = strtotime('+1 day', strtotime($thisDay));
#$this->scheduleNext['year'] = strftime('%Y', $nextDayStamp); //$this->scheduleNext['year'] = strftime('%Y', $nextDayStamp);
#$this->scheduleNext['month'] = strftime('%m', $nextDayStamp);; //$this->scheduleNext['month'] = strftime('%m', $nextDayStamp);;
#$this->scheduleNext['day'] = strftime('%d', $nextDayStamp); //$this->scheduleNext['day'] = strftime('%d', $nextDayStamp);
$this->scheduleNext['hour'] = 23; $this->scheduleNext['hour'] = 23;
$this->scheduleNext['minute'] = 59; $this->scheduleNext['minute'] = 59;
$this->scheduleNext['second'] = 59; $this->scheduleNext['second'] = 59;
if (isset($today)) { if (isset($today)) {
list($year, $month, $day) = explode("-", strftime("%Y-%m-%d")); list($year, $month, $day) = explode("-", strftime("%Y-%m-%d"));
@ -237,7 +242,7 @@ class uiScheduler extends uiCalendar
if (is_array($week = $this->getWeekEntrys())) { if (is_array($week = $this->getWeekEntrys())) {
## search for previous entry // search for previous entry
if (count($week[$this->scheduleAtTime['day']]) >= 1) { if (count($week[$this->scheduleAtTime['day']]) >= 1) {
foreach (array_reverse($week[$this->scheduleAtTime['day']]) as $hourly) { foreach (array_reverse($week[$this->scheduleAtTime['day']]) as $hourly) {
foreach (array_reverse($hourly) as $entry) { foreach (array_reverse($hourly) as $entry) {
@ -253,7 +258,7 @@ class uiScheduler extends uiCalendar
reset($week); reset($week);
## search for next entry // search for next entry
if (count($week[$this->scheduleAtTime['day']]) >= 1) { if (count($week[$this->scheduleAtTime['day']]) >= 1) {
foreach ($week[$this->scheduleAtTime['day']] as $hourly) { foreach ($week[$this->scheduleAtTime['day']] as $hourly) {
foreach ($hourly as $entry) { foreach ($hourly as $entry) {
@ -267,19 +272,19 @@ class uiScheduler extends uiCalendar
} }
} }
#print_r($this->schedulePrev); //print_r($this->schedulePrev);
#print_r($this->scheduleNext); //print_r($this->scheduleNext);
} // fn setScheduleAtTime } // fn setScheduleAtTime
function getWeekEntrys() function getWeekEntrys()
{ {
## build array within all entrys of current week ## // build array within all entrys of current week ##
$this->buildWeek(); $this->buildWeek();
$thisWeekStart = strftime("%Y%m%d", $this->Week[0]['timestamp']); $thisWeekStart = strftime("%Y%m%d", $this->Week[0]['timestamp']);
$nextWeekStart = strftime("%Y%m%d", $this->Week[6]['timestamp'] + 86400); $nextWeekStart = strftime("%Y%m%d", $this->Week[6]['timestamp'] + 86400);
$arr = $this->displayScheduleMethod($thisWeekStart.'T00:00:00', $nextWeekStart.'T00:00:00'); $arr = $this->displayScheduleMethod($thisWeekStart.'T00:00:00', $nextWeekStart.'T00:00:00');
#print_r($arr); //print_r($arr);
if (!is_array($arr)) { if (!is_array($arr)) {
return FALSE; return FALSE;
@ -299,19 +304,19 @@ class uiScheduler extends uiCalendar
); );
} }
#print_r($items); //print_r($items);
return $items; return $items;
} // fn getWeekEntrys } // fn getWeekEntrys
function getDayEntrys() function getDayEntrys()
{ {
## build array within all entrys of current day ## // build array within all entrys of current day ##
$this->buildDay(); $this->buildDay();
$thisDay = strftime("%Y%m%d", $this->Day[0]['timestamp']); $thisDay = strftime("%Y%m%d", $this->Day[0]['timestamp']);
$nextDay = strftime("%Y%m%d", $this->Day[0]['timestamp'] + 86400); $nextDay = strftime("%Y%m%d", $this->Day[0]['timestamp'] + 86400);
$arr = $this->displayScheduleMethod($thisDay.'T00:00:00', $nextDay.'T00:00:00'); $arr = $this->displayScheduleMethod($thisDay.'T00:00:00', $nextDay.'T00:00:00');
#print_r($arr); //print_r($arr);
if (!is_array($arr)) { if (!is_array($arr)) {
return FALSE; return FALSE;
@ -326,7 +331,7 @@ class uiScheduler extends uiCalendar
$h = number_format(strftime('%H', $start)); $h = number_format(strftime('%H', $start));
$M = number_format(strftime('%i', $start)); $M = number_format(strftime('%i', $start));
## item starts today // item starts today
if (strftime('%Y%m%d', $start) === $thisDay) { if (strftime('%Y%m%d', $start) === $thisDay) {
$items[number_format(strftime('%H', $start))]['start'][] = array( $items[number_format(strftime('%H', $start))]['start'][] = array(
'id' => $this->Base->gb->_idFromGunid($val['playlistId']), 'id' => $this->Base->gb->_idFromGunid($val['playlistId']),
@ -347,7 +352,7 @@ class uiScheduler extends uiCalendar
} }
*/ */
## item ends today // item ends today
if (strftime('%Y%m%d', $end) === $thisDay && strftime('%H', $start) !== strftime('%H', $end)) { if (strftime('%Y%m%d', $end) === $thisDay && strftime('%H', $start) !== strftime('%H', $end)) {
$items[number_format(strftime('%H', $end))]['end'][] = $items[number_format(strftime('%H', $end))]['end'][] =
array( array(
@ -363,7 +368,7 @@ class uiScheduler extends uiCalendar
} }
} }
#print_r($items); //print_r($items);
return $items; return $items;
} // fn getDayEntrys } // fn getDayEntrys
@ -397,13 +402,13 @@ class uiScheduler extends uiCalendar
return FALSE; return FALSE;
} }
foreach ($arr as $key=>$val) { foreach ($arr as $key => $val) {
$arr[$key]['title'] = $this->Base->_getMDataValue($this->Base->gb->_idFromGunid($val['playlistId']), UI_MDATA_KEY_TITLE); $arr[$key]['title'] = $this->Base->_getMDataValue($this->Base->gb->_idFromGunid($val['playlistId']), UI_MDATA_KEY_TITLE);
$arr[$key]['creator'] = $this->Base->_getMDataValue($this->Base->gb->_idFromGunid($val['playlistId']), UI_MDATA_KEY_CREATOR); $arr[$key]['creator'] = $this->Base->_getMDataValue($this->Base->gb->_idFromGunid($val['playlistId']), UI_MDATA_KEY_CREATOR);
$arr[$key]['pos'] = $this->_datetime2timestamp($val['start']); $arr[$key]['pos'] = $this->_datetime2timestamp($val['start']);
$arr[$key]['span'] = date('H', $this->_datetime2timestamp($val['end'])) - date('H', $this->_datetime2timestamp($val['start'])) +1; $arr[$key]['span'] = date('H', $this->_datetime2timestamp($val['end'])) - date('H', $this->_datetime2timestamp($val['start'])) +1;
} }
#print_r($arr); //print_r($arr);
return $arr; return $arr;
} // fn getDayUsage } // fn getDayUsage
@ -434,11 +439,11 @@ class uiScheduler extends uiCalendar
function getScheduleForm() function getScheduleForm()
{ {
global $ui_fmask; global $ui_fmask;
#print_r($this->availablePlaylists); //print_r($this->availablePlaylists);
foreach ($this->availablePlaylists as $val) { foreach ($this->availablePlaylists as $val) {
$ui_fmask['schedule']['gunid_duration']['options'][$val['gunid'].'|'.$val['duration']] = $val['title']; $ui_fmask['schedule']['gunid_duration']['options'][$val['gunid'].'|'.$val['duration']] = $val['title'];
} }
#print_r($ui_fmask['schedule']); //print_r($ui_fmask['schedule']);
$form = new HTML_QuickForm('schedule', UI_STANDARD_FORM_METHOD, UI_HANDLER); $form = new HTML_QuickForm('schedule', UI_STANDARD_FORM_METHOD, UI_HANDLER);
$this->Base->_parseArr2Form($form, $ui_fmask['schedule']); $this->Base->_parseArr2Form($form, $ui_fmask['schedule']);
@ -457,7 +462,7 @@ class uiScheduler extends uiCalendar
$renderer =& new HTML_QuickForm_Renderer_Array(true, true); $renderer =& new HTML_QuickForm_Renderer_Array(true, true);
$form->accept($renderer); $form->accept($renderer);
$output = $renderer->toArray(); $output = $renderer->toArray();
#print_r($output); //print_r($output);
return $output; return $output;
} // fn getScheduleForm } // fn getScheduleForm
@ -495,7 +500,7 @@ class uiScheduler extends uiCalendar
function getNowNextClip($distance=0) function getNowNextClip($distance=0)
{ {
## just use methods which work without valid authentification // just use methods which work without valid authentification
$datetime = strftime('%Y-%m-%dT%H:%M:%S'); $datetime = strftime('%Y-%m-%dT%H:%M:%S');
$xmldatetime = str_replace('-', '', $datetime); $xmldatetime = str_replace('-', '', $datetime);
@ -506,7 +511,8 @@ class uiScheduler extends uiCalendar
} }
$pl = current($pl); $pl = current($pl);
$offset = strftime('%H:%M:%S', time() - $this->_datetime2timestamp($pl['start']) - 3600 * strftime('%H', 0)); ## subtract difference to UTC // subtract difference to UTC
$offset = strftime('%H:%M:%S', time() - $this->_datetime2timestamp($pl['start']) - 3600 * strftime('%H', 0));
$clip = $this->Base->gb->displayPlaylistClipAtOffset($this->Base->sessid, $pl['playlistId'], $offset, $distance, $_SESSION['langid'], UI_DEFAULT_LANGID); $clip = $this->Base->gb->displayPlaylistClipAtOffset($this->Base->sessid, $pl['playlistId'], $offset, $distance, $_SESSION['langid'], UI_DEFAULT_LANGID);
@ -535,7 +541,7 @@ class uiScheduler extends uiCalendar
function getNowNextClip4jscom() function getNowNextClip4jscom()
{ {
## just use methods which work without valid authentification // just use methods which work without valid authentification
if ($curr = $this->getNowNextClip()) { if ($curr = $this->getNowNextClip()) {
$next = $this->getNowNextClip(1); $next = $this->getNowNextClip(1);
@ -563,7 +569,7 @@ class uiScheduler extends uiCalendar
{ {
$i = str_replace('T', ' ', $i); $i = str_replace('T', ' ', $i);
$formatted = $i[0].$i[1].$i[2].$i[3].'-'.$i[4].$i[5].'-'.$i[6].$i[7].strrchr($i, ' '); $formatted = $i[0].$i[1].$i[2].$i[3].'-'.$i[4].$i[5].'-'.$i[6].$i[7].strrchr($i, ' ');
#echo "input: $i formatted:".$formatted; //echo "input: $i formatted:".$formatted;
return $this->_strtotime($formatted); return $this->_strtotime($formatted);
} // fn _datetime2timestamp } // fn _datetime2timestamp
@ -691,15 +697,15 @@ class uiScheduler extends uiCalendar
function uploadPlaylistMethod(&$formdata) function uploadPlaylistMethod(&$formdata)
{ {
#$gunid = $formdata['gunid']; //$gunid = $formdata['gunid'];
#$datetime = $this->curr['year'].$this->curr['month'].$this->curr['day'].'T'.$formdata['time']; //$datetime = $this->curr['year'].$this->curr['month'].$this->curr['day'].'T'.$formdata['time'];
$gunid = $formdata['playlist']; $gunid = $formdata['playlist'];
$datetime = $formdata['date']['Y'].sprintf('%02d', $formdata['date']['m']).sprintf('%02d', $formdata['date']['d']).'T'.sprintf('%02d', $formdata['time']['H']).':'.sprintf('%02d', $formdata['time']['i']).':'.sprintf('%02d', $formdata['time']['s']); $datetime = $formdata['date']['Y'].sprintf('%02d', $formdata['date']['m']).sprintf('%02d', $formdata['date']['d']).'T'.sprintf('%02d', $formdata['time']['H']).':'.sprintf('%02d', $formdata['time']['i']).':'.sprintf('%02d', $formdata['time']['s']);
#echo "Schedule Gunid: $gunid At: ".$datetime; //echo "Schedule Gunid: $gunid At: ".$datetime;
$r = $this->spc->UploadPlaylistMethod($this->Base->sessid, $gunid, $datetime); $r = $this->spc->UploadPlaylistMethod($this->Base->sessid, $gunid, $datetime);
#print_r($r); //print_r($r);
if ($this->_isError($r)) { if ($this->_isError($r)) {
return FALSE; return FALSE;
} }
@ -711,9 +717,9 @@ class uiScheduler extends uiCalendar
function removeFromScheduleMethod($id) function removeFromScheduleMethod($id)
{ {
#echo "Unschedule Gunid: $gunid"; //echo "Unschedule Gunid: $gunid";
$r = $this->spc->removeFromScheduleMethod($this->Base->sessid, $id); $r = $this->spc->removeFromScheduleMethod($this->Base->sessid, $id);
#print_r($r); //print_r($r);
if ($this->_isError($r)) { if ($this->_isError($r)) {
return FALSE; return FALSE;
} }
@ -725,7 +731,7 @@ class uiScheduler extends uiCalendar
function displayScheduleMethod($from, $to) function displayScheduleMethod($from, $to)
{ {
#echo $from.$to; //echo $from.$to;
$r = $this->spc->displayScheduleMethod($this->Base->sessid, $from, $to); $r = $this->spc->displayScheduleMethod($this->Base->sessid, $from, $to);
if ($this->_isError($r)) { if ($this->_isError($r)) {
return FALSE; return FALSE;

View file

@ -1,33 +1,4 @@
<?php <?php
/*------------------------------------------------------------------------------
Copyright (c) 2004 Media Development Loan Fund
This file is part of the Campcaster project.
http://campcaster.campware.org/
To report bugs, send an e-mail to bugs@campware.org
Campcaster is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Campcaster is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Campcaster; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author$
Version : $Revision$
Location : $URL$
------------------------------------------------------------------------------*/
/* ================================================================= includes */ /* ================================================================= includes */
#require_once 'DB.php'; #require_once 'DB.php';
#require_once "XML/RPC.php"; #require_once "XML/RPC.php";
@ -45,6 +16,11 @@
* <li>r</li> array of result element names (not used there at present) * <li>r</li> array of result element names (not used there at present)
* <li>e</li> array of error codes/messages (not used there at present) * <li>e</li> array of error codes/messages (not used there at present)
* </ul> * </ul>
*
* @package Campcaster
* @subpackage htmlUI
* @author $Author$
* @version $Revision$
*/ */
$mdefs = array( $mdefs = array(
"listMethods" => array('m'=>"system.listMethods", 'p'=>NULL, 't'=>NULL), "listMethods" => array('m'=>"system.listMethods", 'p'=>NULL, 't'=>NULL),
@ -193,7 +169,7 @@ $mdefs = array(
/* ======================================================== class definitions */ /* ======================================================== class definitions */
class SchedulerPhpClient{ class SchedulerPhpClient {
/** /**
* Databases object reference * Databases object reference
*/ */
@ -218,15 +194,19 @@ class SchedulerPhpClient{
* XMLRPC debug flag * XMLRPC debug flag
*/ */
var $debug = 0; var $debug = 0;
/** /**
* Constructor - pelase DON'T CALL IT, use factory method instead * Constructor - please DON'T CALL IT, use factory method instead
* *
* @param dbc object, database object reference * @param DB $dbc
* @param mdefs array, hash array with methods description * @param array $mdefs
* @param config array, hash array with configuration * hash array with methods description
* @param debug int, XMLRPC debug flag * @param array $config
* @param verbose boolean, verbosity flag * hash array with configuration
* @return this * @param int $debug
* XMLRPC debug flag
* @param boolean $verbose
* verbosity flag
*/ */
function SchedulerPhpClient( function SchedulerPhpClient(
&$dbc, $mdefs, $config, $debug=0, $verbose=FALSE) &$dbc, $mdefs, $config, $debug=0, $verbose=FALSE)
@ -237,37 +217,45 @@ class SchedulerPhpClient{
$this->debug = $debug; $this->debug = $debug;
$this->verbose = $verbose; $this->verbose = $verbose;
$confPrefix = "scheduler"; $confPrefix = "scheduler";
# $confPrefix = "storage"; //$confPrefix = "storage";
$serverPath = $serverPath =
"http://{$config["{$confPrefix}UrlHost"]}:{$config["{$confPrefix}UrlPort"]}". "http://{$config["{$confPrefix}UrlHost"]}:{$config["{$confPrefix}UrlPort"]}".
"{$config["{$confPrefix}UrlPath"]}/{$config["{$confPrefix}XMLRPC"]}"; "{$config["{$confPrefix}UrlPath"]}/{$config["{$confPrefix}XMLRPC"]}";
#$serverPath = "http://localhost:80/livesupportStorageServerCVS/xmlrpc/xrLocStor.php"; //$serverPath = "http://localhost:80/campcasterStorageServerCVS/xmlrpc/xrLocStor.php";
if($this->verbose) echo "serverPath: $serverPath\n"; if ($this->verbose) {
echo "serverPath: $serverPath\n";
}
$url = parse_url($serverPath); $url = parse_url($serverPath);
$this->client = new XML_RPC_Client($url['path'], $url['host'], $url['port']); $this->client = new XML_RPC_Client($url['path'], $url['host'], $url['port']);
} } // constructor
/** /**
* Factory, create object instance * Factory, create object instance
* *
* In fact it doesn't create instance of SchedulerPhpClient, but * In fact it doesn't create instance of SchedulerPhpClient, but
* dynamically extend this class with set of methods based on $mdefs array * dynamically extend this class with set of methods based on $mdefs array
* (using eval function) and instantiate resulting class * (using eval function) and instantiate resulting class
* SchedulerPhpClientCore instead. * SchedulerPhpClientCore instead.
* Each new method in this subclass accepts parameters according to $mdefs * Each new method in this subclass accepts parameters according to $mdefs
* array, call wrapper callMethod(methodname, parameters) and return its * array, call wrapper callMethod(methodname, parameters) and return its
* result. * result.
* *
* @param dbc object, database object reference * @param DB $dbc
* @param mdefs array, hash array with methods description * @param array $mdefs
* @param config array, hash array with configuration * hash array with methods description
* @param debug int, XMLRPC debug flag * @param array $config
* @param verbose boolean, verbosity flag * hash array with configuration
* @return object, created object instance * @param int $debug
* XMLRPC debug flag
* @param boolean $verbose
* verbosity flag
* @return object, created object instance
*/ */
function &factory(&$dbc, $mdefs, $config, $debug=0, $verbose=FALSE){ function &factory(&$dbc, $mdefs, $config, $debug=0, $verbose=FALSE)
{
$f = ''; $f = '';
foreach($mdefs as $fn=>$farr){ foreach ($mdefs as $fn => $farr) {
$f .= $f .=
' function '.$fn.'(){'."\n". ' function '.$fn.'(){'."\n".
' $pars = func_get_args();'."\n". ' $pars = func_get_args();'."\n".
@ -280,25 +268,31 @@ class SchedulerPhpClient{
"$f\n". "$f\n".
"}\n"; "}\n";
# echo $e; # echo $e;
if(FALSE === eval($e)) return $dbc->raiseError("Eval failed"); if (FALSE === eval($e)) {
return $dbc->raiseError("Eval failed");
}
$spc =& new SchedulerPhpClientCore( $spc =& new SchedulerPhpClientCore(
$dbc, $mdefs, $config, $debug, $verbose); $dbc, $mdefs, $config, $debug, $verbose);
return $spc; return $spc;
} } // fn factory
/** /**
* XMLRPC methods wrapper * XMLRPC methods wrapper
* Encode XMLRPC request message, send it, receive and decode response. * Encode XMLRPC request message, send it, receive and decode response.
* *
* @param method string, method name * @param string $method
* @param gettedPars array, returned by func_get_args() in called method * method name
* @return array, PHP hash with response * @param array $gettedPars
* returned by func_get_args() in called method
* @return array
* PHP hash with response
*/ */
function callMethod($method, $gettedPars) function callMethod($method, $gettedPars)
{ {
$parr = array(); $parr = array();
$XML_RPC_val = new XML_RPC_Value; $XML_RPC_val = new XML_RPC_Value;
foreach($this->mdefs[$method]['p'] as $i=>$p){ foreach ($this->mdefs[$method]['p'] as $i => $p) {
$parr[$p] = new XML_RPC_Value; $parr[$p] = new XML_RPC_Value;
switch ($this->mdefs[$method]['t'][$i]) { // switch ($parr[$p]->kindOf($gettedPars[$i])) { switch ($this->mdefs[$method]['t'][$i]) { // switch ($parr[$p]->kindOf($gettedPars[$i])) {
/* array type: normal array */ /* array type: normal array */
@ -317,7 +311,7 @@ class SchedulerPhpClient{
$XML_RPC_val->addStruct($parr); $XML_RPC_val->addStruct($parr);
$fullmethod = $this->mdefs[$method]['m']; $fullmethod = $this->mdefs[$method]['m'];
$msg = new XML_RPC_Message($fullmethod, array($XML_RPC_val)); $msg = new XML_RPC_Message($fullmethod, array($XML_RPC_val));
if($this->verbose){ if ($this->verbose) {
echo "parr:\n"; echo "parr:\n";
var_dump($parr); var_dump($parr);
echo "message:\n"; echo "message:\n";
@ -327,7 +321,7 @@ class SchedulerPhpClient{
if (!$res = $this->client->send($msg)) { if (!$res = $this->client->send($msg)) {
return array('error' => array('code' => -1, 'message' => '##Cannot connect to Scheduler##')); return array('error' => array('code' => -1, 'message' => '##Cannot connect to Scheduler##'));
} }
if($res->faultCode() > 0) { if ($res->faultCode() > 0) {
return array('error' => array('code' => $res->faultCode(), 'message' => $res->faultString())); ## changed by sebastian return array('error' => array('code' => $res->faultCode(), 'message' => $res->faultString())); ## changed by sebastian
/* /*
tomas<EFBFBD> orig. method tomas<EFBFBD> orig. method
@ -344,7 +338,7 @@ class SchedulerPhpClient{
); );
*/ */
} }
if($this->verbose){ if ($this->verbose) {
echo "result:\n"; echo "result:\n";
echo $res->serialize(); echo $res->serialize();
} }
@ -352,9 +346,9 @@ class SchedulerPhpClient{
# echo"<pre>\n"; var_dump($val); exit; # echo"<pre>\n"; var_dump($val); exit;
$resp = XML_RPC_decode($res->value()); $resp = XML_RPC_decode($res->value());
return $resp; return $resp;
} } // fn callMethod
} } // class SchedulerPhpClient
/* ======================================================== class definitions */ /* ======================================================== class definitions */
?> ?>

View file

@ -1,6 +1,16 @@
<?php <?php
/**
* @package Campcaster
* @subpackage htmlUI
* @version $Revision$
*/
class uiScratchPad class uiScratchPad
{ {
var $Base;
var $items;
var $order;
var $reloadUrl;
function uiScratchPad(&$uiBase) function uiScratchPad(&$uiBase)
{ {
$this->Base =& $uiBase; $this->Base =& $uiBase;
@ -9,73 +19,71 @@ class uiScratchPad
$this->reloadUrl = UI_BROWSER.'?popup[]=_reload_parent&popup[]=_close'; $this->reloadUrl = UI_BROWSER.'?popup[]=_reload_parent&popup[]=_close';
} }
function setReload() function setReload()
{ {
$this->Base->redirUrl = $this->reloadUrl; $this->Base->redirUrl = $this->reloadUrl;
} }
function &get() function &get()
{ {
if (!is_array($this->items)) if (!is_array($this->items)) {
$this->_load(); $this->_load();
#print_r($this->items); }
//print_r($this->items);
return $this->items; return $this->items;
} }
function _load() function _load()
{ {
$this->items = array(); $this->items = array();
$spData = $this->Base->gb->loadPref($this->Base->sessid, UI_SCRATCHPAD_KEY); $spData = $this->Base->gb->loadPref($this->Base->sessid, UI_SCRATCHPAD_KEY);
if (!PEAR::isError($spData)) { if (!PEAR::isError($spData)) {
## ScratchPad found in DB // ScratchPad found in DB
$arr = explode(' ', $spData); $arr = explode(' ', $spData);
/*
## Akos old format #####################################
foreach($arr as $val) {
if (preg_match(UI_SCRATCHPAD_REGEX, $val)) {
list ($gunid, $date) = explode(':', $val);
if ($this->Base->gb->_idFromGunid($gunid) != FALSE) {
$res[] = array_merge($this->Base->_getMetaInfo($this->Base->gb->_idFromGunid($gunid)), array('added' => $date));
}
}
}
*/
## new format ########################################## foreach ($arr as $gunid) {
foreach($arr as $gunid) {
if (preg_match('/[0-9]{1,20}/', $gunid)) { if (preg_match('/[0-9]{1,20}/', $gunid)) {
if ($this->Base->gb->_idFromGunid($this->Base->_toHex($gunid)) != FALSE) { if ($this->Base->gb->_idFromGunid($this->Base->_toHex($gunid)) != FALSE) {
if ($i = $this->Base->_getMetaInfo($this->Base->gb->_idFromGunid($this->Base->_toHex($gunid)))) if ($i = $this->Base->_getMetaInfo($this->Base->gb->_idFromGunid($this->Base->_toHex($gunid)))) {
$this->items[] = $i; $this->items[] = $i;
}
} }
} }
} }
} }
} } // fn _load
function save() function save()
{ {
foreach($this->items as $val) { foreach ($this->items as $val) {
#$str .= $val['gunid'].':'.$val['added'].' '; ## new format ### //$str .= $val['gunid'].':'.$val['added'].' '; ## new format ###
$str .= $this->Base->_toInt8($val['gunid']).' '; ## Akos´ old format ### $str .= $this->Base->_toInt8($val['gunid']).' '; ## Akos<EFBFBD> old format ###
} }
$this->Base->gb->savePref($this->Base->sessid, UI_SCRATCHPAD_KEY, $str); $this->Base->gb->savePref($this->Base->sessid, UI_SCRATCHPAD_KEY, $str);
} } // fn save
function addItem($ids) function addItem($ids)
{ {
if(!$this->Base->STATIONPREFS[UI_SCRATCHPAD_MAXLENGTH_KEY]) { if (!$this->Base->STATIONPREFS[UI_SCRATCHPAD_MAXLENGTH_KEY]) {
if (UI_WARNING) $this->Base->_retMsg('The scratchpad length is not set in system preferences, so it cannot be used.'); if (UI_WARNING) {
$this->Base->_retMsg('The scratchpad length is not set in system preferences, so it cannot be used.');
}
return false; return false;
} }
if (!$ids) { if (!$ids) {
if (UI_WARNING) $this->Base->_retMsg('No item(s) selected.'); if (UI_WARNING) {
$this->Base->_retMsg('No item(s) selected.');
}
return FALSE; return FALSE;
} }
if (!is_array($ids)) if (!is_array($ids)) {
$ids = array($ids); $ids = array($ids);
}
$sp = $this->get(); $sp = $this->get();
foreach ($ids as $id) { foreach ($ids as $id) {
@ -84,7 +92,9 @@ class uiScratchPad
foreach ($sp as $key=>$val) { foreach ($sp as $key=>$val) {
if ($val['id'] == $item['id']) { if ($val['id'] == $item['id']) {
unset($sp[$key]); unset($sp[$key]);
if (UI_VERBOSE) $this->Base->_retMsg('Entry $1 is already on the scratchpad. It has been moved to the top of the list.', $item['title'], $val['added']); if (UI_VERBOSE) {
$this->Base->_retMsg('Entry $1 is already on the scratchpad. It has been moved to the top of the list.', $item['title'], $val['added']);
}
} else { } else {
#$this->Base->incAccessCounter($id); #$this->Base->incAccessCounter($id);
} }
@ -92,21 +102,26 @@ class uiScratchPad
$sp = array_merge(array($item), is_array($sp) ? $sp : NULL); $sp = array_merge(array($item), is_array($sp) ? $sp : NULL);
} }
for ($n=0; $n<$this->Base->STATIONPREFS[UI_SCRATCHPAD_MAXLENGTH_KEY]; $n++) { for ($n=0; $n < $this->Base->STATIONPREFS[UI_SCRATCHPAD_MAXLENGTH_KEY]; $n++) {
if (is_array($sp[$n])) $this->items[$n] = $sp[$n]; if (is_array($sp[$n])) {
$this->items[$n] = $sp[$n];
}
} }
ksort($this->items); ksort($this->items);
} } // fn addItem
function removeItems($ids) function removeItems($ids)
{ {
if (!$ids) { if (!$ids) {
if (UI_WARNING) $this->Base->_retMsg('No item(s) selected.'); if (UI_WARNING) {
$this->Base->_retMsg('No item(s) selected.');
}
return FALSE; return FALSE;
} }
if (!is_array($ids)) if (!is_array($ids)) {
$ids = array($ids); $ids = array($ids);
}
foreach ($ids as $id) { foreach ($ids as $id) {
$sp =& $this->get(); $sp =& $this->get();
@ -119,21 +134,26 @@ class uiScratchPad
} }
return TRUE; return TRUE;
} } // fn removeItems
function reOrder($by) function reOrder($by)
{ {
if (count($this->items) == 0) if (count($this->items) == 0) {
return FALSE; return FALSE;
}
foreach ($this->items as $key=>$val) { foreach ($this->items as $key=>$val) {
$s[$key] = $val[$by]; $s[$key] = $val[$by];
} }
$curr = $this->order[$by]; $curr = $this->order[$by];
$this->order = array(); $this->order = array();
(is_null($curr) || $curr=='DESC') ? $this->order[$by] = 'ASC' : $this->order[$by] = 'DESC'; if (is_null($curr) || $curr=='DESC') {
switch($this->order[$by]) { $this->order[$by] = 'ASC';
} else {
$this->order[$by] = 'DESC';
}
switch ($this->order[$by]) {
case "ASC": asort($s); break; case "ASC": asort($s); break;
case "DESC": arsort($s); break; case "DESC": arsort($s); break;
} }
@ -146,8 +166,9 @@ class uiScratchPad
function reLoadM() function reLoadM()
{ {
foreach($this->items as $key=>$val) foreach($this->items as $key=>$val) {
$this->items[$key] = $this->Base->_getMetaInfo($val['id']); $this->items[$key] = $this->Base->_getMetaInfo($val['id']);
}
} }
} } // class uiScratchPad
?> ?>

View file

@ -1,4 +1,9 @@
<?php <?php
/**
* @package Campcaster
* @subpackage htmlUI
* @version $Revision$
*/
class uiSearch class uiSearch
{ {
var $Base; var $Base;
@ -11,7 +16,7 @@ class uiSearch
{ {
$this->Base =& $uiBase; $this->Base =& $uiBase;
$this->prefix = 'SEARCH'; $this->prefix = 'SEARCH';
#$this->results =& $_SESSION[UI_SEARCH_SESSNAME]['results']; //$this->results =& $_SESSION[UI_SEARCH_SESSNAME]['results'];
$this->criteria =& $_SESSION[UI_SEARCH_SESSNAME]['criteria']; $this->criteria =& $_SESSION[UI_SEARCH_SESSNAME]['criteria'];
$this->reloadUrl = UI_BROWSER.'?popup[]=_reload_parent&popup[]=_close'; $this->reloadUrl = UI_BROWSER.'?popup[]=_reload_parent&popup[]=_close';
if (empty($this->criteria['limit'])) { if (empty($this->criteria['limit'])) {
@ -19,25 +24,29 @@ class uiSearch
} }
} }
function setReload() function setReload()
{ {
$this->Base->redirUrl = $this->reloadUrl; $this->Base->redirUrl = $this->reloadUrl;
} }
function getResult() function getResult()
{ {
$this->searchDB(); $this->searchDB();
return $this->results; return $this->results;
} }
function getCriteria() function getCriteria()
{ {
return $this->criteria; return $this->criteria;
} }
function searchForm($id, $mask2) function searchForm($id, $mask2)
{ {
#print_r($this->criteria['form']); //print_r($this->criteria['form']);
include dirname(__FILE__).'/formmask/metadata.inc.php'; include dirname(__FILE__).'/formmask/metadata.inc.php';
$form = new HTML_QuickForm('search', UI_STANDARD_FORM_METHOD, UI_HANDLER); $form = new HTML_QuickForm('search', UI_STANDARD_FORM_METHOD, UI_HANDLER);
$counter = isset($this->criteria['counter']) ? $this->criteria['counter'] : 1; $counter = isset($this->criteria['counter']) ? $this->criteria['counter'] : 1;
@ -99,8 +108,8 @@ class uiSearch
$renderer =& new HTML_QuickForm_Renderer_Array(true, true); $renderer =& new HTML_QuickForm_Renderer_Array(true, true);
$form->accept($renderer); $form->accept($renderer);
$output['dynform'] = $renderer->toArray(); $output['dynform'] = $renderer->toArray();
#print_r($output); //print_r($output);
#echo '<XMP>output:'; print_r($output); echo "</XMP>\n"; //echo '<XMP>output:'; print_r($output); echo "</XMP>\n";
return $output; return $output;
} }
@ -117,7 +126,8 @@ class uiSearch
$this->criteria['limit'] = $formdata['limit']; $this->criteria['limit'] = $formdata['limit'];
$this->criteria['counter'] = 0; $this->criteria['counter'] = 0;
$this->criteria['form']['operator'] = $formdata['operator']; ## $criteria['form'] is used for retransfer to form ## // $criteria['form'] is used for retransfer to form
$this->criteria['form']['operator'] = $formdata['operator'];
$this->criteria['form']['filetype'] = $formdata['filetype']; $this->criteria['form']['filetype'] = $formdata['filetype'];
$this->criteria['form']['limit'] = $formdata['limit']; $this->criteria['form']['limit'] = $formdata['limit'];
@ -128,14 +138,14 @@ class uiSearch
'op' => $val[1], 'op' => $val[1],
'val' => stripslashes($val[2]) 'val' => stripslashes($val[2])
); );
$this->criteria['form'][$key] = array(0 => $val[0], $this->criteria['form'][$key] = array(0 => $val[0],
1 => $val[1], 1 => $val[1],
2 => stripslashes($val[2]) 2 => stripslashes($val[2])
); );
} }
} }
$this->Base->redirUrl = UI_BROWSER.'?act='.$this->prefix; $this->Base->redirUrl = UI_BROWSER.'?act='.$this->prefix;
#$this->searchDB(); //$this->searchDB();
} }
@ -146,7 +156,7 @@ class uiSearch
$renderer =& new HTML_QuickForm_Renderer_Array(true, true); $renderer =& new HTML_QuickForm_Renderer_Array(true, true);
$form->accept($renderer); $form->accept($renderer);
$output = $renderer->toArray(); $output = $renderer->toArray();
#print_r($output); //print_r($output);
return $output; return $output;
} }
@ -164,7 +174,7 @@ class uiSearch
$this->criteria['form']['filetype'] = UI_SIMPLESEARCH_FILETYPE; $this->criteria['form']['filetype'] = UI_SIMPLESEARCH_FILETYPE;
$this->criteria['form']['limit'] = UI_SIMPLESEARCH_LIMIT; $this->criteria['form']['limit'] = UI_SIMPLESEARCH_LIMIT;
for ($n = 1; $n<=UI_SIMPLESEARCH_ROWS; $n++) { for ($n = 1; $n <= UI_SIMPLESEARCH_ROWS; $n++) {
$this->criteria['conditions'][$n] = array('cat' => constant('UI_SIMPLESEARCH_CAT'.$n), $this->criteria['conditions'][$n] = array('cat' => constant('UI_SIMPLESEARCH_CAT'.$n),
'op' => constant('UI_SIMPLESEARCH_OP'.$n), 'op' => constant('UI_SIMPLESEARCH_OP'.$n),
'val' => stripslashes($formdata['criterium']) 'val' => stripslashes($formdata['criterium'])
@ -218,7 +228,7 @@ class uiSearch
## end test ## end test
*/ */
#print_r($this->results); //print_r($this->results);
$this->pagination($results); $this->pagination($results);
return TRUE; return TRUE;
@ -231,8 +241,8 @@ class uiSearch
return FALSE; return FALSE;
} }
$offset = isset($this->criteria['offset']) ? $this->criteria['offset'] : 0; $offset = isset($this->criteria['offset']) ? $this->criteria['offset'] : 0;
$currp = ($offset / $this->criteria['limit']) + 1; # current page $currp = ($offset / $this->criteria['limit']) + 1; // current page
$maxp = ceil($results['cnt'] / $this->criteria['limit']); # maximum page $maxp = ceil($results['cnt'] / $this->criteria['limit']); // maximum page
/* /*
for ($n = 1; $n <= $maxp; $n = $n+$width) { for ($n = 1; $n <= $maxp; $n = $n+$width) {
@ -246,12 +256,12 @@ class uiSearch
$start = $currp; $start = $currp;
if ($start + $maxp > 0) { if ($start + $maxp > 0) {
$deltaLower += $start - $maxp; ## correct lower boarder if page is near end $deltaLower += $start - $maxp; // correct lower boarder if page is near end
} }
for ($n = $start-$deltaLower; $n <= $start+$deltaUpper; $n++) { for ($n = $start-$deltaLower; $n <= $start+$deltaUpper; $n++) {
if ($n <= 0) { if ($n <= 0) {
$deltaUpper++; ## correct upper boarder if page is near zero $deltaUpper++; // correct upper boarder if page is near zero
} elseif ($n <= $maxp) { } elseif ($n <= $maxp) {
$this->results['pagination'][$n] = $n; $this->results['pagination'][$n] = $n;
} }
@ -279,18 +289,19 @@ class uiSearch
} }
$this->criteria['orderby'] = $by; $this->criteria['orderby'] = $by;
$this->setReload(); $this->setReload();
#$this->searchDB(); //$this->searchDB();
} }
function clear() function clear()
{ {
#$this->results = NULL; //$this->results = NULL;
$this->criteria['form'] = NULL; $this->criteria['form'] = NULL;
$this->criteria['counter'] = NULL; $this->criteria['counter'] = NULL;
$this->setReload(); $this->setReload();
} }
function setOffset($page) function setOffset($page)
{ {
$o =& $this->criteria['offset']; $o =& $this->criteria['offset'];
@ -304,7 +315,8 @@ class uiSearch
$o = $l * ($page-1); $o = $l * ($page-1);
} }
$this->setReload(); $this->setReload();
#$this->searchDB(); //$this->searchDB();
} }
}
} // class uiSearch
?> ?>

View file

@ -22,10 +22,12 @@ $Smarty->register_function('niceTime', 'S_niceTime');
// --- Smarty Extensions --- // --- Smarty Extensions ---
/** /**
* Repeat given string. * Repeat given string.
* *
* @param array $param - must have the key values "str" and "count" * @param array $param
* @return string, repeated string * must have the key values "str" and "count"
* @return string
* repeated string
*/ */
function S_str_repeat($param) function S_str_repeat($param)
{ {
@ -37,7 +39,8 @@ function S_str_repeat($param)
/** /**
* Translate given string. * Translate given string.
* *
* @param array $in, array of strings to be outputted translated * @param array $in
* array of strings to be outputted translated
* @return string * @return string
*/ */
function S_tra($in) function S_tra($in)
@ -58,7 +61,7 @@ function S_getHour($param)
if (!isset($time) || !is_string($time)) { if (!isset($time) || !is_string($time)) {
return 0; return 0;
} }
list ($h, $m, $s) = explode (':', $time); list($h, $m, $s) = explode (':', $time);
$curr = mktime($h, $m ,$s); $curr = mktime($h, $m ,$s);
if ($pause) { if ($pause) {
$curr = strtotime(UI_SCHEDULER_PAUSE_PL2PL, $curr); $curr = strtotime(UI_SCHEDULER_PAUSE_PL2PL, $curr);

View file

@ -1,6 +1,17 @@
<?php <?php
/**
* @package Campcaster
* @subpackage htmlUI
* @version $Revision$
*/
class uiSubjects class uiSubjects
{ {
var $Base;
var $reloadUrl;
var $suRedirUrl;
var $redirUrl;
function uiSubjects(&$uiBase) function uiSubjects(&$uiBase)
{ {
$this->Base =& $uiBase; $this->Base =& $uiBase;
@ -9,31 +20,34 @@ class uiSubjects
$this->redirUrl = UI_BROWSER.'?act=SUBJECTS'; $this->redirUrl = UI_BROWSER.'?act=SUBJECTS';
} }
function setReload() function setReload()
{ {
$this->Base->redirUrl = $this->reloadUrl; $this->Base->redirUrl = $this->reloadUrl;
} }
function setSuRedir() function setSuRedir()
{ {
$this->Base->redirUrl = $this->suRedirUrl; $this->Base->redirUrl = $this->suRedirUrl;
} }
function setRedir() function setRedir()
{ {
$this->Base->redirUrl = $this->redirUrl; $this->Base->redirUrl = $this->redirUrl;
} }
/** /**
* getAddSubjectForm * Create a form to add GreenBox subjects (users/groups).
* *
* create a form to add GreenBox subjects (users/groups) * @param unknown $type
* * @return string (html)
* @return string (html)
*/ */
function getAddSubjForm($type) function getAddSubjForm($type)
{ {
include dirname(__FILE__). '/formmask/subjects.inc.php'; include(dirname(__FILE__). '/formmask/subjects.inc.php');
$form = new HTML_QuickForm('addSubject', UI_STANDARD_FORM_METHOD, UI_HANDLER); $form = new HTML_QuickForm('addSubject', UI_STANDARD_FORM_METHOD, UI_HANDLER);
$this->Base->_parseArr2Form($form, $mask[$type]); $this->Base->_parseArr2Form($form, $mask[$type]);
@ -44,11 +58,13 @@ class uiSubjects
/** /**
* addSubj * Create a new user or group (empty password => create group).
* *
* Create new user or group (empty pass => create group) * @param array $request
* * Must have keys -> value:
* @param formdata array('login', 'pass') * login - string
* passwd - string
* @return string
*/ */
function addSubj($request) function addSubj($request)
{ {
@ -82,12 +98,15 @@ class uiSubjects
return TRUE; return TRUE;
} }
/** /**
* removeSubj * Remove an existing user or group.
* *
* Remove existing user or group * @todo Renamed this function to "removeSubject".
* * @param array $request
* @param login string, login name of removed user * must contain the "login" key,
* a string, the login name of removed user
* @return boolean
*/ */
function removeSubj($request) function removeSubj($request)
{ {
@ -107,15 +126,17 @@ class uiSubjects
/** /**
* getChgPasswdForm * Create a form to change user-passwords in GreenBox.
* *
* create a form to change user-passwords in GreenBox * @param string $login
* * @param boolean $su
* @return string (html) * this parameter isnt used
* @return string
* HTML string
*/ */
function getChgPasswdForm($login, $su=FALSE) function getChgPasswdForm($login, $su = FALSE)
{ {
include dirname(__FILE__). '/formmask/subjects.inc.php'; include(dirname(__FILE__). '/formmask/subjects.inc.php');
$form = new HTML_QuickForm('chgPasswd', UI_STANDARD_FORM_METHOD, UI_HANDLER); $form = new HTML_QuickForm('chgPasswd', UI_STANDARD_FORM_METHOD, UI_HANDLER);
if ($this->Base->gb->checkPerm($this->Base->userid, 'subjects') === TRUE) { if ($this->Base->gb->checkPerm($this->Base->userid, 'subjects') === TRUE) {
@ -133,14 +154,12 @@ class uiSubjects
/** /**
* chgPasswd * Change password for specified user.
* *
* Change password for specified user * @todo Rename this function to "changePassword".
* * @param array $request
* @param uid int, local user id * Required array keys: passwd, passwd2, login, oldpasswd
* @param oldpass string, old user password * @return boolean
* @param pass string, new password
* @param pass2 string, retype of new password
*/ */
function chgPasswd($request) function chgPasswd($request)
{ {
@ -155,7 +174,7 @@ class uiSubjects
} else { } else {
$this->setRedir(); $this->setRedir();
if ($this->Base->login !== $request['login']){ if ($this->Base->login !== $request['login']) {
$this->Base->_retMsg('Access denied.'); $this->Base->_retMsg('Access denied.');
return FALSE; return FALSE;
} }
@ -179,61 +198,64 @@ class uiSubjects
/** /**
* getSubjects * Get all GreenBox subjects (users/groups)
* *
* get all GreenBox subjects (users/groups) * @todo Rename this function.
* * @return array
* @return array subj=>unique id of subject, loggedAs=>corresponding login name * subj=>unique id of subject
* loggedAs=>corresponding login name
*/ */
function getSubjectsWCnt() function getSubjectsWCnt()
{ {
return $this->Base->gb->getSubjectsWCnt(); return $this->Base->gb->getSubjectsWCnt();
} }
/** /**
* getGroupMember * Get a list of groups that the user belongs to.
* *
* get a list of members in given group * @todo Rename this function to "getGroupMembers"
* * @param int $id
* @parm $id int local user ID * local user ID
* @return array * @return array
*/ */
function getGroupMember($id) function getGroupMember($id)
{ {
return $this->Base->gb->listGroup($id); return $this->Base->gb->listGroup($id);
} } // fn getGroupMember
/** /**
* getNonGroupMember * Get a list of groups that the user does not belong to.
* *
* get a list of groups where user is member of * @param int $id
* * Local user ID
* @parm $id int local user ID * @return array
* @return array
*/ */
function getNonGroupMember($id) function getNonGroupMember($id)
{ {
foreach($this->Base->gb->listGroup($id) as $val1) foreach ($this->Base->gb->listGroup($id) as $val1) {
$members[$val1['id']] = TRUE; $members[$val1['id']] = TRUE;
}
$all = $this->Base->gb->getSubjectsWCnt(); $all = $this->Base->gb->getSubjectsWCnt();
foreach($all as $key2=>$val2) foreach ($all as $key2=>$val2) {
if($members[$val2['id']]) if ($members[$val2['id']]) {
unset($all[$key2]); unset($all[$key2]);
}
}
return $all; return $all;
} } // fn getNonGroupMember
/** /**
* addSubj2Group * Add a subject to a group.
* *
* Add {login} and direct/indirect members to {gname} and to groups, * @todo Rename this function to "addSubjectToGroup"
* where {gname} is [in]direct member * @param array $request
* * Required array keys: login, id, gname
* @param login string * @return boolean
* @param gname string
* @param reid string, local id of managed group, just needed for redirect
*/ */
function addSubj2Gr(&$request) function addSubj2Gr(&$request)
{ {
@ -244,7 +266,7 @@ class uiSubjects
return FALSE; return FALSE;
} }
## loop for multiple action // loop for multiple action
if (is_array($request['id'])) { if (is_array($request['id'])) {
foreach ($request['id'] as $val) { foreach ($request['id'] as $val) {
$req = array('login' => $this->Base->gb->getSubjName($val), 'gname' => $request['gname']); $req = array('login' => $this->Base->gb->getSubjName($val), 'gname' => $request['gname']);
@ -265,14 +287,13 @@ class uiSubjects
return TRUE; return TRUE;
} }
/** /**
* removeGroupMember * Remove a subject from a group.
* *
* Remove subject from group * @param array $request
* * Required keys: login, id, gname
* @param login string * @return boolean
* @param gname string
* @param reid string, local id of managed group, just needed for redirect
*/ */
function removeSubjFromGr(&$request) function removeSubjFromGr(&$request)
{ {
@ -283,7 +304,7 @@ class uiSubjects
return FALSE; return FALSE;
} }
## loop for multiple action // loop for multiple action
if (is_array($request['id'])) { if (is_array($request['id'])) {
foreach ($request['id'] as $val) { foreach ($request['id'] as $val) {
$req = array('login' => $this->Base->gb->getSubjName($val), 'gname' => $request['gname']); $req = array('login' => $this->Base->gb->getSubjName($val), 'gname' => $request['gname']);
@ -305,6 +326,12 @@ class uiSubjects
} }
/**
* Return true if the subject is a member of the given group.
*
* @param string $groupname
* @return boolean
*/
function isMemberOf($groupname) function isMemberOf($groupname)
{ {
if ($gid = $this->Base->gb->getSubjId($groupname)) { if ($gid = $this->Base->gb->getSubjId($groupname)) {
@ -318,8 +345,8 @@ class uiSubjects
} }
} }
return false; return false;
} } // fn isMemberOf
}
} // class uiSubjects
?> ?>

View file

@ -1,5 +1,10 @@
<?php <?php
/**
* @package Campcaster
* @subpackage htmlUI
* @version $Revision$
*/
class uiTransfers class uiTransfers
{ {
var $Base; var $Base;
@ -11,51 +16,55 @@ class uiTransfers
function uiTransfers(&$uiBase) function uiTransfers(&$uiBase)
{ {
$this->Base =& $uiBase; $this->Base =& $uiBase;
$this->reloadUrl = UI_BROWSER.'?popup[]=_reload_parent&popup[]=_close'; $this->reloadUrl = UI_BROWSER.'?popup[]=_reload_parent&popup[]=_close';
$this->trShowInfo =& $_SESSION[UI_TRANSFER_SESSNAME]['trShowInfo']; $this->trShowInfo =& $_SESSION[UI_TRANSFER_SESSNAME]['trShowInfo'];
$this->trShowInfo['limit'] = UI_BROWSE_DEFAULT_LIMIT; $this->trShowInfo['limit'] = UI_BROWSE_DEFAULT_LIMIT;
$this->trShowInfo['offset'] = 0; $this->trShowInfo['offset'] = 0;
$this->trShowInfo['desc'] = FALSE; $this->trShowInfo['desc'] = FALSE;
$this->trShowInfo['orderby'] = FALSE; $this->trShowInfo['orderby'] = FALSE;
} }
function reOrder($by) function reOrder($by)
{ {
$this->trShowInfo['offset'] = NULL; $this->trShowInfo['offset'] = NULL;
if ($this->trShowInfo['orderby'] == $by && !$this->trShowInfo['desc']) if ($this->trShowInfo['orderby'] == $by && !$this->trShowInfo['desc']) {
$this->trShowInfo['desc'] = TRUE; $this->trShowInfo['desc'] = TRUE;
else } else {
$this->trShowInfo['desc'] = FALSE; $this->trShowInfo['desc'] = FALSE;
}
$this->trShowInfo['orderby'] = $by; $this->trShowInfo['orderby'] = $by;
$this->setReload(); $this->setReload();
//echo '<XMP>this:'; print_r($this); echo "</XMP>\n"; //echo '<XMP>this:'; print_r($this); echo "</XMP>\n";
} }
function getTransfers() function getTransfers()
{ {
$this->buildList(); $this->buildList();
return $this->rows; return $this->rows;
} }
function buildList() { function buildList() {
# set items // set items
$transfers = $this->Base->gb->getHubInitiatedTransfers(); $transfers = $this->Base->gb->getHubInitiatedTransfers();
foreach ($transfers as $transfer) { foreach ($transfers as $transfer) {
$token = $transfer['trtok']; $token = $transfer['trtok'];
$data=$this->Base->gb->getTransportInfo($token); $data = $this->Base->gb->getTransportInfo($token);
if ($data['state']!='finished') { if ($data['state']!='finished') {
$this->allItems[]=array_merge($data,array('id' => $token)); $this->allItems[] = array_merge($data,array('id' => $token));
} }
} }
$this->rows['cnt'] =count($this->allItems); $this->rows['cnt'] = count($this->allItems);
$this->pagination(); $this->pagination();
$this->showItems(); $this->showItems();
//echo '<XMP>this'; print_r($this); echo "</XMP>\n"; //echo '<XMP>this'; print_r($this); echo "</XMP>\n";
} }
function pagination() function pagination()
{ {
if (sizeof($this->allItems) == 0) { if (sizeof($this->allItems) == 0) {
@ -70,11 +79,16 @@ class uiTransfers
$deltaUpper = UI_BROWSERESULTS_DELTA; $deltaUpper = UI_BROWSERESULTS_DELTA;
$start = $currp; $start = $currp;
if ($start+$delta-$maxp > 0) $deltaLower += $start+$delta-$maxp; ## correct lower boarder if page is near end if ($start+$delta-$maxp > 0) {
$deltaLower += $start+$delta-$maxp; ## correct lower boarder if page is near end
}
for ($n = $start-$deltaLower; $n <= $start+$deltaUpper; $n++) { for ($n = $start-$deltaLower; $n <= $start+$deltaUpper; $n++) {
if ($n <= 0) $deltaUpper++; ## correct upper boarder if page is near zero if ($n <= 0) {
elseif ($n <= $maxp) $this->rows['pagination'][$n] = $n; $deltaUpper++; ## correct upper boarder if page is near zero
} elseif ($n <= $maxp) {
$this->rows['pagination'][$n] = $n;
}
} }
$this->rows['pagination'][1] ? NULL : $this->rows['pagination'][1] = '|<<'; $this->rows['pagination'][1] ? NULL : $this->rows['pagination'][1] = '|<<';
@ -82,16 +96,18 @@ class uiTransfers
$this->rows['next'] = $this->rows['cnt'] > $this->trShowInfo['offset'] + $this->trShowInfo['limit'] ? TRUE : FALSE; $this->rows['next'] = $this->rows['cnt'] > $this->trShowInfo['offset'] + $this->trShowInfo['limit'] ? TRUE : FALSE;
$this->rows['prev'] = $this->trShowInfo['offset'] > 0 ? TRUE : FALSE; $this->rows['prev'] = $this->trShowInfo['offset'] > 0 ? TRUE : FALSE;
ksort($this->rows['pagination']); ksort($this->rows['pagination']);
} } // fn pagination
function setReload() function setReload()
{ {
$this->Base->redirUrl = $this->reloadUrl; $this->Base->redirUrl = $this->reloadUrl;
} }
function setOffset($page) function setOffset($page)
{ {
#echo '<XMP>page:'; print_r($page); echo "</XMP>\n"; //echo '<XMP>page:'; print_r($page); echo "</XMP>\n";
$o =& $this->trShowInfo['offset']; $o =& $this->trShowInfo['offset'];
$l =& $this->trShowInfo['limit']; $l =& $this->trShowInfo['limit'];
@ -105,10 +121,13 @@ class uiTransfers
$this->setReload(); $this->setReload();
} }
function cmp($a,$b)
function cmp($a, $b)
{ {
#echo '<XMP>cmp:'; echo($a[$this->trShowInfo['orderby']].' - '.$b[$this->trShowInfo['orderby']]); echo "</XMP>\n"; //echo '<XMP>cmp:'; echo($a[$this->trShowInfo['orderby']].' - '.$b[$this->trShowInfo['orderby']]); echo "</XMP>\n";
if ($a[$this->trShowInfo['orderby']] == $b[$this->trShowInfo['orderby']]) return 0; if ($a[$this->trShowInfo['orderby']] == $b[$this->trShowInfo['orderby']]) {
return 0;
}
if ($a[$this->trShowInfo['orderby']] < $b[$this->trShowInfo['orderby']]) { if ($a[$this->trShowInfo['orderby']] < $b[$this->trShowInfo['orderby']]) {
return $this->trShowInfo['desc'] ? 1 : -1; return $this->trShowInfo['desc'] ? 1 : -1;
} else { } else {
@ -116,22 +135,24 @@ class uiTransfers
} }
} }
function showItems() function showItems()
{ {
# array sort // array sort
if (is_array($this->allItems) && $this->trShowInfo['orderby']!==FALSE) { if (is_array($this->allItems) && $this->trShowInfo['orderby']!==FALSE) {
usort($this->allItems,array($this,'cmp')); usort($this->allItems,array($this,'cmp'));
} }
# pagination // pagination
for ($i=$this->trShowInfo['offset'];$i<$this->trShowInfo['offset']+$this->trShowInfo['limit'];$i++) { for ($i=$this->trShowInfo['offset'];$i<$this->trShowInfo['offset']+$this->trShowInfo['limit'];$i++) {
if (!is_null($this->allItems[$i])) { if (!is_null($this->allItems[$i])) {
$this->rows['items'][]=$this->allItems[$i]; $this->rows['items'][]=$this->allItems[$i];
} }
} }
#$this->rows['page'] = $this->trShowInfo['offset'] % $this->trShowInfo['limit']; //$this->rows['page'] = $this->trShowInfo['offset'] % $this->trShowInfo['limit'];
} }
function upload2Hub($id) function upload2Hub($id)
{ {
$gunid = $this->Base->gb->_gunidFromId($id); $gunid = $this->Base->gb->_gunidFromId($id);
@ -151,6 +172,7 @@ class uiTransfers
} }
} }
function downloadFromHub($id,$type) function downloadFromHub($id,$type)
{ {
switch ($type) { switch ($type) {
@ -167,6 +189,7 @@ class uiTransfers
} }
} }
function doTransportAction($trtokens,$action) { function doTransportAction($trtokens,$action) {
//echo '<XMP>ids:'; print_r($trtokens); echo "</XMP>\n"; //echo '<XMP>ids:'; print_r($trtokens); echo "</XMP>\n";
if (!is_array($trtokens)) { if (!is_array($trtokens)) {