PHP Method User::getProjectPermission, Code Examples

PHP User::getProjectPermission - 26 examples found. These are the top rated real world PHP examples of method User::getProjectPermission from package extracted from open source projects. You can rate examples to help us improve the quality of examples
/**
 * Handle on prepare project overview event
 *
 * @param NamedList $tabs
 * @param User $logged_user
 * @param Project $project
 * @return null
 */
function milestones_handle_on_project_tabs(&$tabs, &$logged_user, &$project)
{
    if ($logged_user->getProjectPermission('milestone', $project) >= PROJECT_PERMISSION_ACCESS) {
        $tabs->add('milestones', array('text' => lang('Milestones'), 'url' => milestones_module_url($project)));
    }
    // if
    if ($logged_user->getProjectPermission('ticket', $project) >= PROJECT_PERMISSION_ACCESS) {
        $tabs->add('tickets', array('text' => lang('Tickets'), 'url' => tickets_module_url($project)));
    }
    // if
    if ($logged_user->getProjectPermission('page', $project) >= PROJECT_PERMISSION_ACCESS) {
        $tabs->add('pages', array('text' => lang('Pages'), 'url' => pages_module_url($project)));
    }
    // if
}
/**
 * Handle on_milestone_add_links event
 *
 * @param Milestone $milestone
 * @param User $user
 * @param array $links
 * @return null
 */
function tickets_handle_on_milestone_add_links($milestone, $user, &$links)
{
    if ($user->getProjectPermission('ticket', $milestone->getProject()) >= PROJECT_PERMISSION_CREATE) {
        $links[lang('Ticket')] = tickets_module_add_ticket_url($milestone->getProject(), array('milestone_id' => $milestone->getId()));
    }
    // if
}
/**
 * Handle on prepare project overview event
 *
 * @param NamedList $tabs
 * @param User $logged_user
 * @param Project $project
 * @return null
 */
function source_handle_on_project_tabs(&$tabs, &$logged_user, &$project)
{
    if ($logged_user->getProjectPermission('repository', $project) >= PROJECT_PERMISSION_ACCESS) {
        $tabs->add('source', array('text' => lang('Source'), 'url' => source_module_url($project)));
    }
    // if
}
/**
 * Handle on_milestone_add_links event
 *
 * @param Milestone $milestone
 * @param User $user
 * @param array $links
 * @return null
 */
function pages_handle_on_milestone_add_links($milestone, $user, &$links)
{
    if ($user->getProjectPermission('page', $milestone->getProject()) >= PROJECT_PERMISSION_CREATE) {
        $links[lang('Page')] = pages_module_add_page_url($milestone->getProject(), array('milestone_id' => $milestone->getId()));
    }
    // if
}
/**
 * Handle on prepare project overview event
 *
 * @param NamedList $tabs
 * @param User $logged_user
 * @param Project $project
 * @return null
 */
function checklists_handle_on_project_tabs(&$tabs, &$logged_user, &$project)
{
    if ($logged_user->getProjectPermission('checklist', $project) >= PROJECT_PERMISSION_ACCESS) {
        $tabs->add('checklists', array('text' => lang('Checklists'), 'url' => checklists_module_url($project)));
    }
    // if
}
/**
 * Populate $objects with objects that $user can see
 *
 * @param Milestone $milestone
 * @param array $objects
 * @param User $user
 * @return null
 */
function checklists_handle_on_milestone_objects(&$milestone, &$objects, &$user)
{
    if ($user->getProjectPermission('checklist', $milestone->getProject()) >= PROJECT_PERMISSION_ACCESS) {
        $objects[lang('Checklists')] = Checklists::findByMilestone($milestone, STATE_VISIBLE, $user->getVisibility());
    }
    // if
}
/**
 * Handle on prepare project overview event
 *
 * @param NamedList $tabs
 * @param User $logged_user
 * @param Project $project
 * @return null
 */
function timetracking_handle_on_project_tabs(&$tabs, &$logged_user, &$project)
{
    if ($logged_user->getProjectPermission('timerecord', $project) >= PROJECT_PERMISSION_ACCESS) {
        $tabs->add('time', array('text' => lang('Time'), 'url' => timetracking_module_url($project)));
    }
    // if
}
/**
 * Handle on_milestone_add_links event
 *
 * @param Milestone $milestone
 * @param User $user
 * @param array $links
 * @return null
 */
