0
|
1 <?php
|
|
2
|
|
3 ctools_add_js('auto-submit');
|
|
4
|
|
5 function digitalobjects_user_admin_collection_submit($form,$formstate){
|
|
6 $userid = $formstate['values']['userid'];
|
|
7
|
|
8
|
|
9
|
|
10 drupal_goto("user/".$userid.'/collections');
|
|
11
|
|
12 }
|
|
13 function digitalobjects_user_admin_collection($key){
|
|
14
|
|
15
|
|
16
|
|
17
|
|
18 $form['digitalobjects_user_admin_form'] = drupal_get_form("digitalobjects_user_admin_form");
|
|
19 #$form = drupal_get_form("digitalobjects_user_admin_form");
|
|
20
|
|
21 $user_full=user_load($key);
|
|
22 $val = $user_full->field_digitalobjects_cid['und'][0]['objid'];
|
|
23
|
|
24 $form['digitalobjects_user_admin_form']['digitalcollection']['#default_value']="";
|
|
25 $form['digitalobjects_user_admin_form']['digitalcollection']['#value']=$val;
|
|
26 $form['digitalobjects_user_admin_form']['userid']['#value']=$key;
|
|
27
|
|
28 //$form['digitalcollection_chooser'] = drupal_get_form("digitalcollection_chooser");
|
|
29
|
|
30
|
|
31 # $element = $form;
|
|
32
|
|
33 $form['chooser']=drupal_get_form("digitalcollection_chooser");
|
|
34
|
|
35 $form['chooser']['pager'] = array('#markup' => theme('pager'));
|
|
36 $form['chooser']['userid']['#value']=$key;
|
|
37
|
|
38 #$element += $form3;
|
|
39
|
|
40 #
|
|
41 #$element += $form2;
|
|
42
|
|
43 return $form;
|
|
44 }
|
|
45
|
|
46 function digitalcollection_chooser(array $form){
|
|
47 // Build the sortable table header.
|
|
48 $header = array(
|
|
49 'title' => array('data' => t('Title'), 'field' => 'n.title'),
|
|
50 'nid' => array('data' => t('nid'), 'field' => 'n.nid')
|
|
51 );
|
|
52
|
|
53
|
|
54 #$result = db_query("SELECT nid FROM node WHERE type = :ntype ", array ('ntype' => 'digitalcollection'));
|
|
55 $result = db_query("SELECT n.nid FROM {node} n ");
|
|
56
|
|
57 $nids = array();
|
|
58 foreach ($result as $record) {
|
|
59 $nids[] = $record->nid;
|
|
60 }
|
|
61 //Get the node data.
|
|
62 //$nids = $query
|
|
63 //->fields('n',array('nid'))
|
|
64 //->limit(50)
|
|
65 //->orderByHeader($header)
|
|
66 //->execute()
|
|
67 //->fetchCol();
|
|
68
|
|
69
|
|
70 $nodes = node_load_multiple($nids);
|
|
71
|
|
72 //Build the rows.
|
|
73 $options = array();
|
|
74 $l_options=array("");
|
|
75 $destination = drupal_get_destination();
|
|
76 $languages = language_list();
|
|
77 foreach ($nodes as $node) {
|
|
78 $langcode = entity_language('node', $node);
|
|
79 $l_options = $langcode != LANGUAGE_NONE && isset($languages[$langcode]) ? array('language' => $languages[$langcode]) : array();
|
|
80
|
|
81 $options[$node->nid] = array(
|
|
82 'title' => array(
|
|
83 'data' => array(
|
|
84 '#type' => 'link',
|
|
85 '#title' => $node->title,
|
|
86 '#href' => 'node/' . $node->nid,
|
|
87 '#options' => $l_options,
|
|
88 '#suffix' => ' ' ,
|
|
89 ),
|
|
90 ),
|
|
91 'nid' => $node->nid,
|
|
92 );
|
|
93
|
|
94 }
|
|
95
|
|
96 $destination = drupal_get_destination();
|
|
97
|
|
98 /*
|
|
99 $operations = array();
|
|
100 if (node_access('update', $node)) {
|
|
101 $operations['edit'] = array(
|
|
102 'title' => t('edit'),
|
|
103 'href' => 'node/' . $node->nid . '/edit',
|
|
104 'query' => $destination,
|
|
105 );
|
|
106 }
|
|
107 if (node_access('delete', $node)) {
|
|
108 $operations['delete'] = array(
|
|
109 'title' => t('delete'),
|
|
110 'href' => 'node/' . $node->nid . '/delete',
|
|
111 'query' => $destination,
|
|
112 );
|
|
113 }
|
|
114 $options[$node->nid]['operations'] = array();
|
|
115 $options[$node->nid]['operations'] = array(
|
|
116 'data' => array(
|
|
117 '#theme' => 'links__node_operations',
|
|
118 '#links' => $operations,
|
|
119 '#attributes' => array('class' => array('links', 'inline')),
|
|
120 ),
|
|
121 );
|
|
122
|
|
123
|
|
124 */
|
|
125
|
|
126
|
|
127
|
|
128
|
|
129 $form['digitalcollection_chooser'] = array(
|
|
130 '#type' => 'tableselect',
|
|
131 '#header' => $header,
|
|
132 '#options' => $options,
|
|
133 '#empty' => t('No content available.'),
|
|
134 '#attributes' => array('class' => array('search-form', 'ctools-auto-submit-full-form')),
|
|
135 '#multiple' => False,
|
|
136
|
|
137 );
|
|
138
|
|
139 #form['chooser']['change'] = array('#type' => 'actions');
|
|
140 $form+= $form['submit2'] = array('#type' => 'submit', '#value' => t('Choose'));
|
|
141 #$form['chooser']['#submit'][] = 'digitalobjects_user_change_form_submit';
|
|
142 $form['submit2']['#submit'][] = 'digitalobjects_user_change_form_submit';
|
|
143 #$form['chooser']['#attributes']= array('class' => array('ctools-use-ajax', 'ctools-auto-submit-click'));
|
|
144
|
|
145 $form['userid'] = array(
|
|
146 '#type' => 'hidden',
|
|
147 );
|
|
148
|
|
149 return $form;
|
|
150 }
|
|
151
|
|
152
|
|
153 function digitalobjects_user_change_form_submit($form,$formstate){
|
|
154 $input = $formstate['input']['digitalcollection_chooser'];
|
|
155 $userid = $formstate['values']['userid'];
|
|
156
|
|
157 $user=user_load($userid);
|
|
158
|
|
159
|
|
160 $user->field_digitalobjects_cid['und'][0]['objid'] = $input;
|
|
161
|
|
162 user_save($user);
|
|
163
|
|
164 }
|
|
165 #füge objid zur aktuelle sammlung hinzu
|
|
166 function digitalobjects_addToCurrentCollection($objid){
|
|
167 global $user;
|
|
168 #hole current collection
|
|
169 $user_full = user_load($user->uid);
|
|
170 $val = $user_full->field_digitalobjects_cid['und'][0]['objid'];
|
|
171
|
|
172 #hole sammlung
|
|
173
|
|
174 $node = node_load($val);
|
|
175
|
|
176 foreach ( $node->field_objid['und'] as $obj){
|
|
177 if ($obj['objid']==$objid){
|
|
178 return drupal_set_message(t("Already in the current collection"),"error");
|
|
179 }
|
|
180
|
|
181 }
|
|
182
|
|
183 $node->field_objid['und'][]['objid']=$objid;
|
|
184
|
|
185 $node = node_submit($node);
|
|
186
|
|
187 node_save($node);
|
|
188
|
|
189 drupal_goto("node/".$node->nid);
|
|
190 }
|
|
191
|
|
192
|
|
193
|
|
194 function digitalobjects_digitalcollectionsManage(){
|
|
195
|
|
196 $data = $_GET;
|
|
197
|
|
198
|
|
199 global $user;
|
|
200 #hole current collection
|
|
201 $user_full = user_load($user->uid);
|
|
202 $val = $user_full->field_digitalobjects_cid['und'][0]['objid'];
|
|
203
|
|
204 #hole sammlung
|
|
205
|
|
206 $node = node_load($val);
|
|
207
|
|
208 foreach ($data['digitalobjects_items_select'] as $objid){
|
|
209 /*foreach ( $node->field_objid['und'] as $obj){
|
|
210 if ($obj['objid']==$objid){
|
|
211 return drupal_set_message(t("Already in the current collection"),"error");
|
|
212 }
|
|
213
|
|
214 }
|
|
215 */
|
|
216 $node->field_objid['und'][]['objid']=$objid;
|
|
217
|
|
218 }
|
|
219
|
|
220
|
|
221 $node = node_submit($node);
|
|
222
|
|
223 node_save($node);
|
|
224
|
|
225 if (isset($data['redirect'])){
|
|
226
|
|
227 drupal_goto(urldecode($data['redirect']));
|
|
228 } else {
|
|
229 drupal_goto("node/".$node->nid);
|
|
230 }
|
|
231
|
|
232 /*
|
|
233 $output['digitalobjects_item']= array(
|
|
234 '#theme' => 'digitalobjects_item',
|
|
235 '#objid' => '');
|
|
236 return $output;
|
|
237 */
|
|
238 }
|
|
239
|