Exemplo n.º 1
0
	/**
	* Delete multiple items from a table which is managed by a nested set structure. Automatically handles deletion of child records.
	*
	* @param ISC_NESTEDSET $nestedSet An instance of ISC_NESTEDSET (or another class that extends it) for the table being managed
	* @param array $ids The array of ids to delete
	* @return boolean Return true on successful deletion
	*/
	public function multiDeleteNestedSet($nestedSet, $ids=0)
	{
		// If the database connection isnt setup we can't proceed
		if (!$this->db) {
			$this->error = GetLang('apiNotConnectedToDB');
			return false;
		}

		if (!is_array($ids)) {
			$this->error = GetLang('apiNotAnArray');
			return false;
		}

		if (empty($ids)) {
			return true;
		}

		// Make sure the array only contains integers
		foreach ($ids as $id) {
			if (!is_numeric($id)) {
				$this->error = GetLang('apiIdNotAPosInt');
				return false;
			}
		}

		$success = true;
		foreach ($ids as $id) {
			if (!$nestedSet->deleteNode($id)) {
				$success = false;
			}
		}

		if (!$success) {
			$this->error = GetLang('apiDeleteFailed');
			return false;
		}

		return true;
	}
	public function __construct()
	{
		parent::__construct('categories', 'categoryid', 'catparentid', array('catsort', 'catname'), 'catnsetleft', 'catnsetright', 'catdepth');
	}
Exemplo n.º 3
0
	public function __construct()
	{
		parent::__construct('pages', 'pageid', 'pageparentid', array('pagevendorid', 'pagesort', 'pagetitle'), 'pagensetleft', 'pagensetright', 'pagedepth');
	}