Declares an association between this object and a ChildPermission object.

@param  ChildPermission $v
@return $this|\Alchemy\Component\Cerberus\Model\RolePermission The current object (for fluent API support)
@throws PropelException
541372
public function setPermission(ChildPermission $v = null)
    {
        if ($v === null) {
            $this->setPermissionId(NULL);
        } else {
            $this->setPermissionId($v->getId());
        }

        $this->aPermission = $v;

        // Add binding for other direction of this n:n relationship.
        // If this object has already been added to the ChildPermission object, it will not be re-added.
        if ($v !== null) {
            $v->addRolePermission($this);
        }


        return $this;
    }
204046
public function setMultipleOf(ChildSkill $v = null)
    {
        if ($v === null) {
            $this->setMultipleOfId(NULL);
        } else {
            $this->setMultipleOfId($v->getId());
        }

        $this->aMultipleOf = $v;

        // Add binding for other direction of this n:n relationship.
        // If this object has already been added to the ChildSkill object, it will not be re-added.
        if ($v !== null) {
            $v->addMultiple($this);
        }


        return $this;
    }
347159
public function setParentId($v)
    {
        if ($v !== null) {
            $v = (int) $v;
        }

        if ($this->parent_id !== $v) {
            $this->parent_id = $v;
            $this->modifiedColumns[PermissionTableMap::COL_PARENT_ID] = true;
        }

        if ($this->aPermissionRelatedByParentId !== null && $this->aPermissionRelatedByParentId->getId() !== $v) {
            $this->aPermissionRelatedByParentId = null;
        }

        return $this;
    }
1289417
public function setSkill(ChildSkill $v = null)
    {
        if ($v === null) {
            $this->setSkillId(NULL);
        } else {
            $this->setSkillId($v->getId());
        }

        $this->aSkill = $v;

        // Add binding for other direction of this n:n relationship.
        // If this object has already been added to the ChildSkill object, it will not be re-added.
        if ($v !== null) {
            $v->addSkillReference($this);
        }


        return $this;
    }
1190228
public function setFeaturedTutorial(ChildVideo $v = null)
    {
        if ($v === null) {
            $this->setTutorialId(NULL);
        } else {
            $this->setTutorialId($v->getId());
        }

        $this->aFeaturedTutorial = $v;

        // Add binding for other direction of this n:n relationship.
        // If this object has already been added to the ChildVideo object, it will not be re-added.
        if ($v !== null) {
            $v->addFeaturedTutorialSkill($this);
        }


        return $this;
    }
1352681
public function setCategory(ChildCategory $v = null)
    {
        if ($v === null) {
            $this->setCategoryId(NULL);
        } else {
            $this->setCategoryId($v->getId());
        }

        $this->aCategory = $v;

        // Add binding for other direction of this n:n relationship.
        // If this object has already been added to the ChildCategory object, it will not be re-added.
        if ($v !== null) {
            $v->addC2M($this);
        }


        return $this;
    }
969161
public function setParent(LeafRole $parent = null)
    {
        if ($parent && !$parent->getChildren()->contains($this)) {
            $parent->addChild($this);
        }
        $this->parent = $parent;

        return $this;
    }
1171476
public function setAdmin(ChildAdmin $v = null)
    {
        if ($v === null) {
            $this->setAdminId(NULL);
        } else {
            $this->setAdminId($v->getId());
        }

        $this->aAdmin = $v;

        // Add binding for other direction of this n:n relationship.
        // If this object has already been added to the ChildAdmin object, it will not be re-added.
        if ($v !== null) {
            $v->addDealerAdmin($this);
        }


        return $this;
    }
1037587
public function setSmartyFilter(ChildSmartyFilter $v = null)
    {
        if ($v === null) {
            $this->setId(null);
        } else {
            $this->setId($v->getId());
        }

        $this->aSmartyFilter = $v;

        // Add binding for other direction of this n:n relationship.
        // If this object has already been added to the ChildSmartyFilter object, it will not be re-added.
        if ($v !== null) {
            $v->addSmartyFilterI18n($this);
        }


        return $this;
    }
