Esempio n. 1
0
 /**
  * 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);
 }
/*                                                                      */
/* This program is free software. You can redistribute it and/or        */
/* modify it under the terms of the GNU General Public License          */
/* as published by the Free Software Foundation.                        */
/************************************************************************/
// $Id$
define('AC_INCLUDE_PATH', '../include/');
include AC_INCLUDE_PATH . 'vitals.inc.php';
include_once AC_INCLUDE_PATH . 'classes/DAO/GuidelinesDAO.class.php';
include_once AC_INCLUDE_PATH . 'classes/DAO/ChecksDAO.class.php';
$guidelinesDAO = new GuidelinesDAO();
if (isset($_POST['submit_no'])) {
    $msg->addFeedback('CANCELLED');
    header('Location: index.php');
    exit;
} else {
    if (isset($_POST['submit_yes'])) {
        if ($guidelinesDAO->Delete($_POST['id'])) {
            $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
            header('Location: index.php');
            exit;
        }
    }
}
$rows = $guidelinesDAO->getGuidelineByIDs($_GET['id']);
unset($hidden_vars);
$hidden_vars['id'] = $_GET['id'];
require AC_INCLUDE_PATH . 'header.inc.php';
$msg->addConfirm(array('DELETE_GUIDELINE', $rows[0]['title']), $hidden_vars);
$msg->printConfirm();
require AC_INCLUDE_PATH . 'footer.inc.php';