Code Duplication    Length = 42-42 lines in 2 locations

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

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