Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions admin_console/controllers/WidgetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
class WidgetController extends Zend_Controller_Action
{
const HTML5_URL = 'html5_url';
const UI_CONF_STATUS_DELETED = 3;
public function listAction()
{
$request = $this->getRequest();
Expand Down Expand Up @@ -187,11 +188,24 @@ public function duplicateAction()
$id = $request->getParam('id');
$client = Infra_ClientHelper::getClient();
$adminConsolePlugin = Kaltura_Client_AdminConsole_Plugin::get($client);

$uiConf = $adminConsolePlugin->uiConfAdmin->get($id);
$uiConf->id = null;
$uiConf = $adminConsolePlugin->uiConfAdmin->add($uiConf);


echo $this->_helper->json('ok', false);
}

public function restoreAction()
{
$this->_helper->viewRenderer->setNoRender();
$request = $this->getRequest();
$id = $request->getParam('id');
$client = Infra_ClientHelper::getClient();
$adminConsolePlugin = Kaltura_Client_AdminConsole_Plugin::get($client);

$adminConsolePlugin->uiConfAdmin->restore($id);

echo $this->_helper->json('ok', false);
}

Expand Down
54 changes: 41 additions & 13 deletions admin_console/views/scripts/widget/list.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,21 @@
<td>
<select class="options" onchange="doAction(this.value, <?php echo $uiConf->id; ?>)">
<option value=""><?php echo $this->translate('Select Action'); ?></option>
<?php if (Infra_AclHelper::isAllowed('widget','edit')): ?>
<option value="editForm" ><?php echo $this->translate('Edit'); ?></option>
<option value="externalEditForm" ><?php echo $this->translate('External Edit'); ?></option>
<?php endif; ?>
<?php if (Infra_AclHelper::isAllowed('widget','delete')): ?>
<option value="deleteWidget" ><?php echo $this->translate('Delete'); ?></option>
<?php endif; ?>
<?php if (Infra_AclHelper::isAllowed('widget','duplicate')): ?>
<option value="duplicateWidget" ><?php echo $this->translate('Duplicate'); ?></option>
<?php if ($uiConf->status == WidgetController::UI_CONF_STATUS_DELETED): ?>
<?php if (Infra_AclHelper::isAllowed('widget','restore')): ?>
<option value="restoreWidget" ><?php echo $this->translate('Restore'); ?></option>
<?php endif; ?>
<?php else: ?>
<?php if (Infra_AclHelper::isAllowed('widget','edit')): ?>
<option value="editForm" ><?php echo $this->translate('Edit'); ?></option>
<option value="externalEditForm" ><?php echo $this->translate('External Edit'); ?></option>
<?php endif; ?>
<?php if (Infra_AclHelper::isAllowed('widget','delete')): ?>
<option value="deleteWidget" ><?php echo $this->translate('Delete'); ?></option>
<?php endif; ?>
<?php if (Infra_AclHelper::isAllowed('widget','duplicate')): ?>
<option value="duplicateWidget" ><?php echo $this->translate('Duplicate'); ?></option>
<?php endif; ?>
<?php endif; ?>
</select>
</td>
Expand All @@ -75,12 +81,12 @@ jQuery('#filter_type').change(function()
if(this.value == "by-uiconf-type")
{
$("#filter_text").css("display","none");
$("#filter_obj_type_input").css("display","inline");
}
$("#filter_obj_type_input").css("display","inline");
}
else
{
{
$("#filter_text").css("display","inline");
$("#filter_obj_type_input").css("display","none");
$("#filter_obj_type_input").css("display","none");
}
});

Expand Down Expand Up @@ -191,6 +197,28 @@ function deleteWidget(id) {
}
}

function restoreWidget(id) {
var ok = confirm('<?php echo $this->translate('are you sure restore uiconf?'); ?>');

if (ok) {
var url = '<?php echo $this->url(array('controller' => 'widget', 'action' => 'restore', 'id' => '')); ?>' + id;

jQuery.ajax({
url: url,
dataType: 'json',
success: function(result) {
if (result != 'ok')
return this.error();
alert('<?php echo $this->translate('uiconf was restored');?>');
jQuery('#frmPaginator1').submit();
},
error: function() {
alert('<?php echo $this->translate('uiconf was not restored');?>');
}
});
}
}