1022262
public function removeRole(ChildRole $role)
    {
        if ($this->getRoles()->contains($role)) { $rolePermission = new ChildRolePermission();

            $rolePermission->setRole($role);
            if ($role->isPermissionsLoaded()) {
                //remove the back reference if available
                $role->getPermissions()->removeObject($this);
            }

            $rolePermission->setPermission($this);
            $this->removeRolePermission(clone $rolePermission);
            $rolePermission->clear();

            $this->collRoles->remove($this->collRoles->search($role));

            if (null === $this->rolesScheduledForDeletion) {
                $this->rolesScheduledForDeletion = clone $this->collRoles;
                $this->rolesScheduledForDeletion->clear();
            }

            $this->rolesScheduledForDeletion->push($role);
        }


        return $this;
    }
457703
public function setSkillRelatedByParentId(ChildSkill $v = null)
    {
        if ($v === null) {
            $this->setParentId(NULL);
        } else {
            $this->setParentId($v->getId());
        }

        $this->aSkillRelatedByParentId = $v;

        // Add binding for other direction of this n:n relationship.
        // If this object has already been added to the ChildSkill object, it will not be re-added.
        if ($v !== null) {
            $v->addParent($this);
        }


        return $this;
    }
766562
public function setSkillRelatedByCompositeId(ChildSkill $v = null)
    {
        if ($v === null) {
            $this->setCompositeId(NULL);
        } else {
            $this->setCompositeId($v->getId());
        }

        $this->aSkillRelatedByCompositeId = $v;

        // Add binding for other direction of this n:n relationship.
        // If this object has already been added to the ChildSkill object, it will not be re-added.
        if ($v !== null) {
            $v->addComposite($this);
        }


        return $this;
    }
8465
function hasPermission($Role, $Permission)
	{
		$Res = Jf::sql ( "
					SELECT COUNT(*) AS Result
					FROM {$this->tablePrefix()}rolepermissions AS TRel
					JOIN {$this->tablePrefix()}permissions AS TP ON ( TP.ID= TRel.PermissionID)
					JOIN {$this->tablePrefix()}roles AS TR ON ( TR.ID = TRel.RoleID)
					WHERE TR.Lft BETWEEN
					(SELECT Lft FROM {$this->tablePrefix()}roles WHERE ID=?)
					AND
					(SELECT Rght FROM {$this->tablePrefix()}roles WHERE ID=?)
					/* the above section means any row that is a descendants of our role (if descendant roles have some permission, then our role has it two) */
					AND TP.ID IN (
					SELECT parent.ID
					FROM {$this->tablePrefix()}permissions AS node,
					{$this->tablePrefix()}permissions AS parent
					WHERE node.Lft BETWEEN parent.Lft AND parent.Rght
					AND ( node.ID=? )
					ORDER BY parent.Lft
					);
					/*
					the above section returns all the parents of (the path to) our permission, so if one of our role or its descendants
					has an assignment to any of them, we're good.
					*/
					", $Role, $Role, $Permission );
		return $Res [0] ['Result'] >= 1;
	}
540497
public function setSkillRelatedByPartId(ChildSkill $v = null)
    {
        if ($v === null) {
            $this->setPartId(NULL);
        } else {
            $this->setPartId($v->getId());
        }

        $this->aSkillRelatedByPartId = $v;

        // Add binding for other direction of this n:n relationship.
        // If this object has already been added to the ChildSkill object, it will not be re-added.
        if ($v !== null) {
            $v->addPart($this);
        }


        return $this;
    }
74066
public function setAttributeType(ChildAttributeType $v = null)
    {
        if ($v === null) {
            $this->setId(NULL);
        } else {
            $this->setId($v->getId());
        }

        $this->aAttributeType = $v;

        // Add binding for other direction of this n:n relationship.
        // If this object has already been added to the ChildAttributeType object, it will not be re-added.
        if ($v !== null) {
            $v->addAttributeTypeI18n($this);
        }


        return $this;
    }
995120
public function setStructureNode(ChildStructureNode $v = null)
    {
        if ($v === null) {
            $this->setId(NULL);
        } else {
            $this->setId($v->getId());
        }

        $this->aStructureNode = $v;

        // Add binding for other direction of this 1:1 relationship.
        if ($v !== null) {
            $v->setFunctionPhase($this);
        }


        return $this;
    }
1245213
public function addPermission(ChildPermission $permission)
    {
        if ($this->collPermissions === null) {
            $this->initPermissions();
        }

        if (!$this->getPermissions()->contains($permission)) {
            // only add it if the **same** object is not already associated
            $this->collPermissions->push($permission);
            $this->doAddPermission($permission);
        }

        return $this;
    }