CloneSet72


Previous CloneSetNext CloneSetBack to Main Report
Clone
Mass
Clones in
CloneSet
Parameter
Count
Clone
Similarity
Syntax Category
[Sequence Length]
87201.000statement_sequence[12]
Clone AbstractionParameter Bindings
Clone Instance
(Click to see clone)
Line CountSource Line
Source File
187691
libraries/joomla/access/permission/accesslevel.php
287657
libraries/joomla/access/permission/simplerule.php
Clone Instance
1
Line Count
87
Source Line
691
Source File
libraries/joomla/access/permission/accesslevel.php

                // Map the action to the rule.
                $db->setQuery(
                        'REPLACE INTO `#__access_action_rule_map` (`action_id`, `rule_id`) VALUES'
                        . ' ('
                        .    (int) $this->_action_id
                        .                            ', '
                        .                                 (int) $this->_rule_id
                        .                                                       ')');
                $db->query();
                // Check for a database error.
                if ($db->getErrorNum()) {
                        $this->setError($db->getErrorMsg());
                        return FALSE;
                      }
                // Delete existing usergroup maps to the rule.
                $db->setQuery(
                        'DELETE FROM `#__usergroup_rule_map`'
                        . ' WHERE `rule_id` = '
                        .                     (int) $this->_rule_id);
                $db->query();
                // Check for a database error.
                if ($db->getErrorNum()) {
                        $this->setError($db->getErrorMsg());
                        return FALSE;
                      }

                // Map the usergroups to the rule if any exist.
                if (!empty($this->_user_groups))
                {
                        // Build the values clause for the insert query.
                        $values=  array();
                        foreach ($this->_user_groups as $group)
                        {
                                $values[]=  '('
                                            .   (int) $group
                                            .                ', '
                                            .                     (int) $this->_rule_id
                                            .                                           ')';
                              }
                        // Perform the insert query.
                        $db->setQuery(
                                'INSERT INTO `#__usergroup_rule_map` (`group_id`, `rule_id`) VALUES '
                                . implode(', ', $values));
                        $db->query();
                        // Check for a database error.
                        if ($db->getErrorNum()) {
                                $this->setError($db->getErrorMsg());
                                return FALSE;
                              }
                      }
                // Delete existing user maps to the rule.
                $db->setQuery(
                        'DELETE FROM `#__user_rule_map`'
                        . ' WHERE `rule_id` = '
                        .                     (int) $this->_rule_id);
                $db->query();

                // Check for a database error.
                if ($db->getErrorNum()) {
                        $this->setError($db->getErrorMsg());
                        return FALSE;
                      }

                // Map the users to the rule if any exist.
                if (!empty($this->_users))
                {
                        // Build the values clause for the insert query.
                        $values=  array();
                        foreach ($this->_users as $user)
                        {
                                $values[]=  '('
                                            .   (int) $user
                                            .               ', '
                                            .                    (int) $this->_rule_id
                                            .                                          ')';
                              }
                        // Perform the insert query.
                        $db->setQuery(
                                'INSERT INTO `#__user_rule_map` (`user_id`, `rule_id`) VALUES '
                                . implode(', ', $values));
                        $db->query();
                        // Check for a database error.
                        if ($db->getErrorNum()) {
                                $this->setError($db->getErrorMsg());
                                return FALSE;
                              }
                      }
                return TRUE;


Clone Instance
2
Line Count
87
Source Line
657
Source File
libraries/joomla/access/permission/simplerule.php

                // Map the action to the rule.
                $db->setQuery(
                        'REPLACE INTO `#__access_action_rule_map` (`action_id`, `rule_id`) VALUES'
                        . ' ('
                        .    (int) $this->_action_id
                        .                            ', '
                        .                                 (int) $this->_rule_id
                        .                                                       ')');
                $db->query();
                // Check for a database error.
                if ($db->getErrorNum()) {
                        $this->setError($db->getErrorMsg());
                        return FALSE;
                      }
                // Delete existing usergroup maps to the rule.
                $db->setQuery(
                        'DELETE FROM `#__usergroup_rule_map`'
                        . ' WHERE `rule_id` = '
                        .                     (int) $this->_rule_id);
                $db->query();
                // Check for a database error.
                if ($db->getErrorNum()) {
                        $this->setError($db->getErrorMsg());
                        return FALSE;
                      }

                // Map the usergroups to the rule if any exist.
                if (!empty($this->_user_groups))
                {
                        // Build the values clause for the insert query.
                        $values=  array();
                        foreach ($this->_user_groups as $group)
                        {
                                $values[]=  '('
                                            .   (int) $group
                                            .                ', '
                                            .                     (int) $this->_rule_id
                                            .                                           ')';
                              }
                        // Perform the insert query.
                        $db->setQuery(
                                'INSERT INTO `#__usergroup_rule_map` (`group_id`, `rule_id`) VALUES '
                                . implode(', ', $values));
                        $db->query();
                        // Check for a database error.
                        if ($db->getErrorNum()) {
                                $this->setError($db->getErrorMsg());
                                return FALSE;
                              }
                      }
                // Delete existing user maps to the rule.
                $db->setQuery(
                        'DELETE FROM `#__user_rule_map`'
                        . ' WHERE `rule_id` = '
                        .                     (int) $this->_rule_id);
                $db->query();

                // Check for a database error.
                if ($db->getErrorNum()) {
                        $this->setError($db->getErrorMsg());
                        return FALSE;
                      }

                // Map the users to the rule if any exist.
                if (!empty($this->_users))
                {
                        // Build the values clause for the insert query.
                        $values=  array();
                        foreach ($this->_users as $user)
                        {
                                $values[]=  '('
                                            .   (int) $user
                                            .               ', '
                                            .                    (int) $this->_rule_id
                                            .                                          ')';
                              }
                        // Perform the insert query.
                        $db->setQuery(
                                'INSERT INTO `#__user_rule_map` (`user_id`, `rule_id`) VALUES '
                                . implode(', ', $values));
                        $db->query();
                        // Check for a database error.
                        if ($db->getErrorNum()) {
                                $this->setError($db->getErrorMsg());
                                return FALSE;
                              }
                      }
                return TRUE;


Clone AbstractionParameter Count: 0Parameter Bindings

// Map the action to the rule.
$db->setQuery('REPLACE INTO `#__access_action_rule_map` (`action_id`, `rule_id`) VALUES'
              . ' ('
              . (int) $this->_action_id
              . ', '
              . (int) $this->_rule_id
              . ')');
$db->query();
// Check for a database error.
if ($db->getErrorNum()) {
  $this->setError($db->getErrorMsg());
  return FALSE;
}
// Delete existing usergroup maps to the rule.
$db->setQuery('DELETE FROM `#__usergroup_rule_map`'
              . ' WHERE `rule_id` = '
              . (int) $this->_rule_id);
$db->query();
// Check for a database error.
if ($db->getErrorNum()) {
  $this->setError($db->getErrorMsg());
  return FALSE;
}
// Map the usergroups to the rule if any exist.
if (!empty($this->_user_groups)) {
  // Build the values clause for the insert query.
  $values=array();
  foreach ($this->_user_groups as $group) {
    $values[]='('
              . (int) $group
              . ', '
              . (int) $this->_rule_id
              . ')';
  }
  // Perform the insert query.
  $db->setQuery('INSERT INTO `#__usergroup_rule_map` (`group_id`, `rule_id`) VALUES '
                . implode(', ',$values));
  $db->query();
  // Check for a database error.
  if ($db->getErrorNum()) {
    $this->setError($db->getErrorMsg());
    return FALSE;
  }
}
// Delete existing user maps to the rule.
$db->setQuery('DELETE FROM `#__user_rule_map`'
              . ' WHERE `rule_id` = '
              . (int) $this->_rule_id);
$db->query();
// Check for a database error.
if ($db->getErrorNum()) {
  $this->setError($db->getErrorMsg());
  return FALSE;
}
// Map the users to the rule if any exist.
if (!empty($this->_users)) {
  // Build the values clause for the insert query.
  $values=array();
  foreach ($this->_users as $user) {
    $values[]='('
              . (int) $user
              . ', '
              . (int) $this->_rule_id
              . ')';
  }
  // Perform the insert query.
  $db->setQuery('INSERT INTO `#__user_rule_map` (`user_id`, `rule_id`) VALUES '
                . implode(', ',$values));
  $db->query();
  // Check for a database error.
  if ($db->getErrorNum()) {
    $this->setError($db->getErrorMsg());
    return FALSE;
  }
}
return TRUE;
 

CloneAbstraction
Parameter Bindings
Parameter
Index
Clone
Instance
Parameter
Name
Value
None