Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
m120330_130431_custom_user_fields.php
1 <?php
2 /**
3  * Gentics Portal.Node PHP
4  * Author & Copyright (c) by Gentics Software GmbH
5  * sales@gentics.com
6  * http://www.gentics.com
7  * Licenses can be found in the LICENSE.txt file in the root-folder of this installation
8  * You must not use this software without a valid license agreement.
9  */
10 class m120330_130431_custom_user_fields extends CDbMigration
11 {
12  public function safeUp()
13  {
14  $this->createTable('{{profiles_fields}}', array(
15  'id' => 'pk',
16  'varname' => 'string NOT NULL',
17  'title' => 'string NOT NULL',
18  'field_type' => 'string NOT NULL',
19  'field_size' => "integer NOT NULL DEFAULT '0'",
20  'field_size_min' => "integer NOT NULL DEFAULT '0'",
21  'required' => "integer NOT NULL DEFAULT '0'",
22  'match' => "string DEFAULT NULL",
23  'range' => "string NOT NULL DEFAULT ''",
24  'error_message' => "string NOT NULL DEFAULT ''",
25  'other_validator' => "text NOT NULL DEFAULT ''",
26  'default' => "string NOT NULL DEFAULT ''",
27  'widget' => "string NOT NULL DEFAULT ''",
28  'widgetparams' => "text NOT NULL DEFAULT ''",
29  'position' => "integer NOT NULL DEFAULT '0'",
30  'visible' => "integer NOT NULL DEFAULT '0'",
31  ));
32  $this->createIndex('profiles_fields_varname_idx', '{{profiles_fields}}', 'varname');
33  $this->createIndex('profiles_fields_widget_idx', '{{profiles_fields}}', 'widget');
34  $this->createIndex('profiles_fields_visible_idx', '{{profiles_fields}}', 'visible');
35 
36  $this->insert('{{profiles_fields}}', array('varname' => 'lastname', 'title' => 'Last Name', 'field_type' => 'VARCHAR', 'field_size' => 255, 'field_size_min' => 3, 'required' => 1, 'error_message' => 'Incorrect Last Name (length between 3 and 255 characters).', 'position' => 1, 'visible' => 3,));
37  $this->insert('{{profiles_fields}}', array('varname' => 'firstname', 'title' => 'First Name', 'field_type' => 'VARCHAR', 'field_size' => 255, 'field_size_min' => 3, 'required' => 1, 'error_message' => 'Incorrect First Name (length between 3 and 255 characters).', 'position' => 3, 'visible' => 3,));
38  $this->insert('{{profiles_fields}}', array('varname' => 'birthday', 'title' => 'Birthday', 'field_type' => 'DATE', 'field_size' => 0, 'field_size_min' => 0, 'required' => 2, 'widget' => 'UWjuidate', 'widgetparams' => '{"ui-theme":"base","defaultDate":"-20y","maxDate":"+0y","minDate":"-100y","yearRange":"-100:+0","changeMonth":"true","changeYear":"true"}', 'position' => 3, 'visible' => 2,));
39  $this->insert('{{profiles_fields}}', array('varname' => 'title', 'title' => 'Title', 'field_type' => 'VARCHAR', 'field_size' => '30', 'field_size_min' => '0', 'required' => '2', 'position' => '100', 'visible' => '3'));
40  $this->insert('{{profiles_fields}}', array('varname' => 'gender', 'title' => 'Gender', 'field_type' => 'VARCHAR', 'field_size' => '1', 'field_size_min' => '1', 'required' => '2', 'range' => 'M==Male;F==Female', 'position' => '100', 'visible' => '3'));
41  $this->insert('{{profiles_fields}}', array('varname' => 'photo', 'title' => 'Photo', 'field_type' => 'VARCHAR', 'field_size' => '255', 'field_size_min' => '0', 'required' => '0', 'other_validator' => '{\"file\":{\"types\":\"jpg, gif, png\",\"allowEmpty\":\"true\"}}', 'widget' => 'UWfile', 'widgetparams' => '{\'path\':\'assets\'}', 'position' => '100', 'visible' => '0'));
42  $this->insert('{{profiles_fields}}', array('varname' => 'private_zip', 'title' => 'Private Zip', 'field_type' => 'VARCHAR', 'field_size' => '64', 'field_size_min' => '0', 'required' => '2', 'position' => '100', 'visible' => '3'));
43  $this->insert('{{profiles_fields}}', array('varname' => 'private_city', 'title' => 'Private City ', 'field_type' => 'VARCHAR', 'field_size' => '50', 'field_size_min' => '0', 'required' => '2', 'position' => '100', 'visible' => '3'));
44  $this->insert('{{profiles_fields}}', array('varname' => 'private_country', 'title' => 'Private Country', 'field_type' => 'VARCHAR', 'field_size' => '50', 'field_size_min' => '0', 'required' => '2', 'position' => '100', 'visible' => '3'));
45  $this->insert('{{profiles_fields}}', array('varname' => 'private_phone_number', 'title' => 'Private Phone Number', 'field_type' => 'VARCHAR', 'field_size' => '100', 'field_size_min' => '0', 'required' => '2', 'position' => '100', 'visible' => '3'));
46  $this->insert('{{profiles_fields}}', array('varname' => 'private_mobile_phone', 'title' => 'Private Mobile Phone Number ', 'field_type' => 'VARCHAR', 'field_size' => '100', 'field_size_min' => '0', 'required' => '2', 'position' => '100', 'visible' => '3'));
47  $this->insert('{{profiles_fields}}', array('varname' => 'company', 'title' => 'Company', 'field_type' => 'VARCHAR', 'field_size' => '100', 'field_size_min' => '0', 'required' => '2', 'position' => '100', 'visible' => '3'));
48  $this->insert('{{profiles_fields}}', array('varname' => 'position', 'title' => 'Position', 'field_type' => 'VARCHAR', 'field_size' => '100', 'field_size_min' => '0', 'required' => '2', 'position' => '100', 'visible' => '3'));
49  $this->insert('{{profiles_fields}}', array('varname' => 'business_zip', 'title' => 'Business ZIP ', 'field_type' => 'VARCHAR', 'field_size' => '64', 'field_size_min' => '0', 'required' => '2', 'position' => '100', 'visible' => '3'));
50  $this->insert('{{profiles_fields}}', array('varname' => 'business_city', 'title' => 'Business City', 'field_type' => 'VARCHAR', 'field_size' => '50', 'field_size_min' => '0', 'required' => '2', 'position' => '100', 'visible' => '3'));
51  $this->insert('{{profiles_fields}}', array('varname' => 'business_country', 'title' => 'Business Country', 'field_type' => 'VARCHAR', 'field_size' => '50', 'field_size_min' => '0', 'required' => '2', 'position' => '100', 'visible' => '3'));
52  $this->insert('{{profiles_fields}}', array('varname' => 'business_phone_number', 'title' => 'Business Phone Number ', 'field_type' => 'VARCHAR', 'field_size' => '100', 'field_size_min' => '0', 'required' => '2', 'position' => '100', 'visible' => '3'));
53  $this->insert('{{profiles_fields}}', array('varname' => 'business_mobile_phone_number', 'title' => 'Business Mobile Phone Number', 'field_type' => 'VARCHAR', 'field_size' => '100', 'field_size_min' => '0', 'required' => '2', 'position' => '100', 'visible' => '3'));
54  $this->insert('{{profiles_fields}}', array('varname' => 'skypename', 'title' => 'Skypename', 'field_type' => 'VARCHAR', 'field_size' => '50', 'field_size_min' => '0', 'required' => '2', 'position' => '100', 'visible' => '3'));
55  $this->insert('{{profiles_fields}}', array('varname' => 'icq_number', 'title' => 'ICQ-Number', 'field_type' => 'VARCHAR', 'field_size' => '32', 'field_size_min' => '0', 'required' => '2', 'position' => '100', 'visible' => '3'));
56  $this->insert('{{profiles_fields}}', array('varname' => 'facebook_profile', 'title' => 'Facebook Profile', 'field_type' => 'VARCHAR', 'field_size' => '255', 'field_size_min' => '0', 'required' => '2', 'position' => '100', 'visible' => '3'));
57  $this->insert('{{profiles_fields}}', array('varname' => 'xing_profile', 'title' => 'Xing Profile', 'field_type' => 'VARCHAR', 'field_size' => '255', 'field_size_min' => '0', 'required' => '2', 'position' => '100', 'visible' => '3'));
58  $this->insert('{{profiles_fields}}', array('varname' => 'linkedin_profile', 'title' => 'LinkedIn Profile', 'field_type' => 'VARCHAR', 'field_size' => '255', 'field_size_min' => '0', 'required' => '2', 'position' => '100', 'visible' => '3'));
59  $this->insert('{{profiles_fields}}', array('varname' => 'twitter_name', 'title' => 'Twitter-Name', 'field_type' => 'VARCHAR', 'field_size' => '50', 'field_size_min' => '0', 'required' => '2', 'position' => '100', 'visible' => '3'));
60  $this->insert('{{profiles_fields}}', array('varname' => 'make_public', 'title' => 'Make my profile public', 'field_type' => 'VARCHAR', 'field_size' => '1', 'field_size_min' => '0', 'required' => '2', 'range' => 'checkbox-1', 'position' => '100', 'visible' => '3'));
61  $this->insert('{{profiles_fields}}', array('varname' => 'find_me_in_phone_book', 'title' => 'Find me in phone book', 'field_type' => 'VARCHAR', 'field_size' => '1', 'field_size_min' => '0', 'required' => '2', 'range' => 'checkbox-1', 'position' => '100', 'visible' => '3'));
62  $this->insert('{{profiles_fields}}', array('varname' => 'send_me_notifications', 'title' => 'Send me notifications via mail', 'field_type' => 'VARCHAR', 'field_size' => '1', 'field_size_min' => '0', 'required' => '2', 'range' => 'checkbox-1', 'position' => '100', 'visible' => '3', 'default' => 1));
63 
64 
65  $this->addColumn("{{profiles}}", "title", "string NOT NULL DEFAULT ''");
66  $this->addColumn("{{profiles}}", "gender", "string NOT NULL DEFAULT ''");
67  $this->addColumn("{{profiles}}", "photo", "string NOT NULL DEFAULT ''");
68  $this->addColumn("{{profiles}}", "private_zip", "string NOT NULL DEFAULT ''");
69  $this->addColumn("{{profiles}}", "private_city", "string NOT NULL DEFAULT ''");
70  $this->addColumn("{{profiles}}", "private_country", "string NOT NULL DEFAULT ''");
71  $this->addColumn("{{profiles}}", "private_phone_number", "string NOT NULL DEFAULT ''");
72  $this->addColumn("{{profiles}}", "private_mobile_phone", "string NOT NULL DEFAULT ''");
73  $this->addColumn("{{profiles}}", "company", "string NOT NULL DEFAULT ''");
74  $this->addColumn("{{profiles}}", "position", "string NOT NULL DEFAULT ''");
75  $this->addColumn("{{profiles}}", "business_zip", "string NOT NULL DEFAULT ''");
76  $this->addColumn("{{profiles}}", "business_country", "string NOT NULL DEFAULT ''");
77  $this->addColumn("{{profiles}}", "business_phone_number", "string NOT NULL DEFAULT ''");
78  $this->addColumn("{{profiles}}", "business_mobile_phone_number", "string NOT NULL DEFAULT ''");
79  $this->addColumn("{{profiles}}", "skypename", "string NOT NULL DEFAULT ''");
80  $this->addColumn("{{profiles}}", "icq_number", "string NOT NULL DEFAULT ''");
81  $this->addColumn("{{profiles}}", "facebook_profile", "string NOT NULL DEFAULT ''");
82  $this->addColumn("{{profiles}}", "xing_profile", "string NOT NULL DEFAULT ''");
83  $this->addColumn("{{profiles}}", "linkedin_profile", "string NOT NULL DEFAULT ''");
84  $this->addColumn("{{profiles}}", "twitter_name", "string NOT NULL DEFAULT ''");
85  $this->addColumn("{{profiles}}", "make_public", "string NOT NULL DEFAULT ''");
86  $this->addColumn("{{profiles}}", "business_city", "string NOT NULL DEFAULT ''");
87  $this->addColumn("{{profiles}}", "find_me_in_phone_book", "string NOT NULL DEFAULT ''");
88  $this->addColumn("{{profiles}}", "send_me_notifications", "string NOT NULL DEFAULT '1'");
89  }
90 
91  public function safeDown()
92  {
93  $this->dropTable('{{profiles_fields}}');
94 
95  $this->dropColumn("{{profiles}}", "title");
96  $this->dropColumn("{{profiles}}", "gender");
97  $this->dropColumn("{{profiles}}", "photo");
98  $this->dropColumn("{{profiles}}", "private_zip");
99  $this->dropColumn("{{profiles}}", "private_city");
100  $this->dropColumn("{{profiles}}", "private_country");
101  $this->dropColumn("{{profiles}}", "private_phone_number");
102  $this->dropColumn("{{profiles}}", "private_mobile_phone");
103  $this->dropColumn("{{profiles}}", "company");
104  $this->dropColumn("{{profiles}}", "position");
105  $this->dropColumn("{{profiles}}", "business_zip");
106  $this->dropColumn("{{profiles}}", "business_country");
107  $this->dropColumn("{{profiles}}", "business_phone_number");
108  $this->dropColumn("{{profiles}}", "business_mobile_phone_number");
109  $this->dropColumn("{{profiles}}", "skypename");
110  $this->dropColumn("{{profiles}}", "icq_number");
111  $this->dropColumn("{{profiles}}", "facebook_profile");
112  $this->dropColumn("{{profiles}}", "xing_profile");
113  $this->dropColumn("{{profiles}}", "linkedin_profile");
114  $this->dropColumn("{{profiles}}", "twitter_name");
115  $this->dropColumn("{{profiles}}", "make_public");
116  $this->dropColumn("{{profiles}}", "business_city", "");
117  $this->dropColumn("{{profiles}}", "find_me_in_phone_book");
118  $this->dropColumn("{{profiles}}", "send_me_notifications");
119 
120  return true;
121  }
122 
123  /*
124  // Use safeUp/safeDown to do migration with transaction
125  public function safeUp()
126  {
127  }
128 
129  public function safeDown()
130  {
131  }
132  */
133 }