本文整理汇总了PHP中OA_Dal::staticDuplicate方法的典型用法代码示例。如果您正苦于以下问题:PHP OA_Dal::staticDuplicate方法的具体用法?PHP OA_Dal::staticDuplicate怎么用?PHP OA_Dal::staticDuplicate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OA_Dal
的用法示例。
在下文中一共展示了OA_Dal::staticDuplicate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDuplicate
function testDuplicate()
{
$GLOBALS['strCopyOf'] = 'Copy of ';
// create test channel
$doChannel = OA_Dal::factoryDO('channel');
$doChannel->acls_updated = '2007-04-03 19:29:54';
$channelId = DataGenerator::generateOne($doChannel, true);
// create test acls
$doAcls = OA_Dal::factoryDO('acls_channel');
$doAcls->channelid = $channelId;
$doAcls->type = 'Client:Ip';
$doAcls->comparison = '==';
$doAcls->data = '127.0.0.1';
$doAcls->executionorder = 1;
$doAcls->insert();
$doAcls = OA_Dal::factoryDO('acls_channel');
$doAcls->channelid = $channelId;
$doAcls->type = 'Client:Domain';
$doAcls->comparison = '==';
$doAcls->data = 'example.com';
$doAcls->executionorder = 2;
$doAcls->insert();
// duplicate
$newChannelId = OA_Dal::staticDuplicate('channel', $channelId);
// retrieve original and duplicate channel
$doChannel = OA_Dal::staticGetDO('channel', $channelId);
$doNewChannel = OA_Dal::staticGetDO('channel', $newChannelId);
// assert they are not equal including primary keys - name column should not match
$this->assertNotEqualDataObjects($this->stripKeys($doChannel), $this->stripKeys($doNewChannel));
// assert they are equal excluding primary keys
$doChannel->name = $doNewChannel->name = null;
$this->assertEqualDataObjects($this->stripKeys($doChannel), $this->stripKeys($doNewChannel));
// retrieve acls for original and duplicate channel
$doAcls = OA_Dal::factoryDO('acls_channel');
$doAcls->channelid = $channelId;
$doAcls->orderBy('executionorder');
if ($doAcls->find()) {
while ($doAcls->fetch()) {
$aAcls[] = clone $doAcls;
}
}
$doNewAcls = OA_Dal::factoryDO('acls_channel');
$doNewAcls->channelid = $newChannelId;
$doNewAcls->orderBy('executionorder');
if ($doNewAcls->find()) {
while ($doNewAcls->fetch()) {
$aNewAcls[] = clone $doNewAcls;
}
}
// iterate through acls ensuring they were properly copied
if ($this->assertEqual(count($aAcls), count($aNewAcls))) {
for ($x = 0; $x < count($aAcls); $x++) {
$this->assertNotEqual($aAcls[$x]->channelid, $aNewAcls[$x]->channelid);
$this->assertEqualDataObjects($this->stripKeys($aAcls[$x]), $this->stripKeys($aNewAcls[$x]));
}
}
}
示例2: duplicate
function duplicate($channelId)
{
// Populate $this with channel data
$this->get($channelId);
// Prepare a new name for the channel
$this->name = $GLOBALS['strCopyOf'] . ' ' . $this->name;
// Duplicate channel
$this->channelid = null;
$newChannelId = $this->insert();
// Duplicate channel's acls
$result = OA_Dal::staticDuplicate('acls_channel', $channelId, $newChannelId);
return $newChannelId;
}
示例3: array
OA_Permission::enforceAccessToObject('channel', $channelid);
$affiliateid = (int) $affiliateid;
$channelid = (int) $channelid;
if (empty($returnurl)) {
$returnurl = 'channel-edit.php';
}
// Security check
if (isset($channelid) && $channelid != '') {
if (isset($duplicate) && $duplicate == 'true') {
//get channel old channel name
$doChannel = OA_Dal::factoryDO('channel');
if ($doChannel->get($channelid)) {
$oldName = $doChannel->name;
}
// Duplicate the channel
$newChannelId = OA_Dal::staticDuplicate('channel', $channelid);
//get new name
$doChannel = OA_Dal::factoryDO('channel');
if ($doChannel->get($newChannelId)) {
$newName = $doChannel->name;
}
// Queue confirmation message
$translation = new OX_Translation();
$oldChannelParams = !$affiliateid ? "channelid={$channelid}" : "affiliateid={$affiliateid}&channelid={$channelid}";
$newChannelParams = !$affiliateid ? "?channelid={$newChannelId}" : "?affiliateid={$affiliateid}&channelid={$newChannelId}";
$translated_message = $translation->translate($GLOBALS['strChannelHasBeenDuplicated'], array(MAX::constructURL(MAX_URL_ADMIN, "channel-edit.php?" . $oldChannelParams), htmlspecialchars($oldName), MAX::constructURL(MAX_URL_ADMIN, "channel-edit.php?" . $newChannelParams), htmlspecialchars($newName)));
OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0);
Header("Location: " . $returnurl . $newChannelParams);
exit;
}
}