/[drupal]/contributions/modules/cubalaya/cubalaya.module
ViewVC logotype

Contents of /contributions/modules/cubalaya/cubalaya.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.8 - (show annotations) (download) (as text)
Thu Jul 26 23:32:10 2007 UTC (2 years, 4 months ago) by njt1982
Branch: MAIN
CVS Tags: HEAD
Changes since 1.7: +2 -2 lines
File MIME type: text/x-php
Fixed an SQL Query
1 <?php
2
3 /**
4 * Implementation of hook_perm
5 *
6 * @return array of permission strings
7 */
8 function cubalaya_perm() {
9 return array('administer cubalaya settings', 'view cubalaya nodes', 'administer cubalaya nodes', 'view cubalaya logs');
10 }
11
12
13 /**
14 * Implementation of hook_help
15 *
16 * @param string $section - Defines section of the site
17 * @return Help Text
18 */
19 function cubalaya_help($section) {
20 switch ($section) {
21 case 'admin/settings#cubalaya' :
22 case 'admin/help#cubalaya':
23 return '<p>' . t('Configure your Cubalaya data here such as Account ID.') . '</p>';
24 case 'admin/settings/cubalaya' :
25 return '<p>' . t('Fill out the form below with your Cubalaya settings. The ID is provided to you by Cubalaya and contains numeric characters only. Fill out one of the height OR width fields - not both. This will limit the size of the images for you.') . '</p>';
26 }
27 }
28
29
30 /**
31 * Implementation of hook_menu
32 *
33 * @param boolean $may_cache - Defines if the menus being returned are statically cachable or dynamic
34 * @return array of menu items
35 */
36 function cubalaya_menu($may_cache) {
37 $items = array();
38
39 if ($may_cache) {
40 $items[] = array(
41 'path' => 'admin/settings/cubalaya',
42 'callback' => 'drupal_get_form',
43 'callback arguments' => array('cubalaya_admin_form'),
44 'access' => user_access('administer cubalaya settings'),
45 'title' => t('Cubalaya'),
46 'description' => t('Configure your Cubalaya data here, such as Account ID.'),
47 );
48 $items[] = array(
49 'path' => 'admin/logs/cubalaya',
50 'callback' => 'cubalaya_logs',
51 'access' => user_access('view cubalaya logs'),
52 'title' => t('Cubalaya'),
53 'description' => t('View Cubalaya Clicks.'),
54 );
55 }
56 else {
57 $items[] = array(
58 'path' => 'cubalaya/' . arg(1),
59 'callback' => 'cubalaya_redirect',
60 'callback arguments' => array(arg(1), (arg(2) == 'test')),
61 'type' => MENU_CALLBACK,
62 'access' => TRUE,
63 );
64 }
65
66 return $items;
67 }
68
69
70 /**
71 * Logs callback page
72 *
73 * @return page output - themed table in this case
74 */
75 function cubalaya_logs() {
76 $result = db_query("SELECT
77 FROM_UNIXTIME(c.timestamp, '%%d-%m-%y') as day,
78 c.nid nid,
79 count(*) as count
80 FROM cubalaya_hits c
81 GROUP BY day, c.nid WITH ROLLUP
82 ");
83
84
85 $max = 0;
86 $data = array();
87 while($line = db_fetch_object($result)) {
88 if (empty($line->day)) {
89 //No day - this is the overall total...
90 }
91 else {
92 //Day is set - is the nid?
93 if(empty($line->nid)) {
94 //Nid not set, total for that day
95 $data[$line->day]['total'] = $line->count;
96 if ($data[$line->day]['total'] > $max) { $max = $data[$line->day]['total']; }
97 }
98 else {
99 //Nid is set, total for that node on that day
100 $data[$line->day]['nid'][$line->nid] = $line->count;
101 }
102 }
103 }
104
105
106 $rows = array();
107 foreach ($data as $day => $day_data) {
108 $row = array();
109
110 $row[] = $day;
111 $row[] = $day_data['total'];
112 $row[] = theme('cubalaya_day_breakdown', $day_data, $max);
113
114 $rows[] = $row;
115 }
116
117 drupal_add_css(drupal_get_path('module', 'cubalaya') . '/cubalaya.css');
118 $headers = array(
119 array('data' => 'Date', 'style'=>'width: 60px'),
120 array('data' => 'Total', 'style'=>'width: 40px'),
121 'Breakdown'
122 );
123 return theme('table', $headers, $rows, array('style' => 'width: 100%;'));
124 }
125
126
127 /**
128 * Pass in an array of hits per node for that day - get out a bar split relateively per day
129 *
130 * @param array $data - array of hits for that day per node
131 * @param integer $max - maximum number of hits in period being displayed - used for percentage purposes
132 * @return rendered output
133 */
134 function theme_cubalaya_day_breakdown($data, $max) {
135 $output = '<div class="cubalaya_bar">';
136
137 $first = true;
138 foreach ($data['nid'] as $nid => $count) {
139 $output .= '<div class="cubalaya_breakdown_day ' . ($first ? 'first ' : '') . 'node_' . $nid . '" style="width: ' . (98.0 * $count / $max) . '%; "><!-- --></div>';
140 $first = false;
141 }
142
143 $output .= '</div>';
144
145 return $output;
146 }
147
148
149 /**
150 * Redirect Callback
151 *
152 * @param integer $nid - Node ID of Cubalaya Product
153 * @param boolean $testing - If true, then DO NOT record the hit in the database
154 * @return if node is cubalaya product then no return (redirects instead), otherwise a 404.
155 */
156 function cubalaya_redirect($nid, $testing = FALSE) {
157 if ($node = node_load($nid)) {
158 if ($node->type == 'cubalaya') {
159 $settings = variable_get('cubalaya', array());
160
161 $keywords = explode(',', $node->keywords);
162
163 array_walk($keywords, 'trim');
164 $keywords = implode('-', $keywords);
165
166 $path = $node->link_type . '-' . $keywords;
167
168 if (!$testing) {
169 db_query("INSERT INTO {cubalaya_hits} VALUES(%d, %d)", $node->nid, time());
170 }
171
172 drupal_goto('http://www.cubalaya.co.uk/' . $path, $testing ? NULL : 'inId=' . $settings['settings']['id'], NULL, 301);
173 }
174 }
175 return drupal_not_found();
176 }
177
178
179 /**
180 * Implementation of hook_requirements
181 *
182 * @param string $phase - represents drupal phase (eg install or runtime)
183 * @return array of requirement data
184 */
185 function cubalaya_requirements($phase) {
186 $requirements = array();
187 // Ensure translations don't break at install time
188 $t = get_t();
189
190 // Report status
191 if ($phase == 'runtime') {
192 $requirements['cubalaya'] = array( 'title' => t('Cubalaya'), );
193
194
195 $settings = variable_get('cubalaya', NULL);
196 if(is_array($settings)) {
197 $errors = array();
198
199 //Check if the account ID is set
200 if (!isset($settings['settings']['id'])) {
201 $errors[] = $t('There is no account ID.');
202 }
203
204 //Check if the thumbnail sizes are set.
205 if (!isset($settings['thumbnail']['width']) || !isset($settings['thumbnail']['height'])) {
206 $errors[] = $t('There are no thumbnail settings.');
207 }
208
209 //If no errors, set a nice output - otherwise set and error output.
210 if (empty($errors)) {
211 $requirements['cubalaya']['value'] = $t('The module seems to be configured correctly.');
212 }
213 else {
214 $requirements['cubalaya']['value'] = $t('There are configuration errors... please <a href="@url">rectify them</a>', array('@url' => url('admin/settings/cubalaya'), ));
215 $requirements['cubalaya']['description'] = theme('item_list', $errors);
216 $requirements['cubalaya']['severity'] = REQUIREMENT_ERROR;
217 }
218 }
219 else {
220 //No settings done yet, set a severe warning
221 $requirements['cubalaya']['value'] = $t('No configuration found.');
222 $requirements['cubalaya']['description'] = $t('please <a href="@url">configure this module</a>.', array('@url' => url('admin/settings/cubalaya'),));
223 $requirements['cubalaya']['severity'] = REQUIREMENT_ERROR;
224 }
225 }
226
227 return $requirements;
228 }
229
230
231 /**
232 * Implementation of hook_access
233 *
234 * @param string $op - Operation on $node
235 * @param object $node - Node Object
236 * @return boolean
237 */
238 function cubalaya_access($op, $node) {
239 if ($op == 'view') {
240 return user_access('administer cubalaya nodes');
241 }
242
243 else {
244 return user_access('administer cubalaya nodes');
245 }
246 }
247
248
249 /**
250 * Implementation of hook_node_info
251 *
252 * @return array containing information about the Node - appears with the Create Content section
253 */
254 function cubalaya_node_info() {
255 return array(
256 'cubalaya' => array(
257 'name' => t('Cubalaya Product'),
258 'module' => 'cubalaya',
259 'description' => t("This is a cubalaya product which gets associated with other nodes."),
260 )
261 );
262 }
263
264
265 /**
266 * Implementation of hook_form
267 *
268 * @param object $node - the Node object
269 * @return array - structured as per the Forms API
270 */
271 function cubalaya_form(&$node) {
272 $type = node_get_types('type', $node);
273
274 $form['#attributes'] = array('enctype' => 'multipart/form-data');
275
276 // We need to define form elements for the node's title and body.
277 $form['title'] = array(
278 '#type' => 'textfield',
279 '#title' => t('Product Title'),
280 '#required' => TRUE,
281 '#default_value' => $node->title,
282 '#weight' => -5,
283 '#description' => t('Enter the title of the product here'),
284 );
285
286 $form['keywords'] = array(
287 '#type' => 'textfield',
288 '#title' => t('Product Keywords'),
289 '#required' => TRUE,
290 '#default_value' => $node->keywords,
291 '#weight' => -3,
292 '#description' => t('Enter some keywords for this product, command separated'),
293 );
294
295 $form['link_type'] = array(
296 '#type' => 'select',
297 '#title' => t('What type of link would you like?'),
298 '#required' => TRUE,
299 '#default_value' => $node->link_type,
300 '#options' => array('OP' => 'Offers Page (OP)', 'DP' => 'Deal Page (DP)', 'DC' => 'Direct Connect (DC)'),
301 '#weight' => 0,
302 '#description' => t('Enter some keywords for this product, command separated'),
303 );
304
305 if ($node->thumbnail) {
306 $rows = array();
307 foreach (image_get_info($node->thumbnail) as $key => $value) {
308 $rows[] = array($key, $value);
309 }
310 $form['thumbnail_preview'] = array('#title' => t('Current Thumbnail'), '#value' => theme('table', NULL, $rows));
311 $form['thumbnail'] = array('#type' => 'value', '#value' => $node->thumbnail);
312 }
313
314 $form['new_thumbnail'] = array(
315 '#type' => 'file',
316 '#title' => t('Image Thumbnail'),
317 '#weight' => 4,
318 '#description' => t('Attach an image to represent this product.'),
319 );
320
321 if ($node->thumbnail) {
322 $form['new_thumbnail']['#description'] = t('An image is already attached, adding an image here will replace the previous image.');
323 }
324
325
326 return $form;
327 }
328
329
330 /**
331 * Implementation of hook_validate
332 *
333 * @param Object $node - Node Object being validated
334 */
335 function cubalaya_validate(&$node) {
336
337 if (preg_match('|[^a-z0-9,]|i', $node->keywords)) {
338 form_set_error('keywords', t('Please use alpha-numeric characters for the keyword and separate by comma.'));
339 }
340
341 if (empty($node->thumbnail) && empty($_FILES['files']['tmp_name']['new_thumbnail'])) {
342 form_set_error('new_thumbnail', t('You must attach a thumbnail to this product'));
343 }
344 else if (!empty($_FILES['files']['tmp_name']['new_thumbnail']) && !in_array($_FILES['files']['type']['new_thumbnail'], array('image/png', 'image/gif', 'image/jpg', 'image/jpeg'))) {
345 form_set_error('new_thumbnail', t('Please only attach PNG, GIF or JPEG images.'));
346 }
347
348
349 //These need to be done in two steps to make sure the top level folder exists.
350
351 //Check for the cubalaya folder
352 $path = file_directory_path() . '/cubalaya';
353 file_check_directory($path, FILE_CREATE_DIRECTORY, 'new_thumbnail');
354
355 //Check for the cubalaya/source folder
356 $path = file_directory_path() . '/cubalaya/source';
357 file_check_directory($path, FILE_CREATE_DIRECTORY, 'new_thumbnail');
358 }
359
360
361 /**
362 * Implementation of hook_submit
363 *
364 * @param Object $node - Node object being submitted
365 */
366 function cubalaya_submit(&$node) {
367 $dest = file_create_path('cubalaya/source');
368
369 if ($file = file_check_upload('new_thumbnail')) {
370 $uploaded = file_save_upload($file, $dest);
371 }
372
373 if(is_object($uploaded)) {
374 $node->thumbnail = $uploaded->filepath;
375 }
376 }
377
378
379 /**
380 * Implementation of hook_insert
381 *
382 * @param Object $node - Node object being inserted
383 */
384 function cubalaya_insert(&$node) {
385 db_query("INSERT INTO {node_cubalaya} VALUES(%d, '%s', '%s', '%s')", $node->nid, $node->keywords, $node->link_type, $node->thumbnail);
386 }
387
388
389 /**
390 * Implementation of hook_update. This deletes any existing data and calls the insert function
391 *
392 * @param Object $node - Node object being updated
393 */
394 function cubalaya_update(&$node) {
395 db_query("DELETE FROM {node_cubalaya} WHERE nid=%d", $node->nid);
396 cubalaya_insert($node);
397 }
398
399
400 /**
401 * Implementation of hook_load
402 *
403 * @param Object $node - Node object being loaded
404 * @return Object to be appended onto Node
405 */
406 function cubalaya_load($node) {
407 return db_fetch_object(db_query("SELECT * FROM {node_cubalaya} WHERE nid = %d", $node->nid));
408 }
409
410
411 /**
412 * Implementation of hook_view
413 *
414 * @param Object $node - Node object being viewed
415 * @param boolean $teaser - if view is teaser
416 * @param boolean $page - if view is page
417 * @return Node object
418 */
419 function cubalaya_view($node, $teaser = FALSE, $page = FALSE) {
420 $node = node_prepare($node, $teaser);
421
422 $node->content['product_thumbnail'] = array(
423 '#value' => theme('cubalaya_thumbnail', $node),
424 '#weight' => 1,
425 );
426 $node->content['cubalaya_link'] = array(
427 '#value' => l('Test Link', 'cubalaya/' . $node->nid . '/test', array('target' => '_blank')),
428 '#weight' => 2,
429 );
430
431
432 return $node;
433 }
434
435
436 /**
437 * Theme function to render a thumbnail for a node
438 *
439 * @param Object $node - Node Object being themed
440 * @return Output HTML
441 */
442 function theme_cubalaya_thumbnail($node) {
443 if ($node->type != 'cubalaya') {
444 return t('Not a Cubalaya Node');
445 }
446
447 $settings = variable_get('cubalaya', array());
448
449 if (!($thumbnail_dst = cubalaya_get_thumbnail($node->thumbnail))) {
450 $thumb_not_found_src = drupal_get_path('module', 'cubalaya') . '/images/thumbnail-not-available.png';
451
452 if (!($thumbnail_dst = cubalaya_get_thumbnail($thumb_not_found_src))) {
453 return "ERROR!!!";
454 }
455 }
456
457 $output = '<p>' . l(t($node->title), 'cubalaya/' . $node->nid) . '</p>';
458 $output .= '<p>' . l(theme('image', $thumbnail_dst, $node->title, $node->title), 'cubalaya/' . $node->nid, array(), NULL, NULL, FALSE, TRUE) . '</p>';
459
460 return $output;
461 }
462
463
464 /**
465 * Function to get the path to a thumbnail
466 *
467 * @param string $src - Path to Source image
468 * @return Either path to thumbnail OR FALSE is thumbnail creation failed
469 */
470 function cubalaya_get_thumbnail($src) {
471 //If source doesn't exist, return false
472 if (!is_file($src)) {
473 return FALSE;
474 }
475
476 //Get settings
477 $settings = variable_get('cubalaya', array('thumbnail' => array('height' => 64, 'width' => ''), ));
478
479 //Get a hash of the source.
480 $src_hash = md5($src . $settings['thumbnail']['height'] . $settings['thumbnail']['width']);
481
482
483 //Check the destination folder structure exists first...
484 //Check for the cubalaya folder
485 $path = file_directory_path() . '/cubalaya';
486 if (!file_check_directory($path, FILE_CREATE_DIRECTORY, 'thumbnail')) return false;
487
488 //Check for the cubalaya/thumbs folder
489 $path = file_directory_path() . '/cubalaya/thumbs';
490 if (!file_check_directory($path, FILE_CREATE_DIRECTORY, 'thumbnail')) return false;
491
492
493 $dst = file_create_path('cubalaya/thumbs') . '/' . $src_hash . '.jpg';
494
495 if (is_file($dst)) {
496 //File exists - return the path
497 return $dst;
498 }
499 else {
500 //File doesn't exist - create it and return the path
501 if ($details = image_get_info($src)) {
502 if ($settings['thumbnail']['height'] > 0) {
503 //Scale based in limited height...
504 $scale = $settings['thumbnail']['height'] / $details['height'];
505 }
506 else {
507 //Scale based in limited width...
508 $scale = $settings['thumbnail']['width'] / $details['width'];
509 }
510
511 $width = $details['width'] * $scale;
512 $height = $details['height'] * $scale;
513 ini_set('memory_limit', '32M');
514 if (image_resize($src, $dst, $width, $height)) {
515 //If it worked - return the destination image path
516 return $dst;
517 }
518 else {
519 //Return false
520 return FALSE;
521 }
522 }
523 else {
524 //Unable to get details on image - fail to create thumbnail
525 return FALSE;
526 }
527 }
528
529 //We shouldn't really ever get here, but if we do - assume something has gone wrong getting the thumbnail!
530 return FALSE;
531 }
532
533
534 /**
535 * Admin form callback
536 *
537 * @return array structured as per Forms API with System Settings buttons
538 */
539 function cubalaya_admin_form() {
540 $settings = variable_get('cubalaya', array());
541
542 $form = array();
543
544 $form['cubalaya'] = array(
545 '#tree' => TRUE,
546 );
547
548 $form['cubalaya']['settings'] = array(
549 '#type' => 'fieldset',
550 '#title' => t('Settings'),
551 );
552
553 $form['cubalaya']['thumbnail'] = array(
554 '#type' => 'fieldset',
555 '#title' => t('Thumbnail Settings'),
556 );
557
558
559 $form['cubalaya']['settings']['id'] = array(
560 '#title' => t('Account ID'),
561 '#type' => 'textfield',
562 '#description' => t('This is your account ID - usually a positive number.'),
563 '#required' => TRUE,
564 '#default_value' => isset($settings['settings']['id']) ? $settings['settings']['id'] : 0,
565 );
566
567 $form['cubalaya']['thumbnail']['width'] = array(
568 '#title' => t('Thumbnail Width'),
569 '#type' => 'textfield',
570 '#description' => t('Maxmimum width of a thumbnail.'),
571 '#default_value' => isset($settings['thumbnail']['width']) ? $settings['thumbnail']['width'] : '',
572 );
573
574 $form['cubalaya']['thumbnail']['height'] = array(
575 '#title' => t('Thumbnail Height'),
576 '#type' => 'textfield',
577 '#description' => t('Maximum height of a thumbnail.'),
578 '#default_value' => isset($settings['thumbnail']['height']) ? $settings['thumbnail']['height'] : '',
579 );
580
581 return system_settings_form($form);
582 }
583
584
585 /**
586 * Validate the Admin Form
587 *
588 * @param string $form_id - unique ID for form
589 * @param array $form_values - array of form values entered
590 */
591 function cubalaya_admin_form_validate($form_id, $form_values) {
592 $empty_width = empty($form_values['cubalaya']['thumbnail']['width']);
593 $empty_height = empty($form_values['cubalaya']['thumbnail']['height']);
594 if ( ! ($empty_width xor $empty_height)) {
595 //THIS ISN'T WORKING - IT WONT HIGHLIGHT THE FIELDS...
596 form_set_error('cubalaya][thumbnail', t('You must fill out only one of the thumbnail size fields.'));
597 }
598 }
599
600
601 /**
602 * Implementation of hook_block
603 *
604 * @param string $op - Operation being performed on the block
605 * @param mixed $delta - ID for this particular block
606 * @param array $edit - values from configuration
607 * @return array, depends on $op. See API for more details.
608 */
609 function cubalaya_block($op = 'list', $delta = 0, $edit = array()) {
610 if ($op == 'list') {
611 $blocks[0]['info'] = t('Cubalaya Products Block');
612 return $blocks;
613 }
614 else if ($op == 'view') {
615 $products = cubalaya_get_associate_products();
616 if (count($products)) {
617 $nodes = array();
618 foreach ($products as $nid) {
619 $nodes[] = node_load($nid);
620 }
621
622 if (!empty($nodes)) {
623 return array(
624 'title' => t('Cubalaya'),
625 'content' => theme('cubalaya_products_block', $nodes) . theme('cubalaya_image_link'),
626 );
627 }
628 }
629 }
630 }
631
632
633 /**
634 * Theem function to render a cubalaya image link - used in the block.
635 *
636 * @return unknown
637 */
638 function theme_cubalaya_image_link() {
639 return l(theme('image', drupal_get_path('module', 'cubalaya') . '/images/logo_85_25.png'), 'http://www.cubalaya.co.uk', array('target'=>'_blank'), NULL, NULL, TRUE, TRUE);
640 }
641
642
643 /**
644 * Theme function to attach products to a block - exposed as theme to allow sites to manipulate the output.
645 *
646 * @param array $products - list of product nodes.
647 * @return HTML output for a set of thumbnails
648 */
649 function theme_cubalaya_products_block($products = array()) {
650 $output = '';
651 foreach ($products as $node) {
652 $output .= theme('cubalaya_thumbnail', $node);
653 }
654 return $output;
655 }
656
657
658 /**
659 * Implementation of hook_nodeapi
660 *
661 * @param object $node - Node Object being operated on
662 * @param string $op - Operation String, for example 'load'
663 * @param mixed $a3 - depends on $op, see API
664 * @param mixed $a4 - depends on $op, see API
665 * @return mixed - depends on $op, see API
666 */
667 function cubalaya_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
668 switch ($op) {
669 case 'load' :
670 if ($node->type == 'cubalaya') break;
671 $node_vocabs = taxonomy_get_vocabularies('cubalaya');
672
673 $node_cubalaya_terms = array();
674 foreach ($node_vocabs as $v) {
675 $terms = taxonomy_node_get_terms_by_vocabulary($node->nid, $v->vid);
676 $node_cubalaya_terms += $terms;
677 }
678
679 if (count($node_cubalaya_terms)) {
680 $result = db_query(
681 "SELECT tn.nid nid, count(*) cnt FROM {term_node} tn, node n WHERE tn.tid IN (%s) AND n.nid = tn.nid AND n.type = 'cubalaya' GROUP BY tn.nid ORDER BY cnt DESC",
682 implode(", ", array_keys($node_cubalaya_terms))
683 );
684
685 $cubalaya_nodes = array();
686 while ($line = db_fetch_object($result)) {
687 $cubalaya_nodes[] = $line->nid;
688 }
689
690 $output['cubalaya'] = $cubalaya_nodes;
691 return $output;
692 }
693 return array('cubalaya' => array());
694 case 'view' :
695 //We do this as we're only interested in getting the cubalaya block visible is we're VIEWING the node AND its in page view.
696 if ($a4) {
697 cubalaya_get_associate_products($node->cubalaya);
698 }
699 }
700 }
701
702
703 /**
704 * Static cache to allow data to be passed from nodeapi to block rendering
705 *
706 * @param array $product_ids - Array of product Node ID's
707 * @return statically cached product node ID's
708 */
709 function cubalaya_get_associate_products($product_ids = NULL) {
710 static $products = array();
711
712 if (isset($product_ids)) {
713 $products = $product_ids;
714 }
715
716 return $products;
717 }
718
719
720
721 function cubalaya_disable() {
722 cubalaya_node_access_disabling(TRUE);
723 node_access_rebuild();
724 }
725
726
727
728 function cubalaya_node_access_disabling($set = NULL) {
729 static $disabling = false;
730 if ($set !== NULL) {
731 $disabling = $set;
732 }
733 return $disabling;
734 }
735
736
737 function cubalaya_enable() {
738 node_access_rebuild();
739 }
740
741
742 function cubalaya_node_access_records($node) {
743 if (cubalaya_node_access_disabling()) {
744 return;
745 }
746
747 if ($node->type == 'cubalaya') {
748 $grants = array();
749 $grants[] = array(
750 'realm' => 'cubalaya_product',
751 'gid' => TRUE,
752 'grant_view' => TRUE,
753 'grant_update' => FALSE,
754 'grant_delete' => FALSE,
755 'priority' => 0,
756 );
757
758 return $grants;
759 }
760 }
761
762
763 function cubalaya_node_grants($account, $op) {
764 if ($op == 'view' && user_access('administer cubalaya settings', $account)) {
765 $grants['cubalaya_product'] = array(1);
766 }
767
768 if (($op == 'update' || $op == 'delete') && user_access('edit private content', $account)) {
769 $grants['cubalaya_product'] = array(1);
770 }
771
772 return $grants;
773 }

  ViewVC Help
Powered by ViewVC 1.1.2