当前位置: 首页>>代码示例>>PHP>>正文


PHP Campaign::Add方法代码示例

本文整理汇总了PHP中Campaign::Add方法的典型用法代码示例。如果您正苦于以下问题:PHP Campaign::Add方法的具体用法?PHP Campaign::Add怎么用?PHP Campaign::Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Campaign的用法示例。


在下文中一共展示了Campaign::Add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Boot

 public function Boot()
 {
     global $db;
     // On upgrade, fix all of the layouts, excluding the default
     $campaign = new Campaign($db);
     $SQL = "SELECT LayoutID, Layout, UserID FROM layout WHERE layout <> 'Default Layout'";
     $layouts = $db->GetArray($SQL);
     // Create a campaign record for all of the layouts that currently exist
     foreach ($layouts as $layout) {
         $layoutId = $layout['LayoutID'];
         $campaignId = $campaign->Add($layout['Layout'], 1, $layout['UserID']);
         $campaign->Link($campaignId, $layoutId, 1);
         // Update Security
         $SQL = "INSERT INTO lkcampaigngroup (CampaignID, GroupID, View, Edit, Del) ";
         $SQL .= " SELECT '{$campaignId}', GroupID, View, Edit, Del ";
         $SQL .= "  FROM lklayoutgroup ";
         $SQL .= " WHERE lklayoutgroup.LayoutID = {$layoutId}";
         $db->query($SQL);
         // Update Events
         $db->query("UPDATE schedule SET layoutid = '{$campaignId}' WHERE layoutid = '{$layoutId}'");
         $db->query("UPDATE schedule_detail SET layoutid = '{$campaignId}' WHERE layoutid = '{$layoutId}'");
     }
     // Also run a script to tidy up orphaned media in the library
     $library = Config::GetSetting('LIBRARY_LOCATION');
     $library = rtrim($library, '/') . '/';
     // Dump the files in the temp folder
     foreach (scandir($library . 'temp') as $item) {
         if ($item == '.' || $item == '..') {
             continue;
         }
         unlink($library . 'temp' . DIRECTORY_SEPARATOR . $item);
     }
     // Have commented this block out, as am not 100% convinced that it doesn't
     // delete things it shouldn't
     //
     // Get a list of all media files
     //        foreach(scandir($library) as $file)
     //        {
     //            if ($file == '.' || $file == '..')
     //                continue;
     //
     //            if (is_dir($library . $file))
     //                continue;
     //
     //            $rowCount = $db->GetCountOfRows("SELECT * FROM media WHERE storedAs = '" . $file . "'");
     //
     //            // For each media file, check to see if the file still exists in the library
     //            if ($rowCount == 0)
     //            {
     //                // If not, delete it
     //                unlink($library . $file);
     //
     //                if (file_exists($library . 'tn_' . $file))
     //                {
     //                    unlink($library . 'tn_' . $file);
     //                }
     //
     //                if (file_exists($library . 'bg_' . $file))
     //                {
     //                    unlink($library . 'bg_' . $file);
     //                }
     //            }
     //        }
     return true;
 }
开发者ID:fignew,项目名称:xibo-cms,代码行数:65,代码来源:46.php

示例2: Add

 /**
  * Add a Campaign
  */
 public function Add()
 {
     // Check the token
     if (!Kit::CheckToken()) {
         trigger_error(__('Sorry the form has expired. Please refresh.'), E_USER_ERROR);
     }
     $db =& $this->db;
     $response = new ResponseManager();
     $name = Kit::GetParam('Name', _POST, _STRING);
     Kit::ClassLoader('campaign');
     $campaignObject = new Campaign($db);
     if (!$campaignObject->Add($name, 0, $this->user->userid)) {
         trigger_error($campaignObject->GetErrorMessage(), E_USER_ERROR);
     }
     $response->SetFormSubmitResponse(__('Campaign Added'), false);
     $response->Respond();
 }
开发者ID:fignew,项目名称:xibo-cms,代码行数:20,代码来源:campaign.class.php

