public function setTransferredTotal($v) { parent::setTransferredTotal(json_encode($v)); return $this; }
public function delete(Doctrine_Connection $conn = null) { $communityMemberTable = Doctrine::getTable('CommunityMember'); $communityIds = $communityMemberTable->getCommunityIdsOfAdminByMemberId($this->getId()); foreach ($communityIds as $communityId) { $community = Doctrine::getTable('Community')->find($communityId); $communityMembers = $communityMemberTable->getCommunityMembers($communityId); if (!$communityMembers->count()) { $community->delete(); continue; } $subAdminMember = Doctrine::getTable('CommunityMemberPosition')->findOneByCommunityIdAndName($communityId, 'sub_admin'); if ($subAdminMember) { $communityMember = $subAdminMember->getCommunityMember(); } else { $communityMember = $communityMembers[0]; } $communityMember->removeAllPosition(); $communityMember->addPosition('admin'); $adminCommunityMember = $communityMemberTable->retrieveByMemberIdAndCommunityId($this->getId(), $communityId); $adminCommunityMember->delete(); } return parent::delete($conn); }
function delete() { // change parent of child nodes $child_members = $this->getAllChildren(); if (is_array($child_members)) { $parent = $this->getParentMember(); foreach ($child_members as $child) { $child->setParentMemberId($this->getParentMemberId()); if ($parent instanceof Member) { $child->setDepth($parent->getDepth() + 1); } else { $child->setDepth(1); } $child->save(); } } // delete member restrictions MemberRestrictions::delete(array("`member_id` = ?", $this->getId())); MemberRestrictions::delete(array("`restricted_member_id` = ?", $this->getId())); // delete member properties MemberPropertyMembers::delete(array("`member_id` = ?", $this->getId())); MemberPropertyMembers::delete(array("`property_member_id` = ?", $this->getId())); // delete permissions ContactMemberPermissions::delete(array("member_id = ?", $this->getId())); // delete member objects (if they don't belong to another member) $sql = "SELECT `o`.`object_id` FROM `" . ObjectMembers::instance()->getTableName() . "` `o` WHERE `o`.`is_optimization`=0 AND `o`.`member_id`=" . $this->getId() . " AND NOT EXISTS (\n\t\t\tSELECT `om`.`object_id` FROM `" . ObjectMembers::instance()->getTableName() . "` `om` WHERE `om`.`object_id`=`o`.`object_id` AND `om`.`is_optimization`=0 AND `om`.`member_id`<>" . $this->getId() . ")"; $result = DB::execute($sql); $rows = $result->fetchAll(); if (!is_null($rows)) { foreach ($rows as $row) { $obj = Objects::findById(array_var($row, 'object_id')); $obj->delete(); } } // delete object if member is a dimension_object if ($this->getObjectId()) { $object = Objects::findObject($this->getObjectId()); if ($object instanceof ContentDataObject) { $object->delete(); } } return parent::delete(); }
/** * Returns a peer instance associated with this om. * * Since Peer classes are not to have any instance attributes, this method returns the * same instance for all member of this class. The method could therefore * be static, but this would prevent one from overriding the behavior. * * @return MemberPeer */ public function getPeer() { if (self::$peer === null) { self::$peer = new MemberPeer(); } return self::$peer; }
function setParentMemberId($value) { $parent = Members::getMemberById($value); if ($parent instanceof Member) { $parent_type = $parent->getObjectTypeId(); $parents_types = DimensionObjectTypeHierarchies::getAllParentObjectTypeIds($this->getDimensionId(), $this->getObjectTypeId(), false); if (in_array($parent_type, $parents_types)) { return parent::setParentMemberId($value); } else { //error Logger::log("Not valid parent member type '{$parent_type}'," . $this->getObjectTypeId()); $errors = array(); $errors[] = "Not valid parent member type"; throw new DAOValidationError($this, $errors); } } else { return parent::setParentMemberId(0); } }
public function delete(Doctrine_Connection $conn = null) { $communityMemberTable = Doctrine::getTable('CommunityMember'); $communityIds = $communityMemberTable->getCommunityIdsOfAdminByMemberId($this->getId()); foreach ($communityIds as $communityId) { if (!$communityMemberTable->getCommunityMembers($communityId)->count()) { $community = Doctrine::getTable('Community')->find($communityId); $community->delete(); continue; } $communityMember = $communityMemberTable->createQuery()->where('community_id = ?', $communityId)->addWhere('position = ?', '')->fetchOne(); $communityMember->setPosition('admin'); $communityMember->save(); $communityMember = $communityMemberTable->retrieveByMemberIdAndCommunityId($this->getId(), $communityId); $communityMember->delete(); } return parent::delete($conn); }
function delete($check = true) { if ($check && !$this->canBeDeleted($error_message)) { throw new Exception($error_message); } // change parent of child nodes $child_members = $this->getAllChildren(); if (is_array($child_members)) { $parent = $this->getParentMember(); foreach($child_members as $child) { $child->setParentMemberId($this->getParentMemberId()); if ($parent instanceof Member) { $child->setDepth($parent->getDepth()+1); } else $child->setDepth(1); $child->save(); } } // delete member restrictions MemberRestrictions::delete(array("`member_id` = ?", $this->getId())); MemberRestrictions::delete(array("`restricted_member_id` = ?", $this->getId())); // delete member properties MemberPropertyMembers::delete(array("`member_id` = ?", $this->getId())); MemberPropertyMembers::delete(array("`property_member_id` = ?", $this->getId())); // delete permissions ContactMemberPermissions::delete(array("member_id = ?", $this->getId())); // delete member objects (if they don't belong to another member) $sql = "SELECT `o`.`object_id` FROM `".ObjectMembers::instance()->getTableName()."` `o` WHERE `o`.`is_optimization`=0 AND `o`.`member_id`=".$this->getId()." AND NOT EXISTS ( SELECT `om`.`object_id` FROM `".ObjectMembers::instance()->getTableName()."` `om` WHERE `om`.`object_id`=`o`.`object_id` AND `om`.`is_optimization`=0 AND `om`.`member_id`<>".$this->getId().")"; $result = DB::execute($sql); $rows = $result->fetchAll(); if (!is_null($rows)) { foreach ($rows as $row) { $obj = Objects::findById(array_var($row, 'object_id')); $obj->delete(); } } // clean object_members ObjectMembers::delete("member_id = ".$this->getId()); // delete object if member is a dimension_object if ($this->getObjectId()) { $object = Objects::findObject($this->getObjectId()); if ($object instanceof ContentDataObject) $object->delete(); } ApplicationLogs::createLog($this, ApplicationLogs::ACTION_DELETE, false, true, true, 'member deleted'); return parent::delete(); }