Code Duplication    Length = 42-42 lines in 2 locations

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

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