18 require_once SQ_CORE_PACKAGE_PATH.
'/designs/design/design.inc';
43 parent::__construct($assetid);
61 require_once SQ_CORE_PACKAGE_PATH.
'/system/system_asset_fns.inc';
62 if (!system_asset_fns_create_pre_check($this)) {
65 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
66 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
68 if ($linkid = parent::create($link)) {
76 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
78 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
81 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
95 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
96 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
98 require_once SQ_FUDGE_PATH.
'/general/file_system.inc';
99 if (!create_directory($this->data_path)) {
100 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
101 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
105 if (!create_directory($this->data_path_public)) {
106 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
107 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
111 $source_dir = dirname(__FILE__).
'/design_files';
113 $file_contents = file_to_string($source_dir.
'/index.html');
114 if ($file_contents ==
'') {
115 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
116 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
117 trigger_localised_error(
'CORE0094', E_USER_WARNING);
123 $parse_file = $this->data_path.
'/parse.txt';
124 $file_exists = file_exists($parse_file);
128 $file_contents = str_replace(Array(
'<MySource',
'</MySource'), Array(
'<'.$ef->tag_name,
'</'.$ef->tag_name), $file_contents);
129 if (!string_to_file($file_contents, $parse_file)) {
130 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
131 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
132 trigger_localised_error(
'CORE0095', E_USER_WARNING);
142 $fv = $GLOBALS[
'SQ_SYSTEM']->getFileVersioning();
146 if (!$fv->add($this->data_path_suffix, $parse_file,
'')) {
147 trigger_localised_error(
'CORE0025', E_USER_WARNING);
148 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
149 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
154 $file_status = $fv->upToDate($parse_file);
155 if (FUDGE_FV_MODIFIED & $file_status) {
156 if (!$fv->commit($parse_file,
'')) {
157 trigger_localised_error(
'CORE0033', E_USER_WARNING);
158 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
159 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
166 if (!$fv->checkOut($this->data_path_suffix.
'/parse.txt', $this->data_path)) {
167 trigger_localised_error(
'CORE0031', E_USER_WARNING);
168 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
169 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
174 if ($handle = opendir($source_dir.
'/files')) {
175 while (FALSE !== ($file = readdir($handle))) {
177 if ($file ==
'.' || $file ==
'..' || strtoupper($file) ==
'CVS') {
182 $info[
'name'] = $file;
183 $info[
'tmp_name'] = $source_dir.
'/files/'.$file;
184 $info[
'non_uploaded_file'] = TRUE;
185 if (!$ef->_processUploadedFile($this, $info)) {
186 trigger_localised_error(
'CORE0030', E_USER_WARNING, $file);
192 if (!$GLOBALS[
'SQ_SYSTEM']->am->acquireLock($this->id,
'all')) {
193 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
194 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
199 if (!$ef->parseAndProcessFile($this)) {
200 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
201 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
210 trigger_localised_error(
'CORE0062', E_USER_WARNING);
215 $public_userids = $GLOBALS[
'SQ_SYSTEM']->am->getTypeAssetids(
'public_user');
216 if (!$GLOBALS[
'SQ_SYSTEM']->am->setPermission($this->id, $public_userids[0], SQ_PERMISSION_READ,
'1')) {
217 trigger_localised_error(
'CORE0060', E_USER_WARNING);
220 $GLOBALS[
'SQ_SYSTEM']->am->releaseLock($this->
id,
'all');
222 $dependants = $GLOBALS[
'SQ_SYSTEM']->am->getDependantChildren($this->
id);
223 foreach ($dependants as $dependantid => $dependant_data) {
224 $dep_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($dependantid, $dependant_data[0][
'type_code']);
225 if (!$GLOBALS[
'SQ_SYSTEM']->am->acquireLock($dep_asset->id,
'permissions')) {
226 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
227 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
230 if (!$dep_asset->processStatusChange(SQ_STATUS_LIVE)) {
231 trigger_localised_error(
'CORE0061', E_USER_WARNING, $dep_asset->name, $dep_asset->id);
233 if (!$GLOBALS[
'SQ_SYSTEM']->am->setPermission($dep_asset->id, $public_userids[0], SQ_PERMISSION_READ,
'1')) {
234 trigger_localised_error(
'CORE0059', E_USER_WARNING, $dep_asset->name, $dep_asset->id);
236 $GLOBALS[
'SQ_SYSTEM']->am->releaseLock($dep_asset->id,
'permissions');
237 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($dep_asset);
240 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
241 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
256 $ret_val = parent::_getAllowedLinks();
258 unset($ret_val[SQ_LINK_TYPE_2][
'design_customisation']);