/** * Additional data to update after a save call (such as denormalized values in other tables). * In batch updates, is executed for each record updated. * * @param boolean Do the query? */ function post_save_each($doquery = true) { if (!$this->condition) { $activity = new vB_ActivityStream_Manage('calendar', 'event'); $activity->set('contentid', intval($this->fetch_field('eventid'))); $activity->set('userid', intval($this->fetch_field('userid'))); $activity->set('dateline', intval($this->fetch_field('dateline'))); $activity->set('action', 'create'); $activity->save(); } if ($this->condition and $this->fetch_field('dateline_from') - $this->existing['dateline_from'] >= 82800) { // Start date has been pushed up at least 23 hours (this is a bit arbitrary) so reset any reminders that have already been sent $this->dbobject->query_write("\n\t\t\t\tUPDATE " . TABLE_PREFIX . "subscribeevent\n\t\t\t\tSET lastreminder = 0\n\t\t\t\tWHERE eventid = " . intval($this->fetch_field('eventid')) . "\n\t\t\t"); } ($hook = vBulletinHook::fetch_hook('eventdata_postsave')) ? eval($hook) : false; return true; }
/** * Additional data to update after a save call (such as denormalized values in other tables). * In batch updates, is executed for each record updated. * * @param boolean Do the query? */ function post_save_each($doquery = true) { if ($this->condition and $this->fetch_field('state') == 'private' and $this->existing['state'] != 'private') { // making an existing album non-public, get rid of bg images $this->remove_usercss_background_image(); } if (!$this->condition) { $activity = new vB_ActivityStream_Manage('album', 'album'); $activity->set('contentid', $this->fetch_field('albumid')); $activity->set('userid', $this->fetch_field('userid')); $activity->set('dateline', $this->fetch_field('createdate')); $activity->set('action', 'create'); $activity->save(); } ($hook = vBulletinHook::fetch_hook('albumdata_postsave')) ? eval($hook) : false; return true; }
/** * Code to run after Saving a Visitor Message * * @param boolean Do the query? */ function post_save_once($doquery = true) { $vmid = intval($this->fetch_field('vmid')); vB_Search_Indexcontroller_Queue::indexQueue('vBForum', 'VisitorMessage', 'index', $vmid); if (!$this->condition) { if ($this->fetch_field('userid')) { $this->insert_dupehash($this->fetch_field('userid')); } $activity = new vB_ActivityStream_Manage('forum', 'visitormessage'); $activity->set('contentid', $this->fetch_field('vmid')); $activity->set('userid', $this->fetch_field('postuserid')); $activity->set('dateline', $this->fetch_field('dateline')); $activity->set('action', 'create'); $activity->save(); } if (!$this->info['profileuser']) { $this->info['profileuser'] = fetch_userinfo($this->fetch_field('userid')); } if ($this->info['profileuser'] and !in_coventry($this->fetch_field('postuserid'), true)) { $userdata =& datamanager_init('User', $this->registry, ERRTYPE_SILENT); $userdata->set_existing($this->info['profileuser']); if ($this->fetch_field('state') == 'visible') { if (!$this->condition and !$this->fetch_field('messageread')) { // new vm, not been read, visible -> increase unread count $userdata->set('vmunreadcount', 'vmunreadcount + 1', false); } else { if ($this->condition and $this->fetch_field('messageread') and isset($this->existing['messageread']) and !$this->existing['messageread']) { // existing vm going from unread to read -> decrease unread count // isset() check ensures that messageread info was explicitly passed in $userdata->set('vmunreadcount', 'vmunreadcount - 1', false); } } } if ($this->fetch_field('state') == 'visible' and $this->existing['state'] == 'moderation') { // moderated message made visible -> decrease moderated count $userdata->set('vmmoderatedcount', 'vmmoderatedcount - 1', false); } else { if ($this->fetch_field('state') == 'moderation' and $this->fetch_field('state') != $this->existing['state']) { // message is moderated and wasn't moderated before -> increase moderated count $userdata->set('vmmoderatedcount', 'vmmoderatedcount + 1', false); } } $userdata->save(); } if ($this->fetch_field('state') == 'moderation') { /*insert query*/ $this->dbobject->query_write("\n\t\t\t\tINSERT IGNORE INTO " . TABLE_PREFIX . "moderation\n\t\t\t\t\t(primaryid, type, dateline)\n\t\t\t\tVALUES\n\t\t\t\t\t({$vmid}, 'visitormessage', " . TIMENOW . ")\n\t\t\t"); } else { if ($this->fetch_field('state') == 'visible' and $this->existing['state'] == 'moderation') { // message was made visible, remove the moderation record $this->dbobject->query_write("\n\t\t\t\tDELETE FROM " . TABLE_PREFIX . "moderation\n\t\t\t\tWHERE primaryid = {$vmid} AND type = 'visitormessage'\n\t\t\t"); } } ($hook = vBulletinHook::fetch_hook('visitormessagedata_postsave')) ? eval($hook) : false; }
function post_save_each($doquery = true) { if (!$this->condition and $this->fetch_field('dateline') == TIMENOW) { $this->insert_dupehash(0); } $this->post_save_each_post($doquery); if (!$this->condition and $this->fetch_field('dateline') == TIMENOW) { $this->insert_postlog_data(); } $threadid = intval($this->fetch_field('threadid')); if (!$this->condition and !$this->info['skip_activitystream']) { $activity = new vB_ActivityStream_Manage('forum', 'thread'); $activity->set('contentid', $threadid); $activity->set('userid', $this->fetch_field('postuserid')); $activity->set('dateline', $this->fetch_field('dateline')); $activity->set('action', 'create'); $activity->save(); } if ($this->thread['visible'] === 0) { $postid = intval($this->fetch_field('firstpostid')); /*insert query*/ $this->dbobject->query_write("INSERT IGNORE INTO " . TABLE_PREFIX . "moderation (primaryid, type, dateline) VALUES ({$threadid}, 'thread', " . TIMENOW . ")"); } if ($this->info['forum']['podcast'] and $postid = intval($this->fetch_field('firstpostid'))) { $this->dbobject->query_write("\n\t\t\t\tREPLACE INTO " . TABLE_PREFIX . "podcastitem\n\t\t\t\t\t(postid, url, length, explicit, author, keywords, subtitle)\n\t\t\t\tVALUES\n\t\t\t\t\t(\n\t\t\t\t\t\t{$postid},\n\t\t\t\t\t\t'" . $this->dbobject->escape_string($this->info['podcasturl']) . "',\n\t\t\t\t\t\t" . intval($this->info['podcastsize']) . ",\n\t\t\t\t\t\t" . intval($this->info['podcastexplicit']) . ",\n\t\t\t\t\t\t'" . $this->dbobject->escape_string($this->info['podcastauthor']) . "',\n\t\t\t\t\t\t'" . $this->dbobject->escape_string($this->info['podcastkeywords']) . "',\n\t\t\t\t\t\t'" . $this->dbobject->escape_string($this->info['podcastsubtitle']) . "'\n\t\t\t\t\t)\n\t\t\t"); // reset rss cache for this forum $this->dbobject->query_write("\n\t\t\t\tDELETE FROM " . TABLE_PREFIX . "externalcache\n\t\t\t\tWHERE forumid = " . intval($this->info['forum']['forumid']) . "\n\t\t\t"); } if ($this->info['mark_thread_read'] and $this->info['forum'] and $this->registry->options['threadmarking'] and $userid = $this->fetch_field('postuserid')) { $threadinfo = fetch_threadinfo($threadid); if ($threadinfo) { require_once DIR . '/includes/functions_bigthree.php'; mark_thread_read($threadinfo, $this->info['forum'], $userid, $this->fetch_field('dateline')); } } $this->insert_moderator_log(); if (!$this->condition) { $this->email_moderators(array('newthreademail', 'newpostemail')); } ($hook = vBulletinHook::fetch_hook('threadfpdata_postsave')) ? eval($hook) : false; }
/** * * @param boolean Do the query? */ function post_save_once($doquery = true) { $gmid = intval($this->fetch_field('gmid')); $discussionid = intval($this->fetch_field('discussionid')); if (!$this->condition) { if ($this->fetch_field('discussionid')) { $this->insert_dupehash($this->fetch_field('discussionid')); } // Update last post info on parent discussion if ($this->info['discussion']) { $dataman =& datamanager_init('Discussion', $this->registry, ERRTYPE_SILENT); $dataman->set_existing($this->info['discussion']); // Give group info to discussion if ($this->info['group']) { $dataman->setr_info('group', $this->info['group']); } if ($this->fetch_field('state') == 'visible' and $this->fetch_field('dateline') == TIMENOW) { $dataman->set('lastpost', TIMENOW); $dataman->set('lastposter', $this->fetch_field('postusername')); $dataman->set('lastposterid', $this->fetch_field('postuserid')); $dataman->set('lastpostid', $gmid); $dataman->set_info('lastposttitle', $this->info['discussion']['title']); } if ($this->fetch_field('state') == 'visible') { $dataman->set('visible', 'visible + 1', false); } else { if ($this->fetch_field('state') == 'moderation') { $dataman->set('moderation', 'moderation + 1', false); } } $dataman->save(); unset($dataman); $activity = new vB_ActivityStream_Manage('socialgroup', 'groupmessage'); $activity->set('contentid', $gmid); $activity->set('userid', $this->fetch_field('postuserid')); $activity->set('dateline', $this->fetch_field('dateline')); $activity->set('action', 'create'); $activity->save(); } } if ($this->fetch_field('state') == 'moderation') { /*insert query*/ $this->dbobject->query_write("INSERT IGNORE INTO " . TABLE_PREFIX . "moderation (primaryid, type, dateline) VALUES ({$gmid}, 'groupmessage', " . TIMENOW . ")"); } else { if ($this->fetch_field('state') == 'visible' and $this->existing['state'] == 'moderation') { // message was made visible, remove the moderation record $this->dbobject->query_write("\n\t\t\t\tDELETE FROM " . TABLE_PREFIX . "moderation\n\t\t\t\tWHERE primaryid = {$gmid} AND type = 'groupmessage'\n\t\t\t"); } } if ($this->info['group']) { update_owner_pending_gm_count($this->info['group']['creatoruserid']); } ($hook = vBulletinHook::fetch_hook('groupmessagedata_postsave')) ? eval($hook) : false; }
/** * Runs any extra actions after saving all. * * @access protected * * @param boolean $doquery Do the query? */ function post_save_once($doquery = true) { $discussionid = intval($this->fetch_field('discussionid')); $groupid = intval($this->fetch_field('groupid')); $new_discussion = (!$this->condition and $this->fetch_field('lastpostid') == $this->fetch_field('firstpostid')); // If new discussion and info['updatefirstpost'] then update the firstpost to this discussion if ($new_discussion) { // set discussionid on new (now saved and existing) message $this->registry->db->query_write("\n\t\t\t\tUPDATE " . TABLE_PREFIX . "groupmessage\n\t\t\t\tSET discussionid = " . $discussionid . "\n\t\t\t\tWHERE gmid = " . intval($this->fetch_field('firstpostid')) . " \n\t\t\t\tAND discussionid = 0"); $activity = new vB_ActivityStream_Manage('socialgroup', 'discussion'); $activity->set('contentid', $this->fetch_field('discussionid')); $activity->set('userid', $this->fetch_field('lastposterid')); $activity->set('dateline', $this->fetch_field['lastpost'] ? $this->fetch_field['lastpost'] : TIMENOW); $activity->set('action', 'create'); $activity->save(); } $update_counters = (isset($this->rawfields['visible']) or isset($this->rawfields['moderation']) or isset($this->rawfields['deleted'])); // If last post has changed, update parent group if ($update_counters or isset($this->setfields['lastpost']) and isset($this->info['group']['groupid'])) { $dataman =& datamanager_init('SocialGroup', $this->registry, ERRTYPE_SILENT); $dataman->set_existing($this->info['group']); if (isset($this->setfields['lastpost']) and $this->fetch_field('lastpost') == TIMENOW) { $dataman->set('lastpost', TIMENOW); $dataman->set('lastgmid', $this->fetch_field('lastpostid')); $dataman->set('lastposter', $this->fetch_field('lastposter')); $dataman->set('lastposterid', $this->fetch_field('lastposterid')); $dataman->set('lastdiscussionid', $this->fetch_field('discussionid')); $dataman->set('lastupdate', TIMENOW); if (isset($this->info['lastposttitle'])) { $dataman->set('lastdiscussion', $this->info['lastposttitle']); } } if ($this->condition) { // check if moderated, deleted or visible was delta modified (visible = visible + 1) and repro on the group foreach (array('visible', 'moderation', 'deleted') as $counter) { if (isset($this->rawfields[$counter]) and isset($this->setfields[$counter]) and isset($this->{$this->table}[$counter])) { $dataman->set($counter, $this->{$this->table}[$counter], false); } } } else { if ($new_discussion) { if ($this->setfields['visible'] == 1) { $dataman->set('discussions', 'discussions + 1', false); $dataman->set('visible', 'visible + 1', false); $dataman->set('lastupdate', TIMENOW); } else { $dataman->set('moderation', 'moderation + 1', false); } } } $dataman->save(); unset($dataman); } // Update pending count for group owner if ($this->info['group']) { $this->update_owner_pending_gm_count($this->info['group']['creatoruserid']); } ($hook = vBulletinHook::fetch_hook('groupmessagedata_postsave')) ? eval($hook) : false; }
/** * Additional data to update after a save call (such as denormalized values in other tables). * * @param boolean Do the query? */ function post_save_each($doquery = true) { // When creating a group, the creator needs to be come a user automatically if (empty($this->condition)) { $socialgroupmemberdm = datamanager_init('SocialGroupMember', $this->registry, ERRTYPE_STANDARD); $socialgroupmemberdm->set('userid', $this->fetch_field('creatoruserid')); $socialgroupmemberdm->set('groupid', $this->fetch_field('groupid')); $socialgroupmemberdm->set('dateline', $this->fetch_field('dateline')); $socialgroupmemberdm->set('type', 'member'); $socialgroupmemberdm->save(); unset($socialgroupmemberdm); exec_sg_mark_as_read('group', $this->fetch_field('groupid')); $activity = new vB_ActivityStream_Manage('socialgroup', 'group'); $activity->set('contentid', $this->fetch_field('groupid')); $activity->set('userid', $this->fetch_field('creatoruserid')); $activity->set('dateline', $this->fetch_field('dateline')); $activity->set('action', 'create'); $activity->save(); } ($hook = vBulletinHook::fetch_hook('socgroupdata_postsave')) ? eval($hook) : false; if ($this->fetch_field('socialgroupcategoryid') != $this->existing['socialgroupcategoryid']) { fetch_socialgroup_category_cloud(true); } if ($this->fetch_field('name') != $this->existing['name'] or $this->fetch_field('description') != $this->existing['description']) { fetch_socialgroup_newest_groups(true, false, !$this->registry->options['sg_enablesocialgroupicons']); } vb_Search_Indexcontroller_Queue::indexQueue('vBForum', 'SocialGroup', 'index', $this->fetch_field('groupid')); }
$changed_groups = array(); $groups_sql = $db->query_read("\n\t\t\tSELECT\n\t\t\t\tsocialgroup.*, IF(attachment.filedataid IS NULL, 0, 1) AS picingroup,\n\t\t\t\tattachment.filedataid, attachment.filename\n\t\t\tFROM " . TABLE_PREFIX . "socialgroup AS socialgroup\n\t\t\tINNER JOIN " . TABLE_PREFIX . "socialgroupmember AS socialgroupmember ON\n\t\t\t\t(\n\t\t\t\t\tsocialgroupmember.groupid = socialgroup.groupid\n\t\t\t\t\t\tAND\n\t\t\t\t\tsocialgroupmember.userid = {$userinfo['userid']}\n\t\t\t\t)\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "attachment AS attachment ON\n\t\t\t\t(\n\t\t\t\t\tattachment.contenttypeid = " . intval(vB_Types::instance()->getContentTypeID('vBForum_SocialGroup')) . "\n\t\t\t\t\t\tAND\n\t\t\t\t\tsocialgroup.groupid = attachment.contentid\n\t\t\t\t\t\tAND\n\t\t\t\t\tattachment.filedataid = {$pictureinfo['filedataid']}\n\t\t\t\t\t\tAND\n\t\t\t\t\tattachment.userid = {$userinfo['userid']}\n\t\t\t\t)\n\t\t\tWHERE\n\t\t\t\tsocialgroup.groupid IN (" . implode(',', $vbulletin->GPC['groupsshown']) . ")\n\t\t\t\t\tAND\n\t\t\t\tsocialgroupmember.type = 'member'\n\t\t\t\t\tAND\n\t\t\t\tsocialgroup.options & " . $vbulletin->bf_misc_socialgroupoptions['enable_group_albums'] . "\n\t\t"); while ($group = $db->fetch_array($groups_sql)) { if (!empty($vbulletin->GPC['groupids']["{$group['groupid']}"]) and !$group['picingroup']) { // Yes this does single inserts on purpose // An atomic check since we can't put an unique key on the attachment table but we don't want the same attachment getting into the group more than once. if (!$db->query_first("\n\t\t\t\t\tSELECT attachmentid\n\t\t\t\t\tFROM " . TABLE_PREFIX . "attachment\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tcontenttypeid = " . intval(vB_Types::instance()->getContentTypeID('vBForum_SocialGroup')) . "\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\tuserid = {$userinfo['userid']}\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\tcontentid = {$group['groupid']}\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\tfiledataid = {$pictureinfo['filedataid']}\n\t\t\t\t")) { $db->query_write("\n\t\t\t\t\t\tINSERT IGNORE INTO " . TABLE_PREFIX . "attachment\n\t\t\t\t\t\t\t(contenttypeid, contentid, userid, dateline, filedataid, filename, caption)\n\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t(" . intval(vB_Types::instance()->getContentTypeID('vBForum_SocialGroup')) . ", {$group['groupid']}, {$userinfo['userid']}, " . TIMENOW . ", {$pictureinfo['filedataid']}, '" . $db->escape_string($pictureinfo['filename']) . "', '" . $db->escape_string($pictureinfo['caption']) . "')\n\t\t\t\t\t"); $changed_groups["{$group['groupid']}"] = $group; $attachmentid = $db->insert_id(); $activity = new vB_ActivityStream_Manage('socialgroup', 'photo'); $activity->set('contentid', $attachmentid); $activity->set('userid', $userinfo[userid]); $activity->set('dateline', TIMENOW); $activity->set('action', 'create'); $activity->save(); } } else { if (empty($vbulletin->GPC['groupids']["{$group['groupid']}"]) and $group['picingroup']) { $delete[] = $group['groupid']; $changed_groups["{$group['groupid']}"] = $group; } } } ($hook = vBulletinHook::fetch_hook('album_picture_doaddgroups')) ? eval($hook) : false; if ($delete) { $db->query_write("\n\t\t\t\tDELETE FROM " . TABLE_PREFIX . "attachment\n\t\t\t\tWHERE\n\t\t\t\t\tfiledataid = {$pictureinfo['filedataid']}\n\t\t\t\t\t\tAND\n\t\t\t\t\tcontentid IN (" . implode(',', $delete) . ")\n\t\t\t\t\t\tAND\n\t\t\t\t\tcontenttypeid = " . intval(vB_Types::instance()->getContentTypeID('vBForum_SocialGroup')) . "\n\t\t\t\t\t\tAND\n\t\t\t\t\tuserid = {$userinfo['userid']}\n\t\t\t"); } foreach ($changed_groups as $group) { $groupdm =& datamanager_init('SocialGroup', $vbulletin, ERRTYPE_STANDARD); $groupdm->set_existing($group);
/** * Code to run after saving a picture comment * * @param boolean Do the query? */ function post_save_once($doquery = true) { $commentid = intval($this->fetch_field('commentid')); if (!$this->condition) { if ($this->fetch_field('filedataid') and $this->fetch_field('userid')) { $this->insert_dupehash($this->fetch_field('filedataid'), $this->fetch_field('userid')); } if ($this->info['pictureuser'] and !in_coventry($this->fetch_field('postuserid'), true)) { $userdata =& datamanager_init('User', $this->registry, ERRTYPE_STANDARD); $userdata->set_existing($this->info['pictureuser']); if (!$this->fetch_field('messageread') and $this->fetch_field('state') == 'visible') { $userdata->set('pcunreadcount', 'pcunreadcount + 1', false); } else { if ($this->fetch_field('state') == 'moderation') { $userdata->set('pcmoderatedcount', 'pcmoderatedcount + 1', false); } } $userdata->save(); } if ($this->info['pictureinfo']['groupid']) { $section = 'socialgroup'; $type = 'photocomment'; } else { if ($this->info['pictureinfo']['albumid']) { $section = 'album'; $type = 'comment'; } else { ($hook = vBulletinHook::fetch_hook('picturecommentdata_postsave_activitystream')) ? eval($hook) : false; } } if ($section and $type) { $activity = new vB_ActivityStream_Manage($section, $type); $activity->set('contentid', $commentid); $activity->set('userid', $this->fetch_field('postuserid')); $activity->set('dateline', $this->fetch_field('dateline')); $activity->set('action', 'create'); $activity->save(); } } if ($this->fetch_field('state') == 'moderation') { /*insert query*/ $this->dbobject->query_write("\n\t\t\t\tINSERT IGNORE INTO " . TABLE_PREFIX . "moderation\n\t\t\t\t\t(primaryid, type, dateline)\n\t\t\t\tVALUES\n\t\t\t\t\t({$commentid}, 'picturecomment', " . TIMENOW . ")\n\t\t\t"); } ($hook = vBulletinHook::fetch_hook('picturecommentdata_postsave')) ? eval($hook) : false; }