" . t('Links Module') . "
" . t('This module allows you to maintain a database of links') . "
"; case 'links': return variable_get('linksdb_message', t('A selection of useful links')); } } function linksdb_perm() { return array('manage links', 'suggest links', 'moderate links'); } function linksdb_menu($may_cache) { $items = array(); $items[] = array( 'path' => 'admin/settings/linkdb', 'title' => t('LinksDB'), 'description' => t('Manages the database of links.'), 'callback' => 'drupal_get_form', 'callback arguments' => array('linksdb_settings'), 'access' => user_access('administer site configuration'), 'type' => MENU_NORMAL_ITEM, // optional ); $items[] = array( 'path' => 'links', 'title' => t('Links'), 'callback' => 'linksdb_display', 'access' => user_access('access content'), ); $items[] = array( 'path' => 'links/submit', 'title' => t('suggest a link'), 'callback' => 'linksdb_suggest', 'access' => user_access('suggest links'), ); $items[] = array( 'path' => 'links/view/all', 'callback' => 'linksdb_show_all', 'type' => MENU_CALLBACK, 'access' => user_access('access content'), ); $items[] = array( 'path' => 'links/view', 'title' => t('view'), 'callback' => 'linksdb_display', 'type' => MENU_DEFAULT_LOCAL_TASK, 'access' => user_access('access content'), 'weight' => -10, ); $items[] = array( 'path' => 'links/edit', 'title' => t('add link'), 'callback' => 'linksdb_edit', 'type' => MENU_LOCAL_TASK, 'access' => user_access('manage links'), ); $items[] = array( 'path' => 'links/import', 'title' => t('import from text'), 'callback' => 'linksdb_import', 'type' => MENU_LOCAL_TASK, 'access' => user_access('manage links'), ); $items[] = array( 'path' => 'links/category', 'title' => t('categories'), 'callback' => 'linksdb_categories', 'type' => MENU_LOCAL_TASK, 'access' => user_access('manage links'), ); $items[] = array( 'path' => 'links/moderate', 'title' => t('moderate'), 'callback' => 'linksdb_moderate', 'type' => MENU_LOCAL_TASK, 'access' => user_access('moderate links'), ); $items[] = array( 'path' => 'links/deadlinks', 'title' => t('dead links'), 'callback' => 'linksdb_deadlinks', 'type' => MENU_LOCAL_TASK, 'access' => user_access('manage links'), ); $items[] = array( 'path' => 'links/category/edit', 'callback' => 'linksdb_categories_edit', 'type' => MENU_CALLBACK, 'access' => user_access('manage links'), ); $items[] = array( 'path' => 'links/refer', 'callback' => 'linksdb_refer', 'type' => MENU_CALLBACK, 'access' => TRUE, ); $items[] = array( 'path' => 'links/report', 'callback' => 'linksdb_report', 'type' => MENU_CALLBACK, 'access' => TRUE, ); return $items; } function linksdb_report($id=NULL) { return drupal_get_form('linksdb_report_form', $id, 'linksdb_report'); } function linksdb_report_form($id=NULL) { $form = array(); $form['id'] = array('#type' => 'hidden', '#value' => $id); $form['reason'] = array( '#type' => 'textfield', '#title' => t('Reason'), '#description' => t('Please be clear and consise with your reason why you think this link is dead'), ); $form['submit'] = array( '#type' => 'submit', '#value' => t('Submit report'), ); return $form; } function linksdb_report_submit($fid, $v) { global $user; db_query("UPDATE {links_links} SET dead=1, deadcomment='%s', deadby=%d WHERE id=%d;", $v['reason'], $user->uid, $v['id']); drupal_set_message(t("Thank you for your feedback. The site administrators will check this link soon and take the appropriate action.")); return "links"; } function linksdb_refer($id=NULL) { db_query("UPDATE {links_links} SET clicks=clicks+1 WHERE id=%d;", $id); $link = db_fetch_object(db_query("SELECT url FROM {links_links} WHERE id=%d;", $id)); header("Location: $link->url"); } function linksdb_deadlinks() { return drupal_get_form('linksdb_deadlinks_form', 'linksdb_moderate'); } function linksdb_deadlinks_form() { $form = array(); $c = array(); $cl = db_query("SELECT name, id FROM {links_categories};"); while($cat = db_fetch_object($cl)) { $c[$cat->id] = $cat->name; } $c[0] = "<" . t('Root') . ">"; $ll = db_query("SELECT * FROM {links_links} WHERE dead=1 ORDER BY name;"); while($link = db_fetch_object($ll)) { if(variable_get('linksdb_show_report', 1)==1) { if($link->dead==1) { $link->description .= "| Link | Category | Activate |
|---|---|---|
| ', ); $form["link$link->id"] = array( '#type' => 'link', '#title' => $link->name, '#description' => $link->description, '#url' => $link->url, '#click' => "links/refer/$link->id", '#edit' => "links/edit/$link->id", '#newwindow' => $link->newwindow, '#clicks' => $link->clicks, ); $form["mid$link->id"] = array( '#type' => 'markup', '#value' => ' | ' . $c[$link->category] . " | ", ); $form["activate$link->id"] = array( '#type' => 'checkbox', '#default_value' => 0, ); $form["right$link->id"] = array( '#type' => 'markup', '#value' => ' |
| No links to moderate. | ||