/** * Copies Properties, Extensions, Usergroups, Permissions, Tags, assigned and embedded Cblocks * from another Mailing into a new version of this Mailing * * @param object $sourceMailing Source Mailing object * @return bool TRUE on success or FALSE in case of an error * @throws Exception */ public function copyFrom(&$sourceMailing) { $targetID = (int) $this->_id; if ($this->permissions->checkInternal($this->_uid, $targetID, "RWRITE")) { $sourceInfo = $sourceMailing->get(); $targetVersion = $this->getVersion(); parent::copyFrom($sourceMailing); $this->setTemplate($sourceInfo['TEMPLATEID']); $assignedGroups = $sourceMailing->getUsergroups(); foreach ($assignedGroups as $assignedGroup) { if (sUsergroups()->usergroupPermissions->checkInternal(sUserMgr()->getCurrentUserID(), $assignedGroup['ID'], 'RREAD')) { $this->addUsergroup($assignedGroup['ID'], $targetVersion); } } $this->copyExtensionsFrom($sourceMailing); // Clear contentareas $mailingInfo = $this->get(); $templateMgr = new Templates(); $contentareas = $templateMgr->getContentareas($mailingInfo['TEMPLATEID']); for ($i = 0; $i < count($contentareas); $i++) { $mailinglist = $this->getCblockList($contentareas[$i]['CODE']); for ($x = 0; $x < count($mailinglist); $x++) { $this->removeCblock($mailinglist[$x]['ID'], $contentareas[$i]['CODE']); } } $templateMgr = new Templates(); $mailingInfo = $sourceMailing->get(); $contentareas = $templateMgr->getContentareas($mailingInfo['TEMPLATEID']); for ($i = 0; $i < count($contentareas); $i++) { $cbListOrder = array(); $mailinglist = $sourceMailing->getCblockList($contentareas[$i]['CODE']); for ($x = 0; $x < count($mailinglist); $x++) { $coid = $mailinglist[$x]['OBJECTID']; // Check if we have a blind contentblock if ($mailinglist[$x]['EMBEDDED'] == 1) { // Yes, we have to copy it to the blind folder // Check which entrymasks are contained $srcCo = sCblockMgr()->getCblock($coid, $mailinglist[$x]['VERSION']); $src_entrymasks = $srcCo->getEntrymasks(); // Create blind contentblocks with these entrymasks foreach ($src_entrymasks as $src_entrymask_item) { // Add new contentblock to folder $contentblockID = $this->addCblockEmbedded($contentareas[$i]['CODE']); $newCo = sCblockMgr()->getCblock($contentblockID); $newCo->properties->setValue("NAME", $src_entrymask_item['ENTRYMASKNAME']); // Add requested control to contentblock $new_control = $newCo->addEntrymask($src_entrymask_item['ENTRYMASKID']); // Loop through all formfields $controlFormfields = $srcCo->getFormfieldsInternal($src_entrymask_item['LINKID']); $newControlFormfields = $newCo->getFormfieldsInternal($new_control); // Fill all formfield parameter values with content from the source formfield for ($c = 0; $c < count($newControlFormfields); $c++) { $newCo->setFormfield($newControlFormfields[$c]['ID'], $controlFormfields[$c]['VALUE01'], $controlFormfields[$c]['VALUE02'], $controlFormfields[$c]['VALUE03'], $controlFormfields[$c]['VALUE04'], $controlFormfields[$c]['VALUE05'], $controlFormfields[$c]['VALUE06'], $controlFormfields[$c]['VALUE07'], $controlFormfields[$c]['VALUE08']); } } } else { // No, it's a normal one, just link it to the mailing $this->addCblockLink($coid, $contentareas[$i]['CODE']); } $cbListOrder[] = $coid; } $this->setCblockOrder($cbListOrder, $contentareas[$i]['CODE']); } $this->markAsChanged(); } else { return false; } }
$templateMgr = new Templates(); // Normal Mode $contentareasEntryMasks = $templateMgr->resolveContentareaEntrymaskMapping($pageInfo['TEMPLATEID']); $loop = 0; foreach ($data as $item) { $coid = $item[0]; $contentarea = $item[1]; $contentarea_id = $item[2]; $colnkid = $item[3]; if ($coid) { $cb = sCblockMgr()->getCblock($coid); if ($siteID == 'cblock') { $co = $cb->get(); $co['ENTRYMASKS'] = $cb->getEntrymasks(); } else { $contentareas = $templateMgr->getContentareas($pageInfo['TEMPLATEID']); for ($i = 0; $i < count($contentareas); $i++) { if ($contentareas[$i]['ID'] == $contentarea_id) { if ($siteID == 'mailing') { // For mailings $page = $mailingMgr->getMailing($pageID); } else { // For pages $page = $pageMgr->getPage($pageID); } $colist = $page->getCblockList($contentareas[$i]['CODE'], true); for ($j = 0; $j < count($colist); $j++) { if ($colist[$j]['OBJECTID'] == $coid) { $new_co = $colist[$j]; if ($new_co['OBJECTID']) { $newcb = sCblockMgr()->getCblock($colist[$j]['OBJECTID']);
$contentblockID = $this->params['contentblockId']; $cb = sCblockMgr()->getCblock($contentblockID); $contentarea = $this->params['contentareaID']; $parentwindow = $this->params['openerRefID']; $refresh = $this->params['refresh']; $target_id = $this->params['targetId']; $target_pos = $this->params['targetPosition']; $copymode = $this->params['copymode']; $templateMgr = new Templates(); $entrymaskMgr = new Entrymasks(); $contentarea = str_replace('wid_' . $parentwindow . '_ca_', '', $contentarea); if ($target_id != '' && $target_pos != '') { // Get code for contentarea_id $contentarea_id = $contentarea; $contentarea = ''; $contentareas = $templateMgr->getContentareas($myObjectInfo['TEMPLATEID']); foreach ($contentareas as $pagecontentarea) { if ($pagecontentarea['ID'] == $contentarea_id) { $contentarea = $pagecontentarea['CODE']; } } if ($contentblockID > 0) { // Check if already there $add_co = true; 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']; if ($coid == $contentblockID) { $add_co = false;
/** * Copies Properties, Extensions, Permissions, Tags, assigned and embedded Cblocks * from another Page into a new version of this Page * * @param object $sourcePage Source Page object * @return bool TRUE on success or FALSE in case of an error * @throws Exception */ public function copyFrom(&$sourcePage) { if ($this->permissions->checkInternal($this->_uid, $this->_id, "RWRITE")) { $sourceID = $sourcePage->getID(); $sourceSite = $sourcePage->getSite(); $sourceVersion = $sourcePage->getVersion(); $targetID = (int) $this->_id; $targetVersion = (int) $this->getVersion(); $sourceVersionID = (int) $sourcePage->getPropertyId(); $targetVersionID = (int) $this->getPropertyId(); $sourceInfo = $sourcePage->get(); $this->copyExtensionsFrom($sourcePage); if ($sourceSite == $this->_site) { $this->permissions->copyTo($sourceID, $targetID); $this->properties->copyTo($sourceVersionID, $targetVersionID); $this->tags->copyTo($sourceID, $sourceVersion, $targetID, $targetVersion); } else { // Permissions $sourcePermissions = $sourcePage->permissions->getPermissions(); $this->permissions->setPermissions($sourcePermissions); // Properties $pageMgr = new PageMgr($this->getSite()); $propstocopy = $pageMgr->properties->getList(); $p = new Page($sourceSite, $sourceID, $sourceVersion); for ($i = 0; $i < count($propstocopy); $i++) { $scpd = $p->getPropertyId(); $sourcevalue = $p->properties->getValueInternal($propstocopy[$i]["IDENTIFIER"]); $this->properties->setValue($propstocopy[$i]["IDENTIFIER"], $sourcevalue); } // Tags $sourceTags = $sourcePage->tags->getAssigned(); foreach ($sourceTags as $sourceTag) { $this->tags->assign($sourceTag['ID']); } } $this->setTemplate($sourceInfo['TEMPLATEID']); $this->setNavigation($sourceInfo['NAVIGATIONID']); $this->setActive($sourceInfo['ACTIVE']); $this->setHidden($sourceInfo['HIDDEN']); // Clear contentareas $pageInfo = $this->get(); $templateMgr = new Templates(); $contentareas = $templateMgr->getContentareas($pageInfo['TEMPLATEID']); for ($i = 0; $i < count($contentareas); $i++) { $cblockList = $this->getCblockList($contentareas[$i]['CODE']); for ($x = 0; $x < count($cblockList); $x++) { $this->removeCblock($cblockList[$x]['ID'], $contentareas[$i]['CODE']); } } $pageInfo = $sourcePage->get(); $contentareas = $templateMgr->getContentareas($pageInfo['TEMPLATEID']); $finalCblockListLinkOrder = array(); for ($i = 0; $i < count($contentareas); $i++) { $cblockList = $sourcePage->getCblockList($contentareas[$i]['CODE']); for ($x = 0; $x < count($cblockList); $x++) { $coid = $cblockList[$x]['OBJECTID']; // Check if we have a blind contentblock if ($cblockList[$x]['EMBEDDED'] == 1) { // Yes, we have to copy it to the blind folder // Check which entrymasks are contained $sourcecb = sCblockMgr()->getCblock($coid, $cblockList[$x]['VERSION']); if ($sourcecb) { $src_entrymasks = $sourcecb->getEntrymasks(); // Create blind contentblocks with these entrymasks foreach ($src_entrymasks as $src_entrymask_item) { // Add new contentblock to folder $contentblockID = $this->addCblockEmbedded($contentareas[$i]['CODE']); $newcb = sCblockMgr()->getCblock($contentblockID); $newcb->setPagePermissions($sourcePage); $newcb->properties->setValue("NAME", $src_entrymask_item['ENTRYMASKNAME']); // Get the Link Id of the newly created contentblock (and save it) $finalCblockListLinkOrder[] = $this->getEmbeddedCblockLinkId($contentblockID); // Add requested control to contentblock $new_control = $newcb->addEntrymask($src_entrymask_item['ENTRYMASKID']); // Loop through all formfields $controlFormfields = $sourcecb->getFormfieldsInternal($src_entrymask_item['LINKID']); $newControlFormfields = $newcb->getFormfieldsInternal($new_control); // Fill all formfield parameter values with content from the source formfield for ($c = 0; $c < count($newControlFormfields); $c++) { $newcb->setFormfield($newControlFormfields[$c]['ID'], $controlFormfields[$c]['VALUE01'], $controlFormfields[$c]['VALUE02'], $controlFormfields[$c]['VALUE03'], $controlFormfields[$c]['VALUE04'], $controlFormfields[$c]['VALUE05'], $controlFormfields[$c]['VALUE06'], $controlFormfields[$c]['VALUE07'], $controlFormfields[$c]['VALUE08']); } } } } else { // No, it's a normal one, just link it to the page (and save the Link Id) $finalCblockListLinkOrder[] = $this->addCblockLink($coid, $contentareas[$i]['CODE']); } } } $this->setCblockLinkOrder($finalCblockListLinkOrder); return true; } else { return false; } }
$ygid = $this->request->parameters['yg_id']; $refresh = $this->request->parameters['refresh']; $initload = $this->request->parameters['initload']; $sortby = $this->request->parameters['sortby']; $show = $this->request->parameters['show']; $view = $this->request->parameters['view']; $template = explode('-', $ygid); $site = $template[1]; $template = $template[0]; $templateMgr = new Templates(); $templateInfo = $templateMgr->getTemplate($template); $objectparents = $templateMgr->getParents($template); $objectparents[count($objectparents) - 1][0]['NAME'] = $itext['TXT_TEMPLATES'] != '' ? $itext['TXT_TEMPLATES'] : '$TXT_TEMPLATES'; // Get all contentareas $contentareas = $templateMgr->getContentareas($template); // Get all navigations $navigations = $templateMgr->getNavis($template); $hasdefault = false; foreach ($navigations as $idx => $navigation) { if ($navigation['DEFAULT'] == 1) { $hasdefault = true; $defaultnavi = $navigation['CODE']; } } if (!$hasdefault) { $navigations[0]['DEFAULT'] = 1; $defaultnavi = $navigations[0]['CODE']; } // Check for template preview $templatepreviewdir = getRealpath(sConfig()->getVar('CONFIG/DIRECTORIES/TEMPLATEPREVIEWDIR')) . '/';
/** * Callback method which is executed when Usergroup permissions on a Mailing changes * * @param int $usergroupId Usergroup Id * @param string $permission Permission (RREAD, RWRITE, RDELETE, RSUB, RSTAGE, RMODERATE, RCOMMENT, RSEND) * @param bool $value TRUE when the permission is granted, FALSE when it is removed * @param int $objectId Mailing Id */ public function onPermissionChange($usergroupId, $permission, $value, $objectId) { // Also set these permissions to the all blinds Cblocks in this Mailing $templateMgr = new Templates(); $mailing = $this->getMailing($objectId); if ($mailing) { $mailingVersions = $mailing->getVersions(); foreach ($mailingVersions as $mailingVersions_item) { $tmpMailing = $this->getMailing($objectId, $mailingVersions_item['VERSION']); $mailingInfo = $tmpMailing->get(); $contentareas = $templateMgr->getContentareas($mailingInfo['TEMPLATEID']); $blindCos = array(); foreach ($contentareas as $contentareaItem) { $colist = $tmpMailing->getCblockList($contentareaItem['CODE']); foreach ($colist as $colistItem) { if ($colistItem['ID'] > 0) { $cb = sCblockMgr()->getCblock($colistItem['ID']); $coInfo = $cb->get(); if ($coInfo['EMBEDDED'] == 1) { array_push($blindCos, $colistItem['ID']); } } } } } $blindCos = array_unique($blindCos); $mailingPermissions = $mailing->permissions->getByUsergroup($usergroupId, $objectId); if ($mailingPermissions) { foreach ($blindCos as $coid) { $bcb = sCblockMgr()->getCblock($coid); $bcb->permissions->setByUsergroup($usergroupId, $permission, $coid, $value); } } } return true; }
$history[$i]['FORMFIELD'] = $formfield_name; $history[$i]['EMBLOCK'] = $control_name; $history[$i]['TYPE'] = 'COEDIT'; } } } if ($history[$i]['TAB'] == 'P_CONTENT') { if ($history[$i]['TEXT'] == 'TXT_PAGE_H_COREMOVE' || $history[$i]['TEXT'] == 'TXT_PAGE_H_EMREMOVE' || $history[$i]['TEXT'] == 'TXT_PAGE_H_COADD' || $history[$i]['TEXT'] == 'TXT_PAGE_H_EMADD' || $history[$i]['TEXT'] == 'TXT_PAGE_H_EMCOPY' || $history[$i]['TEXT'] == 'TXT_PAGE_H_COORDER') { if ($siteID && $objectID) { $Tmp_ThePageMgr = new PageMgr($siteID); $Tmp_page = $Tmp_ThePageMgr->getPage($objectID); if ($Tmp_page) { $Tmp_pageInfo = $Tmp_page->get(); $templateId = $Tmp_pageInfo["TEMPLATEID"]; $Tmp_TheTemplateMgr = new Templates(); $tmp_contentareas = $Tmp_TheTemplateMgr->getContentareas($templateId); $history[$i]['CONTENTAREA'] = $history[$i]['OLDVALUE']; unset($realContentareaName); foreach ($tmp_contentareas as $tmp_contentarea) { if ($tmp_contentarea['CODE'] == $history[$i]['CONTENTAREA']) { $realContentareaName = $tmp_contentarea['NAME']; } } if ($realContentareaName) { $history[$i]['CONTENTAREA'] = $realContentareaName; } $history[$i]['TYPE'] = 'COACTION'; // For contentblocks if ($history[$i]['TEXT'] == 'TXT_PAGE_H_COREMOVE' || $history[$i]['TEXT'] == 'TXT_PAGE_H_COADD') { if ($history[$i]['TARGETID']) { $cb = sCblockMgr()->getCblock($history[$i]['TARGETID']);
$template_files = glob($templatedir . 'TMP_' . $templateid . '-*'); // Remove all entries in array before submitted timestamp foreach ($template_files as $template_file) { $tmp_filename = str_replace('TMP_' . $templateid . '-', '', basename($template_file)); $filetimestamp = explode('-', $tmp_filename); $filetimestamp = (int) $filetimestamp[0]; if ($filetimestamp > $timestamp) { array_push($old_template_files, $template_file); } } // Check for added/removed contentareas $filecontentareas = $templateMgr->getContentareasFromTempFile($old_template_files[count($old_template_files) - 1]); if (count($old_template_files) > 1) { $contentareas = $templateMgr->getContentareasFromTempFile($old_template_files[count($old_template_files) - 2]); } else { $contentareas = $templateMgr->getContentareas($templateid); } $a = 0; $r = 0; $afilecontentareas = array(); $rfilecontentareas = array(); for ($s = 0; $s < count($filecontentareas); $s++) { $alreadythere = false; for ($s2 = 0; $s2 < count($contentareas); $s2++) { if ($filecontentareas[$s]['CODE'] == $contentareas[$s2]['CODE']) { $alreadythere = true; } } if ($alreadythere == false) { $afilecontentareas[$a]['CODE'] = $filecontentareas[$s]['CODE']; $a++;