Code Duplication    Length = 42-42 lines in 2 locations

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

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