public function process($objectid, $params) { $view = $params["VIEW"]; $fileMgr = sFileMgr(); $view = $fileMgr->views->get($view["ID"]); $fileinfo = $params["FILEINFO"]; $filedir = getrealpath(getcwd() . "/" . sConfig()->getVar('CONFIG/DIRECTORIES/FILESDIR')) . "/"; $filename = $fileinfo['OBJECTID'] . '-' . $fileinfo['VIEWVERSION'] . $fileinfo['FILENAME']; $file = $filedir . $filename; $imgsize = getimagesize($file); $info = $this->generateThumbnail($filename, $imgsize, $view['IDENTIFIER'], $view['WIDTH'], $view['HEIGHT'], $filedir, $file, $view['CONSTRAINWIDTH'], $view['CONSTRAINHEIGHT'], $view['WIDTHCROP'], $view['HEIGHTCROP']); if ($info) { $file = new File($fileinfo['OBJECTID'], $fileinfo['VERSION']); $file->views->addGenerated($view["ID"], $info["WIDTH"], $info["HEIGHT"], $info["VIEWTYPE"]); } return true; }
$confirmed = $this->params['confirmed']; $positive = $this->params['positive']; $objectYGID = explode('-', $objectYGID); $siteID = $objectYGID[1]; $objectID = $objectYGID[0]; switch ($objectType) { case 'page': $pageMgr = new PageMgr($siteID); $page = $pageMgr->getPage($objectID); $objectInfo = $page->get(); $commentsObject = $page->comments; $historyObject = $page->history; $historyType = HISTORYTYPE_PAGE; break; case 'file': $file = sFileMgr()->getFile($objectID); $objectInfo = $file->get(); $commentsObject = $file->comments; $historyObject = $file->history; $historyType = HISTORYTYPE_FILE; break; case 'cblock': $cb = sCblockMgr()->getCblock($objectID); $objectInfo = $cb->get(); $commentsObject = $cb->comments; $historyObject = $cb->history; $historyType = HISTORYTYPE_CO; break; } $hadError = false; $errorCode = NULL;
$tp2[$p]['ID'] = $tinfo['ID']; $tp2[$p]['NAME'] = $tinfo['NAME']; } $tp2[count($tp2) - 1]['NAME'] = $itext['TXT_TAGS'] != '' ? $itext['TXT_TAGS'] : '$TXT_TAGS'; $tags[$t]['PARENTS'] = $tp2; } $fileinfo['TAGS'] = $tags; $jsQueue->add($id, HISTORYTYPE_FILE, 'OBJECT_DELETE', sGuiUS(), 'file', NULL, NULL, $id . '-file', 'name'); $jsQueue->add($id, HISTORYTYPE_FILE, 'ADD_FILE', sGuiUS(), NULL); $jsQueue->add($id, HISTORYTYPE_FILE, 'CLEAR_REFRESH', sGuiUS(), 'file'); } else { // replace view $version = (int) $version; $versions = false; $zoom = $zoom * 100; $file = sFileMgr()->getFile($id, $version); if ($file) { $views = $file->views->getAssigned(); for ($i = 0; $i < count($views); $i++) { if ($views[$i]["IDENTIFIER"] == $view) { $viewinfo = $views[$i]; } } $params = array(); $params["FILEINFO"] = $fileinfo; $params["VIEW"] = $viewinfo; $params["FROMTMPFILE"] = $filetmpname; //copy($filetmpname, $filedir.$viewinfo["IDENTIFIER"].$fileinfo['OBJECTID'].'-'.$fileinfo['VIEWVERSION'].$filename); $moduleclass->process($fileinfo['OBJECTID'], $params); //$info = $moduleclass->generateThumbnail($fileinfo['OBJECTID'].'-'.$fileinfo['VIEWVERSION'].$fileinfo['FILENAME'], 0, $viewinfo['IDENTIFIER'], $viewinfo['WIDTH'], $viewinfo['HEIGHT'], $filedir, $filetmpname, $viewinfo['CONSTRAINWIDTH'], $viewinfo['CONSTRAINHEIGHT'], $viewinfo['WIDTHCROP'], $viewinfo['HEIGHTCROP'] ); //$file->views->addGenerated($viewinfo["ID"], $info["WIDTH"], $info["HEIGHT"], FILE_TYPE_WEBIMAGE);
$value = str_replace("\r", '', str_replace("\n", '\\n', $this->reponsedata[$property]->value)); if ($oldname == $value) { // No update needed, henceforth break break; } // Check for empty name if (trim($value) == '') { //$jsQueue->add ($data[0], HISTORYTYPE_ENTRYMASK, 'OBJECT_CHANGE', sGuiUS(), 'entrymask', NULL, NULL, $this->reponsedata[$property]->yg_id, 'name', $oldvalue); //$jsQueue->add ($data[0], HISTORYTYPE_FILE, 'REFRESH_WINDOW', sGuiUS(), 'name'); $koala->alert($itext['TXT_CANT_CHANGE_ENTRYMASKTITLE_TO_EMPTY_VALUE']); break; } // Special handling for files if ($propertyInfo[0]['TYPE'] == 'FILE') { if (substr($value, 0, 7) == '/image/') { $realValue = sFileMgr()->getFileIdByPname(substr($value, 7)); if ($realValue) { $value = $realValue; } } } // Special handling for links if ($propertyInfo[0]['TYPE'] == 'LINK') { $value = trim(prettifyUrl($value)); $result = checkLinkInternalExternal($value); if ($result['TYPE'] != 'external') { $value = createSpecialURLfromShortURL($value); } } // Special handling for textareas if ($propertyInfo[0]['TYPE'] == 'TEXTAREA') {
if ($cb) { $base = $cb->get(); $maxlevels = $base['LEVEL'] + 2; $objects = sCblockMgr()->getList($obj_id, array('SUBNODES'), $maxlevels, $roleid); $objects = sCblockMgr()->getAdditionalTreeInfo(false, $objects); // Check if the folder for blind contentblocks already exists and create it if it doesn't exist $embeddedCblockFolder = (int) sConfig()->getVar("CONFIG/EMBEDDED_CBLOCKFOLDER"); $smarty->assign("embeddedCblockFolder", $embeddedCblockFolder); } sUserMgr()->unimpersonate(); break; case 'files': sUserMgr()->impersonate(sUserMgr()->getAdministratorID()); $filetypeMgr = new Filetypes(); $objects = sFileMgr()->getList($obj_id, array('SUBNODES'), 'group2.LFT', $maxlevels, $roleid); $objects = sFileMgr()->getAdditionalTreeInfo(false, $objects); $filetypes = $filetypeMgr->getList(); foreach ($objects as $objects_idx => $objects_item) { foreach ($filetypes as $filetypes_item) { if ($objects_item['FILETYPE'] == $filetypes_item['OBJECTID']) { $objects[$objects_idx]['TYPEINFO'] = $filetypes_item; } } } sUserMgr()->unimpersonate(); break; case 'tags': sUserMgr()->impersonate(sUserMgr()->getAdministratorID()); $tagMgr = new Tags(); $objects = $tagMgr->getList($obj_id, array('SUBNODES'), true, $maxlevels, $roleid); $objects = $tagMgr->getAdditionalTreeInfo(false, $objects);
// Add to history $myObject->history->add($historyType, $contentarea, $cblockInfo['NAME'], 'TXT_' . $historyStr . '_H_COADD', $contentblockID); for ($i = 0; $i < count($contentareas); $i++) { if ($contentareas[$i]['CODE'] == $contentarea) { $colist = $myObject->getCblockList($contentareas[$i]['CODE']); for ($x = 0; $x < count($colist); $x++) { $coid = $colist[$x]['OBJECTID']; $lcb = sCblockMgr()->getCblock($coid, $colist[$x]['VERSION']); if ($coid > 0) { $colist[$x]['CBVERSION'] = $colist[$x]['VERSION']; $colist[$x]['ENTRYMASKS'] = $lcb->getEntrymasks(); for ($c = 0; $c < count($colist[$x]['ENTRYMASKS']); $c++) { $controlFormfields = $lcb->getFormfieldsInternal($colist[$x]['ENTRYMASKS'][$c]['LINKID']); for ($w = 0; $w < count($controlFormfields); $w++) { if ($controlFormfields[$w]['FORMFIELD'] == 6 || $controlFormfields[$w]['FORMFIELD'] == 16) { $file = sFileMgr()->getFile($controlFormfields[$w]['VALUE01']); if ($file) { $fileInfo = $file->get(); $controlFormfields[$w]['DISPLAYNAME'] = $fileInfo['NAME']; } } if ($controlFormfields[$w]['FORMFIELD'] == 7) { $clcb = sCblockMgr()->getCblock($controlFormfields[$w]['VALUE01']); if ($clcb) { $info = $clcb->get(); $controlFormfields[$w]['DISPLAYNAME'] = $info['NAME']; } } if ($controlFormfields[$w]['FORMFIELD'] == 8) { $info = $myObject->tags->get($controlFormfields[$w]['VALUE01']); $controlFormfields[$w]['DISPLAYNAME'] = $info['NAME'];
if ($acb) { $assignedComments[$assignedCommentIdx]['CBLOCKINFO'] = $acb->get(); $assignedComments[$assignedCommentIdx]['CBLOCKINFO']['RWRITE'] = $acb->permissions->checkInternal(sUserMgr()->getCurrentUserID(), $assignedComment['OBJECTID'], "RWRITE"); $assignedComments[$assignedCommentIdx]['CBLOCKINFO']['RDELETE'] = $acb->permissions->checkInternal(sUserMgr()->getCurrentUserID(), $assignedComment['OBJECTID'], "RDELETE"); $styleData = getStyleForContentblock($assignedComments[$assignedCommentIdx]['CBLOCKINFO']); $assignedComments[$assignedCommentIdx]['STYLE'] = $styleData; $assignedComments[$assignedCommentIdx]['HASCHANGED'] = $assignedComments[$assignedCommentIdx]['CBLOCKINFO']['HASCHANGED']; $assignedComments[$assignedCommentIdx]['RMODERATE'] = $acb->permissions->checkInternal(sUserMgr()->getCurrentUserID(), $assignedComment['OBJECTID'], 'RMODERATE'); $assignedComments[$assignedCommentIdx]['RCOMMENT'] = $acb->permissions->checkInternal(sUserMgr()->getCurrentUserID(), $assignedComment['OBJECTID'], 'RCOMMENT'); $commentsObject = $acb->comments; } break; case 'FILE': $assignedComments[$assignedCommentIdx]['PARENTS'] = $fileMgr->getParents($assignedComment['OBJECTID']); array_pop($assignedComments[$assignedCommentIdx]['PARENTS']); $file = sFileMgr()->getFile($assignedComment['OBJECTID']); if ($file) { $assignedComments[$assignedCommentIdx]['FILEINFO'] = $file->get(); $assignedComments[$assignedCommentIdx]['RMODERATE'] = $file->permissions->checkInternal(sUserMgr()->getCurrentUserID(), $assignedComment['OBJECTID'], 'RMODERATE'); $assignedComments[$assignedCommentIdx]['RCOMMENT'] = $file->permissions->checkInternal(sUserMgr()->getCurrentUserID(), $assignedComment['OBJECTID'], 'RCOMMENT'); $commentsObject = $file->comments; } break; } if ($assignedComments[$assignedCommentIdx]['CREATEDTS']) { $assignedComments[$assignedCommentIdx]['CREATEDTS'] = TStoLocalTS($assignedComments[$assignedCommentIdx]['CREATEDTS']); $assignedComments[$assignedCommentIdx]['CHANGEDTS'] = TStoLocalTS($assignedComments[$assignedCommentIdx]['CHANGEDTS']); } $assignedComments[$assignedCommentIdx]['STATUS'] = $commentsObject->getStatus($assignedComment['OBJECTID']); } } else {
/** * Post processes a property value (resolves urls, permanent names, etc.) * * @param string $type Property type * @param string $value Property value * @return mixed Post processed property value */ function postProcessValue($type, $value) { switch ($type) { case 'LINK': $linkInfo = checkLinkInternalExternal(resolveSpecialURL($value)); if ($linkInfo['TYPE'] == 'internal') { return resolveSpecialURL($linkInfoJSON['href']); } elseif ($linkInfo['TYPE'] == 'file') { $pname = sFileMgr()->getPNameByFileId($linkInfo['INFO']['FILE_ID']); if ($pname) { return sApp()->webroot . 'download/' . $pname; } } else { if ($value != '') { return $value; } else { return NULL; } } case 'PAGE': $pageInfo = json_decode($value, true); $tmpPageMgr = sPageMgr($pageInfo['site']); $tmpPage = $tmpPageMgr->getPage($pageInfo['page']); if ($tmpPage) { $tmpUrl = $tmpPage->getUrl(); $tmpPname = $tmpPageMgr->getPNameByPageId($pageInfo['page']); return array('SITE_ID' => $pageInfo['site'], 'PAGE_ID' => $pageInfo['page'], 'URL' => $tmpUrl, 'PNAME' => $tmpPname, 'VALUE' => $value); } else { return NULL; } case 'FILE': $pname = sFileMgr()->getPNameByFileId($value); if ($pname) { return array('FILE_ID' => $value, 'URL' => sApp()->webroot . 'download/' . $pname, 'IMAGE_URL' => sApp()->webroot . 'image/' . $pname, 'PNAME' => $pname, 'VALUE' => $value); } else { return NULL; } case 'RICHTEXT': return replaceSpecialURLs($value); break; case 'CBLOCK': $pname = sCblockMgr()->getPNameByCblockId($value); if ($pname) { return array('CBLOCK_ID' => $value, 'PNAME' => $pname, 'VALUE' => $value); } else { return NULL; } case 'TAG': $tagInfo = sTags()->get($value); if ($tagInfo) { return array('TAG_ID' => $value, 'NAME' => $tagInfo['NAME'], 'VALUE' => $value); } else { return NULL; } default: return $value; } }
case 'filefolder': $file = new File($objectID); $latestFinalVersion = $file->getLatestApprovedVersion(); $file = new File($objectID, $latestFinalVersion); $objectInfo = $file->get(); $tags = $file->tags->getAssigned(); $object_permissions = array(); $object_permissions['RWRITE'] = $file->permissions->checkInternal(sUserMgr()->getCurrentUserID(), $objectID, "RWRITE"); $object_permissions['READONLY'] = !$file->permissions->checkInternal(sUserMgr()->getCurrentUserID(), $objectID, "RWRITE"); if ($objectInfo['DELETED'] == 1) { $object_permissions['RWRITE'] = false; $object_permissions['READONLY'] = true; } // Get current locks for this token (and unlock them) $lockToken = sGuiUS() . '_' . $this->request->parameters['win_no']; $lockedObjects = sFileMgr()->getLocksByToken($lockToken); foreach ($lockedObjects as $lockedObject) { $currentObject = new File($lockedObject['OBJECTID']); $currentObject->releaseLock($lockedObject['TOKEN']); } // Check for lock, and lock if not locked $lockStatus = $file->getLock(); if ($lockStatus['LOCKED'] == 0) { $lockedFailed = !$file->acquireLock($lockToken); } else { $lockedFailed = true; } for ($i = 0; $i < count($tags); $i++) { $myparents = $file->tags->tree->getParents($tags[$i]['ID']); $parents = array(); for ($p = 0; $p < count($myparents) - 1; $p++) {
$latestVersion = $file->getLatestApprovedVersion(); $file = sFileMgr()->getFile($fileID, $latestVersion); $fileInfo = $file->get(); $url = $file->getUrl(); $fileTypes = $fileMgr->getFiletypes(); $fileInfo['RDELETE'] = $file->permissions->checkInternal(sUserMgr()->getCurrentUserID(), $fileID, 'RDELETE'); $fileInfo['RWRITE'] = $file->permissions->checkInternal(sUserMgr()->getCurrentUserID(), $fileID, 'RWRITE'); if ($fileInfo['DELETED'] == 1) { $fileInfo['RDELETE'] = false; $fileInfo['RWRITE'] = false; } // Get current locks for this token (and unlock them) $lockToken = sGuiUS() . '_' . $this->request->parameters['win_no']; $lockedObjects = $fileMgr->getLocksByToken($lockToken); foreach ($lockedObjects as $lockedObject) { $currentObject = sFileMgr()->getFile($lockedObject['OBJECTID']); $currentObject->releaseLock($lockedObject['TOKEN']); } // Check for lock, and lock if not locked $lockStatus = $file->getLock(); if ($lockStatus['LOCKED'] == 0) { $lockedFailed = !$file->acquireLock($lockToken); } else { $lockedFailed = true; } $views = $file->views->getAssigned(true); $viewInfo = $file->views->getGeneratedViewInfo($views[0]["ID"]); $fileInfo['WIDTH'] = $viewInfo[0]["WIDTH"]; $fileInfo['HEIGHT'] = $viewInfo[0]["HEIGHT"]; foreach ($fileTypes as $fileTypes_item) { if ($fileTypes_item['ID'] == $fileInfo['FILETYPE']) {
if ($refinfo["OBJECTID"] < 1) { $outgoing[$refcohash[$hash]]["VIATARGETS"][$viacnt]["BAD"] = 1; } else { $outgoing[$refcohash[$hash]]["VIATARGETS"][$viacnt]["NAME"] = $refinfo["NAME"]; $outgoing[$refcohash[$hash]]["VIATARGETS"][$viacnt]["IDENTIFIER"] = $refinfo["IDENTIFIER"]; $outgoing[$refcohash[$hash]]["VIATARGETS"][$viacnt]["CODE"] = $refinfo["CODE"]; $outgoing[$refcohash[$hash]]["VIATARGETS"][$viacnt]["COLOR"] = $refinfo["COLOR"]; $outgoing[$refcohash[$hash]]["VIATARGETS"][$viacnt]["ID"] = $oref[$i]["TGTOID"]; $outgoing[$refcohash[$hash]]["VIATARGETS"][$viacnt]["SITE"] = 'file'; } } } elseif ($oref[$i]["TGTTYPE"] == REFTYPE_IMAGE) { $pr = sFileMgr()->getParents($oref[$i]["TGTOID"]); array_pop($pr); $outgoing[$refcohash[$hash]]["VIATARGETS"][$viacnt]["PARENTS"] = $pr; $file = sFileMgr()->getFile($oref[$i]["TGTOID"]); if ($file) { $refinfo = $file->get(); if ($refinfo["OBJECTID"] < 1) { $outgoing[$refcohash[$hash]]["VIATARGETS"][$viacnt]["BAD"] = 1; } else { $outgoing[$refcohash[$hash]]["VIATARGETS"][$viacnt]["NAME"] = $refinfo["NAME"]; $outgoing[$refcohash[$hash]]["VIATARGETS"][$viacnt]["IDENTIFIER"] = $refinfo["IDENTIFIER"]; $outgoing[$refcohash[$hash]]["VIATARGETS"][$viacnt]["CODE"] = $refinfo["CODE"]; $outgoing[$refcohash[$hash]]["VIATARGETS"][$viacnt]["COLOR"] = $refinfo["COLOR"]; } } } elseif ($oref[$i]["TGTTYPE"] == REFTYPE_EMAIL) { $outgoing[$refcohash[$hash]]["VIATARGETS"][$viacnt]["NAME"] = $oref[$i]["TGTOID"]; } elseif ($oref[$i]["TGTTYPE"] == REFTYPE_EXTERNAL) { $outgoing[$refcohash[$hash]]["VIATARGETS"][$viacnt]["NAME"] = $oref[$i]["TGTOID"];
/** * Saves content to a Formfield * * @param int $linkId Entrymask Formfield Link Id * @param string $value01 Content for Formfield parameter 1 * @param string $value02 Content for Formfield parameter 2 * @param string $value02 Content for Formfield parameter 3 * @param string $value04 Content for Formfield parameter 4 * @param string $value05 Content for Formfield parameter 5 * @param string $value06 Content for Formfield parameter 6 * @param string $value07 Content for Formfield parameter 7 * @param string $value08 Content for Formfield parameter 8 * @return bool TRUE on success or FALSE in case of an error * @throws Exception */ function setFormfield($linkId, $value01, $value02, $value03, $value04, $value05, $value06, $value07, $value08) { $cbId = $this->_id; $linkId = (int) $linkId; if ($this->permissions->checkInternal($this->_uid, $cbId, "RWRITE")) { $value01 = sYDB()->escape_string($value01); $value02 = sYDB()->escape_string($value02); $value03 = sYDB()->escape_string($value03); $value04 = sYDB()->escape_string($value04); $value05 = sYDB()->escape_string($value05); $value06 = sYDB()->escape_string($value06); $value07 = sYDB()->escape_string($value07); $value08 = sYDB()->escape_string($value08); // Check if an URL needs to be generated $sql = "SELECT\n\t\t\t\t\t\tt.TYPE\n\t\t\t\t\tFROM\n\t\t\t\t\t\t`yg_contentblocks_lnk_entrymasks_c` AS c,\n\t\t\t\t\t\t`yg_formfields` AS t\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t(c.FORMFIELD = t.ID) AND\n\t\t\t\t\t\t(c.ID = ?);"; $ra = $this->cacheExecuteGetArray($sql, $linkId); $webRoot = (string) sConfig()->getVar("CONFIG/DIRECTORIES/WEBROOT"); switch ($ra[0]['TYPE']) { case 'PAGE': if (strlen(trim($value02)) && strlen(trim($value01))) { $siteMgr = new Sites(); $sitePName = $siteMgr->getPName($value02); $pageMgr = sPageMgr($value02); $tmpPage = $pageMgr->getPage($value01); $tmpPageInfo = $tmpPage->get(); $value03 = $webRoot . $sitePName . '/' . $tmpPageInfo['PNAME'] . '/'; $value04 = $tmpPageInfo['PNAME']; $value05 = $sitePName; } else { $value01 = $value02 = $value03 = $value04 = ''; } break; case 'FILE': if (strlen(trim($value01))) { $tmpFile = sFileMgr()->getFile($value01); if ($tmpFile) { $tmpFileInfo = $tmpFile->get(); $value02 = $webRoot . 'download/' . $tmpFileInfo['PNAME'] . '/'; $value03 = $tmpFileInfo['PNAME']; $value04 = $webRoot . 'image/' . $tmpFileInfo['PNAME'] . '/'; } } else { $value01 = $value02 = $value03 = ''; } break; } $sql = "UPDATE `yg_contentblocks_lnk_entrymasks_c` SET\n\t\t\t\t\t\tVALUE01 = ?,\n\t\t\t\t\t\tVALUE02 = ?,\n\t\t\t\t\t\tVALUE03 = ?,\n\t\t\t\t\t\tVALUE04 = ?,\n\t\t\t\t\t\tVALUE05 = ?,\n\t\t\t\t\t\tVALUE06 = ?,\n\t\t\t\t\t\tVALUE07 = ?,\n\t\t\t\t\t\tVALUE08 = ?\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t(ID = ?);"; $result = sYDB()->Execute($sql, $value01, $value02, $value03, $value04, $value05, $value06, $value07, $value08, $linkId); if ($result === false) { throw new Exception(sYDB()->ErrorMsg()); } // Check to which object this entrymask belongs to $CblockInfo = $this->get(); // Check if it is an embedded entrymask if ($CblockInfo['EMBEDDED']) { $sql = "SELECT PID, PVERSION FROM yg_mailing_lnk_cb WHERE CBID = " . $CblockInfo['OBJECTID'] . " AND CBVERSION = " . $CblockInfo['VERSION'] . ";"; $linkedMailings = $this->cacheExecuteGetArray($sql); if (count($linkedMailings) > 0) { // Yes, it links to a Mailing $mailingMgr = new MailingMgr(); foreach ($linkedMailings as $linkedMailing) { $mailing = $mailingMgr->getMailing($linkedMailing['PID'], $linkedMailing['PVERSION']); if ($mailing) { $mailing->markAsChanged(); } } } else { // Check if it is related to a Page $sites = sSites()->getList(true, false); for ($i = 0; $i < count($sites); $i++) { $sql = "SELECT PID, PVERSION FROM yg_site_" . (int) $sites[$i]['ID'] . "_lnk_cb WHERE CBID = " . (int) $CblockInfo['OBJECTID'] . " AND CBVERSION = " . (int) $CblockInfo['VERSION'] . ";"; $linkedPages = $this->cacheExecuteGetArray($sql); if (count($linkedPages) > 0) { // Yes, it links to a Pages $pageMgr = sPageMgr($sites[$i]['ID']); foreach ($linkedPages as $linkedPage) { $page = $pageMgr->getPage($linkedPage['PID'], $linkedPage['PVERSION']); if ($page) { $page->markAsChanged(); } } } } } } else { // Entrymask is NOT embedded, so mark this Cblock as changed $this->markAsChanged(); } return true; } else { return false; } }
/** * Updates filename, filetype and source file of this File * * @param string $filename New filename * @param int $filetypeId New Filetype Id * @param $tmpfile Temporary file * @param $produceNewVersion (optional) TRUE if a new version should be produced * @return int|false New File version or FALSE in case of an error */ public function updateFile($filename, $filetypeId, $tmpfile, $produceNewVersion = true) { if ($this->permissions->checkInternal($this->_uid, $this->getID(), "RWRITE")) { if ($produceNewVersion == true) { $newVersion = $this->newVersion(); } else { $newVersion = $this->getVersion(); } $filetypeId = (int) $filetypeId; if ($filetypeId == 0) { return false; } if (!file_exists($tmpfile)) { return false; } $filedir = sConfig()->getVar('CONFIG/DIRECTORIES/FILESDIR') . "/"; $fprefix = $this->getID() . "-" . $newVersion; copy($tmpfile, $filedir . $fprefix . $filename); unlink($tmpfile); $fileSize = filesize($filedir . $fprefix . $filename); $this->setFilename($filename); $this->setFileSize($fileSize); $this->setFileType($filetypeId); $this->setViewVersion($newVersion); $this->views->scheduleUpdate(); sFileMgr()->callExtensionHook('onUpdate', (int) $this->_id, $newVersion); return $newVersion; } else { return false; } }
for ($p = 0; $p < count($tp); $p++) { $tinfo = $file->tags->get($tp[$p]); $tp2[$p]['ID'] = $tinfo['ID']; $tp2[$p]['NAME'] = $tinfo['NAME']; } $tp2[count($tp2) - 1]['NAME'] = $itext['TXT_TAGS'] != '' ? $itext['TXT_TAGS'] : '$TXT_TAGS'; array_pop($tp2); $tags[$t]['PARENTS'] = $tp2; } $filelist[$i]['TAGS'] = $tags; $filelist[$i]['THUMB'] = 0; $filelist[$i]['CLASSNAME'] = ''; $filelist[$i]['IMAGE'] = 0; $webroot = sApp()->webroot; $filelist[$i]['DOWNLOAD_URL'] = $webroot . 'download/' . $filelist[$i]['PNAME']; $scheduledJobs = sFileMgr()->scheduler->getSchedule($filelist[$i]['OBJECTID']); $hiddenViewsToProcess = 0; foreach ($scheduledJobs as $scheduledJob) { if ($scheduledJob['PARAMETERS']['VIEW']['HIDDEN']) { $hiddenViewsToProcess++; } } $hiddenviews = $file->views->getHiddenViews(); foreach ($hiddenviews as $hiddenview) { if ($hiddenview['IDENTIFIER'] == 'yg-thumb' || $hiddenview['IDENTIFIER'] == 'yg-list') { $tmpviewinfo = $file->views->getGeneratedViewInfo($hiddenview['ID']); if ($tmpviewinfo[0]['TYPE'] == FILE_TYPE_WEBIMAGE) { $filelist[$i]['THUMB'] = 1; } foreach ($scheduledJobs as $scheduledJob) { if ($scheduledJob['PARAMETERS']['VIEW']['IDENTIFIER'] == $hiddenview['IDENTIFIER']) {
/** * Gets all Contentareas of this Page including Cblocks and content * * @return array */ function getContentInternal() { $pageId = $this->_id; if ($this->permissions->checkInternal($this->_uid, $pageId, "RREAD")) { $templateMgr = new Templates(); $pageInfo = $this->get(); $contentareas = $templateMgr->getContentareas($pageInfo['TEMPLATEID']); for ($i = 0; $i < count($contentareas); $i++) { $colist = $this->getCblockList($contentareas[$i]['CODE']); for ($x = 0; $x < count($colist); $x++) { if ($colist[$x]['OBJECTID'] > 0) { if ($colist[$x]['EMBEDDED'] == 0) { $cb = sCblockMgr()->getPublishedCblock($colist[$x]['OBJECTID']); if ($cb) { $cbInfo = $cb->get(); $colist[$x]['CBVERSION'] = $colist[$x]['VERSION'] = $cbInfo['VERSIONPUBLISHED']; } } else { $cb = sCblockMgr()->getCblock($colist[$x]['OBJECTID'], $colist[$x]['VERSION']); $colist[$x]['CBVERSION'] = $colist[$x]['VERSION']; } if ($cb) { $colist[$x]['ENTRYMASKS'] = $cb->getEntrymasks(); for ($c = 0; $c < count($colist[$x]['ENTRYMASKS']); $c++) { $controlFormfields = $cb->getFormfieldsInternal($colist[$x]['ENTRYMASKS'][$c]['LINKID']); for ($w = 0; $w < count($controlFormfields); $w++) { if ($controlFormfields[$w]['FORMFIELD'] == 6 || $controlFormfields[$w]['FORMFIELD'] == 16) { if (trim($controlFormfields[$w]['VALUE01'])) { $file = sFileMgr()->getFile($controlFormfields[$w]['VALUE01']); if ($file) { $fileInfo = $file->get(); $controlFormfields[$w]['DISPLAYNAME'] = $fileInfo['NAME']; } } } if ($controlFormfields[$w]['FORMFIELD'] == 7) { if (trim($controlFormfields[$w]['VALUE01'])) { $icb = sCblockMgr()->getCblock($controlFormfields[$w]['VALUE01']); if ($icb) { $info = $icb->get(); $controlFormfields[$w]['DISPLAYNAME'] = $info['NAME']; } } } if ($controlFormfields[$w]['FORMFIELD'] == 8) { if (trim($controlFormfields[$w]['VALUE01'])) { $info = $this->tags->get($controlFormfields[$w]['VALUE01']); $controlFormfields[$w]['DISPLAYNAME'] = $info['NAME']; } } } $colist[$x]['ENTRYMASKS'][$c]['FORMFIELDS'] = $controlFormfields; } } else { // dummy $colist[$x] = NULL; } } } // Clear all "NULL" entries $realCoList = array(); foreach ($colist as $colistIdx => $colistItem) { if ($colistItem !== NULL) { $realCoList[] = $colistItem; } } $contentareas[$i]['LIST'] = $realCoList; } return $contentareas; } else { return false; } }
Contentblocks, Seiten (auch seiten die blinde contentblocks enthalten mit control typ tag), */ $incoming_files = array(); $incoming_cos = array(); $incoming_mailings = array(); $incoming_pages = array(); // Get all files with this tag $filterArray = array(); $filterArray[] = array('TYPE' => 'DELETED', 'OPERATOR' => 'is_not', 'VALUE' => 1); $tagged_files = sFileMgr()->tags->getByTag($tag_id, "OBJECTORDER DESC", "OR", false, $filterArray); foreach ($tagged_files as $tagged_file_item) { $file = sFileMgr()->getFile($tagged_file_item['OBJECTID']); if ($file) { $objectInfo = $file->get(); $pr = sFileMgr()->getParents($tagged_file_item['OBJECTID']); array_pop($pr); $objectparents = $pr; array_push($incoming_files, array('ID' => $tagged_file_item['OBJECTID'], 'NAME' => $objectInfo['NAME'], 'PARENTS' => $objectparents, 'IDENTIFIER' => $objectInfo['IDENTIFIER'], 'CODE' => $objectInfo['CODE'], 'COLOR' => $objectInfo['COLOR'], 'FOLDER' => $objectInfo['FOLDER'])); } } // Get all cos with this tag $filterArray = array(); $filterArray[] = array('TYPE' => 'DELETED', 'OPERATOR' => 'is_not', 'VALUE' => 1); $tagged_cos = sCblockMgr()->tags->getByTag($tag_id, "OBJECTORDER DESC", "OR", false, $filterArray); foreach ($tagged_cos as $tagged_co_item) { $pr = sCblockMgr()->getParents($tagged_co_item['OBJECTID']); $cb = sCblockMgr()->getCblock($tagged_co_item['OBJECTID']); $cblockInfo = $cb->get(); $cblockInfo['RWRITE'] = $cb->permissions->checkInternal(sUserMgr()->getCurrentUserID(), $tagged_co_item['OBJECTID'], "RWRITE"); $cblockInfo['RDELETE'] = $cb->permissions->checkInternal(sUserMgr()->getCurrentUserID(), $tagged_co_item['OBJECTID'], "RDELETE");
/** * Function to get the queued commands from the history */ public function getQueuedCommands() { $entrymaskMgr = new Entrymasks(); $jsQueue = new JSQueue(NULL); $tagMgr = new Tags(); $queuedCommands = array(); $currentQueueId = sGuiLH(); if (!$currentQueueId || $currentQueueId == 'false') { return; // if running first time (only) //$currentQueueId = $jsQueue->getLastQueueId(); } if ($currentQueueId) { $queuedCommandsRaw = $jsQueue->getQueue($currentQueueId, sGuiUS()); $templateMgr = new Templates(); $viewMgr = new Views(); foreach ($queuedCommandsRaw as $queuedCommandRaw) { // Check permissions $permissionsObj = NULL; $objectID = $queuedCommandRaw['OID']; $siteID = $queuedCommandRaw['SITEID']; $icons = new Icons(); $url = $imgurl = ''; switch ($queuedCommandRaw['TYPE']) { case HISTORYTYPE_MAILING: $mailingMgr = new MailingMgr(); $mailingObj = $mailingMgr->getMailing($objectID); $permissionsObj = $mailingObj->permissions; break; case HISTORYTYPE_PAGE: if ($siteID > 0 && $objectID > 0) { $pageMgr = new PageMgr($siteID); $pageObj = $pageMgr->getPage($objectID); if ($pageObj) { $url = $pageObj->getUrl(); $permissionsObj = $pageObj->permissions; } } break; case HISTORYTYPE_CO: if (!$objectID) { continue; } $cb = sCblockMgr()->getCblock($objectID); $permissionsObj = $cb->permissions; break; case HISTORYTYPE_ENTRYMASK: $permissionsObj = $entrymaskMgr->permissions; break; case HISTORYTYPE_FILE: $permissionsObj = sFileMgr()->permissions; if ($objectID) { $file = sFileMgr()->getFile($objectID); if ($file) { $info = $file->get(); $url = sApp()->webroot . "download/" . $info['PNAME'] . "/"; $hiddenviews = $file->views->getHiddenViews(); foreach ($hiddenviews as $hiddenview) { if ($hiddenview['IDENTIFIER'] == "YGSOURCE") { $tmpviewinfo = $file->views->getGeneratedViewInfo($hiddenview['ID']); if ($tmpviewinfo[0]['TYPE'] == FILE_TYPE_WEBIMAGE) { $imgurl = sApp()->webroot . "image/" . $info['PNAME'] . "/"; } } } } } break; case HISTORYTYPE_TEMPLATE: $permissionsObj = $templateMgr->permissions; break; case HISTORYTYPE_TAG: $permissionsObj = $tagMgr->permissions; break; case HISTORYTYPE_SITE: $pageMgr = new PageMgr($siteID); $sitePages = $pageMgr->tree->get(0, 1); $tmpPageID = $sitePages[0]["ID"]; if ($tmpPageID) { $pageObj = $pageMgr->getPage($tmpPageID); $permissionsObj = $pageObj->permissions; } break; case HISTORYTYPE_USER: $permissionsObj = sUsergroups()->usergroupPermissions; break; case HISTORYTYPE_USERGROUP: case HISTORYTYPE_EXTERNAL: case HISTORYTYPE_IMAGE: case HISTORYTYPE_FILETYPES: case HISTORYTYPE_FILEVIEWS: case HISTORYTYPE_JSQUEUE: case HISTORYTYPE_PERMISSION: default: break; } if ($queuedCommandRaw['TEXT'] == 'NOPERMISSIONCHECK' || strpos($queuedCommandRaw['OLDVALUE'], 'HIGHLIGHT') === 0 || strpos($queuedCommandRaw['OLDVALUE'], 'UNHIGHLIGHT') === 0 || strpos($queuedCommandRaw['OLDVALUE'], 'PAGE_MOVE') === 0 || strpos($queuedCommandRaw['OLDVALUE'], 'PAGE_HIDE') === 0 || strpos($queuedCommandRaw['OLDVALUE'], 'PAGE_UNHIDE') === 0 || strpos($queuedCommandRaw['OLDVALUE'], 'PAGE_ACTIVATE') === 0 || strpos($queuedCommandRaw['OLDVALUE'], 'RELOAD_WINDOW') === 0 || strpos($queuedCommandRaw['OLDVALUE'], 'CLEAR_USERINFOS') === 0 || strpos($queuedCommandRaw['OLDVALUE'], 'SET_USERINFOS') === 0 || strpos($queuedCommandRaw['OLDVALUE'], 'CLEAR_FILEINFOS') === 0 || strpos($queuedCommandRaw['OLDVALUE'], 'REFRESH_WINDOW') === 0 || strpos($queuedCommandRaw['OLDVALUE'], 'ADD_FILE') === 0 || strpos($queuedCommandRaw['OLDVALUE'], 'OBJECT_DELETE') === 0 || strpos($queuedCommandRaw['OLDVALUE'], 'OBJECT_ADD_TAG') === 0 || strpos($queuedCommandRaw['OLDVALUE'], 'OBJECT_CHANGE') === 0 || strpos($queuedCommandRaw['OLDVALUE'], 'OBJECT_CHANGECLASS') === 0 || strpos($queuedCommandRaw['OLDVALUE'], 'OBJECT_CHANGEPNAME') === 0 || strpos($queuedCommandRaw['OLDVALUE'], 'OBJECT_CHANGEBGIMAGE') === 0 || strpos($queuedCommandRaw['OLDVALUE'], 'OBJECT_CHANGE_LOCK_STATE') === 0) { $allowed = true; } else { if ($permissionsObj != NULL) { $allowed = $permissionsObj->checkInternal(sUserMgr()->getCurrentUserID(), $objectID, "RREAD"); } } if ($permissionsObj != NULL || $allowed) { if ($allowed) { $itext = sItext(); switch ($queuedCommandRaw['OLDVALUE']) { case 'UNHIGHLIGHT': if ($queuedCommandRaw['TEXT']) { //$queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_unHilite(\''.$queuedCommandRaw['TEXT'].'\', \''.$objectID.'-template\', \''.$queuedCommandRaw['TEXT'].'\');'; $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_unHilite(\'' . $queuedCommandRaw['TEXT'] . '\', \'' . $queuedCommandRaw['VALUE1'] . '\', \'' . $queuedCommandRaw['VALUE2'] . '\');'; } break; case 'OBJECT_CHANGE_LOCK_STATE': if ($queuedCommandRaw['TEXT']) { $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_changeWindowLockStateForObject(\'' . $queuedCommandRaw['TEXT'] . '\', \'' . $queuedCommandRaw['VALUE1'] . '\', \'' . $queuedCommandRaw['VALUE2'] . '\');'; } break; case 'OBJECT_CHANGEBGIMAGE': if ($queuedCommandRaw['TEXT']) { $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_changeBGImage(\'' . $queuedCommandRaw['TEXT'] . '\', \'' . $queuedCommandRaw['VALUE1'] . '\', \'' . $queuedCommandRaw['VALUE2'] . '\', \'' . $queuedCommandRaw['VALUE3'] . '\');'; } break; case 'OBJECT_CHANGECLASS': if ($queuedCommandRaw['TEXT']) { $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_changeClass(\'' . $queuedCommandRaw['TEXT'] . '\', \'' . $queuedCommandRaw['VALUE1'] . '\', \'' . $queuedCommandRaw['VALUE2'] . '\', \'' . $queuedCommandRaw['VALUE3'] . '\');'; } break; case 'OBJECT_CHANGEPNAME': if ($queuedCommandRaw['TEXT']) { $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_changePName(\'' . $queuedCommandRaw['TEXT'] . '\', \'' . $queuedCommandRaw['VALUE1'] . '\', \'' . $queuedCommandRaw['VALUE2'] . '\', \'' . $queuedCommandRaw['VALUE3'] . '\', \'' . $url . '\', \'' . $imgurl . '\');'; } break; case 'OBJECT_CHANGE': if ($queuedCommandRaw['TEXT']) { $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_change(\'' . $queuedCommandRaw['TEXT'] . '\', \'' . addslashes($queuedCommandRaw['VALUE1']) . '\', \'' . addslashes($queuedCommandRaw['VALUE2']) . '\', \'' . addslashes($queuedCommandRaw['VALUE3']) . '\');'; } break; case 'OBJECT_ADD_TAG': if ($queuedCommandRaw['TEXT']) { $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_addTag(\'' . $queuedCommandRaw['TEXT'] . '\', \'' . $queuedCommandRaw['VALUE1'] . '\', \'' . $queuedCommandRaw['VALUE2'] . '\', \'' . $queuedCommandRaw['VALUE3'] . '\', \'' . $queuedCommandRaw['VALUE4'] . '\', ' . stripslashes($queuedCommandRaw['VALUE5']) . ', \'' . $queuedCommandRaw['VALUE6'] . '\', \'' . $queuedCommandRaw['VALUE7'] . '\');'; } break; case 'OBJECT_DELETE': if ($queuedCommandRaw['TEXT']) { $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_del(\'' . $queuedCommandRaw['TEXT'] . '\', \'' . $queuedCommandRaw['VALUE1'] . '\', \'' . $queuedCommandRaw['VALUE2'] . '\', \'' . $queuedCommandRaw['VALUE3'] . '\', \'' . $queuedCommandRaw['VALUE4'] . '\');'; } break; case 'ADD_FILE': $file = new File($objectID); $latestVersion = $file->getLatestApprovedVersion(); $file = new File($objectID, $latestVersion); $fileInfo = $file->get(); $reftracker = new Reftracker(); if ($fileInfo['CREATEDBY']) { $user = new User($fileInfo['CREATEDBY']); $userInfo = $user->get(); $userInfo['PROPS'] = $user->properties->getValues($fileInfo['CREATEDBY']); } $fileInfo['CUSTOM_DATE'] = date('d.m.Y', TStoLocalTS($fileInfo['CHANGEDTS'])); $fileInfo['CUSTOM_TIME'] = date('G:i', TStoLocalTS($fileInfo['CHANGEDTS'])); $fileInfo['REFS'] = $reftracker->getIncomingForFile($fileInfo['OBJECTID']); $tags = $file->tags->getAssigned(); for ($t = 0; $t < count($tags); $t++) { $tp = array(); $tp = $file->tags->tree->getParents($tags[$t]['ID']); $tp2 = array(); for ($p = 0; $p < count($tp); $p++) { $tinfo = $file->tags->get($tp[$p]); $tp2[$p]['ID'] = $tinfo['ID']; $tp2[$p]['NAME'] = $tinfo['NAME']; } $tp2[count($tp2) - 1]['NAME'] = $itext['TXT_TAGS'] != '' ? $itext['TXT_TAGS'] : '$TXT_TAGS'; $tags[$t]['PARENTS'] = $tp2; } $fileInfo['TAGS'] = $tags; $fileInfo['THUMB'] = 1; if ($queuedCommandRaw['TEXT'] == 'nothumb') { $fileInfo['THUMB'] = 0; } $views = $file->views->getAssigned(); foreach ($views as $view) { if ($view["IDENTIFIER"] == "YGSOURCE") { $viewinfo = $file->views->getGeneratedViewInfo($view["ID"]); $fileInfo["WIDTH"] = $viewinfo[0]["WIDTH"]; $fileInfo["HEIGHT"] = $viewinfo[0]["HEIGHT"]; } } $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_addFile(\'file\', \'' . $fileInfo['PARENT'] . '-file\', \'' . $objectID . '\', \'' . $fileInfo['THUMB'] . '\', \'' . $fileInfo['COLOR'] . '\', \'' . $fileInfo['CODE'] . '\', \'' . $fileInfo['NAME'] . '\', \'' . $fileInfo['PNAME'] . '\', \'' . json_encode($fileInfo['TAGS']) . '\', \'' . $fileInfo['FILESIZE'] . '\', \'' . count($fileInfo['REFS']) . '\', \'' . TStoLocalTS($fileInfo['CHANGEDTS']) . '\', \'' . $fileInfo['CUSTOM_DATE'] . '\', \'' . $fileInfo['CUSTOM_TIME'] . '\', \'' . $fileInfo['UID'] . '\', \'' . $userInfo['PROPS']['FIRSTNAME'] . ' ' . $userInfo['PROPS']['LASTNAME'] . '\', \'' . $fileInfo['FILENAME'] . '\', \'' . $fileInfo["WIDTH"] . '\', \'' . $fileInfo['HEIGHT'] . '\');'; break; case 'REFRESH_TAGS': if ($queuedCommandRaw['TEXT']) { switch ($queuedCommandRaw['TYPE']) { case HISTORYTYPE_CO: $objType = 'cblock'; break; case HISTORYTYPE_FILE: $objType = 'file'; break; } } $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_refreshTags(\'' . $objType . '\', \'' . $objectID . '-' . $objType . '\', \'tags\', \'' . $queuedCommandRaw['TEXT'] . '\');'; break; case 'REFRESH_WINDOW': if ($queuedCommandRaw['TEXT']) { switch ($queuedCommandRaw['TYPE']) { case HISTORYTYPE_CO: $objType = 'cblock'; break; case HISTORYTYPE_PAGE: $objType = 'page'; break; case HISTORYTYPE_FILE: $objType = 'file'; break; case HISTORYTYPE_TAG: $objType = 'tag'; break; case HISTORYTYPE_TEMPLATE: $objType = 'template'; break; case HISTORYTYPE_ENTRYMASK: $objType = 'entrymask'; break; case HISTORYTYPE_SITE: $objType = 'site'; break; } // Special cases switch ($queuedCommandRaw['TYPE']) { case HISTORYTYPE_PAGE: $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_refreshWin(\'' . $objType . '\',\'' . $objectID . '-' . $siteID . '\',\'' . $queuedCommandRaw['TEXT'] . '\');'; break; case HISTORYTYPE_FILE: $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_refreshWin(\'' . $objType . '\',\'' . $objectID . '-' . $objType . '\',\'' . $queuedCommandRaw['TEXT'] . '\');'; $queuedCommands[$queuedCommandRaw['ID']] .= 'Koala.yg_refreshWin(\'' . $objType . 'folder\',\'' . $objectID . '-' . $objType . '\',\'' . $queuedCommandRaw['TEXT'] . '\');'; break; default: $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_refreshWin(\'' . $objType . '\',\'' . $objectID . '-' . $objType . '\',\'' . $queuedCommandRaw['TEXT'] . '\');'; break; } } break; case 'CLEAR_FILEINFOS': $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_fileInfos[' . $objectID . '] = null;'; break; case 'SET_FILEINFOS': $file = sFileMgr()->getFile($objectID); if ($file) { $latestFinalVersion = $file->getLatestApprovedVersion(); $file = new File($objectID, $latestFinalVersion); $fileInfo = $file->get(); $fileTypes = sFileMgr()->getFiletypes(); $user = new User(sUserMgr()->getCurrentUserID()); $fileInfo['DATE'] = date($itext['DATE_FORMAT'], TStoLocalTS($fileInfo['CHANGEDTS'])); $fileInfo['TIME'] = date($itext['TIME_FORMAT'], TStoLocalTS($fileInfo['CHANGEDTS'])); $fileInfo['FILESIZE'] = formatFileSize($fileInfo['FILESIZE']); $views = $file->views->getAssigned(true); $viewInfo = $file->views->getGeneratedViewInfo($views[0]["ID"]); $fileInfo['WIDTH'] = $viewInfo[0]["WIDTH"]; $fileInfo['HEIGHT'] = $viewInfo[0]["HEIGHT"]; $fileInfo['TAGS'] = $file->tags->getAssigned(); $tags = array(); foreach ($fileInfo['TAGS'] as $tag) { array_push($tags, $tag['NAME']); } $fileTags = implode(', ', $tags); if (strlen($fileTags) > 40) { $fileTags = substr($fileTags, 0, 40); $fileTags .= '...'; } $fileInfo['TAGS'] = $fileTags; if (strlen($fileInfo['NAME']) > 40) { $fileInfo['NAME'] = substr($fileInfo['NAME'], 0, 40); $fileInfo['NAME'] .= '...'; } if (strlen($fileInfo['FILENAME']) > 40) { $fileInfo['FILENAME'] = substr($fileInfo['FILENAME'], 0, 40); $fileInfo['FILENAME'] .= '...'; } if ($fileInfo['CREATEDBY']) { $user = new User($fileInfo['CREATEDBY']); $userInfo = $user->get(); $userInfo['PROPS'] = $user->properties->getValues($fileInfo['CREATEDBY']); $fileInfo['USERNAME'] = $userInfo['PROPS']['FIRSTNAME'] . ' ' . $userInfo['PROPS']['LASTNAME']; } foreach ($fileTypes as $fileTypes_item) { if ($fileTypes_item['ID'] == $fileInfo['FILETYPE']) { $fileInfo['FILETYPE_TXT'] = $fileTypes_item['NAME']; } } $fileInfo['THUMB'] = 0; $hiddenViews = $file->views->getHiddenViews(); foreach ($hiddenViews as $view) { if ($view['IDENTIFIER'] == 'yg-preview') { $tmpviewinfo = $file->views->getGeneratedViewInfo($view["ID"]); if ($tmpviewinfo[0]["TYPE"] == FILE_TYPE_WEBIMAGE) { $fileInfo['THUMB'] = 1; $fileInfo['PREVIEWWIDTH'] = $tmpviewinfo[0]["WIDTH"]; $fileInfo['PREVIEWHEIGHT'] = $tmpviewinfo[0]["HEIGHT"]; } } } $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_fileInfos[' . $objectID . '] = ' . json_encode($fileInfo) . ';Koala.yg_showFileHint(\'' . $objectID . '\');'; } break; case 'SET_USERINFOS': $user = new User($objectID); $userInfo = $user->get(); $userInfo['PROPS'] = $user->properties->getValues($objectID); $userInfo['USERGROUPS'] = $user->getUsergroups($objectID); $roles = array(); foreach ($userInfo['USERGROUPS'] as $role) { array_push($roles, $role['NAME']); } $user_roles = implode(', ', $roles); if (strlen($user_roles) > 30) { $user_roles = substr($user_roles, 0, 30); $user_roles .= '...'; } if (file_exists(sApp()->app_root . sApp()->userpicdir . $objectID . '-picture.jpg')) { $internPrefix = (string) sConfig()->getVar('CONFIG/REFTRACKER/INTERNALPREFIX'); $user_picture = $internPrefix . 'userimage/' . $objectID . '/48x48?rnd=' . rand(); } else { $user_picture = sApp()->imgpath . 'content/temp_userpic.png'; } $user_company = $userInfo['PROPS']['COMPANY']; $user_name = $userInfo['PROPS']['FIRSTNAME'] . ' ' . $userInfo['PROPS']['LASTNAME']; $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_userInfos[' . $objectID . '] = {name: \'' . $user_name . '\', groups: \'' . $user_roles . '\', pic: \'' . $user_picture . '\', company: \'' . $user_company . '\'}'; break; case 'CLEAR_USERINFOS': $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_userInfos[' . $objectID . '] = null;'; break; case 'CLEAR_REFRESH': if ($queuedCommandRaw['TEXT']) { $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_clearRefresh(\'' . $objectID . '-' . $queuedCommandRaw['TEXT'] . '\');'; } break; case 'RELOAD_WINDOW': if ($queuedCommandRaw['TEXT']) { $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_reloadWin(null, \'' . $objectID . '-' . $queuedCommandRaw['TEXT'] . '\');'; } break; case 'PAGE_DEACTIVATE': if ($queuedCommandRaw['TEXT']) { $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_deActivate(\'page\', \'' . $objectID . '-' . $siteID . '\', \'name\');'; } break; case 'PAGE_ACTIVATE': if ($queuedCommandRaw['TEXT']) { $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_activate(\'page\', \'' . $objectID . '-' . $siteID . '\', \'name\');'; } break; case 'PAGE_UNHIDE': if ($queuedCommandRaw['TEXT']) { $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_unHide(\'page\', \'' . $objectID . '-' . $siteID . '\', \'name\');'; } break; case 'PAGE_HIDE': if ($queuedCommandRaw['TEXT']) { $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_hide(\'page\', \'' . $objectID . '-' . $siteID . '\', \'name\');'; } break; case 'FILE_DELVIEW': if ($queuedCommandRaw['TEXT']) { $file = sFileMgr()->getFile($objectID); $fileInfo = $file->get(); if ($fileInfo['FOLDER'] == 1) { $isFolder = 'true'; } else { $isFolder = 'false'; } $queuedCommands[$queuedCommandRaw['ID']] = 'if (Koala.yg_delViewArr[' . $queuedCommandRaw['TEXT'] . ']) Koala.yg_delViewArr[' . $queuedCommandRaw['TEXT'] . '](' . $objectID . ', ' . $isFolder . ');'; } break; case 'FILE_CLEAR_DELVIEW': if ($queuedCommandRaw['TEXT']) { $queuedCommands[$queuedCommandRaw['ID']] = 'if (Koala.yg_delViewArr[' . $queuedCommandRaw['TEXT'] . ']) Koala.yg_delViewArr[' . $queuedCommandRaw['TEXT'] . ']=undefined;'; } break; case 'FILE_ADDVIEW': if ($queuedCommandRaw['TEXT']) { $file = sFileMgr()->getFile($objectID); $fileInfo = $file->get(); $viewInfo = $viewMgr->get($queuedCommandRaw['TEXT']); if ($fileInfo['FOLDER'] == 1) { $isFolder = 'true'; } else { $isFolder = 'false'; } $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_addView(\'' . $objectID . '\', \'' . $viewInfo['ID'] . '\', \'' . $viewInfo['IDENTIFIER'] . '\', \'' . $viewInfo['NAME'] . '\', \'' . $viewInfo['WIDTH'] . '\', \'' . $viewInfo['HEIGHT'] . '\', \'' . $isFolder . '\');'; } break; case 'FILE_GENERATEDVIEW': if ($queuedCommandRaw['TEXT']) { $file = sFileMgr()->getFile($objectID); $viewInfo = $viewMgr->get($queuedCommandRaw['TEXT']); $generatedViewInfo = $file->views->getGeneratedViewInfo($viewInfo['ID']); if ($generatedViewInfo[0]['TYPE'] == FILE_TYPE_WEBIMAGE) { $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_addGenerated(\'' . $objectID . '\',\'' . $viewInfo['IDENTIFIER'] . '\', \'' . $viewInfo['WIDTH'] . '\', \'' . $viewInfo['HEIGHT'] . '\');'; } else { if ($generatedViewInfo[0]) { $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_addGenerated(\'' . $objectID . '\',\'NULL\');'; } } } break; case 'UNHIGHLIGHT_TEMPLATE': if ($queuedCommandRaw['TEXT']) { $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_unHilite(\'template\', \'' . $objectID . '-template\', \'' . $queuedCommandRaw['TEXT'] . '\');'; } break; case 'HIGHLIGHT_PAGE': if ($queuedCommandRaw['TEXT']) { $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_hilite(\'page\', \'' . $objectID . '-' . $siteID . '\', \'' . $queuedCommandRaw['TEXT'] . '\');'; } break; case 'UNHIGHLIGHT_PAGE': if ($queuedCommandRaw['TEXT']) { $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_unHilite(\'page\', \'' . $objectID . '-' . $siteID . '\', \'' . $queuedCommandRaw['TEXT'] . '\');'; } break; case 'HIGHLIGHT_CBLOCK': if ($queuedCommandRaw['TEXT']) { $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_hilite(\'cblock\', \'' . $objectID . '-cblock\', \'' . $queuedCommandRaw['TEXT'] . '\');'; } break; case 'UNHIGHLIGHT_CBLOCK': if ($queuedCommandRaw['TEXT']) { $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_unHilite(\'cblock\', \'' . $objectID . '-cblock\', \'' . $queuedCommandRaw['TEXT'] . '\');'; } break; case 'UNHIGHLIGHT_ENTRYMASK': if ($queuedCommandRaw['TEXT']) { $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_unHilite(\'entrymask\', \'' . $objectID . '-entrymask\', \'' . $queuedCommandRaw['TEXT'] . '\');' . 'Koala.yg_unHilite(\'page\', \'' . $objectID . '-entrymask\', \'' . $queuedCommandRaw['TEXT'] . '\');'; } break; case 'UNHIGHLIGHT_SITE': if ($queuedCommandRaw['TEXT']) { $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_unHilite(\'page\', \'' . $objectID . '-site\', \'' . $queuedCommandRaw['TEXT'] . '\');'; } break; case 'HIGHLIGHT_SITE': if ($queuedCommandRaw['TEXT']) { $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_hilite(\'page\', \'' . $objectID . '-site\', \'' . $queuedCommandRaw['TEXT'] . '\');'; } break; case 'HIGHLIGHT_MAILING': if ($queuedCommandRaw['TEXT']) { $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_hilite(\'mailing\', \'' . $objectID . '-mailing' . '\', \'' . $queuedCommandRaw['TEXT'] . '\');'; } break; case 'UNHIGHLIGHT_MAILING': if ($queuedCommandRaw['TEXT']) { $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_unHilite(\'mailing\', \'' . $objectID . '-mailing' . '\', \'' . $queuedCommandRaw['TEXT'] . '\');'; } break; case 'PAGE_MOVE': if ($queuedCommandRaw['TEXT']) { if ($queuedCommandRaw['TARGETID'] == 1) { $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_moveTreeNode(\'page\', \'' . $objectID . '-' . $siteID . '\', \'' . $queuedCommandRaw['TEXT'] . '\', 2);'; } else { $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_moveTreeNode(\'page\', \'' . $objectID . '-' . $siteID . '\', \'' . $queuedCommandRaw['TEXT'] . '\', 1);'; } } break; case 'PAGE_MOVEUP': if ($queuedCommandRaw['TEXT']) { $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_moveUp(\'page\', \'' . $objectID . '-' . $siteID . '\', \'' . $queuedCommandRaw['TEXT'] . '\');'; } break; case 'PAGE_MOVEDOWN': if ($queuedCommandRaw['TEXT']) { $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_moveDown(\'page\', \'' . $objectID . '-' . $siteID . '\', \'' . $queuedCommandRaw['TEXT'] . '\');'; } break; case 'CBLOCK_MOVE': if ($queuedCommandRaw['TEXT']) { $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_moveTreeNode(\'cblock\', \'' . $objectID . '-cblock\', \'' . $queuedCommandRaw['TEXT'] . '-cblock\', 1);'; } break; case 'FILE_MOVE': if ($queuedCommandRaw['TEXT']) { $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_moveTreeNode(\'file\', \'' . $objectID . '-file\', \'' . $queuedCommandRaw['TEXT'] . '-file\', 1);'; } break; case 'TAG_MOVE': if ($queuedCommandRaw['TEXT']) { $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_moveTreeNode(\'tag\', \'' . $objectID . '-tag\', \'' . $queuedCommandRaw['TEXT'] . '-tag\', 1);'; } break; case 'TAG_ADD': $objectInfo = $tagMgr->get($objectID); $icon = $icons->icon['tag_small']; $statusClass = ''; if (!$permissionsObj->checkInternal(sUserMgr()->getCurrentUserID(), $objectID, "RWRITE")) { // Nur Leserecht (hellgrau) $statusClass .= " nowrite"; } if (!$permissionsObj->checkInternal(sUserMgr()->getCurrentUserID(), $objectID, "RDELETE")) { // Nur Leserecht (hellgrau) $statusClass .= " nodelete"; } if (!$permissionsObj->checkInternal(sUserMgr()->getCurrentUserID(), $objectID, "RSUB")) { $statusClass .= " nosub"; } $objectName = $objectInfo['NAME']; $objectParents = $tagMgr->getParents($objectID); $parentNodeId = $objectParents[0][0]["ID"]; if ($queuedCommandRaw['NEWVALUE'] == sGuiUS()) { $andSelect = 'true'; } else { $andSelect = 'false'; } $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_addChild(\'tag\', \'' . $parentNodeId . '-tag\', \'name\', \'' . $objectName . '\', \'tag\', \'' . $objectID . '-tag\', \'name\', \'' . $icon . '\', \'' . $statusClass . '\', ' . $andSelect . ');'; break; case 'FILE_ADD': case 'FILEFOLDER_ADD': $file = sFileMgr()->getFile($objectID); if ($file) { $objectInfo = $file->get(); $icon = $icons->icon['folder']; $statusClass = ''; if ($objectInfo["VERSIONPUBLISHED"] + 2 != $objectInfo["VERSION"] && $objectInfo["VERSIONPUBLISHED"] != ALWAYS_LATEST_APPROVED_VERSION && $objectInfo["HASCHANGED"] == "1") { // Editiert (grĂ¼n) $statusClass = "changed"; } elseif ($objectInfo["HASCHANGED"] == "1") { $statusClass = "changed"; } if (!$permissionsObj->checkInternal(sUserMgr()->getCurrentUserID(), $objectID, "RWRITE")) { // Nur Leserecht (hellgrau) $statusClass .= " nowrite"; } if (!$permissionsObj->checkInternal(sUserMgr()->getCurrentUserID(), $objectID, "RDELETE")) { // Nur Leserecht (hellgrau) $statusClass .= " nodelete"; } if (!$permissionsObj->checkInternal(sUserMgr()->getCurrentUserID(), $objectID, "RSUB")) { $statusClass .= " nosub"; } $objectName = $objectInfo['NAME']; $objectParents = sFileMgr()->getParents($objectID); $parentNodeId = $objectParents[0][0]["ID"]; if ($queuedCommandRaw['NEWVALUE'] == sGuiUS()) { $andSelect = 'true'; } else { $andSelect = 'false'; } $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_addChild(\'file\', \'' . $parentNodeId . '-file\', \'name\', \'' . $objectName . '\', \'file\', \'' . $objectID . '-file\', \'name\', \'' . $icon . '\', \'' . $statusClass . '\', ' . $andSelect . ');'; } break; case 'CBLOCK_ADD': $cb = sCblockMgr()->getCblock($objectID); $objectInfo = $cb->get(); $icon = $icons->icon['cblock_small']; $statusClass = ''; if ($objectInfo['FOLDER'] != 1) { if ($objectInfo["VERSIONPUBLISHED"] + 2 != $objectInfo["VERSION"] && $objectInfo["VERSIONPUBLISHED"] != ALWAYS_LATEST_APPROVED_VERSION && $objectInfo["HASCHANGED"] == "1") { // Editiert (grĂ¼n) $statusClass .= "changed changed1 nosub"; } elseif ($objectInfo["HASCHANGED"] == "1") { $statusClass .= "changed changed2 nosub"; } } else { if (!$permissionsObj->checkInternal(sUserMgr()->getCurrentUserID(), $objectID, "RSUB")) { $statusClass .= " nosub"; } $icon = $icons->icon['folder']; $statusClass .= " folder"; } if (!$permissionsObj->checkInternal(sUserMgr()->getCurrentUserID(), $objectID, "RWRITE")) { // Nur Leserecht (hellgrau) $statusClass .= " nowrite"; } if (!$permissionsObj->checkInternal(sUserMgr()->getCurrentUserID(), $objectID, "RDELETE")) { // Nur Leserecht (hellgrau) $statusClass .= " nodelete"; } $objectName = $objectInfo['NAME']; $objectParents = sCblockMgr()->getParents($objectID); $parentNodeId = $objectParents[0][0]["ID"]; if ($queuedCommandRaw['NEWVALUE'] == sGuiUS() && $queuedCommandRaw['TEXT'] != 'list') { $andSelect = 'true'; } else { $andSelect = 'false'; } if ($queuedCommandRaw['NEWVALUE'] == sGuiUS()) { $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_addListItem(\'' . $parentNodeId . '-cblock\', \'' . addslashes(json_encode($objectInfo)) . '\', \'' . $queuedCommandRaw['TEXT'] . '\');'; } $queuedCommands[$queuedCommandRaw['ID']] .= 'Koala.yg_addChild(\'cblock\', \'' . $parentNodeId . '-cblock\', \'name\', \'' . $objectName . '\', \'cblock\', \'' . $objectID . '-cblock\', \'name\', \'' . $icon . '\', \'' . $statusClass . '\', ' . $andSelect . ');'; break; case 'PAGE_ADD': if ($pageObj) { $objectInfo = $pageObj->get(); $icon = $icons->icon['page_small']; $statusClass = ''; $inactive = false; if ($objectInfo["ACTIVE"] == "0") { $icon = $icons->icon['page_inactive_small']; $inactive = true; } $naviinfo = NULL; $navis = $templateMgr->getNavis($objectInfo["TEMPLATEID"]); for ($i = 0; $i < count($navis); $i++) { if ($navis[$i]["ID"] == $objectInfo["NAVIGATIONID"]) { $naviinfo = $navis[$i]; } } if ($objectInfo["HIDDEN"] == "1" || $objectInfo["TEMPLATEID"] == "0" || !$naviinfo['ID']) { $icon = $icons->icon['page_hidden_small']; if ($inactive == true) { $icon = $icons->icon['page_inactive_hidden_small']; } } if ($objectInfo["VERSIONPUBLISHED"] + 2 != $objectInfo["VERSION"] && $objectInfo["VERSIONPUBLISHED"] != ALWAYS_LATEST_APPROVED_VERSION && $objectInfo["HASCHANGED"] == "1") { // Editiert (grĂ¼n) $statusClass = "changed"; } elseif ($objectInfo["HASCHANGED"] == "1") { $statusClass = "changed"; } if (!$permissionsObj->checkInternal(sUserMgr()->getCurrentUserID(), $objectID, "RWRITE")) { // Nur Leserecht (hellgrau) $statusClass .= " nowrite"; } if (!$permissionsObj->checkInternal(sUserMgr()->getCurrentUserID(), $objectID, "RDELETE")) { // Nur Leserecht (hellgrau) $statusClass .= " nodelete"; } if (!$permissionsObj->checkInternal(sUserMgr()->getCurrentUserID(), $objectID, "RSUB")) { $statusClass .= " nosub"; } $objectName = $objectInfo['NAME']; $objectParents = $pageMgr->getParents($objectID); $parentNodeId = $objectParents[0][0]["ID"]; if (!$parentNodeId) { $parentNodeId = 1; } $url = $pageObj->getUrl(); if ($queuedCommandRaw['NEWVALUE'] == sGuiUS()) { $andSelect = 'true'; } else { $andSelect = 'false'; } $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_addChild(\'page\', \'' . $parentNodeId . '-' . $siteID . '\', \'name\', \'' . $objectName . '\', \'page\', \'' . $objectID . '-' . $siteID . '\', \'name\', \'' . $icon . '\', \'' . $statusClass . '\', ' . $andSelect . ', \'' . $url . '\');' . "\n"; } break; case 'MAILING_ADD': $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_refreshMailingsWindow();' . "\n"; break; case 'MAILING_DELETE': $queuedCommands[$queuedCommandRaw['ID']] = 'Koala.yg_refreshMailingsWindow(true);' . "\n"; break; default: $queuedCommands[$queuedCommandRaw['ID']] = stripslashes($queuedCommandRaw['OLDVALUE']) . "\n"; break; } } } } if (count($queuedCommandsRaw)) { $currentQueueId = $queuedCommandsRaw[count($queuedCommandsRaw) - 1]['ID']; } } $output = "\n<script>\n"; $output .= "parent.Koala.currentGuiSyncHistoryId = " . $currentQueueId . ";\n"; $output .= "parent.Koala.yg_executeGuiJSQueue( " . json_encode($queuedCommands) . " );\n"; $output .= "</script>\n"; print $output; }
} else { $pageMgr = new PageMgr($special_url_info['SITE']); $tmpPage = $pageMgr->getPage($special_url_info['ID']); $link_pageInfo = $tmpPage->get(); if ($siteID != 'cblock') { } $objectdynprops[$objectdynprops_cnt]['LINKTITLE'] = $link_pageInfo['NAME']; $objectdynprops[$objectdynprops_cnt]['IS_INTERNAL'] = true; } } else { if (preg_match_all($this->URLRegEx1, $objectdynprops[$objectdynprops_cnt]['VALUE'], $internal) > 0) { if ($internal[2][0] == 'download') { $objectdynprops[$objectdynprops_cnt]['IS_FILE'] = true; $link_file = str_replace('/', '', $internal[3][0]); if ($link_file) { $tmpFile = sFileMgr()->File($link_file); if ($tmpFile) { $link_fileinfo = $tmpFile->get(); $objectdynprops[$objectdynprops_cnt]['LINKTITLE'] = $link_fileinfo['NAME']; $link_filetype = $filetypeMgr->get($link_fileinfo['FILETYPE']); $objectdynprops[$objectdynprops_cnt]['FILEIDENTIFIER'] = $link_filetype['IDENTIFIER']; $objectdynprops[$objectdynprops_cnt]['FILEABBREVIATION'] = $link_filetype['CODE']; $objectdynprops[$objectdynprops_cnt]['FILECOLOR'] = $link_filetype['COLOR']; $objectdynprops[$objectdynprops_cnt]['FILE_ID'] = $link_file; } } } else { $link_site = $internal[3][0]; $link_page = str_replace('/', '', $internal[5][0]); $pageMgr = new PageMgr($link_site); $tmpPage = $pageMgr->getPage($link_page);
switch ($siteID) { case 'cblock': // For contentblocks $contentblockMgr = sCblockMgr(); $page = $contentblockMgr->getCblock($pageID); // Get current locks for this token (and unlock them) $lockToken = sGuiUS() . '_' . $this->request->parameters['win_no']; $lockedObjects = $contentblockMgr->getLocksByToken($lockToken); foreach ($lockedObjects as $lockedObject) { $currentObject = $contentblockMgr->getCblock($lockedObject['OBJECTID']); $currentObject->releaseLock($lockedObject['TOKEN']); } break; case 'file': // For files $fileMgr = sFileMgr(); $page = $fileMgr->getFile($pageID); // Get current locks for this token (and unlock them) $lockToken = sGuiUS() . '_' . $this->request->parameters['win_no']; $lockedObjects = $fileMgr->getLocksByToken($lockToken); foreach ($lockedObjects as $lockedObject) { $currentObject = $fileMgr->getFile($lockedObject['OBJECTID']); $currentObject->releaseLock($lockedObject['TOKEN']); } break; case 'mailing': // For mailings $page = $mailingMgr->getMailing($pageID); // Get current locks for this token (and unlock them) $lockToken = sGuiUS() . '_' . $this->request->parameters['win_no']; $lockedObjects = $mailingMgr->getLocksByToken($lockToken);
/** * Gets n last History entries * * @param int $max (optional) Maximum number of entries * @param string|array $text (optional) One or multiple text filters * @return array List of History entries * @throws Exception */ function getLastChanges($max = 8, $text = '') { $max = (int) $max; $tmpTableName = 'TMP_' . strtoupper(sApp()->request->parameters['us']) . '_' . rand() . '_HISTORY'; $sql = "DROP TEMPORARY TABLE IF EXISTS `{$tmpTableName}`;"; $result = sYDB()->Execute($sql); if ($result === false) { throw new Exception(sYDB()->ErrorMsg()); } $sql = "CREATE TEMPORARY TABLE `{$tmpTableName}` (\n\t\t\t\t\t`ID` int(11) NOT NULL,\n\t\t\t\t\t`SOURCEID` varchar(20) NOT NULL,\n\t\t\t\t\t`OID` int(11) NOT NULL DEFAULT '0',\n\t\t\t\t\t`DATETIME` int(11) DEFAULT NULL,\n\t\t\t\t\t`TEXT` text NOT NULL,\n\t\t\t\t\t`UID` int(11) NOT NULL DEFAULT '0',\n\t\t\t\t\t`TYPE` int(11) NOT NULL,\n\t\t\t\t\t`TARGETID` int(11) NOT NULL,\n\t\t\t\t\t`OLDVALUE` text NOT NULL,\n\t\t\t\t\t`NEWVALUE` text NOT NULL,\n\t\t\t\t\t`SITEID` int(11) NOT NULL,\n\t\t\t\t\t`FROM` int(11) DEFAULT '0',\n\t\t\t\t\t`TYPE_OID` int(11) DEFAULT NULL,\n\t\t\t\t\tPRIMARY KEY (`ID`),\n\t\t\t\t\tKEY `OID` (`OID`)\n\t\t\t\t);"; $result = sYDB()->Execute($sql); if ($result === false) { throw new Exception(sYDB()->ErrorMsg()); } $sqlargs = array(); if (!is_array($text) && strlen($text) > 1) { $wheresql .= "TEXT=?"; array_push($sqlargs, $text); } else { if (is_array($text) && count($text) > 0) { for ($t = 0; $t < count($text); $t++) { $wheresql .= "TEXT = ? "; array_push($sqlargs, $text[$t]); if ($t < count($text) - 1) { $wheresql .= " OR "; } } } else { $wheresql .= "1"; } } if ($this->_sourceid != "") { $sourcesql = "AND SOURCEID = ?"; array_push($sqlargs, $this->_sourceid); } $sql = "INSERT INTO `{$tmpTableName}`\n\t\t\t\tSELECT\n\t\t\t\t\t*,\n\t\t\t\t\t((TYPE *1000000) + OID) AS `TYPE_OID`\n\t\t\t\tFROM " . $this->_table . "\n\t\t\t\tWHERE {$wheresql} {$sourcesql}\n\t\t\t\tORDER BY `DATETIME` DESC\n\t\t\t\tLIMIT 0, 2000;"; array_unshift($sqlargs, $sql); $dbr = call_user_func_array(array(sYDB(), 'Execute'), $sqlargs); if ($dbr === false) { throw new Exception(sYDB()->ErrorMsg()); } // Get folder for embedded cblocks $embeddedCblockFolder = (int) sConfig()->getVar('CONFIG/EMBEDDED_CBLOCKFOLDER'); // Remove all embedded Cblocks from temporary table $sql = "DELETE\n\t\t\t\tFROM\n\t\t\t\t\t`{$tmpTableName}`\n\t\t\t\tUSING\n\t\t\t\t\t`{$tmpTableName}`\n\t\t\t\tINNER JOIN\n\t\t\t\t\t`yg_contentblocks_tree`\n\t\t\t\tWHERE\n\t\t\t\t\t(`{$tmpTableName}`.OID = `yg_contentblocks_tree`.ID) AND\n\t\t\t\t\t(`yg_contentblocks_tree`.PARENT = " . $embeddedCblockFolder . ") AND\n\t\t\t\t\t(TYPE = " . HISTORYTYPE_CO . ");"; $result = sYDB()->Execute($sql); if ($result === false) { throw new Exception(sYDB()->ErrorMsg()); } $sql = "SELECT *, (SELECT\n\t\t\t\t\t\tMAX(`DATETIME`)\n\t\t\t\t\tFROM\n\t\t\t\t\t\t" . $this->_table . " AS `h2`\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t`h2`.`OID` = `lft`.`OID`) AS `MAXDATETIME`\n\t\t\t\tFROM `{$tmpTableName}` AS `lft`\n\t\t\t\tGROUP BY `TYPE_OID`\n\t\t\t\tORDER BY `DATETIME` DESC\n\t\t\t\tLIMIT 0, {$max};"; $result = sYDB()->Execute($sql); if ($result === false) { throw new Exception(sYDB()->ErrorMsg()); } $resultarray = $result->GetArray(); for ($i = 0; $i < count($resultarray); $i++) { $oid = $resultarray[$i]['OID']; $rread = false; if ($this->permissions == NULL) { if ($resultarray[$i]['SITEID'] && $resultarray[$i]['TYPE'] == HISTORYTYPE_PAGE) { $tmpPageMgr = new PageMgr($resultarray[$i]['SITEID']); if ($tmpPageMgr->permissions->checkInternal($this->_uid, $oid, "RREAD")) { $rread = true; } } if ($resultarray[$i]['TYPE'] == HISTORYTYPE_CO) { if (sCblockMgr()->permissions->checkInternal($this->_uid, $oid, "RREAD")) { $rread = true; } } if ($resultarray[$i]['TYPE'] == HISTORYTYPE_FILE) { if (sFileMgr()->permissions->checkInternal($this->_uid, $oid, "RREAD")) { $file = sFileMgr()->getFile($oid); if ($file) { $fileinfo = $file->get(); if ($fileinfo["FOLDER"] == 0) { $rread = true; } } } } } else { if ($this->permissions->checkInternal($this->_uid, $oid, "RREAD")) { $rread = true; } } if ($rread) { if ($resultarray[$i]['TYPE'] == HISTORYTYPE_CO) { $tmpCblock = sCblockMgr()->getCblock($resultarray[$i]['OID']); if ($tmpCblock) { $tmpCblockInfo = $tmpCblock->get(); $embeddedCblockFolder = (int) sConfig()->getVar("CONFIG/EMBEDDED_CBLOCKFOLDER"); if ($tmpCblockInfo['PARENT'] != $embeddedCblockFolder) { $ra[] = $resultarray[$i]; } } } else { $ra[] = $resultarray[$i]; } } } return $ra; }
/** * Checks if a specific File exists * * @param int $fileId File Id * @return bool TRUE if file exists, FALSE if not */ public function fileExists($fileId) { sUserMgr()->impersonate(sUserMgr()->getAdministratorID()); $check = sFileMgr()->getFile($fileId); sUserMgr()->unimpersonate(); if ($check) { return true; } else { return false; } sUserMgr()->unimpersonate(); }
function sumchanges_new($newchangeslist) { for ($i = 0; $i < count($newchangeslist); $i++) { if ($newchangeslist[$i]['TYPE'] == HISTORYTYPE_PAGE) { if ($newchangeslist[$i]["SITEID"] && $newchangeslist[$i]["OID"]) { try { $PageMgr = new PageMgr($newchangeslist[$i]["SITEID"]); $page = $PageMgr->getPage($newchangeslist[$i]["OID"]); if ($page) { $oidinfo = $page->get(); $name = $oidinfo["NAME"]; } } catch (Exception $ex) { } } } if ($newchangeslist[$i]['TYPE'] == HISTORYTYPE_CO) { try { $cb = sCblockMgr()->getCblock($newchangeslist[$i]["OID"]); if ($cb) { $oidinfo = $cb->get(); $name = $oidinfo["NAME"]; } } catch (Exception $ex) { } } if ($newchangeslist[$i]['TYPE'] == HISTORYTYPE_FILE) { try { $file = sFileMgr()->getFile($newchangeslist[$i]["OID"]); if ($file) { $oidinfo = $file->get(); $name = $oidinfo["NAME"]; } } catch (Exception $ex) { } } if ($newchangeslist[$i]['TYPE'] == HISTORYTYPE_MAILING) { try { $mailing = sMailingMgr()->getMailing($newchangeslist[$i]["OID"]); if ($mailing) { $oidinfo = $mailing->get(); $name = $oidinfo["NAME"]; } } catch (Exception $ex) { } } if (strlen($name) > 0) { $changeslist[$i] = $newchangeslist[$i]; $changeslist[$i]["NAME"] = $name; } } return $changeslist; }
switch ($objectType) { case 'cblock': // For Contentblocks $cb = sCblockMgr()->getCblock($objectid); $cblockInfo = $cb->get(); for ($i = 0; $i < count($taglist); $i++) { $cb->tags->setOrder($taglist[$i], $i); } // Add to history $cb->history->add(HISTORYTYPE_CO, NULL, NULL, "TXT_TAG_H_TAGORDER", NULL); break; case 'file': // For Files // For Files case 'filefolder': $file = sFileMgr()->getFile($objectid); $fileinfo = $file->get(); for ($i = 0; $i < count($taglist); $i++) { $file->tags->setOrder($taglist[$i], $i); } // Add to history $file->history->add(HISTORYTYPE_FILE, NULL, NULL, "TXT_TAG_H_TAGORDER", NULL); break; case 'page': // For Pages $pageMgr = new PageMgr($siteID); $page = $pageMgr->getPage($objectid); $pageInfo = $page->get(); $jsQueue = new JSQueue(NULL, $siteID); for ($i = 0; $i < count($taglist); $i++) { $page->tags->setOrder($taglist[$i], $i);
<?php $ygid = $this->request->parameters['yg_id']; $refresh = $this->request->parameters['refresh']; $initload = $this->request->parameters['initload']; $siteID = explode('-', $ygid); $siteID = $siteID[0]; $siteMgr = new Sites(); $siteinfo = $siteMgr->get($siteID); if ($siteinfo['FAVICON']) { // Favicon is set, get all information about file $file = sFileMgr()->getFile($siteinfo['FAVICON']); if ($file) { $favicon = $file->get(); $smarty->assign('favicon', $favicon); } } $templateMgr = new Templates(); $templateInfo = $templateMgr->getTemplate($siteinfo['DEFAULTTEMPLATE']); $templateInfo['PREVIEWPATH'] = $templateMgr->getPreviewPath($siteinfo['DEFAULTTEMPLATE']); if ($siteinfo['TEMPLATEROOT']) { $templaterootinfo = $templateMgr->getTemplate($siteinfo['TEMPLATEROOT']); } $smarty->assign('object', $siteID); $smarty->assign('siteinfo', $siteinfo); $smarty->assign('templateInfo', $templateInfo); $smarty->assign('templaterootinfo', $templaterootinfo); $smarty->assign('mode', 1); $smarty->assign('refresh', $refresh); $smarty->assign('initload', $initload); $smarty->assign('win_no', $this->request->parameters['win_no']);
header($header); echo $header; die; } else { if (!strstr($mime, "video")) { header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 24 * 60 * 60) . ' GMT'); header("Cache-Control: "); // leave blank to avoid IE errors header("Pragma: "); // leave blank to avoid IE errors header("Content-Disposition: attachment; filename=\"" . $filename . "\""); header("Content-Transfer-Encoding: binary"); header("Content-Type: {$mime}"); header("Content-length: " . (string) $filesize); } fclose($fdl); byteserve($filestring, $mime); exit; } } elseif (is_numeric($fileId) && sFileMgr()->fileExists($fileId) && $fileinfo["DELETED"] != 1) { sFileMgr()->callExtensionHook("onAccessDenied", $fileId, $version); $header = $_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden'; header($header); echo $header; die; } else { $header = $_SERVER['SERVER_PROTOCOL'] . ' 404 Not found'; header($header); echo $header; die; }
function getAdditionalFormfieldData(&$controlFormfields) { $entrymaskMgr = new Entrymasks(); $tagMgr = new Tags(); $filetypeMgr = new Filetypes(); for ($w = 0; $w < count($controlFormfields); $w++) { $controlFormfields[$w]['LVALUES'] = NULL; $controlFormfields[$w]['DISPLAYNAME'] = NULL; // Date & Datetime if ($controlFormfields[$w]['TYPE'] == 'DATE' || $controlFormfields[$w]['TYPE'] == 'DATETIME') { if ($controlFormfields[$w]['VALUE']) { $controlFormfields[$w]['VALUE'] = TStoLocalTS($controlFormfields[$w]['VALUE']); } } // Link if ($controlFormfields[$w]['TYPE'] == 'LINK') { $special_url = resolveSpecialURL($controlFormfields[$w]['URL']); if ($special_url !== false) { $special_url_info = getSpecialURLInfo($controlFormfields[$w]['VALUE01']); if ($special_url_info['TYPE'] == 'IMG' || $special_url_info['TYPE'] == 'DOWN') { $controlFormfields[$w]['IS_FILE'] = true; $file = sFileMgr()->getFile($special_url_info['ID']); $link_fileinfo = $file->get(); $controlFormfields[$w]['DISPLAYNAME'] = $link_fileinfo['NAME']; $link_filetype = $filetypeMgr->get($link_fileinfo['FILETYPE']); $controlFormfields[$w]['IDENTIFIER'] = $link_filetype['IDENTIFIER']; $controlFormfields[$w]['TYPECODE'] = $link_filetype['CODE']; $controlFormfields[$w]['COLOR'] = $link_filetype['COLOR']; $controlFormfields[$w]['FILE_ID'] = $special_url_info['ID']; } else { $pageMgr = new PageMgr($special_url_info['SITE']); $page = $pageMgr->getPage($special_url_info['ID']); $link_pageInfo = $page->get(); $controlFormfields[$w]['DISPLAYNAME'] = $link_pageInfo['NAME']; $controlFormfields[$w]['IS_INTERNAL'] = true; } } else { if (preg_match_all(sApp()->URLRegEx1, $controlFormfields[$w]['VALUE01'], $internal) > 0) { if ($internal[2][0] == 'download') { $controlFormfields[$w]['IS_FILE'] = true; $link_file = str_replace('/', '', $internal[3][0]); $file = sFileMgr()->getFile($link_file); $link_fileinfo = $file->get(); $controlFormfields[$w]['DISPLAYNAME'] = $link_fileinfo['NAME']; $link_filetype = $filetypeMgr->get($link_fileinfo['FILETYPE']); $controlFormfields[$w]['IDENTIFIER'] = $link_filetype['IDENTIFIER']; $controlFormfields[$w]['TYPECODE'] = $link_filetype['CODE']; $controlFormfields[$w]['COLOR'] = $link_filetype['COLOR']; $controlFormfields[$w]['FILE_ID'] = $link_file; } else { $link_site = $internal[3][0]; $link_page = str_replace('/', '', $internal[5][0]); $pageMgr = new PageMgr($link_site); $page = $pageMgr->getPage($link_page); $link_pageInfo = $page->get(); $controlFormfields[$w]['DISPLAYNAME'] = $link_pageInfo['NAME']; $controlFormfields[$w]['IS_INTERNAL'] = true; } } elseif (substr($controlFormfields[$w]['URL'], 0, 7) == 'mailto:') { $controlFormfields[$w]['IS_EMAIL'] = true; } else { $linkInfo = checkLinkInternalExternal($controlFormfields[$w]['URL']); switch ($linkInfo['TYPE']) { case 'external': $controlFormfields[$w]['DISPLAYNAME'] = $controlFormfields[$w]['URL']; break; case 'internal': $controlFormfields[$w]['DISPLAYNAME'] = $linkInfo['NAME']; $controlFormfields[$w]['IS_INTERNAL'] = true; break; case 'file': $controlFormfields[$w]['IS_FILE'] = true; $controlFormfields[$w]['DISPLAYNAME'] = $linkInfo['NAME']; $controlFormfields[$w]['IDENTIFIER'] = $linkInfo['INFO']['IDENTIFIER']; $controlFormfields[$w]['TYPECODE'] = $linkInfo['INFO']['CODE']; $controlFormfields[$w]['COLOR'] = $linkInfo['INFO']['COLOR']; $controlFormfields[$w]['FILE_ID'] = $linkInfo['INFO']['FILE_ID']; break; } } } } // File if ($controlFormfields[$w]['TYPE'] == 'FILE') { if (trim($controlFormfields[$w]['FILE_ID'])) { $file = sFileMgr()->getFile($controlFormfields[$w]['FILE_ID']); if ($file) { $fileInfo = $file->get(); $controlFormfields[$w]['DISPLAYNAME'] = $fileInfo['NAME']; $controlFormfields[$w]['IDENTIFIER'] = $fileInfo['IDENTIFIER']; $controlFormfields[$w]['TYPECODE'] = $fileInfo['CODE']; $controlFormfields[$w]['COLOR'] = $fileInfo['COLOR']; } } } // File if ($controlFormfields[$w]['TYPE'] == 'FILEFOLDER') { if (trim($controlFormfields[$w]['FILE_ID'])) { $file = sFileMgr()->getFile($controlFormfields[$w]['FILE_ID']); if ($file) { $fileInfo = $file->get(); $controlFormfields[$w]['DISPLAYNAME'] = $fileInfo['NAME']; } } } // Contentblock if ($controlFormfields[$w]['TYPE'] == 'CO') { if (trim($controlFormfields[$w]['CBLOCK_ID'])) { $cb = sCblockMgr()->getCblock($controlFormfields[$w]['CBLOCK_ID']); $info = $cb->get(); $controlFormfields[$w]['DISPLAYNAME'] = $info['NAME']; } } // Tag if ($controlFormfields[$w]['TYPE'] == 'TAG') { if (trim($controlFormfields[$w]['TAG_ID'])) { $info = $tagMgr->get($controlFormfields[$w]['TAG_ID']); $controlFormfields[$w]['DISPLAYNAME'] = $info['NAME']; } } // Page if ($controlFormfields[$w]['TYPE'] == 'PAGE') { if (trim($controlFormfields[$w]['SITE_ID']) && trim($controlFormfields[$w]['PAGE_ID'])) { $tmpPageMgr = new PageMgr($controlFormfields[$w]['SITE_ID']); $tmpPage = $tmpPageMgr->getPage($controlFormfields[$w]['PAGE_ID']); $info = $tmpPage->get(); $info['RWRITE'] = $tmpPage->permissions->checkInternal(sUserMgr()->getCurrentUserID(), $controlFormfields[$w]['PAGE_ID'], "RWRITE"); $info['RDELETE'] = $tmpPage->permissions->checkInternal(sUserMgr()->getCurrentUserID(), $controlFormfields[$w]['PAGE_ID'], "RDELETE"); $iconData = getIconForPage($info); $controlFormfields[$w]['ICON'] = $iconData['iconclass']; $controlFormfields[$w]['STYLE'] = $iconData['style']; $controlFormfields[$w]['DISPLAYNAME'] = $info['NAME']; } } // List if ($controlFormfields[$w]['TYPE'] == 'LIST') { if (trim($controlFormfields[$w]['ENTRYMASKFORMFIELD'])) { $controlFormfields[$w]['LIST_VALUES'] = $entrymaskMgr->getListValuesByLinkID($controlFormfields[$w]['ENTRYMASKFORMFIELD']); } } } }