示例3: Copy

 /**
  * Copys a Layout
  * @param <int> $oldLayoutId
  * @param <string> $newLayoutName
  * @param <int> $userId
  * @param <bool> $copyMedia Make copies of this layouts media
  * @return <int> 
  */
 public function Copy($oldLayoutId, $newLayoutName, $newDescription, $userId, $copyMedia = false)
 {
     try {
         $dbh = PDOConnect::init();
         $currentdate = date("Y-m-d H:i:s");
         $campaign = new Campaign($this->db);
         // Include to media data class?
         if ($copyMedia) {
             $mediaObject = new Media($this->db);
             $mediaSecurity = new MediaGroupSecurity($this->db);
         }
         // We need the old campaignid
         $oldCampaignId = $campaign->GetCampaignId($oldLayoutId);
         // The Layout ID is the old layout
         $SQL = "";
         $SQL .= " INSERT INTO layout (layout, xml, userID, description, retired, duration, backgroundImageId, createdDT, modifiedDT, status) ";
         $SQL .= " SELECT :layout, xml, :userid, :description, retired, duration, backgroundImageId, :createddt, :modifieddt, status ";
         $SQL .= "  FROM layout ";
         $SQL .= " WHERE layoutid = :layoutid";
         $sth = $dbh->prepare($SQL);
         $sth->execute(array('layout' => $newLayoutName, 'description' => $newDescription, 'userid' => $userId, 'createddt' => $currentdate, 'modifieddt' => $currentdate, 'layoutid' => $oldLayoutId));
         $newLayoutId = $dbh->lastInsertId();
         // Create a campaign
         $newCampaignId = $campaign->Add($newLayoutName, 1, $userId);
         // Link them
         $campaign->Link($newCampaignId, $newLayoutId, 0);
         // Open the layout XML and parse for media nodes
         if (!$this->SetDomXml($newLayoutId)) {
             $this->ThrowError(25000, __('Unable to copy layout'));
         }
         // Handle the Background
         $sth = $dbh->prepare('SELECT mediaId FROM lklayoutmedia WHERE layoutId = :layoutId AND regionId = :regionId');
         $sth->execute(array('layoutId' => $oldLayoutId, 'regionId' => 'background'));
         if ($row = $sth->fetch()) {
             // This layout does have a background image
             // Link it to the new one
             if (!($newLkId = $this->AddLk($newLayoutId, 'background', $row['mediaId']))) {
                 throw new Exception(__('Unable to link background'));
             }
         }
         // Get all media nodes
         $xpath = new DOMXpath($this->DomXml);
         // Create an XPath to get all media nodes
         $mediaNodes = $xpath->query("//media");
         Debug::LogEntry('audit', 'About to loop through media nodes', 'layout', 'Copy');
         $copiesMade = array();
         // On each media node, take the existing LKID and MediaID and create a new LK record in the database
         $sth = $dbh->prepare('SELECT StoredAs FROM media WHERE MediaID = :mediaid');
         foreach ($mediaNodes as $mediaNode) {
             $mediaId = $mediaNode->getAttribute('id');
             $type = $mediaNode->getAttribute('type');
             // Store the old media id
             $oldMediaId = $mediaId;
             Debug::LogEntry('audit', sprintf('Media %s node found with id %d', $type, $mediaId), 'layout', 'Copy');
             // If this is a non region specific type, then move on
             if ($this->IsRegionSpecific($type)) {
                 // Generate a new media id
                 $newMediaId = md5(Kit::uniqueId());
                 $mediaNode->setAttribute('id', $newMediaId);
                 // Copy media security
                 $security = new LayoutMediaGroupSecurity($this->db);
                 $security->CopyAllForMedia($oldLayoutId, $newLayoutId, $mediaId, $newMediaId);
                 continue;
             }
             // Library media assigned to the layout, it will have a lkid
             $lkId = $mediaNode->getAttribute('lkid');
             // Get the regionId
             $regionNode = $mediaNode->parentNode;
             $regionId = $regionNode->getAttribute('id');
             // Do we need to copy this media record?
             if ($copyMedia) {
                 // Take this media item and make a hard copy of it.
                 if (!($mediaId = $mediaObject->Copy($mediaId, $newLayoutName))) {
                     throw new Exception("Error Processing Request", 1);
                 }
                 // Update the permissions for the new media record
                 $mediaSecurity->Copy($oldMediaId, $mediaId);
                 // Copied the media node, so set the ID
                 $mediaNode->setAttribute('id', $mediaId);
                 // Also need to set the options node
                 // Get the stored as value of the new node
                 $sth->execute(array('mediaid' => $mediaId));
                 if (!($row = $sth->fetch())) {
                     $this->ThrowError(25000, __('Unable to find stored value of newly copied media'));
                 }
                 $fileName = Kit::ValidateParam($row['StoredAs'], _STRING);
                 $newNode = $this->DomXml->createElement('uri', $fileName);
                 // Find the old node
                 $uriNodes = $mediaNode->getElementsByTagName('uri');
                 $uriNode = $uriNodes->item(0);
                 // Replace it
                 $uriNode->parentNode->replaceChild($newNode, $uriNode);
//.........这里部分代码省略.........
开发者ID:taphier,项目名称:xibo-cms,代码行数:101,代码来源:layout.data.class.php


注:本文中的Campaign::Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。