Ejemplo n.º 1
0
/**
 * Display 'Edit Trackback' page.
 */
function pageEdittrackback()
{
    require_once dirname(__FILE__) . '/modules/module_trackbacks.php';
    global $PIVOTX;
    // check if the user has the required userlevel to view this page.
    $PIVOTX['session']->minLevel(PIVOTX_UL_NORMAL);
    $PIVOTX['template']->assign('title', __('Trackbacks'));
    $PIVOTX['template']->assign('heading', __('Edit or Delete Trackbacks'));
    if ($_GET['uid'] != "" && $_GET['key'] != "") {
        // uid should be numeric. (If it's not, someone is hacking ...)
        if (!is_numeric($_GET['uid'])) {
            echo "uid must be numeric";
            die;
        }
        // Editing a trackback.. Get it from the DB..
        $entry = $PIVOTX['db']->read_entry(intval($_GET['uid']));
        // Check if the user is allowed to edit this entry. It should either be his/her own
        // Entry, or the userlevel should be advanced.
        if ($PIVOTX['session']->currentUsername() != $entry['user']) {
            $PIVOTX['session']->minLevel(PIVOTX_UL_ADVANCED);
        }
        if (isset($entry['trackbacks'][$_GET['key']])) {
            $trackback = $entry['trackbacks'][$_GET['key']];
        } else {
            // This should only happen for non-SQL db when editing a trackback from
            // the last trackback screen (or similar functions) which uses fake UIDs.
            foreach ($entry['trackbacks'] as $key => $value) {
                if ($_GET['key'] == makeTrackbackUID($value)) {
                    $trackback = $value;
                    // Setting the key to the array key
                    $_GET['key'] = $key;
                    break;
                }
            }
        }
        $PIVOTX['template']->assign('uid', $_GET['uid']);
        $form = getTrackbackForm();
        // Get the validation result
        $result = $form->validate();
        if ($result != FORM_OK) {
            // Put the user values in the form.
            $form->setValues($trackback);
            $PIVOTX['template']->assign("form", $form->fetch());
        } else {
            $val = $form->getValues();
            unset($val['csrfcheck']);
            editTrackback($entry, $_GET['key'], $val);
            // Set a message, show the trackback screen.
            $msg = __('The Trackback was saved!');
            $PIVOTX['messages']->addMessage($msg);
            pageTrackbacks();
            die;
        }
    } else {
        $PIVOTX['messages']->addMessage(__('You have to select an entry in order to view its trackback.'));
        pageTrackbacks();
        die;
    }
    renderTemplate('modal.tpl');
}
Ejemplo n.º 2
0
/**
 * Creates the file that holds the last trackbacks. Just returns
 * if we're using SQL.
 *
 * @param array $temptrack
 * @return void
 */
function generateLastTrackbacks($temptrack)
{
    global $PIVOTX;
    // If we're using MySQL, there's no need for the last trackbacks file..
    if ($PIVOTX['db']->db_type != "flat") {
        return "";
    }
    $lasttrack_file = $PIVOTX['paths']['db_path'] . 'ser_lasttrack.php';
    // if it exists, load it
    if (file_exists($lasttrack_file)) {
        $lasttrack = loadSerialize($lasttrack_file, true, true);
    } else {
        $lasttrack = array();
    }
    $lasttrack[] = array('title' => $temptrack['title'], 'excerpt' => trimText($temptrack['excerpt'], 250), 'name' => $temptrack['name'], 'url' => $temptrack['url'], 'date' => $temptrack['date'], 'entry_uid' => $temptrack['entry_uid'], 'uid' => makeTrackbackUID($temptrack), 'category' => $PIVOTX['db']->entry['category'], 'ip' => $temptrack['ip']);
    if (count($lasttrack) > intval($PIVOTX['config']->get('lastcomm_amount_max'))) {
        array_shift($lasttrack);
    }
    saveSerialize($lasttrack_file, $lasttrack);
}
Ejemplo n.º 3
0
 /**
  * Returns a trackback from the current entry.
  *
  * @param int $uid
  * @return array
  */
 function get_trackback($uid)
 {
     global $PIVOTX;
     if (isset($this->entry['trackbacks'][$uid])) {
         $track = $this->entry['trackbacks'][$uid];
     } else {
         // This should only happen when editing a trackback from the last
         // trackbacks screen (or similar functions) which uses fake UIDs.
         foreach ($this->entry['trackbacks'] as $key => $value) {
             if ($uid == makeTrackbackUID($value)) {
                 $track = $value;
                 break;
             }
         }
     }
     return $track;
 }