|
From: <bi...@us...> - 2013-03-05 20:15:19
|
Revision: 11160
http://sourceforge.net/p/xoops/svn/11160
Author: bitc3r0
Date: 2013-03-05 20:15:16 +0000 (Tue, 05 Mar 2013)
Log Message:
-----------
Improves the updates system
Modified Paths:
--------------
RMC/rmcommon/trunk/rmcommon/include/install.php
RMC/rmcommon/trunk/rmcommon/include/js/updates.js
RMC/rmcommon/trunk/rmcommon/index.php
RMC/rmcommon/trunk/rmcommon/templates/ajax/rmc_updates_list.php
RMC/rmcommon/trunk/rmcommon/templates/rmc_updates.php
RMC/rmcommon/trunk/rmcommon/updates.php
RMC/rmcommon/trunk/rmcommon/xoops_version.php
Modified: RMC/rmcommon/trunk/rmcommon/include/install.php
===================================================================
--- RMC/rmcommon/trunk/rmcommon/include/install.php 2013-03-05 19:56:43 UTC (rev 11159)
+++ RMC/rmcommon/trunk/rmcommon/include/install.php 2013-03-05 20:15:16 UTC (rev 11160)
@@ -44,13 +44,3 @@
return true;
}
-
-function xoops_module_update_rmcommon($mod, $prev){
-
- $db = XoopsDatabaseFactory::getDatabaseConnection();
-
- // Add tables to database
- $sql = "ALTER TABLE `".$db->prefix("rmc_blocks")."` ADD `content` TEXT NOT NULL AFTER `content_type`";
- return $db->queryF($sql);
-
-}
Modified: RMC/rmcommon/trunk/rmcommon/include/js/updates.js
===================================================================
--- RMC/rmcommon/trunk/rmcommon/include/js/updates.js 2013-03-05 19:56:43 UTC (rev 11159)
+++ RMC/rmcommon/trunk/rmcommon/include/js/updates.js 2013-03-05 20:15:16 UTC (rev 11160)
@@ -83,7 +83,16 @@
var id = $(this).attr("data-id");
if(id==undefined || id<0) return;
credentials[id] = $("#uname").val()+':'+$("#upass").val();
- installUpdate(id);
+
+ if($("#upd-login").data('next')=='download'){
+
+ downloadUpdate(id);
+
+ } else {
+
+ installUpdate(id);
+
+ }
});
@@ -203,6 +212,72 @@
}
+/**
+ * This function allows to download update package in order to install manually
+ * @param id
+ * @return {*}
+ */
+function downloadUpdate(id){
+
+ if(id==null || id==undefined) return false;
+
+ var updates = eval($("#json-container").html());
+ var update = updates[id].data;
+ if(update.url.match(/^http:\/\//)==null) return false;
+
+ var url = update.url.replace(/\&/,'&');
+
+ if(update.login==1 && credentials[id]==undefined){
+ $("#upd-login .ok-login").attr("data-id", id);
+ $("#upd-login").data("next", 'download');
+ showLogin(update);
+ return;
+ }
+
+ var params = {
+ action: 'later',
+ url: url,
+ credentials: credentials[id]==undefined ? '' : credentials[id],
+ type: update.type,
+ dir: update.dir
+ };
+
+ $.post("updates.php", params, function(data){
+
+ if(data.error==1){
+ alert(data.message);
+ return;
+ }
+
+ $("#upd-"+id+" .button-later > i").removeClass("icon-spinner icon-spin").addClass("icon-time");
+
+ window.location.href="updates.php?action=getfile&file="+data.data.file;
+
+ }, 'json');
+
+}
+
+function installLater(id){
+ if(id==null || id==undefined) return false;
+
+ $("#upd-"+id+" .button-later > i").removeClass("icon-time").addClass("icon-spinner icon-spin");
+
+ var updates = eval($("#json-container").html());
+ var update = updates[id].data;
+ if(update.url.match(/^http:\/\//)==null) return false;
+
+ var url = update.url.replace(/\&/,'&')+'&action=download';
+
+ if(update.login==1 && credentials[id]==undefined){
+ $("#upd-login .ok-login").attr("data-id", id);
+ $("#upd-login").data("next", 'download');
+ showLogin(update);
+ return;
+ }
+
+ downloadUpdate(id);
+}
+
function showWarning(update){
$("#upd-info-blocker").fadeIn('fast');
Modified: RMC/rmcommon/trunk/rmcommon/index.php
===================================================================
--- RMC/rmcommon/trunk/rmcommon/index.php 2013-03-05 19:56:43 UTC (rev 11159)
+++ RMC/rmcommon/trunk/rmcommon/index.php 2013-03-05 20:15:16 UTC (rev 11160)
@@ -80,7 +80,7 @@
RMTemplate::get()->add_style('dashboard.css', 'rmcommon');
RMTemplate::get()->add_script(RMCURL.'/include/js/dashboard.js');
RMTemplate::get()->add_style('pagenav.css', 'rmcommon');
- RMTemplate::get()->add_help(__('Dashboard Help','rmcommon'),'http://www.redmexico.com.mx/docs/common-utilities/uso-de-common-utilities/standalone/1/#dashboard');
+ RMTemplate::get()->add_help(__('Dashboard Help','rmcommon'),'http://www.xoopsmexico.net/docs/common-utilities/uso-de-common-utilities/standalone/1/#dashboard');
include RMTemplate::get()->get_template('rmc_dashboard.php', 'module', 'rmcommon');
xoops_cp_footer();
Modified: RMC/rmcommon/trunk/rmcommon/templates/ajax/rmc_updates_list.php
===================================================================
--- RMC/rmcommon/trunk/rmcommon/templates/ajax/rmc_updates_list.php 2013-03-05 19:56:43 UTC (rev 11159)
+++ RMC/rmcommon/trunk/rmcommon/templates/ajax/rmc_updates_list.php 2013-03-05 20:15:16 UTC (rev 11160)
@@ -8,7 +8,7 @@
<?php echo sprintf(__('Version: %s','rmcommon'), '<strong>'.$upd['data']['version'].'</strong>'); ?> |
<?php echo sprintf(__('Released on: %s','rmcommon'), '<strong>'.$upd['data']['released'].'</strong>'); ?>
<?php if($upd['data']['login']): ?>
- | <?php _e('Login required','rmcommon'); ?>
+ | <i class="icon-lock"></i> <?php _e('Login required','rmcommon'); ?>
<?php endif; ?>
</div>
<div class="upd-progress">
@@ -23,6 +23,7 @@
<div class="btn-group pull-right">
<button type="button" class="btn" onclick="loadUpdateDetails(<?php echo $i; ?>);"><i class="icon-info-sign"></i> <?php _e('View details','rmcommon'); ?></button>
<button type="button" class="btn" onclick="installUpdate(<?php echo $i; ?>);" data-id="<?php echo $i; ?>"><i class="icon-circle-arrow-down"></i> <?php _e('Update now!','rmcommon'); ?></button>
+ <button type="button" class="btn button-later" onclick="installLater(<?php echo $i; ?>);" data-id="<?php echo $i; ?>"><i class="icon-time"></i> <?php _e('Install Later','rmcommon'); ?></button>
</div>
</div>
</div>
Modified: RMC/rmcommon/trunk/rmcommon/templates/rmc_updates.php
===================================================================
--- RMC/rmcommon/trunk/rmcommon/templates/rmc_updates.php 2013-03-05 19:56:43 UTC (rev 11159)
+++ RMC/rmcommon/trunk/rmcommon/templates/rmc_updates.php 2013-03-05 20:15:16 UTC (rev 11160)
@@ -81,7 +81,7 @@
</div>
<div id="login-blocker"></div>
-<div id="upd-login">
+<div id="upd-login" data-next="">
<div class="title xo-bluebar">
<button class="close" type="button">×</button>
<i class="icon-user icon-white"></i> <?php _e('User Credentials','rmcommon'); ?>
Modified: RMC/rmcommon/trunk/rmcommon/updates.php
===================================================================
--- RMC/rmcommon/trunk/rmcommon/updates.php 2013-03-05 19:56:43 UTC (rev 11159)
+++ RMC/rmcommon/trunk/rmcommon/updates.php 2013-03-05 20:15:16 UTC (rev 11160)
@@ -42,6 +42,8 @@
$rmTpl->add_local_script('updates.js', 'rmcommon', 'include');
$rmTpl->add_head_script('var xoToken = "'.$xoopsSecurity->createToken().'";');
$rmTpl->add_head_script('var langUpdated = "'.__('Item updated!','rmcommon').'";');
+
+ $rmTpl->add_help(__('Updates Help','rmcommon'), 'http://www.xoopsmexico.net/docs/common-utilities/actualizaciones-automaticas/standalone/1/');
$ftpserver = parse_url(XOOPS_URL);
$ftpserver = $ftpserver['host'];
@@ -338,6 +340,69 @@
}
+function download_for_later(){
+ global $xoopsLogger;
+
+ $xoopsLogger->activated = false;
+
+ $url = rmc_server_var($_POST, 'url', '');
+ $cred = rmc_server_var($_POST, 'credentials', '');
+ $type = rmc_server_var($_POST, 'type', '');
+ $dir = rmc_server_var($_POST, 'dir', '');
+
+ if($url=='')
+ jsonReturn(__('Invalid parameters!','rmcommon'));
+
+ // Request access
+ $response = json_decode(file_get_contents($url.'&action=login'.($cred!='' ? '&l='.$cred : '')), true);
+ if($response['error']==1)
+ jsonReturn($response['message']);
+
+ if(!is_dir(XOOPS_CACHE_PATH.'/updates/'))
+ mkdir(XOOPS_CACHE_PATH.'/updates/', 511);
+
+ if(!file_put_contents(XOOPS_CACHE_PATH.'/updates/'.$type.'-'.$dir.'.zip', file_get_contents($response['data']['url'])))
+ jsonReturn(__('Unable to download update file!','rmcommon'));
+
+ jsonReturn(__('Downloaded!', 'rmcommon'), 0, array(
+ 'file' => $type.'-'.$dir.'.zip'
+ ));
+}
+
+
+/**
+ * Send downloaded file to user
+ */
+function get_file_now(){
+
+ global $xoopsSecurity;
+ $tfile = rmc_server_var($_GET, 'file', '');
+
+ if($tfile=='')
+ redirectMsg('updates.php', __('File not found!','rmcommon'), RMMSG_ERROR);
+
+ $tfile = str_replace(array("/","\\"), '', $tfile);
+
+ $file = XOOPS_CACHE_PATH.'/updates/'.$tfile;
+ if(!is_file($file))
+ redirectMsg("updates.php", __('File not found!','rmcommon')." $tfile = $file", RMMSG_ERROR);
+
+ header('Content-type: application/zip');
+ header('Cache-control: no-store');
+ header('Expires: 0');
+ header('Content-disposition: attachment; filename='.urlencode($tfile));
+ header('Content-Transfer-Encoding: binary');
+ header('Content-Lenght: '.filesize($file));
+ header('Last-Modified: '.gmdate("D, d M Y H:i:s",$file).'GMT');
+ ob_clean();
+ flush();
+ readfile($file);
+ unlink($file);
+ exit();
+
+}
+
+
$action = rmc_server_var($_REQUEST, 'action', '');
switch($action){
@@ -350,8 +415,12 @@
case 'first-step':
download_file();
break;
- case 'second-step':
-
+ case 'later':
+ download_for_later();
+ break;
+ case 'getfile':
+ get_file_now();
+ break;
default:
show_available_updates();
break;
Modified: RMC/rmcommon/trunk/rmcommon/xoops_version.php
===================================================================
--- RMC/rmcommon/trunk/rmcommon/xoops_version.php 2013-03-05 19:56:43 UTC (rev 11159)
+++ RMC/rmcommon/trunk/rmcommon/xoops_version.php 2013-03-05 20:15:16 UTC (rev 11160)
@@ -34,10 +34,9 @@
$modversion['icon24'] = 'images/rmc24.png';
$modversion['icon48'] = 'images/icon48.png';
$modversion['rmnative'] = 1;
-$modversion['rmversion'] = array('major'=>2,'minor'=>1,'revision'=>88,'stage'=>-1,'name'=>'Common Utilities');
+$modversion['rmversion'] = array('major'=>2,'minor'=>1,'revision'=>89.1,'stage'=>-1,'name'=>'Common Utilities');
$modversion['onUninstall'] = 'include/install.php';
$modversion['onInstall'] = 'include/install.php';
-$modversion['onUpdate'] = 'include/install.php';
$modversion['social'][0] = array('title' => __('Twitter', 'rmcommon'),'type' => 'twitter','url' => 'http://www.twitter.com/bitcero/');
$modversion['social'][1] = array('title' => __('LinkedIn', 'rmcommon'),'type' => 'linkedin','url' => 'http://www.linkedin.com/bitcero/');
@@ -450,7 +449,7 @@
'description' => '',
'formtype' => 'textbox',
'valuetype' => 'int',
- 'default' => 7
+ 'default' => 1
);
// BLOCKS
|