예제 #1
0
 function addCustomColumns($table)
 {
     global ${"{$table}_typ"};
     static $maxColumnIndex = 0;
     // hogy a load a custom fieldeket is betoltse az objektumba:
     //$customColumnIndexes or $customColumnIndexes = self::getCustomColumnIndexes($table);
     $maxColumnIndex or $maxColumnIndex = CustomField::getNextColumnIndex() - 1;
     //foreach( $customColumnIndexes as $columnIndex )
     //{
     //    if( !isset(${"{$table}_typ"}["attributes"][$columnIndex]) ) ${"{$table}_typ"}["attributes"][$columnIndex]=array("type"=>"TEXT");
     //}
     for ($i = 0; $i <= $maxColumnIndex; $i++) {
         if (!isset(${"{$table}_typ"}["attributes"]["col_{$i}"])) {
             ${"{$table}_typ"}["attributes"]["col_{$i}"] = array("type" => "TEXT");
         }
     }
 }
예제 #2
0
파일: itemfield.php 프로젝트: alencarmo/OCF
 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();
     }
 }