index 0c4738b4b8efbb951e75b62bcaf549bd27af5f8e..1d6a1f04ac07b87f3308f9074ec63a0eea69e489 100644 (file)
/* Create CP handler */
/* Create CP handler */
- function CopyPasteHandler($config)
+ function CopyPasteHandler(&$config)
{
{
- $this->config = $config;
+ $this->config = &$config;
$this->current= NULL;
$this->queue = array();
$this->setvar_array = array();
$this->current= NULL;
$this->queue = array();
$this->setvar_array = array();
* array['tab_class'] - Tab object that should be used to initialize the new object
* array['tab_object'] - Tab object name used to initialize correct object Type like USERTABS
*/
* array['tab_class'] - Tab object that should be used to initialize the new object
* array['tab_object'] - Tab object name used to initialize correct object Type like USERTABS
*/
- function add_to_queue($dn,$action,$tab_class,$tab_object)
+ function add_to_queue($dn,$action,$tab_class,$tab_object,$tab_acl_category)
{
if(!class_exists($tab_class)){
trigger_error(sprintf("Specified class object '%s' does not exists.",$tab_class));
{
if(!class_exists($tab_class)){
trigger_error(sprintf("Specified class object '%s' does not exists.",$tab_class));
$tmp['dn'] = $dn;
$tmp['tab_class'] = $tab_class;
$tmp['tab_object']= $tab_object;
$tmp['dn'] = $dn;
$tmp['tab_class'] = $tab_class;
$tmp['tab_object']= $tab_object;
+ $tmp['tab_acl_category']= $tab_acl_category;
$this->queue[] = $tmp;
}
}
$this->queue[] = $tmp;
}
}
unset($this->queue[$key]);
}
unset($this->queue[$key]);
}
+ /* Create patch if it doesn't exists */
+ if(!is_dir(LDAP_DUMP_PATH)){
+ @mkdir(LDAP_DUMP_PATH);
+ }
+
+ /* check if we are able to create a new file the given directory */
+ if(!is_writeable(LDAP_DUMP_PATH)){
+ print_red(sprintf(_("Could not cleanup copy & paste queue. We are not allowed to save ldap dump to '%s', please check permissions."),LDAP_DUMP_PATH));
+ new log("copy","all/all","copy & paste, event queue.",array(),
+ sprintf("Could not cleanup copy & paste queue. We are not allowed to save ldap dump to '%s', please check permissions.",LDAP_DUMP_PATH));
+ return(FALSE);
+ }
+
/* Remove entries from hdd that are older than24 hours */
$fp = opendir(LDAP_DUMP_PATH);
while($file = readdir($fp)){
/* Remove entries from hdd that are older than24 hours */
$fp = opendir(LDAP_DUMP_PATH);
while($file = readdir($fp)){
$entry = $this->queue[$key];
$tab_c = $entry['tab_class'];
$tab_o = $entry['tab_object'];
$entry = $this->queue[$key];
$tab_c = $entry['tab_class'];
$tab_o = $entry['tab_object'];
+ $tab_a = $entry['tab_acl_category'];
if($entry['method'] == "copy"){
if($entry['method'] == "copy"){
- $entry['object'] = new $tab_c($this->config,$this->config->data['TABS'][$tab_o],"new");
+ $entry['object'] = new $tab_c($this->config,$this->config->data['TABS'][$tab_o],"new",$tab_a);
}else{
}else{
- $entry['object'] = new $tab_c($this->config,$this->config->data['TABS'][$tab_o],$entry['dn'],"users");
+ $entry['object'] = new $tab_c($this->config,$this->config->data['TABS'][$tab_o],$entry['dn'],$tab_a);
}
$entry['source_data'] = $this->load_attributes_from_hdd($entry['file_name']);
}
$entry['source_data'] = $this->load_attributes_from_hdd($entry['file_name']);
Create unique names, ids, or what ever */
function execute()
{
Create unique names, ids, or what ever */
function execute()
{
+ $ui = get_userinfo();
$type = $this->current['method'];
if($type == "cut"){
if(isset($_POST['PerformCopyPaste'])){
$type = $this->current['method'];
if($type == "cut"){
if(isset($_POST['PerformCopyPaste'])){
$this->_update_vars();
$msgs = $this->check();
$this->_update_vars();
$msgs = $this->check();
- if(count ($msgs) ){
+ $acl = $ui->get_category_permissions($this->current['dn'], $this->current['tab_acl_category']);
+
+ /* Check permissions */
+ if(!preg_match("/((c|w)|(w|c))/",$acl)){
+ print_red(sprintf(_("You are not allowed to cut and paste the following object '%s'."),$this->current['dn']));
+ }elseif(count ($msgs) ){
foreach( $msgs as $msg){
print_red($msg);
}
foreach( $msgs as $msg){
print_red($msg);
}
if(isset($_POST['PerformCopyPaste'])){
$this->_update_vars();
$msgs = $this->check();
if(isset($_POST['PerformCopyPaste'])){
$this->_update_vars();
$msgs = $this->check();
- if(count ($msgs) ){
+
+ $acl = $ui->get_category_permissions($this->current['dn'], $this->current['tab_acl_category']);
+
+ /* Check permissions */
+ if(!preg_match("/((c|w)|(w|c))/",$acl)){
+ print_red(sprintf(_("You are not allowed to copy and paste the following object '%s'."),$this->current['dn']));
+ }elseif(count ($msgs) ){
foreach( $msgs as $msg){
print_red($msg);
}
foreach( $msgs as $msg){
print_red($msg);
}