delete() public method

public delete ( )
示例#1
0
 function deleteBase($formvars = array())
 {
     global $SERVER_EXTENSIONS;
     $mdb = $this->mdb;
     // add all missing keys to array
     fixFormVars($formvars, array('IDbase'));
     $this->notifs['base_deleted'] = true;
     $mdb->delete('base_client', "IDbase = %i AND IDbase IN (SELECT IDbase FROM base WHERE IDaccount = %i)", $formvars['IDbase'], $_SESSION['IDaccount']);
     $mdb->delete('txserver2base', "IDbase = %i AND IDbase IN (SELECT IDbase FROM base WHERE IDaccount = %i)", $formvars['IDbase'], $_SESSION['IDaccount']);
     // security check for log file deletion
     $base = $mdb->queryFirstRow("SELECT IDbase FROM base WHERE IDbase = %i AND IDaccount = %i", $formvars['IDbase'], $_SESSION['IDaccount']);
     if (count($base) !== NULL) {
         $path = server_basesock_log_path;
         $file = $path . $base['IDbase'] . '.json';
         if (file_exists($file)) {
             unlink($file);
         }
     }
     // Handle Server Extensions deletion
     // first lets check if we own this IDbase... easiest way, not the smartest
     $is_my_base = $this->getBase($formvars['IDbase']);
     if (count($is_my_base) == 1) {
         // Android GCM is here?
         if (isset($SERVER_EXTENSIONS['se_android_gcm']) && $SERVER_EXTENSIONS['se_android_gcm']['enabled'] == 1) {
             $se_mdb = new MeekroDB(mysql_host, mysql_username, mysql_password, $SERVER_EXTENSIONS['se_android_gcm']['mysql_database']);
             $se_mdb->delete('base_config', "IDbase = %i", $formvars['IDbase']);
         }
     }
     // Lastly delete the Base record
     $mdb->delete('base', "IDbase = %i AND IDaccount = %i", $formvars['IDbase'], $_SESSION['IDaccount']);
 }