示例#1
0
 public static function mark(GWF_User $user, GWF_Links $link, $bool)
 {
     $userid = $user->getID();
     $linkid = $link->getID();
     $is_fav = self::table(__CLASS__)->getRow($userid, $linkid) !== false;
     if ($is_fav === $bool) {
         return true;
     }
     $row = new self(array('lf_uid' => $userid, 'lf_lid' => $linkid));
     if ($bool) {
         if (!$row->replace()) {
             return false;
         }
     } else {
         if (!$row->delete()) {
             return false;
         }
     }
     if (false === $link->increase('link_favcount', $bool ? 1 : -1)) {
         return false;
     }
     if (false === $link->onCalcPopularity()) {
         return false;
     }
     return true;
 }