|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* extends Member with fields specific to the Software Author |
|
5
|
|
|
* @author nicolaas [at] sunnysideup.co.nz |
|
6
|
|
|
* |
|
7
|
|
|
* |
|
8
|
|
|
**/ |
|
9
|
|
|
|
|
10
|
|
|
class SoftwareAuthorMemberDOD extends DataExtension |
|
|
|
|
|
|
11
|
|
|
{ |
|
12
|
|
|
private static $register_group_title = "Software Authors"; |
|
13
|
|
|
public function set_register_group_title($s) |
|
14
|
|
|
{ |
|
15
|
|
|
self::$register_group_title = $s; |
|
16
|
|
|
} |
|
17
|
|
|
public function get_register_group_title() |
|
18
|
|
|
{ |
|
19
|
|
|
return self::$register_group_title; |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
private static $register_group_code = "softwareauthors"; |
|
23
|
|
|
public function set_register_group_code($s) |
|
24
|
|
|
{ |
|
25
|
|
|
self::$register_group_code = $s; |
|
26
|
|
|
} |
|
27
|
|
|
public function get_register_group_code() |
|
28
|
|
|
{ |
|
29
|
|
|
return self::$register_group_code; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
private static $register_group_access_key = "SOFTWAREAUTHORS"; |
|
33
|
|
|
public function set_register_group_access_key($s) |
|
34
|
|
|
{ |
|
35
|
|
|
self::$register_group_access_key = $s; |
|
36
|
|
|
} |
|
37
|
|
|
public function get_register_group_access_key() |
|
38
|
|
|
{ |
|
39
|
|
|
return self::$register_group_access_key; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
private static $db = array( |
|
|
|
|
|
|
43
|
|
|
"ScreenName" => "Varchar(255)", |
|
44
|
|
|
"GithubURL" => "Varchar(255)", |
|
45
|
|
|
"SilverstripeDotOrgURL" => "Varchar(255)", |
|
46
|
|
|
"CompanyName" => "Varchar(255)", |
|
47
|
|
|
"CompanyURL" => "Varchar(255)", |
|
48
|
|
|
"AreYouHappyForPeopleToContactYou" => "Boolean", |
|
49
|
|
|
"ContactDetailURL" => "Varchar(255)", |
|
50
|
|
|
"OtherURL" => "Varchar(255)", |
|
51
|
|
|
"AreYouAvailableForPaidSupport" => "Boolean", |
|
52
|
|
|
"Rate15Mins" => "Currency", |
|
53
|
|
|
"Rate120Mins" => "Currency", |
|
54
|
|
|
"Rate480Mins" => "Currency" |
|
55
|
|
|
); |
|
56
|
|
|
|
|
57
|
|
|
private static $belongs_many_many = array( |
|
|
|
|
|
|
58
|
|
|
"ModuleProducts" => "ModuleProduct" |
|
59
|
|
|
); |
|
60
|
|
|
|
|
61
|
|
|
private static $defaults= array( |
|
|
|
|
|
|
62
|
|
|
"Rate15Mins" => 0, |
|
63
|
|
|
"Rate120Mins" => 0, |
|
64
|
|
|
"Rate480Mins" => 0 |
|
65
|
|
|
); |
|
66
|
|
|
|
|
67
|
|
|
private static $api_acces = array( |
|
|
|
|
|
|
68
|
|
|
"view" => array("ModuleProducts", "ScreenName") |
|
69
|
|
|
); |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Returns the currency used on the site. |
|
73
|
|
|
* @return String |
|
|
|
|
|
|
74
|
|
|
*/ |
|
75
|
|
|
public function Currency() |
|
76
|
|
|
{ |
|
77
|
|
|
$currency = EcommercePayment::site_currency(); |
|
78
|
|
|
return $currency; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
public function updateMemberFormFields(&$fields) |
|
82
|
|
|
{ |
|
83
|
|
|
$currency = $this->Currency(); |
|
84
|
|
|
$fields->RemoveByName("PreferredCurrencyID"); |
|
85
|
|
|
$field = $fields->fieldByName("ScreenName"); |
|
86
|
|
|
$field->setTitle("Screen Name / Alias"); |
|
87
|
|
|
$field = $fields->fieldByName("GithubURL"); |
|
88
|
|
|
$field->setTitle("Github URL - e.g. https://github.com/mynamehere"); |
|
89
|
|
|
$field = $fields->fieldByName("SilverstripeDotOrgURL"); |
|
90
|
|
|
$field->setTitle("www.silverstripe.org URL - e.g. http://www.silverstripe.org/ForumMemberProfile/show/1"); |
|
91
|
|
|
$field = $fields->fieldByName("CompanyName"); |
|
92
|
|
|
$field->setTitle("Company Name (if any)"); |
|
93
|
|
|
$field = $fields->fieldByName("CompanyURL"); |
|
94
|
|
|
$field->setTitle("Company Link - e.g. http://www.the-company-i-work-for.co.nz/"); |
|
95
|
|
|
$field = $fields->fieldByName("AreYouHappyForPeopleToContactYou"); |
|
96
|
|
|
$field->setTitle("Are you happy to answer private questions about your code?"); |
|
97
|
|
|
$field = $fields->fieldByName("ContactDetailURL"); |
|
98
|
|
|
$field->setTitle("Contact Details URL - e.g. http://www.mysite.com/contact/"); |
|
99
|
|
|
$field = $fields->fieldByName("OtherURL"); |
|
100
|
|
|
$field->setTitle("other URL - e.g. - e.g. http://www.mysite.com/about-me/"); |
|
101
|
|
|
$field = $fields->fieldByName("AreYouAvailableForPaidSupport"); |
|
102
|
|
|
$field->setTitle("Are you available for paid support?"); |
|
103
|
|
|
$field = $fields->fieldByName("Rate15Mins"); |
|
104
|
|
|
$field->setTitle("If applicable, approximate charge (in $currency) for a fifteen minute skype chat?"); |
|
105
|
|
|
$field = $fields->fieldByName("Rate120Mins"); |
|
106
|
|
|
$field->setTitle("If applicable, approximate charge (in $currency) for a two hour support block?"); |
|
107
|
|
|
$field = $fields->fieldByName("Rate480Mins"); |
|
108
|
|
|
$field->setTitle("If applicable, approximate charge (in $currency) for a development day (eight hours)?"); |
|
109
|
|
|
if ($modules = $this->owner->ModuleProducts()) { |
|
110
|
|
|
if ($modules->count()) { |
|
111
|
|
|
$html = "<h3 id=\"ModuleListHeading\" class=\"clear\"><a href=\"".$this->ListOfModulesLink()."\">Currently Listed Modules ...</a></h3><ul>"; |
|
112
|
|
|
foreach ($modules as $module) { |
|
113
|
|
|
if ($module->ShowInSearch) { |
|
114
|
|
|
$html .= "<li><a href=\"".$module->Link()."\">".$module->Title."</a></li>"; |
|
115
|
|
|
} |
|
116
|
|
|
} |
|
117
|
|
|
$html .= "</ul>"; |
|
118
|
|
|
$fields->push(new LiteralField("ModuleList", $html)); |
|
119
|
|
|
} |
|
120
|
|
|
} |
|
121
|
|
|
Requirements::javascript("ecommerce_software/javascript/SoftwareAuthorMemberDOD.js"); |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
|
|
125
|
|
|
public function onBeforeWrite() |
|
126
|
|
|
{ |
|
127
|
|
|
$id = intval($this->owner->ID); |
|
128
|
|
|
if (!$id) { |
|
129
|
|
|
$id = 0; |
|
130
|
|
|
} |
|
131
|
|
|
$i = 0; |
|
132
|
|
|
$startScreenName = $this->owner->ScreenName; |
|
133
|
|
|
$this->owner->ScreenName = preg_replace("[^A-Za-z0-9]", "", $this->owner->ScreenName); |
|
134
|
|
|
$className = $this->owner->ClassName; |
|
135
|
|
|
while ($className::get() |
|
136
|
|
|
->filter(array("ScreenName" => $this->owner->ScreenName)) |
|
137
|
|
|
->exclude(array("ID" => $id )) |
|
138
|
|
|
->first() |
|
139
|
|
|
&& $i < 10 |
|
140
|
|
|
) { |
|
141
|
|
|
$i++; |
|
142
|
|
|
$this->ScreenName = $startScreenName."_".$i; |
|
|
|
|
|
|
143
|
|
|
} |
|
144
|
|
|
$this->owner->Locale = "en_GB"; |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
public function ListOfModulesLink() |
|
148
|
|
|
{ |
|
149
|
|
|
$page = ModuleProductGroup::get() |
|
150
|
|
|
->filter(array("LevelOfProductsToShow" => 1)) |
|
151
|
|
|
->first(); |
|
152
|
|
|
if ($page) { |
|
153
|
|
|
return $page->Link()."#author_".$this->owner->ScreenName; |
|
154
|
|
|
} |
|
155
|
|
|
} |
|
156
|
|
|
} |
|
157
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.