|
@@ -12,7 +12,7 @@
|
|
* @package QBF
|
|
* @package QBF
|
|
*/
|
|
*/
|
|
|
|
|
|
-// $Id: qbf.module,v 1.9.2.3 2008-10-03 17:40:40 marand Exp $
|
|
|
|
|
|
+// $Id: qbf.module,v 1.9.2.4 2008-10-04 17:01:32 marand Exp $
|
|
|
|
|
|
/**
|
|
/**
|
|
* Saved error reporting level.
|
|
* Saved error reporting level.
|
|
@@ -60,6 +60,10 @@ define('QBF_PATH_MAIN', 'qbf');
|
|
* @ingroup paths
|
|
* @ingroup paths
|
|
*/
|
|
*/
|
|
define('QBF_PATH_AC', 'qbf/ac');
|
|
define('QBF_PATH_AC', 'qbf/ac');
|
|
|
|
+/**
|
|
|
|
+ * The path to the QBF settings page
|
|
|
|
+ */
|
|
|
|
+define('QBF_PATH_SETTINGS', 'admin/settings/qbf');
|
|
|
|
|
|
/**
|
|
/**
|
|
* Authorize use of QBF searches
|
|
* Authorize use of QBF searches
|
|
@@ -474,6 +478,7 @@ function qbf_load($qid) {
|
|
else
|
|
else
|
|
{
|
|
{
|
|
$ret->query = unserialize($ret->query);
|
|
$ret->query = unserialize($ret->query);
|
|
|
|
+ //dsm($ret);
|
|
}
|
|
}
|
|
return $ret;
|
|
return $ret;
|
|
}
|
|
}
|
|
@@ -551,10 +556,28 @@ function _qbf_save($form_id, $form_values) {
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
|
|
+ $arRemoved = array
|
|
|
|
+ (
|
|
|
|
+ 'form_id',
|
|
|
|
+ 'form_token',
|
|
|
|
+ 'form_build_id',
|
|
|
|
+ 'op',
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ $arValues = array();
|
|
|
|
+ foreach ($form_values as $key => $value)
|
|
|
|
+ {
|
|
|
|
+ if (empty($value) || in_array($key, $arRemoved))
|
|
|
|
+ {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ $arValues[$key] = $value;
|
|
|
|
+ }
|
|
|
|
+dsm($arValues);
|
|
$sq = 'INSERT INTO {%s} (qid, uid, name, query) '
|
|
$sq = 'INSERT INTO {%s} (qid, uid, name, query) '
|
|
."VALUES (%d, %d, '%s', '%s' ) ";
|
|
."VALUES (%d, %d, '%s', '%s' ) ";
|
|
$ret = db_next_id('qbf_qid');
|
|
$ret = db_next_id('qbf_qid');
|
|
- $q = db_query($sq, QBF_TABLE_NAME, $ret, $user->uid, $form_values['save-name'], serialize($form_values));
|
|
|
|
|
|
+ $q = db_query($sq, QBF_TABLE_NAME, $ret, $user->uid, $form_values['save-name'], serialize($arValues));
|
|
}
|
|
}
|
|
|
|
|
|
return $ret;
|
|
return $ret;
|
|
@@ -571,6 +594,15 @@ function qbf_menu($may_cache) {
|
|
$items = array();
|
|
$items = array();
|
|
if ($may_cache)
|
|
if ($may_cache)
|
|
{
|
|
{
|
|
|
|
+ $items[] = array
|
|
|
|
+ (
|
|
|
|
+ 'path' => QBF_PATH_SETTINGS,
|
|
|
|
+ 'title' => t('Query-By-Form'),
|
|
|
|
+ 'access' => user_access(QBF_PERM_ADMIN),
|
|
|
|
+ 'callback' => 'drupal_get_form',
|
|
|
|
+ 'callback arguments' => 'qbf_admin_settings',
|
|
|
|
+ 'type' => MENU_NORMAL_ITEM,
|
|
|
|
+ );
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
@@ -609,8 +641,8 @@ function _qbf_query_delete($qid) {
|
|
$link = l($qid, QBF_PATH_MAIN . '/' . $qid . '/delete');
|
|
$link = l($qid, QBF_PATH_MAIN . '/' . $qid . '/delete');
|
|
|
|
|
|
// @todo Check safety, this seem dangerous
|
|
// @todo Check safety, this seem dangerous
|
|
- $usArgs = func_get_args();
|
|
|
|
- $path = implode('/', array_slice($usArgs, 1));
|
|
|
|
|
|
+ //$usArgs = func_get_args();
|
|
|
|
+ //$path = implode('/', array_slice($usArgs, 1));
|
|
|
|
|
|
// only valid if valid query, and owner or admin
|
|
// only valid if valid query, and owner or admin
|
|
if (isset($query->uid) && (($query->uid == $user->uid) || user_access(QBF_PERM_ADMIN)))
|
|
if (isset($query->uid) && (($query->uid == $user->uid) || user_access(QBF_PERM_ADMIN)))
|
|
@@ -624,6 +656,16 @@ function _qbf_query_delete($qid) {
|
|
));
|
|
));
|
|
drupal_set_message($message, 'status');
|
|
drupal_set_message($message, 'status');
|
|
watchdog('qbf', $message, WATCHDOG_NOTICE, $link);
|
|
watchdog('qbf', $message, WATCHDOG_NOTICE, $link);
|
|
|
|
+ if (variable_get(QBF_VAR_NOTIFY_DELETE, QBF_DEF_NOTIFY_DELETE) && $query->uid != $user->uid)
|
|
|
|
+ {
|
|
|
|
+ $ret = drupal_mail(__FUNCTION__, $user->mail, $message, $message, $user->mail);
|
|
|
|
+ $account = user_load(array('uid' => $query->uid));
|
|
|
|
+ drupal_set_message(t('User !link has been informed', array
|
|
|
|
+ (
|
|
|
|
+ '!link' => l($account->name, 'user/' . $query->uid),
|
|
|
|
+ )));
|
|
|
|
+ dsm($ret);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
@@ -634,7 +676,19 @@ function _qbf_query_delete($qid) {
|
|
drupal_set_message($message, 'error');
|
|
drupal_set_message($message, 'error');
|
|
watchdog('qbf', $message, WATCHDOG_ERROR, $link);
|
|
watchdog('qbf', $message, WATCHDOG_ERROR, $link);
|
|
}
|
|
}
|
|
- drupal_goto($path);
|
|
|
|
|
|
+ drupal_goto();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+function qbf_admin_settings() {
|
|
|
|
+
|
|
|
|
+ $form = array();
|
|
|
|
+ $form[QBF_VAR_NOTIFY_DELETE] = array
|
|
|
|
+ (
|
|
|
|
+ '#type' => 'checkbox',
|
|
|
|
+ '#default_value' => variable_get(QBF_VAR_NOTIFY_DELETE, QBF_DEF_NOTIFY_DELETE),
|
|
|
|
+ '#title' => t('Notify users when one of their saved searches has been deleted'),
|
|
|
|
+ );
|
|
|
|
+ return system_settings_form($form);
|
|
}
|
|
}
|
|
|
|
|
|
error_reporting($_qbf_er);
|
|
error_reporting($_qbf_er);
|