コード例 #1
0
ファイル: leomanagewidgets.php プロジェクト: pacxs/pacxscom
 public function hookActionShopDataDuplication($params)
 {
     //select all group
     $listGroupId = LeoManageWidgetGroup::getAllGroupId((int) $params['old_id_shop']);
     foreach ($listGroupId as $groupId) {
         $group = new LeoManageWidgetGroup($groupId);
         $oldID = $group->id;
         $group->id_shop = (int) $params['new_id_shop'];
         $group->id = 0;
         if ($group->add()) {
             $columns = LeoManageWidgetColumn::getAllColumn(' AND `id_group` = ' . $oldID, (int) $params['old_id_shop']);
             if ($columns) {
                 foreach ($columns as $columnID) {
                     $column = new LeoManageWidgetColumn($columnID['id_column']);
                     $oldColumnId = $column->id;
                     $column->id = 0;
                     $column->id_group = $group->id;
                     $column->id_shop = (int) $params['new_id_shop'];
                     $column->add();
                     $rows = LeoManagerWidgetContent::getAllRowColumn(' AND `id_column` = ' . $oldColumnId, (int) $params['old_id_shop']);
                     if ($rows) {
                         foreach ($rows as $rowID) {
                             $row = new LeoManagerWidgetContent($rowID['id_content']);
                             $row->id = 0;
                             $row->id_column = $column->id;
                             $row->id_shop = (int) $params['new_id_shop'];
                             $row->add();
                         }
                     }
                 }
             }
         }
     }
     $this->clearHookCache();
 }
コード例 #2
0
 public static function getOldData()
 {
     $res = 1;
     $columns = LeoManageWidgetColumn::getAllOldColumn();
     //echo "<pre>";print_r($columns);die;
     if ($columns) {
         foreach ($columns as $column) {
             $newColumn = new LeoManageWidgetColumn();
             //echo "<pre>";print_r($columnID);die;
             $newColumn->id_group = $column['id_group'];
             $newColumn->id_shop = $column['id_shop'];
             $newColumn->position = $column['position'];
             $newColumn->active = $column['active'];
             $newColumn->params = $column['params'];
             if ($newColumn->add()) {
                 $row = new LeoManagerWidgetContent();
                 $row->id_column = $newColumn->id;
                 $row->id_shop = $newColumn->id_shop;
                 $row->position = 1;
                 $row->active = $newColumn->active;
                 $row->key_widget = $column['key_widget'];
                 if ($column['key_widget'] != 0) {
                     $row->type = '0';
                     if (!$row->add()) {
                         $res = 0;
                     }
                 } else {
                     if ($newColumn->params) {
                         $myParam = Tools::jsonDecode(call_user_func('base64' . '_decode', $newColumn->params), true);
                         if ($myParam) {
                             foreach ($myParam as $key => $value) {
                                 if ($key == 'module' && $value) {
                                     $row->module_name = $value;
                                 }
                                 if ($key == 'hook' && $value) {
                                     $row->hook_name = $value;
                                 }
                             }
                         }
                     }
                     if (isset($row->module_name) && isset($row->hook_name)) {
                         $row->type = '1';
                         if (!$row->add()) {
                             $res = 0;
                         }
                     }
                 }
             } else {
                 $res = 0;
             }
         }
     }
     return $res;
 }