/** * Deletes the selected field and all references in other tables. * Also the gap in sequence will be closed. After that the class will be initialize. * @return void|true true if no error occurred */ public function delete() { global $gCurrentSession; $this->db->startTransaction(); // close gap in sequence $sql = 'UPDATE ' . TBL_USER_FIELDS . ' SET usf_sequence = usf_sequence - 1 WHERE usf_cat_id = ' . $this->getValue('usf_cat_id') . ' AND usf_sequence > ' . $this->getValue('usf_sequence'); $this->db->query($sql); // close gap in sequence of saved lists $sql = 'SELECT lsc_lst_id, lsc_number FROM ' . TBL_LIST_COLUMNS . ' WHERE lsc_usf_id = ' . $this->getValue('usf_id'); $listsStatement = $this->db->query($sql); while ($row_lst = $listsStatement->fetch()) { $sql = 'UPDATE ' . TBL_LIST_COLUMNS . ' SET lsc_number = lsc_number - 1 WHERE lsc_lst_id = ' . $row_lst['lsc_lst_id'] . ' AND lsc_number > ' . $row_lst['lsc_number']; $this->db->query($sql); } // delete all dependencies in other tables $sql = 'DELETE FROM ' . TBL_USER_LOG . ' WHERE usl_usf_id = ' . $this->getValue('usf_id'); $this->db->query($sql); $sql = 'DELETE FROM ' . TBL_USER_DATA . ' WHERE usd_usf_id = ' . $this->getValue('usf_id'); $this->db->query($sql); $sql = 'DELETE FROM ' . TBL_LIST_COLUMNS . ' WHERE lsc_usf_id = ' . $this->getValue('usf_id'); $this->db->query($sql); // all active users must renew their user data because the user field structure has been changed $gCurrentSession->renewUserObject(); $return = parent::delete(); $this->db->endTransaction(); return $return; }
/** * Deletes the selected record of the table and the associated file in the file system. * After that the class will be initialize. * @return bool @b true if no error occurred */ public function delete() { @chmod($this->getCompletePathOfFile(), 0777); @unlink($this->getCompletePathOfFile()); // Auch wenn das Loeschen nicht klappt wird true zurueckgegeben, // damit der Eintrag aus der DB verschwindet. return parent::delete(); }
/** * Deletes the selected item of the table and all the many references in other tables. * After that the class will be initialize. * @return bool @b true if no error occurred */ public function delete() { $this->db->startTransaction(); $sql = 'DELETE FROM ' . TBL_INVENT_DATA . ' WHERE ind_itm_id = ' . $this->getValue('inv_id'); $this->db->query($sql); $return = parent::delete(); $this->db->endTransaction(); return $return; }
/** * Deletes the selected guestbook entry and all comments. * After that the class will be initialize. * @return @b true if no error occurred */ public function delete() { $this->db->startTransaction(); // erst einmal alle vorhanden Kommentare zu diesem Gaestebucheintrag loeschen... $sql = 'DELETE FROM ' . TBL_GUESTBOOK_COMMENTS . ' WHERE gbc_gbo_id = ' . $this->getValue('gbo_id'); $result = $this->db->query($sql); $return = parent::delete(); $this->db->endTransaction(); return $return; }
/** Deletes the selected list with all associated fields. * After that the class will be initialize. * @return @b true if no error occurred */ public function delete() { $this->db->startTransaction(); // alle Spalten der Liste loeschen $sql = 'DELETE FROM ' . TBL_LIST_COLUMNS . ' WHERE lsc_lst_id = ' . $this->getValue('lst_id'); $result = $this->db->query($sql); $return = parent::delete(); $this->db->endTransaction(); return $return; }
/** * Deletes the selected list with all associated fields. * After that the class will be initialize. * @return @b true if no error occurred */ public function delete() { global $gPreferences; // if this list is the default configuration than it couldn't be deleted if ($this->getValue('lst_id') == $gPreferences['lists_default_configuation']) { throw new AdmException('LST_ERROR_DELETE_DEFAULT_LIST', $this->getValue('lst_name')); } $this->db->startTransaction(); // alle Spalten der Liste loeschen $sql = 'DELETE FROM ' . TBL_LIST_COLUMNS . ' WHERE lsc_lst_id = ' . $this->getValue('lst_id'); $result = $this->db->query($sql); $return = parent::delete(); $this->db->endTransaction(); return $return; }
/** * Deletes the selected field and all references in other tables. * Also the gap in sequence will be closed. After that the class will be initialize. * @return bool @b true if no error occurred */ public function delete() { $this->db->startTransaction(); // close gap in sequence $sql = 'UPDATE ' . TBL_INVENT_FIELDS . ' SET inf_sequence = inf_sequence - 1 WHERE inf_cat_id = ' . $this->getValue('inf_cat_id') . ' AND inf_sequence > ' . $this->getValue('inf_sequence'); $this->db->query($sql); $sql = 'DELETE FROM ' . TBL_INVENT_DATA . ' WHERE ind_inf_id = ' . $this->getValue('inf_id'); $this->db->query($sql); $return = parent::delete(); $this->db->endTransaction(); return $return; }
/** * Deletes the selected record of the table and all references in other tables. * After that the class will be initialize. * @return bool @b true if no error occurred */ public function delete() { $this->db->startTransaction(); $sql = 'DELETE FROM ' . TBL_DATE_ROLE . ' WHERE dtr_dat_id = ' . $this->getValue('dat_id'); $this->db->query($sql); // if date has participants then the role with their memberships must be deleted if ($this->getValue('dat_rol_id') > 0) { $sql = 'UPDATE ' . TBL_DATES . ' SET dat_rol_id = NULL WHERE dat_id = ' . $this->getValue('dat_id'); $this->db->query($sql); $dateRole = new TableRoles($this->db, $this->getValue('dat_rol_id')); $dateRole->delete(); } parent::delete(); return $this->db->endTransaction(); }
/** Deletes the selected record of the table and all references in other tables. * After that the class will be initialize. The method throws exceptions if * the category couldn't be deleted. * @return @b true if no error occurred */ public function delete() { global $gCurrentSession; // system-category couldn't be deleted if ($this->getValue('cat_system') == 1) { throw new AdmException('SYS_DELETE_SYSTEM_CATEGORY'); } // checks if there exists another category of this type. Don't delete the last category of a type! $sql = 'SELECT count(1) AS count_categories FROM ' . TBL_CATEGORIES . ' WHERE ( cat_org_id = ' . $gCurrentSession->getValue('ses_org_id') . ' OR cat_org_id IS NULL ) AND cat_type = \'' . $this->getValue('cat_type') . '\''; $result = $this->db->query($sql); $row = $this->db->fetch_array($result); if ($row['count_categories'] > 1) { $this->db->startTransaction(); // Luecke in der Reihenfolge schliessen $sql = 'UPDATE ' . TBL_CATEGORIES . ' SET cat_sequence = cat_sequence - 1 WHERE ( cat_org_id = ' . $gCurrentSession->getValue('ses_org_id') . ' OR cat_org_id IS NULL ) AND cat_sequence > ' . $this->getValue('cat_sequence') . ' AND cat_type = \'' . $this->getValue('cat_type') . '\''; $this->db->query($sql); // Abhaenigigkeiten loeschen if ($this->getValue('cat_type') == 'DAT') { $object = new TableDate($this->db); } elseif ($this->getValue('cat_type') == 'LNK') { $object = new TableWeblink($this->db); } elseif ($this->getValue('cat_type') == 'ROL') { $object = new TableRoles($this->db); } elseif ($this->getValue('cat_type') == 'USF') { $object = new TableUserField($this->db); } // alle zugehoerigen abhaengigen Objekte suchen und mit weiteren Abhaengigkeiten loeschen $sql = 'SELECT * FROM ' . $this->elementTable . ' WHERE ' . $this->elementColumn . ' = ' . $this->getValue('cat_id'); $resultRecordsets = $this->db->query($sql); if ($this->db->num_rows() > 0) { throw new AdmException('CAT_DONT_DELETE_CATEGORY', $this->getValue('cat_name'), $this->getNumberElements()); } $return = parent::delete(); $this->db->endTransaction(); return $return; } else { // Don't delete the last category of a type! throw new AdmException('SYS_DELETE_LAST_CATEGORY'); } }
/** * Deletes the selected role of the table and all references in other tables. * After that the class will be initialize. * @throws AdmException * @return bool @b true if no error occurred */ public function delete() { global $gCurrentSession, $gL10n, $gCurrentOrganization; if ($this->getValue('rol_default_registration') == 1) { // checks if at least one other role has this flag, if not than this role couldn't be deleted $sql = 'SELECT COUNT(*) AS count FROM ' . TBL_ROLES . ' INNER JOIN ' . TBL_CATEGORIES . ' ON cat_id = rol_cat_id WHERE rol_default_registration = 1 AND rol_id <> ' . $this->getValue('rol_id') . ' AND cat_org_id = ' . $gCurrentOrganization->getValue('org_id'); $countRolesStatement = $this->db->query($sql); $row = $countRolesStatement->fetch(); if ($row['count'] === 0) { throw new AdmException('ROL_DELETE_NO_DEFAULT_ROLE', $this->getValue('rol_name'), $gL10n->get('ROL_DEFAULT_REGISTRATION')); } } // users are not allowed to delete system roles if ($this->getValue('rol_system')) { throw new AdmException('ROL_DELETE_SYSTEM_ROLE', $this->getValue('rol_name')); } elseif ($this->getValue('rol_webmaster')) { throw new AdmException('ROL_DELETE_ROLE', $gL10n->get('SYS_WEBMASTER')); } else { $this->db->startTransaction(); $sql = 'DELETE FROM ' . TBL_ROLE_DEPENDENCIES . ' WHERE rld_rol_id_parent = ' . $this->getValue('rol_id') . ' OR rld_rol_id_child = ' . $this->getValue('rol_id'); $this->db->query($sql); $sql = 'DELETE FROM ' . TBL_MEMBERS . ' WHERE mem_rol_id = ' . $this->getValue('rol_id'); $this->db->query($sql); $sql = 'UPDATE ' . TBL_DATES . ' SET dat_rol_id = NULL WHERE dat_rol_id = ' . $this->getValue('rol_id'); $this->db->query($sql); $sql = 'DELETE FROM ' . TBL_DATE_ROLE . ' WHERE dtr_rol_id = ' . $this->getValue('rol_id'); $result = $this->db->query($sql); $sql = 'DELETE FROM ' . TBL_FOLDER_ROLES . ' WHERE flr_rol_id = ' . $this->getValue('rol_id'); $result = $this->db->query($sql); $return = parent::delete(); $this->db->endTransaction(); if (isset($gCurrentSession)) { // all active users must renew their user data because maybe their // rights have been changed if they where members of this role $gCurrentSession->renewUserObject(); } return $return; } }
/** Deletes the selected photo album and all sub photo albums. * After that the class will be initialize. * @return @b true if no error occurred */ public function delete() { if ($this->deleteInDatabase($this->getValue('pho_id'))) { return parent::delete(); } return false; }
/** * Deletes the selected user of the table and all the many references in other tables. * After that the class will be initialize. * @return true|void @b true if no error occurred */ public function delete() { global $gCurrentUser; $this->db->startTransaction(); $sql = 'UPDATE ' . TBL_ANNOUNCEMENTS . ' SET ann_usr_id_create = NULL WHERE ann_usr_id_create = ' . $this->getValue('usr_id'); $this->db->query($sql); $sql = 'UPDATE ' . TBL_ANNOUNCEMENTS . ' SET ann_usr_id_change = NULL WHERE ann_usr_id_change = ' . $this->getValue('usr_id'); $this->db->query($sql); $sql = 'UPDATE ' . TBL_DATES . ' SET dat_usr_id_create = NULL WHERE dat_usr_id_create = ' . $this->getValue('usr_id'); $this->db->query($sql); $sql = 'UPDATE ' . TBL_DATES . ' SET dat_usr_id_change = NULL WHERE dat_usr_id_change = ' . $this->getValue('usr_id'); $this->db->query($sql); $sql = 'UPDATE ' . TBL_FOLDERS . ' SET fol_usr_id = NULL WHERE fol_usr_id = ' . $this->getValue('usr_id'); $this->db->query($sql); $sql = 'UPDATE ' . TBL_FILES . ' SET fil_usr_id = NULL WHERE fil_usr_id = ' . $this->getValue('usr_id'); $this->db->query($sql); $sql = 'UPDATE ' . TBL_GUESTBOOK . ' SET gbo_usr_id_create = NULL WHERE gbo_usr_id_create = ' . $this->getValue('usr_id'); $this->db->query($sql); $sql = 'UPDATE ' . TBL_GUESTBOOK . ' SET gbo_usr_id_change = NULL WHERE gbo_usr_id_change = ' . $this->getValue('usr_id'); $this->db->query($sql); $sql = 'UPDATE ' . TBL_LINKS . ' SET lnk_usr_id_create = NULL WHERE lnk_usr_id_create = ' . $this->getValue('usr_id'); $this->db->query($sql); $sql = 'UPDATE ' . TBL_LINKS . ' SET lnk_usr_id_change = NULL WHERE lnk_usr_id_change = ' . $this->getValue('usr_id'); $this->db->query($sql); $sql = 'UPDATE ' . TBL_LISTS . ' SET lst_usr_id = NULL WHERE lst_global = 1 AND lst_usr_id = ' . $this->getValue('usr_id'); $this->db->query($sql); $sql = 'UPDATE ' . TBL_PHOTOS . ' SET pho_usr_id_create = NULL WHERE pho_usr_id_create = ' . $this->getValue('usr_id'); $this->db->query($sql); $sql = 'UPDATE ' . TBL_PHOTOS . ' SET pho_usr_id_change = NULL WHERE pho_usr_id_change = ' . $this->getValue('usr_id'); $this->db->query($sql); $sql = 'UPDATE ' . TBL_ROLES . ' SET rol_usr_id_create = NULL WHERE rol_usr_id_create = ' . $this->getValue('usr_id'); $this->db->query($sql); $sql = 'UPDATE ' . TBL_ROLES . ' SET rol_usr_id_change = NULL WHERE rol_usr_id_change = ' . $this->getValue('usr_id'); $this->db->query($sql); $sql = 'UPDATE ' . TBL_ROLE_DEPENDENCIES . ' SET rld_usr_id = NULL WHERE rld_usr_id = ' . $this->getValue('usr_id'); $this->db->query($sql); $sql = 'UPDATE ' . TBL_USER_LOG . ' SET usl_usr_id_create = NULL WHERE usl_usr_id_create = ' . $this->getValue('usr_id'); $this->db->query($sql); $sql = 'UPDATE ' . TBL_USERS . ' SET usr_usr_id_create = NULL WHERE usr_usr_id_create = ' . $this->getValue('usr_id'); $this->db->query($sql); $sql = 'UPDATE ' . TBL_USERS . ' SET usr_usr_id_change = NULL WHERE usr_usr_id_change = ' . $this->getValue('usr_id'); $this->db->query($sql); $sql = 'DELETE FROM ' . TBL_LIST_COLUMNS . ' WHERE lsc_lst_id IN (SELECT lst_id FROM ' . TBL_LISTS . ' WHERE lst_usr_id = ' . $this->getValue('usr_id') . ' AND lst_global = 0)'; $this->db->query($sql); $sql = 'DELETE FROM ' . TBL_LISTS . ' WHERE lst_global = 0 AND lst_usr_id = ' . $this->getValue('usr_id'); $this->db->query($sql); $sql = 'DELETE FROM ' . TBL_GUESTBOOK_COMMENTS . ' WHERE gbc_usr_id_create = ' . $this->getValue('usr_id'); $this->db->query($sql); $sql = 'DELETE FROM ' . TBL_MEMBERS . ' WHERE mem_usr_id = ' . $this->getValue('usr_id'); $this->db->query($sql); // MySQL couldn't create delete statement with same table in subquery. // Therefore we fill a temporary table with all ids that should be deleted and reference on this table $sql = 'DELETE FROM ' . TBL_IDS . ' WHERE ids_usr_id = ' . $gCurrentUser->getValue('usr_id'); $this->db->query($sql); $sql = 'INSERT INTO ' . TBL_IDS . ' (ids_usr_id, ids_reference_id) SELECT ' . $gCurrentUser->getValue('usr_id') . ', msc_msg_id FROM ' . TBL_MESSAGES_CONTENT . ' WHERE msc_usr_id = ' . $this->getValue('usr_id'); $this->db->query($sql); $sql = 'DELETE FROM ' . TBL_MESSAGES_CONTENT . ' WHERE msc_msg_id IN (SELECT ids_reference_id FROM ' . TBL_IDS . ' WHERE ids_usr_id = ' . $gCurrentUser->getValue('usr_id') . ')'; $this->db->query($sql); $sql = 'DELETE FROM ' . TBL_MESSAGES . ' WHERE msg_id IN (SELECT ids_reference_id FROM ' . TBL_IDS . ' WHERE ids_usr_id = ' . $gCurrentUser->getValue('usr_id') . ')'; $this->db->query($sql); $sql = 'DELETE FROM ' . TBL_IDS . ' WHERE ids_usr_id = ' . $gCurrentUser->getValue('usr_id'); $this->db->query($sql); $sql = 'DELETE FROM ' . TBL_REGISTRATIONS . ' WHERE reg_usr_id = ' . $this->getValue('usr_id'); $this->db->query($sql); $sql = 'DELETE FROM ' . TBL_AUTO_LOGIN . ' WHERE atl_usr_id = ' . $this->getValue('usr_id'); $this->db->query($sql); $sql = 'DELETE FROM ' . TBL_SESSIONS . ' WHERE ses_usr_id = ' . $this->getValue('usr_id'); $this->db->query($sql); $sql = 'DELETE FROM ' . TBL_USER_LOG . ' WHERE usl_usr_id = ' . $this->getValue('usr_id'); $this->db->query($sql); $sql = 'DELETE FROM ' . TBL_USER_DATA . ' WHERE usd_usr_id = ' . $this->getValue('usr_id'); $this->db->query($sql); $return = parent::delete(); $this->db->endTransaction(); return $return; }
/** Deletes the selected record of the table and all references in other tables. * Also all files, subfolders and the selected folder will be deleted in the file system. * After that the class will be initialize. * @return @b true if no error occurred */ public function delete($folderId = 0) { $returnCode = true; if ($folderId == 0) { $folderId = $this->getValue('fol_id'); if (!strlen($this->getValue('fol_name')) > 0) { return false; } $folderPath = $this->getCompletePathOfFolder(); } $this->db->startTransaction(); //Alle Unterordner auslesen, die im uebergebenen Verzeichnis enthalten sind $sql_subfolders = 'SELECT * FROM ' . TBL_FOLDERS . ' WHERE fol_fol_id_parent = ' . $folderId; $result_subfolders = $this->db->query($sql_subfolders); while ($row_subfolders = $this->db->fetch_object($result_subfolders)) { //rekursiver Aufruf mit jedem einzelnen Unterordner $this->delete($row_subfolders->fol_id); } //In der DB die Files der aktuellen folder_id loeschen $sql_delete_files = 'DELETE from ' . TBL_FILES . ' WHERE fil_fol_id = ' . $folderId; $this->db->query($sql_delete_files); //In der DB die verknuepften Berechtigungen zu dieser Folder_ID loeschen... $sql_delete_fol_rol = 'DELETE from ' . TBL_FOLDER_ROLES . ' WHERE flr_fol_id = ' . $folderId; $this->db->query($sql_delete_fol_rol); //In der DB den Eintrag des Ordners selber loeschen $sql_delete_folder = 'DELETE from ' . TBL_FOLDERS . ' WHERE fol_id = ' . $folderId; $this->db->query($sql_delete_folder); //Jetzt noch das Verzeichnis physikalisch von der Platte loeschen if (isset($folderPath)) { $this->folderPath->setFolder($folderPath); $this->folderPath->delete($folderPath); } //Auch wenn das physikalische Löschen fehl schlägt, wird in der DB alles gelöscht... if ($folderId == $this->getValue('fol_id')) { $returnCode = parent::delete(); } $this->db->endTransaction(); return $returnCode; }
/** * Deletes the selected message with all associated fields. * After that the class will be initialize. * @return bool @b true if message is deleted or message with additional information if it is marked * for other user to delete. On error it is false */ public function delete() { global $gCurrentUser; $this->db->startTransaction(); if ($this->getValue('msg_read') == 2 || $this->getValue('msg_type') === 'EMAIL') { $sql = 'DELETE FROM ' . TBL_MESSAGES_CONTENT . ' WHERE msc_msg_id = ' . $this->getValue('msg_id'); $this->db->query($sql); parent::delete(); } else { $other = $this->getValue('msg_usr_id_sender'); if ($other == $gCurrentUser->getValue('usr_id')) { $other = $this->getValue('msg_usr_id_receiver'); } $sql = "UPDATE " . TBL_MESSAGES . " SET msg_read = 2, msg_timestamp = CURRENT_TIMESTAMP\n , msg_usr_id_sender = " . $gCurrentUser->getValue('usr_id') . ", msg_usr_id_receiver = '" . $other . "'\n WHERE msg_id = " . $this->getValue('msg_id'); $this->db->query($sql); } $this->db->endTransaction(); return true; }