function delete()
 {
     if ($this->fetch_field('type') == 'category') {
         $this->registry->db->query("delete from " . TABLE_PREFIX . "{$this->table} where type='template' and userid=" . $this->fetch_field('userid') . " and parentid=" . $this->fetch_field('pid'));
     }
     parent::delete();
 }
Example #2
0
 /**
  * Sets a bit in a bitfield
  *
  * @param	string	Name of the database bitfield (options, permissions etc.)
  * @param	string	Name of the bit within the bitfield (canview, canpost etc.)
  * @param	boolean	Whether the bit should be set or not
  *
  * @return	boolean
  */
 function set_bitfield($fieldname, $bitname, $onoff)
 {
     // there are 2 permissions in the the admin permission bitfield that don't actually
     // belong in this table...
     if ($fieldname == 'adminpermissions' and ($bitname == 'ismoderator' or $bitname == 'cancontrolpanel')) {
         return false;
     }
     return parent::set_bitfield($fieldname, $bitname, $onoff);
 }
	/**
	* Constructor - checks that the registry object has been passed correctly.
	*
	* @param	vB_Registry	Instance of the vBulletin data registry object - expected to have the database object as one of its $this->db member.
	* @param	integer		One of the ERRTYPE_x constants
	*/
	function vB_DataManager_Blog_Category(&$registry, $errtype = ERRTYPE_STANDARD)
	{
		parent::vB_DataManager($registry, $errtype);

		($hook = vBulletinHook::fetch_hook('blog_categorydata_start')) ? eval($hook) : false;
	}
Example #4
0
 /**
  * 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)
 {
     // attachment counts
     if ($this->fetch_field('visible') and empty($this->existing['visible'])) {
         // new attachment or making one invisible
         $this->registry->db->query_write("\r\n\t\t\t\tUPDATE " . TABLE_PREFIX . "pt_issue SET\r\n\t\t\t\t\tattachcount = attachcount + 1\r\n\t\t\t\tWHERE issueid = " . intval($this->fetch_field('issueid')));
     } else {
         if (!$this->fetch_field('visible') and !empty($this->existing['visible'])) {
             // hiding visible attachment
             $this->registry->db->query_write("\r\n\t\t\t\tUPDATE " . TABLE_PREFIX . "pt_issue SET\r\n\t\t\t\t\tattachcount = IF(attachcount > 0, attachcount - 1, 0)\r\n\t\t\t\tWHERE issueid = " . intval($this->fetch_field('issueid')));
         }
     }
     if (!$this->condition and $this->fetch_field('visible')) {
         // insert issue change
         $change =& datamanager_init('Pt_IssueChange', $this->registry, ERRTYPE_STANDARD);
         $change->set_info('roll_post_time_limit', 0);
         // disable folding for attachment uploads
         $change->set('issueid', $this->fetch_field('issueid'));
         $change->set('userid', $this->registry->userinfo['userid']);
         $change->set('field', 'attachment_uploaded');
         $change->set('newvalue', $this->fetch_field('filename'));
         $change->set('oldvalue', '');
         $change->save();
     }
     ($hook = vBulletinHook::fetch_hook('ptattachdata_postsave')) ? eval($hook) : false;
     return parent::post_save_each($doquery);
 }
	/**
	* Additional data to update after a delete call (such as denormalized values in other tables).
	*
	* @access protected
	*
	* @param boolean $doquery					Do the query?
	*/
	function post_delete($doquery = true)
	{
		require_once(DIR . '/includes/functions_socialgroup.php');
		fetch_socialgroup_newest_groups(true, false, !$this->registry->options['sg_enablesocialgroupicons']);

		($hook = vBulletinHook::fetch_hook('socgroupicondata_delete')) ? eval($hook) : false;
		return parent::post_delete($doquery);
	}
Example #6
0
 /**
  * Constructor - checks that the registry object has been passed correctly.
  *
  * @param	vB_Registry	Instance of the vBulletin data registry object - expected to have the database object as one of its $this->db member.
  * @param	integer		One of the ERRTYPE_x constants
  */
 function vB_DataManager_SocialGroup(&$registry, $errtype = ERRTYPE_STANDARD)
 {
     parent::vB_DataManager($registry, $errtype);
     ($hook = vBulletinHook::fetch_hook('socgroupdata_start')) ? eval($hook) : false;
 }
