Code Duplication    Length = 42-42 lines in 2 locations

mail/inc/class.mail_ui.inc.php 2 locations

@@ 4347-4388 (lines=42) @@
4344
	 * @param string $selectedFolder seleted(active) folder by nm filter
4345
	 * @return nothing
4346
	 */
4347
	function ajax_emptySpam($icServerID, $selectedFolder)
4348
	{
4349
		//error_log(__METHOD__.__LINE__.' '.$icServerID);
4350
		Api\Translation::add_app('mail');
4351
		$response = Api\Json\Response::get();
4352
		$rememberServerID = $this->mail_bo->profileID;
4353
		if ($icServerID && $icServerID != $this->mail_bo->profileID)
4354
		{
4355
			//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
4356
			$this->changeProfile($icServerID);
4357
		}
4358
		$junkFolder = $this->mail_bo->getJunkFolder();
4359
		if(!empty($junkFolder)) {
4360
			if ($selectedFolder == $icServerID.self::$delimiter.$junkFolder)
4361
			{
4362
				// Lock the tree if the active folder is junk folder
4363
				$response->call('app.mail.lock_tree');
4364
			}
4365
			$this->mail_bo->deleteMessages('all',$junkFolder,'remove_immediately');
4366
4367
			$heirarchyDelimeter = $this->mail_bo->getHierarchyDelimiter(true);
4368
			$fShortName =  array_pop(explode($heirarchyDelimeter, $junkFolder));
4369
			$fStatus = array(
4370
				$icServerID.self::$delimiter.$junkFolder => lang($fShortName)
4371
			);
4372
			//Call to reset folder status counter, after junkFolder triggered not from Junk folder
4373
			//-as we don't have junk folder specific information available on client-side we need to deal with it on server
4374
			$response->call('app.mail.mail_setFolderStatus',$fStatus);
4375
		}
4376
		if ($rememberServerID != $this->mail_bo->profileID)
4377
		{
4378
			$oldFolderInfo = $this->mail_bo->getFolderStatus($junkFolder,false,false,false);
4379
			$response->call('egw.message',lang('empty junk'));
4380
			$response->call('app.mail.mail_reloadNode',array($icServerID.self::$delimiter.$junkFolder=>$oldFolderInfo['shortDisplayName']));
4381
			//error_log(__METHOD__.__LINE__.' change Profile to ->'.$rememberServerID);
4382
			$this->changeProfile($rememberServerID);
4383
		}
4384
		else if ($selectedFolder == $icServerID.self::$delimiter.$junkFolder)
4385
		{
4386
			$response->call('egw.refresh',lang('empty junk'),'mail');
4387
		}
4388
	}
4389
4390
	/**
4391
	 * Empty trash folder
@@ 4397-4438 (lines=42) @@
4394
	 * @param string $selectedFolder seleted(active) folder by nm filter
4395
	 * @return nothing
4396
	 */
4397
	function ajax_emptyTrash($icServerID, $selectedFolder)
4398
	{
4399
		//error_log(__METHOD__.__LINE__.' '.$icServerID);
4400
		Api\Translation::add_app('mail');
4401
		$response = Api\Json\Response::get();
4402
		$rememberServerID = $this->mail_bo->profileID;
4403
		if ($icServerID && $icServerID != $this->mail_bo->profileID)
4404
		{
4405
			//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
4406
			$this->changeProfile($icServerID);
4407
		}
4408
		$trashFolder = $this->mail_bo->getTrashFolder();
4409
		if(!empty($trashFolder)) {
4410
			if ($selectedFolder == $icServerID.self::$delimiter.$trashFolder)
4411
			{
4412
				// Lock the tree if the active folder is Trash folder
4413
				$response->call('app.mail.lock_tree');
4414
			}
4415
			$this->mail_bo->compressFolder($trashFolder);
4416
4417
			$heirarchyDelimeter = $this->mail_bo->getHierarchyDelimiter(true);
4418
			$fShortName =  array_pop(explode($heirarchyDelimeter, $trashFolder));
4419
			$fStatus = array(
4420
				$icServerID.self::$delimiter.$trashFolder => lang($fShortName)
4421
			);
4422
			//Call to reset folder status counter, after emptyTrash triggered not from Trash folder
4423
			//-as we don't have trash folder specific information available on client-side we need to deal with it on server
4424
			$response->call('app.mail.mail_setFolderStatus',$fStatus);
4425
		}
4426
		if ($rememberServerID != $this->mail_bo->profileID)
4427
		{
4428
			$oldFolderInfo = $this->mail_bo->getFolderStatus($trashFolder,false,false,false);
4429
			$response->call('egw.message',lang('empty trash'));
4430
			$response->call('app.mail.mail_reloadNode',array($icServerID.self::$delimiter.$trashFolder=>$oldFolderInfo['shortDisplayName']));
4431
			//error_log(__METHOD__.__LINE__.' change Profile to ->'.$rememberServerID);
4432
			$this->changeProfile($rememberServerID);
4433
		}
4434
		else if ($selectedFolder == $icServerID.self::$delimiter.$trashFolder)
4435
		{
4436
			$response->call('egw.refresh',lang('empty trash'),'mail');
4437
		}
4438
	}
4439
4440
	/**
4441
	 * compress folder - its called via json, so the function must start with ajax (or the class-name must contain ajax)