You are here

function shurly_set_link_active in ShURLy 8

Same name and namespace in other branches
  1. 6 shurly.module \shurly_set_link_active()
  2. 7 shurly.module \shurly_set_link_active()

Activate or deactivate a link.

2 calls to shurly_set_link_active()
ShurlyDeactivateForm::submitForm in src/Form/ShurlyDeactivateForm.php
Form submission handler.
shurly_disable_url in ./shurly.module

File

./shurly.module, line 313
Description http://www.youtube.com/watch?v=Qo7qoonzTCE.

Code

function shurly_set_link_active($rid, $active) {
  $record = \Drupal::database()
    ->query('SELECT * FROM {shurly} WHERE rid = :rid', [
    'rid' => $rid,
  ])
    ->fetchObject();
  if ($record) {
    $rid = $record->rid;
    $active = $active ? 1 : 0;
    return \Drupal::database()
      ->merge('shurly')
      ->fields([
      'rid' => $rid,
      'active' => $active,
    ])
      ->key([
      'rid' => $rid,
    ])
      ->execute();
  }
  else {
    return FALSE;
  }
}