Пример #1
0
 function modify()
 {
     list($oldIsCommon, $oldName, $oldColumnIndex, $this->userField) = G::getAttr($this->id, "customfield", "isCommon", "name", "columnIndex", "userField");
     // ha most allitjuk common-ra, uj columnIndex kell:
     if (!$oldIsCommon && $this->isCommon) {
         if ($this->commonFieldAlreadyExists()) {
             return;
         }
         $this->columnIndex = "col_" . CustomField::getNextColumnIndex();
     }
     parent::modify();
     if (!Roll::isFormInvalid() && !$this->isFixField()) {
         if ($oldIsCommon != $this->isCommon) {
             if ($this->isCommon) {
                 load($this);
                 $newColumnAdded = $this->addNewColumnToManagedTable();
                 // az item tablaban minden erteket atmasolunk a regi columnIndexrol az ujba:
                 if ($newColumnAdded) {
                     executeQuery("UPDATE @item SET {$this->columnIndex}={$oldColumnIndex}, {$oldColumnIndex}='' WHERE cid=#cid#", $this->cid);
                     $this->updatePictureNames($oldColumnIndex, $this->cid);
                 }
                 // TODO: a customlistek search felteteleinek update-ezese!
                 $this->nextAction =& new AppController("field/sortfield_form/{$this->cid}");
                 $this->propagateCommonField();
             } else {
                 // a globalis common torlese:
                 executeQuery("DELETE FROM @customfield WHERE cid=0 AND isCommon=1 AND  columnIndex=#ci#", $this->columnIndex);
                 // az osszes tobbi kategoriaban atallitjuk ezt a field-et unique-ra:
                 executeQuery("UPDATE @customfield SET isCommon=0 WHERE cid!=#cid# AND isCommon=1 AND columnIndex=#ci#", $this->cid, $this->columnIndex);
             }
         } elseif ($this->isCommon && $oldName != $this->name) {
             executeQuery("UPDATE @customfield SET name=#name# WHERE cid!=#cid# AND isCommon=1 AND columnIndex=#ci#", $this->name, $this->cid, $this->columnIndex);
         }
     }
     if (!Roll::isFormInvalid()) {
         CacheManager::resetAllCache();
     }
 }