コード例 #1
0
ファイル: cblock.php プロジェクト: nrueckmann/yeager
 /**
  * Generates a new version of this Cblock
  *
  * @return int|false New version of this Cblock or FALSE in case of an error
  */
 function newVersion()
 {
     $cbId = $this->_id;
     if ($this->permissions->checkInternal($this->_uid, $cbId, "RWRITE")) {
         $sourceVersion = $this->getVersion();
         $sourceObject = sCblockMgr()->getCblock($this->_id, $sourceVersion);
         if ($sourceVersion == $this->getLatestVersion()) {
             $historyIdentifier = 'TXT_CBLOCK_H_NEWVERSION';
             $historySourceVersion = NULL;
         } else {
             $historyIdentifier = 'TXT_CBLOCK_H_NEWVERSION_FROM';
             $historySourceVersion = $sourceVersion;
         }
         $newVersion = (int) parent::newVersion();
         $this->properties = new Properties($this->_table_properties, $this->getPropertyId(), $this);
         $this->tags->copyTo($cbId, $sourceVersion, $cbId, $newVersion);
         $this->copyExtensionsFrom($sourceObject);
         if ($sourceVersionLinks > 0) {
             $sql = "SELECT * FROM yg_contentblocks_lnk_entrymasks WHERE CBID = ? AND CBVERSION = ?";
             $dbr = sYDB()->Execute($sql, $cbId, $sourceVersion);
             $links = $dbr->GetArray();
             for ($l = 0; $l < count($links); $l++) {
                 $sql = "INSERT INTO yg_contentblocks_lnk_entrymasks (ENTRYMASK, CBID, CBVERSION, ORDERPROD)\n\t\t\t\t\t\tVALUES (?, ?, ?, ?)";
                 sYDB()->Execute($sql, $links[$l]["ENTRYMASK"], $links[$l]["CBID"], $newVersion, $links[$l]["ORDERPROD"]);
                 $linkId = (int) sYDB()->Insert_ID();
                 $sql = "INSERT INTO `yg_contentblocks_lnk_entrymasks_c`\n\t\t\t\t\t\t\t\t(FORMFIELD, ENTRYMASKFORMFIELD, LNK, VALUE01, VALUE02, VALUE03, VALUE04, VALUE05, VALUE06, VALUE07, VALUE08)\n\t\t\t\t\t\t\tSELECT FORMFIELD, ENTRYMASKFORMFIELD, {$linkId}, VALUE01, VALUE02, VALUE03, VALUE04, VALUE05, VALUE06, VALUE07, VALUE08\n\t\t\t\t\t\t\tFROM yg_contentblocks_lnk_entrymasks_c WHERE (LNK = ?);";
                 sYDB()->Execute($sql, $links[$l]["ID"]);
                 $sql = "SELECT * FROM yg_contentblocks_lnk_entrymasks_c AS c WHERE c.LNK = ?";
                 $dbr = sYDB()->Execute($sql, $linkId);
                 $newcs = $dbr->GetArray();
                 $sql = "SELECT * FROM yg_contentblocks_lnk_entrymasks_c AS c WHERE c.LNK = ?";
                 $dbr = sYDB()->Execute($sql, $links[$l]["ID"]);
                 $oldcs = $dbr->GetArray();
                 for ($r = 0; $r < count($oldcs); $r++) {
                     $sql = "INSERT INTO yg_references (SRCTYPE, SRCOID, SRCVER, TGTTYPE, TGTOID, TGTAID)\n\t\t\t\t\t\t\t\tSELECT SRCTYPE, " . (int) $newcs[$r]["ID"] . ", " . $newVersion . ", TGTTYPE, TGTOID, TGTAID\n\t\t\t\t\t\t\t\tFROM yg_references WHERE (SRCOID =  ?);";
                     sYDB()->Execute($sql, $oldcs[$r]["ID"]);
                 }
             }
         } else {
             $sql = "SELECT * FROM yg_contentblocks_lnk_entrymasks WHERE CBID = ? AND CBVERSION = ?";
             $dbr = sYDB()->Execute($sql, $cbId, $sourceVersion);
             if (!$dbr) {
                 return;
             }
             $links = $dbr->GetArray();
             for ($l = 0; $l < count($links); $l++) {
                 $sql = "INSERT INTO yg_contentblocks_lnk_entrymasks (ENTRYMASK, CBID, CBVERSION, ORDERPROD)\n\t\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t(?, ?, ?, ?)";
                 sYDB()->Execute($sql, $links[$l]["ENTRYMASK"], $links[$l]["CBID"], $newVersion, $links[$l]["ORDERPROD"]);
                 $linkId = (int) sYDB()->Insert_ID();
                 $sql = "INSERT INTO `yg_contentblocks_lnk_entrymasks_c`\n\t\t\t\t\t\t\t\t(FORMFIELD, ENTRYMASKFORMFIELD, LNK, VALUE01, VALUE02, VALUE03, VALUE04, VALUE05, VALUE06, VALUE07, VALUE08)\n\t\t\t\t\t\t\tSELECT FORMFIELD, ENTRYMASKFORMFIELD, {$linkId}, VALUE01, VALUE02, VALUE03, VALUE04, VALUE05, VALUE06, VALUE07, VALUE08\n\t\t\t\t\t\t\tFROM yg_contentblocks_lnk_entrymasks_c WHERE (LNK = ?);";
                 sYDB()->Execute($sql, $links[$l]["ID"]);
                 $sql = "SELECT * FROM yg_contentblocks_lnk_entrymasks_c AS c WHERE c.LNK = ?";
                 $dbr = sYDB()->Execute($sql, $linkId);
                 $newcs = $dbr->GetArray();
                 $sql = "SELECT * FROM yg_contentblocks_lnk_entrymasks_c AS c WHERE c.LNK = ?";
                 $dbr = sYDB()->Execute($sql, $links[$l]["ID"]);
                 $oldcs = $dbr->GetArray();
                 for ($r = 0; $r < count($oldcs); $r++) {
                     $sql = "INSERT INTO yg_references (SRCTYPE, SRCOID, SRCVER, TGTTYPE, TGTOID, TGTAID)\n\t\t\t\t\t\t\t\tSELECT SRCTYPE, " . (int) $newcs[$r]["ID"] . ", " . $newVersion . ", TGTTYPE, TGTOID, TGTAID\n\t\t\t\t\t\t\t\tFROM yg_references WHERE (SRCOID = ?);";
                     sYDB()->Execute($sql, $oldcs[$r]["ID"]);
                 }
             }
         }
         $extensions = new ExtensionMgr(sYDB(), $this->_uid);
         $all_cblock_extensions = $extensions->getList(EXTENSION_CBLOCK, true);
         foreach ($all_cblock_extensions as $all_cblock_extension) {
             $extension = $extensions->getExtension($all_cblock_extension['CODE']);
             if ($extension && $extension->usedByCblock($cbId, $sourceVersion) === true) {
                 if ($extension->usedByCblock($cbId, $newVersion) !== true) {
                     $extension->addToCBlockInternal($cbId, $newVersion);
                 }
                 $extension = $extensions->getExtension($all_cblock_extension['CODE'], $cbId, $newVersion);
                 $sourceext = $extensions->getExtension($all_cblock_extension['CODE'], $cbId, $sourceVersion);
                 if ($extension && $sourceext) {
                     $newCbId = $extension->getPropertyId();
                     $oldcid = $sourceext->getPropertyId();
                     $extension->properties->copyTo($oldcid, $newCbId);
                 }
             }
         }
         sCblockMgr()->callExtensionHook('onVersionNew', (int) $this->_id, $this->getVersion());
         // Add to history
         $new_version = $this->getLatestVersion();
         $this->history->add(HISTORYTYPE_CO, $historySourceVersion, $new_version, $historyIdentifier);
         return $newVersion;
     } else {
         return false;
     }
 }
コード例 #2
0
ファイル: mailing.php プロジェクト: nrueckmann/yeager
 /**
  * Generates a new version of this Mailing by copying the currently instanced version
  * and updates the currently instanced Object to the new version
  *
  * @return int|false New version of this Mailing or FALSE in case of an error
  */
 public function newVersion()
 {
     $mailingID = $this->_id;
     if ($this->permissions->checkInternal($this->_uid, $mailingID, "RWRITE")) {
         $colist = $this->getCblockList();
         $sourceVersion = $this->getVersion();
         $sourceObject = sMailingMgr()->getMailing($this->_id, $sourceVersion);
         if ($sourceVersion == $this->getLatestVersion()) {
             $historyIdentifier = 'TXT_MAILING_H_NEWVERSION';
             $historySourceVersion = NULL;
         } else {
             $historyIdentifier = 'TXT_MAILING_H_NEWVERSION_FROM';
             $historySourceVersion = $sourceVersion;
         }
         $newVersion = parent::newVersion();
         $this->properties = new Properties($this->_table_properties, $this->getPropertyId(), $this);
         $this->tags->copyTo($mailingID, $sourceVersion, $mailingID, $newVersion);
         $this->copyCblockLinks($sourceVersion, $newVersion);
         $this->copyUsergroupLinks($sourceVersion, $newVersion);
         $this->copyExtensionsFrom($sourceObject);
         // Check if there are blind entrymasks in this mailing (and add a version)
         foreach ($colist as $colist_item) {
             if ($colist_item['EMBEDDED'] == 1) {
                 $tmpCb = sCblockMgr()->getCblock($colist_item['OBJECTID'], $colist_item['VERSION']);
                 $version = $tmpCb->newVersion();
                 $CoLnkInfo = $this->getCblockLinkById($colist_item['LINKID']);
                 $this->addCblockVersion($colist_item['OBJECTID'], $CoLnkInfo[0]['TEMPLATECONTENTAREA'], $version);
             }
         }
         sMailingMgr()->callExtensionHook('onVersionNew', (int) $this->_id, $this->getVersion());
         // Add to history
         $this->history->add(HISTORYTYPE_MAILING, $historySourceVersion, $newVersion, $historyIdentifier);
         return $newVersion;
     } else {
         return false;
     }
 }
コード例 #3
0
ファイル: file.php プロジェクト: nrueckmann/yeager
 /**
  * Generates a new version of this File by copying the currently instanced version
  * and updates the currently instanced Object to the new version
  *
  * @return int|false New version of this File or FALSE in case of an error
  */
 public function newVersion()
 {
     $fileID = $this->_id;
     if ($this->permissions->checkInternal($this->_uid, $fileID, "RWRITE")) {
         $sourceVersion = $this->getVersion();
         $sourceObject = sFileMgr()->getFile($this->_id, $sourceVersion);
         if ($sourceVersion == $this->getLatestVersion()) {
             $historyIdentifier = 'TXT_FILE_H_NEWVERSION';
             $historySourceVersion = NULL;
         } else {
             $historyIdentifier = 'TXT_FILE_H_NEWVERSION_FROM';
             $historySourceVersion = $sourceVersion;
         }
         $newVersion = parent::newVersion();
         $this->properties = new Properties($this->_table_properties, $this->getPropertyId(), $this);
         $this->tags->copyTo($fileID, $sourceVersion, $fileID, $newVersion);
         $this->views->copyTo($fileID, $sourceVersion, $fileID, $newVersion, false);
         $this->views->copyGeneratedViewInfo($sourceVersion, $newVersion);
         $this->approveVersion($newVersion);
         $this->copyExtensionsFrom($sourceObject);
         sFileMgr()->callExtensionHook('onVersionNew', (int) $this->_id, $this->getVersion());
         // Add to history
         $newVersion = $this->getLatestApprovedVersion();
         $this->history->add(HISTORYTYPE_FILE, $historySourceVersion, $newVersion, $historyIdentifier);
         if (Singleton::cache_config()->getVar("CONFIG/INVALIDATEON/FILE_PUBLISH") == "true") {
             Singleton::FC()->emptyBucket();
         }
         return $newVersion;
     } else {
         return false;
     }
 }