Example #7
0
 /**
  * Constructor - checks that the registry object has been passed correctly.
  *
  * @param	vB_Registry	Instance of the vBulletin data registry object - expected to have the database object as one of its $this->db member.
  * @param	integer		One of the ERRTYPE_x constants
  */
 function vB_DataManager_Album(&$registry, $errtype = ERRTYPE_STANDARD)
 {
     parent::vB_DataManager($registry, $errtype);
     ($hook = vBulletinHook::fetch_hook('albumdata_start')) ? eval($hook) : false;
 }
Example #8
0
	/**
	* Constructor - checks that the registry object has been passed correctly.
	*
	* @param	vB_Registry	Instance of the vBulletin data registry object - expected to have the database object as one of its $this->db member.
	* @param	integer		One of the ERRTYPE_x constants
	*/
	function vB_DataManager_Cms_Layout(&$registry, $errtype = ERRTYPE_STANDARD)
	{
		parent::vB_DataManager($registry, $errtype);

		($hook = vBulletinHook::fetch_hook('cms_layout_start')) ? eval($hook) : false;
	}
Example #9
0
 function post_delete($doquery = true)
 {
     ($hook = vBulletinHook::fetch_hook('userpicdata_delete')) ? eval($hook) : false;
     return parent::post_delete($doquery);
 }
Example #10
0
	/**
	 * Overridding parent function to add search index updates
	 *
	* @param	boolean	Do the query?
	* @param	mixed	Whether to run the query now; see db_update() for more info
	* @param 	bool 	Whether to return the number of affected rows.
	* @param 	bool	Perform REPLACE INTO instead of INSERT
	8 @param 	bool	Perfrom INSERT IGNORE instead of INSERT
	*
	* @return	mixed	If this was an INSERT query, the INSERT ID is returned
	*/
	function save($doquery = true, $delayed = false, $affected_rows = false, $replace = false, $ignore = false)
	{
		// Call and get the new id
		$result = parent::save($doquery, $delayed, $affected_rows, $replace, $ignore);
		require_once DIR . '/vb/search/indexcontroller/queue.php' ;
		// Search index maintenance
		vb_Search_Indexcontroller_Queue::indexQueue('vBForum', 'Forum', 'index',
			  $this->fetch_field('forumid'));

		return $result;
	}
Example #11
0
 public function post_save_once($doquery = true)
 {
     parent::post_save_once($doquery);
     require_once DIR . '/includes/adminfunctions_template.php';
     //print_rebuild_style(-1, '', 0, 1, 1, 0, false);
     build_style(-1, '', array('docss' => 0, 'dostylevars' => 1, 'doreplacements' => 0, 'doposteditor' => 0), '-1,1', '', false, false);
 }
Example #12
0
 /**
  * Saves the data from the object into the specified database tables
  *
  * We change the default for $replace to true, and then call the parent.
  */
 function save($doquery = true, $delayed = false, $affected_rows = false, $replace = true, $ignore = false)
 {
     // We default $replace to true, and then call the parent.
     return parent::save($doquery, $delayed, $affected_rows, $replace, $ignore);
 }