function discussions_handle_on_milestone_add_links($milestone, $user, &$links)
{
    if ($user->getProjectPermission('discussion', $milestone->getProject()) >= PROJECT_PERMISSION_CREATE) {
        $links[lang('Discussion')] = discussions_module_add_discussion_url($milestone->getProject(), array('milestone_id' => $milestone->getId()));
    }
    // if
}
 /**
  * Return all milestones for a given project
  *
  * @param Project $project
  * @param User $user
  * @return array
  */
 function findByProject($project, $user)
 {
     if ($user->getProjectPermission('milestone', $project) >= PROJECT_PERMISSION_ACCESS) {
         return ProjectObjects::find(array('conditions' => array('project_id = ? AND type = ? AND state >= ? AND visibility >= ?', $project->getId(), 'Milestone', STATE_VISIBLE, $user->getVisibility()), 'order' => 'name'));
     }
     // if
     return null;
 }
/**
 * Handle on prepare project overview event
 *
 * @param NamedList $tabs
 * @param User $logged_user
 * @param Project $project
 * @return null
 */
function files_handle_on_project_tabs(&$tabs, &$logged_user, &$project)
{
    $tabs->add('attachments', array('text' => lang('Attachments'), 'url' => assemble_url('attachments_list', array('project_id' => $project->getId()))));
    if ($logged_user->getProjectPermission('file', $project) >= PROJECT_PERMISSION_ACCESS) {
        $tabs->add('files', array('text' => lang('Files'), 'url' => files_module_url($project)));
    }
    // if
}
Example #11
0
 /**
  * Returns value of CAN_UPLOAD_FILES permission
  *
  * @param User $user
  * @param Project $project
  * @return boolean
  */
 function canUpload(User $user, Project $project)
 {
     if (!$user->isProjectUser($project)) {
         return false;
     }
     // if
     return $user->getProjectPermission($project, ProjectUsers::CAN_UPLOAD_FILES);
 }
 /**
  * Returns true if $user can change billable status of specific record
  *
  * @param User $user
  * @return boolean
  */
 function canChangeBillableStatus($user)
 {
     return $user->getProjectPermission('timerecord', $this->getProject()) >= PROJECT_PERMISSION_MANAGE;
 }
 /**
  * Check if specific user can add messages to specific project
  *
  * @access public
  * @param User $user
  * @param Project $project
  * @return booelean
  */
 function canAdd(User $user, Project $project)
 {
     if (!$user->isProjectUser($project)) {
         return false;
         // user is on project
     }
     // if
     if ($user->isAdministrator()) {
         return true;
         // administrator
     }
     // if
     return $user->getProjectPermission($project, PermissionManager::CAN_MANAGE_MESSAGES);
 }
 /**
  * Returns true if $user can delete this object
  *
  * @param User $user
  * @param string $manage_permission_name
  * @return boolean
  */
 function canDelete($user)
 {
     $project = $this->getProject();
     if (!instance_of($project, 'Project')) {
         return false;
     }
     // if
     if ($user->isProjectManager() || $user->isProjectLeader($this->getProject())) {
         return true;
         // administrators and project managers have all permissions
     }
     // if
     if ($this->getVisibility() < VISIBILITY_NORMAL && !$user->canSeePrivate()) {
         return false;
     }
     // if
     if ($this->permission_name && $user->getProjectPermission($this->permission_name, $project) >= PROJECT_PERMISSION_MANAGE) {
         return true;
     }
     // if
     // Author in the next three hours
     if ($this->getCreatedById() == $user->getId()) {
         $created_on = $this->getCreatedOn();
         return time() < $created_on->getTimestamp() + 10800;
     }
     // if
     return false;
 }
 /**
  * Returns true if $user can create a new ticket in $project
  *
  * @param User $user
  * @param Project $project
  * @return boolean
  */
 function canReorder($user, $project)
 {
     return $user->getProjectPermission('checklist', $project) == PROJECT_PERMISSION_MANAGE;
 }
 /**
  * Check if user can add task lists in specific project
  *
  * @param User $user
  * @param Project $project
  * @return boolean
  */
 function canAdd(User $user, Project $project)
 {
     if ($user->isAccountOwner()) {
         return true;
     }
     // if
     if ($user->isAdministrator()) {
         return true;
     }
     // if
     return $user->getProjectPermission($project, PermissionManager::CAN_MANAGE_TASKS);
 }
