本文整理汇总了PHP中XoopsPersistableObjectHandler::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP XoopsPersistableObjectHandler::insert方法的具体用法?PHP XoopsPersistableObjectHandler::insert怎么用?PHP XoopsPersistableObjectHandler::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XoopsPersistableObjectHandler
的用法示例。
在下文中一共展示了XoopsPersistableObjectHandler::insert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: insert
function insert(&$object, $force = true)
{
if ($ret = parent::insert($object, $force)) {
$object->unsetNew();
}
return $ret;
}
示例2: insert
function insert(&$category)
{
parent::insert($category, true);
if ($category->isNew()) {
$this->applyPermissionTemplate($category);
}
return $category->getVar('cat_id');
}
示例3: insert
function insert(&$forum)
{
if (!parent::insert($forum, true)) {
return false;
}
if ($forum->isNew()) {
$this->applyPermissionTemplate($forum);
}
return $forum->getVar('forum_id');
}
示例4: insert
/**
* @param object $obj
*
* @return mixed
*/
function insert($obj)
{
$obj->setVar('last_modified', time());
return parent::insert($obj);
}
示例5: insert
function insert($obj, $force = true)
{
error_reporting(E_ALL);
xoops_load('cache');
$read = XoopsCache::read('spider_id%%' . $obj->getVar('id'));
if (!is_array($read)) {
$value = '0A';
} else {
$value = $read['value'];
}
$value++;
$read = XoopsCache::delete('spider_id%%' . $obj->getVar('id'));
$read = XoopsCache::write('spider_id%%' . $obj->getVar('id'), array('value' => $value));
$modulehandler =& xoops_gethandler('module');
$confighandler =& xoops_gethandler('config');
$xoModule = $modulehandler->getByDirname('spiders');
$xoConfig = $confighandler->getConfigList($xoModule->getVar('mid'), false);
if ($xoConfig['xortify_shareme'] == true) {
// Connect to API
$api = $this->apimethod();
include_once $GLOBALS['xoops']->path('/modules/spiders/class/' . $api . '.php');
$func = strtoupper($api) . 'SpidersExchange';
$exchange = new $func();
//Form Associated Array
$spiders_handler =& xoops_getmodulehandler('spiders', 'spiders');
$spider = $spiders_handler->get($obj->getVar('id'));
$ret = array();
$ret['useragent'] = $obj->getVar('useragent');
$ret['netaddy'] = $obj->getVar('netaddy');
$ret['ip'] = $obj->getVar('ip');
$ret['server-ip'] = isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : $_SERVER['LOCAL_ADDR'];
$obj->setVar('server-ip', isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : $_SERVER['LOCAL_ADDR']);
$ret['when'] = $obj->getVar('when');
$ret['uri'] = $obj->getVar('uri');
$ret['sitename'] = $GLOBALS['xoopsConfig']['sitename'];
$ret['robot-name'] = $spider->getVar('robot-name');
$ret['robot-id'] = $spider->getVar('robot-id');
//Send to API
$exchange->sendStatistic($ret);
}
// Clear Statistics - Save on database size
$modulehandler = xoops_gethandler('module');
$confighandler = xoops_gethandler('config');
$xoMod = $modulehandler->getByDirname('spiders');
$xoConfig = $confighandler->getConfigList($xoMod->getVar('mid'));
$criteria = new Criteria('when', time() - $xoConfig['weeks_stats'] * (60 * 60 * 24 * 7), '<');
$this->deleteAll($criteria, true);
return parent::insert($obj, $force);
}
示例6: insert
/**
* save a profile field in the database
*
* @param object $obj reference to the object
* @param bool $force whether to force the query execution despite security settings
* @param bool $checkObject check if the object is dirty and clean the attributes
* @return bool FALSE if failed, TRUE if already present and unchanged or successful
*/
function insert(&$obj, $force = false)
{
$profile_handler =& xoops_getmodulehandler('profile', 'profile');
$obj->setVar('field_name', str_replace(' ', '_', $obj->getVar('field_name')));
$obj->cleanVars();
$defaultstring = "";
switch ($obj->getVar('field_type')) {
case "datetime":
case "date":
$obj->setVar('field_valuetype', XOBJ_DTYPE_INT);
$obj->setVar('field_maxlength', 10);
break;
case "longdate":
$obj->setVar('field_valuetype', XOBJ_DTYPE_MTIME);
break;
case "yesno":
$obj->setVar('field_valuetype', XOBJ_DTYPE_INT);
$obj->setVar('field_maxlength', 1);
break;
case "textbox":
if ($obj->getVar('field_valuetype') != XOBJ_DTYPE_INT) {
$obj->setVar('field_valuetype', XOBJ_DTYPE_TXTBOX);
}
break;
case "autotext":
if ($obj->getVar('field_valuetype') != XOBJ_DTYPE_INT) {
$obj->setVar('field_valuetype', XOBJ_DTYPE_TXTAREA);
}
break;
case "group_multi":
case "select_multi":
case "checkbox":
$obj->setVar('field_valuetype', XOBJ_DTYPE_ARRAY);
break;
case "language":
case "timezone":
case "theme":
$obj->setVar('field_valuetype', XOBJ_DTYPE_TXTBOX);
break;
case "dhtml":
case "textarea":
$obj->setVar('field_valuetype', XOBJ_DTYPE_TXTAREA);
break;
}
if ($obj->getVar('field_valuetype') == "") {
$obj->setVar('field_valuetype', XOBJ_DTYPE_TXTBOX);
}
if (!in_array($obj->getVar('field_name'), $this->getUserVars())) {
if ($obj->isNew()) {
//add column to table
$changetype = "ADD";
} else {
//update column information
$changetype = "CHANGE `" . $obj->getVar('field_name', 'n') . "`";
}
$maxlengthstring = $obj->getVar('field_maxlength') > 0 ? "(" . $obj->getVar('field_maxlength') . ")" : "";
//set type
switch ($obj->getVar('field_valuetype')) {
default:
case XOBJ_DTYPE_ARRAY:
case XOBJ_DTYPE_UNICODE_ARRAY:
$type = "mediumtext";
break;
case XOBJ_DTYPE_UNICODE_EMAIL:
case XOBJ_DTYPE_UNICODE_TXTBOX:
case XOBJ_DTYPE_UNICODE_URL:
case XOBJ_DTYPE_EMAIL:
case XOBJ_DTYPE_TXTBOX:
case XOBJ_DTYPE_URL:
$type = "varchar";
// varchars must have a maxlength
if (!$maxlengthstring) {
//so set it to max if maxlength is not set - or should it fail?
$maxlengthstring = "(255)";
$obj->setVar('field_maxlength', 255);
}
break;
case XOBJ_DTYPE_INT:
$type = "int";
break;
case XOBJ_DTYPE_DECIMAL:
$type = "decimal(14,6)";
break;
case XOBJ_DTYPE_FLOAT:
$type = "float(15,9)";
break;
case XOBJ_DTYPE_OTHER:
case XOBJ_DTYPE_UNICODE_TXTAREA:
case XOBJ_DTYPE_TXTAREA:
$type = "text";
$maxlengthstring = "";
break;
//.........这里部分代码省略.........
示例7: insert
/**
* insert a new field in the database
*
* @param XoopsObject $field reference to the {@link TDMCreateFields} object
* @param bool $force
*
* @return bool FALSE if failed, TRUE if already present and unchanged or successful
*/
public function insert(XoopsObject $field, $force = false)
{
if (!parent::insert($field, $force)) {
return false;
}
return true;
}
示例8: insert
/**
* insert a new category in the database
*
* @param object $category reference to the {@link PublisherCategory} object
* @param bool $force
*
* @return bool FALSE if failed, TRUE if already present and unchanged or successful
*/
public function insert(&$category, $force = false)
{
// Auto create meta tags if empty
if (!$category->meta_keywords() || !$category->meta_description()) {
$publisherMetagen = new PublisherMetagen($category->name(), $category->getVar('meta_keywords'), $category->getVar('description'));
if (!$category->meta_keywords()) {
$category->setVar('meta_keywords', $publisherMetagen->keywords);
}
if (!$category->meta_description()) {
$category->setVar('meta_description', $publisherMetagen->description);
}
}
// Auto create short_url if empty
if (!$category->short_url()) {
$category->setVar('short_url', PublisherMetagen::generateSeoTitle($category->name('n'), false));
}
$ret = parent::insert($category, $force);
return $ret;
}
示例9: insert
/**
* insert a new object in the database
*
* @param object $obj reference to the object
* @param bool $force whether to force the query execution despite security settings
* @param bool $checkObject check if the object is dirty and clean the attributes
*
* @return bool FALSE if failed, TRUE if already present and unchanged or successful
*/
function insert(&$obj, $force = false, $checkObject = true)
{
$uservars = $this->getUserVars();
foreach ($uservars as $var) {
unset($obj->vars[$var]);
}
if (count($obj->vars) == 0) {
return true;
}
return parent::insert($obj, $force, $checkObject);
}
示例10: insert
/**
* @param XoopsObject|ArtObject $object
* @param bool $force
*
* @return mixed
*/
public function insert(XoopsObject $object, $force = true)
{
if (!$object instanceof $this->className) {
return false;
}
if ($ret = parent::insert($object, $force)) {
$object->unsetNew();
}
return $ret;
}
示例11: insert
/**
* save a profile field in the database
*
* @param XoopsObject|ProfileField $obj reference to the object
* @param bool $force whether to force the query execution despite security settings
*
* @internal param bool $checkObject check if the object is dirty and clean the attributes
* @return bool FALSE if failed, TRUE if already present and unchanged or successful
*/
public function insert(XoopsObject $obj, $force = false)
{
if (!$obj instanceof $this->className) {
return false;
}
$profile_handler = xoops_getModuleHandler('profile', 'profile');
$obj->setVar('field_name', str_replace(' ', '_', $obj->getVar('field_name')));
$obj->cleanVars();
$defaultstring = '';
switch ($obj->getVar('field_type')) {
case 'datetime':
case 'date':
$obj->setVar('field_valuetype', XOBJ_DTYPE_INT);
$obj->setVar('field_maxlength', 10);
break;
case 'longdate':
$obj->setVar('field_valuetype', XOBJ_DTYPE_MTIME);
break;
case 'yesno':
$obj->setVar('field_valuetype', XOBJ_DTYPE_INT);
$obj->setVar('field_maxlength', 1);
break;
case 'textbox':
if ($obj->getVar('field_valuetype') != XOBJ_DTYPE_INT) {
$obj->setVar('field_valuetype', XOBJ_DTYPE_TXTBOX);
}
break;
case 'autotext':
if ($obj->getVar('field_valuetype') != XOBJ_DTYPE_INT) {
$obj->setVar('field_valuetype', XOBJ_DTYPE_TXTAREA);
}
break;
case 'group_multi':
case 'select_multi':
case 'checkbox':
$obj->setVar('field_valuetype', XOBJ_DTYPE_ARRAY);
break;
case 'language':
case 'timezone':
case 'theme':
$obj->setVar('field_valuetype', XOBJ_DTYPE_TXTBOX);
break;
case 'dhtml':
case 'textarea':
$obj->setVar('field_valuetype', XOBJ_DTYPE_TXTAREA);
break;
}
if ($obj->getVar('field_valuetype') === '') {
$obj->setVar('field_valuetype', XOBJ_DTYPE_TXTBOX);
}
if (!in_array($obj->getVar('field_name'), $this->getUserVars()) && isset($_REQUEST['field_required'])) {
if ($obj->isNew()) {
//add column to table
$changetype = 'ADD';
} else {
//update column information
$changetype = 'CHANGE `' . $obj->getVar('field_name', 'n') . '`';
}
$maxlengthstring = $obj->getVar('field_maxlength') > 0 ? '(' . $obj->getVar('field_maxlength') . ')' : '';
//set type
switch ($obj->getVar('field_valuetype')) {
default:
case XOBJ_DTYPE_ARRAY:
case XOBJ_DTYPE_UNICODE_ARRAY:
$type = 'mediumtext';
break;
case XOBJ_DTYPE_UNICODE_EMAIL:
case XOBJ_DTYPE_UNICODE_TXTBOX:
case XOBJ_DTYPE_UNICODE_URL:
case XOBJ_DTYPE_EMAIL:
case XOBJ_DTYPE_TXTBOX:
case XOBJ_DTYPE_URL:
$type = 'varchar';
// varchars must have a maxlength
if (!$maxlengthstring) {
//so set it to max if maxlength is not set - or should it fail?
$maxlengthstring = '(255)';
$obj->setVar('field_maxlength', 255);
}
break;
case XOBJ_DTYPE_INT:
$type = 'int';
break;
case XOBJ_DTYPE_DECIMAL:
$type = 'decimal(14,6)';
break;
case XOBJ_DTYPE_FLOAT:
$type = 'float(15,9)';
break;
case XOBJ_DTYPE_OTHER:
case XOBJ_DTYPE_UNICODE_TXTAREA:
//.........这里部分代码省略.........
示例12: intval
function setRead_db($read_item, $post_id, $uid)
{
if (empty($uid)) {
if (is_object($GLOBALS["xoopsUser"])) {
$uid = $GLOBALS["xoopsUser"]->getVar("uid");
} else {
return false;
}
}
$sql = "UPDATE " . $this->table . " SET post_id = " . intval($post_id) . "," . " read_time =" . time() . " WHERE read_item = " . intval($read_item) . " AND uid = " . intval($uid);
if ($this->db->queryF($sql) && $this->db->getAffectedRows()) {
return true;
}
$object =& $this->create();
$object->setVar("read_item", $read_item, true);
$object->setVar("post_id", $post_id, true);
$object->setVar("uid", $uid, true);
$object->setVar("read_time", time(), true);
return parent::insert($object);
}
示例13: insert
/**
* insert a new object in the database
*
* @param XoopsObject|ProfileProfile $obj reference to the object
* @param bool $force whether to force the query execution despite security settings
*
* @return bool FALSE if failed, TRUE if already present and unchanged or successful
*/
public function insert(\Xoops\Core\Kernel\XoopsObject $obj, $force = false)
{
$uservars = $this->getUserVars();
foreach ($uservars as $var) {
unset($obj->vars[$var]);
}
if (count($obj->vars) == 0) {
return true;
}
return parent::insert($obj, $force);
}
示例14: insert
/**
* @param XoopsObject|SystemBlock $obj
*
* @return int|bool object id on success, otherwise false
*/
public function insert(XoopsObject $obj, $force = true)
{
if (!$obj instanceof $this->className) {
return false;
}
$obj->setVar('last_modified', time());
return parent::insert($obj, $force);
}
示例15: insert
function insert(&$object, $force = true)
{
if (!$object->getVar("topic_time")) {
$object->setVar("topic_time", time());
}
if (!parent::insert($object, $force) || !$object->getVar("approved")) {
return $object->getVar("topic_id");
}
require_once XOOPS_ROOT_PATH . "/modules/newbb/include/functions.config.php";
$newbbConfig = newbb_loadConfig();
if (!empty($newbbConfig['do_tag']) && @(include_once XOOPS_ROOT_PATH . "/modules/tag/include/functions.php")) {
if ($tag_handler = tag_getTagHandler()) {
$tag_handler->updateByItem($object->getVar('topic_tags', 'n'), $object->getVar('topic_id'), "newbb");
}
}
return $object->getVar("topic_id");
}