You are here

function flag_flag::revert in Flag 6.2

Same name and namespace in other branches
  1. 7.3 includes/flag/flag_flag.inc \flag_flag::revert()
  2. 7.2 flag.inc \flag_flag::revert()

Reverts an overriding flag to its default state.

Note that $this isn't altered. To see the reverted flag you'll have to call flag_get_flag($this->name) again.

Return value

TRUE if the flag was reverted successfully; FALSE if there was an error; NULL if this flag overrides no default flag.

File

./flag.inc, line 1153
Implements various flags. Uses object oriented style inspired by that of Views 2.

Class

flag_flag
This abstract class represents a flag, or, in Views 2 terminology, "a handler".

Code

function revert() {
  if ($default_flag = $this
    ->find_default_flag()) {
    if ($default_flag
      ->is_compatible()) {
      $default_flag = clone $default_flag;
      $default_flag->fid = $this->fid;
      $default_flag
        ->save();
      flag_get_flags(NULL, NULL, NULL, TRUE);
      return TRUE;
    }
    else {
      return FALSE;
    }
  }
}