function duplicateWidget(id) {
var url = '<?php echo $this->url(array('controller' => 'widget', 'action' => 'duplicate', 'id' => '')); ?>' + id;

Expand Down
17 changes: 13 additions & 4 deletions deployment/permissions/service.adminconsole.uiconfadmin.ini
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,18 @@ permissionItem4.permissions = SYSTEM_ADMIN_WIDGET
permissionItem5.service = adminconsole_uiconfadmin
permissionItem5.action = delete
permissionItem5.partnerId = -2
permissionItem5.param3 =
permissionItem5.param4 =
permissionItem5.param5 =
permissionItem5.tags =
permissionItem5.param3 =
permissionItem5.param4 =
permissionItem5.param5 =
permissionItem5.tags =
permissionItem5.permissions = SYSTEM_ADMIN_WIDGET

permissionItem6.service = adminconsole_uiconfadmin
permissionItem6.action = restore
permissionItem6.partnerId = -2
permissionItem6.param3 =
permissionItem6.param4 =
permissionItem6.param5 =
permissionItem6.tags =
permissionItem6.permissions = SYSTEM_ADMIN_WIDGET

14 changes: 11 additions & 3 deletions plugins/admin_console/lib/api/KalturaUiConfAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ class KalturaUiConfAdmin extends KalturaUiConf
* @var bool
*/
public $isPublic;


/**
* @var int
* @readonly
*/
public $status;

public function doFromObject($source_object, KalturaDetachedResponseProfile $responseProfile = null)
{
if ($source_object instanceof uiConf)
Expand All @@ -18,8 +24,10 @@ public function doFromObject($source_object, KalturaDetachedResponseProfile $res
$this->isPublic = true;
else
$this->isPublic = false;

$this->status = $source_object->getStatus();
}

return parent::doFromObject($source_object, $responseProfile);
}

Expand All @@ -34,4 +42,4 @@ public function toObject($object_to_fill = null, $props_to_skip = array())
}
return parent::toObject($object_to_fill, $props_to_skip);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@
class KalturaAdminConsoleErrors extends KalturaErrors
{
const ENTRY_ASSETS_WRONG_STATUS_FOR_RESTORE = "ENTRY_ASSETS_WRONG_STATUS_FOR_RESTORE;ENTRY_ID; Entry [@ENTRY_ID@] or one of its assets are not in status \"DELETED\"";
const UI_CONF_NOT_IN_DELETED_STATUS = "UI_CONF_NOT_IN_DELETED_STATUS;UI_CONF_ID;UIConf [@UI_CONF_ID@] is not in deleted status and cannot be restored";
const UI_CONF_FILE_SYNC_MISSING = "UI_CONF_FILE_SYNC_MISSING;UI_CONF_ID,FILE;UIConf [@UI_CONF_ID@] file sync \"@FILE@\" was not found on disk and cannot be restored";
}
105 changes: 93 additions & 12 deletions plugins/admin_console/services/UiConfAdminService.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,37 +116,118 @@ function deleteAction($id)
}

