Project

General

Profile

Revision b75b6b8b

Added by Assos Assos almost 6 years ago

Installation module makemeeting

View differences:

drupal7/sites/all/modules/makemeeting/LICENSE.txt
1
                    GNU GENERAL PUBLIC LICENSE
2
                       Version 2, June 1991
3

  
4
 Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6
 Everyone is permitted to copy and distribute verbatim copies
7
 of this license document, but changing it is not allowed.
8

  
9
                            Preamble
10

  
11
  The licenses for most software are designed to take away your
12
freedom to share and change it.  By contrast, the GNU General Public
13
License is intended to guarantee your freedom to share and change free
14
software--to make sure the software is free for all its users.  This
15
General Public License applies to most of the Free Software
16
Foundation's software and to any other program whose authors commit to
17
using it.  (Some other Free Software Foundation software is covered by
18
the GNU Lesser General Public License instead.)  You can apply it to
19
your programs, too.
20

  
21
  When we speak of free software, we are referring to freedom, not
22
price.  Our General Public Licenses are designed to make sure that you
23
have the freedom to distribute copies of free software (and charge for
24
this service if you wish), that you receive source code or can get it
25
if you want it, that you can change the software or use pieces of it
26
in new free programs; and that you know you can do these things.
27

  
28
  To protect your rights, we need to make restrictions that forbid
29
anyone to deny you these rights or to ask you to surrender the rights.
30
These restrictions translate to certain responsibilities for you if you
31
distribute copies of the software, or if you modify it.
32

  
33
  For example, if you distribute copies of such a program, whether
34
gratis or for a fee, you must give the recipients all the rights that
35
you have.  You must make sure that they, too, receive or can get the
36
source code.  And you must show them these terms so they know their
37
rights.
38

  
39
  We protect your rights with two steps: (1) copyright the software, and
40
(2) offer you this license which gives you legal permission to copy,
41
distribute and/or modify the software.
42

  
43
  Also, for each author's protection and ours, we want to make certain
44
that everyone understands that there is no warranty for this free
45
software.  If the software is modified by someone else and passed on, we
46
want its recipients to know that what they have is not the original, so
47
that any problems introduced by others will not reflect on the original
48
authors' reputations.
49

  
50
  Finally, any free program is threatened constantly by software
51
patents.  We wish to avoid the danger that redistributors of a free
52
program will individually obtain patent licenses, in effect making the
53
program proprietary.  To prevent this, we have made it clear that any
54
patent must be licensed for everyone's free use or not licensed at all.
55

  
56
  The precise terms and conditions for copying, distribution and
57
modification follow.
58

  
59
                    GNU GENERAL PUBLIC LICENSE
60
   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61

  
62
  0. This License applies to any program or other work which contains
63
a notice placed by the copyright holder saying it may be distributed
64
under the terms of this General Public License.  The "Program", below,
65
refers to any such program or work, and a "work based on the Program"
66
means either the Program or any derivative work under copyright law:
67
that is to say, a work containing the Program or a portion of it,
68
either verbatim or with modifications and/or translated into another
69
language.  (Hereinafter, translation is included without limitation in
70
the term "modification".)  Each licensee is addressed as "you".
71

  
72
Activities other than copying, distribution and modification are not
73
covered by this License; they are outside its scope.  The act of
74
running the Program is not restricted, and the output from the Program
75
is covered only if its contents constitute a work based on the
76
Program (independent of having been made by running the Program).
77
Whether that is true depends on what the Program does.
78

  
79
  1. You may copy and distribute verbatim copies of the Program's
80
source code as you receive it, in any medium, provided that you
81
conspicuously and appropriately publish on each copy an appropriate
82
copyright notice and disclaimer of warranty; keep intact all the
83
notices that refer to this License and to the absence of any warranty;
84
and give any other recipients of the Program a copy of this License
85
along with the Program.
86

  
87
You may charge a fee for the physical act of transferring a copy, and
88
you may at your option offer warranty protection in exchange for a fee.
89

  
90
  2. You may modify your copy or copies of the Program or any portion
91
of it, thus forming a work based on the Program, and copy and
92
distribute such modifications or work under the terms of Section 1
93
above, provided that you also meet all of these conditions:
94

  
95
    a) You must cause the modified files to carry prominent notices
96
    stating that you changed the files and the date of any change.
97

  
98
    b) You must cause any work that you distribute or publish, that in
99
    whole or in part contains or is derived from the Program or any
100
    part thereof, to be licensed as a whole at no charge to all third
101
    parties under the terms of this License.
102

  
103
    c) If the modified program normally reads commands interactively
104
    when run, you must cause it, when started running for such
105
    interactive use in the most ordinary way, to print or display an
106
    announcement including an appropriate copyright notice and a
107
    notice that there is no warranty (or else, saying that you provide
108
    a warranty) and that users may redistribute the program under
109
    these conditions, and telling the user how to view a copy of this
110
    License.  (Exception: if the Program itself is interactive but
111
    does not normally print such an announcement, your work based on
112
    the Program is not required to print an announcement.)
113

  
114
These requirements apply to the modified work as a whole.  If
115
identifiable sections of that work are not derived from the Program,
116
and can be reasonably considered independent and separate works in
117
themselves, then this License, and its terms, do not apply to those
118
sections when you distribute them as separate works.  But when you
119
distribute the same sections as part of a whole which is a work based
120
on the Program, the distribution of the whole must be on the terms of
121
this License, whose permissions for other licensees extend to the
122
entire whole, and thus to each and every part regardless of who wrote it.
123

  
124
Thus, it is not the intent of this section to claim rights or contest
125
your rights to work written entirely by you; rather, the intent is to
126
exercise the right to control the distribution of derivative or
127
collective works based on the Program.
128

  
129
In addition, mere aggregation of another work not based on the Program
130
with the Program (or with a work based on the Program) on a volume of
131
a storage or distribution medium does not bring the other work under
132
the scope of this License.
133

  
134
  3. You may copy and distribute the Program (or a work based on it,
135
under Section 2) in object code or executable form under the terms of
136
Sections 1 and 2 above provided that you also do one of the following:
137

  
138
    a) Accompany it with the complete corresponding machine-readable
139
    source code, which must be distributed under the terms of Sections
140
    1 and 2 above on a medium customarily used for software interchange; or,
141

  
142
    b) Accompany it with a written offer, valid for at least three
143
    years, to give any third party, for a charge no more than your
144
    cost of physically performing source distribution, a complete
145
    machine-readable copy of the corresponding source code, to be
146
    distributed under the terms of Sections 1 and 2 above on a medium
