/** * Marks library card for deletion so that it can be recovered easily. * * @param UserCard $userCard * @param boolean $shouldBeDeleted */ public function setLibCardDeletionFlag(UserCard $userCard, $shouldBeDeleted) { $eppn = $userCard->eppn; if ($shouldBeDeleted) { $userCard->eppn = "DEL_{$eppn}"; } elseif (substr($eppn, 0, 4) === 'DEL_') { $userCard->eppn = substr($eppn, 4); } $userCard->save(); }
/** * This method deletes UserCard row. * If it was active card, then is activated another * using activateBestLibraryCard method. * * @param UserCard $libCard * @return number $affectedRows */ public function deleteLibraryCardRow(UserCard $libCard, $activateAnother = true) { $affectedRows = $libCard->delete(); if ($activateAnother && $libCard->cat_username == $this->cat_username) { // Activate another card (if any) or remove cat_username and cat_password $this->activateBestLibraryCard(); } return $affectedRows; }