1 Jun 2012 20:17
[Tikiwiki-cvs/svn] SF.net SVN: tikiwiki:[41711] branches/9.x/lib/profilelib/installlib.php
Revision: 41711
http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=41711&view=rev
Author: lphuberdeau
Date: 2012-06-01 18:17:15 +0000 (Fri, 01 Jun 2012)
Log Message:
-----------
[MOD] Allow to upload a series of files from URL during profile install into a file gallery
Modified Paths:
--------------
branches/9.x/lib/profilelib/installlib.php
Modified: branches/9.x/lib/profilelib/installlib.php
===================================================================
--- branches/9.x/lib/profilelib/installlib.php 2012-06-01 18:15:18 UTC (rev 41710)
+++ branches/9.x/lib/profilelib/installlib.php 2012-06-01 18:17:15 UTC (rev 41711)
<at> <at> -1241,13 +1241,50 <at> <at>
}
function _install()
{
- global $filegallib;
- if ( ! $filegallib ) require_once 'lib/filegals/filegallib.php';
+ $filegallib = TikiLib::lib('filegal');
$input = $this->getData();
- return $filegallib->replace_file_gallery($input);
+ $files = array();
+ if (! empty($input['init_files'])) {
+ $files = (array) $input['init_files'];
+ unset($input['init_files']);
+ }
+
+ $galleryId = $filegallib->replace_file_gallery($input);
+
+ if (empty($input['galleryId']) && count($files)) {
+ $gal_info = $filegallib->get_file_gallery_info($galleryId);
+
+ foreach ($files as $url) {
+ $this->upload($gal_info, $url);
+ }
+ }
+
+ return $galleryId;
}
+
+ function upload($gal_info, $url)
+ {
+ $filegallib = TikiLib::lib('filegal');
+ if ($filegallib->lookup_source($url)) {
+ return;
+ }
+
+ $info = $filegallib->get_info_from_url($url);
+
+ if (! $info) {
+ return;
+ }
+
+ $fileId = $filegallib->upload_single_file($gal_info, $info['name'], $info['size'],
$info['type'], $info['data']);
+
+ if ($fileId === false) {
+ return;
+ }
+
+ $filegallib->attach_file_source($fileId, $url, $info);
+ }
} // }}}
class Tiki_Profile_InstallHandler_Module extends Tiki_Profile_InstallHandler // {{{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open
Source development site.
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
RSS Feed