Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
cron_job_update_trim_record.inc
1 <?php
18 require_once SQ_CORE_PACKAGE_PATH.'/system/cron/cron_job/cron_job.inc';
19 require_once SQ_FUDGE_PATH.'/db_extras/db_extras.inc';
20 
33 {
34 
35 
42  function __construct($assetid=0)
43  {
44  parent::__construct($assetid);
45 
46  }//end constructor
47 
48 
60  function create(&$link)
61  {
62  require_once SQ_CORE_PACKAGE_PATH.'/system/system_asset_fns.inc';
63 
64  $GLOBALS['SQ_SYSTEM']->changeDatabaseConnection('db2');
65  $GLOBALS['SQ_SYSTEM']->doTransaction('BEGIN');
66 
67  if ($linkid = parent::create($link)) {
68  if (!system_asset_fns_create_cleanup($this)) {
69  $linkid = FALSE;
70  }
71  }
72 
73  if ($linkid) {
74  $GLOBALS['SQ_SYSTEM']->doTransaction('COMMIT');
75  } else {
76  $GLOBALS['SQ_SYSTEM']->doTransaction('ROLLBACK');
77  }
78 
79  $GLOBALS['SQ_SYSTEM']->restoreDatabaseConnection();
80  return $linkid;
81 
82  }//end create()
83 
84 
94  function _getName($short_name=FALSE)
95  {
96  return $GLOBALS['SQ_SYSTEM']->am->getTypeInfo($this->type(), 'name');
97 
98  }//end _getName()
99 
100 
107  function canClone()
108  {
109  return FALSE;
110 
111  }//end canClone()
112 
113 
125  function morph($new_type_code)
126  {
127  trigger_localised_error('CRON0024', E_USER_WARNING, $GLOBALS['SQ_SYSTEM']->am->getTypeInfo($this->type(), 'name'));
128  return FALSE;
129 
130  }//end morph()
131 
132 
141  function canDelete()
142  {
143  return FALSE;
144 
145  }//end canDelete()
146 
147 
163  function _exec(&$msg)
164  {
165  $old_mask = umask(0002);
166 
167  require_once SQ_PACKAGES_PATH.'/trim/lib/trim_common.inc';
168 
169  $sql = 'SELECT assetid FROM sq_ast WHERE type_code like \'trim_saved_search\'';
170  $query = MatrixDAL::preparePdoQuery($sql);
171  $assetids = MatrixDAL::executePdoGroupedAssoc($query);
172  if (!empty($assetids)) {
173  foreach ($assetids as $assetid => $info) {
174  $trash_link = $GLOBALS['SQ_SYSTEM']->am->getParents($assetid, 'trash_folder', TRUE);
175  if (empty($trash_link)) {
176  $ss = $GLOBALS['SQ_SYSTEM']->am->getAsset($assetid);
177  if(!empty($ss)) {
178  $connection = $ss->getConnection();
179  $test_connection = TRIM_Common::test_trim_connection($connection);
180  if ($test_connection) {
181  $ss->updateCachedResult();
182  }//end if
183  }
184  }//end if
185  }//end if
186  }//end if
187 
188  umask($old_mask);
189 
190  return SQ_CRON_JOB_COMPLETED;
191 
192  }//end _exec()
193 
194 
195 }//end class
196 ?>