Commit b62b54f1 authored by Côme Bernigaud's avatar Côme Bernigaud Committed by Benoit Mortier
Browse files

Automatically setting unicity on main attr

Also using objectTypes for copyPaste handling
parent 487f2b2e
......@@ -128,6 +128,11 @@ class Attribute
}
}
function getUnique ()
{
return $this->unique;
}
function isInLdap ()
{
return $this->inLdap;
......
......@@ -555,28 +555,53 @@ class simpleManagement extends management
* @param Array 'target' A list of object dns, which should be affected by this method.
* @param Array 'all' A combination of both 'action' and 'target'.
*/
function copyPasteHandler($action = '', $target = array(), $all = array(),
$altTabClass = '', $altTabType = '', $altAclCategory = '', $altAclPlugin = '')
function copyPasteHandler($action = "", $target = array(), $all = array(),
$altTabClass = "", $altTabType = "", $altAclCategory = "", $altAclPlugin = "")
{
$tInfo = $this->config->data['OBJECTS'];
// Return without any actions while copy&paste handler is disabled.
if (!is_object($this->cpHandler)) {
return FALSE;
}
$tabClass = array();
$tabType = array();
$aclCategory = array();
$aclPlugin = array();
// Save user input
$this->cpHandler->save_object();
$headpage = $this->getHeadpage();
// Add entries to queue
if ($action == "copy" || $action == "cut") {
$this->cpHandler->cleanup_queue();
foreach ($target as $dn) {
$type = $this->getType($dn);
$infos = objects::infos($type);
foreach ($target as $dn) {
$type = $this->getType($dn);
if ($action == "copy" && $this->ui->is_copyable($dn, $infos['aclCategory'], $infos['mainTab'])) {
$this->cpHandler->add_to_queue($dn, "copy", $type);
@DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $dn, "Entry copied!");
}
if ($action == "cut" && $this->ui->is_cutable($dn, $infos['aclCategory'], $infos['mainTab'])) {
$this->cpHandler->add_to_queue($dn, "cut", $type);
@DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $dn, "Entry cutted!");
}
}
}
// Initiate pasting
if ($action == "paste") {
$this->cpPastingStarted = TRUE;
}
$tabClass[$dn] = $tInfo[$type]['tabClass'];
$tabType[$dn] = $tInfo[$type]['tabGroup'];
$aclCategory[$dn] = $tInfo[$type]['aclCategory'];
$aclPlugin[$dn] = $tInfo[$type]['mainTab'];
// Display any c&p dialogs, eg. object modifications required before pasting.
if ($this->cpPastingStarted && $this->cpHandler->entries_queued()) {
$data = $this->cpHandler->execute($this->headpage->getBase());
if (!empty($data)) {
return $data;
}
}
return parent::copyPasteHandler($action, $target, $all, $tabClass, $tabType, $aclCategory, $aclPlugin);
// Automatically disable pasting process since there is no entry left to paste.
if (!$this->cpHandler->entries_queued()) {
$this->cpPastingStarted = FALSE;
}
return "";
}
static function filterRowLink()
......
......@@ -60,6 +60,14 @@ class simpleTabs extends tabs
parent::__construct($config_object, $data, $dn, $category, $copied_object);
$infos = $this->objectInfos();
if ($infos) {
$baseobject = $this->getBaseObject();
if (($baseobject instanceof simplePlugin) && $baseobject->attributesAccess[$infos['mainAttr']]->getUnique() === FALSE) {
$baseobject->attributesAccess[$infos['mainAttr']]->setUnique(TRUE);
}
}
if ($this->specialTabs) {
/* Add references/acls/snapshots */
$this->addSpecialTabs();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment