public function getPath($asString = true)
 {
     $member = Members::findOneByObjectId($this->getId());
     $parents = array();
     foreach ($member->getAllParentMembersInHierarchy(false) as $parent) {
         $parents[] = $parent->getName();
     }
     $parents = array_reverse($parents);
     if ($asString) {
         if (count($parents)) {
             return "(" . implode(" | ", $parents) . ")";
         } else {
             return "";
         }
     } else {
         return $parents;
     }
 }
예제 #2
0
 function getIconClass()
 {
     $d = Dimensions::findByCode('workspaces');
     $m = Members::findOneByObjectId($this->getId(), $d->getId());
     return "ico-color" . ($m instanceof Member ? $m->getColor() : '0');
 }
예제 #3
0
function core_dimensions_after_save_member_permissions($member, &$ignored) {
	if (!$member instanceof Member || !($member->getId()>0)) return;
	$permission_group_ids = array();
	
	$cmp_rows = DB::executeAll("SELECT DISTINCT permission_group_id FROM ".TABLE_PREFIX."contact_member_permissions WHERE member_id = '".$member->getId()."' AND permission_group_id IN (SELECT id FROM ".TABLE_PREFIX."permission_groups WHERE type IN ('permission_groups','user_groups'))");
	foreach ($cmp_rows as $row) {
		$permission_group_ids[$row['permission_group_id']] = $row['permission_group_id'];
	}
	
	$contacts = array();
	// users
	if (count($permission_group_ids) > 0) {
		$contacts = Contacts::findAll(array('conditions' => 'user_type > 0 && permission_group_id IN ('.implode(',', $permission_group_ids).')'));
	}
	// contacts
	$contact_rows = DB::executeAll("SELECT DISTINCT om.object_id FROM ".TABLE_PREFIX."object_members om INNER JOIN ".TABLE_PREFIX."contacts c ON c.object_id=om.object_id 
		WHERE om.member_id='".$member->getId()."' AND c.user_type=0");
	$no_user_ids = array();
	if (is_array($contact_rows)) {
		foreach ($contact_rows as $row) {
			$no_user_ids[] = $row['object_id'];
		}
	}
	$more_contacts = Contacts::findAll(array('conditions' => 'object_id IN ('.implode(',', $no_user_ids).')'));
	
	$contacts = array_merge($contacts, $more_contacts);
	$contact_ids = array(0);
	
	$persons_dim = Dimensions::findByCode("feng_persons");

	core_dim_remove_contacts_member_associations($member);
	
	foreach ($contacts as $contact) {
		$contact_id = $contact->getId();
		$contact_member = Members::findOneByObjectId($contact_id, $persons_dim->getId());
		if ($contact_member instanceof Member) {
			core_dim_add_contact_member_associations($contact_member, $member);
			
			if ($contact instanceof Contact && $contact->isUser()) {
				$has_project_permissions = ContactMemberPermissions::instance()->count("permission_group_id = '".$contact->getPermissionGroupId()."' AND member_id = ".$member->getId()) > 0;
				if (!$has_project_permissions) {
					RoleObjectTypePermissions::createDefaultUserPermissions($contact, $member);
				}
			}
		}
		// add user content object to customer member
		ObjectMembers::addObjectToMembers($contact_id, array($member));
		$contact->addToSharingTable();
		$contact_ids[] = $contact_id;
	}
	
	// remove contacts whose members are no longer associated to the customer member
	$previous_users_in_member = Contacts::instance()->listing(array(
		'member_ids' => array($member->getId()),
		'ignore_context' => true,
		'extra_conditions' => ' AND e.user_type > 0 AND e.object_id NOT IN ('.implode(',', $contact_ids).')',
	))->objects;
	foreach ($previous_users_in_member as $prev_u) {
		ObjectMembers::removeObjectFromMembers($prev_u, logged_user(), array($member), array($member->getId()));
	}
	
	// refresh dimensions
	evt_add("reload dimension tree", array('dim_id' => $persons_dim->getId(), 'node' => null));
}