Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
metadata_schema.inc
1 <?php
17 require_once SQ_CORE_PACKAGE_PATH.'/folder/folder.inc';
18 
30 class Metadata_Schema extends Folder
31 {
32 
33 
40  function __construct($assetid=0)
41  {
42  parent::__construct($assetid);
43 
44  }//end constructor
45 
46 
53  public function lockTypes()
54  {
55  $lock_types = parent::lockTypes();
56  $lock_types['content'] = ($lock_types['attributes'] | $lock_types['links']);
57  return $lock_types;
58 
59  }//end lockTypes()
60 
61 
69  public function _getAllowedLinks()
70  {
71  return Array(
72  SQ_LINK_TYPE_1 => Array(),
73  SQ_LINK_TYPE_2 => Array('metadata_section' => Array('card' => 'M', 'exclusive' => FALSE)),
74  SQ_LINK_TYPE_3 => Array(),
75  SQ_LINK_NOTICE => Array(),
76  );
77 
78  }//end _getAllowedLinks()
79 
80 
101  public function prepareLink(Asset $asset, $side_of_link, &$link_type, &$value, &$sort_order, &$dependant, &$exclusive)
102  {
103  // if this is a metadata section then we need to make it a dependant link
104  if ($side_of_link == 'major' && ($asset instanceof Metadata_Section) && $dependant != '1') {
105  $link_type = SQ_LINK_TYPE_2;
106  $dependant = '1';
107  return TRUE;
108  }
109 
110  return FALSE;
111 
112  }//end prepareLink()
113 
114 
125  public function delete($release_lock=TRUE)
126  {
127  if (parent::delete($release_lock)) {
128  $GLOBALS['SQ_SYSTEM']->changeDatabaseConnection('db2');
129  $db = MatrixDAL::getDb();
130  $GLOBALS['SQ_SYSTEM']->doTransaction('BEGIN');
131 
132  // First remove any values assets have for this field
133  try {
134  $sql = 'DELETE FROM sq_ast_mdata WHERE ';
135  $sql .= 'schemaid = :schemaid';
136 
137  $query = MatrixDAL::preparePdoQuery($sql);
138  MatrixDAL::bindValueToPdo($query, 'schemaid', $this->id);
139 
140  MatrixDAL::executePdoOne($query);
141  } catch (Exception $e) {
142  throw new Exception('Unable to delete metadata schema with schemaid #'.$this->id.' due to the following database error:'.$e->getMessage());
143  }//end try catch
144 
145  $GLOBALS['SQ_SYSTEM']->doTransaction('COMMIT');
146  $GLOBALS['SQ_SYSTEM']->restoreDatabaseConnection();
147 
148  return TRUE;
149  }
150  return FALSE;
151 
152  }//end delete()
153 
154 
163  public function saveWebPaths(Array $paths)
164  {
165  return TRUE;
166 
167  }//end saveWebPaths()
168 
169 
170 }//end class
171 
172 ?>