Fix saving MontageLayouts
parent
ce6cc24de5
commit
b5491102ef
|
@ -41,7 +41,7 @@ EXECUTE stmt;
|
|||
SET @s = ( SELECT IF(
|
||||
(SELECT COUNT(*) FROM MontageLayouts WHERE Name='3 Wide') > 0,
|
||||
"SELECT '3 Wide already in layouts'",
|
||||
'INSERT INTO MontageLayouts (`Name`,`Positions`) VALUES (\'3 Wide\', \'{ "default":{"float":"left", "width":"33%"} }\');'
|
||||
'INSERT INTO MontageLayouts (`Name`,`Positions`) VALUES (\'3 Wide\', \'{"default":{"float":"left","width":"33%"}}\');'
|
||||
) );
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
@ -49,7 +49,7 @@ EXECUTE stmt;
|
|||
SET @s = ( SELECT IF(
|
||||
(SELECT COUNT(*) FROM MontageLayouts WHERE Name='4 Wide') > 0,
|
||||
"SELECT '4 Wide already in layouts'",
|
||||
'INSERT INTO MontageLayouts (`Name`,`Positions`) VALUES (\'4 Wide\', \'{ "default":{"float":"left", "width":"24.5%"} }\');'
|
||||
'INSERT INTO MontageLayouts (`Name`,`Positions`) VALUES (\'4 Wide\', \'{"default":{"float":"left","width":"24.5%"}}\');'
|
||||
) );
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
|
@ -58,7 +58,7 @@ EXECUTE stmt;
|
|||
SET @s = ( SELECT IF(
|
||||
(SELECT COUNT(*) FROM MontageLayouts WHERE Name='5 Wide') > 0,
|
||||
"SELECT '5 Wide already in layouts'",
|
||||
"INSERT INTO MontageLayouts (`Name`,`Positions`) VALUES ('5 Wide', '{ \"default\":{\"float\":\"left\", \"width\":\"19%\"} }' );"
|
||||
"INSERT INTO MontageLayouts (`Name`,`Positions`) VALUES ('5 Wide', '{\"default\":{\"float\":\"left\",\"width\":\"19%\"}}' );"
|
||||
) );
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
|
|
|
@ -112,9 +112,9 @@ class MontageLayout {
|
|||
}
|
||||
}
|
||||
|
||||
$fields = array_keys( $this->defaults );
|
||||
$fields = array_values( array_filter( array_keys($this->defaults), function($field){return $field != 'Id';} ) );
|
||||
$values = null;
|
||||
if ( $this->{'Id'} ) {
|
||||
if ( isset($this->{'Id'}) ) {
|
||||
$sql = 'UPDATE MontageLayouts SET '.implode(', ', array_map( function($field) {return $field.'=?';}, $fields ) ) . ' WHERE Id=?';
|
||||
$values = array_map( function($field){return $this->{$field};}, $fields );
|
||||
$values[] = $this->{'Id'};
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
//
|
||||
warning("Un error");
|
||||
|
||||
// PP - POST request handler for PHP which does not need extensions
|
||||
// credit: http://wezfurlong.org/blog/2006/nov/http-post-from-php-without-curl/
|
||||
|
@ -79,10 +78,8 @@ function getAffectedIds( $name ) {
|
|||
|
||||
|
||||
if ( empty($action) ) {
|
||||
Warning("No action");
|
||||
return;
|
||||
}
|
||||
Warning("Have action $action");
|
||||
if ( $action == 'login' && isset($_REQUEST['username']) && ( ZM_AUTH_TYPE == 'remote' || isset($_REQUEST['password']) ) ) {
|
||||
// if true, a popup will display after login
|
||||
// PP - lets validate reCaptcha if it exists
|
||||
|
@ -90,15 +87,15 @@ if ( $action == 'login' && isset($_REQUEST['username']) && ( ZM_AUTH_TYPE == 're
|
|||
&& defined('ZM_OPT_GOOG_RECAPTCHA_SECRETKEY')
|
||||
&& defined('ZM_OPT_GOOG_RECAPTCHA_SITEKEY')
|
||||
&& ZM_OPT_USE_GOOG_RECAPTCHA && ZM_OPT_GOOG_RECAPTCHA_SECRETKEY
|
||||
&& ZM_OPT_GOOG_RECAPTCHA_SITEKEY)
|
||||
&& ZM_OPT_GOOG_RECAPTCHA_SITEKEY )
|
||||
{
|
||||
$url = 'https://www.google.com/recaptcha/api/siteverify';
|
||||
$fields = array (
|
||||
'secret'=> ZM_OPT_GOOG_RECAPTCHA_SECRETKEY,
|
||||
'response' => $_REQUEST['g-recaptcha-response'],
|
||||
'remoteip'=> $_SERVER['REMOTE_ADDR']
|
||||
'secret' => ZM_OPT_GOOG_RECAPTCHA_SECRETKEY,
|
||||
'response' => $_REQUEST['g-recaptcha-response'],
|
||||
'remoteip' => $_SERVER['REMOTE_ADDR']
|
||||
);
|
||||
$res= do_post_request($url, http_build_query($fields));
|
||||
$res = do_post_request($url, http_build_query($fields));
|
||||
$responseData = json_decode($res,true);
|
||||
// PP - credit: https://github.com/google/recaptcha/blob/master/src/ReCaptcha/Response.php
|
||||
// if recaptcha resulted in error, we might have to deny login
|
||||
|
@ -685,7 +682,6 @@ if ( canEdit( 'Groups' ) ) {
|
|||
// System edit actions
|
||||
if ( canEdit( 'System' ) ) {
|
||||
if ( isset( $_REQUEST['object'] ) ) {
|
||||
Warning("Have object: " . $_REQUEST['object']);
|
||||
if ( $_REQUEST['object'] == 'MontageLayout' ) {
|
||||
require_once('MontageLayout.php');
|
||||
if ( $action == 'Save' ) {
|
||||
|
@ -696,7 +692,6 @@ if ( canEdit( 'System' ) ) {
|
|||
} else {
|
||||
$Layout = new MontageLayout( $_REQUEST['zmMontageLayout'] );
|
||||
}
|
||||
Warning("Positions: " . $_REQUEST['Positions'] );
|
||||
$Layout->Positions( $_REQUEST['Positions'] );
|
||||
$Layout->save();
|
||||
} // end if save
|
||||
|
|
|
@ -175,9 +175,7 @@ foreach ( getSkinIncludes( 'skin.php' ) as $includeFile )
|
|||
|
||||
if ( ZM_OPT_USE_AUTH && ZM_AUTH_HASH_LOGINS ) {
|
||||
if ( empty($user) && ! empty($_REQUEST['auth']) ) {
|
||||
Logger::Debug("Getting user from auth hash");
|
||||
if ( $authUser = getAuthUser( $_REQUEST['auth'] ) ) {
|
||||
Logger::Debug("Success Getting user from auth hash");
|
||||
userLogin( $authUser['Username'], $authUser['Password'], true );
|
||||
}
|
||||
} else if ( ! empty($user) ) {
|
||||
|
|
|
@ -13,7 +13,6 @@ function Monitor( monitorData ) {
|
|||
this.streamCmdTimer = null;
|
||||
|
||||
this.start = function( delay ) {
|
||||
console.log(delay);
|
||||
this.streamCmdTimer = this.streamCmdQuery.delay( delay, this );
|
||||
};
|
||||
|
||||
|
@ -120,6 +119,7 @@ function selectLayout( element ) {
|
|||
|
||||
if ( layout_id = parseInt(layout) ) {
|
||||
layout = layouts[layout];
|
||||
console.log(layout);
|
||||
|
||||
for ( var i = 0; i < monitors.length; i++ ) {
|
||||
monitor = monitors[i];
|
||||
|
@ -132,18 +132,23 @@ function selectLayout( element ) {
|
|||
}
|
||||
|
||||
// Apply default layout options, like float left
|
||||
if ( layout.default ) {
|
||||
styles = layout.default;
|
||||
if ( layout.Positions['default'] ) {
|
||||
styles = layout.Positions['default'];
|
||||
for ( style in styles ) {
|
||||
monitor_frame.css(style, styles[style]);
|
||||
}
|
||||
} else {
|
||||
console.log("No default styles to apply" + layout.Positions);
|
||||
} // end if default styles
|
||||
|
||||
if ( layout[monitor.id] ) {
|
||||
styles = layout[monitor.id].Positions;
|
||||
if ( layout.Positions['mId'+monitor.id] ) {
|
||||
styles = layout.Positions['mId'+monitor.id];
|
||||
for ( style in styles ) {
|
||||
monitor_frame.css(style, styles[style]);
|
||||
console.log("Applying " + style + ' : ' + styles[style] );
|
||||
}
|
||||
} else {
|
||||
console.log("No Monitor styles to apply");
|
||||
} // end if specific monitor style
|
||||
} // end foreach monitor
|
||||
} // end if a stored layout
|
||||
|
@ -291,14 +296,14 @@ function edit_layout(button) {
|
|||
|
||||
function save_layout(button) {
|
||||
var form=button.form;
|
||||
var Positions = new Array();
|
||||
for ( var x = 0; x < monitors.length; x++ ) {
|
||||
var monitor = monitors[x];
|
||||
var Positions = {};
|
||||
for ( var i = 0; i < monitors.length; i++ ) {
|
||||
var monitor = monitors[i];
|
||||
monitor_frame = $j('#monitorFrame'+monitor.id);
|
||||
|
||||
Positions[monitor.id] = {
|
||||
Positions['mId'+monitor.id] = {
|
||||
width: monitor_frame.css('width'),
|
||||
height: monitor_frame.css('width'),
|
||||
height: monitor_frame.css('height'),
|
||||
top: monitor_frame.css('top'),
|
||||
bottom: monitor_frame.css('bottom'),
|
||||
left: monitor_frame.css('left'),
|
||||
|
@ -321,7 +326,7 @@ function initPage() {
|
|||
monitors[i] = new Monitor(monitorData[i]);
|
||||
var delay = Math.round( (Math.random()+0.75)*statusRefreshTimeout );
|
||||
console.log("delay: " + delay);
|
||||
//monitors[i].start(delay);
|
||||
monitors[i].start(delay);
|
||||
}
|
||||
selectLayout('#zmMontageLayout');
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ layouts[0] = {}; // reserved, should hold which fields to clear when transitioni
|
|||
<?php
|
||||
foreach ( $layouts as $layout ) {
|
||||
?>
|
||||
layouts[<?php echo $layout->Id() ?>] = <?php echo json_encode( $layout ) ?>;
|
||||
layouts[<?php echo $layout->Id() ?>] = {"Name":"<?php echo $layout->Name()?>","Positions":<?php echo $layout->Positions() ?>};
|
||||
<?php
|
||||
} // end foreach layout
|
||||
?>
|
||||
|
|
|
@ -142,6 +142,7 @@ if ( $showZones ) {
|
|||
<div id="sizeControl">
|
||||
<form action="index.php?view=montage" method="post">
|
||||
<input type="hidden" name="object" value="MontageLayout"/>
|
||||
<input type="hidden" name="action" value="Save"/>
|
||||
|
||||
<span id="widthControl"><label><?php echo translate('Width') ?>:</label><?php echo htmlSelect( 'width', $widths, $options['width'], 'changeSize(this);' ); ?></span>
|
||||
<span id="heightControl"><label><?php echo translate('Height') ?>:</label><?php echo htmlSelect( 'height', $heights, $options['height'], 'changeSize(this);' ); ?></span>
|
||||
|
@ -154,7 +155,7 @@ if ( $showZones ) {
|
|||
<input type="button" id="EditLayout" value="<?php echo translate('EditLayout') ?>" onclick="edit_layout(this);"/>
|
||||
<span id="SaveLayout" style="display:none;">
|
||||
<input type="text" name="Name" placeholder="Enter new name for layout if desired" />
|
||||
<input type="button" name="action" value="<?php echo translate('Save') ?>" onclick="save_layout(this);"/>
|
||||
<input type="button" value="<?php echo translate('Save') ?>" onclick="save_layout(this);"/>
|
||||
<input type="button" value="Cancel" onclick="cancel_layout(this);"/>
|
||||
</span>
|
||||
</form>
|
||||
|
|
Loading…
Reference in New Issue