Lines Matching refs:this

26     /** @var int The ID of this schema */
29 /** @var string the user who last edited this schema */
53 * @param string $table The table this schema is for
54 * @param int $ts The timestamp for when this schema was valid, 0 for current
63 $this->structversion = $info['date'];
64 $this->sqlite = $helper->getDB();
66 $this->table = $table;
68 $this->ts = $ts;
87 $schema = $this->sqlite->queryAll($sql, $opt);
92 $this->id = $result['id'];
93 $this->user = $result['user'];
94 $this->ts = $result['ts'];
97 $this->config = array_merge($baseconfig, $config);
98 $this->initTransConfig(['label']);
99 if (!$this->id) return;
108 $rows = $this->sqlite->queryAll($sql, [$this->id]);
135 $this->columns[] = $column;
136 if ($row['sort'] > $this->maxsort) $this->maxsort = $row['sort'];
145 return self::class . ' ' . $this->table . ' (' . $this->id . ') ';
186 * Delete all data associated with this schema
192 if (!$this->id) throw new StructException('can not delete unsaved schema');
194 $this->sqlite->query('BEGIN TRANSACTION');
197 $this->sqlite->query($sql . 'data_' . $this->table);
198 $this->sqlite->query($sql . 'multi_' . $this->table);
200 $sql = "DELETE FROM schema_assignments WHERE tbl = '$this->table'";
201 $this->sqlite->query($sql);
203 $sql = "DELETE FROM schema_assignments_patterns WHERE tbl = '$this->table'";
204 $this->sqlite->query($sql);
213 $this->sqlite->query($sql, [$this->table]);
220 $this->sqlite->query($sql, [$this->table]);
223 $this->sqlite->query($sql, [$this->table]);
225 $this->sqlite->query('COMMIT TRANSACTION');
226 $this->sqlite->query('VACUUM');
229 $this->id = 0;
230 $this->columns = [];
231 $this->maxsort = 0;
232 $this->ts = 0;
241 if (!$this->id) throw new StructException('can not clear data of unsaved schema');
243 $this->sqlite->query('BEGIN TRANSACTION');
245 $this->sqlite->query($sql . 'data_' . $this->table);
246 $this->sqlite->query($sql . 'multi_' . $this->table);
247 $this->sqlite->query('COMMIT TRANSACTION');
248 $this->sqlite->query('VACUUM');
256 return $this->id;
260 * @return int returns the timestamp this Schema was created at
264 return $this->ts;
272 return $this->user;
277 return $this->config;
281 * Returns the translated label for this schema
290 return $this->getTranslatedKey('label', $this->table);
294 * Checks if the current user may edit data in this schema
302 if ($this->config['allowed editors'] === '') return true;
305 return auth_isMember($this->config['allowed editors'], $INPUT->server->str('REMOTE_USER'), $USERINFO['grps']);
314 return (bool)$this->config['internal'];
318 * Returns a list of columns in this schema
327 $this->columns,
332 return $this->columns;
345 foreach ($this->columns as $col) {
358 return $this->table;
362 * @return int the highest sort number used in this schema
366 return $this->maxsort;
370 * @return string the JSON representing this schema
375 'structversion' => $this->structversion,
376 'schema' => $this->getTable(),
377 'id' => $this->getId(),
378 'user' => $this->getUser(),
379 'config' => $this->getConfig(),
383 foreach ($this->columns as $column) {