foreach ($dimensions as $dimension) { if (in_array($dimension->getCode(), array('feng_users', 'feng_persons'))) { continue; } if (!isset($dimensions_info[$dimension->getName()])) { $dimensions_info[$dimension->getName()] = array('id' => $dimension->getId(), 'members' => array()); } } $members = $object->getMembers(); foreach ($members as $member) { /* @var $member Member */ $dimension = $member->getDimension(); if (in_array($dimension->getCode(), array('feng_users', 'feng_persons'))) { continue; } if (!can_read(logged_user(), array($member), $object->getObjectTypeId())) { continue; } if (!isset($dimensions_info[$dimension->getName()])) { $dimensions_info[$dimension->getName()] = array('members' => array(), 'icon' => $member->getIconClass()); } if (!isset($dimensions_info[$dimension->getName()]['icon'])) { $dimensions_info[$dimension->getName()]['icon'] = $member->getIconClass(); } $parents = array_reverse($member->getAllParentMembersInHierarchy(true)); foreach ($parents as $p) { $dimensions_info[$dimension->getName()]['members'][$p->getId()] = array('p' => $p->getParentMemberId(), 'name' => $p->getName(), 'ot' => $p->getObjectTypeId(), 'color' => $p->getMemberColor()); } } foreach ($dimensions_info as &$dim_info) { if (!isset($dim_info['icon'])) {
/** * Returns true if user can download this file * * @param User $user * @return boolean */ function canDownload(User $user) { return can_read($user, $this); }
/** * Returns true if $user can access this report * * @param Contact $user * @return boolean */ function canView(Contact $user) { return can_read($user, $this->getMembers(), $this->getObjectTypeId()); }
$dimensions = Dimensions::findAll(); foreach ($dimensions as $dimension) { if (in_array($dimension->getCode(), array('feng_users', 'feng_persons'))) continue; if (!isset($dimensions_info[$dimension->getName()])) { $dimensions_info[$dimension->getName()] = array('id' => $dimension->getId(), 'members' => array()); } } $members = $object->getMembers(); foreach ($members as $member) { /* @var $member Member */ $dimension = $member->getDimension(); if (in_array($dimension->getCode(), array('feng_users', 'feng_persons'))) continue; if ($dimension->getDefinesPermissions() && !can_read(logged_user(), array($member), $object->getObjectTypeId())) continue; if (!isset($dimensions_info[$dimension->getName()])) { $dimensions_info[$dimension->getName()] = array('members' => array(), 'icon' => $member->getIconClass()); } if (!isset($dimensions_info[$dimension->getName()]['icon'])) { $dimensions_info[$dimension->getName()]['icon'] = $member->getIconClass(); } $parents = array_reverse($member->getAllParentMembersInHierarchy(true)); foreach ($parents as $p) { $dimensions_info[$dimension->getName()]['members'][$p->getId()] = array('p' => $p->getParentMemberId(), 'name' => $p->getName(), 'ot' => $p->getObjectTypeId(), 'color' => $p->getMemberColor()); } } foreach ($dimensions_info as &$dim_info) { if (!isset($dim_info['icon'])) {
function copy() { if (logged_user()->isGuest()) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } ajx_set_no_toolbar(); $ws = active_or_personal_project(); $id = get_id(); $file = ProjectFiles::findById($id); if (!$file instanceof ProjectFile) { flash_error("file dnx"); ajx_current("empty"); return; } if (!can_read(logged_user(), $file)) { flash_error("no access permissions"); ajx_current("empty"); return; } if (!ProjectFile::canAdd(logged_user(), $ws)) { flash_error("no access permissions"); ajx_current("empty"); return; } try { DB::beginWork(); $copy = $file->copy(); $copy->setFilename(lang('copy of file', $file->getFilename())); $copy->save(); $copy->addToWorkspace($ws); $rev_data = array(); $rev_data['name'] = $copy->getFilename(); $rev_data['size'] = $file->getFileSize(); $rev_data['type'] = $file->getTypeString(); $rev_data['tmp_name'] = ROOT . '/tmp/' . rand(); $handler = fopen($rev_data['tmp_name'], 'w'); $file_content = $file->getLastRevision()->getFileContent(); fputs($handler, $file_content); fclose($handler); $copy->handleUploadedFile($rev_data, false, lang("copied from file", $file->getFilename(), $file->getUniqueObjectId())); DB::commit(); $this->setTemplate('file_details'); tpl_assign('file', $copy); tpl_assign('last_revision', $copy->getLastRevision()); tpl_assign('revisions', $copy->getRevisions()); } catch (Exception $ex) { DB::rollback(); flash_error($ex->getMessage()); ajx_current("empty"); } }
function reload_dimensions_js() { ajx_current("empty"); $dimensions = Dimensions::findAll(); $ot_extra_cond = ""; Hook::fire('available_object_types_extra_cond', null, $ot_extra_cond); $ots = ObjectTypes::getAvailableObjectTypesWithTimeslots($ot_extra_cond); $dims_info = array(); $perms_info = array(); foreach ($dimensions as $dim) { $dims_info[$dim->getId()] = array(); $perms_info[$dim->getId()] = array(); $members = $dim->getAllMembers(); foreach ($members as $member) { $mem_info = array(); $mem_info['id'] = $member->getId(); $mem_info['name'] = clean($member->getName()); $mem_info['ot'] = $member->getObjectTypeId(); $mem_info['path'] = $dim->getIsManageable() ? trim(clean($member->getPath())) : ''; $mem_info['ico'] = $member->getIconClass(); $mem_info['color'] = $member->getMemberColor(); $mem_info['parent_id'] = $member->getParentMemberId(); $mem_info['archived'] = $member->getArchivedById(); $p_info = array(); if ($dim->getIsManageable()) { foreach ($ots as $ot) { $p_info[$ot->getId()] = $dim->getDefinesPermissions() ? can_read(logged_user(), array($member), $ot->getId()) : true; } } $dims_info[$dim->getId()][$member->getId()] = $mem_info; $perms_info[$dim->getId()][$member->getId()] = $p_info; } } ajx_extra_data(array("dims" => $dims_info, "perms" => $perms_info)); }
static function canRead($bookId = null) { self::includeBasic(); $file_id = self::ogBookId(); if ($file_id == null) { return false; } if ($bookId != self::getGelsheetBookId($file_id)) { return false; } $file = ProjectFiles::findById($file_id); if (!$file instanceof ProjectFile) { return false; } return can_read(self::getCompanyWebsite()->getLoggedUser(), $file); }
function canLinkObject(User $user) { return can_manage_contacts($user, true) || can_read($user, $this); }
/** * Returns true if $user can access this report * * @param User $user * @return boolean */ function canView(User $user) { return can_read($user, $this); }
/** * Returns true if $user can view this email * * @param User $user * @return boolean */ function canView(User $user) { return can_read($user, $this); //return $this->getAccount()->getUserId() == $user->getId() || $user->isAdministrator(); }
/** * Can $user view this object * * @param User $user * @return boolean */ function canView(Contact $user) { if ($this->getRelObject() instanceof ContentDataObject) { return can_read($user, $this->getRelObject()->getMembers(), $this->getRelObject()->getObjectTypeId()); } else { return can_read($user, $this->getMembers(), $this->getObjectTypeId()); } }
/** * Can $user view this object * * @param User $user * @return boolean */ function canView(Contact $user) { return can_read($user,$this); } // canView
/** * Check if specific user can view this company * * @access public * @param User $user * @return boolean */ function canView(User $user) { if (can_manage_contacts(logged_user())) { return true; } else { return can_read($user, $this); } }
$amountOfObjects = user_config_option('amount_objects_to_show', null, logged_user()->getId()); $moreLinkedObjects = false; foreach ($linked_objects as $linked_object) { if (!$linked_object instanceof ApplicationDataObject) { continue; } //check that it is a valid object if ($linked_object instanceof Contact) { // if it is a contact if (!$linked_object->canView(logged_user())) { continue; } // check permissions on contacts } else { // not a contact if (!can_read(logged_user(), $linked_object)) { //check permissions on other COs continue; } } $object_title = $linked_object->getObjectName(); if (strlen($object_title) > 28) { $object_title = clean(utf8_substr($object_title, 0, 26)) . "…"; } else { $object_title = clean($object_title); } $icon_class = $linked_object->getObjectTypeName(); if ($linked_object instanceof ProjectFile) { $icon_class = 'file ico-' . str_replace(".", "_", str_replace("/", "-", $linked_object->getTypeString())); } $counter++;
/** * Return true if $user can link this task * * @param Contact $user * @return boolean */ function canLinkObject(Contact $user) { if (can_read($user, $this->getMembers(), $this->getObjectTypeId())) { return can_link_objects($user); } return parent::canLinkObject(); }