147
    customarily used for software interchange; or,
148

  
149
    c) Accompany it with the information you received as to the offer
150
    to distribute corresponding source code.  (This alternative is
151
    allowed only for noncommercial distribution and only if you
152
    received the program in object code or executable form with such
153
    an offer, in accord with Subsection b above.)
154

  
155
The source code for a work means the preferred form of the work for
156
making modifications to it.  For an executable work, complete source
157
code means all the source code for all modules it contains, plus any
158
associated interface definition files, plus the scripts used to
159
control compilation and installation of the executable.  However, as a
160
special exception, the source code distributed need not include
161
anything that is normally distributed (in either source or binary
162
form) with the major components (compiler, kernel, and so on) of the
163
operating system on which the executable runs, unless that component
164
itself accompanies the executable.
165

  
166
If distribution of executable or object code is made by offering
167
access to copy from a designated place, then offering equivalent
168
access to copy the source code from the same place counts as
169
distribution of the source code, even though third parties are not
170
compelled to copy the source along with the object code.
171

  
172
  4. You may not copy, modify, sublicense, or distribute the Program
173
except as expressly provided under this License.  Any attempt
174
otherwise to copy, modify, sublicense or distribute the Program is
175
void, and will automatically terminate your rights under this License.
176
However, parties who have received copies, or rights, from you under
177
this License will not have their licenses terminated so long as such
178
parties remain in full compliance.
179

  
180
  5. You are not required to accept this License, since you have not
181
signed it.  However, nothing else grants you permission to modify or
182
distribute the Program or its derivative works.  These actions are
183
prohibited by law if you do not accept this License.  Therefore, by
184
modifying or distributing the Program (or any work based on the
185
Program), you indicate your acceptance of this License to do so, and
186
all its terms and conditions for copying, distributing or modifying
187
the Program or works based on it.
188

  
189
  6. Each time you redistribute the Program (or any work based on the
190
Program), the recipient automatically receives a license from the
191
original licensor to copy, distribute or modify the Program subject to
192
these terms and conditions.  You may not impose any further
193
restrictions on the recipients' exercise of the rights granted herein.
194
You are not responsible for enforcing compliance by third parties to
195
this License.
196

  
197
  7. If, as a consequence of a court judgment or allegation of patent
198
infringement or for any other reason (not limited to patent issues),
199
conditions are imposed on you (whether by court order, agreement or
200
otherwise) that contradict the conditions of this License, they do not
201
excuse you from the conditions of this License.  If you cannot
202
distribute so as to satisfy simultaneously your obligations under this
203
License and any other pertinent obligations, then as a consequence you
204
may not distribute the Program at all.  For example, if a patent
205
license would not permit royalty-free redistribution of the Program by
206
all those who receive copies directly or indirectly through you, then
207
the only way you could satisfy both it and this License would be to
208
refrain entirely from distribution of the Program.
209

  
210
If any portion of this section is held invalid or unenforceable under
211
any particular circumstance, the balance of the section is intended to
212
apply and the section as a whole is intended to apply in other
213
circumstances.
214

  
215
It is not the purpose of this section to induce you to infringe any
216
patents or other property right claims or to contest validity of any
217
such claims; this section has the sole purpose of protecting the
218
integrity of the free software distribution system, which is
219
implemented by public license practices.  Many people have made
220
generous contributions to the wide range of software distributed
221
through that system in reliance on consistent application of that
222
system; it is up to the author/donor to decide if he or she is willing
223
to distribute software through any other system and a licensee cannot
224
impose that choice.
225

  
226
This section is intended to make thoroughly clear what is believed to
227
be a consequence of the rest of this License.
228

  
229
  8. If the distribution and/or use of the Program is restricted in
230
certain countries either by patents or by copyrighted interfaces, the
231
original copyright holder who places the Program under this License
232
may add an explicit geographical distribution limitation excluding
233
those countries, so that distribution is permitted only in or among
234
countries not thus excluded.  In such case, this License incorporates
235
the limitation as if written in the body of this License.
236

  
237
  9. The Free Software Foundation may publish revised and/or new versions
238
of the General Public License from time to time.  Such new versions will
239
be similar in spirit to the present version, but may differ in detail to
240
address new problems or concerns.
241

  
242
Each version is given a distinguishing version number.  If the Program
243
specifies a version number of this License which applies to it and "any
244
later version", you have the option of following the terms and conditions
245
either of that version or of any later version published by the Free
246
Software Foundation.  If the Program does not specify a version number of
247
this License, you may choose any version ever published by the Free Software
248
Foundation.
249

  
250
  10. If you wish to incorporate parts of the Program into other free
251
programs whose distribution conditions are different, write to the author
252
to ask for permission.  For software which is copyrighted by the Free
253
Software Foundation, write to the Free Software Foundation; we sometimes
254
make exceptions for this.  Our decision will be guided by the two goals
255
of preserving the free status of all derivatives of our free software and
256
of promoting the sharing and reuse of software generally.
257

  
258
                            NO WARRANTY
259

  
260
  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
262
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
266
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
267
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
REPAIR OR CORRECTION.
269

  
270
  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
POSSIBILITY OF SUCH DAMAGES.
279

  
280
                     END OF TERMS AND CONDITIONS
281

  
282
            How to Apply These Terms to Your New Programs
283

  
284
  If you develop a new program, and you want it to be of the greatest
285
possible use to the public, the best way to achieve this is to make it
286
free software which everyone can redistribute and change under these terms.
287

  
288
  To do so, attach the following notices to the program.  It is safest
289
to attach them to the start of each source file to most effectively
290
convey the exclusion of warranty; and each file should have at least
291
the "copyright" line and a pointer to where the full notice is found.
292

  
293
    <one line to give the program's name and a brief idea of what it does.>
294
    Copyright (C) <year>  <name of author>
295

  
296
    This program is free software; you can redistribute it and/or modify
297
    it under the terms of the GNU General Public License as published by
298
    the Free Software Foundation; either version 2 of the License, or
299
    (at your option) any later version.
300

  
301
    This program is distributed in the hope that it will be useful,
302
    but WITHOUT ANY WARRANTY; without even the implied warranty of
303
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
304
    GNU General Public License for more details.
305

  
306
    You should have received a copy of the GNU General Public License along
307
    with this program; if not, write to the Free Software Foundation, Inc.,
308
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309

  
310
Also add information on how to contact you by electronic and paper mail.
311

  
312
If the program is interactive, make it output a short notice like this
313
when it starts in an interactive mode:
314

  
315
    Gnomovision version 69, Copyright (C) year name of author
