OSDN Git Service

f7389588e172a31d52c4df26d6d5aa5f014151d3
[mulab/sd2nd.git] / trust_path / modules / sd2nd / class / updater / dispose / GarbageCollection.class.php
1 <?php
2 /**
3  * @file
4  * @package Sd2nd
5  * @version $Id$
6 **/
7
8 if(!defined('XOOPS_ROOT_PATH'))
9 {
10     exit();
11 }
12
13 /**
14  * @class   Sd2nd_GarbageCollectionDispose
15 **/
16 class Sd2nd_GarbageCollectionDispose extends Sd2nd_AbstractFilter
17 {
18     /**
19      * @brief   Enum
20     **/
21     const ACTIVE_TABLE = Sd2nd_AssetManager::HANDLER_LEARNED_ABILITY;
22     
23     /**
24      * @brief   Enum
25     **/
26     const CHAR_TABLE = Sd2nd_AssetManager::HANDLER_CHAR;
27     
28     /**
29      * @brief   string[]
30     **/
31     protected $_mTableName = array();
32     
33     /**
34      * getPriority
35      * 
36      * @param   void
37      * 
38      * @return  Enum
39     **/
40     public function getPriority()
41     {
42         return XCUBE_DELEGATE_PRIORITY_FIRST;
43     }
44     
45     /**
46      * _executeGC
47      * 
48      * @param   void
49      * 
50      * @return  void
51      * @throw   Sd2nd_QueryException
52     **/
53     protected function _executeGC()
54     {
55         $root =& XCube_Root::getSingleton();
56         $db =& $root->mController->mDB;
57         
58         if(!$res = $db->query('select `m`.`eno` as `eno` from `' . Sd2nd_UpdateUtils::convertTableName(self::ACTIVE_TABLE) . '` as m left join `' . Sd2nd_UpdateUtils::convertTableName(self::CHAR_TABLE) . '` as c on `m`.`eno` = `c`.`eno` where isnull(`c`.`full_name`) group by `m`.`eno`'))
59         {
60             throw new Sd2nd_QueryException(array('active' => self::ACTIVE_TABLE,'char' => self::CHAR_TABLE));
61         }
62         
63         $cri = new CriteriaCompo();
64         while($row = $db->fetchArray($res))
65         {
66             $cri->add(new Criteria('eno',$row['eno']));
67         }
68         
69         if($cri->hasChildElements())
70         {
71             foreach($this->_mTableName as $type)
72             {
73                 Sd2nd_UpdateUtils::deleteMultiObjects($type,$cri);
74             }
75         }
76     }
77     
78     /**
79      * executeLatest
80      * 
81      * @param   void
82      * 
83      * @return  void
84      * @throw   Sd2nd_QueryException
85     **/
86     public function executeLatest()
87     {
88         $this->_mTableName = array(
89             Sd2nd_AssetManager::HANDLER_ICON,
90             Sd2nd_AssetManager::HANDLER_IMAGE,
91             Sd2nd_AssetManager::HANDLER_LEARNED_ABILITY,
92             Sd2nd_AssetManager::HANDLER_LEARNED_COSTUME,
93             Sd2nd_AssetManager::HANDLER_LEARNED_SKILL
94         );
95         
96         $this->_executeGC();
97     }
98 }
99
100 ?>