Will now download the requested app. Still need to add the setup/install process to it.

This commit is contained in:
skeeter 2002-02-24 21:00:59 +00:00
parent a850a50c3a
commit 1cd5737c51

View File

@ -42,6 +42,15 @@
var $soap_functions = array(); var $soap_functions = array();
var $install_file = True;
// var $install_file = False;
var $write_file = True;
// var $write_file = False;
// var $debug = True;
var $debug = False;
var $db; var $db;
var $is; var $is;
var $client; var $client;
@ -215,45 +224,110 @@
} }
} }
function create_file($basedir,$sep,$filename,$file_content)
{
// This will be dangerous to do
$directory = dirname($filename);
if($this->debug)
{
echo 'Checking filename: '.$filename.'<br>'."\n".'Directory part: '.$directory.'<br>'."\n";
}
$ind_dir = explode('/',$directory);
$long_dir = '';
$new_base = $basedir;
for($i=0;$i<count($ind_dir);$i++)
{
@chdir($new_base);
if($this->debug)
{
echo 'Changing directory to :'.$new_base.'<br>'."\n";
}
$long_dir .= ($long_dir?$sep:'').$ind_dir[$i];
if(!is_dir($ind_dir[$i]))
{
@mkdir($ind_dir[$i],0770);
if($this->debug)
{
echo 'Creating Directory: '.$ind_dir[$i].'<br>'."\n";
}
clearstatcache();
}
$new_base .= $sep.$ind_dir[$i];
}
if($this->write_file)
{
@chdir($basedir);
$fp=fopen($basedir.$sep.$filename,'wb');
fwrite($fp,base64_decode($file_content));
fclose($fp);
if($this->debug)
{
echo 'Creating file: '.$basedir.$sep.$filename.'<br>'."\n";
}
}
if($this->debug)
{
echo '<br>'."\n";
}
}
function delete_dir($directory,$sep)
{
$d = dir($directory);
$dir_path = Array();
while($entry = $d->read())
{
$new_filename = $directory.$sep.$entry;
if(is_file($new_filename))
{
unlink($new_filename);
}
elseif(is_dir($new_filename))
{
if($entry != '.' && $entry != '..')
{
$dir_path[] = $new_filename;
}
}
}
$d->close();
@reset($dir_path);
while($dir_path && list($dummy,$dir) = each($dir_path))
{
$this->delete_dir($dir,$sep);
}
rmdir($directory);
}
function request_packaged_app($app_id) function request_packaged_app($app_id)
{ {
if(is_object($this->is)) if(is_object($this->is))
{ {
$application = $this->is->send('system.package_app',$app_id,$this->is->server['server_url']); $application = $this->is->send('system.package_app',$app_id,$this->is->server['server_url'],False);
// comment from here down to stop the actual install
/* if(is_array($application) && $this->install_file)
// This is where I need to install the application
$sep = filesystem_separator();
@reset($application);
list($appid,$app_info) = each($application);
$app_name = $app_info['name'];
$basedir = PHPGW_SERVER_ROOT.$sep.$app_name;
@mkdir($basedir);
while($application && list($filename,$file_content) = each($application))
{ {
$long_filename = $basedir.$sep.$filename; // This is where I need to install the application
// This will be dangerous to do $sep = filesystem_separator();
$directory = dirname($long_filename); @reset($application);
if(!is_dir($directory)) list($appid,$app_info) = each($application);
$app_name = $app_info['name'];
$basedir = PHPGW_SERVER_ROOT.$sep.$app_name;
$this->delete_dir($basedir,$sep);
@mkdir($basedir,0770);
if($this->debug)
{ {
$long_dir = $long_filename; echo 'Creating Directory: '.$basedir.'<br>'."\n";
$pos_slash = pos(' '.$long_dir,$sep) }
while($pos_slash)
{ while(list($filename,$file_content) = each($application))
$short_dir = substr($long_dir,0,$pos_slash - 1); {
$long_dir = str_replace($short_dir.$sep,'',$long_dir); $this->create_file($basedir,$sep,$filename,$file_content);
@mkdir($short_dir,770);
$pos_slash = pos(' '.$long_dir,$sep)
}
} }
$fp=fopen($long_filename,'wb');
fwrite($fp,base64_decode($file_content));
fclose($fp);
} }
*/
// Comment above to stop the actual install
@reset($application); @reset($application);
return $application; return $application;
} }
@ -408,9 +482,10 @@
$this->dir_file = Array(); $this->dir_file = Array();
$this->db->next_record(); $this->db->next_record();
$app_name = $this->db->f('app_name'); $app_name = $this->db->f('app_name');
$this->dir_file[$this->db->f('app_id')] = CreateObject('phpgwapi.xmlrpcval', $app_id = $this->db->f('app_id');
$this->dir_file[$app_id] = CreateObject('phpgwapi.xmlrpcval',
Array( Array(
'id' => CreateObject('phpgwapi.xmlrpcval',$this->db->f('app_id'),'int'), 'id' => CreateObject('phpgwapi.xmlrpcval',$app_id,'int'),
'name' => CreateObject('phpgwapi.xmlrpcval',$app_name,'string'), 'name' => CreateObject('phpgwapi.xmlrpcval',$app_name,'string'),
'title' => CreateObject('phpgwapi.xmlrpcval',$this->db->f('app_title'),'string'), 'title' => CreateObject('phpgwapi.xmlrpcval',$this->db->f('app_title'),'string'),
'version' => CreateObject('phpgwapi.xmlrpcval',$this->db->f('app_version'),'string'), 'version' => CreateObject('phpgwapi.xmlrpcval',$this->db->f('app_version'),'string'),