Public Member Functions | Static Public Member Functions | Data Fields | Private Member Functions | Private Attributes | Static Private Attributes

ilCopyWizardOptions Class Reference

Collaboration diagram for ilCopyWizardOptions:

Public Member Functions

 saveOwner ($a_user_id)
 Save owner for copy.
 saveRoot ($a_root)
 Save root node id.
 isRootNode ($a_root)
 Is root node.
 disableSOAP ()
 Disable soap calls.
 isSOAPEnabled ()
 Check if SOAP calls are disabled.
 checkOwner ($a_user_id)
 check owner
 getCopyId ()
 Get copy id.
 initContainer ($a_source_id, $a_target_id)
 Init container Add copy entry.
 storeTree ($a_source_id)
 Save tree Stores two copies of the tree structure: id 0 is used for recursive call of cloneObject() id -1 is used for recursive call of cloneDependencies().
 fetchFirstNode ()
 Fetch first node for cloneObject.
 fetchFirstDependenciesNode ()
 Fetch first dependencies node.
 dropFirstNodeById ($a_id)
 Drop first node by id.
 dropFirstNode ()
 Drop first node (for cloneObject()).
 dropFirstDependenciesNode ()
 Drop first node (for cloneDependencies()).
 getOptions ($a_source_id)
 Get entry by source.
 addEntry ($a_source_id, $a_options)
 Add new entry.
 appendMapping ($a_source_id, $a_target_id)
 Add mapping of source -> target.
 getMappings ()
 Get Mappings.
 deleteAll ()
 Delete all entries.
 read ()
 public

Static Public Member Functions

static _getInstance ($a_copy_id)
 Get instance of copy wizard options.
static _isFinished ($a_copy_id)
 check if copy is finished
static _allocateCopyId ()
 Allocate a copy for further entries.

Data Fields

const COPY_WIZARD_OMIT = 1
const COPY_WIZARD_COPY = 2
const COPY_WIZARD_LINK = 3
const OWNER_KEY = -3
const DISABLE_SOAP = -4
const ROOT_NODE = -5

Private Member Functions

 __construct ($a_copy_id=0)
 Private Constructor (Singleton class).
 fetchFirstNodeById ($a_id)
 Get first node of stored tree.
 readTree ($a_source_id)
 Purge ommitted node recursively.

Private Attributes

 $db
 $copy_id
 $source_id
 $options = array()

Static Private Attributes

static $instances = null

Detailed Description

Definition at line 32 of file class.ilCopyWizardOptions.php.


Constructor & Destructor Documentation

ilCopyWizardOptions::__construct ( a_copy_id = 0  )  [private]

Private Constructor (Singleton class).

private

Parameters:
int copy_id

Definition at line 57 of file class.ilCopyWizardOptions.php.

References read().

        {
                global $ilDB;
                
                $this->db = $ilDB;
                $this->copy_id = $a_copy_id;
                
                if($this->copy_id)
                {
                        $this->read();
                }       
        }

Here is the call graph for this function:


Member Function Documentation

static ilCopyWizardOptions::_allocateCopyId (  )  [static]

Allocate a copy for further entries.

public

Definition at line 112 of file class.ilCopyWizardOptions.php.

References $res.

Referenced by ilObjectGUI::cloneAllObject(), and ilContainer::cloneAllObject().

        {
                global $ilDB;
                
                $query = "SELECT MAX(copy_id) as latest FROM copy_wizard_options ";
                $res = $ilDB->query($query);
                $row = $res->fetchRow(DB_FETCHMODE_OBJECT);
                
                $query = "INSERT INTO copy_wizard_options ".
                        "SET copy_id = ".$ilDB->quote($row->latest + 1);
                $ilDB->query($query);
                
                return $row->latest + 1;
        }

Here is the caller graph for this function:

static ilCopyWizardOptions::_getInstance ( a_copy_id  )  [static]

Get instance of copy wizard options.

public

Parameters:
int copy id

Definition at line 78 of file class.ilCopyWizardOptions.php.

Referenced by ilObjectGUI::cloneAllObject(), ilContainer::cloneAllObject(), ilLPCollections::cloneCollections(), ilCourseStart::cloneDependencies(), ilCourseObjectiveQuestion::cloneDependencies(), ilCourseObjectiveMaterials::cloneDependencies(), ilCourseItems::cloneDependencies(), ilEventItems::cloneItems(), ilObjTest::cloneObject(), ilObjForum::cloneObject(), ilSoapUtils::ilClone(), ilSoapUtils::ilCloneDependencies(), and ilObject::prependCopyInfo().

        {
                if(is_array(self::$instances) and isset(self::$instances[$a_copy_id]))
                {
                        return self::$instances[$a_copy_id];
                }
                return self::$instances[$a_copy_id] = new ilCopyWizardOptions($a_copy_id);
        }

