/** * Approves the specified version of this Mailing and all embedded Cblocks and creates a new working version * * @param int $version (optional) Mailing version * @return int|false New version or FALSE in case of an error */ public function approveVersion($version = 0) { $result = parent::approveVersion($version); // Check if there are blind entrymasks in this mailing (and add a version) $colist = $this->getCblockList(); foreach ($colist as $colist_item) { if ($colist_item['EMBEDDED'] == 1) { $tmpCb = sCblockMgr()->getCblock($colist_item['OBJECTID'], $colist_item['VERSION']); $tmpCb->approveVersion(); } } if ((int) $version == 0) { $version = (int) $this->getVersion(); } $this->history->add(HISTORYTYPE_MAILING, NULL, $version, 'TXT_MAILING_H_APPROVE'); if ($this->getPublishedVersion() == ALWAYS_LATEST_APPROVED_VERSION) { $this->history->add(HISTORYTYPE_MAILING, NULL, $version, 'TXT_MAILING_H_AUTOPUBLISH'); sMailingMgr()->callExtensionHook("onPublish", $this->_id, $version); if (Singleton::cache_config()->getVar("CONFIG/INVALIDATEON/MAILING_PUBLISH") == "true") { Singleton::FC()->emptyBucket(); } } sMailingMgr()->callExtensionHook('onApprove', (int) $this->_id, (int) $this->_version); return result; }
if (count($userIds) > 0) { // Queue emails foreach ($userIds as $currUserId) { $user = new User($currUserId); $userInfo = $user->get(); $userInfo['PROPERTIES'] = $user->properties->getValues($currUserId); $userId = $userInfo['ID']; $userEmail = $userInfo['PROPERTIES']['EMAIL']; $userFirstName = $userInfo['PROPERTIES']['FIRSTNAME']; $userLastName = $userInfo['PROPERTIES']['LASTNAME']; $userName = trim($userFirstName . ' ' . $userLastName); $userCompany = $userInfo['PROPERTIES']['COMPANY']; $userDepartment = $userInfo['PROPERTIES']['COMPANY']; $emailData = array('MAILING_ID' => $mailingId, 'USER_ID' => $userInfo['ID'], 'IS_TEST' => false, 'TO' => array(array('EMAIL' => $userEmail, 'EMAIL_NAME' => $userName)), 'CC' => array(), 'BCC' => array(), 'ATTACHMENTS' => array(), 'ENCODING' => $emailData['ENCODING'], 'CHARSET' => 'utf-8'); $mailingData = array('USERINFO' => $userInfo, 'DATA' => $emailData); $mailingData = sMailingMgr()->callExtensionHook('beforeSend', $mailingId, $latestFinalVersion, $mailingData); $scheduleId = $mailingMgr->scheduler->schedule($mailingId, 'SCH_EMAILSEND', time(), $mailingData['DATA']); } $scheduleId = $mailingMgr->scheduler->schedule($mailingId, 'SCH_EMAILCHECKFINISH', time(), array('MAILING_ID' => $mailingId)); // Set status of mailing $mailing->setStatus('INPROGRESS'); // Set status in gui $jsQueue->add($mailingId, HISTORYTYPE_MAILING, 'OBJECT_CHANGECLASS', sGuiUS(), 'mailing', NULL, NULL, $mailingId . '-mailing', 'statusinfo', 'status_info inprogress'); // Trigger locking of the current mailing $jsQueue->add($mailingId, HISTORYTYPE_MAILING, 'OBJECT_CHANGE_LOCK_STATE', sGuiUS(), 'mailing', NULL, NULL, $mailingId . '-mailing', 'true'); // Log history $mailing->history->add(HISTORYTYPE_MAILING, $latestFinalVersion, $latestFinalVersion, 'TXT_MAILING_H_SENDING'); } else { $koala->alert($itext['TXT_MAILING_ERROR_NO_RECIPIENTS']); } }
$page = $pageMgr->getPage($objectid); $pageInfo = $page->get(); $jsQueue = new JSQueue(NULL, $siteID); $tagInfo = $page->tags->get($tag); if ($page->tags->unassign($tag) === false) { $koala->alert($itext['TXT_ERROR_ACCESS_DENIED']); } else { $jsQueue->add($objectid, HISTORYTYPE_PAGE, 'OBJECT_DELETE', sGuiUS(), 'tag', NULL, NULL, $tag . '-tag', 'name', 'page', $objectid . '-' . $siteID); $jsQueue->add($objectid, HISTORYTYPE_PAGE, 'HIGHLIGHT_PAGE', sGuiUS(), 'name'); // Add to history $page->history->add(HISTORYTYPE_PAGE, NULL, $tagInfo[NAME], "TXT_TAG_H_REMOVE", $tag); } break; case 'mailing': // For Mailings $mailing = sMailingMgr()->getMailing($objectid); $mailingInfo = $mailing->get(); $tagInfo = $mailing->tags->get($tag); if ($mailing->tags->unassign($tag) === false) { $koala->alert($itext['TXT_ERROR_ACCESS_DENIED']); } else { $jsQueue->add($objectid, HISTORYTYPE_MAILING, 'OBJECT_DELETE', sGuiUS(), 'tag', NULL, NULL, $tag . '-tag', 'name', 'mailing', $objectid . '-mailing'); $jsQueue->add($objectid, HISTORYTYPE_MAILING, 'HIGHLIGHT_MAILING', sGuiUS(), 'name'); // Add to history $mailing->history->add(HISTORYTYPE_PAGE, NULL, $tagInfo[NAME], "TXT_TAG_H_REMOVE", $tag); } break; } break; case 'orderObjectTag': $objectid = $this->params['objectID'];
switch ($action) { case 'deleteTemplate': $template = $this->params['template']; $confirmed = $this->params['confirmed']; $positive = $this->params['positive']; // Check if template is still used $stillInUse = false; $sites = sSites()->getList(); foreach ($sites as $curr_site) { $pageMgr = new PageMgr($curr_site['ID']); $pages = $pageMgr->getPagesByTemplate($template); if (count($pages) > 0) { $stillInUse = true; } } $mailings = sMailingMgr()->getMailingsByTemplate($template); if (count($pages) > 0) { $stillInUse = true; } $tmpTemplateInfo = $templateMgr->getTemplate($template); if ($stillInUse) { // Still used! if ($confirmed != 'true') { $parameters = array('template' => $template); $koala->callJSFunction('Koala.yg_confirm', $itext['TXT_DELETE_USED_TEMPLATE_TITLE'] != '' ? $itext['TXT_DELETE_USED_TEMPLATE_TITLE'] : '$TXT_DELETE_USED_TEMPLATE_TITLE', $itext['TXT_DELETE_USED_TEMPLATE'] != '' ? $itext['TXT_DELETE_USED_TEMPLATE'] : '$TXT_DELETE_USED_TEMPLATE', $action, json_encode($parameters)); } else { if ($confirmed == 'true' && $positive == 'true') { $successfullyDeleted = $templateMgr->remove($template); if (in_array($template, $successfullyDeleted)) { if ($tmpTemplateInfo['FOLDER']) { $jsQueue->add($template, HISTORYTYPE_TEMPLATE, 'OBJECT_DELETE', sGuiUS(), 'templatefolder', NULL, NULL, $template . '-template', 'name');
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; }
/** * Removes this Extension from the specified Mailing * * @param string $pageID Mailing Id * @param string $version Mailing version * @return bool TRUE on success or FALSE in case of an error * @throws Exception */ public function removeFromMailing($mailingID, $version) { $mailingID = (int) $mailingID; $version = (int) $version; $sql = "DELETE FROM yg_extensions_lnk_mailings WHERE CODE = ? AND MAILINGID = ? AND MAILINGVERSION = ?;"; $result = sYDB()->Execute($sql, $this->_code, $mailingID, $version); if ($result === false) { throw new Exception(sYDB()->ErrorMsg()); } $mailing = sMailingMgr()->getMailing($mailingID, $version); if ($mailing) { $mailing->markAsChanged(); } return true; }
$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"); $styleData = getStyleForContentblock($cblockInfo, true); array_pop($pr); $objectparents = $pr; array_push($incoming_cos, array('ID' => $cblockInfo['OBJECTID'], 'STYLE' => $styleData, 'NAME' => $cblockInfo['NAME'], 'FOLDER' => $cblockInfo['FOLDER'], 'PARENTS' => $objectparents)); } // Get all mailings with this tag $filterArray = array(); $filterArray[] = array('TYPE' => 'DELETED', 'OPERATOR' => 'is_not', 'VALUE' => 1); $tagged_mailings = sMailingMgr()->tags->getByTag($tag_id, "OBJECTORDER DESC", "OR", false, $filterArray); foreach ($tagged_mailings as $tagged_mailing_item) { $pr = sMailingMgr()->getParents($tagged_mailing_item['OBJECTID']); $mailing = sMailingMgr()->getMailing($tagged_mailing_item['OBJECTID']); $mailingInfo = $mailing->get(); $mailingInfo['RWRITE'] = $mailing->permissions->checkInternal(sUserMgr()->getCurrentUserID(), $tagged_mailing_item['OBJECTID'], "RWRITE"); $mailingInfo['RDELETE'] = $mailing->permissions->checkInternal(sUserMgr()->getCurrentUserID(), $tagged_mailing_item['OBJECTID'], "RDELETE"); $styleData = getStyleForContentblock($mailingInfo, true); array_pop($pr); $objectparents = $pr; array_push($incoming_mailings, array('ID' => $mailingInfo['OBJECTID'], 'STYLE' => $styleData, 'NAME' => $mailingInfo['NAME'], 'PARENTS' => $objectparents)); } // Get all sites $sites = sSites()->getList(); foreach ($sites as $currentSite) { // Get all pages with this tag $pageMgr = new PageMgr($currentSite['ID']); $filterArray = array(); $filterArray[] = array('TYPE' => 'DELETED', 'OPERATOR' => 'is_not', 'VALUE' => 1);
if (strpos($request_path_string, "/mailing/") >= 0) { // Remove leading 'mailing/' $request_path_string = str_replace('/mailing/', '/', $request_path_string); } if (strpos($request_path_string, "mailing/") === 0) { // Remove leading 'mailing/' $request_path_string = substr($request_path_string, strlen('mailing/')); } if (strpos($request_path_string, $webroot_path_string . '/') === 0) { // Remove leading webroot-prefix $request_path_string = substr($request_path_string, strlen($webroot_path_string . '/')); } $request_path = explode('/', $request_path_string); $mailingId = $request_path[0]; if (!is_numeric($mailingId)) { $mailingId = sMailingMgr()->getMailingIdByPName($mailingId); } // Fill userinfo with data from current user $user = new User(sUserMgr()->getCurrentUserID()); $userInfo = $user->get(); $userInfo['PROPERTIES'] = $user->properties->getValues(sUserMgr()->getCurrentUserID()); $userInfo['PROPERTIES']['FULLNAME'] = trim($userInfo['PROPERTIES']['FIRSTNAME'] . ' ' . $userInfo['PROPERTIES']['LASTNAME']); $previewMode = true; } else { // Get and set frontend timezone $this->displaymode = "live"; $frontendTimezone = (string) Singleton::config()->getVar('CONFIG/TIMEZONES/FRONTEND'); if (!$frontendTimezone) { $frontendTimezone = 'Europe/Berlin'; } date_default_timezone_set($frontendTimezone);
$objectInfo = $mailing->get(); $tags = $mailing->tags->getAssigned(); $object_permissions = array(); $object_permissions['RWRITE'] = $mailing->permissions->checkInternal(sUserMgr()->getCurrentUserID(), $objectID, "RWRITE"); $object_permissions['READONLY'] = !$mailing->permissions->checkInternal(sUserMgr()->getCurrentUserID(), $objectID, "RWRITE"); $object_permissions['RSTAGE'] = $mailing->permissions->checkInternal(sUserMgr()->getCurrentUserID(), $objectID, "RSTAGE"); if ($objectInfo['DELETED']) { $object_permissions['RWRITE'] = false; $object_permissions['READONLY'] = true; $object_permissions['RSTAGE'] = false; } // Get current locks for this token (and unlock them) $lockToken = sGuiUS() . '_' . $this->request->parameters['win_no']; $lockedObjects = sMailingMgr()->getLocksByToken($lockToken); foreach ($lockedObjects as $lockedObject) { $currentObject = sMailingMgr()->getMailing($lockedObject['OBJECTID']); $currentObject->releaseLock($lockedObject['TOKEN']); } // Check for lock, and lock if not locked $lockStatus = $mailing->getLock(); if ($lockStatus['LOCKED'] == 0) { $lockedFailed = !$mailing->acquireLock($lockToken); } else { $lockedFailed = true; } for ($i = 0; $i < count($tags); $i++) { $myparents = $mailing->tags->tree->getParents($tags[$i]['ID']); $parents = array(); for ($p = 0; $p < count($myparents) - 1; $p++) { $parents[$p]['INFO'] = $mailing->tags->get($myparents[$p]); }
if (!isset($reftargethash[$oref[$i]["SRCOID"]])) { $links = sCblockMgr()->getCblockLinkByEntrymaskLinkId($oref[$i]["SRCOID"]); $linkedto = array(); for ($c = 0; $c < count($links); $c++) { if ($oref[$i]["SRCVER"] > 0) { $lcb = sCblockMgr()->getCblock($links[$c]["CBLOCKID"]); if ($lcb) { $lcv = $lcb->getPublishedVersion(true); $lcb = sCblockMgr()->getCblock($links[$c]["CBLOCKID"], $lcv); $lcoinfo = $lcb->get(); $linkedtomailings = $lcb->getLinkedMailingVersions(true); for ($m = 0; $m < count($linkedtomailings); $m++) { $linkmailingid = $linkedtomailings[$m]['ID']; $lMailing = sMailingMgr()->getMailing($linkmailingid); $mailingversions = $lMailing->getVersionsByCblockId($links[$c]['CBLOCKID']); $referredMailing = sMailingMgr()->getMailing($linkedtomailings[$m]["PID"]); $lmv = $referredMailing->getPublishedVersion(true); // $lmv++; for ($mv = 0; $mv < count($mailingversions); $mv++) { if ($lmv == $mailingversions[$mv]["VERSION"]) { $cb = sCblockMgr()->getCblock($links[$c]['CBLOCKID']); $cblockInfo = $cb->get(); if (!isset($refcohash[$cblockInfo["ID"]])) { $incoming[$ic]["ID"] = $links[$c]["CBLOCKID"]; $incoming[$ic]["VIATYPE"] = REFTYPE_FORMFIELD; $incoming[$ic]["VIANAME"] = $cblockInfo["NAME"]; $cop = sCblockMgr()->getParents($links[$c]["CBLOCKID"]); array_pop($cop); $incoming[$ic]["PARENTS"] = $cop; $incoming[$ic]["EMBEDDED"] = $cblockInfo["EMBEDDED"]; $incoming[$ic]['ID'] = $links[$c]["CBLOCKID"];
/** * Gets all published Mailings linked to this Cblock * * @param bool $onlyPublished TRUE if only published Pageversions should be returned (optional) * @return array|false Array of linked Mailings or FALSE in case of an error */ function getLinkedMailings($onlyPublished = false) { $cbId = (int) $this->_id; if ($this->permissions->checkInternal($this->_uid, $cbId, "RREAD")) { $mailingMgr = sMailingMgr(); $a = 0; $linkedtomailing = $this->getLinkedMailingVersions(true); if (count($linkedtomailing) > 0) { for ($x = 0; $x < count($linkedtomailing); $x++) { $linkmailingid = $linkedtomailing[$x]['ID']; $n = $mailingMgr->getMailing($linkmailingid); $mailingversions = $n->getVersionsByCblockId($cbId); $linkedMailingInfo = $n->get(); $linkedmailings[$a]['MAILINGID'] = $linkmailingid; $linkedmailings[$a]['MAILINGNAME'] = $linkedMailingInfo['NAME']; $linkedmailings[$a]['HASCHANGED'] = $linkedtomailing[$x]['HASCHANGED']; if ($onlyPublished) { $tmpVersion = $n->getPublishedVersion(true); $linkedpages[$a]['VERSION'] = $tmpVersion; $linkedInPublishedVersion = false; foreach ($mailingversions as $mailingversionsItem) { if ($mailingversionsItem['VERSION'] == $tmpVersion) { $linkedInPublishedVersion = true; } } if (!$linkedInPublishedVersion) { unset($linkedmailings[$a]); } else { $a++; } } else { $linkedmailings[$a]['VERSIONS'] = $mailingversions; $a++; } } } return $linkedmailings; } else { return false; } }
$tmpPageInfo['RWRITE'] = $tmpPage->permissions->checkInternal(sUserMgr()->getCurrentUserID(), $curr_page['ID'], "RWRITE"); $tmpPageInfo['RDELETE'] = $tmpPage->permissions->checkInternal(sUserMgr()->getCurrentUserID(), $curr_page['ID'], "RDELETE"); $pages[$curr_idx]['PAGEINFO'] = $tmpPageInfo; $iconData = getIconForPage($tmpPageInfo); $pages[$curr_idx]['ICON'] = $iconData['iconclass']; $pages[$curr_idx]['STYLE'] = $iconData['style']; $pages[$curr_idx]['HASCHANGED'] = $tmpPageInfo['HASCHANGED']; } $all_pages = array_merge($all_pages, $pages); } } $all_mailings = array(); $mailings = sMailingMgr()->getMailingsByTemplate($template); if (count($mailings) > 0) { foreach ($mailings as $curr_idx => $curr_mailing) { $tmpMailing = sMailingMgr()->getMailing($curr_mailing['ID']); $tmpMailingInfo = $tmpMailing->get(); $tmpMailingInfo['RWRITE'] = $tmpMailing->permissions->checkInternal(sUserMgr()->getCurrentUserID(), $curr_mailing['ID'], "RWRITE"); $tmpMailingInfo['RDELETE'] = $tmpMailing->permissions->checkInternal(sUserMgr()->getCurrentUserID(), $curr_mailing['ID'], "RDELETE"); $mailings[$curr_idx]['PAGEINFO'] = $tmpMailingInfo; $iconData = getIconForPage($tmpMailingInfo); $mailings[$curr_idx]['ICON'] = 'mailing'; if ($tmpMailingInfo['HASCHANGED']) { $mailings[$curr_idx]['STYLE'] = 'changed'; } $mailings[$curr_idx]['HASCHANGED'] = $tmpMailingInfo['HASCHANGED']; } $all_mailings = array_merge($all_mailings, $mailings); } $smarty->assign("all_pages", $all_pages); $smarty->assign("all_mailings", $all_mailings);