コード例 #1
0
 /**
  * Use ajax for run, since we're launching in the background.
  */
 public function build_operations_alter($job, &$allowed_operations)
 {
     if (empty($allowed_operations['run'])) {
         if (in_array('killable', $job->hook['tags']) && !$job->peekSignal('kill')) {
             $allowed_operations['kill'] = array('title' => t('Kill'), 'href' => 'admin/config/system/cron/jobs/list/' . $job->name . '/signal/' . $this->type . '/' . $this->name . '/kill', 'attributes' => array('class' => array('use-ajax')), 'query' => array('token' => drupal_get_token('signal')));
         }
     }
 }
コード例 #2
0
 /**
  * Use ajax for run, since we're launching in the background.
  */
 public function build_operations_alter($job, &$allowed_operations)
 {
     if (!empty($allowed_operations['run'])) {
         $allowed_operations['run']['attributes'] = array('class' => array('use-ajax'));
     } else {
         $settings = $job->getSettings('launcher');
         if ($settings['daemonize'] && !$job->peekSignal('end_daemonize')) {
             unset($allowed_operations['kill']);
             $allowed_operations['end_daemonize'] = array('title' => t('Kill daemon'), 'href' => 'admin/config/system/cron/jobs/list/' . $job->name . '/signal/' . $this->type . '/' . $this->name . '/end_daemonize', 'attributes' => array('class' => array('use-ajax')), 'query' => array('token' => drupal_get_token('signal')));
         }
     }
 }
コード例 #3
0
/**
 * Presets form.
 */
function spaces_preset_list($form, &$form_state, $export_ui)
{
    // Some setup for the spaces_preset_name_validation
    $form_state['plugin'] = $export_ui->plugin;
    $form_state['object'] =& $export_ui;
    $types = array();
    foreach (spaces_types(TRUE) as $type => $info) {
        $types[$type] = $info['title'];
    }
    $form['new'] = array('#tree' => FALSE, '#theme' => 'spaces_preset_list_new', 'space_type' => array('#title' => t('Type'), '#type' => 'select', '#options' => $types), 'name' => array('#type' => 'textfield', '#maxlength' => 64, '#size' => 32, '#title' => t('Machine ID'), '#element_validate' => array('spaces_preset_name_validate')), 'title' => array('#type' => 'textfield', '#maxlength' => 64, '#size' => 32, '#title' => t('Name')), 'submit' => array('#type' => 'submit', '#value' => t('Create new preset'), '#submit' => array('spaces_preset_list_new')));
    // Generate preset options.
    foreach ($types as $type => $title) {
        module_load_include('inc', 'spaces', 'spaces.admin');
        $presets = spaces_preset_load(NULL, $type, TRUE);
        ksort($presets);
        $form[$type] = spaces_preset_form($presets, $type, TRUE);
        $form[$type]['#title'] = t('@spacetype presets', array('@spacetype' => $title));
        $form[$type]['#description'] = t('Select a default preset for each new @spacetype.', array('@spacetype' => $title));
        $plugin = $export_ui->plugin;
        foreach ($presets as $name => $item) {
            // Note: Creating this list seems a little clumsy, but can't think of
            // better ways to do this.
            $allowed_operations = drupal_map_assoc(array_keys($plugin['allowed operations']));
            $not_allowed_operations = array('import');
            if ($item->type == t('Normal')) {
                $not_allowed_operations[] = 'revert';
            } elseif ($item->type == t('Overridden')) {
                $not_allowed_operations[] = 'delete';
            } else {
                $not_allowed_operations[] = 'revert';
                $not_allowed_operations[] = 'delete';
            }
            $not_allowed_operations[] = empty($item->disabled) ? 'enable' : 'disable';
            foreach ($not_allowed_operations as $op) {
                // Remove the operations that are not allowed for the specific exportable.
                unset($allowed_operations[$op]);
            }
            $operations = array();
            foreach ($allowed_operations as $op) {
                $operations[$op] = array('title' => $plugin['allowed operations'][$op]['title'], 'href' => ctools_export_ui_plugin_menu_path($plugin, $op, $name));
                if (!empty($plugin['allowed operations'][$op]['token'])) {
                    $operations[$op]['query'] = array('token' => drupal_get_token($op));
                }
            }
            $form[$type]['storage'][$item->name] = array('#type' => 'markup', '#markup' => isset($item->disabled) && $item->disabled ? t('Disabled') : check_plain($item->type));
            $form[$type]['actions'][$item->name] = array('#type' => 'markup', '#markup' => theme('links', array('links' => $operations)));
            $form[$type]["spaces_preset_{$type}"][$name] = array();
        }
    }
    $form = system_settings_form($form);
    return $form;
}
コード例 #4
0
</th>
        <th style="width:45%;"><?php 
print t('Assigned To');
?>
</th>
        <th style="text-align:right;width:10%;"><?php 
print t('Operation');
?>
</th>
      </tr>
    </thead>

    <tbody>

