private function trackerHasOnlyTitleRequired(Tracker $tracker, Tracker_Semantic_Title $semantic_title)
 {
     $used_fields = $this->form_element_factory->getUsedFields($tracker);
     foreach ($used_fields as $used_field) {
         if ($used_field->isRequired() && $used_field->getId() != $semantic_title->getFieldId()) {
             return false;
         }
     }
     return true;
 }
 public function testExport()
 {
     $GLOBALS['Language'] = new MockBaseLanguage($this);
     $GLOBALS['Language']->setReturnValue('getText', 'Title', array('plugin_tracker_admin_semantic', 'title_label'));
     $GLOBALS['Language']->setReturnValue('getText', 'Define the title of an artifact', array('plugin_tracker_admin_semantic', 'title_description'));
     $xml = simplexml_load_file(dirname(__FILE__) . '/_fixtures/ImportTrackerSemanticTitleTest.xml');
     $tracker = new MockTracker();
     $f = new MockTracker_FormElement_Field_Text();
     $f->setReturnValue('getId', 102);
     $tst = new Tracker_Semantic_Title($tracker, $f);
     $root = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><tracker />');
     $array_mapping = array('F13' => '102');
     $tst->exportToXML($root, $array_mapping);
     $this->assertEqual((string) $xml->shortname, (string) $root->semantic->shortname);
     $this->assertEqual((string) $xml->label, (string) $root->semantic->label);
     $this->assertEqual((string) $xml->description, (string) $root->semantic->description);
     $this->assertEqual((string) $xml->field['REF'], (string) $root->semantic->field['REF']);
 }
 /**
  * @return Tracker_SemanticCollection
  */
 public function getSemantics()
 {
     $semantics = new Tracker_SemanticCollection();
     $title_semantic = Tracker_Semantic_Title::load($this->tracker);
     $semantics->add($title_semantic->getShortName(), $title_semantic);
     $status_semantic = Tracker_Semantic_Status::load($this->tracker);
     $semantics->add($status_semantic->getShortName(), $status_semantic);
     $contributor_semantic = Tracker_Semantic_Contributor::load($this->tracker);
     $semantics->add($contributor_semantic->getShortName(), $contributor_semantic);
     $tooltip_semantic = $this->tracker->getTooltip();
     $semantics->add($tooltip_semantic->getShortName(), $tooltip_semantic);
     $this->addOtherSemantics($semantics);
     return $semantics;
 }
 public function getByTracker(Tracker $tracker)
 {
     return Tracker_Semantic_Title::load($tracker);
 }
 /**
  *
  * @param <type> $recipient
  * @param <type> $ignore_perms
  * @return <type>
  */
 public function fetchMailTitle($recipient, $format = 'text', $ignore_perms = false)
 {
     $output = '';
     if ($title_field = Tracker_Semantic_Title::load($this->getTracker())->getField()) {
         if ($ignore_perms || $title_field->userCanRead($recipient)) {
             if ($value = $this->getLastChangeset()->getValue($title_field)) {
                 if ($title = $value->getText()) {
                     $output .= $title;
                 }
             }
         }
     }
     return $output;
 }
 /**
  * Returns the "open" artifacts 
  *  - assigned to user $user_id OR
  *  - submitted by user $user_id OR
  *  - submitted by or assigned to user $user_id.
  * regarding the callback method (respectively
  *  - searchOpenAssignedToUserId,
  *  - searchOpenSubmittedByUserId
  *  - searchOpenSubmittedByOrAssignedToUserId)
  *
  * in an array of the form:
  * array(
  *    $tracker_id => array(
  *                      'tracker'   => $tracker (Tracker),
  *                      'artifacts' => array(
  *                                          'artifact' => $artifact (Tracker_Artifact),
  *                                          'title'    => $title (string)
  *                                     )
  *                   )
  * )
  *
  * @param int    $user_id  the id of the user
  * @param string $callback the callback method
  *
  * @return array Complex array of artifacts group by trackers (see above)
  */
 protected function getUserOpenArtifacts($user_id, $callback)
 {
     $tf = TrackerFactory::instance();
     $artifacts = array();
     foreach ($this->getDao()->{$callback}($user_id) as $row) {
         if (!isset($artifacts[$row['tracker_id']])) {
             $tracker = $tf->getTrackerById($row['tracker_id']);
             $with_title = false;
             if ($title_field = Tracker_Semantic_Title::load($tracker)->getField()) {
                 if ($title_field->userCanRead()) {
                     $with_title = true;
                 }
             }
             $artifacts[$row['tracker_id']] = array('tracker' => $tracker, 'with_title' => $with_title, 'artifacts' => array());
         }
         if (!isset($artifacts[$row['tracker_id']]['artifacts'][$row['id']])) {
             $artifact = $this->getInstanceFromRow($row);
             if ($artifact->userCanView()) {
                 $artifacts[$row['tracker_id']]['artifacts'][$row['id']] = array('artifact' => $artifact, 'title' => $artifacts[$row['tracker_id']]['with_title'] ? $row['title'] : '');
             }
         }
     }
     return $artifacts;
 }
Beispiel #7
0
 /**
  * Return the title field, or null if no title field defined
  *
  * @return Tracker_FormElement_Text the title field, or null if not defined
  */
 public function getTitleField()
 {
     $title_field = Tracker_Semantic_Title::load($this)->getField();
     if ($title_field) {
         return $title_field;
     } else {
         return null;
     }
 }
 public function tearDown()
 {
     parent::tearDown();
     Tracker_Semantic_Title::clearInstances();
 }
 /**
  * Allows clear factory instance for test. DO NOT USE IT IN PRODUCTION!
  */
 public static function clearInstances()
 {
     self::$_instances = null;
 }
 /**
  * @return array of Tracker_Semantic
  */
 public function getSemantics()
 {
     $semantics = array();
     $t = Tracker_Semantic_Title::load($this->tracker);
     $semantics[$t->getShortName()] = $t;
     $t = Tracker_Semantic_Status::load($this->tracker);
     $semantics[$t->getShortName()] = $t;
     $t = Tracker_Semantic_Contributor::load($this->tracker);
     $semantics[$t->getShortName()] = $t;
     $t = $this->tracker->getTooltip();
     $semantics[$t->getShortName()] = $t;
     return $semantics;
 }
 protected function userCanReadBacklogTitleField(PFUser $user, Tracker $tracker)
 {
     if (!isset($this->cache_read_title[$tracker->getId()])) {
         $field = Tracker_Semantic_Title::load($tracker)->getField();
         if (!$field) {
             $this->cache_read_title[$tracker->getId()] = false;
         } else {
             $this->cache_read_title[$tracker->getId()] = $field->userCanRead($user);
         }
     }
     return $this->cache_read_title[$tracker->getId()];
 }