/** * write a new block into the database * * @param XoopsObject|XoopsBlock $block a XoopsBlock object * * @return bool true on success, otherwise false */ public function insert(XoopsObject $block) { $className = 'XoopsBlock'; if (!$block instanceof $className) { return false; } if (!$block->isDirty()) { return true; } if (!$block->cleanVars()) { return false; } $bid = $block->getVar('bid', 'n'); $mid = $block->getVar('mid', 'n'); $func_num = $block->getVar('func_num', 'n'); $options = $block->getVar('options', 'n'); $name = $block->getVar('name', 'n'); $title = $block->getVar('title', 'n'); $content = $block->getVar('content', 'n'); $side = $block->getVar('side', 'n'); $weight = $block->getVar('weight', 'n'); $visible = $block->getVar('visible', 'n'); $c_type = $block->getVar('c_type', 'n'); $isactive = $block->getVar('isactive', 'n'); $func_file = $block->getVar('func_file', 'n'); $show_func = $block->getVar('show_func', 'n'); $edit_func = $block->getVar('edit_func', 'n'); $template = $block->getVar('template', 'n'); $bcachetime = $block->getVar('bcachetime', 'n'); $block_type = $block->getVar('block_type', 'n'); $dirname = $block->getVar('dirname', 'n'); if ($block->isNew()) { $bid = $this->db->genId('newblocks_bid_seq'); $sql = sprintf('INSERT INTO %s (bid, mid, func_num, options, name, title, content, side, weight, visible, block_type,' . ' c_type, isactive, dirname, func_file, show_func, edit_func, template, bcachetime, last_modified)' . " VALUES (%u, %u, %u, '%s', '%s', '%s', '%s', %u, %u, %u, '%s', '%s', %u, '%s', '%s', '%s', '%s'," . " '%s', %u, %u)", $this->db->prefix('newblocks'), $bid, $mid, $func_num, $options, $name, $title, $content, $side, $weight, $visible, $block_type, $c_type, 1, $dirname, $func_file, $show_func, $edit_func, $template, $bcachetime, time()); } else { $sql = sprintf("UPDATE %s SET func_num = %u, options = '%s', name = '%s', title = '%s', content = '%s', side = %u," . " weight = %u, visible = %u, c_type = '%s', isactive = %u, func_file = '%s', show_func = '%s'," . " edit_func = '%s', template = '%s', bcachetime = %u, last_modified = %u WHERE bid = %u", $this->db->prefix('newblocks'), $func_num, $options, $name, $title, $content, $side, $weight, $visible, $c_type, $isactive, $func_file, $show_func, $edit_func, $template, $bcachetime, time(), $bid); } if (!($result = $this->db->query($sql))) { return false; } if (empty($bid)) { $bid = $this->db->getInsertId(); } $block->assignVar('bid', $bid); return true; }
/** * Write a {@link XoopsImage} object to the database * * @param XoopsObject|XoopsImage $image a XoopsImage object * * @return bool true on success, otherwise false **/ public function insert(XoopsObject $image) { $className = 'XoopsImage'; if (!$image instanceof $className) { return false; } if (!$image->isDirty()) { return true; } if (!$image->cleanVars()) { return false; } foreach ($image->cleanVars as $k => $v) { ${$k} = $v; } if ($image->isNew()) { $image_id = $this->db->genId('image_image_id_seq'); $sql = sprintf('INSERT INTO %s (image_id, image_name, image_nicename, image_mimetype, image_created, image_display, image_weight, imgcat_id) VALUES (%u, %s, %s, %s, %u, %u, %u, %u)', $this->db->prefix('image'), $image_id, $this->db->quoteString($image_name), $this->db->quoteString($image_nicename), $this->db->quoteString($image_mimetype), time(), $image_display, $image_weight, $imgcat_id); if (!($result = $this->db->query($sql))) { return false; } if (empty($image_id)) { $image_id = $this->db->getInsertId(); } if (isset($image_body) && $image_body != '') { $sql = sprintf('INSERT INTO %s (image_id, image_body) VALUES (%u, %s)', $this->db->prefix('imagebody'), $image_id, $this->db->quoteString($image_body)); if (!($result = $this->db->query($sql))) { $sql = sprintf('DELETE FROM %s WHERE image_id = %u', $this->db->prefix('image'), $image_id); $this->db->query($sql); return false; } } $image->assignVar('image_id', $image_id); } else { $sql = sprintf('UPDATE %s SET image_name = %s, image_nicename = %s, image_display = %u, image_weight = %u, imgcat_id = %u WHERE image_id = %u', $this->db->prefix('image'), $this->db->quoteString($image_name), $this->db->quoteString($image_nicename), $image_display, $image_weight, $imgcat_id, $image_id); if (!($result = $this->db->query($sql))) { return false; } if (isset($image_body) && $image_body != '') { $sql = sprintf('UPDATE %s SET image_body = %s WHERE image_id = %u', $this->db->prefix('imagebody'), $this->db->quoteString($image_body), $image_id); if (!($result = $this->db->query($sql))) { $this->db->query(sprintf('DELETE FROM %s WHERE image_id = %u', $this->db->prefix('image'), $image_id)); return false; } } } return true; }
/** * inserts a membership in the database * * @param XoopsObject|XoopsMembership $mship a XoopsMembership object * * @return bool true on success, otherwise false */ public function insert(XoopsObject $mship) { $className = 'XoopsMembership'; if (!$mship instanceof $className) { return false; } if (!$mship->isDirty()) { return true; } if (!$mship->cleanVars()) { return false; } foreach ($mship->cleanVars as $k => $v) { ${$k} = $v; } if ($mship->isNew()) { $linkid = $this->db->genId('groups_users_link_linkid_seq'); $sql = sprintf('INSERT INTO %s (linkid, groupid, uid) VALUES (%u, %u, %u)', $this->db->prefix('groups_users_link'), $linkid, $groupid, $uid); } else { $sql = sprintf('UPDATE %s SET groupid = %u, uid = %u WHERE linkid = %u', $this->db->prefix('groups_users_link'), $groupid, $uid, $linkid); } if (!($result = $this->db->query($sql))) { return false; } if (empty($linkid)) { $linkid = $this->db->getInsertId(); } $mship->assignVar('linkid', $linkid); return true; }
/** * Write a {@link XoopsImageSetImg} object to the database * * @param XoopsObject|XoopsImageSetImg $imgsetimg a XoopsImageSet object * * @return bool true on success, otherwise false **/ public function insert(XoopsObject $imgsetimg) { $className = 'XoopsImageSetImg'; if (!$imgsetimg instanceof $className) { return false; } if (!$imgsetimg->isDirty()) { return true; } if (!$imgsetimg->cleanVars()) { return false; } foreach ($imgsetimg->cleanVars as $k => $v) { ${$k} = $v; } if ($imgsetimg->isNew()) { $imgsetimg_id = $this->db->genId('imgsetimg_imgsetimg_id_seq'); $sql = sprintf('INSERT INTO %s (imgsetimg_id, imgsetimg_file, imgsetimg_body, imgsetimg_imgset) VALUES (%u, %s, %s, %s)', $this->db->prefix('imgsetimg'), $imgsetimg_id, $this->db->quoteString($imgsetimg_file), $this->db->quoteString($imgsetimg_body), $this->db->quoteString($imgsetimg_imgset)); } else { $sql = sprintf('UPDATE %s SET imgsetimg_file = %s, imgsetimg_body = %s, imgsetimg_imgset = %s WHERE imgsetimg_id = %u', $this->db->prefix('imgsetimg'), $this->db->quoteString($imgsetimg_file), $this->db->quoteString($imgsetimg_body), $this->db->quoteString($imgsetimg_imgset), $imgsetimg_id); } if (!($result = $this->db->query($sql))) { return false; } if (empty($imgsetimg_id)) { $imgsetimg_id = $this->db->getInsertId(); } $imgsetimg->assignVar('imgsetimg_id', $imgsetimg_id); return true; }
/** * Store a {@link XoopsGroupPerm} * * @param XoopsObject|XoopsGroupPerm $perm a XoopsGroupPerm object * * @return bool true on success, otherwise false */ public function insert(XoopsObject $perm) { $className = 'XoopsGroupPerm'; if (!$perm instanceof $className) { return false; } if (!$perm->isDirty()) { return true; } if (!$perm->cleanVars()) { return false; } foreach ($perm->cleanVars as $k => $v) { ${$k} = $v; } if ($perm->isNew()) { $gperm_id = $this->db->genId('group_permission_gperm_id_seq'); $sql = sprintf('INSERT INTO %s (gperm_id, gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (%u, %u, %u, %u, %s)', $this->db->prefix('group_permission'), $gperm_id, $gperm_groupid, $gperm_itemid, $gperm_modid, $this->db->quoteString($gperm_name)); } else { $sql = sprintf('UPDATE %s SET gperm_groupid = %u, gperm_itemid = %u, gperm_modid = %u WHERE gperm_id = %u', $this->db->prefix('group_permission'), $gperm_groupid, $gperm_itemid, $gperm_modid, $gperm_id); } if (!($result = $this->db->query($sql))) { return false; } if (empty($gperm_id)) { $gperm_id = $this->db->getInsertId(); } $perm->assignVar('gperm_id', $gperm_id); return true; }
/** * Insert a new {@link XoopsConfigOption} * * @param XoopsObject|XoopsConfigOption $confoption a XoopsConfigOption object * * @return bool true on success, otherwise false */ public function insert(XoopsObject $confoption) { $className = 'XoopsConfigOption'; if (!$confoption instanceof $className) { return false; } if (!$confoption->isDirty()) { return true; } if (!$confoption->cleanVars()) { return false; } $confop_id = $confoption->getVar('confop_id'); $confop_name = $confoption->getVar('confop_name'); $confop_value = $confoption->getVar('confop_value'); $conf_id = $confoption->getVar('conf_id'); if ($confoption->isNew()) { $confop_id = $this->db->genId('configoption_confop_id_seq'); $sql = sprintf('INSERT INTO %s (confop_id, confop_name, confop_value, conf_id) VALUES (%u, %s, %s, %u)', $this->db->prefix('configoption'), $confop_id, $this->db->quote($confop_name), $this->db->quote($confop_value), $conf_id); } else { $sql = sprintf('UPDATE %s SET confop_name = %s, confop_value = %s WHERE confop_id = %u', $this->db->prefix('configoption'), $this->db->quote($confop_name), $this->db->quote($confop_value), $confop_id); } if (!($result = $this->db->query($sql))) { return false; } if (empty($confop_id)) { $confop_id = $this->db->getInsertId(); } $confoption->assignVar('confop_id', $confop_id); return $confop_id; }
/** * Store a {@link XoopsConfigCategory} * * @param XoopsObject|XoopsConfigCategory $confcat a XoopsConfigCategory object * * @return bool true on success, otherwise false */ public function insert(XoopsObject $confcat) { $className = 'XoopsConfigCategory'; if (!$confcat instanceof $className) { return false; } if (!$confcat->isDirty()) { return true; } if (!$confcat->cleanVars()) { return false; } foreach ($confcat->cleanVars as $k => $v) { ${$k} = $v; } if ($confcat->isNew()) { $confcat_id = $this->db->genId('configcategory_confcat_id_seq'); $sql = sprintf('INSERT INTO %s (confcat_id, confcat_name, confcat_order) VALUES (%u, %s, %u)', $this->db->prefix('configcategory'), $confcat_id, $this->db->quoteString($confcat_name), $confcat_order); } else { $sql = sprintf('UPDATE %s SET confcat_name = %s, confcat_order = %u WHERE confcat_id = %u', $this->db->prefix('configcategory'), $this->db->quoteString($confcat_name), $confcat_order, $confcat_id); } if (!($result = $this->db->query($sql))) { return false; } if (empty($confcat_id)) { $confcat_id = $this->db->getInsertId(); } $confcat->assignVar('confcat_id', $confcat_id); return $confcat_id; }
/** * Write a config to the database * * @param XoopsObject|XoopsConfigItem $config a XoopsConfigCategory object * * @return bool true on success, otherwise false */ public function insert(XoopsObject $config) { $className = 'XoopsConfigItem'; if (!$config instanceof $className) { return false; } if (!$config->isDirty()) { return true; } if (!$config->cleanVars()) { return false; } $conf_id = $config->getVar('conf_id', 'n'); $conf_modid = $config->getVar('conf_modid', 'n'); $conf_catid = $config->getVar('conf_catid', 'n'); $conf_name = $config->getVar('conf_name', 'n'); $conf_title = $config->getVar('conf_title', 'n'); $conf_value = $config->getVar('conf_value', 'n'); $conf_desc = $config->getVar('conf_desc', 'n'); $conf_formtype = $config->getVar('conf_formtype', 'n'); $conf_valuetype = $config->getVar('conf_valuetype', 'n'); $conf_order = $config->getVar('conf_order', 'n'); if ($config->isNew()) { $conf_id = $this->db->genId('config_conf_id_seq'); $sql = sprintf('INSERT INTO %s (conf_id, conf_modid, conf_catid, conf_name, conf_title, conf_value, conf_desc, conf_formtype, conf_valuetype, conf_order) VALUES (%u, %u, %u, %s, %s, %s, %s, %s, %s, %u)', $this->db->prefix('config'), $conf_id, $conf_modid, $conf_catid, $this->db->quoteString($conf_name), $this->db->quoteString($conf_title), $this->db->quoteString($conf_value), $this->db->quoteString($conf_desc), $this->db->quoteString($conf_formtype), $this->db->quoteString($conf_valuetype), $conf_order); } else { $sql = sprintf('UPDATE %s SET conf_modid = %u, conf_catid = %u, conf_name = %s, conf_title = %s, conf_value = %s, conf_desc = %s, conf_formtype = %s, conf_valuetype = %s, conf_order = %u WHERE conf_id = %u', $this->db->prefix('config'), $conf_modid, $conf_catid, $this->db->quoteString($conf_name), $this->db->quoteString($conf_title), $this->db->quoteString($conf_value), $this->db->quoteString($conf_desc), $this->db->quoteString($conf_formtype), $this->db->quoteString($conf_valuetype), $conf_order, $conf_id); } if (!($result = $this->db->query($sql))) { return false; } if (empty($conf_id)) { $conf_id = $this->db->getInsertId(); } $config->assignVar('conf_id', $conf_id); return true; }
/** * Write a {@link XoopsImageCategory} object to the database * * @param XoopsObject|XoopsImageCategory $imgcat a XoopsImageCategory object * * @return bool true on success, otherwise false **/ public function insert(XoopsObject $imgcat) { $className = 'XoopsImageCategory'; if (!$imgcat instanceof $className) { return false; } if (!$imgcat->isDirty()) { return true; } if (!$imgcat->cleanVars()) { return false; } foreach ($imgcat->cleanVars as $k => $v) { ${$k} = $v; } if ($imgcat->isNew()) { $imgcat_id = $this->db->genId('imgcat_imgcat_id_seq'); $sql = sprintf('INSERT INTO %s (imgcat_id, imgcat_name, imgcat_display, imgcat_weight, imgcat_maxsize, imgcat_maxwidth, imgcat_maxheight, imgcat_type, imgcat_storetype) VALUES (%u, %s, %u, %u, %u, %u, %u, %s, %s)', $this->db->prefix('imagecategory'), $imgcat_id, $this->db->quoteString($imgcat_name), $imgcat_display, $imgcat_weight, $imgcat_maxsize, $imgcat_maxwidth, $imgcat_maxheight, $this->db->quoteString($imgcat_type), $this->db->quoteString($imgcat_storetype)); } else { $sql = sprintf('UPDATE %s SET imgcat_name = %s, imgcat_display = %u, imgcat_weight = %u, imgcat_maxsize = %u, imgcat_maxwidth = %u, imgcat_maxheight = %u, imgcat_type = %s WHERE imgcat_id = %u', $this->db->prefix('imagecategory'), $this->db->quoteString($imgcat_name), $imgcat_display, $imgcat_weight, $imgcat_maxsize, $imgcat_maxwidth, $imgcat_maxheight, $this->db->quoteString($imgcat_type), $imgcat_id); } if (!($result = $this->db->query($sql))) { return false; } if (empty($imgcat_id)) { $imgcat_id = $this->db->getInsertId(); } $imgcat->assignVar('imgcat_id', $imgcat_id); return true; }
/** * write a new block into the database * * @param XoopsObject|XoopsTplset $tplset a XoopsTplset object * * @return bool true on success, otherwise false */ public function insert(XoopsObject $tplset) { $className = 'XoopsTplset'; if (!$tplset instanceof $className) { return false; } if (!$tplset->isDirty()) { return true; } if (!$tplset->cleanVars()) { return false; } foreach ($tplset->cleanVars as $k => $v) { ${$k} = $v; } if ($tplset->isNew()) { $tplset_id = $this->db->genId('tplset_tplset_id_seq'); $sql = sprintf('INSERT INTO %s (tplset_id, tplset_name, tplset_desc, tplset_credits, tplset_created) VALUES (%u, %s, %s, %s, %u)', $this->db->prefix('tplset'), $tplset_id, $this->db->quoteString($tplset_name), $this->db->quoteString($tplset_desc), $this->db->quoteString($tplset_credits), $tplset_created); } else { $sql = sprintf('UPDATE %s SET tplset_name = %s, tplset_desc = %s, tplset_credits = %s, tplset_created = %u WHERE tplset_id = %u', $this->db->prefix('tplset'), $this->db->quoteString($tplset_name), $this->db->quoteString($tplset_desc), $this->db->quoteString($tplset_credits), $tplset_created, $tplset_id); } if (!($result = $this->db->query($sql))) { return false; } if (empty($tplset_id)) { $tplset_id = $this->db->getInsertId(); } $tplset->assignVar('tplset_id', $tplset_id); return true; }
/** * Insert a message in the database * * @param XoopsPrivmessage $pm {@link XoopsPrivmessage} object * @param bool $force flag to force the query execution skip request method check, which might be required in some situations * @param XoopsObject|XoopsPrivmessage $pm a XoopsMembership object * * @return bool true on success, otherwise false **/ public function insert(XoopsObject $pm, $force = false) { $className = 'XoopsPrivmessage'; if (!$pm instanceof $className) { return false; } if (!$pm->isDirty()) { return true; } if (!$pm->cleanVars()) { return false; } foreach ($pm->cleanVars as $k => $v) { ${$k} = $v; } if ($pm->isNew()) { $msg_id = $this->db->genId('priv_msgs_msg_id_seq'); $sql = sprintf('INSERT INTO %s (msg_id, msg_image, subject, from_userid, to_userid, msg_time, msg_text, read_msg) VALUES (%u, %s, %s, %u, %u, %u, %s, %u)', $this->db->prefix('priv_msgs'), $msg_id, $this->db->quoteString($msg_image), $this->db->quoteString($subject), $from_userid, $to_userid, time(), $this->db->quoteString($msg_text), 0); } else { $sql = sprintf('UPDATE %s SET msg_image = %s, subject = %s, from_userid = %u, to_userid = %u, msg_text = %s, read_msg = %u WHERE msg_id = %u', $this->db->prefix('priv_msgs'), $this->db->quoteString($msg_image), $this->db->quoteString($subject), $from_userid, $to_userid, $this->db->quoteString($msg_text), $read_msg, $msg_id); } $queryFunc = empty($force) ? 'query' : 'queryF'; if (!($result = $this->db->{$queryFunc}($sql))) { return false; } if (empty($msg_id)) { $msg_id = $this->db->getInsertId(); } $pm->assignVar('msg_id', $msg_id); return true; }
/** * Write a notification(subscription) to database * * @param XoopsObject|XoopsNotification $notification a XoopsNotification object * * @return bool true on success, otherwise false **/ public function insert(XoopsObject $notification) { $className = 'XoopsNotification'; if (!$notification instanceof $className) { return false; } if (!$notification->isDirty()) { return true; } if (!$notification->cleanVars()) { return false; } foreach ($notification->cleanVars as $k => $v) { ${$k} = $v; } if ($notification->isNew()) { $not_id = $this->db->genId('xoopsnotifications_not_id_seq'); $sql = sprintf('INSERT INTO %s (not_id, not_modid, not_itemid, not_category, not_uid, not_event, not_mode) VALUES (%u, %u, %u, %s, %u, %s, %u)', $this->db->prefix('xoopsnotifications'), $not_id, $not_modid, $not_itemid, $this->db->quoteString($not_category), $not_uid, $this->db->quoteString($not_event), $not_mode); } else { $sql = sprintf('UPDATE %s SET not_modid = %u, not_itemid = %u, not_category = %s, not_uid = %u, not_event = %s, not_mode = %u WHERE not_id = %u', $this->db->prefix('xoopsnotifications'), $not_modid, $not_itemid, $this->db->quoteString($not_category), $not_uid, $this->db->quoteString($not_event), $not_mode, $not_id); } if (!($result = $this->db->query($sql))) { return false; } if (empty($not_id)) { $not_id = $this->db->getInsertId(); } $notification->assignVar('not_id', $not_id); return true; }
/** * Write a comment to database * * @param XoopsObject|XoopsComment $comment a XoopsComment object * * @return bool true on success, otherwise false **/ public function insert(XoopsObject $comment) { $className = 'XoopsComment'; if (!$comment instanceof $className) { return false; } if (!$comment->isDirty()) { return true; } if (!$comment->cleanVars()) { return false; } foreach ($comment->cleanVars as $k => $v) { ${$k} = $v; } // Start edit by voltan if ($comment->isNew()) { $com_id = $this->db->genId('xoopscomments_com_id_seq'); $sql = sprintf('INSERT INTO %s (com_id, com_pid, com_modid, com_icon, com_title, com_text, com_created, com_modified, com_uid, com_user, com_email, com_url, com_ip, com_sig, com_itemid, com_rootid, com_status, com_exparams, dohtml, dosmiley, doxcode, doimage, dobr) VALUES (%u, %u, %u, %s, %s, %s, %u, %u, %u, %s, %s, %s, %s, %u, %u, %u, %u, %s, %u, %u, %u, %u, %u)', $this->db->prefix('xoopscomments'), $com_id, $com_pid, $com_modid, $this->db->quoteString($com_icon), $this->db->quoteString($com_title), $this->db->quoteString($com_text), $com_created, $com_modified, $com_uid, $this->db->quoteString($com_user), $this->db->quoteString($com_email), $this->db->quoteString($com_url), $this->db->quoteString($com_ip), $com_sig, $com_itemid, $com_rootid, $com_status, $this->db->quoteString($com_exparams), $dohtml, $dosmiley, $doxcode, $doimage, $dobr); } else { $sql = sprintf('UPDATE %s SET com_pid = %u, com_icon = %s, com_title = %s, com_text = %s, com_created = %u, com_modified = %u, com_uid = %u, com_user = %s, com_email = %s, com_url = %s, com_ip = %s, com_sig = %u, com_itemid = %u, com_rootid = %u, com_status = %u, com_exparams = %s, dohtml = %u, dosmiley = %u, doxcode = %u, doimage = %u, dobr = %u WHERE com_id = %u', $this->db->prefix('xoopscomments'), $com_pid, $this->db->quoteString($com_icon), $this->db->quoteString($com_title), $this->db->quoteString($com_text), $com_created, $com_modified, $com_uid, $this->db->quoteString($com_user), $this->db->quoteString($com_email), $this->db->quoteString($com_url), $this->db->quoteString($com_ip), $com_sig, $com_itemid, $com_rootid, $com_status, $this->db->quoteString($com_exparams), $dohtml, $dosmiley, $doxcode, $doimage, $dobr, $com_id); } // End edit by voltan if (!($result = $this->db->query($sql))) { return false; } if (empty($com_id)) { $com_id = $this->db->getInsertId(); } $comment->assignVar('com_id', $com_id); return true; }
/** * Write a module to the database * * @param XoopsObject|XoopsModule $module a XoopsModule object * * @return bool true on success, otherwise false */ public function insert(XoopsObject $module) { $className = 'XoopsModule'; if (!$module instanceof $className) { return false; } if (!$module->isDirty()) { return true; } if (!$module->cleanVars()) { return false; } foreach ($module->cleanVars as $k => $v) { ${$k} = $v; } if ($module->isNew()) { $mid = $this->db->genId('modules_mid_seq'); $sql = sprintf('INSERT INTO %s (mid, name, version, last_update, weight, isactive, dirname, hasmain, hasadmin, hassearch, hasconfig, hascomments, hasnotification) VALUES (%u, %s, %u, %u, %u, %u, %s, %u, %u, %u, %u, %u, %u)', $this->db->prefix('modules'), $mid, $this->db->quoteString($name), $version, time(), $weight, 1, $this->db->quoteString($dirname), $hasmain, $hasadmin, $hassearch, $hasconfig, $hascomments, $hasnotification); } else { $sql = sprintf('UPDATE %s SET name = %s, dirname = %s, version = %u, last_update = %u, weight = %u, isactive = %u, hasmain = %u, hasadmin = %u, hassearch = %u, hasconfig = %u, hascomments = %u, hasnotification = %u WHERE mid = %u', $this->db->prefix('modules'), $this->db->quoteString($name), $this->db->quoteString($dirname), $version, time(), $weight, $isactive, $hasmain, $hasadmin, $hassearch, $hasconfig, $hascomments, $hasnotification, $mid); } if (!($result = $this->db->query($sql))) { return false; } if (empty($mid)) { $mid = $this->db->getInsertId(); } $module->assignVar('mid', $mid); if (!empty($this->_cachedModule_dirname[$dirname])) { unset($this->_cachedModule_dirname[$dirname]); } if (!empty($this->_cachedModule_mid[$mid])) { unset($this->_cachedModule_mid[$mid]); } return true; }
/** * Insert and Object into the database * * @param XoopsObject|XoopsAvatar $avatar a XoopsAvatar object * * @return bool true on success, otherwise false */ public function insert(XoopsObject $avatar) { $className = 'XoopsAvatar'; if (!$avatar instanceof $className) { return false; } if (!$avatar->isDirty()) { return true; } if (!$avatar->cleanVars()) { return false; } foreach ($avatar->cleanVars as $k => $v) { ${$k} = $v; } if ($avatar->isNew()) { $avatar_id = $this->db->genId('avatar_avatar_id_seq'); $sql = sprintf('INSERT INTO %s (avatar_id, avatar_file, avatar_name, avatar_created, avatar_mimetype, avatar_display, avatar_weight, avatar_type) VALUES (%u, %s, %s, %u, %s, %u, %u, %s)', $this->db->prefix('avatar'), $avatar_id, $this->db->quoteString($avatar_file), $this->db->quoteString($avatar_name), time(), $this->db->quoteString($avatar_mimetype), $avatar_display, $avatar_weight, $this->db->quoteString($avatar_type)); } else { $sql = sprintf('UPDATE %s SET avatar_file = %s, avatar_name = %s, avatar_created = %u, avatar_mimetype= %s, avatar_display = %u, avatar_weight = %u, avatar_type = %s WHERE avatar_id = %u', $this->db->prefix('avatar'), $this->db->quoteString($avatar_file), $this->db->quoteString($avatar_name), $avatar_created, $this->db->quoteString($avatar_mimetype), $avatar_display, $avatar_weight, $this->db->quoteString($avatar_type), $avatar_id); } if (!($result = $this->db->query($sql))) { return false; } if (empty($avatar_id)) { $avatar_id = $this->db->getInsertId(); } $avatar->assignVar('avatar_id', $avatar_id); return true; }
/** * write a new Tplfile into the database * * @param XoopsObject|XoopsTplfile $tplfile a XoopsTplfile object * * @return bool true on success, otherwise false */ public function insert(XoopsObject $tplfile) { $className = 'XoopsTplfile'; if (!$tplfile instanceof $className) { return false; } if (!$tplfile->isDirty()) { return true; } if (!$tplfile->cleanVars()) { return false; } foreach ($tplfile->cleanVars as $k => $v) { ${$k} = $v; } if ($tplfile->isNew()) { $tpl_id = $this->db->genId('tpltpl_file_id_seq'); $sql = sprintf('INSERT INTO %s (tpl_id, tpl_module, tpl_refid, tpl_tplset, tpl_file, tpl_desc, tpl_lastmodified, tpl_lastimported, tpl_type) VALUES (%u, %s, %u, %s, %s, %s, %u, %u, %s)', $this->db->prefix('tplfile'), $tpl_id, $this->db->quoteString($tpl_module), $tpl_refid, $this->db->quoteString($tpl_tplset), $this->db->quoteString($tpl_file), $this->db->quoteString($tpl_desc), $tpl_lastmodified, $tpl_lastimported, $this->db->quoteString($tpl_type)); if (!($result = $this->db->query($sql))) { return false; } if (empty($tpl_id)) { $tpl_id = $this->db->getInsertId(); } if (isset($tpl_source) && $tpl_source != '') { $sql = sprintf('INSERT INTO %s (tpl_id, tpl_source) VALUES (%u, %s)', $this->db->prefix('tplsource'), $tpl_id, $this->db->quoteString($tpl_source)); if (!($result = $this->db->query($sql))) { $this->db->query(sprintf('DELETE FROM %s WHERE tpl_id = %u', $this->db->prefix('tplfile'), $tpl_id)); return false; } } $tplfile->assignVar('tpl_id', $tpl_id); } else { $sql = sprintf('UPDATE %s SET tpl_tplset = %s, tpl_file = %s, tpl_desc = %s, tpl_lastimported = %u, tpl_lastmodified = %u WHERE tpl_id = %u', $this->db->prefix('tplfile'), $this->db->quoteString($tpl_tplset), $this->db->quoteString($tpl_file), $this->db->quoteString($tpl_desc), $tpl_lastimported, $tpl_lastmodified, $tpl_id); if (!($result = $this->db->query($sql))) { return false; } if (isset($tpl_source) && $tpl_source != '') { $sql = sprintf('UPDATE %s SET tpl_source = %s WHERE tpl_id = %u', $this->db->prefix('tplsource'), $this->db->quoteString($tpl_source), $tpl_id); if (!($result = $this->db->query($sql))) { return false; } } } return true; }