Code Duplication    Length = 42-42 lines in 2 locations

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

@@ 4491-4532 (lines=42) @@
4488
	 * @param string $selectedFolder seleted(active) folder by nm filter
4489
	 * @return nothing
4490
	 */
4491
	function ajax_emptySpam($icServerID, $selectedFolder)
4492
	{
4493
		//error_log(__METHOD__.__LINE__.' '.$icServerID);
4494
		Api\Translation::add_app('mail');
4495
		$response = Api\Json\Response::get();
4496
		$rememberServerID = $this->mail_bo->profileID;
4497
		if ($icServerID && $icServerID != $this->mail_bo->profileID)
4498
		{
4499
			//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
4500
			$this->changeProfile($icServerID);
4501
		}
4502
		$junkFolder = $this->mail_bo->getJunkFolder();
4503
		if(!empty($junkFolder)) {
4504
			if ($selectedFolder == $icServerID.self::$delimiter.$junkFolder)
4505
			{
4506
				// Lock the tree if the active folder is junk folder
4507
				$response->call('app.mail.lock_tree');
4508
			}
4509
			$this->mail_bo->deleteMessages('all',$junkFolder,'remove_immediately');
4510
4511
			$heirarchyDelimeter = $this->mail_bo->getHierarchyDelimiter(true);
4512
			$fShortName =  array_pop(explode($heirarchyDelimeter, $junkFolder));
4513
			$fStatus = array(
4514
				$icServerID.self::$delimiter.$junkFolder => lang($fShortName)
4515
			);
4516
			//Call to reset folder status counter, after junkFolder triggered not from Junk folder
4517
			//-as we don't have junk folder specific information available on client-side we need to deal with it on server
4518
			$response->call('app.mail.mail_setFolderStatus',$fStatus);
4519
		}
4520
		if ($rememberServerID != $this->mail_bo->profileID)
4521
		{
4522
			$oldFolderInfo = $this->mail_bo->getFolderStatus($junkFolder,false,false,false);
4523
			$response->call('egw.message',lang('empty junk'));
4524
			$response->call('app.mail.mail_reloadNode',array($icServerID.self::$delimiter.$junkFolder=>$oldFolderInfo['shortDisplayName']));
4525
			//error_log(__METHOD__.__LINE__.' change Profile to ->'.$rememberServerID);
4526
			$this->changeProfile($rememberServerID);
4527
		}
4528
		else if ($selectedFolder == $icServerID.self::$delimiter.$junkFolder)
4529
		{
4530
			$response->call('egw.refresh',lang('empty junk'),'mail');
4531
		}
4532
	}
4533
4534
	/**
4535
	 * Empty trash folder
@@ 4541-4582 (lines=42) @@
4538
	 * @param string $selectedFolder seleted(active) folder by nm filter
4539
	 * @return nothing
4540
	 */
4541
	function ajax_emptyTrash($icServerID, $selectedFolder)
4542
	{
4543
		//error_log(__METHOD__.__LINE__.' '.$icServerID);
4544
		Api\Translation::add_app('mail');
4545
		$response = Api\Json\Response::get();
4546
		$rememberServerID = $this->mail_bo->profileID;
4547
		if ($icServerID && $icServerID != $this->mail_bo->profileID)
4548
		{
4549
			//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
4550
			$this->changeProfile($icServerID);
4551
		}
4552
		$trashFolder = $this->mail_bo->getTrashFolder();
4553
		if(!empty($trashFolder)) {
4554
			if ($selectedFolder == $icServerID.self::$delimiter.$trashFolder)
4555
			{
4556
				// Lock the tree if the active folder is Trash folder
4557
				$response->call('app.mail.lock_tree');
4558
			}
4559
			$this->mail_bo->compressFolder($trashFolder);
4560
4561
			$heirarchyDelimeter = $this->mail_bo->getHierarchyDelimiter(true);
4562
			$fShortName =  array_pop(explode($heirarchyDelimeter, $trashFolder));
4563
			$fStatus = array(
4564
				$icServerID.self::$delimiter.$trashFolder => lang($fShortName)
4565
			);
4566
			//Call to reset folder status counter, after emptyTrash triggered not from Trash folder
4567
			//-as we don't have trash folder specific information available on client-side we need to deal with it on server
4568
			$response->call('app.mail.mail_setFolderStatus',$fStatus);
4569
		}
4570
		if ($rememberServerID != $this->mail_bo->profileID)
4571
		{
4572
			$oldFolderInfo = $this->mail_bo->getFolderStatus($trashFolder,false,false,false);
4573
			$response->call('egw.message',lang('empty trash'));
4574
			$response->call('app.mail.mail_reloadNode',array($icServerID.self::$delimiter.$trashFolder=>$oldFolderInfo['shortDisplayName']));
4575
			//error_log(__METHOD__.__LINE__.' change Profile to ->'.$rememberServerID);
4576
			$this->changeProfile($rememberServerID);
4577
		}
4578
		else if ($selectedFolder == $icServerID.self::$delimiter.$trashFolder)
4579
		{
4580
			$response->call('egw.refresh',lang('empty trash'),'mail');
4581
		}
4582
	}
4583
4584
	/**
4585
	 * compress folder - its called via json, so the function must start with ajax (or the class-name must contain ajax)