function user_flag_set($flag_name, $value, $user_id) { // Unset the flag first user_flag_unset($flag_name, $user_id); // Then add data $flag = new StdClass(); $flag->flag = $flag_name; $flag->user_id = $user_id; $flag->value = $value; return insert_record('user_flags', $flag); }
<?php // Flag functions: unset // Ben Werdmuller, Sept 05 /* Parameters: [0] - name of the flag [1] - user ID */ $flagname = $parameter[0]; $userid = (int) $parameter[1]; user_flag_unset($flagname, $userid);
if ($usertype == 'person' && isset($receiveemails)) { if ($receiveemails == "yes") { user_flag_set("emailreplies", "1", $id); //$messages[] = __gettext("Email comments and discussion set to 'on'."); } else { user_flag_unset("emailreplies", $id); //$messages[] = __gettext("Email comments and discussion set to 'off'."); } } $receiveemails = optional_param('receivenotifications'); if ($usertype == 'person' && isset($receiveemails)) { if ($receiveemails == "yes") { user_flag_set("emailnotifications", "1", $id); //$messages[] = __gettext("Email notifications set to 'on'."); } else { user_flag_unset("emailnotifications", $id); //$messages[] = __gettext("Email notifications set to 'off'."); } } if (empty($CFG->disable_passwordchanging)) { $password1 = optional_param('password1'); $password2 = optional_param('password2'); if (!empty($password1) || !empty($password2)) { if ($password1 == $password2) { if (strlen($password1) < 4 || strlen($password1) > 32) { $messages[] = __gettext("Password not changed: Your password is either too short or too long. It must be between 4 and 32 characters in length."); } else { if (!preg_match("/^[a-zA-Z0-9]*\$/i", $password1)) { $messages[] = __gettext("Password not changed: Your password can only consist of letters or numbers."); } else { $messages[] = __gettext("Your password was updated.");