| 1 |
<?php |
<?php |
| 2 |
// $Id: signit.module,v 1.5.2.21 2007/10/25 01:08:17 arthuregg Exp $ |
// $Id: signit.module,v 1.5.2.22 2007/11/28 01:45:46 arthuregg Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 26 |
* @ TODO remove depreciated menu items |
* @ TODO remove depreciated menu items |
| 27 |
*/ |
*/ |
| 28 |
function signit_menu($may_cache) { |
function signit_menu($may_cache) { |
| 29 |
|
|
| 30 |
|
// pull in the include files |
| 31 |
|
require_once(drupal_get_path('module', 'signit') .'/signit.inc'); |
| 32 |
|
|
| 33 |
$items = array(); |
$items = array(); |
| 34 |
|
|
| 35 |
if ($may_cache) { |
if ($may_cache) { |
| 88 |
|
|
| 89 |
// view SignIt comments page |
// view SignIt comments page |
| 90 |
$items[] = array( |
$items[] = array( |
| 91 |
'path' => 'signit/view', |
'path' => 'signit/view', |
| 92 |
'callback arguments' => array(arg(2)), |
'callback arguments' => array(arg(2)), |
| 93 |
'callback' => 'signit_view_signit_comments', |
'callback' => 'signit_view_signit_comments', |
| 94 |
'access' => user_access('view signit comments'), |
'access' => user_access('view signit comments'), |
| 95 |
'type' => MENU_CALLBACK, |
'type' => MENU_CALLBACK, |
| 96 |
); |
); |
| 97 |
|
|
| 98 |
// admin individual signit |
// admin individual signit |
| 99 |
$items[] = array( |
$items[] = array( |
| 100 |
'title' => t('SignIt node signatures'), |
'title' => t('SignIt node signatures'), |
| 303 |
|
|
| 304 |
// Get all messaging options from modules that implement the signit_message hook |
// Get all messaging options from modules that implement the signit_message hook |
| 305 |
$message = signit_extend('signit_message', 'create', $signit); |
$message = signit_extend('signit_message', 'create', $signit); |
| 306 |
|
print_r($message); |
| 307 |
if (count($message)) { |
if (count($message)) { |
| 308 |
$form['signit']['message'] = array( |
$form['signit']['message'] = array( |
| 309 |
'#type' => 'fieldset', |
'#type' => 'fieldset', |
| 326 |
// get all modules which implement hook_signit_user |
// get all modules which implement hook_signit_user |
| 327 |
$form['signit']['user'] = signit_extend('signit_user', 'create', $signit); |
$form['signit']['user'] = signit_extend('signit_user', 'create', $signit); |
| 328 |
|
|
| 329 |
|
// ----------------------------------------------------- |
| 330 |
// Stats |
// Stats |
| 331 |
$form['signit']['stats'] = array( |
$form['signit']['stats'] = array( |
| 332 |
'#type' => 'fieldset', |
'#type' => 'fieldset', |
| 1608 |
|
|
| 1609 |
/** |
/** |
| 1610 |
* view the comments on this signit |
* view the comments on this signit |
| 1611 |
|
* @param $nid is a node id |
| 1612 |
*/ |
*/ |
| 1613 |
function signit_view_signit_comments($nid) { |
function signit_view_signit_comments($nid) { |
| 1614 |
$signit = signit_load_signit($nid); |
$signit = signit_load_signit($nid); |
| 1615 |
$node = node_load($nid); |
$node = node_load($nid); |
| 1616 |
|
|
| 1617 |
|
// set the bread crumb |
| 1618 |
|
drupal_set_breadcrumb(array( |
| 1619 |
|
l(t('Home'), ''), |
| 1620 |
|
l($node->title, 'node/'. $node->nid),) |
| 1621 |
|
); |
| 1622 |
|
|
| 1623 |
|
// set the title |
| 1624 |
|
drupal_set_title(t('%title Signatures', array('%title' => $node->title))); |
| 1625 |
|
|
| 1626 |
|
// get all the signatures |
| 1627 |
$signatures = signit_signatures_return($nid, $node->signit['signature_display_count'] ? $node->signit['signature_display_count'] : 20); |
$signatures = signit_signatures_return($nid, $node->signit['signature_display_count'] ? $node->signit['signature_display_count'] : 20); |
| 1628 |
if (user_access("administer signit")) { $delete = "Delete"; } |
|
| 1629 |
$header = array("Name", "Date", "Comment", $delete); |
// build the inital header |
| 1630 |
|
$header = array(t('Name'), t('Date')); |
| 1631 |
|
|
| 1632 |
|
// are comments allowed on this? |
| 1633 |
|
if ($signit['comment_allow']) { $header[] = t('Comment'); } |
| 1634 |
|
|
| 1635 |
|
// fetch each signature |
| 1636 |
while ($signature = db_fetch_array($signatures)) { |
while ($signature = db_fetch_array($signatures)) { |
| 1637 |
$row = array(); |
$row = array(); |
| 1638 |
$account = user_load(array("uid" => $signature['uid'])); // @ TODO hook this up to civicrm |
|
| 1639 |
|
// default data |
| 1640 |
|
$account = user_load(array('uid' => $signature['uid'])); // @ TODO hook this up to civicrm |
| 1641 |
$row['Name'] = $account->name? l($account->name, "user/". $account->uid): $signature['firstname'] ." ". $signature['lastname']; |
$row['Name'] = $account->name? l($account->name, "user/". $account->uid): $signature['firstname'] ." ". $signature['lastname']; |
| 1642 |
$row['Date'] = date("m-d-y", $signature['created']); |
$row['Date'] = date("m-d-y", $signature['created']); |
| 1643 |
$row['Comment'] = check_markup($signature['personal_comment']); |
|
| 1644 |
if ($delete) { |
// comments on this? |
| 1645 |
$row['Delete'] = l("Delete", "admin/signit/delete/". $signature['nid'] ."/". $signature['sid']); |
if ($signit['comment_allow']) { |
| 1646 |
} |
$row['Comment'] = check_markup($signature['personal_comment']); |
| 1647 |
|
} |
| 1648 |
|
|
| 1649 |
|
// we ned the unserialized data for signit_hooks |
| 1650 |
|
$signature['data'] = unserialize($signature['data']); |
| 1651 |
|
|
| 1652 |
|
// allow signit modules to add data to the display |
| 1653 |
|
$data = signit_extend('signit_user', 'view', $signature, $signit); |
| 1654 |
|
|
| 1655 |
|
// get the names of the data coming in |
| 1656 |
|
foreach ($data as $item) { |
| 1657 |
|
// collect data for the header |
| 1658 |
|
$header[$item['#title']] = $item['#title']; |
| 1659 |
|
// build the row |
| 1660 |
|
$row[$item['#title']] = $item['#value']; |
| 1661 |
|
} |
| 1662 |
|
|
| 1663 |
|
// last thing is the delete function |
| 1664 |
|
if (user_access("administer signit")) { |
| 1665 |
|
$row['Delete'] = l("Delete", "admin/signit/delete/". $signature['nid'] ."/". $signature['sid'], null, 'destination='. $_GET['q'] ); |
| 1666 |
|
} |
| 1667 |
|
|
| 1668 |
$rows[] = $row; |
$rows[] = $row; |
| 1669 |
} |
} |
| 1670 |
|
|
| 1671 |
|
if (user_access("administer signit")) {$header[] = t('Delete'); } |
| 1672 |
|
|
| 1673 |
|
|
| 1674 |
$output .= theme("signit_display_message", $node); |
$output .= theme("signit_display_message", $node); |
| 1675 |
$output .= theme("table", $header, $rows); |
$output .= theme("table", $header, $rows); |
| 1676 |
$output .= theme("pager"); |
$output .= theme("pager"); |
| 1677 |
return $output; |
return $output; |
| 1678 |
} |
} |
| 1679 |
|
|
|
|
|
| 1680 |
/** |
/** |
| 1681 |
* view the signatures on this signit |
* view the signatures on this signit |
| 1682 |
*/ |
*/ |
| 1734 |
|
|
| 1735 |
|
|
| 1736 |
|
|
|
|
|
| 1737 |
/* **************************************************** */ |
/* **************************************************** */ |
| 1738 |
/* MAIL FUNCTIONS */ |
/* MAIL FUNCTIONS */ |
| 1739 |
/* **************************************************** */ |
/* **************************************************** */ |
| 1841 |
$count = signit_count_signatures($node->nid) + $node->signit['padding']; |
$count = signit_count_signatures($node->nid) + $node->signit['padding']; |
| 1842 |
|
|
| 1843 |
if ($node->signit['statistics']) { |
if ($node->signit['statistics']) { |
| 1844 |
$output = t("!count people have signed this node. ", array("!count" => $count)); |
$output = t('!count people have signed this node. ', array('!count' => $count)); |
| 1845 |
$output .= t("Our goal is !goal. ", array("!goal" => $node->signit['goal']) ); |
$output .= t('Our goal is !goal. ', array('!goal' => $node->signit['goal']) ); |
| 1846 |
if (user_access("view signature comments")) { |
if (user_access('view signature comments')) { |
| 1847 |
$output .= l("View all signature comments", "signit/view/" . $node->nid); |
$output .= l(t('View all signatures'), "signit/view/" . $node->nid); |
| 1848 |
} |
} |
| 1849 |
} |
} |
| 1850 |
return $output; |
return $output; |
| 1875 |
|
|
| 1876 |
if (! $control) { |
if (! $control) { |
| 1877 |
$control = 1; |
$control = 1; |
| 1878 |
drupal_set_message(t("You have already signed this. Thanks for participating!")); |
drupal_set_message(t('You have signed this. Thanks for participating!')); |
| 1879 |
$output = theme('signit_display_message', $node->signit); |
$output = theme('signit_display_message', $node->signit); |
| 1880 |
return $output; |
return $output; |
| 1881 |
} |
} |