Exemple #1
0
 /**
  * We check that something is really changed.
  */
 public function clean()
 {
     $this->cleaned_data = parent::clean();
     // As soon as we know that at least one change was done, we
     // return the cleaned data and do not go further.
     if (strlen(trim($this->cleaned_data['content']))) {
         return $this->cleaned_data;
     }
     if ($this->show_full) {
         $status = $this->issue->get_status();
         if (trim($this->cleaned_data['status']) != $status->name) {
             return $this->cleaned_data;
         }
         if (trim($this->issue->summary) != trim($this->cleaned_data['summary'])) {
             return $this->cleaned_data;
         }
         $owner = self::findUser($this->cleaned_data['owner']);
         if (is_null($owner) and !is_null($this->issue->get_owner()) or !is_null($owner) and is_null($this->issue->get_owner()) or !is_null($owner) and !is_null($this->issue->get_owner()) and $owner->id != $this->issue->get_owner()->id) {
             return $this->cleaned_data;
         }
         $tags = array();
         for ($i = 1; $i < 7; $i++) {
             if (strlen($this->cleaned_data['label' . $i]) > 0) {
                 if (strpos($this->cleaned_data['label' . $i], ':') !== false) {
                     list($class, $name) = explode(':', $this->cleaned_data['label' . $i], 2);
                     list($class, $name) = array(trim($class), trim($name));
                 } else {
                     $class = 'Other';
                     $name = trim($this->cleaned_data['label' . $i]);
                 }
                 $tags[] = array($class, $name);
             }
         }
         $oldtags = $this->issue->get_tags_list();
         foreach ($tags as $tag) {
             $found = false;
             foreach ($oldtags as $otag) {
                 if ($otag->class == $tag[0] and $otag->name == $tag[1]) {
                     $found = true;
                     break;
                 }
             }
             if (!$found) {
                 // new tag not found in the old tags
                 return $this->cleaned_data;
             }
         }
         foreach ($oldtags as $otag) {
             $found = false;
             foreach ($tags as $tag) {
                 if ($otag->class == $tag[0] and $otag->name == $tag[1]) {
                     $found = true;
                     break;
                 }
             }
             if (!$found) {
                 // old tag not found in the new tags
                 return $this->cleaned_data;
             }
         }
     }
     // no changes!
     throw new Pluf_Form_Invalid(__('No changes were entered.'));
 }