Example #13
0
 /**
  * Any code to run after deleting
  *
  * @param	Boolean Do the query?
  */
 function post_delete($doquery = true)
 {
     foreach ($this->lists['content'] as $contenttypeid => $list) {
         if (!($attach =& vB_Attachment_Dm_Library::fetch_library($this->registry, $contenttypeid))) {
             return false;
         }
         $attach->post_delete($this);
         unset($attach);
     }
     // Update the refcount in the filedata table
     if (!empty($this->lists['filedataids'])) {
         $this->registry->db->query_write("\n\t\t\t\tUPDATE " . TABLE_PREFIX . "filedata AS fd\n\t\t\t\tSET fd.refcount = (\n\t\t\t\t\tSELECT COUNT(*)\n\t\t\t\t\tFROM " . TABLE_PREFIX . "attachment AS a\n\t\t\t\t\tWHERE fd.filedataid = a.filedataid\n\t\t\t\t)\n\t\t\t\tWHERE fd.filedataid IN (" . implode(", ", array_keys($this->lists['filedataids'])) . ")\n\t\t\t");
     }
     // Below here only applies to attachments in pictures/groups but I forsee all attachments gaining the ability to have comments
     if ($this->info['type'] == 'filedata') {
         if (!empty($this->lists['filedataids'])) {
             $this->registry->db->query_write("\n\t\t\t\t\tDELETE FROM " . TABLE_PREFIX . "picturecomment\n\t\t\t\t\tWHERE filedataid IN (" . implode(", ", array_keys($this->lists['filedataids'])) . ")\n\t\t\t\t");
         }
     } else {
         if (!empty($this->lists['picturecomments'])) {
             foreach ($this->lists['picturecomments'] as $sql) {
                 if (!($results = $this->registry->db->query_first("\n\t\t\t\t\tSELECT a.attachmentid\n\t\t\t\t\tFROM " . TABLE_PREFIX . "attachment AS a\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t{$sql}\n\t\t\t\t"))) {
                     $this->registry->db->query_write("\n\t\t\t\t\t\tDELETE FROM " . TABLE_PREFIX . "picturecomment\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t{$sql}\n\t\t\t\t\t");
                 }
             }
         }
     }
     require_once DIR . '/includes/functions_picturecomment.php';
     foreach (array_keys($this->lists['userids']) as $userid) {
         build_picture_comment_counters($userid);
     }
     return parent::post_delete($doquery);
 }
	/**
	* Verifies the page text is valid and sets it up for saving.
	*
	* @param	string	Page text
	*
	* @param	bool	Whether the text is valid
	*/
	function verify_pagetext(&$pagetext)
	{
		if (empty($this->info['skip_charcount']))
		{
			if (!$this->fetch_field('type'))
			{
				trigger_error('vB_Datamanager_Blog_Custom_Block(): \'type\' must be set.', E_USER_ERROR);
			}
			if ($this->fetch_field('type'))
			{
				$maxchars = $this->registry->options['vbblog_blockmaxchars'];
			}
			else
			{
				$maxchars = $this->registry->options['vbblog_pagemaxchars'];
			}
			if ($maxchars != 0 AND ($postlength = vbstrlen($pagetext)) > $maxchars)
			{
				$this->error('toolong', $postlength, $maxchars);
				return false;
			}

			$this->registry->options['postminchars'] = intval($this->registry->options['postminchars']);
			if ($this->registry->options['postminchars'] <= 0)
			{
				$this->registry->options['postminchars'] = 1;
			}
			if (vbstrlen(strip_bbcode($pagetext, $this->registry->options['ignorequotechars'])) < $this->registry->options['postminchars'])
			{
				$this->error('tooshort', $this->registry->options['postminchars']);
				return false;
			}
		}

		return parent::verify_pagetext($pagetext, false);

	}
Example #15
0
 /**
  * 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 (!empty($this->info['update_existing'])) {
         // we're updating an existing attachment that has already been counted
         // in the thread/post.attach fields. We need to decrement those fields
         // because they will be incremented on save.
         $this->registry->db->query_write("\n\t\t\t\tUPDATE " . TABLE_PREFIX . "post SET\n\t\t\t\t\tattach = IF(attach > 0, attach - 1, 0)\n\t\t\t\tWHERE postid = " . intval($this->info['update_existing']));
         $this->registry->db->query_write("\n\t\t\t\tUPDATE " . TABLE_PREFIX . "post AS post, " . TABLE_PREFIX . "thread AS thread SET\n\t\t\t\t\tthread.attach = IF(thread.attach > 0, thread.attach - 1, 0)\n\t\t\t\tWHERE thread.threadid = post.threadid\n\t\t\t\t\tAND post.postid = " . intval($this->info['update_existing']));
     }
     ($hook = vBulletinHook::fetch_hook('attachdata_postsave')) ? eval($hook) : false;
     return parent::post_save_each($doquery);
 }
Example #16
0
	/**
	* Verifies the page text is valid and sets it up for saving.
	*
	* @param	string	Page text
	*
	* @param	bool	Whether the text is valid
	*/
	function verify_pagetext(&$pagetext)
	{
		if (empty($this->info['skip_charcount']))
		{
			if ($this->registry->options['vbblog_usermaxchars'] != 0 AND ($postlength = vbstrlen($pagetext)) > $this->registry->options['vbblog_usermaxchars'])
			{
				$this->error('toolong', $postlength, $this->registry->options['vbblog_usermaxchars']);
				return false;
			}
		}

		return parent::verify_pagetext($pagetext);

	}
 /**
  * Overriding version of the set() function to deal with the selecting userid from username
  *
  * @param	string	Name of the field
  * @param	mixed	Value of the field
  *
  * @return	boolean	Returns true on success
  */
 function set($fieldname, $value)
 {
     switch ($fieldname) {
         case 'username':
         case 'modusername':
             if ($value != '' and $userinfo = $this->dbobject->query_first("SELECT * FROM " . TABLE_PREFIX . "user WHERE username = '******'")) {
                 $this->do_set('userid', $userinfo['userid']);
                 $this->info['user'] =& $userinfo;
                 return true;
             } else {
                 $this->error('no_users_matched_your_query_x', $value);
                 return false;
             }
             break;
         default:
             return parent::set($fieldname, $value);
     }
 }
