| @@ 647-667 (lines=21) @@ | ||
| 644 | * @param int userid |
|
| 645 | * @return serialized|string |
|
| 646 | */ |
|
| 647 | public function GetSettings($userid) |
|
| 648 | { |
|
| 649 | global $xoopsDB; |
|
| 650 | $sql = 'SELECT value FROM ' . $xoopsDB->prefix('smallworld_settings') . ' WHERE userid = ' . (int)$userid . ''; |
|
| 651 | $result = $xoopsDB->queryF($sql); |
|
| 652 | $i = $xoopsDB->getRowsNum($result); |
|
| 653 | if ($i < 1) { |
|
| 654 | $posts = serialize([ |
|
| 655 | 'posts' => 0, |
|
| 656 | 'comments' => 0, |
|
| 657 | 'notify' => 1 |
|
| 658 | ]); |
|
| 659 | $this->saveSettings($userid, $posts); |
|
| 660 | $this->GetSettings($userid); |
|
| 661 | } else { |
|
| 662 | while ($row = $xoopsDB->fetchArray($result)) { |
|
| 663 | $data = $row['value']; |
|
| 664 | } |
|
| 665 | return json_encode(unserialize(stripslashes($data))); |
|
| 666 | } |
|
| 667 | } |
|
| 668 | } |
|
| 669 | ||
| @@ 650-670 (lines=21) @@ | ||
| 647 | * @param int userid |
|
| 648 | * @return serialized|string |
|
| 649 | */ |
|
| 650 | public function GetSettings($userid) |
|
| 651 | { |
|
| 652 | global $xoopsDB; |
|
| 653 | $sql = 'SELECT value FROM ' . $xoopsDB->prefix('smallworld_settings') . ' WHERE userid = ' . (int)$userid . ''; |
|
| 654 | $result = $xoopsDB->queryF($sql); |
|
| 655 | $i = $xoopsDB->getRowsNum($result); |
|
| 656 | if ($i < 1) { |
|
| 657 | $posts = serialize([ |
|
| 658 | 'posts' => 0, |
|
| 659 | 'comments' => 0, |
|
| 660 | 'notify' => 1 |
|
| 661 | ]); |
|
| 662 | $this->saveSettings($userid, $posts); |
|
| 663 | $this->GetSettings($userid); |
|
| 664 | } else { |
|
| 665 | while ($row = $xoopsDB->fetchArray($result)) { |
|
| 666 | $data = $row['value']; |
|
| 667 | } |
|
| 668 | return json_encode(unserialize(stripslashes($data))); |
|
| 669 | } |
|
| 670 | } |
|
| 671 | } |
|
| 672 | ||