/** * レコードの保存 * * @param object &$record {@link WordPressUser} object * @param bool $force POSTメソッド以外で強制更新する場合はture * * @return bool 成功の時は TRUE */ function insert(&$record, $force = false, $updateOnlyChanged = false, $mod_name = '') { $member_handler =& xoops_gethandler('member'); $member =& $member_handler->getUser($record->getVar('ID')); if ($record->isNew()) { if (!$mod_name) { return false; } $user_level = 0; $group = $member->getGroups(); $edit_groups = get_xoops_option($mod_name, 'wp_edit_authgrp'); $admin_groups = get_xoops_option($mod_name, 'wp_admin_authgrp'); if (count(array_intersect($group, $edit_groups)) > 0) { $user_level = 1; } if (count(array_intersect($group, $admin_groups)) > 0) { $user_level = 10; } $record->setVar('user_login', $member->getVar('uname')); $record->setVar('user_email', $member->getVar('email')); $record->setVar('user_url', $member->getVar('url')); $record->setVar('user_level', $user_level); $record->setVar('user_icq', intval($member->getVar('user_icq'))); $record->setVar('user_aim', $member->getVar('user_aim')); $record->setVar('user_yim', $member->getVar('user_yim')); $record->setVar('user_msn', $member->getVar('user_msnm')); } else { if ($member->getVar('uname') != $record->getVar('user_login')) { $record->setVar('user_login', $member->getVar('uname')); } } return parent::insert($record, $force, $updateOnlyChanged); }
/** * レコードの保存 * * @param object &$record {@link WordPressPost} object * @param bool $force POSTメソッド以外で強制更新する場合はture * * @return bool 成功の時は TRUE */ function insert(&$record, $force = false, $updateOnlyChanged = false) { $record->setVar('post_modified', current_time('mysql'), true); if ($result = parent::insert($record, $force, $updateOnlyChanged)) { if (trim($record->getVar('post_name')) == '') { $record->setVar('post_name', "post-" . $record->getVar('ID'), true); $record->unsetNew(); return parent::insert($record, $force, true); } } return $result; }
/** * レコードの保存 * * @param object &$record {@link WordPressPost} object * @param bool $force POSTメソッド以外で強制更新する場合はture * * @return bool 成功の時は TRUE */ function insert(&$record, $force = false, $updateOnlyChanged = false) { $record->setVar('post_modified', current_time('mysql', 0), true); if (trim($record->getVar('post_name')) != '') { $post_name = strtolower($record->getVar('post_name')); $criteria =& new CriteriaCompo(new Criteria('post_name', $record->getVar('post_name'))); $criteria->add(new Criteria('ID', $record->getVar('ID'), '!='), 'AND'); $objects =& $this->getObjects($criteria); $suffix = 2; while (count($objects)) { $post_name = strtolower($record->getVar('post_name')) . '_' . $suffix; $criteria =& new CriteriaCompo(new Criteria('post_name', $post_name)); $criteria->add(new Criteria('ID', $record->getVar('ID'), '!='), 'AND'); $objects =& $this->getObjects($criteria); $suffix++; } $record->setVar('post_name', $post_name, true); } if ($result = parent::insert($record, $force, $updateOnlyChanged)) { if (trim($record->getVar('post_name')) == '') { $record->setVar('post_name', "post-" . $record->getVar('ID'), true); $record->unsetNew(); return parent::insert($record, $force, true); } } return $result; }
/** * レコードの保存 * * @param object &$record {@link WordPressUser} object * @param bool $force POSTメソッド以外で強制更新する場合はture * * @return bool 成功の時は TRUE */ function insert(&$record, $force = false, $updateOnlyChanged = false) { $member =& $this->member_handler->getUser($record->getVar('ID')); if ($record->isNew()) { if ($member) { $user_level = 0; $group = $member->getGroups(); $edit_groups = get_xoops_option($this->module, 'wp_edit_authgrp'); $admin_groups = get_xoops_option($this->module, 'wp_admin_authgrp'); if (count(array_intersect($group, $edit_groups)) > 0) { $user_level = 1; } if (count(array_intersect($group, $admin_groups)) > 0) { $user_level = 10; } $record->setVar('user_login', $member->getVar('uname', 'n'), true); $record->setVar('user_nickname', $member->getVar('uname', 'n'), true); $record->assignVar('user_email', $member->getVar('email', 'n')); $record->assignVar('user_url', $member->getVar('url', 'n')); $record->setVar('user_level', $user_level, true); $record->setVar('user_icq', intval($member->getVar('user_icq', 'n')), true); $record->setVar('user_aim', $member->getVar('user_aim', 'n'), true); $record->setVar('user_yim', $member->getVar('user_yim', 'n'), true); $record->setVar('user_msn', $member->getVar('user_msnm', 'n'), true); $record->setVar('user_idmode', 'nickname', true); } else { return false; } } else { if ($member) { if ($member->getVar('uname') != $record->getVar('user_login', 'n')) { $record->setVar('user_login', $member->getVar('uname', 'n'), true); } if (trim($record->getVar('user_nickname')) == '') { $record->setVar('user_nickname', $member->getVar('uname', 'n'), true); } } } return parent::insert($record, $force, $updateOnlyChanged); }
/** * レコードの保存 * * @param object &$record {@link WordPressCategory} object * @param bool $force POSTメソッド以外で強制更新する場合はture * * @return bool 成功の時は TRUE */ function insert(&$record, $force = false, $updateOnlyChanged = false) { //cat_nameが同名のカテゴリが存在するときはエラー if ($record->isNew() && $this->getCount(new Criteria('cat_name', $record->getVar('cat_name')))) { $this->setError('Duplicate category name (' . $record->getVar('cat_name') . ')'); return false; } if ($result = parent::insert($record, $force, $updateOnlyChanged)) { if (trim($record->getVar('category_nicename')) == '') { $record->setVar('category_nicename', "category-" . $record->getVar('cat_ID')); $record->unsetNew(); return parent::insert($record, $force, true); } } $this->_cache_by_nicename = array(); return $result; }