CloneSet13


Previous CloneSetNext CloneSetBack to Main Report
Clone
Mass
Clones in
CloneSet
Parameter
Count
Clone
Similarity
Syntax Category
[Sequence Length]
188230.998class_member_list[6]
Clone AbstractionParameter Bindings
Clone Instance
(Click to see clone)
Line CountSource Line
Source File
1188282
administrator/components/com_categories/models/category.php
2188402
administrator/components/com_menus/models/item.php
Clone Instance
1
Line Count
188
Source Line
282
Source File
administrator/components/com_categories/models/category.php

        /**
         * Method to delete rows.
         *
         * @param       array   An array of item ids.
         *
         * @return      boolean Returns true on success, false on failure.
         */
        public

               function delete($pks) {

                $pks=  (array) $pks;

                // Get a row instance.
                $table=  &$this->getTable();

                // Iterate the items to delete each one.
                foreach ($pks as $pk)
                {
                        if (!$table->delete( (int) $pk))
                        {
                                $this->setError($table->getError());
                                return FALSE;
                              }
                      }

                return TRUE;
              }

        /**
         * Method to publish categories.
         *
         * @param       array   The ids of the items to publish.
         * @param       int             The value of the published state
         *
         * @return      boolean True on success.
         */
        function publish($pks, $value=  1) {

                $pks=  (array) $pks;

                // Get the current user object.
                $user=  &JFactory::getUser();

                // Get an instance of the table row.
                $table=  &$this->getTable();

                // Attempt to publish the items.
                if (!$table->publish($pks, $value, $user->get('id')))
                {
                        $this->setError($table->getError());
                        return FALSE;
                      }

                return TRUE;
              }
        /**
         * Method to adjust the ordering of a row.
         *
         * @param       int             The numeric id of the row to move.
         * @param       integer Increment, usually +1 or -1
         * @return      boolean False on failure or error, true otherwise.
         */
        public

               function ordering($pk, $direction=  0) {

                // Sanitize the id and adjustment.
                $pk=      (!empty($pk))
                          ?               $pk
                          :                     (int) $this->getState('category.id');
                // If the ordering direction is 0 then we aren't moving anything.
                if ($direction == 0) {
                        return TRUE;
                      }
                // Get a row instance.
                $table=  &$this->getTable();

                // Move the row down in the ordering.
                if ($direction>  0)
                {
                        if (!$table->orderDown($pk)) {
                                $this->setError($table->getError());
                                return FALSE;
                              }
                      }

                // Move the row up in the ordering.
                else
                {
                        if (!$table->orderUp($pk)) {
                                $this->setError($table->getError());
                                return FALSE;
                              }
                      }

                return TRUE;
              }
        /**
         * Method rebuild the entire nested set tree.
         *
         * @return      boolean False on failure or error, true otherwise.
         */
        public

               function rebuild() {

                // Get an instance of the table obejct.
                $table=  &$this->getTable();

                if (!$table->rebuild())
                {
                        $this->setError($table->getError());
                        return FALSE;
                      }

                return TRUE;
              }

        /**
         * Method to perform batch operations on a category or a set of categories.
         *
         * @param       array   An array of commands to perform.
         * @param       array   An array of category ids.
         *
         * @return      boolean Returns true on success, false on failure.
         */
        function batch($commands, $pks) {

                // Sanitize user ids.
                $pks=  array_unique($pks);
                JArrayHelper::toInteger($pks);

                // Remove any values of zero.
                if (array_search(0, $pks, TRUE)) {
                        unset ($pks[array_search(0, $pks, TRUE)]);
                      }

                if (empty($pks)) {
                        $this->setError(JText::_('JError_No_items_selected'));
                        return FALSE;
                      }

                $done=  FALSE;

                if (!empty($commands['assetgroup_id']))
                {
                        if (!$this->_batchAccess($commands['assetgroup_id'], $pks)) {
                                return FALSE;
                              }
                        $done=  TRUE;
                      }

                if (!empty($commands['category_id']))
                {
                        $cmd=  JArrayHelper::getValue($commands, 'move_copy', 'c');

                        if ($cmd == 'c'
                            &&             !$this->_batchCopy($commands['category_id'], $pks)) {
                                return FALSE;
                              }
                        else if ($cmd == 'm'
                                 &&             !$this->_batchMove($commands['category_id'], $pks)) {
                                return FALSE;
                              }
                        $done=  TRUE;
                      }
                if (!$done)
                {
                        $this->setError('Categories_Error_Insufficient_batch_information');
                        return FALSE;
                      }
                return TRUE;
              }
        /**
         * Batch access level changes for a group of rows.
         *
         * @param       int             The new value matching an Asset Group ID.
         * @param       array   An array of row IDs.
         *
         * @return      booelan True if successful, false otherwise and internal error is set.
         */
        protected

                  function _batchAccess($value, $pks) {

                $table=  &$this->getTable();
                foreach ($pks as $pk)
                {
                        $table->reset();
                        $table->load($pk);
                        $table->access = (int) $value;
                        if (!$table->store())
                        {
                                $this->setError($table->getError());
                                return FALSE;
                              }
                      }

                return TRUE;
              }


Clone Instance
2
Line Count
188
Source Line
402
Source File
administrator/components/com_menus/models/item.php

        /**
         * Method to delete rows.
         *
         * @param       array   An array of item ids.
         *
         * @return      boolean Returns true on success, false on failure.
         */
        public

               function delete($pks) {

                $pks=  (array) $pks;

                // Get a row instance.
                $table=  &$this->getTable();

                // Iterate the items to delete each one.
                foreach ($pks as $pk)
                {
                        if (!$table->delete( (int) $pk))
                        {
                                $this->setError($table->getError());
                                return FALSE;
                              }
                      }

                return TRUE;
              }

        /**
         * Method to publish categories.
         *
         * @param       array   The ids of the items to publish.
         * @param       int             The value of the published state
         *
         * @return      boolean True on success.
         */
        function publish($pks, $value=  1) {

                $pks=  (array) $pks;

                // Get the current user object.
                $user=  &JFactory::getUser();

                // Get an instance of the table row.
                $table=  &$this->getTable();

                // Attempt to publish the items.
                if (!$table->publish($pks, $value, $user->get('id')))
                {
                        $this->setError($table->getError());
                        return FALSE;
                      }

                return TRUE;
              }
        /**
         * Method to adjust the ordering of a row.
         *
         * @param       int             The numeric id of the row to move.
         * @param       integer Increment, usually +1 or -1
         * @return      boolean False on failure or error, true otherwise.
         */
        public

               function ordering($pk, $direction=  0) {

                // Sanitize the id and adjustment.
                $pk=      (!empty($pk))
                          ?               $pk
                          :                     (int) $this->getState('item.id');
                // If the ordering direction is 0 then we aren't moving anything.
                if ($direction == 0) {
                        return TRUE;
                      }
                // Get a row instance.
                $table=  &$this->getTable();

                // Move the row down in the ordering.
                if ($direction>  0)
                {
                        if (!$table->orderDown($pk)) {
                                $this->setError($table->getError());
                                return FALSE;
                              }
                      }

                // Move the row up in the ordering.
                else
                {
                        if (!$table->orderUp($pk)) {
                                $this->setError($table->getError());
                                return FALSE;
                              }
                      }

                return TRUE;
              }
        /**
         * Method rebuild the entire nested set tree.
         *
         * @return      boolean False on failure or error, true otherwise.
         */
        public

               function rebuild() {

                // Get an instance of the table obejct.
                $table=  &$this->getTable();

                if (!$table->rebuild())
                {
                        $this->setError($table->getError());
                        return FALSE;
                      }

                return TRUE;
              }

        /**
         * Method to perform batch operations on a category or a set of categories.
         *
         * @param       array   An array of commands to perform.
         * @param       array   An array of category ids.
         *
         * @return      boolean Returns true on success, false on failure.
         */
        function batch($commands, $pks) {

                // Sanitize user ids.
                $pks=  array_unique($pks);
                JArrayHelper::toInteger($pks);

                // Remove any values of zero.
                if (array_search(0, $pks, TRUE)) {
                        unset ($pks[array_search(0, $pks, TRUE)]);
                      }

                if (empty($pks)) {
                        $this->setError(JText::_('JError_No_items_selected'));
                        return FALSE;
                      }

                $done=  FALSE;

                if (!empty($commands['assetgroup_id']))
                {
                        if (!$this->_batchAccess($commands['assetgroup_id'], $pks)) {
                                return FALSE;
                              }
                        $done=  TRUE;
                      }

                if (!empty($commands['menu_id']))
                {
                        $cmd=  JArrayHelper::getValue($commands, 'move_copy', 'c');

                        if ($cmd == 'c'
                            &&             !$this->_batchCopy($commands['menu_id'], $pks)) {
                                return FALSE;
                              }
                        else if ($cmd == 'm'
                                 &&             !$this->_batchMove($commands['menu_id'], $pks)) {
                                return FALSE;
                              }
                        $done=  TRUE;
                      }
                if (!$done)
                {
                        $this->setError('Menus_Error_Insufficient_batch_information');
                        return FALSE;
                      }
                return TRUE;
              }
        /**
         * Batch access level changes for a group of rows.
         *
         * @param       int             The new value matching an Asset Group ID.
         * @param       array   An array of row IDs.
         *
         * @return      booelan True if successful, false otherwise and internal error is set.
         */
        protected

                  function _batchAccess($value, $pks) {

                $table=  &$this->getTable();
                foreach ($pks as $pk)
                {
                        $table->reset();
                        $table->load($pk);
                        $table->access = (int) $value;
                        if (!$table->store())
                        {
                                $this->setError($table->getError());
                                return FALSE;
                              }
                      }

                return TRUE;
              }


Clone AbstractionParameter Count: 3Parameter Bindings

/**
         * Method to delete rows.
         *
         * @param       array   An array of item ids.
         *
         * @return      boolean Returns true on success, false on failure.
         */
public

      function delete($pks) {
        $pks= (array) $pks;
        // Get a row instance.
        $table= &$this->getTable();
        // Iterate the items to delete each one.
        foreach ($pks as $pk) {
          if (!$table->delete( (int) $pk)) {
            $this->setError($table->getError());
            return FALSE;
          }
        }
        return TRUE;
      }

/**
         * Method to publish categories.
         *
         * @param       array   The ids of the items to publish.
         * @param       int             The value of the published state
         *
         * @return      boolean True on success.
         */
function publish($pks,$value=1) {
  $pks= (array) $pks;
  // Get the current user object.
  $user= &JFactory::getUser();
  // Get an instance of the table row.
  $table= &$this->getTable();
  // Attempt to publish the items.
  if (!$table->publish($pks,$value,$user->get('id'))) {
    $this->setError($table->getError());
    return FALSE;
  }
  return TRUE;
}
/**
         * Method to adjust the ordering of a row.
         *
         * @param       int             The numeric id of the row to move.
         * @param       integer Increment, usually +1 or -1
         * @return      boolean False on failure or error, true otherwise.
         */
public

      function ordering($pk,$direction=0) {
        // Sanitize the id and adjustment.
        $pk=(!empty($pk))
            ? $pk
            : (int) $this->getState( [[#variable541a9a20]]);
        // If the ordering direction is 0 then we aren't moving anything.
        if ($direction == 0) {
          return TRUE;
        }
        // Get a row instance.
        $table= &$this->getTable();
        // Move the row down in the ordering.
        if ($direction>0) {
          if (!$table->orderDown($pk)) {
            $this->setError($table->getError());
            return FALSE;
          }
        }
        // Move the row up in the ordering.
        else {
          if (!$table->orderUp($pk)) {
            $this->setError($table->getError());
            return FALSE;
          }
        }
        return TRUE;
      }
/**
         * Method rebuild the entire nested set tree.
         *
         * @return      boolean False on failure or error, true otherwise.
         */
public

      function rebuild() {
        // Get an instance of the table obejct.
        $table= &$this->getTable();
        if (!$table->rebuild()) {
          $this->setError($table->getError());
          return FALSE;
        }
        return TRUE;
      }

/**
         * Method to perform batch operations on a category or a set of categories.
         *
         * @param       array   An array of commands to perform.
         * @param       array   An array of category ids.
         *
         * @return      boolean Returns true on success, false on failure.
         */
function batch($commands,$pks) {
  // Sanitize user ids.
  $pks=array_unique($pks);
  JArrayHelper::toInteger($pks);
  // Remove any values of zero.
  if (array_search(0,$pks,TRUE)) {
    unset ($pks[array_search(0,$pks,TRUE)]);
  }
  if (empty($pks)) {
    $this->setError(JText::_('JError_No_items_selected'));
    return FALSE;
  }
  $done=FALSE;
  if (!empty($commands['assetgroup_id'])) {
    if (!$this->_batchAccess($commands['assetgroup_id'],$pks)) {
      return FALSE;
    }
    $done=TRUE;
  }
  if (!empty($commands[ [[#variable541a97c0]]])) {
    $cmd=JArrayHelper::getValue($commands,'move_copy','c');
    if ($cmd == 'c'
        && !$this->_batchCopy($commands[ [[#variable541a97c0]]],$pks)) {
      return FALSE;
    }
    else if ($cmd == 'm'
             && !$this->_batchMove($commands[ [[#variable541a97c0]]],$pks)) {
           return FALSE;
         }
    $done=TRUE;
  }
  if (!$done) {
    $this->setError( [[#variable541a9800]]);
    return FALSE;
  }
  return TRUE;
}
/**
         * Batch access level changes for a group of rows.
         *
         * @param       int             The new value matching an Asset Group ID.
         * @param       array   An array of row IDs.
         *
         * @return      booelan True if successful, false otherwise and internal error is set.
         */
protected

         function _batchAccess($value,$pks) {
           $table= &$this->getTable();
           foreach ($pks as $pk) {
             $table->reset();
             $table->load($pk);
             $table->access = (int) $value;
             if (!$table->store()) {
               $this->setError($table->getError());
               return FALSE;
             }
           }
           return TRUE;
         }
 

CloneAbstraction
Parameter Bindings
Parameter
Index
Clone
Instance
Parameter
Name
Value
11[[#541a9a20]]
'category.id' 
12[[#541a9a20]]
'item.id' 
21[[#541a97c0]]
'category_id' 
22[[#541a97c0]]
'menu_id' 
31[[#541a9800]]
'Categories_Error_Insufficient_batch_information' 
32[[#541a9800]]
'Menus_Error_Insufficient_batch_information'