/** * Delete user * @access public * @param user_id * @return true, if successful * false and add error into global var $msg, if unsuccessful * @author Cindy Qi Li */ public function Delete($userIDs) { // delete customized guidelines created by user but yet open to public include_once AC_INCLUDE_PATH . 'classes/DAO/GuidelinesDAO.class.php'; include_once AC_INCLUDE_PATH . 'classes/DAO/ChecksDAO.class.php'; include_once AC_INCLUDE_PATH . 'classes/DAO/UserLinksDAO.class.php'; include_once AC_INCLUDE_PATH . 'classes/Utility.class.php'; $userIDs = Utility::sanitizeIntArray($userIDs); $guidelinesDAO = new GuidelinesDAO(); $guidelines = $guidelinesDAO->getGuidelineByUserIDs($userIDs); if (is_array($guidelines)) { foreach ($guidelines as $guideline) { if ($guideline['open_to_public'] == 0) { $guidelinesDAO->Delete($guideline['guideline_id']); } } } // delete customized checks created by user but yet open to public $checksDAO = new ChecksDAO(); $checks = $checksDAO->getCheckByUserIDs($userIDs); if (is_array($checks)) { foreach ($checks as $check) { if ($check['open_to_public'] == 0) { $checksDAO->Delete($check['check_id']); } } } // delete user links and decisions generated by this user $userLinksDAO = new UserLinksDAO(); $userLinks = $userLinksDAO->DeleteByUserID($userIDs); $sql = "DELETE FROM " . TABLE_PREFIX . "users\n\t\t WHERE user_id in (" . implode(",", $userIDs) . ")"; return $this->execute($sql); }