Example #18
0
	/**
	* Verifies the page text is valid and sets it up for saving.
	*
	* @param	string	Page text
	*
	* @param	bool	Whether the text is valid
	*/
	function verify_pagetext(&$pagetext)
	{
		if (empty($this->info['skip_charcount']))
		{
			$maxchars = $this->table == 'blog' ? $this->registry->options['vbblog_entrymaxchars'] : $this->registry->options['vbblog_commentmaxchars'];
			if ($maxchars != 0 AND ($postlength = vbstrlen($pagetext)) > $maxchars)
			{
				$this->error('toolong', $postlength, $maxchars);
				return false;
			}

			$this->registry->options['postminchars'] = intval($this->registry->options['postminchars']);
			if ($this->registry->options['postminchars'] <= 0)
			{
				$this->registry->options['postminchars'] = 1;
			}
			if (vbstrlen(strip_bbcode($pagetext)) < $this->registry->options['postminchars'])
			{
				$this->error('tooshort', $this->registry->options['postminchars']);
				return false;
			}
		}

		return parent::verify_pagetext($pagetext, false);
	}
Example #19
0
 /**
  * Constructor - checks that the registry object has been passed correctly.
  *
  * @param	vB_Registry	Instance of the vBulletin data registry object - expected to have the database object as one of its $this->db member.
  * @param	integer		One of the ERRTYPE_x constants
  */
 function vB_DataManager_Pt_IssueType(&$registry, $errtype = ERRTYPE_STANDARD)
 {
     parent::vB_DataManager($registry, $errtype);
     ($hook = vBulletinHook::fetch_hook('pt_issuetypedata_start')) ? eval($hook) : false;
 }
 /**
  * Constructor - Checks for necessity of registry object
  *
  * @param	vB_Registry	Instance of the vBulletin data registry object - expected to have the database object as one of its $this->db member.
  * @param	integer		One of the ERRTYPE_x constants
  */
 public function __construct(&$registry = NULL, $errtype = NULL)
 {
     parent::__construct($registry, $errtype);
     // Legacy Hook 'stylevardfndata_start' Removed //
 }
Example #21
0
 function set_existing(&$existing)
 {
     parent::set_existing($existing);
     if (isset($existing['votes'])) {
         $this->poll_votes = explode('|||', $existing['votes']);
     }
     if (isset($existing['options'])) {
         $this->poll_options = explode('|||', $existing['options']);
     }
 }
Example #22
0
 /**
  * Verify a guest's username as valid. Pretty much as we'd do any username.
  *
  * @param	string	Username
  */
 function verify_guest_name(&$name)
 {
     $name = unhtmlspecialchars($name);
     return parent::verify_username($name);
 }
