/**
  * Add checks into guideline
  * @access  public
  * @param   $guidelineID : guideline id
  *          $cids : array of check ids to be added into guideline
  * @return  true : if successful
  *          false : if unsuccessful
  * @author  Cindy Qi Li
  */
 public function addChecks($guidelineID, $cids)
 {
     require_once AC_INCLUDE_PATH . 'classes/DAO/GuidelineGroupsDAO.class.php';
     require_once AC_INCLUDE_PATH . 'classes/DAO/GuidelineSubgroupsDAO.class.php';
     require_once AC_INCLUDE_PATH . 'classes/DAO/SubgroupChecksDAO.class.php';
     $guidelineID = intval($guidelineID);
     if ($guidelineID == 0) {
         $msg->addError('MISSING_GID');
         return false;
     }
     $guidelineGroupsDAO = new GuidelineGroupsDAO();
     $groups = $guidelineGroupsDAO->getUnnamedGroupsByGuidelineID($guidelineID);
     if (is_array($groups)) {
         $group_id = $groups[0]['group_id'];
     } else {
         $group_id = $guidelineGroupsDAO->Create($guidelineID, '', '', '');
     }
     if ($group_id) {
         $guidelineSubgroupsDAO = new GuidelineSubgroupsDAO();
         $subgroups = $guidelineSubgroupsDAO->getUnnamedSubgroupByGroupID($group_id);
         if (is_array($subgroups)) {
             $subgroup_id = $subgroups[0]['subgroup_id'];
         } else {
             $subgroup_id = $guidelineSubgroupsDAO->Create($group_id, '', '');
         }
         if ($subgroup_id) {
             $subgroupChecksDAO = new SubgroupChecksDAO();
             if (is_array($cids)) {
                 foreach ($cids as $cid) {
                     $cid = intval($cid);
                     if ($cid > 0) {
                         $subgroupChecksDAO->Create($subgroup_id, $cid);
                     }
                 }
             }
         } else {
             return false;
         }
     } else {
         return false;
     }
     return true;
 }
예제 #2
0
$guidelineGroupsDAO = new GuidelineGroupsDAO();
$guidelineSubgroupsDAO = new GuidelineSubgroupsDAO();
if (isset($_POST['submit'])) {
    $name = trim($_POST['name']);
    if ($name == '') {
        $msg->addError(array('EMPTY_FIELDS', _AC('name')));
    }
    if (!$msg->containsErrors()) {
        if ($_GET['action'] == 'add') {
            if (isset($_GET['gid'])) {
                // add group into guideline
                $guidelineGroupsDAO->Create($_GET['gid'], $name, '', '');
            }
            if (isset($_GET['ggid'])) {
                // add group into guideline
                $guidelineSubgroupsDAO->Create($_GET['ggid'], $name, '');
            }
        }
        if ($_GET['action'] == 'edit') {
            if (isset($_GET['ggid'])) {
                // add group into guideline
                $guidelineGroupsDAO->Update($_GET['ggid'], $name, '', '');
            }
            if (isset($_GET['gsgid'])) {
                // add group into guideline
                $guidelineSubgroupsDAO->Update($_GET['gsgid'], $name, '');
            }
        }
        $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
        // force refresh parent window
        $javascript_run_now = '<script language="JavaScript">