Beispiel #1
0
	/**
	 * Performs additional queries or tasks after saving.
	 * Updates the node description with the title.
	 *
	 * @param mixed								- The save result
	 * @param bool $deferred						- Save was deferred
	 * @param bool $replace						- Save used REPLACE
	 * @param bool $ignore						- Save used IGNORE if inserting
	 * @return bool								- Whether the save can be considered a success
	 */
	protected function postSave($result, $deferred, $replace, $ignore)
	{
		//result will normally be the nodeid if this was an insert. Let's check.
		if ($this->isUpdating())
		{
			$nodeid = $this->item->getNodeId();
		}
		else if (is_array($result))
		{
			$nodeid = $result['nodeid'];
		}
		else
		{
			$nodeid = $result;
		}

		if (!$result)
		{
			return false;
		}
		parent::postSave($result, $deferred, $replace, $ignore);

		//We need to update category information. Let's figure out what the current categories
		// are and only make the necessary changes.
		vB::$vbulletin->input->clean_array_gpc('r', array('categoryids' =>TYPE_ARRAY));

		//if we don't have a categoryids variable around, we don't want to update categories.
		if (vB::$vbulletin->GPC_exists['categoryids'])
		{
			$newcategories = array();
			$currcategories = array();
			foreach (vB::$vbulletin->GPC['categoryids'] as $categoryid)
			{
				if (isset($_REQUEST["cb_category_$categoryid"]))
				{
					$newcategories[]= $categoryid;
				}
			}
			$newcategories = array_unique($newcategories);

			if ($rst = vB::$vbulletin->db->query_read("SELECT categoryid FROM "
				. TABLE_PREFIX . "cms_nodecategory WHERE nodeid =" . $nodeid))
			{
				while($row = vB::$vbulletin->db->fetch_array($rst))
				{
					$currcategories[] = $row['categoryid'];
				}
			}

			if (count($update = array_diff($newcategories, $currcategories)))
			{
				foreach ($update as $categoryid)
				{
					vB::$vbulletin->db->query_write("INSERT INTO ". TABLE_PREFIX .
						 "cms_nodecategory (nodeid, categoryid) values (" . $nodeid .
						 ", $categoryid) ");
				}
			}

			if (count($update = array_diff($currcategories, $newcategories)))
			{
				vB::$vbulletin->db->query_write("DELETE FROM ". TABLE_PREFIX .
					 "cms_nodecategory WHERE nodeid =" . $nodeid .
					 " AND categoryid in (" . implode(', ', $update) . ")" );
			}
			vB_Cache::instance()->event('categories_updated');
			vB_Cache::instance()->event($this->item->getContentCacheEvent());
		}

		if ($this->index_search)
		{
			$this->indexSearchContent();
		}

		vB_Cache::instance()->event('cms_count_published');

	}
Beispiel #2
0
	/**
	 * Loads a corresponding DM with the fields it needs to express the current
	 * values.
	 *
	 * @param vB_DM $dm							- The DM to give the existing values to.
	 */
	public function loadDM(vB_DM $dm)
	{
		$this->Load($this->dm_load_flags);

		$dm->setExistingFields($this->item_properties, $this);
	}
Beispiel #3
0
 /**
  * Loads a corresponding DM with the fields it needs to express the current
  * values.
  *
  * @param vB_DM $dm							- The DM to give the existing values to.
  */
 public function loadDM(vB_DM $dm)
 {
     $this->Load($this->dm_load_flags);
     // using $this->getProperties() because the intended use of setExistingFields() is to send the actual property values themselves to populate the DM with existing data.
     $dm->setExistingFields($this->getProperties(), $this);
 }
Beispiel #4
0
	/**
	 * Resets all set changes.
	 */
	protected function Reset()
	{
		parent::Reset();
		unset($this->nodeid);
	}
Beispiel #5
0
	/**
	 * Loads a corresponding DM with the fields it needs to express the current
	 * values.
	 *
	 * @param vBCms_DM_Widget $dm							- The DM to give the existing values to.
	 */
	public function loadDM(vB_DM $dm)
	{
		$this->Load($this->dm_load_flags);

		$dm->setExisting($this->item_properties);
		$dm->set('config', $this->config);
	}