Exemplo n.º 1
0
 /** delete sub account */
 function sub_delete($VAR)
 {
     // return false;
     // verify perms
     if (empty($VAR['id']) || !$this->isParentAccount($VAR['id'])) {
         return false;
     }
     // ok, do deletion
     include_once PATH_MODULES . 'account_admin/account_admin.inc.php';
     $aa = new account_admin();
     $VAR['account_admin_id'] = $VAR['id'];
     $aa->delete($VAR);
 }
Exemplo n.º 2
0
 /**
  *  Loop though all accounts to delete inactive accounts with no 
  * invoices, services, and no staff or affiliate accts 
  */
 function account_cleanup($VAR)
 {
     # Load the account admin class
     include_once PATH_MODULES . 'account_admin/account_admin.inc.php';
     $acct = new account_admin();
     # Get each account:
     $time = time() - AGILE_ACCOUNT_CLEANUP_DAYS * 86400;
     $db =& DB();
     $db->SetFetchMode(ADODB_FETCH_ASSOC);
     $sql = 'SELECT id,username,email,first_name,last_name,company FROM ' . AGILE_DB_PREFIX . 'account WHERE date_orig <= ' . $time . ' AND id>1 AND site_id = ' . DEFAULT_SITE . ' ORDER BY id';
     $rs = $db->Execute($sql);
     echo "Accounts Deleted:<pre>";
     while (!$rs->EOF) {
         # Get acct id
         $id = $rs->fields['id'];
         $do = true;
         # Check for staff/admin account
         if ($do) {
             $sql = 'SELECT id FROM ' . AGILE_DB_PREFIX . 'account_group WHERE group_id in (4,1001) AND AND account_id=' . $id . ' site_id = ' . $db->qstr(DEFAULT_SITE);
             $rs2 = $db->Execute($sql);
             if ($rs2 && $rs2->RecordCount()) {
                 $do = false;
             }
         }
         # Check for invoices
         if ($do) {
             $sql = 'SELECT id FROM ' . AGILE_DB_PREFIX . 'invoice WHERE account_id =  ' . $db->qstr($id) . ' AND site_id = ' . $db->qstr(DEFAULT_SITE);
             $rs2 = $db->Execute($sql);
             if ($rs2 && $rs2->RecordCount()) {
                 $do = false;
             }
         }
         # Check for services
         if ($do) {
             $sql = 'SELECT id FROM ' . AGILE_DB_PREFIX . 'service WHERE account_id =  ' . $db->qstr($id) . ' AND site_id = ' . $db->qstr(DEFAULT_SITE);
             $rs2 = $db->Execute($sql);
             if ($rs2 && $rs2->RecordCount()) {
                 $do = false;
             }
         }
         # Check for affiliate acct
         if ($do) {
             $sql = 'SELECT id FROM ' . AGILE_DB_PREFIX . 'affiliate WHERE account_id =  ' . $db->qstr($id) . ' AND site_id = ' . $db->qstr(DEFAULT_SITE);
             $rs2 = $db->Execute($sql);
             if ($rs2 && $rs2->RecordCount()) {
                 $do = false;
             }
         }
         # Check for staff acct
         if ($do) {
             $sql = 'SELECT id FROM ' . AGILE_DB_PREFIX . 'staff WHERE account_id =  ' . $db->qstr($id) . ' AND site_id = ' . $db->qstr(DEFAULT_SITE);
             $rs2 = $db->Execute($sql);
             if ($rs2 && $rs2->RecordCount()) {
                 $do = false;
             }
         }
         # Delete the account
         if ($do) {
             $arr['id'] = $id;
             foreach ($rs->fields as $v) {
                 echo "{$v}\t";
             }
             echo "\r\n";
             $acct->delete($arr, $acct);
         }
         $rs->MoveNext();
     }
     echo "</pre>";
 }