Merge branch 'master' into oc_error
This commit is contained in:
commit
54001ec7d8
10 changed files with 38 additions and 66 deletions
3
3rdparty/MDB2/Driver/Manager/pgsql.php
vendored
3
3rdparty/MDB2/Driver/Manager/pgsql.php
vendored
|
@ -410,6 +410,9 @@ class MDB2_Driver_Manager_pgsql extends MDB2_Driver_Manager_Common
|
|||
}
|
||||
$db->loadModule('Datatype', null, true);
|
||||
$type = $db->datatype->getTypeDeclaration($field['definition']);
|
||||
if($type=='SERIAL PRIMARY KEY'){//not correct when altering a table, since serials arent a real type
|
||||
$type='INTEGER';//use integer instead
|
||||
}
|
||||
$query = "ALTER $field_name TYPE $type USING CAST($field_name AS $type)";
|
||||
$result = $db->exec("ALTER TABLE $name $query");
|
||||
if (PEAR::isError($result)) {
|
||||
|
|
|
@ -40,7 +40,7 @@ if (!isset($_GET['id'])) {
|
|||
bailOut(OC_Contacts_App::$l10n->t('No contact ID was submitted.'));
|
||||
}
|
||||
|
||||
$tmpfname = tempnam("/tmp", "occOrig");
|
||||
$tmpfname = tempnam(get_temp_dir(), "occOrig");
|
||||
$contact = OC_Contacts_App::getContactVCard($_GET['id']);
|
||||
$image = new OC_Image();
|
||||
if(!$image) {
|
||||
|
|
|
@ -42,7 +42,7 @@ if(!isset($_GET['path'])) {
|
|||
}
|
||||
|
||||
$localpath = OC_Filesystem::getLocalFile($_GET['path']);
|
||||
$tmpfname = tempnam("/tmp", "occOrig");
|
||||
$tmpfname = tempnam(get_temp_dir(), "occOrig");
|
||||
|
||||
if(!file_exists($localpath)) {
|
||||
bailOut(OC_Contacts_App::$l10n->t('File doesn\'t exist:').$localpath);
|
||||
|
|
|
@ -71,7 +71,7 @@ if(file_exists($tmp_path)) {
|
|||
OCP\Util::writeLog('contacts','savecrop.php, x: '.$x1.' y: '.$y1.' w: '.$w.' h: '.$h, OCP\Util::DEBUG);
|
||||
if($image->crop($x1, $y1, $w, $h)) {
|
||||
if(($image->width() <= 200 && $image->height() <= 200) || $image->resize(200)) {
|
||||
$tmpfname = tempnam("/tmp", "occCropped"); // create a new file because of caching issues.
|
||||
$tmpfname = tempnam(get_temp_dir(), "occCropped"); // create a new file because of caching issues.
|
||||
if($image->save($tmpfname)) {
|
||||
unlink($tmp_path);
|
||||
$card = OC_Contacts_App::getContactVCard($id);
|
||||
|
|
|
@ -67,7 +67,7 @@ if($error !== UPLOAD_ERR_OK) {
|
|||
}
|
||||
$file=$_FILES['importfile'];
|
||||
|
||||
$tmpfname = tempnam("/tmp", "occOrig");
|
||||
$tmpfname = tempnam(get_temp_dir(), "occOrig");
|
||||
if(file_exists($file['tmp_name'])) {
|
||||
if($view->file_put_contents('/'.$tmpfile, file_get_contents($file['tmp_name']))) {
|
||||
debug($fn.' uploaded');
|
||||
|
|
|
@ -46,7 +46,7 @@ if ($fn) {
|
|||
exit();
|
||||
}
|
||||
$id = $_GET['id'];
|
||||
$tmpfname = tempnam('/tmp', 'occOrig');
|
||||
$tmpfname = tempnam(get_temp_dir(), 'occOrig');
|
||||
file_put_contents($tmpfname, file_get_contents('php://input'));
|
||||
debug($tmpfname.' uploaded');
|
||||
$image = new OC_Image();
|
||||
|
@ -93,7 +93,7 @@ if($error !== UPLOAD_ERR_OK) {
|
|||
}
|
||||
$file=$_FILES['imagefile'];
|
||||
|
||||
$tmpfname = tempnam("/tmp", "occOrig");
|
||||
$tmpfname = tempnam(get_temp_dir(), "occOrig");
|
||||
if(file_exists($file['tmp_name'])) {
|
||||
$image = new OC_Image();
|
||||
if($image->loadFromFile($file['tmp_name'])) {
|
||||
|
|
|
@ -11,6 +11,7 @@ ob_start();
|
|||
OCP\JSON::checkLoggedIn();
|
||||
OCP\App::checkAppEnabled('contacts');
|
||||
$nl = "\n";
|
||||
|
||||
$progressfile = 'import_tmp/' . md5(session_id()) . '.txt';
|
||||
|
||||
function writeProgress($pct) {
|
||||
|
@ -48,78 +49,46 @@ if(isset($_POST['method']) && $_POST['method'] == 'new'){
|
|||
OC_Contacts_App::getAddressbook($id); // is owner access check
|
||||
}
|
||||
//analyse the contacts file
|
||||
writeProgress('20');
|
||||
$searchfor = array('VCARD');
|
||||
$parts = $searchfor;
|
||||
$filearr = explode($nl, $file);
|
||||
writeProgress('40');
|
||||
$lines = explode($nl, $file);
|
||||
$inelement = false;
|
||||
$parts = array();
|
||||
$i = 0;
|
||||
foreach($filearr as $line){
|
||||
foreach($searchfor as $search){
|
||||
if(substr_count($line, $search) == 1){
|
||||
list($attr, $val) = explode(':', $line);
|
||||
if($attr == 'BEGIN'){
|
||||
$parts[]['begin'] = $i;
|
||||
$inelement = true;
|
||||
}
|
||||
if($attr == 'END'){
|
||||
$parts[count($parts) - 1]['end'] = $i;
|
||||
$inelement = false;
|
||||
}
|
||||
}
|
||||
$card = array();
|
||||
foreach($lines as $line){
|
||||
if(strtoupper(trim($line)) == 'BEGIN:VCARD'){
|
||||
$inelement = true;
|
||||
} elseif (strtoupper(trim($line)) == 'END:VCARD') {
|
||||
$card[] = $line;
|
||||
$parts[] = implode($nl, $card);
|
||||
$card = array();
|
||||
$inelement = false;
|
||||
}
|
||||
if ($inelement === true && trim($line) != '') {
|
||||
$card[] = $line;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
//import the contacts
|
||||
writeProgress('40');
|
||||
$start = '';
|
||||
for ($i = 0; $i < $parts[0]['begin']; $i++) {
|
||||
if($i == 0){
|
||||
$start = $filearr[0];
|
||||
}else{
|
||||
$start .= $nl . $filearr[$i];
|
||||
}
|
||||
}
|
||||
$end = '';
|
||||
for($i = $parts[count($parts) - 1]['end'] + 1;$i <= count($filearr) - 1; $i++){
|
||||
if($i == $parts[count($parts) - 1]['end'] + 1){
|
||||
$end = $filearr[$parts[count($parts) - 1]['end'] + 1];
|
||||
}else{
|
||||
$end .= $nl . $filearr[$i];
|
||||
}
|
||||
}
|
||||
writeProgress('50');
|
||||
$importready = array();
|
||||
foreach($parts as $part){
|
||||
for($i = $part['begin']; $i <= $part['end'];$i++){
|
||||
if($i == $part['begin']){
|
||||
$content = $filearr[$i];
|
||||
}else{
|
||||
$content .= $nl . $filearr[$i];
|
||||
}
|
||||
}
|
||||
$importready[] = $start . $nl . $content . $nl . $end;
|
||||
}
|
||||
writeProgress('70');
|
||||
if(count($parts) == 1){
|
||||
$importready = array($file);
|
||||
}
|
||||
$imported = 0;
|
||||
$failed = 0;
|
||||
if(!count($importready) > 0) {
|
||||
if(!count($parts) > 0) {
|
||||
OCP\JSON::error(array('message' => 'No contacts to import in .'.$_POST['file'].' Please check if the file is corrupted.'));
|
||||
exit();
|
||||
}
|
||||
foreach($importready as $import){
|
||||
$card = OC_VObject::parse($import);
|
||||
foreach($parts as $part){
|
||||
$card = OC_VObject::parse($part);
|
||||
if (!$card) {
|
||||
$failed += 1;
|
||||
OCP\Util::writeLog('contacts','Import: skipping card. Error parsing VCard: '.$import, OCP\Util::ERROR);
|
||||
OCP\Util::writeLog('contacts','Import: skipping card. Error parsing VCard: '.$part, OCP\Util::ERROR);
|
||||
continue; // Ditch cards that can't be parsed by Sabre.
|
||||
}
|
||||
$imported += 1;
|
||||
OC_Contacts_VCard::add($id, $card);
|
||||
try {
|
||||
OC_Contacts_VCard::add($id, $card);
|
||||
$imported += 1;
|
||||
} catch (Exception $e) {
|
||||
OCP\Util::writeLog('contacts', 'Error importing vcard: '.$e->getMessage().$nl.$card, OCP\Util::ERROR);
|
||||
$failed += 1;
|
||||
}
|
||||
}
|
||||
//done the import
|
||||
writeProgress('100');
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<p><label for="ldap_port"><?php echo $l->t('Port');?></label><input type="text" id="ldap_port" name="ldap_port" value="<?php echo $_['ldap_port']; ?>" /></p>
|
||||
<p><label for="ldap_base_users"><?php echo $l->t('Base User Tree');?></label><input type="text" id="ldap_base_users" name="ldap_base_users" value="<?php echo $_['ldap_base_users']; ?>" /></p>
|
||||
<p><label for="ldap_base_groups"><?php echo $l->t('Base Group Tree');?></label><input type="text" id="ldap_base_groups" name="ldap_base_groups" value="<?php echo $_['ldap_base_groups']; ?>" /></p>
|
||||
<p><label for="ldap_group_member_assoc_attribute"><?php echo $l->t('Group-Member association');?></label><select id="ldap_group_member_assoc_attribute" name="ldap_group_member_assoc_attribute"><option value="uniqueMember"<?php if (isset($_['ldap_group_member_assoc_attribute']) && ($_['ldap_group_member_assoc_attribute'] == 'uniqueMember')) echo ' selected'; ?>>uniqueMember</option><option value="memberUid"<?php if (isset($_['ldap_group_member_assoc_attribute']) && ($_['ldap_group_member_assoc_attribute'] == 'memberUid')) echo ' selected'; ?>>memberUid</option><option value="memberUid"<?php if (isset($_['ldap_group_member_assoc_attribute']) && ($_['ldap_group_member_assoc_attribute'] == 'member')) echo ' selected'; ?>>member (AD)</option></select></p>
|
||||
<p><label for="ldap_group_member_assoc_attribute"><?php echo $l->t('Group-Member association');?></label><select id="ldap_group_member_assoc_attribute" name="ldap_group_member_assoc_attribute"><option value="uniqueMember"<?php if (isset($_['ldap_group_member_assoc_attribute']) && ($_['ldap_group_member_assoc_attribute'] == 'uniqueMember')) echo ' selected'; ?>>uniqueMember</option><option value="memberUid"<?php if (isset($_['ldap_group_member_assoc_attribute']) && ($_['ldap_group_member_assoc_attribute'] == 'memberUid')) echo ' selected'; ?>>memberUid</option><option value="member"<?php if (isset($_['ldap_group_member_assoc_attribute']) && ($_['ldap_group_member_assoc_attribute'] == 'member')) echo ' selected'; ?>>member (AD)</option></select></p>
|
||||
<p><input type="checkbox" id="ldap_tls" name="ldap_tls" value="1"<?php if ($_['ldap_tls']) echo ' checked'; ?>><label for="ldap_tls"><?php echo $l->t('Use TLS');?></label></p>
|
||||
<p><input type="checkbox" id="ldap_nocase" name="ldap_nocase" value="1"<?php if (isset($_['ldap_nocase']) && ($_['ldap_nocase'])) echo ' checked'; ?>><label for="ldap_nocase"><?php echo $l->t('Case insensitve LDAP server (Windows)');?></label></p>
|
||||
<p><label for="ldap_display_name"><?php echo $l->t('Display Name Field');?></label><input type="text" id="ldap_display_name" name="ldap_display_name" value="<?php echo $_['ldap_display_name']; ?>" />
|
||||
|
|
|
@ -514,7 +514,7 @@ class OC_Helper {
|
|||
* remove all files created by self::tmpFile
|
||||
*/
|
||||
public static function cleanTmp(){
|
||||
$leftoversFile='/tmp/oc-not-deleted';
|
||||
$leftoversFile=get_temp_dir().'/oc-not-deleted';
|
||||
if(file_exists($leftoversFile)){
|
||||
$leftovers=file($leftoversFile);
|
||||
foreach($leftovers as $file) {
|
||||
|
|
|
@ -146,7 +146,7 @@ class OC_Migrate{
|
|||
case 'instance':
|
||||
self::$content = new OC_Migration_Content( self::$zip );
|
||||
// Creates a zip that is compatable with the import function
|
||||
$dbfile = tempnam( "/tmp", "owncloud_export_data_" );
|
||||
$dbfile = tempnam( get_temp_dir(), "owncloud_export_data_" );
|
||||
OC_DB::getDbStructure( $dbfile, 'MDB2_SCHEMA_DUMP_ALL');
|
||||
|
||||
// Now add in *dbname* and *dbprefix*
|
||||
|
|
Loading…
Reference in a new issue