Example #17
0
 /**
  * Check if specific user can add new time to specific project
  *
  * @access public
  * @param User $user
  * @param Project $project
  * @return boolean
  */
 function canAdd(User $user, Project $project)
 {
     if (!$user->isProjectUser($project)) {
         return false;
     }
     if ($user->isAdministrator()) {
         return true;
     }
     return $user->getProjectPermission($project, ProjectTime::CAN_MANAGE_TIME);
 }
 /**
  * Check CAN_MANAGE_DOCUMENS permission
  *
  * @access public
  * @param User $user
  * @return boolean
  */
 function canManage(User $user)
 {
     if (!$user->isProjectUser($this->getProject())) {
         return false;
     }
     return $user->getProjectPermission($this->getProject(), PermissionManager::CAN_MANAGE_FILES);
 }
 /**
  * Check if user can add task lists in specific project
  *
  * @param User $user
  * @param Project $project
  * @return boolean
  */
 function canAdd(User $user, Project $project)
 {
     if ($user->isAccountOwner()) {
         return true;
     }
     // if
     return $user->getProjectPermission($project, ProjectUsers::CAN_MANAGE_TASKS);
 }
Example #20
0
 /**
  * Returns value of CAN_UPLOAD_FILES permission
  *
  * @param User $user
  * @param Project $project
  * @return boolean
  */
 function canUpload(User $user, Project $project)
 {
     trace(__FILE__, 'canUpload');
     if (!$user->isProjectUser($project)) {
         return false;
     }
     // if
     return $user->getProjectPermission($project, PermissionManager::CAN_UPLOAD_FILES);
 }
 /**
  * Check if specific user can delete this <!--category-->
  *
  * @param User $user
  * @return boolean
  */
 function canDelete(User $user)
 {
     if (!$user->isProjectUser($this->getProject())) {
         return false;
         // user is on project
     }
     // if
     if ($user->isAdministrator()) {
         return true;
         // user is administrator or root
     }
     // if
     return $user->getProjectPermission($this->getProject(), ProjectTicket::CAN_MANAGE_TICKETS);
 }
 /**
  * Check if specific user can update this ticket
  *
  * @access public
  * @param User $user
  * @return boolean
  */
 function canEdit(User $user)
 {
     if ($user->isAdministrator()) {
         return true;
     }
     // if
     if (!$user->isProjectUser($this->getProject())) {
         return false;
     }
     // if
     if ($this->isPrivate() && !$user->isMemberOfOwnerCompany()) {
         return false;
         // user that is not member of owner company can't access private objects
     }
     // if
     $assigned_to = $this->getAssignedTo();
     if ($assigned_to instanceof User) {
         if ($user->getId() == $assigned_to->getId()) {
             return true;
         }
         // if
     } elseif ($assigned_to instanceof Company) {
         if ($user->getCompanyId() == $assigned_to->getId()) {
             return true;
         }
         // if
     }
     // if
     return $user->getProjectPermission($this->getProject(), ProjectTicket::CAN_MANAGE_TICKETS);
 }
Example #23
0
 /**
  * Empty implementation of abstract methods. Messages determine does user have
  * permissions to add comment
  *
  * @param void
  * @return null
  */
 function canAdd(User $user, Project $project)
 {
     if (!$user->isProjectUser($project)) {
         return false;
     }
     return $user->getProjectPermission($project, ProjectUsers::CAN_MANAGE_FILES);
 }
 /**
  * Does user have permission to add
  *
  * @param void
  * @return null
  */
 function canAdd(User $user, Project $project)
 {
     trace(__FILE__, 'canAdd()');
     if (!$user->isProjectUser($project)) {
         return false;
     }
     if ($user->isAdministrator()) {
         return true;
     }
     return $user->getProjectPermission($project, PermissionManager::CAN_MANAGE_FILES);
 }
 /**
  * Can change status of this milestone (completed / open)
  *
  * @access public
  * @param User $user
  * @return boolean
  */
 function canChangeStatus(User $user)
 {
     if ($user->getProjectPermission($this->getProject(), PermissionManager::CAN_CHANGE_STATUS_MILESTONES)) {
         return true;
     }
     if ($this->getCreatedById() == $user->getId()) {
         return true;
     }
     if ($user->isAdministrator()) {
         return true;
     }
     // Additional check - is this milestone assigned to this user or its company
     if ($this->getAssignedTo() instanceof User) {
         if ($user->getId() == $this->getAssignedTo()->getObjectId()) {
             return true;
         }
     } elseif ($this->getAssignedTo() instanceof Company) {
         if ($user->getCompanyId() == $this->getAssignedTo()->getObjectId()) {
             return true;
         }
     }
     // if
     return false;
 }
 /**
  * Returns true if user can attach file to this object
  *
  * @param User $user
  * @param Project $project
  * @return boolean
  */
 function canAttachFile(User $user, Project $project)
 {
     if (!$this->isFileContainer()) {
         return false;
     }
     if ($this->isNew()) {
         return $user->getProjectPermission($project, PermissionManager::CAN_UPLOAD_FILES);
     } else {
         return $this->canEdit($user);
     }
     // if
 }