Exemple #1
0
 /**
  * Insert a new user or save an existing one.
  *
  * $_user:    The user to be saved.
  * Returns:   The id of the (maybe newly inserted) user.
  */
 function save_user(&$_user)
 {
     if (!is_object($_user)) {
         die('UserDB::save_user(): Invalid arg.');
     }
     $query = new FreechSqlQuery();
     $query->set_int('id', $_user->get_id());
     $query->set_int('group_id', $_user->get_group_id());
     $query->set_int('status', $_user->get_status());
     $query->set_int('lastlogin', $_user->get_last_login_unixtime());
     $query->set_bool('public_mail', $_user->mail_is_public());
     $query->set_bool('do_notify', $_user->get_do_notify());
     $query->set_string('name', $_user->get_name());
     $query->set_string('soundexname', $_user->get_soundexed_name());
     $query->set_string('password', $_user->get_password_hash());
     $query->set_string('firstname', $_user->get_firstname());
     $query->set_string('lastname', $_user->get_lastname());
     $query->set_var('mail', $_user->get_mail());
     $query->set_string('homepage', $_user->get_homepage());
     $query->set_string('im', $_user->get_im());
     if ($_user->get_id() < 1) {
         $sql = "INSERT INTO {t_user}";
         $sql .= " (";
         $sql .= "  group_id, name, soundexname, password,";
         $sql .= "  firstname, lastname,";
         $sql .= "  mail, public_mail, do_notify, homepage, im, status,";
         $sql .= " created, lastlogin";
         $sql .= " )";
         $sql .= " VALUES (";
         $sql .= "  {group_id}, {name}, {soundexname}, {password},";
         $sql .= "  {firstname}, {lastname},";
         $sql .= "  {mail}, {public_mail}, {do_notify}, {homepage}, {im},";
         $sql .= "  {status}, NULL, FROM_UNIXTIME({lastlogin})";
         $sql .= ")";
         $query->set_sql($sql);
         $this->db->_Execute($query->sql()) or die("UserDB::save_user: Ins");
         $newid = $this->db->Insert_ID();
         $_user->set_id($newid);
         return $newid;
     }
     $sql = "UPDATE {t_user} SET";
     $sql .= " group_id={group_id},";
     $sql .= " name={name}, soundexname={soundexname},";
     $sql .= " password={password},";
     $sql .= " firstname={firstname}, lastname={lastname},";
     $sql .= " mail={mail}, public_mail={public_mail}, homepage={homepage},";
     $sql .= " do_notify={do_notify}, im={im}, status={status},";
     $sql .= " lastlogin=FROM_UNIXTIME({lastlogin})";
     $sql .= " WHERE id={id}";
     $query->set_sql($sql);
     $this->db->_Execute($query->sql()) or die("UserDB::save_user(): Upd");
     return $_user->get_id();
 }
Exemple #2
0
 function save($_forum_id, $_parent_id, &$_posting)
 {
     //FIXME: This currently does not support moving postings (i.e. changing
     // the path, thread, or forum)
     //$this->db->debug = true;
     $this->db->StartTrans();
     $sql = "UPDATE {t_posting} SET";
     $sql .= " forum_id={forum_id},";
     //$sql  .= " thread_id={thread_id},";
     $sql .= " priority={priority},";
     $sql .= " user_id={user_id},";
     $sql .= " user_is_special={user_is_special},";
     $sql .= " user_icon={user_icon},";
     $sql .= " user_icon_name={user_icon_name},";
     $sql .= " renderer={renderer},";
     $sql .= " username={username},";
     $sql .= " subject={subject},";
     $sql .= " body={body},";
     $sql .= " hash={hash},";
     $sql .= " ip_hash={ip_hash},";
     $sql .= " status={status},";
     $sql .= " force_stub={force_stub},";
     $sql .= " notify_author={notify_author},";
     $sql .= " updated=FROM_UNIXTIME({updated})";
     $sql .= " WHERE id={id}";
     $query = new FreechSqlQuery($sql);
     $query->set_int('id', $_posting->get_id());
     $query->set_int('forum_id', $_forum_id);
     //$query->set_int   ('thread_id',       $_posting->get_thread_id());
     $query->set_int('priority', $_posting->get_priority());
     $query->set_int('updated', $_posting->get_updated_unixtime());
     $query->set_int('user_id', $_posting->get_user_id());
     $query->set_bool('user_is_special', $_posting->get_user_is_special());
     $query->set_string('user_icon', $_posting->get_user_icon());
     $query->set_string('user_icon_name', $_posting->get_user_icon_name());
     $query->set_string('renderer', $_posting->get_renderer());
     $query->set_string('username', $_posting->get_username());
     $query->set_string('subject', $_posting->get_subject());
     $query->set_string('body', $_posting->get_body());
     $query->set_string('hash', $_posting->get_hash());
     $query->set_string('ip_hash', $_posting->get_ip_address_hash());
     $query->set_string('status', $_posting->get_status());
     $query->set_bool('force_stub', $_posting->get_force_stub());
     $query->set_bool('notify_author', $_posting->get_notify_author());
     $this->db->_Execute($query->sql()) or die('ForumDB::save(): 2');
     $this->db->CompleteTrans();
 }
Exemple #3
0
 /**
  * Insert a new group or save an existing one.
  *
  * $_group: The group to be saved.
  * Returns: The id of the (maybe newly inserted) group.
  */
 function save_group(&$_group)
 {
     if (!is_object($_group)) {
         die('GroupDB::save_group(): Invalid arg.');
     }
     $query = new FreechSqlQuery();
     $query->set_int('id', $_group->get_id());
     $query->set_string('name', $_group->get_name());
     $query->set_bool('is_special', $_group->is_special());
     $query->set_int('status', $_group->get_status());
     if ($_group->get_id() < 1) {
         $sql = "INSERT INTO {t_group}";
         $sql .= " (";
         $sql .= "  id, name, is_special, status, created";
         $sql .= " )";
         $sql .= " VALUES (";
         $sql .= "  {id}, {name}, {is_special}, {status}, NULL";
         $sql .= " )";
         $query->set_sql($sql);
         $this->db->StartTrans();
         $this->db->_Execute($query->sql()) or die('GroupDB::save_group: Ins');
         $newid = $this->db->Insert_ID();
         $_group->set_id($newid);
         $this->_save_permissions($_group);
         $this->db->CompleteTrans();
         return $newid;
     }
     $sql = "UPDATE {t_group} SET";
     $sql .= " id={id},";
     $sql .= " name={name},";
     $sql .= " is_special={is_special},";
     $sql .= " status={status}";
     $sql .= " WHERE id={id}";
     $query->set_sql($sql);
     $this->db->StartTrans();
     $this->db->_Execute($query->sql()) or die('GroupDB::save_group(): Upd');
     $this->_save_permissions($_group);
     $this->db->CompleteTrans();
     return $_group->get_id();
 }