<?php 
$sec_token = drupal_get_token('maestro_user');
if (is_array($queue)) {
    $i = 0;
    foreach ($queue as $task) {
        $classname = ++$i % 2 == 0 ? 'even' : 'odd';
        ?>
      <tr id="ot_row<?php 
        print $i;
        ?>
" class="<?php 
        print $classname;
        ?>
">
        <td style="vertical-align:top;"><?php 
        print $task->taskname;
        ?>
コード例 #5
0
ファイル: ajaxserver.php プロジェクト: dalia-m-elsayed/spica
function filedepot_dispatcher($action)
{
    global $user;
    $filedepot = filedepot_filedepot();
    $nexcloud = filedepot_nexcloud();
    module_load_include('php', 'filedepot', 'lib-theme');
    module_load_include('php', 'filedepot', 'lib-ajaxserver');
    module_load_include('php', 'filedepot', 'lib-common');
    if (function_exists('timer_start')) {
        timer_start('filedepot_timer');
    }
    firelogmsg("AJAX Server code executing - action: {$action}");
    switch ($action) {
        case 'archive':
            if (isset($_GET['checked_files']) && isset($_GET['checked_folders'])) {
                module_load_include('php', 'filedepot', 'filedepot_archiver.class');
                $checked_files = json_decode($_GET['checked_files'], TRUE);
                $checked_folders = json_decode($_GET['checked_folders'], TRUE);
                //print_r($checked_files);
                //die(1);
                $fa = new filedepot_archiver();
                $fa->createAndCleanArchiveDirectory();
                $fa->addCheckedObjectArrays($checked_files, $checked_folders);
                $fa->createArchive();
                $fa->close();
                $fa->download();
                return;
            } else {
                echo "Invalid Parameters";
                return;
            }
            break;
        case 'getfilelisting':
            $cid = intval($_POST['cid']);
            if ($cid > 0) {
                if (db_query("SELECT count(*) FROM {filedepot_categories} WHERE cid=:cid", array(':cid' => $cid))->fetchField() == 1) {
                    $filedepot->ajaxBackgroundMode = TRUE;
                }
            }
            $reportmode = check_plain($_POST['reportmode']);
            $filedepot->activeview = $reportmode;
            $filedepot->cid = $cid;
            ctools_include('object-cache');
            $cache = ctools_object_cache_set('filedepot', 'folder', $cid);
            $data = filedepotAjaxServer_getfilelisting();
            break;
        case 'getfolderlisting':
            $filedepot->ajaxBackgroundMode = TRUE;
            $cid = intval($_POST['cid']);
            $reportmode = check_plain($_POST['reportmode']);
            if ($cid > 0) {
                ctools_include('object-cache');
                $cache = ctools_object_cache_set('filedepot', 'folder', $cid);
                $filedepot->cid = $cid;
                $filedepot->activeview = $reportmode;
                $data = filedepotAjaxServer_getfilelisting();
                firelogmsg("Completed generating FileListing");
            } else {
                $data = array('retcode' => 500);
            }
            break;
        case 'getleftnavigation':
            $data = filedepotAjaxServer_generateLeftSideNavigation();
            break;
        case 'getmorefiledata':
            /** Need to use XML instead of JSON format for return data.
             * It's taking up to 1500ms to interpret (eval) the JSON data into an object in the client code
             * Parsing the XML is about 10ms
             */
            $cid = intval($_POST['cid']);
            $level = intval($_POST['level']);
            $foldernumber = check_plain($_POST['foldernumber']);
            $filedepot->activeview = 'getmoredata';
            $filedepot->cid = $cid;
            $filedepot->lastRenderedFolder = $cid;
            $retval = '<result>';
            $retval .= '<retcode>200</retcode>';
            $retval .= '<displayhtml>' . htmlspecialchars(nexdocsrv_generateFileListing($cid, $level, $foldernumber), ENT_QUOTES, 'utf-8') . '</displayhtml>';
            $retval .= '</result>';
            firelogmsg("Completed generating AJAX return data - cid: {$cid}");
            break;
        case 'getmorefolderdata':
            /* Need to use XML instead of JSON format for return data.
               It's taking up to 1500ms to interpret (eval) the JSON data into an object in the client code
               Parsing the XML is about 10ms
               */
            $cid = intval($_POST['cid']);
            $level = intval($_POST['level']);
            // Need to remove the last part of the passed in foldernumber as it's the incremental file number
            // Which we recalculate in template_preprocess_filelisting()
            $x = explode('.', check_plain($_POST['foldernumber']));
            $x2 = array_pop($x);
            $foldernumber = implode('.', $x);
            $filedepot->activeview = 'getmorefolderdata';
            $filedepot->cid = $cid;
            $filedepot->lastRenderedFolder = $cid;
            $retval = '<result>';
            $retval .= '<retcode>200</retcode>';
            $retval .= '<displayhtml>' . htmlspecialchars(nexdocsrv_generateFileListing($cid, $level, $foldernumber), ENT_QUOTES, 'utf-8') . '</displayhtml>';
            $retval .= '</result>';
            firelogmsg("Completed generating AJAX return data - cid: {$cid}");
            break;
        case 'rendernewfilefolderoptions':
            $cid = intval($_POST['cid']);
            $data['displayhtml'] = theme('filedepot_newfiledialog_folderoptions', array('cid' => $cid));
            break;
        case 'rendernewfolderform':
            $cid = intval($_POST['cid']);
            $data['displayhtml'] = theme('filedepot_newfolderdialog', array('cid' => $cid));
            break;
        case 'createfolder':
            $node = (object) array('uid' => $user->uid, 'name' => $user->name, 'type' => 'filedepot_folder', 'title' => $_POST['catname'], 'parentfolder' => intval($_POST['catparent']), 'folderdesc' => $_POST['catdesc'], 'inherit' => intval($_POST['catinherit']));
            if ($node->parentfolder == 0 and !user_access('administer filedepot')) {
                $data['errmsg'] = t('Error creating Folder - invalid parent folder');
                $data['retcode'] = 500;
            } else {
                node_save($node);
                if ($node->nid) {
                    $data['displaycid'] = $filedepot->cid;
                    $data['retcode'] = 200;
                } else {
                    $data['errmsg'] = t('Error creating Folder');
                    $data['retcode'] = 500;
                }
            }
            break;
        case 'deletefolder':
            $data = array();
            $cid = intval($_POST['cid']);
            $token = isset($_POST['token']) ? $_POST['token'] : NULL;
            if ($token == NULL || !drupal_valid_token($token, FILEDEPOT_TOKEN_FOLDERMGMT)) {
                $data['retcode'] = 403;
                // Forbidden
            } else {
                $query = db_query("SELECT cid,pid,nid FROM {filedepot_categories} WHERE cid=:cid", array(':cid' => $cid));
                $A = $query->fetchAssoc();
                if ($cid > 0 and $A['cid'] = $cid) {
                    if ($filedepot->checkPermission($cid, 'admin')) {
                        node_delete($A['nid']);
                        $filedepot->cid = $A['pid'];
                        // Set the new active directory to the parent folder
                        $data['retcode'] = 200;
                        $data['activefolder'] = theme('filedepot_activefolder');
                        $data['displayhtml'] = filedepot_displayFolderListing($filedepot->cid);
                        $data = filedepotAjaxServer_generateLeftSideNavigation($data);
                    } else {
                        $data['retcode'] = 403;
                        // Forbidden
                    }
                } else {
                    $data['retcode'] = 404;
                    // Not Found
                }
            }
            break;
        case 'updatefolder':
            $token = isset($_POST['token']) ? $_POST['token'] : NULL;
            if ($token == NULL || !drupal_valid_token($token, FILEDEPOT_TOKEN_FOLDERMGMT)) {
                $data['retcode'] = 403;
                // Forbidden
            } else {
                $data = filedepotAjaxServer_updateFolder();
            }
            break;
        case 'setfolderorder':
            $cid = intval($_POST['cid']);
            $filedepot->cid = intval($_POST['listingcid']);
            $token = isset($_POST['ltoken']) ? $_POST['ltoken'] : NULL;
            if ($token == NULL || !drupal_valid_token($token, FILEDEPOT_TOKEN_LISTING)) {
                $data['retcode'] = 403;
                // Forbidden
            } else {
                if ($filedepot->checkPermission($cid, 'admin')) {
                    // Check and see if any subfolders don't yet have a order value - if so correct
                    $maxorder = 0;
                    $pid = db_query("SELECT pid FROM {filedepot_categories} WHERE cid=:cid", array(':cid' => $cid))->fetchField();
                    $maxquery = db_query_range("SELECT folderorder FROM {filedepot_categories} WHERE pid=:pid ORDER BY folderorder ASC", 0, 1, array(':pid' => $pid))->fetchField();
                    $next_folderorder = $maxorder + 10;
                    $query = db_query("SELECT cid FROM {filedepot_categories} WHERE pid=:pid AND folderorder = 0", array(':pid' => $pid));
                    while ($B = $query->fetchAssoc()) {
                        db_query("UPDATE {filedepot_categories} SET folderorder=:folderorder WHERE cid=:cid", array(':folderorder' => $next_folderorder, ':cid' => $B['cid']));
                        $next_folderorder += 10;
                    }
                    $itemquery = db_query("SELECT * FROM {filedepot_categories} WHERE cid=:cid", array(':cid' => $cid));
                    $retval = 0;
                    while ($A = $itemquery->fetchAssoc()) {
                        if ($_POST['direction'] == 'down') {
                            $sql = "SELECT folderorder FROM {filedepot_categories} WHERE pid=:pid ";
                            $sql .= "AND folderorder > :folderorder ORDER BY folderorder ASC ";
                            $nextorder = db_query_range($sql, 0, 1, array(':pid' => $A['pid'], ':folderorder' => $A['folderorder']))->fetchField();
                            if ($nextorder > $A['folderorder']) {
                                $folderorder = $nextorder + 5;
                            } else {
                                $folderorder = $A['folderorder'];
                            }
                            db_query("UPDATE {filedepot_categories} SET folderorder=:folderorder WHERE cid=:cid", array(':folderorder' => $folderorder, ':cid' => $cid));
                        } elseif ($_POST['direction'] == 'up') {
                            $sql = "SELECT folderorder FROM {filedepot_categories} WHERE pid=:pid ";
                            $sql .= "AND folderorder < :folderorder ORDER BY folderorder DESC ";
                            $nextorder = db_query_range($sql, 0, 1, array(':pid' => $A['pid'], ':folderorder' => $A['folderorder']))->fetchField();
                            $folderorder = $nextorder - 5;
                            if ($folderorder <= 0) {
                                $folderorder = 0;
                            }
                            db_query("UPDATE {filedepot_categories} SET folderorder=:folderorder WHERE cid=:cid", array(':folderorder' => $folderorder, ':cid' => $cid));
                        }
                    }
                    /* Re-order any folders that may have just been moved */
                    $query = db_query("SELECT cid,folderorder from {filedepot_categories} WHERE pid=:pid ORDER BY folderorder", array(':pid' => $pid));
                    $folderorder = 10;
                    $stepnumber = 10;
                    while ($A = $query->fetchAssoc()) {
                        if ($folderorder != $A['folderOrder']) {
                            db_query("UPDATE {filedepot_categories} SET folderorder=:folderorder WHERE cid=:cid", array(':folderorder' => $folderorder, ':cid' => $A['cid']));
                        }
                        $folderorder += $stepnumber;
                    }
                    $data['retcode'] = 200;
                    $data['displayhtml'] = filedepot_displayFolderListing($filedepot->cid);
                } else {
                    $data['retcode'] = 400;
                }
            }
            break;
        case 'updatefoldersettings':
            $cid = intval($_POST['cid']);
            $notifyadd = intval($_POST['fileadded_notify']);
            $notifychange = intval($_POST['filechanged_notify']);
            if ($user->uid > 0 and $cid >= 1) {
                // Update the personal folder notifications for user
                if (db_query("SELECT count(*) FROM {filedepot_notifications} WHERE cid=:cid AND uid=:uid", array(':cid' => $cid, ':uid' => $user->uid))->fetchField() == 0) {
                    $sql = "INSERT INTO {filedepot_notifications} (cid,cid_newfiles,cid_changes,uid,date) ";
                    $sql .= "VALUES (:cid,:notifyadd,:notifychange,:uid,:time)";
                    db_query($sql, array(':cid' => $cid, ':notifyadd' => $notifyadd, ':notifychange' => $notifychange, ':uid' => $user->uid, ':time' => time()));
                } else {
                    $sql = "UPDATE {filedepot_notifications} set cid_newfiles=:notifyadd, ";
                    $sql .= "cid_changes=:notifychange, date=:time ";
                    $sql .= "WHERE uid=:uid and cid=:cid";
                    db_query($sql, array(':notifyadd' => $notifyadd, ':notifychange' => $notifychange, ':time' => time(), ':uid' => $user->uid, ':cid' => $cid));
                }
                $data['retcode'] = 200;
                $data['displayhtml'] = filedepot_displayFolderListing($filedepot->cid);
            } else {
                $data['retcode'] = 500;
            }
            break;
        case 'loadfiledetails':
            $data = filedepotAjaxServer_loadFileDetails();
            break;
        case 'refreshfiledetails':
            $reportmode = check_plain($_POST['reportmode']);
            $fid = intval($_POST['id']);
            $cid = db_query("SELECT cid FROM {filedepot_files} WHERE fid=:fid", array(':fid' => $fid))->fetchField();
            if ($filedepot->checkPermission($cid, 'view')) {
                $data['retcode'] = 200;
                $data['fid'] = $fid;
                $data['displayhtml'] = theme('filedepot_filedetail', array('fid' => $fid, 'reportmode' => $reportmode));
            } else {
                $data['retcode'] = 400;
                $data['error'] = t('Invalid access');
            }
            break;
        case 'updatenote':
            $fid = intval($_POST['fid']);
            $version = intval($_POST['version']);
            $note = check_plain($_POST['note']);
            $reportmode = check_plain($_POST['reportmode']);
            $token = isset($_POST['ftoken']) ? $_POST['ftoken'] : NULL;
            if ($token == NULL || !drupal_valid_token($token, FILEDEPOT_TOKEN_FILEDETAILS)) {
                $data['retcode'] = 403;
                // forbidden
            } elseif ($fid > 0) {
                db_query("UPDATE {filedepot_fileversions} SET notes=:notes WHERE fid=:fid and version=:version", array(':notes' => $note, ':fid' => $fid, ':version' => $version));
                $data['retcode'] = 200;
                $data['fid'] = $fid;
                $data['displayhtml'] = theme('filedepot_filedetail', array('fid' => $fid, 'reportmode' => $reportmode));
            } else {
                $data['retcode'] = 400;
            }
            break;
        case 'getfolderperms':
            $cid = intval($_POST['cid']);
            if ($cid > 0) {
                if ($filedepot->ogenabled) {
                    $data['html'] = theme('filedepot_folderperms_ogenabled', array('cid' => $cid, 'token' => drupal_get_token(FILEDEPOT_TOKEN_FOLDERPERMS)));
                } else {
                    $data['html'] = theme('filedepot_folderperms', array('cid' => $cid, 'token' => drupal_get_token(FILEDEPOT_TOKEN_FOLDERPERMS)));
                }
                $data['retcode'] = 200;
            } else {
                $data['retcode'] = 404;
            }
            break;
        case 'delfolderperms':
            $id = intval($_POST['id']);
            $token = isset($_POST['token']) ? $_POST['token'] : NULL;
            if ($token == NULL || !drupal_valid_token($token, FILEDEPOT_TOKEN_FOLDERPERMS)) {
                $data['retcode'] = 403;
                // forbidden
            } elseif ($id > 0) {
                $query = db_query("SELECT catid, permtype, permid FROM  {filedepot_access} WHERE accid=:accid", array(':accid' => $id));
                $A = $query->fetchAssoc();
                if ($filedepot->checkPermission($A['catid'], 'admin')) {
                    db_delete('filedepot_access')->condition('accid', $id)->execute();
                    db_update('filedepot_usersettings')->fields(array('allowable_view_folders' => ''))->execute();
                    // For this folder - I need to update the access metrics now that a permission has been removed
                    $nexcloud->update_accessmetrics($A['catid']);
                    if ($filedepot->ogenabled) {
                        $data['html'] = theme('filedepot_folderperms_ogenabled', array('cid' => $A['catid'], 'token' => drupal_get_token(FILEDEPOT_TOKEN_FOLDERPERMS)));
                    } else {
                        $data['html'] = theme('filedepot_folderperms', array('cid' => $A['catid'], 'token' => drupal_get_token(FILEDEPOT_TOKEN_FOLDERPERMS)));
                    }
                    $data['retcode'] = 200;
                } else {
                    $data['retcode'] = 403;
                    // Forbidden
                }
            } else {
                $data['retcode'] = 404;
                // Not Found
            }
            break;
        case 'addfolderperm':
            $cid = intval($_POST['catid']);
            $token = isset($_POST['token']) ? $_POST['token'] : NULL;
            if (!isset($_POST['cb_access'])) {
                $data['retcode'] = 204;
                // No permission options selected - return 'No content' statuscode
            } elseif ($token == NULL || !drupal_valid_token($token, FILEDEPOT_TOKEN_FOLDERPERMS)) {
                $data['retcode'] = 403;
                // forbidden
            } elseif ($filedepot->updatePerms($cid, $_POST['cb_access'], $_POST['selusers'], $_POST['selgroups'], $_POST['selroles'])) {
                if (is_array($_POST['selroles']) and count($_POST['selroles']) > 0) {
                    foreach ($_POST['selroles'] as $roleid) {
                        $roleid = intval($roleid);
                        if ($roleid > 0) {
                            $nexcloud->update_accessmetrics($cid);
                        }
                    }
                }
                if ($filedepot->ogenabled) {
                    if (is_array($_POST['selgroups']) and count($_POST['selgroups']) > 0) {
                        foreach ($_POST['selgroups'] as $groupid) {
                            $groupid = intval($groupid);
                            if ($groupid > 0) {
                                $nexcloud->update_accessmetrics($cid);
                            }
                        }
                    }
                    $data['html'] = theme('filedepot_folderperms_ogenabled', array('cid' => $cid, 'token' => drupal_get_token(FILEDEPOT_TOKEN_FOLDERPERMS)));
                } else {
                    $data['html'] = theme('filedepot_folderperms', array('cid' => $cid, 'token' => drupal_get_token(FILEDEPOT_TOKEN_FOLDERPERMS)));
                }
                $data['retcode'] = 200;
            } else {
                $data['retcode'] = 403;
                // Forbidden
            }
            break;
        case 'updatefile':
            $fid = intval($_POST['id']);
            $folder_id = intval($_POST['folder']);
            $version = intval($_POST['version']);
            $filetitle = $_POST['filetitle'];
            $description = $_POST['description'];
            $vernote = $_POST['version_note'];
            $approved = check_plain($_POST['approved']);
            $tags = $_POST['tags'];
            $data = array();
            $data['tagerror'] = '';
            $data['errmsg'] = '';
            $token = isset($_POST['ftoken']) ? $_POST['ftoken'] : NULL;
            if ($token == NULL || !drupal_valid_token($token, FILEDEPOT_TOKEN_FILEDETAILS)) {
                $data['retcode'] = 403;
                // forbidden
                $data['errmsg'] = t('Invalid request');
            } elseif ($_POST['cid'] == 'incoming' and $fid > 0) {
                $filemoved = FALSE;
                $sql = "UPDATE {filedepot_import_queue} SET orig_filename=:filename, description=:description,";
                $sql .= "version_note=:notes WHERE id=:fid";
                db_query($sql, array(':filename' => $filetitle, ':description' => $description, ':notes' => $vernote, ':fid' => $fid));
                $data['retcode'] = 200;
                if ($folder_id > 0 and $filedepot->moveIncomingFile($fid, $folder_id)) {
                    $filemoved = TRUE;
                    $filedepot->activeview = 'incoming';
                    $data = filedepotAjaxServer_generateLeftSideNavigation($data);
                    $data['displayhtml'] = filedepot_displayFolderListing();
                }
            } elseif ($fid > 0) {
                $filemoved = FALSE;
                if ($approved == 0) {
                    $sql = "UPDATE {filedepot_filesubmissions} SET title=:title, description=:description,";
                    $sql .= "version_note=:notes, cid=:cid, tags=:tags WHERE id=:fid;";
                    db_query($sql, array(':title' => $filetitle, ':description' => $description, ':notes' => $vernote, ':cid' => $folder_id, ':tags' => $tags, ':fid' => $fid));
                    $data['cid'] = $folder_id;
                    $data['tags'] = '';
                } else {
                    $query = db_query("SELECT fname,cid,version,submitter FROM {filedepot_files} WHERE fid=:fid", array(':fid' => $fid));
                    list($fname, $cid, $current_version, $submitter) = array_values($query->fetchAssoc());
                    // Allow updating the category, title, description and image for the current version and primary file record
                    if ($version == $current_version) {
                        db_query("UPDATE {filedepot_files} SET title=:title,description=:desc,date=:time WHERE fid=:fid", array(':title' => $filetitle, ':desc' => $description, ':time' => time(), ':fid' => $fid));
                        // Test if user has selected a different directory and if they have perms then move else return FALSE;
                        if ($folder_id > 0) {
                            $newcid = $folder_id;
                            if ($cid != $newcid) {
                                $filemoved = $filedepot->moveFile($fid, $newcid);
                                if ($filemoved == FALSE) {
                                    $data['errmsg'] = t('Error moving file');
                                }
                            }
                            $data['cid'] = $newcid;
                        } else {
                            $data['cid'] = $cid;
                        }
                        unset($_POST['tags']);
                        // Format tags will check this to format tags in case we are doing a search which we are not in this case.
                        $data['tags'] = filedepot_formatfiletags($tags);
                    }
                    db_query("UPDATE {filedepot_fileversions} SET notes=:notes WHERE fid=:fid and version=:version", array(':notes' => $vernote, ':fid' => $fid, ':version' => $version));
                    // Update the file tags if role or group permission set -- we don't support tag access perms at the user level.
                    if ($filedepot->checkPermission($folder_id, 'view', 0, FALSE)) {
                        if ($filedepot->checkPermission($folder_id, 'admin', 0, FALSE) or $user->uid == $submitter) {
                            $admin = TRUE;
                        } else {
                            $admin = FALSE;
                        }
                        if (!$nexcloud->update_tags($fid, $tags, $admin)) {
                            $data['tagerror'] = t('Tags not added - Group or Role assigned view perms required');
                            $data['tags'] = '';
                        }
                    } else {
                        $data['tagerror'] = t('Problem adding or updating tags');
                        $data['tags'] = '';
                    }
                }
                $data['retcode'] = 200;
                $data['tagcloud'] = theme('filedepot_tagcloud');
            } else {
                $data['retcode'] = 500;
                $data['errmsg'] = t('Invalid File');
            }
            $data['description'] = nl2br(filter_xss($description));
            $data['fid'] = $fid;
            $data['filename'] = filter_xss($filetitle);
            $data['filemoved'] = $filemoved;
            break;
        case 'deletefile':
            $fid = intval($_POST['fid']);
            $token = isset($_POST['ftoken']) ? $_POST['ftoken'] : NULL;
            if ($token == NULL || !drupal_valid_token($token, FILEDEPOT_TOKEN_FILEDETAILS)) {
                $data['retcode'] = 403;
                // forbidden
            } elseif ($user->uid > 0 and $fid > 0) {
                $data = filedepotAjaxServer_deleteFile($fid);
            } else {
                $data['retcode'] = 500;
            }
            break;
        case 'deletecheckedfiles':
            $token = isset($_POST['ltoken']) ? $_POST['ltoken'] : NULL;
            if ($token == NULL || !drupal_valid_token($token, FILEDEPOT_TOKEN_LISTING)) {
                $data['retcode'] = 403;
                // forbidden
            } elseif ($user->uid > 0) {
                $data = filedepotAjaxServer_deleteCheckedFiles();
            } else {
                $data['retcode'] = 500;
            }
            break;
        case 'deleteversion':
            $fid = intval($_POST['fid']);
            $version = intval($_POST['version']);
            $reportmode = check_plain($_POST['reportmode']);
            $token = isset($_POST['ftoken']) ? $_POST['ftoken'] : NULL;
            if ($token == NULL || !drupal_valid_token($token, FILEDEPOT_TOKEN_FILEDETAILS)) {
                $data['retcode'] = 403;
                // forbidden
            } elseif ($fid > 0 and $version > 0) {
                if ($filedepot->deleteVersion($fid, $version)) {
                    $data['retcode'] = 200;
                    $data['fid'] = $fid;
                    $data['displayhtml'] = theme('filedepot_filedetail', array('fid' => $fid, 'reportmode' => $reportmode));
                } else {
                    $data['retcode'] = 400;
                }
            } else {
                $data['retcode'] = 400;
            }
            break;
        case 'togglefavorite':
            $id = intval($_POST['id']);
            $token = isset($_POST['ltoken']) ? $_POST['ltoken'] : NULL;
            if ($token == NULL || !drupal_valid_token($token, FILEDEPOT_TOKEN_LISTING)) {
                $data['retcode'] = 403;
                // forbidden
            } elseif ($user->uid > 0 and $id >= 1) {
                if (db_query("SELECT count(fid) FROM {filedepot_favorites} WHERE uid=:uid AND fid=:fid", array(':uid' => $user->uid, ':fid' => $id))->fetchField() > 0) {
                    $data['favimgsrc'] = base_path() . drupal_get_path('module', 'filedepot') . '/css/images/' . $filedepot->getFileIcon('favorite-off');
                    db_query("DELETE FROM {filedepot_favorites} WHERE uid=:uid AND fid=:fid", array(':uid' => $user->uid, ':fid' => $id));
                } else {
                    $data['favimgsrc'] = base_path() . drupal_get_path('module', 'filedepot') . '/css/images/' . $filedepot->getFileIcon('favorite-on');
                    db_query("INSERT INTO {filedepot_favorites} (uid,fid) VALUES (:uid,:fid)", array(':uid' => $user->uid, ':fid' => $id));
                }
                $data['retcode'] = 200;
            } else {
                $data['retcode'] = 400;
            }
            break;
        case 'markfavorite':
            $token = isset($_POST['ltoken']) ? $_POST['ltoken'] : NULL;
            if ($token == NULL || !drupal_valid_token($token, FILEDEPOT_TOKEN_LISTING)) {
                $data['retcode'] = 403;
                // forbidden
            } elseif ($user->uid > 0) {
                $cid = intval($_POST['cid']);
                $reportmode = check_plain($_POST['reportmode']);
                $fileitems = check_plain($_POST['checkeditems']);
                $files = explode(',', $fileitems);
                $filedepot->cid = $cid;
                $filedepot->activeview = $reportmode;
                foreach ($files as $id) {
                    if ($id > 0 and db_query("SELECT COUNT(*) FROM {filedepot_favorites} WHERE uid=:uid AND fid=:fid", array(':uid' => $user->uid, ':fid' => $id))->fetchField() == 0) {
                        db_query("INSERT INTO {filedepot_favorites} (uid,fid) VALUES (:uid,:fid)", array(':uid' => $user->uid, 'fid' => $id));
                    }
                }
                $data['retcode'] = 200;
                $data['displayhtml'] = filedepot_displayFolderListing($cid);
            }
            break;
        case 'clearfavorite':
            $token = isset($_POST['ltoken']) ? $_POST['ltoken'] : NULL;
            if ($token == NULL || !drupal_valid_token($token, FILEDEPOT_TOKEN_LISTING)) {
                $data['retcode'] = 403;
                // forbidden
            } elseif ($user->uid > 0) {
                $cid = intval($_POST['cid']);
                $reportmode = check_plain($_POST['reportmode']);
                $fileitems = check_plain($_POST['checkeditems']);
                $files = explode(',', $fileitems);
                $filedepot->cid = $cid;
                $filedepot->activeview = $reportmode;
                foreach ($files as $id) {
                    if ($id > 0 and db_query("SELECT COUNT(*) FROM {filedepot_favorites} WHERE uid=:uid AND fid=:fid", array(':uid' => $user->uid, ':fid' => $id))->fetchField() == 1) {
                        db_query("DELETE FROM {filedepot_favorites} WHERE uid=:uid AND fid=:fid", array(':uid' => $user->uid, ':fid' => $id));
                    }
                }
                $data['retcode'] = 200;
                $data['displayhtml'] = filedepot_displayFolderListing($cid);
            }
            break;
        case 'togglelock':
            $fid = intval($_POST['fid']);
            $token = isset($_POST['ftoken']) ? $_POST['ftoken'] : NULL;
            if ($token == NULL || !drupal_valid_token($token, FILEDEPOT_TOKEN_FILEDETAILS)) {
                $data['error'] = t('Error locking file');
            } else {
                $data['error'] = '';
                $data['fid'] = $fid;
                $query = db_query("SELECT status FROM {filedepot_files} WHERE fid=:fid", array(':fid' => $fid));
                if ($query) {
                    list($status) = array_values($query->fetchAssoc());
                    if ($status == 1) {
                        db_query("UPDATE {filedepot_files} SET status='2', status_changedby_uid=:uid WHERE fid=:fid", array(':uid' => $user->uid, ':fid' => $fid));
                        $stat_user = db_query("SELECT name FROM {users} WHERE uid=:uid", array(':uid' => $user->uid))->fetchField();
                        $data['message'] = 'File Locked successfully';
                        $data['locked_message'] = '* ' . t('Locked by %name', array('%name' => $stat_user));
                        $data['locked'] = TRUE;
                    } else {
                        db_query("UPDATE {filedepot_files} SET status='1', status_changedby_uid=:uid WHERE fid=:fid", array(':uid' => $user->uid, ':fid' => $fid));
                        $data['message'] = 'File Un-Locked successfully';
                        $data['locked'] = FALSE;
                    }
                } else {
                    $data['error'] = t('Error locking file');
                }
            }
            break;
        case 'movecheckedfiles':
            $token = isset($_POST['ltoken']) ? $_POST['ltoken'] : NULL;
            if ($token == NULL || !drupal_valid_token($token, FILEDEPOT_TOKEN_LISTING)) {
                $data['retcode'] = 403;
                // forbidden
            } elseif ($user->uid > 0) {
                $data = filedepotAjaxServer_moveCheckedFiles();
            } else {
                $data['retcode'] = 500;
            }
            break;
        case 'rendermoveform':
            $data['displayhtml'] = theme('filedepot_movefiles_form');
            break;
        case 'rendermoveincoming':
            $data['displayhtml'] = theme('filedepot_moveincoming_form');
            break;
        case 'togglesubscribe':
            $fid = intval($_POST['fid']);
            $cid = intval($_POST['cid']);
            $token = isset($_POST['ftoken']) ? $_POST['ftoken'] : NULL;
            if ($token == NULL || !drupal_valid_token($token, FILEDEPOT_TOKEN_FILEDETAILS)) {
                $data['error'] = t('Error subscribing');
            } else {
                global $base_url;
                $data['error'] = '';
                $data['fid'] = $fid;
                $ret = filedepotAjaxServer_updateFileSubscription($fid, 'toggle');
                // @TODO: Notifyicon does not appear to be implemented
                if ($ret['retcode'] === TRUE) {
                    $data['retcode'] = 200;
                    if ($ret['subscribed'] === TRUE) {
                        $data['subscribed'] = TRUE;
                        $data['message'] = 'You will be notified of any new versions of this file';
                        $path = drupal_get_path('module', 'filedepot') . '/css/images/email-green.gif';
                        $data['notifyicon'] = $base_url . '/' . $path;
                        $data['notifymsg'] = 'Notification Enabled - Click to change';
                    } elseif ($ret['subscribed'] === FALSE) {
                        $data['subscribed'] = FALSE;
                        $data['message'] = 'You will not be notified of any new versions of this file';
                        $path = drupal_get_path('module', 'filedepot') . '/css/images/email-regular.gif';
                        $data['notifyicon'] = $base_url . '/' . $path;
                        $data['notifymsg'] = 'Notification Disabled - Click to change';
                    }
                } else {
                    $data['error'] = t('Error accessing file record');
                    $data['retcode'] = 404;
                }
            }
            break;
        case 'updatenotificationsettings':
            if ($user->uid > 0) {
                if (db_query("SELECT count(uid) FROM {filedepot_usersettings} WHERE uid=:uid", array(':uid' => $user->uid))->fetchField() == 0) {
                    db_query("INSERT INTO {filedepot_usersettings} (uid) VALUES ( :uid )", array(':uid' => $user->uid));
                }
                $sql = "UPDATE {filedepot_usersettings} SET notify_newfile=:newfile,notify_changedfile=:changefile,allow_broadcasts=:broadcast WHERE uid=:uid";
                db_query($sql, array(':newfile' => $_POST['fileadded_notify'], ':changefile' => $_POST['fileupdated_notify'], ':broadcast' => $_POST['admin_broadcasts'], ':uid' => $user->uid));
                $data['retcode'] = 200;
                $data['displayhtml'] = theme('filedepot_notifications');
            } else {
                $data['retcode'] = 500;
            }
            break;
        case 'deletenotification':
            $id = intval($_POST['id']);
            if ($user->uid > 0 and $id > 0) {
                db_query("DELETE FROM {filedepot_notifications} WHERE id=:id AND uid=:uid", array(':id' => $id, ':uid' => $user->uid));
                $data['retcode'] = 200;
                $data['displayhtml'] = theme('filedepot_notifications');
            } else {
                $data['retcode'] = 500;
            }
            break;
        case 'clearnotificationlog':
            db_query("DELETE FROM {filedepot_notificationlog} WHERE target_uid=:uid", array(':uid' => $user->uid));
            $data['retcode'] = 200;
            break;
        case 'multisubscribe':
            $token = isset($_POST['ltoken']) ? $_POST['ltoken'] : NULL;
            if ($token == NULL || !drupal_valid_token($token, FILEDEPOT_TOKEN_LISTING)) {
                $data['retcode'] = 403;
                // forbidden
            } elseif ($user->uid > 0) {
                $reportmode = check_plain($_POST['reportmode']);
                $fileitems = check_plain($_POST['checkeditems']);
                $folderitems = check_plain($_POST['checkedfolders']);
                $filedepot->cid = intval($_POST['cid']);
                $filedepot->activeview = check_plain($_POST['reportmode']);
                if (!empty($fileitems)) {
                    $files = explode(',', $fileitems);
                    foreach ($files as $fid) {
                        filedepotAjaxServer_updateFileSubscription($fid, 'add');
                    }
                }
                if (!empty($folderitems)) {
                    $folders = explode(',', $folderitems);
                    foreach ($folders as $cid) {
                        if (db_query("SELECT count(id) FROM {filedepot_notifications} WHERE cid=:cid AND uid=:uid", array(':cid' => $cid, ':uid' => $user->uid))->fetchField() == 0) {
                            $sql = "INSERT INTO {filedepot_notifications} (cid,cid_newfiles,cid_changes,uid,date) ";
                            $sql .= "VALUES (:cid,1,1,:uid,:time)";
                            db_query($sql, array(':cid' => $cid, ':uid' => $user->uid, ':time' => time()));
                        }
                    }
                }
                $data['retcode'] = 200;
                $data = filedepotAjaxServer_generateLeftSideNavigation($data);
                $data['displayhtml'] = filedepot_displayFolderListing($filedepot->cid);
            } else {
                $data['retcode'] = 500;
            }
            break;
        case 'autocompletetag':
            $matches = $nexcloud->get_matchingtags($_GET['query']);
            $retval = implode("\n", $matches);
            break;
        case 'refreshtagcloud':
            $data['retcode'] = 200;
            $data['tagcloud'] = theme('filedepot_tagcloud');
            break;
        case 'search':
            $query = $_POST['query'];
            if (!empty($query)) {
                $filedepot->activeview = 'search';
                $filedepot->cid = 0;
                $data['retcode'] = 200;
                $data['displayhtml'] = filedepot_displaySearchListing($query);
                $data['header'] = theme('filedepot_header');
                $data['activefolder'] = theme('filedepot_activefolder');
            } else {
                $data['retcode'] = 400;
            }
            break;
        case 'searchtags':
            if (isset($_POST['tags'])) {
                $tags = stripslashes($_POST['tags']);
            } else {
                $tags = '';
            }
            if (isset($_POST['removetag'])) {
                $removetag = stripslashes($_POST['removetag']);
            } else {
                $removetag = '';
            }
            $current_search_tags = '';
            $filedepot->activeview = 'searchtags';
            $filedepot->cid = 0;
            if (!empty($tags)) {
                if (!empty($removetag)) {
                    $removetag = stripslashes($removetag);
                    $atags = explode(',', $tags);
                    $key = array_search($removetag, $atags);
                    if ($key !== FALSE) {
                        unset($atags[$key]);
                    }
                    $tags = implode(',', $atags);
                    $_POST['tags'] = $tags;
                } else {
                    $removetag = '';
                }
                if (!empty($tags)) {
                    $data['searchtags'] = stripslashes($tags);
                    $atags = explode(',', $tags);
                    if (count($atags) >= 1) {
                        foreach ($atags as $tag) {
                            $tag = trim($tag);
                            // added to handle extra space thats added when removing a tag - thats between 2 other tags
                            if (!empty($tag)) {
                                $current_search_tags .= theme('filedepot_searchtag', array('searchtag' => addslashes($tag), 'label' => check_plain($tag)));
                            }
                        }
                    }
                    $data['retcode'] = 200;
                    $data['currentsearchtags'] = $current_search_tags;
                    $data['displayhtml'] = filedepot_displayTagSearchListing($tags);
                    $data['tagcloud'] = theme('filedepot_tagcloud');
                    $data['header'] = theme('filedepot_header');
                    $data['activefolder'] = theme('filedepot_activefolder');
                } else {
                    unset($_POST['tags']);
                    $filedepot->activeview = 'latestfiles';
                    $data['retcode'] = 200;
                    $data['currentsearchtags'] = '';
                    $data['tagcloud'] = theme('filedepot_tagcloud');
                    $data['displayhtml'] = filedepot_displayFolderListing($filedepot->cid);
                    $data['header'] = theme('filedepot_header');
                    $data['activefolder'] = theme('filedepot_activefolder');
                }
            } else {
                $data['tagcloud'] = theme('filedepot_tagcloud');
                $data['retcode'] = 203;
                // Partial Information
            }
            break;
        case 'approvefile':
            $id = intval($_POST['id']);
            $token = isset($_POST['ltoken']) ? $_POST['ltoken'] : NULL;
            if ($token == NULL || !drupal_valid_token($token, FILEDEPOT_TOKEN_LISTING)) {
                $data['retcode'] = 403;
                // forbidden
            } elseif ($user->uid > 0 and $filedepot->approveFileSubmission($id)) {
                $filedepot->cid = 0;
                $filedepot->activeview = 'approvals';
                $data = filedepotAjaxServer_getfilelisting();
                $data = filedepotAjaxServer_generateLeftSideNavigation($data);
                $data['retcode'] = 200;
            } else {
                $data['retcode'] = 400;
            }
            break;
        case 'approvesubmissions':
            $token = isset($_POST['ltoken']) ? $_POST['ltoken'] : NULL;
            if ($token == NULL || !drupal_valid_token($token, FILEDEPOT_TOKEN_LISTING)) {
                $data['retcode'] = 403;
                // forbidden
            } elseif ($user->uid > 0) {
                $reportmode = check_plain($_POST['reportmode']);
                $fileitems = check_plain($_POST['checkeditems']);
                $files = explode(',', $fileitems);
                $approved_files = 0;
                $filedepot->activeview = 'approvals';
                foreach ($files as $id) {
                    // Check if this is a valid submission record
                    if ($id > 0 and db_query("SELECT COUNT(*) FROM {filedepot_filesubmissions} WHERE id=:id", array(':id' => $id))->fetchField() == 1) {
                        // Verify that user has Admin Access to approve this file
                        $cid = db_query("SELECT cid FROM {filedepot_filesubmissions} WHERE id=:id", array(':id' => $id))->fetchField();
                        if ($cid > 0 and $filedepot->checkPermission($cid, array('admin', 'approval'), 0, FALSE)) {
                            if ($filedepot->approveFileSubmission($id)) {
                                $approved_files++;
                            }
                        }
                    }
                }
                if ($approved_files > 0) {
                    $data['retcode'] = 200;
                    $data = filedepotAjaxServer_generateLeftSideNavigation($data);
                    $data['displayhtml'] = filedepot_displayFolderListing();
                } else {
                    $data['retcode'] = 400;
                }
            }
            break;
        case 'deletesubmissions':
            $token = isset($_POST['ltoken']) ? $_POST['ltoken'] : NULL;
            if ($token == NULL || !drupal_valid_token($token, FILEDEPOT_TOKEN_LISTING)) {
                $data['retcode'] = 403;
                // forbidden
            } elseif ($user->uid > 0) {
                $reportmode = check_plain($_POST['reportmode']);
                $fileitems = check_plain($_POST['checkeditems']);
                $files = explode(',', $fileitems);
                $deleted_files = 0;
                $filedepot->activeview = 'approvals';
                foreach ($files as $id) {
                    // Check if this is a valid submission record
                    if ($id > 0 and db_query("SELECT COUNT(*) FROM {filedepot_filesubmissions} WHERE id=:id", array(':id' => $id))->fetchField() == 1) {
                        // Verify that user has Admin Access to approve this file
                        $cid = db_query("SELECT cid FROM {filedepot_filesubmissions} WHERE id=:id", array(':id' => $id))->fetchField();
                        if ($cid > 0 and $filedepot->checkPermission($cid, array('admin', 'approval'), 0, FALSE)) {
                            if ($filedepot->deleteSubmission($id)) {
                                $deleted_files++;
                            }
                        }
                    }
                }
                if ($deleted_files > 0) {
                    $data['retcode'] = 200;
                    $data = filedepotAjaxServer_generateLeftSideNavigation($data);
                    $data['displayhtml'] = filedepot_displayFolderListing();
                } else {
                    $data['retcode'] = 400;
                }
            }
            break;
        case 'deleteincomingfile':
            $id = intval($_POST['id']);
            $message = '';
            $token = isset($_POST['token']) ? $_POST['token'] : NULL;
            if ($token == NULL || !drupal_valid_token($token, FILEDEPOT_TOKEN_FOLDERMGMT)) {
                $data['retcode'] = 403;
                // forbidden
            } else {
                $fid = db_query("SELECT drupal_fid FROM {filedepot_import_queue} WHERE id=:id", array(':id' => $id))->fetchField();
                if ($fid > 0) {
                    $filepath = db_query("SELECT filepath FROM {files} WHERE fid=:fid", array(':fid' => $fid))->fetchField();
                    if (!empty($filepath) and file_exists($filepath)) {
                        @unlink($filepath);
                    }
                    db_query("DELETE FROM {files} WHERE fid=:fid", array(':fid' => $fid));
                    db_query("DELETE FROM {filedepot_import_queue} WHERE id=:id", array(':id' => $id));
                    $data['retcode'] = 200;
                    $filedepot->activeview = 'incoming';
                    $data = filedepotAjaxServer_generateLeftSideNavigation($data);
                    $data['displayhtml'] = filedepot_displayFolderListing();
                } else {
                    $data['retcode'] = 500;
                }
                $retval = json_encode($data);
            }
            break;
        case 'moveincomingfile':
            //FILEDEPOT_TOKEN_FOLDERMGMT
            $newcid = intval($_POST['newcid']);
            $id = intval($_POST['id']);
            $filedepot->activeview = 'incoming';
            $data = array();
            $token = isset($_POST['token']) ? $_POST['token'] : NULL;
            if ($token == NULL || !drupal_valid_token($token, FILEDEPOT_TOKEN_FOLDERMGMT)) {
                $data['retcode'] = 403;
                // forbidden
            } elseif ($newcid > 0 and $id > 0 and $filedepot->moveIncomingFile($id, $newcid)) {
                // Send out email notifications of new file added to all users subscribed  -  Get fileid for the new file record
                $fid = db_query("SELECT fid FROM {filedepot_files} WHERE cid=:cid AND submitter=:uid ORDER BY fid DESC", array(':cid' => $newcid, ':uid' => $user->uid), 0, 1)->fetchField();
                filedepot_sendNotification($fid, FILEDEPOT_NOTIFY_NEWFILE);
                $data['retcode'] = 200;
                $data = filedepotAjaxServer_generateLeftSideNavigation($data);
                $data['displayhtml'] = filedepot_displayFolderListing();
            } else {
                $data['retcode'] = 500;
            }
            break;
        case 'broadcastalert':
            $data = array();
            if (variable_get('filedepot_default_allow_broadcasts', 1) == 0) {
                $data['retcode'] = 204;
            } else {
                $fid = intval($_POST['fid']);
                $message = check_plain($_POST['message']);
                $token = isset($_POST['ftoken']) ? $_POST['ftoken'] : NULL;
                if ($token == NULL || !drupal_valid_token($token, FILEDEPOT_TOKEN_FILEDETAILS)) {
                    $data['retcode'] = 403;
                } elseif (!empty($message) and $fid > 0) {
                    $data = filedepotAjaxServer_broadcastAlert($fid, $message);
                } else {
                    $data['retcode'] = 500;
                }
            }
            break;
    }
    ob_clean();
    if ($action != 'autocompletetag') {
        if ($action != 'getmorefiledata' and $action != 'getmorefolderdata') {
            $retval = json_encode($data);
        }
        header('Cache-Control: no-store, no-cache, must-revalidate');
        header('content-type: application/xml', TRUE);
        echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";
    }
    echo $retval;
}
コード例 #6
0
ファイル: update.php プロジェクト: veggieryan/drupal
function update_info_page()
{
    // Change query-strings on css/js files to enforce reload for all users.
    _drupal_flush_css_js();
    // Flush the cache of all data for the update status module.
    if (db_table_exists('cache_update')) {
        cache_clear_all('*', 'cache_update', TRUE);
    }
    update_task_list('info');
    drupal_set_title('Drupal database update');
    $token = drupal_get_token('update');
    $output = '<p>Use this utility to update your database whenever a new release of Drupal or a module is installed.</p><p>For more detailed information, see the <a href="http://drupal.org/node/258">Installation and upgrading handbook</a>. If you are unsure what these terms mean you should probably contact your hosting provider.</p>';
    $output .= "<ol>\n";
    $output .= "<li><strong>Back up your database</strong>. This process will change your database values and in case of emergency you may need to revert to a backup.</li>\n";
    $output .= "<li><strong>Back up your code</strong>. Hint: when backing up module code, do not leave that backup in the 'modules' or 'sites/*/modules' directories as this may confuse Drupal's auto-discovery mechanism.</li>\n";
    $output .= '<li>Put your site into <a href="' . base_path() . '?q=admin/settings/maintenance-mode">maintenance mode</a>.</li>' . "\n";
    $output .= "<li>Install your new files in the appropriate location, as described in the handbook.</li>\n";
    $output .= "</ol>\n";
    $output .= "<p>When you have performed the steps above, you may proceed.</p>\n";
    $output .= '<form method="post" action="update.php?op=selection&amp;token=' . $token . '"><p><input type="submit" value="Continue" /></p></form>';
    $output .= "\n";
    return $output;
}
コード例 #7
0
  <div style="margin: 0px 10px 0px 0px; float: right;">&nbsp;</div>

  <div class="active"><div class="maestro_task_edit_tab_close" style="float: right;"><div class="t"><div class=""><div class="r"><div class="l"><div class="bl-cl"><div class="br-cl"><div class="tl-cl"><div class="tr-cl">
  <a href="#" onclick="(function($) { $.modal.close(); disable_ajax_indicator(); select_boxes = []; })(jQuery); return false;"><img src="<?php 
print $maestro_url;
?>
/images/admin/close.png"></a>
  </div></div></div></div></div></div></div></div></div></div>

  <div style="clear: both;"></div>

  <div class="maestro_task_edit_panel">
    <div class="t"><div class="b"><div class="r"><div class="l"><div class="bl-wht"><div class="br-wht"><div class="tl-wht"><div class="tr-wht">
      <form id="maestro_task_edit_form" method="post" action="" onsubmit="return save_task(this, '<?php 
print drupal_get_token('maestro_admin');
?>
');">
        <input type="hidden" name="task_class" value="<?php 
print $task_class;
?>
">
        <input type="hidden" name="template_data_id" value="<?php 
print $tdid;
?>
">

        <div id="task_edit_main">
          <div style="float: none;" class="maestro_tool_tip maestro_taskname"><div class="t"><div class="b"><div class="r"><div class="l"><div class="bl-bge"><div class="br-bge"><div class="tl-bge"><div class="tr-bge">
            <?php 
print t('Task Name');
コード例 #8
0
 function initializeJavascriptArrays()
 {
     $js = '';
     $res = db_query('SELECT id, offset_left, offset_top FROM {maestro_template_data} WHERE template_id=:tid', array(':tid' => $this->_template_id));
     $i = 0;
     $j = 0;
     foreach ($res as $rec) {
         $js .= "existing_tasks[{$i}] = ['task{$rec->id}', {$rec->offset_left}, {$rec->offset_top}];\n";
         $i++;
         $res2 = DB_query("SELECT template_data_to, template_data_to_false FROM {maestro_template_data_next_step} WHERE template_data_from=:tid", array(':tid' => $rec->id));
         foreach ($res2 as $rec2) {
             $to = intval($rec2->template_data_to);
             $to_false = intval($rec2->template_data_to_false);
             if ($to != 0) {
                 $js .= "line_ids[{$j}] = ['task{$rec->id}', 'task{$to}', true];\n";
                 $j++;
             }
             if ($to_false != 0) {
                 $js .= "line_ids[{$j}] = ['task{$rec->id}', 'task{$to_false}', false];\n";
                 $j++;
             }
         }
     }
     $js .= "var move_tkn = '" . drupal_get_token('maestro_admin') . "';\n";
     return $js;
 }
コード例 #9
0
<div id="search" class="container-inline">
  <div class="form-item">
    <input type="text" maxlength="128" name="search_theme_form_keys" id="edit-search-theme-form-keys" size="15" value="" title="<?php 
print t('Enter the terms you wish to search for.');
?>
" class="form-text" />
  </div>
  <input type="submit" name="op" id="edit-submit" value="<?php 
print t('Search');
?>
"  class="form-submit" />
  <input type="hidden" name="form_token" id="edit-search-theme-form-form-token" value="<?php 
print drupal_get_token('search_theme_form');
?>
"  />
  <input type="hidden" name="form_id" id="edit-search-theme-form" value="search_theme_form"  />
</div>
コード例 #10
0
ファイル: SearchClass.php プロジェクト: ratzeni/islandora
 /**
  * apply an xslt to lucene gsearch search results
  *
  * @param <type> $resultData
  * @param <type> $startPage
  * @param <type> $xslt_file
  * @param <type> $query the query that was executed.  May want to pass this on.
  */
 function applyLuceneXSLT($resultData, $startPage = 1, $xslt_file = '/xsl/results.xsl', $query = null)
 {
     $path = drupal_get_path('module', 'Fedora_Repository');
     $proc = null;
     if (!$resultData) {
         //drupal_set_message(t('No Results!'));
         return ' ';
         //no results
     }
     try {
         $proc = new XsltProcessor();
     } catch (Exception $e) {
         drupal_set_message(t('Error loading results xslt! ') . $e->getMessage());
         return ' ';
     }
     if (isset($query)) {
         $proc->setParameter('', 'fullQuery', $query);
     }
     //inject into xsl stylesheet
     global $user;
     $proc->setParameter('', 'userID', $user->uid);
     $proc->setParameter('', 'searchToken', drupal_get_token('fedora_repository_advanced_search'));
     //token generated by Drupal, keeps tack of what tab etc we are on
     $proc->setParameter('', 'searchUrl', url('search') . '/fedora_repository');
     //needed in our xsl
     $proc->setParameter('', 'objectsPage', base_path());
     $proc->setParameter('', 'allowedPidNameSpaces', variable_get('fedora_pids_allowed', 'demo: changeme:'));
     $proc->setParameter('', 'hitPageStart', $startPage);
     $proc->registerPHPFunctions();
     $xsl = new DomDocument();
     $test = $xsl->load($path . $xslt_file);
     if (!isset($test)) {
         drupal_set_message(t('Error loading search results xslt!'));
         return t('Error loading search results xslt! ');
     }
     $input = new DomDocument();
     $didLoadOk = $input->loadXML($resultData);
     if (!isset($didLoadOk)) {
         drupal_set_message(t('Error loading search results!'));
         return t('Error loading search results! ');
     } else {
         $proc->importStylesheet($xsl);
         $newdom = $proc->transformToDoc($input);
         return $newdom->saveXML();
     }
 }
コード例 #11
0
 /**
  * Value callback; Return the CSRF token.
  *
  * @return array
  */
 protected static function getCsrfToken() {
   return drupal_get_token(\RestfulInterface::TOKEN_VALUE);
 }
コード例 #12
0
ファイル: authcache.php プロジェクト: ATouhou/www.alim.org
/**
 * Form tokens (prevents CSRF)
 *
 * form_token_id is a hidden field added by authcache.module's hook_form_alter()
 * @see form.inc
 */
function _authcache_form_token_id($vars) {
  include_once './includes/common.inc';
  foreach($vars as $form_token_id) {
    switch($form_token_id) {
      case 'contact_mail_page':
        global $user;
        $tokens[$form_token_id] = drupal_get_token($user->name . $user->mail);
        break;
      default;
        $tokens[$form_token_id] = drupal_get_token($form_token_id);
        break;
    }
  }
  return $tokens;
}
コード例 #13
0
 /**
  * Value callback; Return the CSRF token.
  *
  * @return string
  *   The token.
  */
 public static function getCsrfToken()
 {
     return drupal_get_token(\Drupal\restful\Plugin\authentication\Authentication::TOKEN_VALUE);
 }
コード例 #14
0
function update_info_page()
{
    drupal_set_title('Drupal database update');
    $link = 'update.php?op=selection&token=' . drupal_get_token('update');
    $output = "<ol>\n";
    $output .= "<li>Use this script to <strong>upgrade an existing Drupal installation</strong>. You don't need this script when installing Drupal from scratch.</li>";
    $output .= "<li>Before doing anything, backup your database. This process will change your database and its values, and some things might get lost.</li>\n";
    $output .= "<li>Update your Drupal sources, check the notes below and <a href=\"{$link}\">run the database upgrade script</a>. Don't upgrade your database twice as it may cause problems.</li>\n";
    $output .= "<li>Go through the various administration pages to change the existing and new settings to your liking.</li>\n";
    $output .= "</ol>";
    $output .= '<p>For more help, see the <a href="http://drupal.org/node/258">Installation and upgrading handbook</a>. If you are unsure what these terms mean you should probably contact your hosting provider.</p>';
    return $output;
}
コード例 #15
0
function gd_js_ext () {
    ob_start();
    header('Content-Type: text/javascript; charset=UTF-8');

    echo '(function(global){ '."\n\n";

    foreach ( \GD\Js\Registry::getInstance()->getVendorFiles() as $file ) {
        echo file_get_contents($file)."\n\n";
    }

    foreach ( \GD\Js\Registry::getInstance()->getFiles() as $file ) {
        echo file_get_contents($file)."\n\n";
    }

    echo 'GD.options.host = "'.GOVDASH_HOST.'";'."\n\n";
    echo 'GD.options.themeList = ["table.css", "filter.css", "highcharts.css", "reportMenu.css", "report.css"];'."\n\n";
    echo 'GD.options.themePath = "' . path_to_theme() . '/css/viewer/";'."\n\n";
    echo 'GD.options.csrf = "' . drupal_get_token('services') . '";'."\n";

    echo "\n\n";
    echo file_get_contents(dirname(__FILE__) . '/js/apps/Ext.js')."\n\n";

    echo 'global.GD_Highcharts = Highcharts;'."\n";
    echo 'global.GD_jQuery = jQuery;'."\n";

    echo "\n";
    echo '})(typeof window === "undefined" ? this : window);'."\n";


    gd_get_session_messages();

    echo ob_get_clean();
    drupal_exit();
}
コード例 #16
0
mytinytodo_page_add_js($mytinytodo_path . 'lib/jquery/jquery.autocomplete-1.1.js');
mytinytodo_page_add_library('system', 'effects');
mytinytodo_page_add_library('system', 'effects.highlight');
mytinytodo_page_add_library('system', 'ui.datepicker');
mytinytodo_page_add_library('system', 'ui.sortable');
$jsoutput = '';
if (is_numeric($_GET['fid'])) {
    $jsoutput .= "var field_id = {$_GET['fid']};\n";
}
$jsoutput .= "var base_url = '" . url(NULL, array('absolute' => TRUE, 'language' => '')) . "';\n";
if (variable_get('clean_url', 0)) {
    $jsoutput .= "var clean_url = true;\n";
} else {
    $jsoutput .= "var clean_url = false;\n";
}
$jsoutput .= "var csrf_token = '" . drupal_get_token('mytinytodo') . "';\n";
echo "<script type=\"text/javascript\">\n{$jsoutput}\n</script>\n";
mytinytodo_page_add_js($mytinytodo_path . 'lib/mytinytodo.js');
mytinytodo_page_add_js($mytinytodo_path . 'lib/mytinytodo_ajax_storage.js');
// Pass field id so that task list specific settings can be loaded.
echo '<script type="text/javascript" src="' . url('mytinytodo/lang', array('query' => array('fid' => $_GET['fid']), 'absolute' => TRUE, 'language' => '')) . '" media="all"></script>' . "\n";
echo '<script type="text/javascript" src="' . url('mytinytodo/init', array('query' => array('fid' => $_GET['fid']), 'absolute' => TRUE, 'language' => '')) . '" media="all"></script>' . "\n";
?>
    </head>
    <body>

    <div id="wrapper">
    <div id="container">
    <div id="mtt_body">

    <div id="loading"></div>
コード例 #17
0
 function getContextMenu()
 {
     $token = drupal_get_token('maestro_admin');
     $draw_line_msg = t('Select a task to draw the line to.');
     $options = array('draw_line' => array('label' => t('Draw Success Line'), 'js' => "tkn = '{$token}'; draw_status = 1; draw_type = 1; line_start = document.getElementById('task{$this->_task_id}'); set_tool_tip('{$draw_line_msg}');\n"), 'draw_line_false' => array('label' => t('Draw Fail Line'), 'js' => "tkn = '{$token}'; draw_status = 1; draw_type = 2; line_start = document.getElementById('task{$this->_task_id}'); set_tool_tip('{$draw_line_msg}');\n"), 'clear_lines' => array('label' => t('Clear Adjacent Lines'), 'js' => "clear_task_lines(document.getElementById('task{$this->_task_id}'), '{$token}');\n"), 'edit_task' => array('label' => t('Edit Task'), 'js' => "enable_ajax_indicator(); \$.ajax({\n          type: 'POST',\n          url: ajax_url + 'MaestroTaskInterface{$this->_task_type}/{$this->_task_id}/0/edit/{$token}',\n          cache: false,\n          dataType: 'json',\n          success: display_task_panel,\n          error: editor_ajax_error\n        });"), 'delete_task' => array('label' => t('Delete Task'), 'js' => "enable_ajax_indicator(); \$.ajax({\n          type: 'POST',\n          url: ajax_url + 'MaestroTaskInterface{$this->_task_type}/{$this->_task_id}/0/destroy/{$token}',\n          cache: false,\n          dataType: 'json',\n          success: delete_task,\n          error: editor_ajax_error\n        });\n"));
     return $options;
 }
コード例 #18
0
 /**
  * Generates a CSRF protecting session token.
  *
  * @return \Symfony\Component\HttpFoundation\Response
  *   The response object.
  */
 public function csrfToken()
 {
     return new Response(drupal_get_token('rest'), 200, array('Content-Type' => 'text/plain'));
 }
コード例 #19
0
 /**
  * Submit the filter/sort form.
  *
  * This submit handler is actually responsible for building up all of the
  * rows that will later be rendered, since it is doing the filtering and
  * sorting.
  *
  * For the most part, you should not need to override this method, as the
  * fiddly bits call through to other functions.
  */
 function list_form_submit(&$form, &$form_state)
 {
     // Filter and re-sort the pages.
     $plugin = $this->plugin;
     $schema = ctools_export_get_schema($this->plugin['schema']);
     $prefix = ctools_export_ui_plugin_base_path($plugin);
     foreach ($this->items as $name => $item) {
         // Call through to the filter and see if we're going to render this
         // row. If it returns TRUE, then this row is filtered out.
         if ($this->list_filter($form_state, $item)) {
             continue;
         }
         // Note: Creating this list seems a little clumsy, but can't think of
         // better ways to do this.
         $allowed_operations = drupal_map_assoc(array_keys($plugin['allowed operations']));
         $not_allowed_operations = array('import');
         if ($item->{$schema['export']['export type string']} == t('Normal')) {
             $not_allowed_operations[] = 'revert';
         } elseif ($item->{$schema['export']['export type string']} == t('Overridden')) {
             $not_allowed_operations[] = 'delete';
         } else {
             $not_allowed_operations[] = 'revert';
             $not_allowed_operations[] = 'delete';
         }
         $not_allowed_operations[] = empty($item->disabled) ? 'enable' : 'disable';
         foreach ($not_allowed_operations as $op) {
             // Remove the operations that are not allowed for the specific
             // exportable.
             unset($allowed_operations[$op]);
         }
         $operations = array();
         foreach ($allowed_operations as $op) {
             $operations[$op] = array('title' => $plugin['allowed operations'][$op]['title'], 'href' => ctools_export_ui_plugin_menu_path($plugin, $op, $name));
             if (!empty($plugin['allowed operations'][$op]['ajax'])) {
                 $operations[$op]['attributes'] = array('class' => 'ctools-use-ajax');
             }
             if (!empty($plugin['allowed operations'][$op]['token'])) {
                 $operations[$op]['query'] = array('token' => drupal_get_token($op));
             }
         }
         $this->list_build_row($item, $form_state, $operations);
     }
     // Now actually sort
     if ($form_state['values']['sort'] == 'desc') {
         arsort($this->sorts);
     } else {
         asort($this->sorts);
     }
     // Nuke the original.
     $rows = $this->rows;
     $this->rows = array();
     // And restore.
     foreach ($this->sorts as $name => $title) {
         $this->rows[$name] = $rows[$name];
     }
 }
コード例 #20
0
ファイル: lib-theme.php プロジェクト: dalia-m-elsayed/spica
function template_preprocess_filedepot_moveincoming_form(&$variables)
{
    $variables['movefolder_options'] = filedepot_recursiveAccessOptions('admin');
    $variables['LANG_newfolder'] = t('New Folder');
    $variables['LANG_submit'] = t('Submit');
    $variables['LANG_cancel'] = t('Cancel');
    $variables['token'] = drupal_get_token(FILEDEPOT_TOKEN_FOLDERMGMT);
}
コード例 #21
0
                </td>
                <td>
                  <input type="text" name="process_variable_value[]" value="<?php 
    print $rec->variable_value;
    ?>
" size="6">
                </td>
              </tr>
<?php 
}
?>
              <tr>
                <td colspan="2" style="text-align: center;"><input class="form-submit" type="submit" value="<?php 
print t('Save Process Variables');
?>
"></td>
              </tr>
            </tbody>
          </table>
        </div>
      </fieldset>
    </form>
  </div>

  <script type="text/javascript">
    var ajax_url = '<?php 
print "{$ajax_url}/trace/{$properties->tracking_id}/{$properties->initiating_pid}/{$properties->queue_id}/" . drupal_get_token('maestro_user');
?>
';
  </script>
コード例 #22
0
        ?>
">
                                  <input type="hidden" name="taskassign_mode" value="<?php 
        print $otask->taskassign_mode;
        ?>
">
                                  <input type="hidden" name="taskid" value="<?php 
        print $otask->task_id;
        ?>
">
                                  <input type="hidden" name="assign_recid" value="<?php 
        print $otask->assign_recid;
        ?>
">
                                  <input type="hidden" name="sec_token" value="<?php 
        print drupal_get_token('maestro_user');
        ?>
">
                                  <select name="task_reassign_uid">
                                      <option value="0"><?php 
        print t('Assign to user');
        ?>
</option>
                                        <?php 
        foreach ($reassign_user_options as $user_id => $user_name) {
            ?>
                                            <option value="<?php 
            print $user_id;
            ?>
"><?php 
            print $user_name;
コード例 #23
0
function filedepotAjaxServer_loadFileDetails()
{
    global $user;
    $filedepot = filedepot_filedepot();
    $nexcloud = filedepot_nexcloud();
    $reportmode = check_plain($_POST['reportmode']);
    $retval = array();
    $retval['editperm'] = FALSE;
    $retval['token'] = drupal_get_token(FILEDEPOT_TOKEN_FILEDETAILS);
    $retval['deleteperm'] = FALSE;
    $retval['addperm'] = FALSE;
    $retval['lockperm'] = FALSE;
    $retval['notifyperm'] = FALSE;
    $retval['broadcastperm'] = FALSE;
    $retval['tags'] = '';
    $validfile = FALSE;
    if ($reportmode == 'approvals') {
        $id = intval($_POST['id']);
        if (db_query("SELECT count(*) FROM {filedepot_filesubmissions} WHERE id=:id", array(':id' => $id))->fetchField() == 1) {
            $validfile = TRUE;
            $sql = "SELECT file.id as fid,file.cid,file.title,file.fname,file.date,file.size,file.version,file.submitter,file.tags,u.name, ";
            $sql .= "file.status,file.description,category.pid,category.name as folder,category.nid,file.version_note,tags ";
            $sql .= "FROM {filedepot_filesubmissions} file ";
            $sql .= "LEFT JOIN {filedepot_categories} category ON file.cid=category.cid ";
            $sql .= "LEFT JOIN {users} u ON u.uid=file.submitter ";
            $sql .= "WHERE file.id=:id ";
            $rec = db_query($sql, array(':id' => $id))->fetchAssoc();
            $retval = array_merge($retval, $rec);
            $retval['displayhtml'] = theme('filedepot_filedetail', array('fid' => $id, 'reportmode' => $reportmode));
            $retval['locked'] = FALSE;
            $retval['subscribed'] = FALSE;
        }
    } elseif ($reportmode == 'incoming') {
        $id = intval($_POST['id']);
        if (db_result(db_query("SELECT count(*) FROM {filedepot_import_queue} WHERE id=:id", array(':id' => $id))) == 1) {
            $validfile = TRUE;
            $sql = "SELECT file.id as fid,file.orig_filename as title,file.description,file.version_note,u.name ";
            $sql .= "FROM {filedepot_import_queue} file ";
            $sql .= "LEFT JOIN {users} u ON u.uid=file.uid ";
            $sql .= "WHERE file.id=:id ";
            $rec = db_query($sql, array(':id' => $id))->fetchAssoc();
            $retval = array_merge($retval, $rec);
            if (empty($retval['version_note'])) {
                $retval['version_note'] = '';
            }
            $retval['displayhtml'] = theme('filedepot_filedetail', array('fid' => $id, 'reportmode' => $reportmode));
            $retval['locked'] = FALSE;
            $retval['subscribed'] = FALSE;
            // Need to reference a valid filedepot_folder node for the filedepot_download callback to work - required for the File Details 'Download' menuitem
            $retval['nid'] = db_query_range("SELECT nid FROM {filedepot_categories} WHERE pid=0", 0, 1, array())->fetchField();
        }
    } else {
        // Check that record exists
        $fid = intval($_POST['id']);
        $cid = db_query("SELECT cid FROM {filedepot_files} WHERE fid=:fid", array(':fid' => $fid))->fetchField();
        if ($filedepot->checkPermission($cid, 'view') and db_query("SELECT count(*) FROM {filedepot_files} WHERE fid=:fid", array(':fid' => $fid))->fetchField() == 1) {
            $validfile = TRUE;
            $sql = "SELECT file.fid,file.cid,file.title,file.description,file.fname,file.date,file.size,file.version,file.submitter,u.name, ";
            $sql .= "file.status,category.pid,category.name as folder,category.nid,v.notes as version_note,file.status_changedby_uid ";
            $sql .= "FROM {filedepot_files} file ";
            $sql .= "LEFT JOIN {filedepot_categories} category ON file.cid=category.cid ";
            $sql .= "LEFT JOIN {filedepot_fileversions} v ON v.fid=file.fid ";
            $sql .= "LEFT JOIN {users} u ON u.uid=file.submitter ";
            $sql .= "WHERE file.fid=:fid ORDER BY v.version DESC";
            $rec = db_query($sql, array(':fid' => $fid))->fetchAssoc();
            $retval = array_merge($retval, $rec);
            $retval['tags'] = $nexcloud->get_itemtags($fid);
            $retval['displayhtml'] = theme('filedepot_filedetail', array('fid' => $fid, 'reportmode' => $reportmode));
            // Check if file is locked
            if ($retval['status'] == FILEDEPOT_LOCKED_STATUS) {
                $retval['locked'] = TRUE;
            } else {
                $retval['locked'] = FALSE;
            }
            // Check and see if user has subscribed to this file
            $direct = FALSE;
            $ignorefilechanges = FALSE;
            // Check if user has an ignore file changes record or a subscribe to changes record for this file
            $query = db_query("SELECT fid,ignore_filechanges FROM {filedepot_notifications} WHERE fid=:fid and uid=:uid", array(':fid' => $fid, ':uid' => $user->uid));
            $A = $query->fetchAssoc();
            if ($A['ignore_filechanges'] == 1) {
                $ignorefilechanges = TRUE;
            } elseif ($A['fid'] == $fid) {
                $direct = TRUE;
            }
            // Check and see if user has indirectly subscribed to file by subscribing to folder
            $sql = "SELECT count(*) FROM {filedepot_notifications} WHERE cid_changes=1 AND cid=:cid AND uid=:uid";
            $indirect = db_query($sql, array(':cid' => $rec['cid'], ':uid' => $user->uid))->fetchField();
            if (($direct or $indirect) and !$ignorefilechanges) {
                $retval['subscribed'] = TRUE;
            } else {
                $retval['subscribed'] = FALSE;
            }
        }
    }
    if ($validfile) {
        $retval['error'] = '';
        $retval['retcode'] = 200;
        if ($reportmode == 'incoming') {
            $retval['downloadperm'] = TRUE;
            $retval['editperm'] = TRUE;
            $retval['deleteperm'] = TRUE;
            $retval['addperm'] = FALSE;
            $retval['lockperm'] = FALSE;
            $retval['notifyperm'] = FALSE;
            $retval['broadcastperm'] = FALSE;
            $folderoptions = filedepot_recursiveAccessOptions('admin', 0);
            $retval['folderoptions'] = '<select name="folder" style="width:220px;">' . $folderoptions . '</select>';
        } else {
            $retval['dispfolder'] = $retval['folder'];
            $retval['description'] = nl2br($retval['description']);
            $retval['version_note'] = nl2br($retval['version_note']);
            $retval['date'] = strftime('%b %d %Y %I:%M %p', $retval['date']);
            $retval['size'] = filedepot_formatFileSize($retval['size']);
            // Setup the folder option select HTML options
            $cid = intval($retval['cid']);
            $folderoptions = filedepot_recursiveAccessOptions('admin', $cid, 0, 1, FALSE);
            if (!empty($folderoptions) and $filedepot->checkPermission($retval['cid'], 'admin')) {
                $retval['folderoptions'] = '<select name="folder" style="width:220px;">' . $folderoptions . '</select>';
            } else {
                $retval['folderoptions'] = '<input type="text" name="folder" value="' . $retval['folder'] . '" READONLY />';
            }
            if ($filedepot->checkPermission($retval['cid'], 'admin')) {
                $retval['downloadperm'] = TRUE;
                $retval['editperm'] = TRUE;
                $retval['deleteperm'] = TRUE;
                $retval['addperm'] = TRUE;
                $retval['lockperm'] = TRUE;
                $retval['notifyperm'] = TRUE;
                $retval['broadcastperm'] = TRUE;
            } elseif ($retval['locked']) {
                if ($retval['status_changedby_uid'] == $user->uid) {
                    $retval['lockperm'] = TRUE;
                    if ($filedepot->checkPermission($retval['cid'], 'upload_ver')) {
                        $retval['addperm'] = TRUE;
                    }
                    if ($retval['submitter'] == $user->uid) {
                        $retval['deleteperm'] = TRUE;
                    }
                } elseif ($retval['status_changedby_uid'] > 0) {
                    if ($retval['submitter'] == $user->uid) {
                        $retval['lockperm'] = TRUE;
                    } else {
                        $retval['downloadperm'] = FALSE;
                    }
                }
                $retval['notifyperm'] = TRUE;
            } elseif ($user->uid > 0) {
                if ($retval['submitter'] == $user->uid) {
                    $retval['deleteperm'] = TRUE;
                    $retval['lockperm'] = TRUE;
                }
                if ($filedepot->checkPermission($retval['cid'], 'upload_ver')) {
                    $retval['addperm'] = TRUE;
                }
                $retval['notifyperm'] = TRUE;
            }
            // Changed
            if ($filedepot->checkPermission($retval['cid'], 'view', 0, TRUE)) {
                $retval['tagperms'] = TRUE;
                // Able to set or change tags
                if ($retval['locked']) {
                    if ($retval['submitter'] == $user->uid or $retval['status_changedby_uid'] == $user->uid) {
                        $retval['downloadperm'] = TRUE;
                    } elseif (variable_get('filedepot_locked_file_download_enabled', 0) == 1) {
                        // Check admin config setting
                        $retval['downloadperm'] = TRUE;
                    } else {
                        $retval['downloadperm'] = FALSE;
                    }
                } else {
                    $retval['downloadperm'] = TRUE;
                    if ($retval['submitter'] == $user->uid) {
                        $retval['editperm'] = TRUE;
                    }
                }
            } else {
                $retval['tagperms'] = FALSE;
                $retval['downloadperm'] = FALSE;
            }
        }
    } else {
        $retval['retcode'] = 400;
        $retval['error'] = t('Invalid access');
    }
    return $retval;
}
コード例 #24
0
<div class="md-wrap">
	<input type="hidden" value="<?php 
print drupal_get_token('delete_tab');
?>
" id="delete_tab_token" />
	<a class="tab-link" id="add_tab" href="#"><span	class="tab-text">[Add new item]</span></a>
	<div id="md-tabs">
		<?php 
if (count($menu_tabs) > 0) {
    ?>
<!-- begin render tabs link -->
			<ul class="md-tabs-head clearfix">
			<?php 
    foreach ($menu_tabs as $key => $tab) {
        ?>
  			<li class="tab-item clearfix<?php 
        if ($tab->settings['general']['item_position'] == 'right') {
            print ' mm-item-right';
        }
        ?>
">
    			<a class="tab-link" href="#tabs-<?php 
        print $key + 1;
        ?>
">
    			  <span class="tab-text"><?php 
        print $tab->settings['general']['title'];
        ?>
</span>
    		  </a>
    		  <span class="ui-icon ui-icon-close">Remove Tab</span>
コード例 #25
0
 /**
  * Builds the operation links for a specific exportable item.
  */
 function build_operations($item)
 {
     $plugin = $this->plugin;
     $schema = ctools_export_get_schema($plugin['schema']);
     $operations = $plugin['allowed operations'];
     $operations['import'] = FALSE;
     if ($item->{$schema['export']['export type string']} == t('Normal')) {
         $operations['revert'] = FALSE;
     } elseif ($item->{$schema['export']['export type string']} == t('Overridden')) {
         $operations['delete'] = FALSE;
     } else {
         $operations['revert'] = FALSE;
         $operations['delete'] = FALSE;
     }
     if (empty($item->disabled)) {
         $operations['enable'] = FALSE;
     } else {
         $operations['disable'] = FALSE;
     }
     $allowed_operations = array();
     foreach ($operations as $op => $info) {
         if (!empty($info)) {
             $allowed_operations[$op] = array('title' => $info['title'], 'href' => ctools_export_ui_plugin_menu_path($plugin, $op, $item->{$this->plugin['export']['key']}));
             if (!empty($info['ajax'])) {
                 $allowed_operations[$op]['attributes'] = array('class' => array('use-ajax'));
             }
             if (!empty($info['token'])) {
                 $allowed_operations[$op]['query'] = array('token' => drupal_get_token($op));
             }
         }
     }
     return $allowed_operations;
 }
コード例 #26
0
<div id="block-user-0" class="clear-block block block-user">
  <div class="content">
    <form action="<?php 
print $action;
?>
" accept-charset="UTF-8" method="post" id="user-login-form">
      <div>
        <div class="form-item" id="edit-name-wrapper">
          <label for="edit-name">Username: <span class="form-required" title="This field is required.">*</span></label>
          <input type="text" maxlength="60" name="name" id="edit-name" size="15" value="" class="form-text required"/>
        </div>
        <div class="form-item" id="edit-pass-wrapper">
          <label for="edit-pass">Password: <span class="form-required" title="This field is required.">*</span></label>
          <input type="password" name="pass" id="edit-pass" maxlength="60" size="15" class="form-text required"/>
        </div>
        <input type="submit" name="op" id="edit-submit" value="Log in" class="form-submit"/>
        <input type="hidden" name="form_build_id" id="<?php 
print $bulid_id;
?>
" value="<?php 
drupal_get_token();
?>
"/>
        <input type="hidden" name="form_id" id="edit-user-login-block" value="user_login_block"/>
      </div>
    </form>
  </div>
</div>
コード例 #27
0
<label for="search_block_form_keys"></label>
<input type="text" maxlength="128" name="search_block_form_keys" id="edit-search_block_form_keys"  size="25" value="" title="Enter the terms you wish to search for." class="form-text" />
<input type="submit" name="op" value=""  />
<input type="hidden" name="form_id" id="edit-search-block-form" value="search_block_form" />
<input type="hidden" name="form_token" id="a-unique-id" value="<?php 
print drupal_get_token('search_block_form');
?>
" />
コード例 #28
0
    private function ui_js ( &$output ) {
        $filters = array();
        $drilldown = array();

        if ( !empty($_REQUEST['t']) ) {
            foreach ($_REQUEST['t'] as $dashboard => $dashboardFilters) {
                if (!isset($_REQUEST['id'])) {
                    break;
                }

                foreach ($dashboardFilters as $filterName => $filter) {
                    if ($dashboard == $_REQUEST['id']) {
                        if (isset($filter['ddf']) && $filter['ddf'] == 1) {
                            $drilldown[] = $filterName;
                        }
                    }
                    else {
                        $drilldown[] = $filterName;
                    }
                }
            }
        }

        $f =  $this->config->getFilters();
        if (isset($f)) {
            foreach ( $f as $filter ) {
                if ( in_array($filter->name, $drilldown)) {
                    $filter->ddf = true;
                }
                $filters[] = $filter;
            }
        }

        $output .= '

            <script type="text/javascript">
            <!--//--><![CDATA[//><!--
                (function(global,$,GD) {
                    var options = {
                        "autodraw": true,
                        "filterContainer": "#int-ui-container",
                        "breadcrumbContainer": "#breadcrumbContainer",
                        "filters": ' . json_encode($filters) . ',
                        "breadcrumbs": ' . json_encode(BreadcrumbFactory::parseBreadcrumbs($this->config)) . ',
                        "dashboard": ' . $this->config->id . ',
                        "public": ' . (isset($this->options['public'])?'true':'false') . ',
                        "host": "' . GOVDASH_HOST . '",
                        "csrf": "' . drupal_get_token('services') . '"
                    };
                    var GD_Int = new GD.Int(options);
                    GD_Int.run();
                    if (GD_Int.filters.length <= 0) {
                        $("#filterContainer").hide();
                    }
                    if (GD_Int.breadcrumbs.length <= 1) {
                        $("#breadcrumbContainer").hide();
                    }
                })(typeof window === "undefined" ? this : window, jQuery,GD);
                //--><!]]>
            </script>

        ';
    }