Exemplo n.º 1
0
 function addDefaultCustomFields($fromInstall = FALSE, $cid = 0)
 {
     global $lll;
     // Creating the fix fields:
     $v = new ItemField();
     $v->cid = $cid;
     $v->isCommon = !$cid;
     $v->name = $lll["item_id"];
     $v->showInForm = customfield_forNone;
     $v->type = customfield_text;
     $v->subType = customfield_integer;
     $v->sortable = TRUE;
     $v->columnIndex = "id";
     $v->searchable = customfield_forNone;
     $v->showInList = customfield_forNone;
     $v->showInDetails = customfield_forNone;
     $v->create();
     $v = new ItemField();
     $v->cid = $cid;
     $v->isCommon = !$cid;
     $v->name = $lll["appcategory"];
     $v->showInForm = customfield_forNone;
     $v->type = customfield_selection;
     $v->columnIndex = "cName";
     $v->searchable = customfield_forAll;
     $v->create();
     if (!$v->cid) {
         $v->showInList = customfield_forAll;
         $v->modify();
     }
     $v = new ItemField();
     $v->cid = $cid;
     $v->isCommon = !$cid;
     $v->name = $lll["creationtime"];
     $v->showInForm = customfield_forNone;
     $v->type = customfield_date;
     $v->searchable = customfield_forAll;
     $v->rangeSearch = TRUE;
     $v->columnIndex = "creationtime";
     $v->create();
     if (!$v->cid) {
         $v->showInList = customfield_forAll;
         $v->modify();
     }
     $v = new ItemField();
     $v->cid = $cid;
     $v->isCommon = !$cid;
     $v->name = $lll["item_status"];
     $v->showInForm = customfield_forAdmin;
     $v->showInDetails = customfield_forAdmin;
     $v->type = customfield_selection;
     $v->values = "0,1";
     $v->columnIndex = "status";
     $v->searchable = customfield_forAdmin;
     $v->create();
     if (!$v->cid) {
         $v->showInList = customfield_forAdmin;
         $v->modify();
     }
     $v = new ItemField();
     $v->cid = $cid;
     $v->isCommon = !$cid;
     $v->name = $lll["item_clicked"];
     $v->showInForm = customfield_forNone;
     $v->showInDetails = customfield_forOwner;
     $v->type = customfield_text;
     $v->subType = customfield_integer;
     $v->columnIndex = "clicked";
     $v->searchable = customfield_forAdmin;
     $v->rangeSearch = TRUE;
     $v->create();
     if (!$v->cid) {
         $v->showInList = customfield_forLoggedin;
         $v->modify();
     }
     $v = new ItemField();
     $v->cid = $cid;
     $v->isCommon = !$cid;
     $v->name = $lll["item_responded"];
     $v->showInForm = customfield_forNone;
     $v->showInDetails = customfield_forOwner;
     $v->type = customfield_text;
     $v->subType = customfield_integer;
     $v->columnIndex = "responded";
     $v->searchable = customfield_forAdmin;
     $v->rangeSearch = TRUE;
     $v->create();
     if (!$v->cid) {
         $v->showInList = customfield_forAdmin;
         $v->modify();
     }
     $v = new ItemField();
     $v->cid = $cid;
     $v->isCommon = !$cid;
     $v->name = $lll["item_ownerName"];
     $v->showInForm = customfield_forNone;
     $v->showInDetails = customfield_forAll;
     $v->type = customfield_multipleselection;
     $v->columnIndex = "ownerName";
     $v->searchable = customfield_forAdmin;
     $v->create();
     if (!$v->cid) {
         $v->showInList = customfield_forAll;
         $v->modify();
     }
     $v = new ItemField();
     $v->cid = $cid;
     $v->isCommon = !$cid;
     $v->name = $lll["exp"];
     $v->showInForm = customfield_forNone;
     $v->showInDetails = customfield_forOwner;
     $v->type = customfield_date;
     $v->searchable = customfield_forAdmin;
     $v->rangeSearch = TRUE;
     $v->columnIndex = "expirationTime";
     $v->create();
     if (!$v->cid) {
         $v->showInList = customfield_forAdmin;
         $v->modify();
     }
     // ha uj kategoriat hozunk letre, akkor a tobbi categoriaban common-na tett mezoket bele kell masolni:
     if ($cid) {
         $query = "SELECT * FROM @customfield WHERE cid=0 AND isCommon=1 AND columnIndex LIKE 'col_%'";
         G::load($commonFields, $query);
         $customCommonFields = array();
         foreach ($commonFields as $field) {
             if (empty($customCommonFields[$field->name][$field->type])) {
                 $field->cid = $cid;
                 unset($field->id);
                 create($field);
                 $customCommonFields[$field->name][$field->type] = 1;
             }
         }
     }
     if (!$fromInstall) {
         // a kovetkezo mezoket csak kkor hozzuk letre, ha meg nem leteznek.
         // Akkor letezhetnek, ha az iment mar letrehoztuk oket, mert common-ok:
         if (!$cid || empty($customCommonFields[$lll["title"]][customfield_text])) {
             $v = new ItemField();
             $v->cid = $cid;
             $v->isCommon = !$cid;
             $v->name = $lll["title"];
             $v->type = customfield_text;
             $v->seo = customfield_title;
             $v->showInList = customfield_forAll;
             $v->mandatory = TRUE;
             $v->searchable = customfield_forAll;
             if (!$cid) {
                 $v->columnIndex = "title";
             }
             $v->create();
         }
         if (!$cid || empty($customCommonFields[$lll["description"]][customfield_textarea])) {
             $v = new ItemField();
             $v->cid = $cid;
             $v->isCommon = !$cid;
             $v->name = $lll["description"];
             $v->type = customfield_textarea;
             $v->seo = customfield_description;
             $v->showInList = customfield_forAll;
             $v->innewline = TRUE;
             $v->searchable = customfield_forAll;
             if (!$cid) {
                 $v->columnIndex = "description";
             }
             $v->create();
         }
         if ($cid && empty($customCommonFields[$lll["item_picture"]][customfield_picture])) {
             $v = new ItemField();
             $v->cid = $cid;
             $v->isCommon = FALSE;
             $v->name = $lll["item_picture"];
             $v->type = customfield_picture;
             $v->mainPicture = 1;
             $v->searchable = customfield_forAll;
             $v->showInList = customfield_forAll;
             $v->rowspan = TRUE;
             $v->create();
         }
     }
 }