Example #23
0
 /**
  * Code to run after deleting
  *
  * @param	boolean	Do the query?
  *
  * @return	boolean	Was this code executed correctly?
  *
  */
 function post_delete($doquery = true)
 {
     $albums = array();
     $albums_sql = $this->registry->db->query_read("\n\t\t\tSELECT album.*\n\t\t\tFROM " . TABLE_PREFIX . "albumpicture AS albumpicture\n\t\t\tINNER JOIN " . TABLE_PREFIX . "album AS album ON (album.albumid = albumpicture.albumid)\n\t\t\tWHERE albumpicture.pictureid = " . $this->fetch_field('pictureid'));
     while ($album = $this->registry->db->fetch_array($albums_sql)) {
         $albums[] = $album;
     }
     $this->registry->db->query_write("\n\t\t\tDELETE FROM " . TABLE_PREFIX . "albumpicture\n\t\t\tWHERE pictureid = " . $this->fetch_field('pictureid'));
     if ($this->info['auto_count_update'] and $albums) {
         foreach ($albums as $album) {
             $albumdata =& datamanager_init('Album', $this->registry, ERRTYPE_SILENT);
             $albumdata->set_existing($album);
             $albumdata->rebuild_counts();
             // for a picture to have been set to the cover, it must have been visible
             if ($albumdata->fetch_field('coverpictureid') == $this->fetch_field('pictureid')) {
                 if ($album['visible'] - 1 > 0) {
                     $new_cover = $this->registry->db->query_first("\n\t\t\t\t\t\t\tSELECT albumpicture.pictureid\n\t\t\t\t\t\t\tFROM " . TABLE_PREFIX . "albumpicture AS albumpicture\n\t\t\t\t\t\t\tINNER JOIN " . TABLE_PREFIX . "picture AS picture ON (albumpicture.pictureid = picture.pictureid)\n\t\t\t\t\t\t\tWHERE albumpicture.albumid = {$album['albumid']} AND picture.state = 'visible'\n\t\t\t\t\t\t\tORDER BY albumpicture.dateline ASC\n\t\t\t\t\t\t\tLIMIT 1\n\t\t\t\t\t\t");
                 }
                 $albumdata->set('coverpictureid', $new_cover['pictureid'] ? $new_cover['pictureid'] : 0);
             }
             $albumdata->save();
         }
     }
     $del_usercss = array();
     foreach ($albums as $album) {
         $del_usercss[] = "'{$album['albumid']}," . $this->fetch_field('pictureid') . "'";
     }
     if ($del_usercss) {
         $this->registry->db->query_write("\n\t\t\t\tDELETE FROM " . TABLE_PREFIX . "usercss\n\t\t\t\tWHERE property = 'background_image'\n\t\t\t\t\tAND value IN (" . implode(',', $del_usercss) . ")\n\t\t\t\t\tAND userid = " . intval($this->fetch_field('userid')) . "\n\t\t\t");
         $this->info['have_updated_usercss'] = $this->registry->db->affected_rows() > 0;
     }
     $groups = array();
     $groups_sql = $this->registry->db->query_read("\n\t\t\tSELECT DISTINCT socialgroup.*\n\t\t\tFROM " . TABLE_PREFIX . "socialgrouppicture AS socialgrouppicture\n\t\t\tINNER JOIN " . TABLE_PREFIX . "socialgroup AS socialgroup ON (socialgroup.groupid = socialgrouppicture.groupid)\n\t\t\tWHERE socialgrouppicture.pictureid = " . $this->fetch_field('pictureid'));
     while ($group = $this->registry->db->fetch_array($groups_sql)) {
         $groups[] = $group;
     }
     $this->registry->db->query_write("\n\t\t\tDELETE FROM " . TABLE_PREFIX . "socialgrouppicture\n\t\t\tWHERE pictureid = " . $this->fetch_field('pictureid'));
     foreach ($groups as $group) {
         $groupdata =& datamanager_init('SocialGroup', $this->registry, ERRTYPE_SILENT);
         $groupdata->set_existing($group);
         $groupdata->rebuild_picturecount();
         $groupdata->save();
     }
     $this->registry->db->query_write("\n\t\t\tDELETE FROM " . TABLE_PREFIX . "picturecomment\n\t\t\tWHERE pictureid = " . $this->fetch_field('pictureid'));
     require_once DIR . '/includes/functions_picturecomment.php';
     build_picture_comment_counters($this->fetch_field('userid'));
     ($hook = vBulletinHook::fetch_hook('picturedata_delete')) ? eval($hook) : false;
     return parent::post_delete($doquery);
 }
