function sItext() { return Singleton::itext(); }
/** * Gets the parents of the specified File * * @param int $fileId File Id * @return array Array of parent Files */ function getParents($fileId) { if ($this->permissions->checkInternal($this->_uid, $fileId, "RREAD")) { $parentnodes = $this->tree->getParents($fileId); if ($parentnodes[0] === NULL) { return array(); } $parentnodeidsql = implode(",", $parentnodes); $sql = "SELECT\n\t\t\t\tgroup2.LFT, group2.RGT, group2.VERSIONPUBLISHED, group2.ID AS ID, group2.LEVEL AS LEVEL, group2.PARENT AS PARENT, prop.FOLDER AS FOLDER,\n\t\t\t\tMAX(prop.VERSION) AS VERSION, prop.LOCKED AS LOCKED, pv.*\n\t\t\t\tFROM\n\t\t\t\t({$this->table} AS group2, yg_files_properties AS prop)\n\t\t\t\tLEFT JOIN yg_files_propsv AS pv ON pv.OID = prop.ID\n\t\t\t\tWHERE\n\t\t\t\t(group2.ID = prop.OBJECTID) AND (group2.ID IN ({$parentnodeidsql}))\n\t\t\t\tGROUP BY\n\t\t\t\tgroup2.LFT, group2.RGT, group2.VERSIONPUBLISHED, group2.ID order by group2.LEVEL DESC;"; $dbr = sYDB()->Execute($sql); $parentsO = $dbr->GetArray(); // Prepare weird array dimension $parents = array(); for ($i = 0; $i < count($parentsO); $i++) { $parents[$i][] = $parentsO[$i]; } if (count($parents) > 0) { $itext = Singleton::itext(); $parents[count($parents) - 1][0]['NAME'] = $itext['TXT_FILES']; } return $parents; } else { return false; } }
/** * Adds a new Template * * @param int $parentTemplateId Parent Template Id * @param int $folder (optional) Specifies if the new node should be a folder * @return int|false The new Template Id or FALSE in case of an error */ function add($parentTemplateId, $folder = 0) { $parentTemplateId = (int) $parentTemplateId; $folder = (int) $folder; $rread = $this->permissions->checkInternal($this->_uid, $parentTemplateId, "RSUB"); if ($rread && sUsergroups()->permissions->check($this->_uid, 'RTEMPLATES')) { // Knoten im Pagestree erzeugen $templateId = $this->tree->add($parentTemplateId); $itext = Singleton::itext(); $text = sYDB()->escape_string($itext['TXT_NEW_OBJECT']); $sql = "INSERT INTO `yg_templates_properties` (`OBJECTID`, `FOLDER`, `NAME`) VALUES (?, ?, ?);"; $result = sYDB()->Execute($sql, $templateId, $folder, $text); if ($result === false) { throw new Exception(sYDB()->ErrorMsg()); } $this->permissions->copyTo($parentTemplateId, $templateId); return $templateId; } else { return false; } }