Here is the caller graph for this function:

static ilCopyWizardOptions::_isFinished ( a_copy_id  )  [static]

check if copy is finished

public

Parameters:
int copy id

Definition at line 95 of file class.ilCopyWizardOptions.php.

References $res.

Referenced by ilContainer::cloneAllObject().

        {
                global $ilDB;
                
                $query = "SELECT * FROM copy_wizard_options ".
                        " WHERE copy_id  = ".$ilDB->quote($a_copy_id)." ";
                $res = $ilDB->query($query);
                return $res->numRows() ? false : true;
        }

Here is the caller graph for this function:

ilCopyWizardOptions::addEntry ( a_source_id,
a_options 
)

Add new entry.

public

Parameters:
int ref_id of source
array array of options

Definition at line 408 of file class.ilCopyWizardOptions.php.

References $res.

Referenced by initContainer().

        {
                if(!is_array($a_options))
                {
                        return false;
                }
                
                $query = "DELETE FROM copy_wizard_options ".
                        "WHERE copy_id = ".$this->db->quote($this->copy_id)." ".
                        "AND source_id = ".$this->db->quote($a_source_id);
                $this->db->query($query);

                $query  = "INSERT INTO copy_wizard_options ".
                        "SET copy_id = ".$this->db->quote($this->copy_id).", ".
                        "source_id = ".$this->db->quote($a_source_id).", ".
                        "options = ".$this->db->quote(serialize($a_options))." ";
                $res = $this->db->query($query);
                return true;
        }

Here is the caller graph for this function:

ilCopyWizardOptions::appendMapping ( a_source_id,
a_target_id 
)

Add mapping of source -> target.

public

Parameters:
int source ref_id
int target ref_id

Definition at line 436 of file class.ilCopyWizardOptions.php.

References $res.

Referenced by initContainer().

        {
                $query = "SELECT * FROM copy_wizard_options ".
                        "WHERE copy_id = ".$this->db->quote($this->copy_id)." ".
                        "AND source_id = -2 ";
                $res = $this->db->query($query);
                $mappings = array();
                while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        $mappings = unserialize($row->options);
                }
                $mappings[$a_source_id] = $a_target_id;
                
                $query = "REPLACE INTO copy_wizard_options ".
                        "SET copy_id = ".$this->db->quote($this->copy_id).", ".
                        "source_id = -2, ".
                        "options = ".$this->db->quote(serialize($mappings))."";
                $this->db->query($query);
                return true;                            
        }

Here is the caller graph for this function:

ilCopyWizardOptions::checkOwner ( a_user_id  ) 

check owner

public

Parameters:
int user_id

Definition at line 215 of file class.ilCopyWizardOptions.php.

References getOptions().

        {
                return in_array($a_user_id,$this->getOptions(self::OWNER_KEY));
        }

Here is the call graph for this function:

ilCopyWizardOptions::deleteAll (  ) 

Delete all entries.

public

Definition at line 478 of file class.ilCopyWizardOptions.php.

        {
                $query = "DELETE FROM copy_wizard_options ".
                        "WHERE copy_id = ".$this->db->quote($this->copy_id);
                $this->db->query($query);
        }

ilCopyWizardOptions::disableSOAP (  ) 

Disable soap calls.

Recursive call of ilClone and ilCloneDependencies

public

Parameters:
 

Definition at line 181 of file class.ilCopyWizardOptions.php.

References getCopyId().

        {
                $this->options[self::DISABLE_SOAP] = 1;         
                $query = "INSERT INTO copy_wizard_options ".
                        "SET copy_id = ".$this->db->quote($this->getCopyId()).", ".
                        "source_id = ".$this->db->quote(self::DISABLE_SOAP).", ".
                        "options = ".$this->db->quote(serialize(array(1)))."";
                $this->db->query($query);
        }

Here is the call graph for this function:

ilCopyWizardOptions::dropFirstDependenciesNode (  ) 

Drop first node (for cloneDependencies()).

public

Definition at line 379 of file class.ilCopyWizardOptions.php.

References dropFirstNodeById().

        {
                return $this->dropFirstNodeById(-1);
        }

Here is the call graph for this function:

ilCopyWizardOptions::dropFirstNode (  ) 

Drop first node (for cloneObject()).

public

Definition at line 368 of file class.ilCopyWizardOptions.php.

References dropFirstNodeById().

        {
                return $this->dropFirstNodeById(0);
        }

Here is the call graph for this function:

ilCopyWizardOptions::dropFirstNodeById ( a_id  ) 

Drop first node by id.

