Esempio n. 1
0
 /**
  * Copies Properties, Permissions, Tags and content from another Cblock into a new version of this Cblock
  *
  * @param object $sourceObject Source Cblock object
  * @return bool TRUE on success or FALSE in case of an error
  * @throws Exception
  */
 public function copyFrom(&$sourceObject)
 {
     $sourceID = $sourceObject->getID();
     $sourceVersion = $sourceObject->getVersion();
     $sourceInfo = $sourceObject->get();
     $targetID = (int) $this->_id;
     $targetVersion = $this->getVersion();
     parent::copyFrom($sourceObject);
     if ($sourceInfo["FOLDER"] == 0) {
         $sql = "DELETE FROM yg_contentblocks_lnk_entrymasks WHERE CBID = ? AND CBVERSION = ?;";
         sYDB()->Execute($sql, $targetID, $targetVersion);
         $sql = "SELECT * FROM yg_contentblocks_lnk_entrymasks WHERE CBID = ? AND CBVERSION = ?;";
         $dbr = sYDB()->Execute($sql, $sourceID, $sourceVersion);
         $links = $dbr->GetArray();
         for ($l = 0; $l < count($links); $l++) {
             $sql = "INSERT INTO yg_contentblocks_lnk_entrymasks (ENTRYMASK, CBID, CBVERSION, ORDERPROD) VALUES (?, ?, ?, ?)";
             sYDB()->Execute($sql, $links[$l]["ENTRYMASK"], $targetID, $targetVersion, $links[$l]["ORDERPROD"]);
             $linkId = (int) sYDB()->Insert_ID();
             $sql = "INSERT INTO `yg_contentblocks_lnk_entrymasks_c`\n\t\t\t\t\t\t\t(FORMFIELD, ENTRYMASKFORMFIELD, LNK, VALUE01, VALUE02, VALUE03, VALUE04, VALUE05, VALUE06, VALUE07, VALUE08)\n\t\t\t\t\t\tSELECT FORMFIELD, ENTRYMASKFORMFIELD, {$linkId}, VALUE01, VALUE02, VALUE03, VALUE04, VALUE05, VALUE06, VALUE07, VALUE08\n\t\t\t\t\t\tFROM yg_contentblocks_lnk_entrymasks_c WHERE (LNK = ?);";
             sYDB()->Execute($sql, $links[$l]["ID"]);
         }
     }
     $this->copyExtensionsFrom($sourceObject);
     $this->markAsChanged();
 }
Esempio n. 2
0
 /**
  * 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;
     }
 }
Esempio n. 3
0
 /**
  * Copies Properties, Extensions, Permissions, Views, Tags from another File into this File
  *
  * @param object $sourceObject Source File object
  * @return bool TRUE on success or FALSE in case of an error
  * @throws Exception
  */
 public function copyFrom(&$sourceObject)
 {
     $sourceID = $sourceObject->getID();
     $sourceVersion = $sourceObject->getVersion();
     $sourceInfo = $sourceObject->get();
     $targetID = (int) $this->_id;
     $targetVersion = $this->getVersion();
     $targetInfo = $this->get();
     $targetThumbVersion = (int) $targetInfo['VIEWVERSION'] + 1;
     $filedir = sConfig()->getVar('CONFIG/DIRECTORIES/FILESDIR') . "/";
     parent::copyFrom($sourceObject);
     $this->setFileType($sourceInfo['FILETYPE']);
     $this->setFilename($sourceInfo['FILENAME']);
     $this->setFilesize($sourceInfo['FILESIZE']);
     if ($sourceInfo["FOLDER"] == 0) {
         $fprefix = $sourceObject->getID() . "-" . $sourceInfo["VIEWVERSION"];
         $filename = $sourceInfo["FILENAME"];
         $tmpfile = $filedir . $fprefix . $filename;
         copy($tmpfile, $filedir . $targetID . "-" . $targetThumbVersion . $sourceInfo["FILENAME"]);
         $tmpfile = tempnam();
         copy($filedir . $fprefix . $filename, $tmpfile);
         $this->updateFile($filename, $sourceInfo["FILETYPE"], $tmpfile, false);
         unlink($tmpfile);
     }
     $this->setViewVersion($targetThumbVersion);
     $this->views->copyTo($sourceID, $sourceVersion, $targetID, $this->getLatestApprovedVersion());
     $this->views->copyGeneratedViewInfo($sourceVersion, $targetVersion, $sourceID);
     $this->views->scheduleUpdate();
     $this->copyExtensionsFrom($sourceObject);
 }