Code Duplication    Length = 42-42 lines in 2 locations

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

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