| @@ 38-52 (lines=15) @@ | ||
| 35 | return $this->is_registered("ttt_registrations", $user_nick); |
|
| 36 | } |
|
| 37 | ||
| 38 | public function register_for_ttt($user_nick, $contact_number) { |
|
| 39 | $stmt = $this->db_lib->prepared_execute( |
|
| 40 | $this->DB->contest, |
|
| 41 | "INSERT INTO `ttt_registrations` |
|
| 42 | (`nick`, `contact_number`) VALUES (?, ?)", |
|
| 43 | "ss", |
|
| 44 | [$user_nick, $contact_number] |
|
| 45 | ); |
|
| 46 | if (!$stmt) { |
|
| 47 | return false; |
|
| 48 | } |
|
| 49 | else { |
|
| 50 | return true; |
|
| 51 | } |
|
| 52 | } |
|
| 53 | ||
| 54 | public function ttt_payment_success($payment_id, $nick, $status, $payment_data) { |
|
| 55 | $stmt = $this->db_lib->prepared_execute( |
|
| @@ 60-72 (lines=13) @@ | ||
| 57 | return $perms; |
|
| 58 | } |
|
| 59 | ||
| 60 | function add_user_role($file_id, $user, $role) { |
|
| 61 | // Add admin user for a file |
|
| 62 | if ($file_id === false || !$user) { |
|
| 63 | return false; |
|
| 64 | } |
|
| 65 | return $this->db_lib->prepared_execute( |
|
| 66 | $this->DB->jugaad, |
|
| 67 | "INSERT INTO `file_permissions` (`file_id`, `user`, `role`) VALUES (?, ?, ?)", |
|
| 68 | "iss", |
|
| 69 | [$file_id, $user, $role], |
|
| 70 | false |
|
| 71 | ); |
|
| 72 | } |
|
| 73 | ||
| 74 | function remove_user_role($file_id, $user) { |
|
| 75 | // Remove admin user for a file |
|
| @@ 74-86 (lines=13) @@ | ||
| 71 | ); |
|
| 72 | } |
|
| 73 | ||
| 74 | function remove_user_role($file_id, $user) { |
|
| 75 | // Remove admin user for a file |
|
| 76 | if ($file_id === false || !$user) { |
|
| 77 | return false; |
|
| 78 | } |
|
| 79 | return $this->db_lib->prepared_execute( |
|
| 80 | $this->DB->jugaad, |
|
| 81 | "DELETE FROM `file_permissions` WHERE `file_id`=? AND `user`=?", |
|
| 82 | "is", |
|
| 83 | [$file_id, $user], |
|
| 84 | false |
|
| 85 | ); |
|
| 86 | } |
|
| 87 | ||
| 88 | function get_default_role($file_id) { |
|
| 89 | // Get default role for a file |
|
| @@ 108-120 (lines=13) @@ | ||
| 105 | return false; |
|
| 106 | } |
|
| 107 | ||
| 108 | function set_default_role($file_id, $role) { |
|
| 109 | // Set default role for a file |
|
| 110 | if ($file_id === false) { |
|
| 111 | return false; |
|
| 112 | } |
|
| 113 | return $this->db_lib->prepared_execute( |
|
| 114 | $this->DB->jugaad, |
|
| 115 | "UPDATE `files` SET `default_role`=? WHERE `id`=?", |
|
| 116 | "si", |
|
| 117 | [$role, $file_id], |
|
| 118 | false |
|
| 119 | ); |
|
| 120 | } |
|
| 121 | ||
| 122 | private function file_get_user_role($file_id, $user) { |
|
| 123 | // Check permissions for a single file |
|