Example #24
0
 /**
  * Additional data to update after a save call (such as denormalized values in other tables).
  * In batch updates, is executed once after all records are updated.
  *
  * @param	boolean	Do the query?
  */
 function post_save_once($doquery = true)
 {
     require_once DIR . '/includes/functions_calendar.php';
     build_events();
     return parent::post_save_once($doquery);
 }
Example #25
0
 /**
  * Verifies the page text is valid and sets it up for saving.
  *
  * @param	string	Page text
  *
  * @param	bool	Whether the text is valid
  */
 function verify_pagetext(&$pagetext)
 {
     if (vbstrlen(strip_bbcode($pagetext, $this->registry->options['ignorequotechars'])) < 1) {
         $this->error('tooshort', 1);
         return false;
     }
     return parent::verify_pagetext($pagetext);
 }
Example #26
0
 /**
  * Saves the data from the object into the specified database tables
  *
  * @param	boolean	Do the query?
  * @param	mixed		Whether to run the query now; see db_update() for more info
  * @param bool 		Whether to return the number of affected rows.
  *
  * @return	mixed	If this was an INSERT query, the INSERT ID is returned
  */
 function save($doquery = true, $delayed = false, $affected_rows = false)
 {
     // Specify a REPLACE INTO insert with the 'true' parameter at the end
     return parent::save($doquery, $delayed, $affected_rows, true);
 }
 /**
  * Verifies the page text is valid and sets it up for saving.
  *
  * @param	string	Page text
  *
  * @param	bool	Whether the text is valid
  */
 function verify_pagetext(&$pagetext)
 {
     if (empty($this->info['is_automated'])) {
         if ($this->registry->options['postmaxchars'] != 0 and ($postlength = vbstrlen($pagetext)) > $this->registry->options['postmaxchars']) {
             $this->error('toolong', $postlength, $this->registry->options['postmaxchars']);
             return false;
         }
         $this->registry->options['postminchars'] = intval($this->registry->options['postminchars']);
         if ($this->registry->options['postminchars'] <= 0) {
             $this->registry->options['postminchars'] = 1;
         }
         if (vbstrlen(strip_bbcode($pagetext, $this->registry->options['ignorequotechars'])) < $this->registry->options['postminchars']) {
             $this->error('tooshort', $this->registry->options['postminchars']);
             return false;
         }
     }
     return parent::verify_pagetext($pagetext);
 }
Example #28
0
 /**
  * Additional data to update after a save call (such as denormalized values in other tables).
  * In batch updates, is executed once after all records are updated.
  *
  * @param	boolean	Do the query?
  */
 function post_save_once($doquery = true)
 {
     parent::post_save_once($doquery);
     if (!empty($this->moderator['userid'])) {
         vB_Cache::allCacheEvent('userChg_' . $this->moderator['userid']);
     }
     vB::getUserContext()->rebuildGroupAccess();
 }
Example #29
0
 /**
  * Constructor - checks that the registry object has been passed correctly.
  *
  * @param	vB_Registry	Instance of the vBulletin data registry object - expected to have the database object as one of its $this->db member.
  * @param	integer		One of the ERRTYPE_x constants
  */
 public function __construct(&$registry, $errtype = ERRTYPE_STANDARD)
 {
     parent::vB_DataManager($registry, $errtype);
     ($hook = vBulletinHook::fetch_hook('stylevardata_start')) ? eval($hook) : false;
 }
Example #30
0
	/**
	* Constructor - checks that the registry object has been passed correctly.
	*
	* @param	vB_Registry	Instance of the vBulletin data registry object - expected to have the database object as one of its $this->db member.
	* @param	integer		One of the ERRTYPE_x constants
	*/
	function vB_DataManager_vBCms_Widget(&$registry, $errtype = ERRTYPE_STANDARD)
	{
		parent::vB_DataManager($registry, $errtype);

		($hook = vBulletinHook::fetch_hook('vbcms_widgetdm_start')) ? eval($hook) : false;
	}