public function getAcl($domain)
 {
     if ($_SESSION['ss_mb_id'] && !$_SESSION['user']['uid']) {
         $dbm = \CADB\DBM::instance();
         if ($_SESSION['ss_mb_id']) {
             $que = "SELECT * FROM `g5_member` WHERE `mb_id` = '" . $_SESSION['ss_mb_id'] . "'";
             $row = $dbm->getFetchArray($que);
             if ($row['mb_no']) {
                 $_SESSION['user'] = array('uid' => $row['mb_no'], 'glevel' => 11 - $row['mb_level']);
                 $que = "SELECT * FROM {privilege} WHERE user_id = '" . addslashes($_SESSION['ss_mb_id']) . "'";
                 while ($row = $dbm->getFetchArray($que)) {
                     $_SESSION['acl'][$domain][$row['oid']] = $row['role'];
                 }
                 if (!count($_SESSION['acl'])) {
                     $_SESSION['user']['glevel'] = BITWISE_ATHENTICATED;
                 }
                 \CADB\Log::accessLog('login');
             }
         }
     }
     if (!isset($_SESSION['acl'][$domain])) {
         $_SESSION['acl'][$domain] = array();
     }
     return $_SESSION['acl'][$domain];
 }
 public function process()
 {
     \CADB\Log::accessLog('logout');
     \CADB\Lib\logout();
     if ($_GET['requestURI']) {
         \CADB\Lib\RedirectURL(rawurldecode($_GET['requestURI']));
     } else {
         \CADB\Lib\RedirectURL(\CADB\Lib\base_uri());
     }
 }
 public static function delete($fields, $oid)
 {
     $dbm = \CADB\DBM::instance();
     self::$fields = $fields;
     $que = "DELETE FROM {organize} WHERE oid = ?";
     $dbm->execute($que, array("d", $oid));
     $que = "DELETE FROM {agreement_organize} WHERE oid = ?";
     $dbm->execute($que, array("d", $oid));
     $que = "DELETE FROM {taxonomy_term_relative} WHERE `table` = ? AND `rid` = ?";
     $dbm->execute($que, array("sd", 'organize', $oid));
     self::$log = "조직 [" . $oid . "] 을 삭제했습니다.\n";
     \CADB\Log::orgLog('delete', $oid, $oid, self::$log);
     return 0;
 }
 public static function fork($fields, $nid, $did)
 {
     $dbm = \CADB\DBM::instance();
     self::$fields = $fields;
     $que = "SELECT * FROM {agreement} WHERE nid = " . $nid . " AND did = " . $did;
     $articles = $dbm->getFetchArray($que);
     if (!$articles) {
         return -1;
     }
     $que = "INSERT INTO {agreement} (";
     $que2 = ") VALUES (";
     $array1 = 'array("';
     $array2 = "";
     $c = 0;
     foreach ($articles as $k => $v) {
         if ($k == 'nid' || $k == 'did') {
             continue;
         }
         if ($k == 'created') {
             continue;
         }
         $que .= ($c ? ", " : "") . "`" . $k . "`";
         $que2 .= ($c ? ", " : "") . "?";
         if (is_numeric($v)) {
             $array1 .= 'd';
         } else {
             $articles[$k] = stripslashes($v);
             $array1 .= 's';
         }
         $array2 .= ($c ? ", " : "") . '$' . 'articles[' . $k . ']';
         $c++;
     }
     $que .= ", `created`";
     $que2 .= ", ?)";
     $que = $que . $que2;
     $array1 .= 'd",';
     $array2 .= ", time())";
     $eval_str = '$' . "q_args = " . $array1 . $array2 . ";";
     eval($eval_str);
     if ($dbm->execute($que, $q_args) < 1) {
         self::setErrorMsg($que . " 가 DB에 반영되지 않았습니다.");
         return -1;
     }
     $insert_nid = $dbm->getLastInsertId();
     $que = "UPDATE {agreement} SET did = ? WHERE nid = ?";
     if ($dbm->execute($que, array("dd", $insert_nid, $insert_nid)) < 1) {
         self::setErrorMsg($que . " 가 DB에 반영되지 않았습니다.");
         return -1;
     }
     $que = "UPDATE {agreement} SET `current` = ? WHERE nid = ? AND did = ?";
     $dbm->execute($que, array("ddd", 0, $nid, $did));
     $article_orgs = array();
     $que = "SELECT * FROM {agreement_organize} WHERE nid = " . $nid . " AND did = " . $did;
     while ($row = $dbm->getFetchArray($que)) {
         $article_orgs[] = $row;
     }
     if (is_array($article_orgs)) {
         foreach ($article_orgs as $orgs) {
             $que = "INSERT INTO {agreement_organize} (`nid`,`did`,`oid`,`vid`,`owner`) VALUES (?,?,?,?,?)";
             if ($dbm->execute($que, array("ddddd", $insert_nid, $insert_nid, $orgs['oid'], $orgs['vid'], $orgs['owner'])) < 1) {
                 self::setErrorMsg($que . " 가 DB에 반영되지 않았습니다.");
                 return -1;
             }
         }
     }
     $taxonomy_terms = array();
     $que = "SELECT * FROM {taxonomy_term_relative} WHERE `table` = 'agreement' AND rid = " . $nid;
     while ($row = $dbm->getFetchArray($que)) {
         $taxonomy_terms[] = $row;
     }
     if (is_array($taxonomy_terms)) {
         foreach ($taxonomy_terms as $terms) {
             $que = "INSERT INTO {taxonomy_term_relative} (`tid`,`table`,`rid`,`fid`) VALUES (?,?,?,?)";
             if ($dbm->execute($que, array("dsdd", $terms['tid'], 'agreement', $insert_nid, $terms['fid'])) < 1) {
                 self::setErrorMsg($que . " 가 DB에 반영되지 않았습니다.");
                 return -1;
             }
         }
     }
     self::$log = "단체협약번호 NID: " . $nid . "/ DID: " . $did . " 를 새 단협번호: " . $insert_nid . "로 복사했습니다";
     \CADB\Log::articleLog('fork', $insert_nid, $insert_nid, self::$log);
     return $insert_nid;
 }
 public static function fork($nid)
 {
     $dbm = \CADB\DBM::instance();
     $que = "SELECT * FROM {guide} WHERE nid = " . $nid;
     $guide = $dbm->getFetchArray($que);
     if (!$guide) {
         self::setErrorMsg("존재하지 않는 모범단협입니다.");
         return -1;
     }
     $que = "INSERT INTO {guide} (";
     $que2 = ") VALUES (";
     $array1 = 'array("';
     $array2 = "";
     $c = 0;
     foreach ($guide as $k => $v) {
         if ($k == 'nid' || $k == 'vid') {
             continue;
         }
         if ($k == 'created') {
             continue;
         }
         $que .= ($c ? ", " : "") . "`" . $k . "`";
         $que2 .= ($c ? ", " : "") . "?";
         if (is_numeric($v)) {
             $array1 .= 'd';
         } else {
             $guide[$k] = stripslashes($v);
             $array1 .= 's';
         }
         if ($k == 'current') {
             $guide[$k] = 0;
         }
         $array2 .= ($c ? ", " : "") . '$' . 'guide[' . $k . ']';
         $c++;
     }
     $que .= ", `created`";
     $que2 .= ", ?)";
     $que = $que . $que2;
     $array1 .= 'd",';
     $array2 .= ", time())";
     $eval_str = '$' . "q_args = " . $array1 . $array2 . ";";
     eval($eval_str);
     if ($dbm->execute($que, $q_args) < 1) {
         self::setErrorMsg($que . "가 DB에 반영되지 않았습니다.");
         return -1;
     }
     $insert_nid = $dbm->getLastInsertId();
     $que = "UPDATE {guide} SET vid = ? WHERE nid = ?";
     if ($dbm->execute($que, array("dd", $insert_nid, $insert_nid)) < 1) {
         self::setErrorMsg($que . " 가 DB에 반영되지 않았습니다.");
         self::rollback($insert_nid);
         return -1;
     }
     self::$log = "모범단협: " . $nid . " 을 복사하여 새모범단협: " . $insert_nid . " 으로 복사했습니다.\n";
     $clause = array();
     $que = "SELECT * FROM {guide_clause} WHERE nid = " . $nid . " ORDER BY parent ASC, idx ASC";
     while ($row = $dbm->getFetchArray($que)) {
         $clause[] = $row;
     }
     if (is_array($clause)) {
         foreach ($clause as $cl) {
             if (self::forkClause($cl, $insert_nid) < 0) {
                 self::rollback($insert_nid);
                 return -1;
             }
         }
     }
     self::$log .= "모범단협: " . $nid . " 의 모든 세부조항을 복사하여 새모범단협: " . $insert_nid . " 의 세부조항으로 복사했습니다.\n";
     \CADB\Log::guideLog('fork', $insert_nid, $insert_nid, 0, self::$log);
     return $insert_nid;
 }
 public static function delete($mb_no, $mb_id)
 {
     $dbm = \CADB\DBM::instance();
     $que = "DELETE FROM `g5_member` WHERE mb_no = ?";
     $dbm->execute($que, array("d", $mb_no));
     self::$log = $mb_id . "(" . $mb_no . ") 회원을 GNU5 테이블에서 삭제했습니다.\n";
     \CADB\Member\DBM::deletePrivilegeByID($mb_id);
     self::$log .= \CADB\Member\DBM::getLog();
     \CADB\Log::memberLog('delete', $mb_no, self::$log);
     return 0;
 }
 public static function resort($table, $index)
 {
     $dbm = \CADB\DBM::instance();
     foreach ($index as $fid => $idx) {
         $que = "UPDATE {fields} SET `idx` = ? WHERE `table` = ? AND `fid` = ?";
         $dbm->execute($que, array("dsd", $idx + 1, $table, $fid));
     }
     self::$log .= "테이블: " . $table . "의 필드순서를 재조정했습니다.\n";
     \CADB\Log::fieldLog('modify', 0, self::$log);
 }
 public function process()
 {
     $context = \CADB\Model\Context::instance();
     if (!$this->params['nid']) {
         Error('단체협약서 번호를 입력하세요.');
     }
     if (!$this->themes) {
         $this->themes = $context->getProperty('service.themes');
     }
     $this->fields = \CADB\Agreement::getFieldInfo(1);
     $this->articles = \CADB\Agreement::getAgreement($this->params['nid'], $this->params['did'] ? $this->params['did'] : 0);
     if (!$this->articles) {
         Error('존재하지 않는 단체협약입니다.');
     }
     \CADB\Log::articleLog('pdf', $this->params['nid'], $this->params['did'] ? $this->params['did'] : 0, "단체협약: [" . $this->articles['subject'] . "]을 PDF 조회했습니다.");
     $pdf = new \TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     // set document information
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->SetAuthor($context->getProperty('service.title'));
     $pdf->SetTitle($this->articles['subject']);
     $pdf->SetSubject($this->articles['subject']);
     $pdf->SetKeywords(preg_replace("/[ ]{1,}/i", ", ", $this->article['subject']));
     // set default header data
     $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, $context->getProperty('service.title'), $context->getProperty('service.domain'), array(0, 64, 255), array(0, 64, 128));
     $pdf->setFooterData(array(0, 64, 0), array(0, 64, 128));
     // set header and footer fonts
     $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
     $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
     // set default monospaced font
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     // set margins
     $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     // set auto page breaks
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     // set image scale factor
     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     // set default font subsetting mode
     $pdf->setFontSubsetting(true);
     $pdf->SetFont('nanumbarungothic', '', 14, '', true);
     $pdf->AddPage();
     // set text shadow effect
     $pdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.2, 'depth_h' => 0.2, 'color' => array(196, 196, 196), 'opacity' => 1, 'blend_mode' => 'Normal'));
     $pdf->writeHTMLCell(0, 0, '', '', '<h1>' . $this->articles['subject'] . '</h1><br><br>', 0, 1, 0, true, '', true);
     ob_start();
     $theme_html_file = "";
     if ($this->themes) {
         $theme_html_file = CADB_PATH . "/themes/" . $this->themes . "/articles/pdf.html.php";
         if ($theme_html_file && file_exists($theme_html_file)) {
             include $theme_html_file;
         } else {
             include dirname(__FILE__) . "/pdf.html.php";
         }
     } else {
         include dirname(__FILE__) . "/pdf.html.php";
     }
     $content = ob_get_contents();
     ob_end_clean();
     $pdf->SetFont('nanumbarungothic', '', 12, '', true);
     $pdf->writeHTML($content, true, false, false, false, 'center');
     $pdf->SetFont('nanumbarungothic', '', 14, '', true);
     $pdf->writeHTMLCell(0, 0, '', '', $this->articles['content'], 0, 1, 0, true, '', true);
     $pdf->Output($this->articles['subject'] . '.pdf', 'I');
 }
 public static function deleteTerm($terms)
 {
     $dbm = \CADB\DBM::instance();
     $que = "DELETE FROM {taxonomy_terms} WHERE `cid` = ? AND `tid` = ?";
     $dbm->execute($que, array("dd", $terms['cid'], $terms['tid']));
     $que = "UPDATE {taxonomy_terms} SET idx = idx - 1 WHERE `cid` = ? AND `parent` = ? AND idx >= ? ORDER BY idx ASC";
     $dbm->execute($que, array("ddd", $terms['cid'], $terms['parent'], $terms['idx']));
     if ($terms['parent']) {
         $que = "UPDATE {taxonomy_terms} SET nsubs = nsubs - 1 WHERE `cid` = ? AND `tid` = ?";
         $dbm->execute($que, array("dd", $terms['cid'], $terms['parent']));
     }
     self::$log = "분류항목 [" . $terms['name'] . "] 을 삭제했습니다.\n";
     \CADB\Log::taxonomytermLog('delete', $terms['cid'], $terms['tid'], $terms['vid'], self::$log);
 }