/**
* Retrieve a list of available UIConfs with no partner limitation
*
* Restore a deleted UIConf and its file syncs
*
* @action restore
* @param int $id
* @return KalturaUiConfAdmin
*
* @throws APIErrors::INVALID_UI_CONF_ID
*/
function restoreAction($id)
{
uiConfPeer::setUseCriteriaFilter(false);
$dbUiConf = uiConfPeer::retrieveByPK($id);
uiConfPeer::setUseCriteriaFilter(true);

if (!$dbUiConf)
throw new KalturaAPIException(APIErrors::INVALID_UI_CONF_ID, $id);

if ($dbUiConf->getPartnerId() == PartnerPeer::GLOBAL_PARTNER && !kPermissionManager::isPermitted(self::PERMISSION_GLOBAL_PARTNER_UI_CONF_UPDTAE))
throw new KalturaAPIException(APIErrors::INVALID_UI_CONF_ID, $id);

if ($dbUiConf->getStatus() != uiConf::UI_CONF_STATUS_DELETED)
throw new KalturaAPIException(KalturaAdminConsoleErrors::UI_CONF_NOT_IN_DELETED_STATUS, $id);

$fileSyncSubTypes = array(
uiConf::FILE_SYNC_UICONF_SUB_TYPE_DATA,
uiConf::FILE_SYNC_UICONF_SUB_TYPE_CONFIG,
uiConf::FILE_SYNC_UICONF_SUB_TYPE_FEATURES,
);

$fileSyncs = array();
FileSyncPeer::setUseCriteriaFilter(false);
foreach ($fileSyncSubTypes as $subType)
{
$fileSync = kFileSyncUtils::getLocalFileSyncForKey($dbUiConf->getSyncKey($subType), false);
if ($fileSync)
$fileSyncs[] = $fileSync;
}
FileSyncPeer::setUseCriteriaFilter(true);

if (empty($fileSyncs))
throw new KalturaAPIException(KalturaAdminConsoleErrors::UI_CONF_FILE_SYNC_MISSING, $id, '');

foreach ($fileSyncs as $fileSync)
{
if (!file_exists($fileSync->getFullPath()))
throw new KalturaAPIException(KalturaAdminConsoleErrors::UI_CONF_FILE_SYNC_MISSING, $id, $fileSync->getFullPath());
}

foreach ($fileSyncs as $fileSync)
{
if (method_exists($fileSync, 'setDeletedId'))
$fileSync->setDeletedId(0);
$fileSync->setStatus(FileSync::FILE_SYNC_STATUS_READY);
$fileSync->save();
}

$dbUiConf->setStatus(uiConf::UI_CONF_STATUS_READY);
$dbUiConf->save();

$uiConf = new KalturaUiConfAdmin();
$uiConf->fromObject($dbUiConf, $this->getResponseProfile());

return $uiConf;
}

/**
* Retrieve a list of available UIConfs with no partner limitation.
* If the request comes from an admin console client, deleted UIConfs are included as well.
*
* @action list
* @param KalturaUiConfFilter $filter
* @param KalturaFilterPager $pager
* @return KalturaUiConfAdminListResponse
*/
function listAction( KalturaUiConfFilter $filter = null , KalturaFilterPager $pager = null)
*/
function listAction(KalturaUiConfFilter $filter = null, KalturaFilterPager $pager = null)
{
$clientTag = kCurrentContext::$client_lang ? strtolower(kCurrentContext::$client_lang) : '';
$includeDeleted = ($clientTag === 'kaltura-admin');
return $this->doList($filter, $pager, $includeDeleted);
}

private function doList(KalturaUiConfFilter $filter = null, KalturaFilterPager $pager = null, $includeDeleted = false)
{
myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL2;

if (!$filter)
$filter = new KalturaUiConfFilter();

$uiConfFilter = new uiConfFilter();
$filter->toObject($uiConfFilter);

$c = new Criteria();
$uiConfFilter->attachToCriteria($c);

if ($includeDeleted)
uiConfPeer::setUseCriteriaFilter(false);

$count = uiConfPeer::doCount($c);
if (! $pager)
$pager = new KalturaFilterPager ();
if (!$pager)
$pager = new KalturaFilterPager();
$pager->attachToCriteria($c);
$list = uiConfPeer::doSelect($c);


if ($includeDeleted)
uiConfPeer::setUseCriteriaFilter(true);

$newList = KalturaUiConfAdminArray::fromDbArray($list, $this->getResponseProfile());

$response = new KalturaUiConfAdminListResponse();
$response->objects = $newList;
$response->totalCount = $count;

return $response;
}
}
6 changes: 6 additions & 0 deletions release-notes.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# West-23.5.0
## Add permissions for uiConfAdmin restore
- Issue Type: Task
- Issue ID: SUP-52187
### Deployment Scripts ###
php deployment/updates/scripts/add_permissions/2026_08_03_adminconsole_uiconfadmin_restore_permission.php
## Add DRM Key Management Policy service and permissions ##
## Add Learner Intelligence partner and permissions
- Issue Type: Task
- Issue ID: PLAT-26018
Expand Down
Loading