72 $rs =
$DB->Execute(
"SELECT ID, Name FROM ".$Tables[
"Locales"].
" ORDER BY Name");
73 while($row = $rs->FetchRow())
91 $rs =
$DB->Execute(
"SELECT ID FROM ".$Tables[
"Projects"].
" WHERE ParentID = 0 AND LocaleID = ? ORDER BY Name", array($localeID));
92 while($row = $rs->FetchRow())
95 $proj->LoadByID($row[
"ID"],
false);
96 $roots[$row[
"ID"]] = $proj;
121 $old =
$DB->GetOne(
"SELECT ID FROM ".$Tables[
"Projects"].
" WHERE ParentID = ? AND Name = ? AND LocaleID = ?", array($this->ParentID, $this->Name, $this->LocaleID));
165 public function CreateProject($rootID, $parentID, $name, $isFolder, $localeID, $document =
'', $skeleton =
'')
167 $this->RootID = $rootID;
168 $this->ParentID = $parentID;
170 $this->IsFolder = $isFolder;
171 $this->LocaleID = $localeID;
172 $this->Document = $document;
173 $this->Skeleton = $skeleton;
174 $this->LastSeen = time();
175 $this->Brief =
false;
181 throw new Exception(
"Project with this name already exists, same location.");
199 if($this->IsFolder && ($this->Document !=
'' || $this->Skeleton !=
''))
201 throw new Exception(
"Folder project must not contain a document or skeleton.");
206 throw new Exception(
"Brief=True projects cannot be saved or updated. They are read-only.");
210 if(isset($this->ProjectID))
214 $ok =
$DB->Execute(
"UPDATE ".$Tables[
"Projects"].
" SET ParentID = ?, Name = ?, IsFolder = ?, LocaleID = ?, OrigDoc = ?, Skeleton = ?, LastSeen = now() WHERE ID = ?", array($this->ParentID, $this->Name, ($this->IsFolder ? 1 : 0), $this->LocaleID, $this->Document, $this->Skeleton, $this->ProjectID));
223 throw new Exception(
"Project with this name already exists, same location.");
226 $root = ($this->RootID > 0 ? $this->RootID : null);
227 $ok =
$DB->Execute(
"INSERT INTO ".$Tables[
"Projects"].
" (RootID, ParentID, Name, IsFolder, LocaleID, OrigDoc, Skeleton, LastSeen) VALUES (?,?,?,?,?,?,?, now())", array($root, $this->ParentID, $this->Name, ($this->IsFolder ? 1 : 0), $this->LocaleID, $this->Document, $this->Skeleton));
230 if(!
$DB->Insert_ID())
232 throw new Exception(
"DB Error: Insert_ID not supported.");
234 $this->ProjectID =
$DB->Insert_ID();
250 return $this->
Load(0, $name, $localeID,
false);
262 public function Load($parentID, $name, $localeID, $brief)
267 $this->Brief = $brief;
270 $sql =
"SELECT ID, RootID, ParentID, Name, IsFolder, LocaleID,".
271 "TIMESTAMP(LastSeen) as LastSeen ".
272 "FROM ".$Tables[
"Projects"].
273 " WHERE ParentID = ? AND Name = ? AND LocaleID = ?";
277 $sql =
"SELECT ID, RootID, ParentID, Name, IsFolder, LocaleID,".
278 "Skeleton, OrigDoc, TIMESTAMP(LastSeen) as LastSeen ".
279 "FROM ".$Tables[
"Projects"].
280 " WHERE ParentID = ? AND Name = ? AND LocaleID = ?";
283 $rs =
$DB->Execute($sql, array($parentID, $name, $localeID));
304 $this->Brief = $brief;
320 $this->Brief = $brief;
323 $sql =
"SELECT ID, RootID, ParentID, Name, IsFolder, LocaleID,".
324 "TIMESTAMP(LastSeen) as LastSeen ".
325 "FROM ".$Tables[
"Projects"].
" WHERE ID = ?";
329 $sql =
"SELECT ID, RootID, ParentID, Name, IsFolder, LocaleID,".
330 "Skeleton, OrigDoc, TIMESTAMP(LastSeen) as LastSeen ".
331 "FROM ".$Tables[
"Projects"].
" WHERE ID = ?";
334 $rs =
$DB->Execute($sql, array($projectID));
353 if($row = $rs->FetchRow())
355 $this->ProjectID = $row[
"ID"];
356 if($row[
"RootID"] == null)
362 $this->RootID = $row[
"RootID"];
364 $this->ParentID = $row[
"ParentID"];
365 $this->Name = $row[
"Name"];
366 $this->IsFolder = ($row[
"IsFolder"] == 1);
367 $this->LocaleID = $row[
"LocaleID"];
368 $this->LastSeen = $row[
"LastSeen"];
372 unset($this->Skeleton);
373 unset($this->Document);
377 $this->Skeleton = $row[
"Skeleton"];
378 $this->Document = $row[
"OrigDoc"];
384 unset($this->ProjectID);
385 unset($this->RootID);
386 unset($this->ParentID);
388 unset($this->IsFolder);
389 unset($this->LocaleID);
390 unset($this->Skeleton);
391 unset($this->Document);
392 unset($this->lastSeen);
393 unset($this->ProjectID);
409 if($children->valid())
411 throw new Exception(
"Cannot destroy data of project ".$this->ProjectID.
", because it has children.");
415 if($strings->valid())
417 throw new Exception(
"Cannot destroy data of project ".$this->ProjectID.
", because it contains strings.");
419 $DB->Execute(
"DELETE FROM ".$Tables[
"Projects"].
" WHERE ID = ".$this->ProjectID);
437 throw new Exception(
"Cannot set Project Name to emtpy.");
451 $this->Skeleton = $skeleton;
462 $this->Document = $document;
475 if(!isset($this->Name))
477 throw new Exception(
"Uninitialized project, cannot get Name.");
489 if(!isset($this->Name))
491 throw new Exception(
"Uninitialized project, cannot get ID.");
503 if(!isset($this->Name))
505 throw new Exception(
"Uninitialized project, cannot get Root ID.");
517 if(!isset($this->Name))
519 throw new Exception(
"Uninitialized project, cannot get Parent ID.");
531 if(!isset($this->Name))
533 throw new Exception(
"Uninitialized project, cannot get IsFolder.");
545 if(!isset($this->Name))
547 throw new Exception(
"Uninitialized project, cannot get Locale ID.");
559 if(!isset($this->Name))
561 throw new Exception(
"Uninitialized project, cannot get Skeleton.");
573 if(!isset($this->Name))
575 throw new Exception(
"Uninitialized project, cannot get Document.");
589 if(!isset($this->Name))
591 throw new Exception(
"Uninitialized project, cannot get LastSeen.");
CreateProject($rootID, $parentID, $name, $isFolder, $localeID, $document='', $skeleton='')
Load($parentID, $name, $localeID, $brief)
LoadByID($projectID, $brief)
LoadRoot($name, $localeID)
__construct($loadByID=0, $brief=false)
LoadFromRecordSet($recordSet, $brief)
static ClearCache($localeID)
CreateRootProject($name, $localeID)
static GetRoots($localeID)
static InitLocaleIDCache()