private

Definition at line 335 of file class.ilCopyWizardOptions.php.

References fetchFirstNodeById(), and read().

Referenced by dropFirstDependenciesNode(), and dropFirstNode().

        {
                if(!isset($this->options[$a_id]) or !is_array($this->options[$a_id]))
                {
                        return false;
                }
                
                $this->options[$a_id] = array_slice($this->options[$a_id],1);
                $query = "UPDATE copy_wizard_options ".
                        "SET options = ".$this->db->quote(serialize($this->options[$a_id]))." ".
                        "WHERE copy_id = ".$this->db->quote($this->copy_id)." ".
                        "AND source_id = ".$this->db->quote($a_id)." ";
                        ;
                $this->db->query($query);
                $this->read();
                // check for role_folder
                if(($node = $this->fetchFirstNodeById($a_id)) === false)
                {
                        return true;
                }
                if($node['type'] == 'rolf')
                {
                        $this->dropFirstNodeById($a_id);
                }
                return true;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilCopyWizardOptions::fetchFirstDependenciesNode (  ) 

Fetch first dependencies node.

public

Definition at line 324 of file class.ilCopyWizardOptions.php.

References fetchFirstNodeById().

        {
                return $this->fetchFirstNodeById(-1);
        }

Here is the call graph for this function:

ilCopyWizardOptions::fetchFirstNode (  ) 

Fetch first node for cloneObject.

public

Parameters:
 

Definition at line 313 of file class.ilCopyWizardOptions.php.

References fetchFirstNodeById().

        {
                return $this->fetchFirstNodeById(0);
        }

Here is the call graph for this function:

ilCopyWizardOptions::fetchFirstNodeById ( a_id  )  [private]

Get first node of stored tree.

private

Definition at line 296 of file class.ilCopyWizardOptions.php.

References getOptions().

Referenced by dropFirstNodeById(), fetchFirstDependenciesNode(), and fetchFirstNode().

        {
                $tree = $this->getOptions($a_id);
                if(isset($tree[0]) and is_array($tree[0]))
                {
                        return $tree[0];
                }
                return false;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilCopyWizardOptions::getCopyId (  ) 

Get copy id.

public

Definition at line 226 of file class.ilCopyWizardOptions.php.

Referenced by disableSOAP(), saveOwner(), and saveRoot().

        {
                return $this->copy_id;
        }

Here is the caller graph for this function:

ilCopyWizardOptions::getMappings (  ) 

Get Mappings.

public

Definition at line 463 of file class.ilCopyWizardOptions.php.

        {
                if(isset($this->options[-2]) and is_array($this->options[-2]))
                {
                        return $this->options[-2];
                }
                return array();
        }

ilCopyWizardOptions::getOptions ( a_source_id  ) 

Get entry by source.

public

Parameters:
int source ref_id

Definition at line 391 of file class.ilCopyWizardOptions.php.

Referenced by checkOwner(), fetchFirstNodeById(), and isRootNode().

        {
                if(isset($this->options[$a_source_id]) and is_array($this->options[$a_source_id]))
                {
                        return $this->options[$a_source_id];
                }
                return array();
        }

Here is the caller graph for this function:

ilCopyWizardOptions::initContainer ( a_source_id,
a_target_id 
)

Init container Add copy entry.

public

Parameters:
 

Definition at line 240 of file class.ilCopyWizardOptions.php.

References addEntry(), appendMapping(), and COPY_WIZARD_COPY.

        {
                global $tree;
                
                $mapping_source = $tree->getParentId($a_source_id);
                $this->addEntry($a_source_id,array('type' => ilCopyWizardOptions::COPY_WIZARD_COPY));
                $this->appendMapping($mapping_source,$a_target_id);
        }

Here is the call graph for this function:

ilCopyWizardOptions::isRootNode ( a_root  ) 

Is root node.

public

Parameters:
int ref_id of copy

Definition at line 169 of file class.ilCopyWizardOptions.php.

References getOptions().

         {
                return in_array($a_root,$this->getOptions(self::ROOT_NODE));
         }

Here is the call graph for this function:

ilCopyWizardOptions::isSOAPEnabled (  ) 

Check if SOAP calls are disabled.

public

Definition at line 197 of file class.ilCopyWizardOptions.php.

        {
                if(isset($this->options[self::DISABLE_SOAP]) and $this->options[self::DISABLE_SOAP])
                {
                        return false;
                }
                return true;
        }

ilCopyWizardOptions::read (  ) 

public

Parameters:
 

Definition at line 492 of file class.ilCopyWizardOptions.php.

References $res.

Referenced by __construct(), and dropFirstNodeById().

        {
                $query = "SELECT * FROM copy_wizard_options ".
                        "WHERE copy_id = ".$this->db->quote($this->copy_id);
                $res = $this->db->query($query);
                
                $this->options = array();
                while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        $this->options[$row->source_id] = unserialize($row->options);
                }

                return true;
        }

Here is the caller graph for this function:

ilCopyWizardOptions::readTree ( a_source_id  )  [private]

Purge ommitted node recursively.

private

Parameters:
array current node

Definition at line 514 of file class.ilCopyWizardOptions.php.

References $options.

Referenced by storeTree().

        {
                global $tree;
                
                $this->tmp_tree[] = $tree->getNodeData($a_source_id);
                
                
                foreach($tree->getChilds($a_source_id) as $sub_nodes)
                {
                        $sub_node_ref_id = $sub_nodes['child'];
                        // check ommited, linked ...
                        $options = $this->options[$sub_node_ref_id];
                        if($options['type'] == self::COPY_WIZARD_COPY or
                                $options['type'] == self::COPY_WIZARD_LINK)
                        {
                                $this->readTree($sub_node_ref_id);
                        }
                }
        }

Here is the caller graph for this function:

ilCopyWizardOptions::saveOwner ( a_user_id  ) 

Save owner for copy.

It will be checked against this user id in all soap calls

public

Parameters:
 

Definition at line 134 of file class.ilCopyWizardOptions.php.

References getCopyId().

        {
                $query = "INSERT INTO copy_wizard_options ".
                        "SET copy_id = ".$this->db->quote($this->getCopyId()).", ".
                        "source_id = ".$this->db->quote(self::OWNER_KEY).", ".
                        "options = ".$this->db->quote(serialize(array($a_user_id)))."";
                $this->db->query($query);
                return true;
        }

Here is the call graph for this function:

ilCopyWizardOptions::saveRoot ( a_root  ) 

Save root node id.

public

Parameters:
int ref_id of copy source

Definition at line 151 of file class.ilCopyWizardOptions.php.

References getCopyId().

        {
                $query = "INSERT INTO copy_wizard_options ".
                        "SET copy_id = ".$this->db->quote($this->getCopyId()).", ".
                        "source_id = ".$this->db->quote(self::ROOT_NODE).", ".
                        "options = ".$this->db->quote(serialize(array($a_root)))."";
                $this->db->query($query);
                return true;
                
        }

Here is the call graph for this function:

ilCopyWizardOptions::storeTree ( a_source_id  ) 

Save tree Stores two copies of the tree structure: id 0 is used for recursive call of cloneObject() id -1 is used for recursive call of cloneDependencies().

public

Parameters:
int source id

Definition at line 259 of file class.ilCopyWizardOptions.php.

References $res, and readTree().

        {
                // Fix for 3.9
                $query = "DESCRIBE copy_wizard_options";
                $res = $this->db->query($query);
                while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        if($row->Field == 'options' and $row->Type == 'text')
                        {
                                $query = 'ALTER TABLE `copy_wizard_options` CHANGE `options` `options` LONGTEXT NOT NULL';
                                $this->db->query($query);
                        }
                }
                
                $this->readTree($a_source_id);
                $a_tree_structure = $this->tmp_tree;
                
                $query = "UPDATE copy_wizard_options ".
                        "SET options = ".$this->db->quote(serialize($a_tree_structure))." ".
                        "WHERE copy_id = ".$this->db->quote($this->copy_id)." ".
                        "AND source_id = 0 ";
                $res = $this->db->query($query);

                $query = "INSERT INTO copy_wizard_options ".
                        "SET options = ".$this->db->quote(serialize($a_tree_structure)).", ".
                        "copy_id = ".$this->db->quote($this->copy_id).", ".
                        "source_id = -1 ";
                $res = $this->db->query($query);
                return true; 
        }

Here is the call graph for this function:


Field Documentation

ilCopyWizardOptions::$copy_id [private]

Definition at line 46 of file class.ilCopyWizardOptions.php.

ilCopyWizardOptions::$db [private]

Definition at line 44 of file class.ilCopyWizardOptions.php.

ilCopyWizardOptions::$instances = null [static, private]

Definition at line 34 of file class.ilCopyWizardOptions.php.

ilCopyWizardOptions::$options = array() [private]

Definition at line 48 of file class.ilCopyWizardOptions.php.

Referenced by readTree().

ilCopyWizardOptions::$source_id [private]

Definition at line 47 of file class.ilCopyWizardOptions.php.

Definition at line 41 of file class.ilCopyWizardOptions.php.

Definition at line 40 of file class.ilCopyWizardOptions.php.

Definition at line 42 of file class.ilCopyWizardOptions.php.


The documentation for this class was generated from the following file: