Пример #1
0
function plugin_routetables_MassiveActionsProcess($data)
{
    $route_item = new PluginRoutetablesRoutetable_Item();
    $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
    switch ($data['action']) {
        case "plugin_routetables_add_item":
            foreach ($data["item"] as $key => $val) {
                if ($val == 1) {
                    $input = array('plugin_routetables_routetables_id' => $data['plugin_routetables_routetables_id'], 'items_id' => $key, 'itemtype' => $data['itemtype']);
                    if ($route_item->can(-1, 'w', $input)) {
                        if ($route_item->add($input)) {
                            $res['ok']++;
                        } else {
                            $res['ko']++;
                        }
                    } else {
                        $res['noright']++;
                    }
                }
            }
            break;
    }
    return $res;
}
Пример #2
0
 /**
  * Do the specific massive actions
  *
  * @since version 0.84
  * 
  * @param $input array of input datas
  * 
  * @return an array of results (nbok, nbko, nbnoright counts)
  **/
 public function doSpecificMassiveActions($input = array())
 {
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     $route_item = new PluginRoutetablesRoutetable_Item();
     switch ($input['action']) {
         case 'Duplicate':
             if ($input['itemtype'] == 'PluginRoutetablesRoutetable') {
                 foreach ($input['item'] as $key => $val) {
                     if ($val == 1) {
                         if ($this->getFromDB($key)) {
                             unset($this->fields["id"]);
                             $this->fields["entities_id"] = $input["entities_id"];
                             if ($newID = $this->add($this->fields)) {
                                 $res['ok']++;
                             } else {
                                 $res['ko']++;
                             }
                         } else {
                             $res['ko']++;
                         }
                     }
                 }
             }
             break;
         case "Install":
             foreach ($input["item"] as $key => $val) {
                 if ($val == 1) {
                     $values = array('plugin_routetables_routetables_id' => $key, 'items_id' => $input["item_item"], 'itemtype' => $input['typeitem']);
                     if ($route_item->can(-1, 'w', $input)) {
                         if ($route_item->add($values)) {
                             $res['ok']++;
                         } else {
                             $res['ko']++;
                         }
                     } else {
                         $res['noright']++;
                     }
                 }
             }
             break;
         case "Desinstall":
             foreach ($input["item"] as $key => $val) {
                 if ($val == 1) {
                     if ($route_item->deleteItemByRoutetablesAndItem($key, $input['item_item'], $input['typeitem'])) {
                         $res['ok']++;
                     } else {
                         $res['ko']++;
                     }
                 }
             }
             break;
         case "Transfert":
             if ($input['itemtype'] == 'PluginRoutetablesRoutetable') {
                 foreach ($input["item"] as $key => $val) {
                     if ($val == 1) {
                         $values["id"] = $key;
                         $values["entities_id"] = $input['entities_id'];
                         if ($this->update($values)) {
                             $res['ok']++;
                         } else {
                             $res['ko']++;
                         }
                     }
                 }
             }
             break;
         default:
             return parent::doSpecificMassiveActions($input);
             break;
     }
     return $res;
 }
Пример #3
0
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with Routetables. If not, see <http://www.gnu.org/licenses/>.
 --------------------------------------------------------------------------
*/
include '../../../inc/includes.php';
if (!isset($_GET["id"])) {
    $_GET["id"] = "";
}
if (!isset($_GET["withtemplate"])) {
    $_GET["withtemplate"] = "";
}
$route = new PluginRoutetablesRoutetable();
$route_item = new PluginRoutetablesRoutetable_Item();
if (isset($_POST["add"])) {
    $route->check(-1, 'w', $_POST);
    $newID = $route->add($_POST);
    Html::back();
} else {
    if (isset($_POST["delete"])) {
        $route->check($_POST['id'], 'w');
        $route->delete($_POST);
        $route->redirectToList();
    } else {
        if (isset($_POST["restore"])) {
            $route->check($_POST['id'], 'w');
            $route->restore($_POST);
            $route->redirectToList();
        } else {