دروپال: مهاجرت از ماژول statuses به ماژول status

function status_migrate() {
  $sid = variable_get('status_migrate', 0);
  variable_set('status_migrate', $sid + 200);
  $statuses = db_select('statuses', 's')->fields('s')->condition('sid', $sid, '>')->range(0, 200)->orderBy('sid', 'ASC')->execute()->fetchAll();
  foreach ($statuses as $statuses_row) {
    $status = (object) array(
          'sid' => $statuses_row->sid,
          'sender' => $statuses_row->sender,
          'recipient' => $statuses_row->recipient,
          'status' => $statuses_row->message,
          'created' => $statuses_row->created,
          'changed' => $statuses_row->created,
    );
    status_insert($status);
    $comments = db_select('fbss_comments', 'fc')->fields('fc')->condition('sid', $statuses_row->sid)->execute()->fetchAll();

    foreach ($comments as $comment) {
      $reply = (object) array(
            'srid' => $comment->cid,
            'sid' => $comment->sid,
            'uid' => $comment->uid,
            'reply' => $comment->comment,
            'created' => $comment->created,
            'changed' => $comment->created,
      );
      status_reply_insert($reply);
    }
  }
  variable_set('status_migrate', $statuses_row->sid);
  print $statuses_row->sid;
  drupal_exit();
}

function status_menu(){
  $items['user/status/migrate'] = array(
    'title' => 'Status migrate',
    'page callback' => 'status_migrate',
    'access callback' => 'user_is_logged_in',
    'type' => MENU_CALLBACK,
    'file' => 'pages/status.page.inc',
  );
  return $items;
}

 

برچسب ها: 

افزودن نظر جدید