Anonymous Login
2019-06-19 05:46 PDT

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0001279v3.0 Release[All Projects] Generalpublic2013-08-28 11:17
Reportercarlosazevedo 
Assigned Tocaseydk 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionfixed 
Product Version 
Target VersionFixed in Version3.0.0 
Summary0001279: FIX: When a user is deleted its contact info is not. Fixes 0000686 and 0001260
DescriptionThis fix makes it so that when an user is deleted its contact info is also deleted. Also, I don't see the point of keeping it for 'history purposes' as the code states. So this involves changes in 'contacts.class.php' in the 'contacts' module and 'do_user_aed.php' in the 'admin' module.

contacts.class.php
------------------
        $custom_fields->store($this->contact_id); // Store Custom Fields

        parent::hook_postStore();
    }

+ protected function hook_postDelete()
+ {
+ // Delete contact methods belonging to the contact
+ $q = $this->_getQuery();
+ $q->setDelete('contacts_methods');
+ $q->addWhere('contact_id=' . (int) $this->contact_id);
+ $q->exec();
+ $q->clear();
+
+ // Delete custom fields belonging to the contact
+ $custom_fields = new w2p_Core_CustomFields('contacts', 'addedit', $this->contact_id, 'delete');
+ foreach ($custom_fields->fields as $key => $notUsed) {
        +$custom_fields->deleteField($custom_fields->fields[$key]->field_id);
+ }
+
+ parent::hook_postDelete();
+ }
+
    /*
     * This is an ugly bit of code that should handle *both* data structures..

do_user_aed.php
---------------

$obj->user_username = strtolower($obj->user_username);

-// !User's contact information not deleted - left for history.
if ($del) {
+ // Load the contact object to be able to delete it later
+ $contact->findContactByUserid($user_id);
+ // Delete the user row first to orphan the contact from it.
+ // Otherwise the contact's canDelete method would prevent its deletion.
+ $result = $obj->delete();
+ if ($result) {
+ $result = $contact->delete();
+ }
- $result = $contact->delete();
    $message = ($result) ? 'User deleted' : $obj->getError();

TagsNo tags attached.
Attached Files

-Relationships
+Relationships

-Notes

~0002855

caseydk (administrator)

Resolved differently than described:
https://github.com/web2project/web2project/commit/93ddcfcc0ff6d70b7d4281beae05cf2e3fc33106
https://github.com/web2project/web2project/commit/69afad9783c29b5725a17015097710db0c1e4691
refactored into:
https://github.com/web2project/web2project/commit/db6e968c117130b2c1bb934eea9421a2252a3a2f

This does not address 0001260 but does address a valid issue where we weren't cleaning up after ourselves for Custom Fields.

Also, 0000686 is not a bug and is by design, so it has been closed as a result.
+Notes

-Issue History
Date Modified Username Field Change
2013-03-05 06:12 carlosazevedo New Issue
2013-03-16 21:57 caseydk Note Added: 0002855
2013-03-16 21:57 caseydk Status new => resolved
2013-03-16 21:57 caseydk Resolution open => fixed
2013-03-16 21:57 caseydk Assigned To => caseydk
2013-08-28 11:14 caseydk Fixed in Version => 3.0.0
2013-08-28 11:17 caseydk Status resolved => closed
+Issue History