<?php
/**
  * Ahead WebSoft Technologies Pvt Ltd.
  * @copyright  Copyright 2006-2026 Ahead WebSoft Technologies Pvt Ltd.
  * @license    https://www.socialengine.com/policies
*/

class User_Plugin_Task_Autosuspend extends Core_Plugin_Task_Abstract
{
	public function execute()
	{
		//Auto Suspend user
		if (Engine_Api::_()->getApi('settings', 'core')->getSetting('user.signup.enabletwostep', 0) && Engine_Api::_()->getApi('settings', 'core')->getSetting('user.signup.autoaccountsuspend', 0)) {
			$days = Engine_Api::_()->getApi('settings', 'core')->getSetting('user.signup.autoaccountsuspendday', 20);
			$pastdate =  date('Y-m-d', strtotime('-' . $days . ' days'));
			$todaydate =  date('Y-m-d');
			$db = Engine_Db_Table::getDefaultAdapter();
			$db->query("UPDATE `engine4_users` SET approved = '0' WHERE `user_id` IN (SELECT `user_id` from engine4_users WHERE (verified ='0')  AND (level_id NOT IN (1)) AND (DATE(creation_date) between ('$pastdate') and ('$todaydate')));");
		}
	}
}
