/** * Populate portal object quick options * * @param NamedList $options * @param ProjectObject $object * @param Portal $portal * @param Commit $commit * @param string $file * @return null */ function source_handle_on_portal_object_quick_options(&$options, $object, $portal = null, $commit = null, $file = null) { if (instance_of($object, 'Repository')) { $options->beginWith('source', array('text' => lang('File Source'), 'url' => $object->getPortalBrowseUrl($portal, $commit, $file))); $options->addAfter('history', array('text' => lang('File History'), 'url' => $object->getPortalFileHistoryUrl($portal, $commit, $file)), 'source'); $options->addAfter('compare', array('text' => lang('Compare'), 'url' => $object->getPortalFileCompareUrl($portal, $commit, $file)), 'history'); $options->addAfter('download', array('text' => lang('Download'), 'url' => $object->getPortalFileDownloadUrl($portal, $commit, $file)), 'compare'); } // if }
/** * Populate object options array * * @param NamedList $options * @param Page $object * @param User $user * @return null */ function pages_handle_on_project_object_options(&$options, $object, $user) { if (instance_of($object, 'Page') && $object->canEdit($user)) { if ($object->getIsArchived()) { $options->addAfter('unarchive', array('url' => $object->getUnarchiveUrl(), 'text' => lang('Unarchive'), 'method' => 'post', 'confirm' => lang('Are you sure that you want to mark this archived page as active?')), 'edit'); } else { $options->addAfter('archive', array('url' => $object->getArchiveUrl(), 'text' => lang('Archive'), 'method' => 'post', 'confirm' => lang('Are you sure that you want to archive this page?')), 'edit'); } // if } // if }
/** * Populate object options array * * @param NamedList $options * @param ProjectObject $object * @param User $user * @return null */ function discussions_handle_on_project_object_options(&$options, $object, $user) { if (instance_of($object, 'Discussion') && $object->canEdit($user)) { if ($object->getIsPinned()) { $options->addAfter('unpin', array('url' => $object->getUnpinUrl(), 'text' => lang('Unpin'), 'method' => 'post'), 'edit'); } else { $options->addAfter('pin', array('url' => $object->getPinUrl(), 'text' => lang('Pin'), 'method' => 'post'), 'edit'); } // if } // if }
/** * Populate quick object options * * @param NamedList $options * @param ProjectObject $object * @param Use $user * @return null */ function milestones_handle_on_project_object_quick_options(&$options, $object, $user) { if (instance_of($object, 'Milestone') && $object->canEdit($user)) { $options->addAfter('reschedule', array('url' => $object->getRescheduleUrl(), 'text' => lang('Reschedule')), 'edit'); } // if }
/** * Populate quick object options * * @param NamedList $options * @param ProjectObject $object * @param Use $user * @return null */ function files_handle_on_project_object_quick_options(&$options, $object, $user) { if (instance_of($object, 'File')) { $options->beginWith('download', array('text' => lang('Download'), 'url' => $object->getDownloadUrl(true))); if ($object->canEdit($user)) { $options->addAfter('new_revision', array('text' => lang('New Version'), 'url' => $object->getNewVersionUrl()), 'edit'); } // if } // if }
/** * Return array of object options * * @param User $user * @return NamedList */ function getOptions($user) { if (!isset($this->options[$user->getId()])) { $options = new NamedList(); if ($this->canEdit($user)) { $options->add('edit', array('url' => $this->getEditUrl(), 'text' => lang('Edit'))); } // if if ($this->can_have_comments && $this->canChangeLockedState($user)) { if ($this->getIsLocked()) { $options->addAfter('unlock', array('url' => $this->getUnlockUrl(), 'text' => lang('Unlock Comments'), 'method' => 'post'), 'star'); } else { $options->addAfter('lock', array('url' => $this->getLockUrl(), 'text' => lang('Lock Comments'), 'method' => 'post'), 'star'); } // if } // if if (StarredObjects::isStarred($this, $user)) { $options->add('unstar', array('text' => lang('Unstar'), 'url' => $this->getUnstarUrl(), 'method' => 'post')); } else { $options->add('star', array('text' => lang('Star'), 'url' => $this->getStarUrl(), 'method' => 'post')); } // if if ($this->canMove($user)) { $options->add('move_to_project', array('text' => lang('Move to Project'), 'url' => $this->getMoveUrl())); } // if if ($this->canCopy($user)) { $options->add('copy_to_project', array('text' => lang('Copy to Project'), 'url' => $this->getCopyUrl())); } // if if ($this->canDelete($user)) { if ($this->getState() == STATE_DELETED) { $options->add('restore_from_trash', array('text' => lang('Restore from Trash'), 'url' => $this->getUntrashUrl(), 'method' => 'post')); } else { $options->add('move_to_trash', array('text' => lang('Move to Trash'), 'url' => $this->getTrashUrl(), 'method' => 'post')); } // if } // if if ($this->canChangeCompleteStatus($user)) { if ($this->isCompleted()) { $options->add('reopen', array('text' => lang('Reopen'), 'url' => $this->getOpenUrl(), 'method' => 'post')); } else { $options->add('complete', array('text' => lang('Complete'), 'url' => $this->getCompleteUrl(), 'method' => 'post')); } // if } // if if ($this->canSubscribe($user)) { if (Subscriptions::isSubscribed($user, $this)) { $options->add('unsubscribe', array('text' => lang('Unsubscribe'), 'url' => $this->getUnsubscribeUrl(), 'method' => 'post')); } else { $options->add('subscribe', array('text' => lang('Subscribe'), 'url' => $this->getSubscribeUrl(), 'method' => 'post')); } // if } // if if ($this->canEdit($user)) { if ($this->can_have_subscribers) { $options->add('manage_subscriptions', array('text' => lang('Manage Subscriptions'), 'url' => $this->getSubscriptionsUrl())); } // if if ($this->can_have_attachments) { $options->add('manage_attachments', array('text' => lang('Manage Attachments'), 'url' => $this->getAttachmentsUrl())); } // if } // if event_trigger('on_project_object_options', array(&$options, $this, $user)); $this->options[$user->getId()] = $options; } // if return $this->options[$user->getId()]; }