316
    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317
    This is free software, and you are welcome to redistribute it
318
    under certain conditions; type `show c' for details.
319

  
320
The hypothetical commands `show w' and `show c' should show the appropriate
321
parts of the General Public License.  Of course, the commands you use may
322
be called something other than `show w' and `show c'; they could even be
323
mouse-clicks or menu items--whatever suits your program.
324

  
325
You should also get your employer (if you work as a programmer) or your
326
school, if any, to sign a "copyright disclaimer" for the program, if
327
necessary.  Here is a sample; alter the names:
328

  
329
  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330
  `Gnomovision' (which makes passes at compilers) written by James Hacker.
331

  
332
  <signature of Ty Coon>, 1 April 1989
333
  Ty Coon, President of Vice
334

  
335
This General Public License does not permit incorporating your program into
336
proprietary programs.  If your program is a subroutine library, you may
337
consider it more useful to permit linking proprietary applications with the
338
library.  If this is what you want to do, use the GNU Lesser General
339
Public License instead of this License.
drupal7/sites/all/modules/makemeeting/README.txt
1

  
2
-- SUMMARY --
3

  
4
The Makemeeting module provides a field to allow users to provide their
5
availability on some dates choosen by the content author.
6

  
7
For a full description of the module, visit the project page:
8
  http://drupal.org/project/makemeeting
9

  
10
To submit bug reports and feature suggestions, or to track changes:
11
  http://drupal.org/project/issues/makemeeting
12

  
13

  
14
-- REQUIREMENTS --
15

  
16
None.
17

  
18

  
19
-- INSTALLATION --
20

  
21
* Install as usual, see http://drupal.org/node/70151 for further information.
22

  
23

  
24
-- CONFIGURATION --
25

  
26
* Configure user permissions in Administration » People » Permissions:
27

  
28
  - Provide an answer to makemeeting forms
29

  
30
    You might want to give this to authenticated users as it is required to
31
    provide an answer to a makemeeting form.
32

  
33
  - Delete any makemeeting answers
34

  
35
    This is intended for administrators and moderators to delete answers made
36
    by anonymous users in case of mistakes.
37

  
38

  
39
-- USAGE --
40

  
41
* Add the field associated with its widget to any content type
42

  
43

  
44
-- ROADMAP --
45

  
46
* Better makemeeting form creation behaviors (remove a date)
47

  
48
* If you would like to see a new feature, please fill an issue on the drupal.org
49
projet page
50

  
51
-- CONTACT --
52

  
53
Current maintainers:
54
* Sebastien Corbin (SebCorbin) - http://drupal.org/user/412171
drupal7/sites/all/modules/makemeeting/makemeeting.css
1
/**
2
 * Default makemeeting style
3
 */
4

  
5
/* Backend */
6

  
7
.makemeeting-choice-date .form-item {
8
  float: left;
9
}
10

  
11
/* Frontend */
12

  
13
.makemeeting-table {
14
}
15

  
16
.makemeeting-table .answer-editable {
17
  position: relative;
18
  display: inline;
19
}
20

  
21
.makemeeting-table .answer-editable .answer-edit {
22
  position: absolute;
23
  left: -4.7em;
24
  top: -0.45em;
25
  padding: 0.25em 0.4em;
26
  border-radius: 0.7em 0 0 0.7em;
27
  display: block;
28
  width: 3.3em;
29
}
30

  
31
.makemeeting-table .answer-editable .answer-edit a {
32
  margin: 0.3em 0 -0.3em 0;
33
  display: block;
34
  float: left;
35
  padding: 0 0.2em;
36
}
37

  
38
.makemeeting-table .answer-editable .answer-edit img {
39
  border: 0 none;
40
}
41

  
42
.makemeeting-table tr.odd .answer-editable .answer-edit {
43
  background: #E4E4E4;
44
  background: rgba(0, 0, 0, 0.105);
45
}
46

  
47
.makemeeting-table tr.even .answer-editable .answer-edit {
48
  background: #EFEFEF;
49
  background: rgba(0, 0, 0, 0.063);
50
}
51
.makemeeting-table tr .answer-editable .answer-edit {
52
  display: none;
53
}
54
.makemeeting-table tr.in .answer-editable .answer-edit {
55
  display: inline;
56
}
57
.makemeeting-table tr.editing,
58
.makemeeting-table tr.editing > td {
59
  padding: 0;
60
}
61
.makemeeting-table tr.editing table {
62
  margin: 0;
63
}
64

  
65
.makemeeting-table .date,
66
.makemeeting-table .suggestion,
67
.makemeeting-table .answer,
68
.makemeeting-table .total-count,
69
.makemeeting-table .total-row {
70
  border: 1px solid white;
71
  text-align: center;
72
}
73

  
74
.makemeeting-table .suggestion {
75
  /*background-color : #D0E3FB;*//* Light blue */
76
}
77

  
78
.makemeeting-table .suggestion,
79
.makemeeting-table .answer,
80
.makemeeting-table .total-count {
81
  border-left: 1px solid gray;
82
}
83

  
84
.makemeeting-table .answer {
85
  background: transparent no-repeat center;
86
  padding: 0;
87
}
88
.makemeeting-table .answer span {
89
  display: block;
90
  width: 24px;
91
  height: 24px;
92
  text-indent: -9999px;
93
  white-space: nowrap;
94
  overflow: hidden;
95
  margin: 0 auto;
96
}
97

  
98
.makemeeting-table .answer-0 {
99
  background-color: #FFCCCA;
100
}
101
.makemeeting-table .answer-0 span {
102
  background-image: url("images/delete.png");
103
}
104

  
105
.makemeeting-table .answer-1 {
106
  background-color: #D1F3D1;
107
}
108
.makemeeting-table .answer-1 span {
109
  background-image: url("images/accept.png");
110
}
111

  
112
.makemeeting-table .answer-2 {
113
  background-color: #FFEDA1;
114
}
115
.makemeeting-table .answer-2 span{
116
  background-image: url("images/warning.png");
117

  
118
}
119

  
120
.makemeeting-table tr.answer-form-row .radio,
121
.makemeeting-table tr.answer-form-row .checkbox {
122
  text-align: center;
123
}
124

  
125
.makemeeting-table .total-0.total-max {
126
  background-color: #FFCCCA;
127
}
128

  
129
.makemeeting-table .total-1.total-max {
130
  background-color: #D1F3D1;
131
}
132

  
133
.makemeeting-table .total-2.total-max {
134
  background-color: #FFEDA1;
135
}
136

  
137
.makemeeting-table .total-max {
138
  font-weight: bold;
139
  color: black;
140
}
drupal7/sites/all/modules/makemeeting/makemeeting.field.inc
1
<?php
2

  
3
/**
4
 * @file
5
 * This file is mostly about the field configuration.
6
 */
7

  
8
/**
9
 * Implements hook_field_info().
10
 */
11
function makemeeting_field_info() {
12
  return array(
13
    'makemeeting' => array(
14
      'label'             => t('Makemeeting form'),
15
      'description'       => t('This field stores user choices about some dates in the database.'),
16
      'default_widget'    => 'makemeeting_choices',
17
      'default_formatter' => 'makemeeting_answers',
18
    ),
19
  );
20
}
21

  
22
/**
23
 * Implements hook_field_widget_info().
24
 */
25
function makemeeting_field_widget_info() {
26
  return array(
27
    'makemeeting_choices' => array(
28
      'label'       => t('Makemeeting choices'),
29
      'field types' => array('makemeeting'),
30
      'behaviors'   => array(
31
        'default value' => FIELD_BEHAVIOR_NONE,
32
      ),
33
    ),
34
  );
35
}
36

  
37
/**
38
 * Implements hook_field_widget_settings_form().
39
 */
40
function makemeeting_field_widget_settings_form($field, $instance) {
41
  $widget = $instance['widget'];
42
  $settings = $widget['settings'];
43

  
44
  $form = array();
45
  if ($widget['type'] == 'makemeeting_choices') {
46
    $form['size'] = array(
47
      '#type'             => 'textfield',
48
      '#title'            => t('Number of dates'),
49
      '#default_value'    => isset($settings['size']) ? $settings['size'] : 1,
50
      '#element_validate' => array('element_validate_integer'),
51
      '#required'         => TRUE,
52
      '#size'             => 5,
53
      '#description'      => t('Default number of date choices to display. Must be positive or equal to 0.')
54
    );
55
  }
56

  
57
  return $form;
58
}
59

  
60
/**
61
 * Implements hook_field_widget_form().
62
 */
63
function makemeeting_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
64
  $element += array(
65
    '#type' => 'fieldset',
66
  );
67

  
68
  $item =& $items[$delta];
69

  
70
  // Simple options form elements about the poll
71
  $element['hidden'] = array(
72
    '#title'         => t('Hidden poll'),
73
    '#description'   => t('Confidential participation: only you and administrators can see the answers.'),
74
    '#type'          => 'checkbox',
75
    '#default_value' => isset($item['hidden']) ? $item['hidden'] : '',
76
  );
77
  $element['one_option'] = array(
78
    '#title'         => t('Participant can only choose one option'),
79
    '#description'   => t('By default all options are selectable. This setting limits the choice to one option per participant.'),
80
    '#type'          => 'checkbox',
81
    '#default_value' => isset($item['one_option']) ? $item['one_option'] : '',
82
  );
83
  $element['limit'] = array(
84
    '#title'            => t('Limit the number of participants per option'),
85
    '#description'      => t('Poll as registration form: As soon as the indicated limit has been reached, the respective option is no longer available. 0 for unlimited'),
86
    '#type'             => 'textfield',
87
    '#default_value'    => isset($item['limit']) ? $item['limit'] : 0,
88
    '#element_validate' => array('element_validate_integer'),
89
  );
90
  $element['yesnomaybe'] = array(
91
    '#title'         => t('Provide a "Maybe" option'),
92
    '#description'   => t('Provide a third "Maybe" option in case users may be available.'),
93
    '#type'          => 'checkbox',
94
    '#default_value' => isset($item['yesnomaybe']) ? $item['yesnomaybe'] : '',
95
    // Hide if one_option is checked
96
    '#states'        => array(
97
      'visible' => array(
98
        ':input[name$="[one_option]"]' => array('checked' => FALSE),
99
      ),
100
    ),
101
  );
102
  $element['closed'] = array(
103
    '#title'         => t('Closed'),
104
    '#description'   => t('Check this when you want to close the poll.'),
105
    '#type'          => 'checkbox',
106
    '#default_value' => isset($item['closed']) ? $item['closed'] : '',
107
  );
108

  
109
  // Now let's take care of the choices part
110
  // $process is a callback that we will attach to the wrapper in order
111
  // to add parents to the form elements. This is so we can store
112
  // nested values in the DB table with field storage API.
113
  $fieldset_info = element_info('fieldset');
114
  $process = array_merge($fieldset_info['#process'], array('_makemeeting_rebuild_parents'));
115
  $element['choices_wrapper'] = array(
116
    '#tree'    => FALSE,
117
    '#prefix'  => '<div class="clearfix" id="makemeeting-choices-wrapper">',
118
    '#suffix'  => '</div>',
119
    '#process' => $process,
120
  );
121

  
122
  // Container just for the poll choices.
123
  $element['choices_wrapper']['choices'] = array(
124
    '#prefix' => '<div id="makemeeting-choices">',
125
    '#suffix' => '</div>',
126
    '#theme'  => 'makemeeting_choices',
127
  );
128

  
129
  // Fill the item values with previously submitted values
130
  if (!empty($form_state['values'])) {
131
    $submitted_values = drupal_array_get_nested_value($form_state['values'], $element['#field_parents']);
132
    $submitted_values = $submitted_values[$element['#field_name']][$element['#language']][$element['#delta']];
133
    if (isset($submitted_values['choices'])) {
134
      $item['choices'] = $submitted_values['choices'];
135
    }
136
  }
137

  
138
  // Calculate the suggestion count
139
  if (empty($form_state['suggestion_count'])) {
140
    $form_state['suggestion_count'] = 1;
141
  }
142
  if (isset($item['choices'])) {
143
    foreach ($item['choices'] as $choice) {
144
      if ($form_state['suggestion_count'] < count($choice['chsuggestions'])) {
145
        $form_state['suggestion_count'] = count($choice['chsuggestions']);
146
      }
147
    }
148
  }
149

  
150
  // Determine choice count if not provided
151
  if (!isset($form_state['choice_count'])) {
152
    try {
153
      list($entity_id) = entity_extract_ids($element['#entity_type'], $element['#entity']);
154
    } catch (Exception $e) {
155
      // Fail silently if the field is not attached to any entity yet.
156
    }
157
    // If the entity isn't created yet, offer the default number of choices,
158
    // else the number of previous choices, or 0 if none
159
    if (!isset($entity_id)) {
160
      $widget = $instance['widget'];
161
      $settings = $widget['settings'];
162
      $form_state['choice_count'] = isset($settings['size']) ? $settings['size'] : 1;
163
    }
164
    else {
165
      $form_state['choice_count'] = isset($item['choices']) ? count($item['choices']) : 0;
166
    }
167
  }
168

  
169
  // Add the current choices to the form.
170
  $delta = 0;
171
  if (isset($item['choices']) && $form_state['choice_count']) {
172
    // Sort choices by their dates
173
    asort($item['choices']);
174
    $delta = count($item['choices']);
175
    foreach ($item['choices'] as $key => $choice) {
176
      $element['choices_wrapper']['choices'][$key] =
177
        _makemeeting_choice_form($key, $choice['chdate'], $choice['chsuggestions'], $form_state['suggestion_count']);
178
    }
179
  }
180

  
181
  // Add choices as required.
182
  if ($form_state['choice_count']) {
183
    // Add a day to the last option's timestamp for the new default date
184
    $last_option_timestamp = isset($choice['chdate']) ? _makemeeting_date_timestamp($choice['chdate']) : REQUEST_TIME;
185
    $existing_delta = $delta;
186
    for (; $delta < $form_state['choice_count'] ; $delta++) {
187
      $additional_stamp = strtotime('+1 day', $last_option_timestamp);
188
      // Build default date
189
      $default_date = array(
190
        'month' => date('n', $additional_stamp),
191
        'day'   => date('j', $additional_stamp),
192
        'year'  => date('Y', $additional_stamp)
193
      );
194
      $key = 'new:' . ($delta - $existing_delta);
195
      $element['choices_wrapper']['choices'][$key] =
196
        _makemeeting_choice_form($key, $default_date, NULL, $form_state['suggestion_count']);
197
      // Repeat
198
      $last_option_timestamp = $additional_stamp;
199
    }
200
  }
201

  
202
  // We prefix our buttons with 'makemeeting' to avoid conflicts
203
  // with other modules using Ajax-enabled buttons with the id 'more'.
204
  $default_submit = array(
205
    '#type'                    => 'submit',
206
    '#limit_validation_errors' => array(array('choices')),
207
    '#submit'                  => array('makemeeting_choices_submit'),
208
    '#ajax'                    => array(
209
      'callback' => 'makemeeting_choice_js',
210
      'wrapper'  => 'makemeeting-choices-wrapper',
211
      'effect'   => 'fade',
212
    ),
213
  );
214
  $element['choices_wrapper']['makemeeting_more_choices'] = $default_submit + array(
215
      '#value'      => t('More choices'),
216
      '#attributes' => array(
217
        'title' => t("If the amount of rows above isn't enough, click here to add more choices."),
218
      ),
219
      '#weight'     => 1,
220
    );
221
  $element['choices_wrapper']['makemeeting_more_suggestions'] = $default_submit + array(
222
      '#value'      => t('More suggestions'),
223
      '#attributes' => array(
224
        'title' => t("If the amount of boxes above isn't enough, click here to add more suggestions."),
225
      ),
226
      '#weight'     => 2,
227
    );
228
  if ($form_state['choice_count'] > 1) {
229
    $element['choices_wrapper']['makemeeting_copy_suggestions'] = $default_submit + array(
230
        '#value'      => t('Copy and paste first row'),
231
        '#attributes' => array(
232
          'title' => t("Copy the suggestions from the first to the other rows."),
233
        ),
234
        '#weight'     => 3,
235
      );
236
  }
237
  return $element;
238
}
239

  
240
/**
241
 * Helper function to construct a row of the widget form
242
 *
243
 * @param $key
244
 * @param string $value
245
 * @param array $suggestions
246
 * @param int $size
247
 * @return array
248
 */
249
function _makemeeting_choice_form($key, $value = '', $suggestions = array(), $size = 1) {
250
  $form = array(
251
    '#tree' => TRUE,
252
  );
253

  
254
  // We'll manually set the #parents property of these fields so that
255
  // their values appear in the $form_state['values']['choices'] array
256
  // They are to be updated later in #process as we don't know here the
257
  // hierarchy of the parents
258
  $form['chdate'] = array(
259
    '#type'          => 'date',
260
    '#title'         => t('Date'),
261
    '#title_display' => 'invisible',
262
    '#default_value' => $value,
263
    '#parents'       => array('choices', $key, 'chdate'),
264
  );
265
  $form['chremove'] = array(
266
    '#type'                    => 'submit',
267
    '#parents'                 => array(),
268
    '#submit'                  => array('makemeeting_choices_submit'),
269
    '#limit_validation_errors' => array(array('choices')),
270
    '#ajax'                    => array(
271
      'callback' => 'makemeeting_choice_js',
272
      'wrapper'  => 'makemeeting-choices',
273
      'effect'   => 'fade',
274
    ),
275
    '#value'                   => t('Remove'),
276
    // Assigning key as name to make each 'Remove' button unique
277
    '#name'                    => $key,
278
  );
279

  
280
  $form['chsuggestions'] = array(
281
    '#tree'    => TRUE,
282
    '#parents' => array('choices', $key, 'chsuggestions'),
283
  );
284

  
285
  for ($i = 0 ; $i < $size ; $i++) {
286
    $key2 = 'sugg:' . ($i);
287
    $form['chsuggestions'][$key2] = array(
288
      '#type'          => 'textfield',
289
      '#title_display' => 'invisible',
290
      '#default_value' => isset($suggestions[$key2]) ? $suggestions[$key2] : '',
291
      '#size'          => 5,
292
      '#maxlength'     => 255,
293
      '#parents'       => array('choices', $key, 'chsuggestions', $key2),
294
    );
295
  }
296
  return $form;
297
}
298

  
299
/**
300
 * Helper function to update the form elements parents. This is required
301
 * for the element to be saved properly by the Field API (see #process)
302
 *
303
 * @param $element
304
 * @return mixed
305
 */
306
function _makemeeting_rebuild_parents(&$element) {
307
  $parents = array_diff($element['#array_parents'], $element['#parents']);
308
  $elements = array(
309
    'makemeeting_more_choices',
310
    'makemeeting_more_suggestions',
311
    'makemeeting_copy_suggestions'
312
  );
313
  foreach ($elements as $e) {
314
    $element[$e]['#parents'] = $parents;
315
    if (isset($element[$e]['#limit_validation_errors'])) {
316
      $element[$e]['#limit_validation_errors'][0] = array_merge($parents,
317
        $element[$e]['#limit_validation_errors'][0]);
318
    }
319
  }
320
  $element['makemeeting_more_suggestions']['#parents'] = $parents;
321
  $element['makemeeting_copy_suggestions']['#parents'] = $parents;
322
  foreach (element_children($element['choices']) as $key1) {
323
    foreach (element_children($element['choices'][$key1]) as $key2) {
324
      $keys = element_children($element['choices'][$key1][$key2]);
325
      if (empty($keys)) {
326
        $element['choices'][$key1][$key2]['#parents'] = array_merge($parents,
327
          $element['choices'][$key1][$key2]['#parents']);
328
      }
329
      else {
330
        foreach ($keys as $key3) {
331
          $element['choices'][$key1][$key2][$key3]['#parents'] = array_merge($parents,
332
            $element['choices'][$key1][$key2][$key3]['#parents']);
333
        }
334
      }
335
    }
336
  }
337
  return $element;
338
}
339

  
340
/**
341
 * Implements hook_field_validate().
342
 */
343
function makemeeting_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
344
  foreach ($items as $delta => $item) {
345
    if (isset($item['choices'])) {
346
      // Verify that we do not have duplicate dates
347
      $dates = array();
348
      foreach ($item['choices'] as $chid => $chvalue) {
349
        $date = implode('', $chvalue['chdate']);
350
        if (in_array($date, $dates)) {
351
          // Register an error with the choice id
352
          $errors[$field['field_name']][$langcode][$delta][] = array(
353
            'error'   => 'duplicate_dates',
354
            'message' => t('%name: you can\'t have duplicate dates.', array('%name' => $instance['label'])),
355
            'chid'    => $chid,
356
          );
357
        }
358
        else {
359
          $dates[] = $date;
360
        }
361
      }
362
    }
363
  }
364
}
365

  
366
/**
367
 * Implements hook_field_widget_error().
368
 */
369
function makemeeting_field_widget_error($element, $error) {
370
  // Show our error concerning duplicate dates here
371
  $choices = $element['choices_wrapper']['choices'];
372
  form_error($choices[$error['chid']]['chdate'], $error['message']);
373
}
374

  
375

  
376
/**
377
 * Implements hook_field_is_empty().
378
 */
379
function makemeeting_field_is_empty($item) {
380
  return empty($item['choices']);
381
}
382

  
383
/**
384
 * Implements hook_field_formatter_info().
385
 */
386
function makemeeting_field_formatter_info() {
387
  return array(
388
    'makemeeting_answers' => array(
389
      'label'       => t('Makemeeting answers'),
390
      'field types' => array('makemeeting'),
391
    ),
392
  );
393
}
394

  
395
/**
396
 * Implements hook_field_formatter_view().
397
 *
398
 * Build a renderable array for a field value.
399
 *
400
 * @param $entity_type
401
 *   The type of $entity.
402
 * @param $entity
403
 *   The entity being displayed.
404
 * @param $field
405
 *   The field structure.
406
 * @param $instance
407
 *   The field instance.
408
 * @param $langcode
409
 *   The language associated with $items.
410
 * @param $items
411
 *   Array of values for this field.
412
 * @param $display
413
 *   The display settings to use, as found in the 'display' entry of instance
414
 *   definitions. The array notably contains the following keys and values;
415
 *   - type: The name of the formatter to use.
416
 *   - settings: The array of formatter settings.
417
 *
418
 * @return array
419
 *  A renderable array for the $items, as an array of child elements keyed
420
 */
421
function makemeeting_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
422
  $content = array();
423
  foreach ($items as $delta => $item) {
424
    list($entity_id) = entity_extract_ids($entity_type, $entity);
425
    $instance += array(
426
      'entity_id' => $entity_id,
427
      'language'  => $langcode,
428
      'delta'     => $delta
429
    );
430
    // Define answers hidden status here as we have $field variable available
431
    $item['is_hidden'] = (bool) $item['hidden'];
432
    if ($item['is_hidden']) {
433
      $access = field_access('edit', $field, $entity_type, $entity);
434
      if ($entity_type == 'node') {
435
        $access = $access && node_access('update', $entity);
436
      }
437
      elseif (module_exists('entity')) {
438
        $access = $access && entity_access('edit', $entity_type, $entity);
439
      }
440
      $item['is_hidden'] = $item['is_hidden'] && !$access;
441
    }
442
    $content[] = drupal_get_form('makemeeting_answers_form_' . $instance['entity_id'], $item, $instance);
443
  }
444
  return $content;
445
}
446

  
447
/**
448
 * Implements hook_field_load().
449
 */
450
function makemeeting_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age) {
451
  // Unserialize array values
452
  foreach ($entities as $id => $entity) {
453
    foreach ($items[$id] as $delta => $item) {
454
      if ($field['type'] == 'makemeeting' && is_string($items[$id][$delta]['choices'])) {
455
        $items[$id][$delta]['choices'] = unserialize($items[$id][$delta]['choices']);
456
      }
457
    }
458
  }
459
}
460

  
461
/**
462
 * Implements hook_field_presave().
463
 */
464
function makemeeting_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
465
  if ($field['type'] == 'makemeeting') {
466
    foreach ($items as $delta => $item) {
467
      if (isset($item['choices'])) {
468
        // Sort the choices by date
469
        $choices = array_values($item['choices']);
470
        usort($choices, '_makemeeting_sort_choices');
471
        // Affect timestamp as keys
472
        $timestamped_choices = array();
473
        foreach ($choices as $choice) {
474
          $timestamped_choices[_makemeeting_date_timestamp($choice['chdate'])] = $choice;
475
        }
476
        // Serialize the whole array
477
        $items[$delta]['choices'] = serialize($timestamped_choices);
478
      }
479
    }
480
  }
481
}
482

  
483
/**
484
 * Helper function to sort choice dates
485
 */
486
function _makemeeting_sort_choices($a, $b) {
487
  if ($a['chdate']['year'] == $b['chdate']['year']) {
488
    if ($a['chdate']['month'] == $b['chdate']['month']) {
489
      if ($a['chdate']['day'] == $b['chdate']['day']) {
490
        return 0;
491
      }
492
      else {
493
        return (int) $a['chdate']['day'] < (int) $b['chdate']['day'] ? -1 : 1;
494
      }
495
    }
496
    else {
497
      return (int) $a['chdate']['month'] < (int) $b['chdate']['month'] ? -1 : 1;
498
    }
499
  }
500
  else {
501
    return (int) $a['chdate']['year'] < (int) $b['chdate']['year'] ? -1 : 1;
502
  }
503
}
504

  
505

  
506
/**
507
 * Submit handler to add more choices or suggestions to a poll form,
508
 * or to copy the first row of suggestions to the others
509
 *
510
 * This handler is run regardless of whether JS is enabled or not. It makes
511
 * changes to the form state. If the button was clicked with JS disabled, then
512
 * the page is reloaded with the complete rebuilt form. If the button was
513
 * clicked with JS enabled, then ajax_form_callback() calls makemeeting_choice_js() to
514
 * return just the changed part of the form.
515
 */
516
function makemeeting_choices_submit($form, &$form_state) {
517
  $clicked_button = $form_state['clicked_button'];
518

  
519
  // Get the element
520
  $element =& drupal_array_get_nested_value($form_state['input'], $clicked_button['#parents']);
521

  
522
  // If clicked button is 'Remove', unset corresponding choice
523
  if ($clicked_button['#value'] == t('Remove')) {
524
    unset($element['choices'][$clicked_button['#name']]);
525
    $form_state['choice_count'] = count($element['choices']);
526
  }
527

  
528
  // Affect timestamp as key to each choice
529
  $choices = array();
530
  if (isset($element['choices'])) {
531
    foreach ($element['choices'] as $choice) {
532
      $choices['choices'][_makemeeting_date_timestamp($choice['chdate'])] = $choice;
533
    }
534
  }
535

  
536
  // Handle other operations
537
  if (!empty($form_state['values']['op'])) {
538
    switch ($form_state['values']['op']) {
539
      // Add 1 more choice to the form.
540
      case t('More choices'):
541
        // Increment choice count
542
        $form_state['choice_count'] = count($element['choices']) + 1;
543
        break;
544

  
545
      // Add 1 more suggestion to the form.
546
      case t('More suggestions'):
547
        $form_state['suggestion_count']++;
548
        break;
549

  
550
      // Copy first row suggestions to the other rows.
551
      case t('Copy and paste first row');
552
        $first = reset($choices['choices']);
553
        foreach (array_keys($choices['choices']) as $key) {
554
          $choices['choices'][$key]['chsuggestions'] = $first['chsuggestions'];
555
        }
556
        break;
557
    }
558
  }
559

  
560
  // Replace submitted values by our own work
561
  drupal_array_set_nested_value($form_state['input'], $clicked_button['#parents'], $choices);
562
  drupal_array_set_nested_value($form_state['values'], $clicked_button['#parents'], $choices);
563

  
564
  // Require the widget form to rebuild the choices
565
  // with the values in $form_state
566
  $form_state['rebuild'] = TRUE;
567
}
568

  
569
/**
570
 * Ajax callback in response to new choices being added to the form.
571
 *
572
 * This returns the new page content to replace the page content made obsolete
573
 * by the form submission.
574
 */
575
function makemeeting_choice_js($form, $form_state) {
576
  // Get the element from the parents of the clicked button
577
  $element = drupal_array_get_nested_value($form, $form_state['clicked_button']['#parents']);
578
  return $element['choices_wrapper'];
579
}
drupal7/sites/all/modules/makemeeting/makemeeting.info
1
name = Make Meeting
2
description = Field allowing to schedule an event
3
core = 7.x
4
package = Fields
5
dependencies[] = field
6
files[] = makemeeting.test
7

  
8
; Information added by Drupal.org packaging script on 2016-10-21
9
version = "7.x-2.1"
10
core = "7.x"
11
project = "makemeeting"
12
datestamp = "1477053252"
13

  
drupal7/sites/all/modules/makemeeting/makemeeting.install
1
<?php
2

  
3
/**
4
 * @file
5
 * Makemeeting installation schemas
6
 */
7

  
8
/**
9
 * Implements hook_field_schema().
10
 */
11
function makemeeting_field_schema($field) {
12
  return array(
13
    'columns' => array(
14
      'closed' => array(
15
        'type' => 'int',
16
        'length' => 1,
17
        'not null' => FALSE,
18
        'default' => 0,
19
      ),
20
      'hidden' => array(
21
        'type' => 'int',
22
        'length' => 1,
23
        'not null' => FALSE,
24
        'default' => 0,
25
      ),
26
      'one_option' => array(
27
        'type' => 'int',
28
        'length' => 1,
29
        'not null' => FALSE,
30
        'default' => 0,
31
      ),
32
      'limit' => array(
33
        'type' => 'int',
34
        'not null' => FALSE,
35
        'default' => 0,
36
      ),
37
      'yesnomaybe' => array(
38
        'type' => 'int',
39
        'length' => 1,
40
        'not null' => FALSE,
41
        'default' => 0,
42
      ),
43
      'choices' => array(
44
        'type' => 'blob',
45
        'not null' => FALSE,
46
        'size' => 'big',
47
        'serialize' => TRUE,
48
      ),
49
    ),
50
  );
51
}
52

  
53
/**
54
 * Implements hook_schema().
55
 */
56
function makemeeting_schema() {
57
  $schema['makemeeting_answers'] = array(
58
    'description' => 'The choices by the visitors.',
59
    'fields' => array(
60
      'answer_id' => array(
61
        'type' => 'serial',
62
        'unsigned' => TRUE,
63
        'not null' => TRUE,
64
      ),
65
      'field_name' => array(
66
        'type' => 'varchar',
67
        'length' => 32,
68
        'not null' => TRUE,
69
        'description' => 'The name of the field this data is attached to',
70
      ),
71
      'entity_type' => array(
72
        'type' => 'varchar',
73
        'length' => 128,
74
        'not null' => TRUE,
75
        'default' => '',
76
        'description' => 'The entity type this data is attached to',
77
      ),
78
      'deleted' => array(
79
        'type' => 'int',
80
        'size' => 'tiny',
81
        'not null' => TRUE,
82
        'default' => 0,
83
        'description' => 'A boolean indicating whether this data item has been deleted'
84
      ),
85
      'entity_id' => array(
86
        'type' => 'int',
87
        'unsigned' => TRUE,
88
        'not null' => TRUE,
89
        'description' => 'The entity id this data is attached to',
90
      ),
91
      'language' => array(
92
        'type' => 'varchar',
93
        'length' => 32,
94
        'not null' => TRUE,
95
        'default' => '',
96
        'description' => 'The language for this data item.',
97
      ),
98
      'delta' => array(
99
        'type' => 'int',
100
        'unsigned' => TRUE,
101
        'not null' => TRUE,
102
        'description' => 'The sequence number for this data item, used for multi-value fields',
103
      ),
104
      'value' => array(
105
        'type' => 'text',
106
        'serialize' => TRUE,
107
      ),
108
      'uid' => array(
109
        'type' => 'int',
110
        'unsigned' => TRUE,
111
        'not null' => TRUE,
112
        'default' => 0,
113
      ),
114
      'name' => array(
115
        'type' => 'varchar',
116
        'length' => 255,
117
      ),
118
      'mail' => array(
119
        'type' => 'varchar',
120
        'length' => 255,
121
      ),
122
      'notification' => array(
123
        'type' => 'int',
124
        'not null' => TRUE,
125
        'length' => 1,
126
        'default' => 0,
127
      ),
128
    ),
129
    'primary key' => array('answer_id'),
130
  );
131
  return $schema;
132
}
133

  
134
/**
135
 * Add yesnomaybe column to field tables
136
 */
137
function makemeeting_update_7201() {
138
  $results = db_select('field_config', 'fc')
139
             ->fields('fc')
140
             ->condition('type', 'makemeeting')
141
             ->execute()
142
             ->fetchAll();
143
  foreach ($results as $field) {
144
    foreach (array('data', 'revision') as $type) {
145
      $table = "field_{$type}_{$field->field_name}";
146
      $column = "{$field->field_name}_yesnomaybe";
147
      // Data and revision tables need to be fixed
148
      if (!db_field_exists($table, $column)) {
149
        db_add_field($table, $column, array(
150
          'type' => 'int',
151
          'length' => 1,
152
          'not null' => FALSE,
153
          'default' => 0,
154
        ));
155
      }
156
    }
157
  }
158
}
drupal7/sites/all/modules/makemeeting/makemeeting.js
1
(function ($) {
2
  Drupal.behaviors.makemeetingHoverButtons = {
3
    attach: function (context) {
4
      var $trs = $('.makemeeting-table', context).find('tr.editable');
5
      $trs.removeClass('in').hover(function () {
6
        // This will hide all other tr
7
        $trs.filter(':not(.hovering)').removeClass('in');
8
        $(this).addClass('in hovering');
9
      }, function () {
10
        // Hide links after a while
11
        $(this).removeClass('hovering');
12
        setTimeout(function () {
13
          $trs.filter(':not(.hovering)').removeClass('in');
14
        }, 500);
15
      });
16
    }
17
  };
18

  
19
  Drupal.behaviors.makemeetingFormWidth = {
20
    attach: function (context) {
21
      if ($(context).is('.editing')) {
22
        $(context).next().find('td').each(function (index) {
23
          $('form td', context).eq(index).css('width', $(this).width() + 'px');
24
        });
25
      }
26
    }
27
  };
28
}(jQuery));
drupal7/sites/all/modules/makemeeting/makemeeting.module
1
<?php
2

  
3
/**
4
 * @file
5
 * Hooks and field implementations
6
 */
7

  
8
// Define choice constants
9
define('MAKEMEETING_ANSWER_PERM', 'answer makemeeting form');
10
define('MAKEMEETING_EDIT_PERM', 'edit any makemeeting answer');
11
define('MAKEMEETING_DELETE_PERM', 'delete any makemeeting answer');
12
define('MAKEMEETING_NO', 0);
13
define('MAKEMEETING_YES', 1);
14
define('MAKEMEETING_MAYBE', 2);
15

  
16
/**
17
 * Include required files.
18
 */
19
include_once 'makemeeting.field.inc';
20

  
21
/**
22
 * Implements hook_permission().
23
 */
24
function makemeeting_permission() {
25
  return array(
26
    MAKEMEETING_ANSWER_PERM => array(
27
      'title' => t('Provide an answer to makemeeting forms'),
28
      'description' => t('Give the ability to make a choice in makemeeting answer forms.'),
29
    ),
30
    MAKEMEETING_EDIT_PERM => array(
31
      'title' => t('Edit any makemeeting answers'),
32
      'description' => t('Edit answers given by other users.'),
33
    ),
34
    MAKEMEETING_DELETE_PERM => array(
35
      'title' => t('Delete any makemeeting answers'),
36
      'description' => t('Delete answers given by other users.'),
37
    ),
38
  );
39
}
40

  
41
/**
42
 * Implements hook_menu().
43
 */
44
function makemeeting_menu() {
45
  $items['makemeeting/delete-answer/%makemeeting_answer'] = array(
46
    'title' => 'Remove an answer',
47
    'page callback' => 'drupal_get_form',
48
    'page arguments' => array('makemeeting_delete_answer', 2),
49
    'access callback' => 'makemeeting_delete_answer_access',
50
    'access arguments' => array(2),
51
    'type' => MENU_CALLBACK,
52
  );
53
  $items['makemeeting/edit-answer/%makemeeting_answer'] = array(
54
    'title' => 'Edit an answer',
55
    'page callback' => 'makemeeting_edit_answer',
56
    'page arguments' => array(2),
57
    'access callback' => 'makemeeting_edit_answer_access',
58
    'access arguments' => array(2),
59
    'type' => MENU_CALLBACK,
60
  );
61
  return $items;
62
}
63

  
64
/**
65
 * Load an answer
66
 *
67
 * @param $answer_id
68
 * @return mixed
69
 */
70
function makemeeting_answer_load($answer_id) {
71
  $answer = db_select('makemeeting_answers', 'm')
72
            ->fields('m')
73
            ->condition('answer_id', $answer_id)
74
            ->execute()
75
            ->fetchAssoc();
76
  $answer['value'] = unserialize($answer['value']);
77
  return $answer ? (object) $answer : FALSE;
78
}
79

  
80
/**
81
 * Access callback: delete an answer
82
 *
83
 * @param $answer
84
 * @return bool
85
 */
86
function makemeeting_delete_answer_access($answer) {
87
  global $user;
88
  return user_access(MAKEMEETING_DELETE_PERM) || (user_is_logged_in() && $answer->uid == $user->uid);
89
}
90

  
91
/**
92
 * Access callback: edit an answer
93
 *
94
 * @param $answer
95
 * @return bool
96
 */
97
function makemeeting_edit_answer_access($answer) {
98
  global $user;
99
  return user_access(MAKEMEETING_EDIT_PERM) || (user_is_logged_in() && $answer->uid == $user->uid);
100
}
101

  
102
/**
103
 * Menu callback: delete an answer
104
 *
105
 * @param $form
106
 * @param $form_state
107
 * @param $answer
108
 * @param bool $redirect
109
 * @return
110
 */
111
function makemeeting_delete_answer($form, &$form_state, $answer, $redirect = TRUE) {
112
  $form['#answer'] = $answer;
113
  return confirm_form(
114
    $form,
115
    t('Are you sure you want to delete the answer?'),
116
    ''
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff