コード例 #1
0
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
use WT\Auth;
define('WT_SCRIPT_NAME', 'admin_site_merge.php');
require './includes/session.php';
$controller = new WT_Controller_Page();
$controller->restrictAccess(Auth::isManager())->setPageTitle(WT_I18N::translate('Merge records'))->addExternalJavascript(WT_STATIC_URL . 'js/autocomplete.js')->addInlineJavascript('autocomplete();')->pageHeader();
require_once WT_ROOT . 'includes/functions/functions_edit.php';
$ged = $GEDCOM;
$gid1 = WT_Filter::post('gid1', WT_REGEX_XREF);
$gid2 = WT_Filter::post('gid2', WT_REGEX_XREF);
$action = WT_Filter::post('action', 'choose|select|merge', 'choose');
$ged1 = WT_Filter::post('ged1', null, $ged);
$ged2 = WT_Filter::post('ged2', null, $ged);
$keep1 = WT_Filter::postArray('keep1');
$keep2 = WT_Filter::postArray('keep2');
if ($action != 'choose') {
    if ($gid1 == $gid2 && $ged1 == $ged2) {
        $action = 'choose';
        echo '<span class="error">', WT_I18N::translate('You entered the same IDs.  You cannot merge the same records.'), '</span>';
    } else {
        $rec1 = WT_GedcomRecord::getInstance($gid1, WT_Tree::getIdFromName($ged1));
        $rec2 = WT_GedcomRecord::getInstance($gid2, WT_Tree::getIdFromName($ged2));
        if (!$rec1) {
            echo '<span class="error">', WT_I18N::translate('Unable to find record with ID'), ':</span> ', $gid1, ', ', $ged;
            $action = 'choose';
        } elseif (!$rec2) {
            echo '<span class="error">', WT_I18N::translate('Unable to find record with ID'), ':</span> ', $gid2, ', ', $ged2;
            $action = 'choose';
        } elseif ($rec1::RECORD_TYPE != $rec2::RECORD_TYPE) {
            echo '<span class="error">', WT_I18N::translate('Records are not the same type.  Cannot merge records that are not the same type.'), '</span>';
コード例 #2
0
ファイル: edit_interface.php プロジェクト: brambravo/webtrees
 if ($AUTH) {
     $newgedrec .= "\n1 AUTH " . $AUTH;
 }
 $PUBL = WT_Filter::post('PUBL');
 if ($PUBL) {
     $newgedrec .= "\n1 PUBL " . preg_replace('/\\r?\\n/', "\n2 CONT ", $PUBL);
 }
 $REPO = WT_Filter::post('REPO', WT_REGEX_XREF);
 if ($REPO) {
     $newgedrec .= "\n1 REPO @" . $REPO . "@";
     $CALN = WT_Filter::post('CALN');
     if ($CALN) {
         $newgedrec .= "\n1 CALN " . $CALN;
     }
 }
 $EVEN = WT_Filter::postArray('EVEN', WT_REGEX_TAG);
 if ($EVEN) {
     $newgedrec .= "\n1 DATA";
     $newgedrec .= "\n2 EVEN " . implode(',', $EVEN);
     $EVEN_DATE = WT_Filter::post('EVEN_DATE');
     if ($EVEN_DATE) {
         $newgedrec .= "\n3 EVEN_DATE " . $EVEN_DATE;
     }
     $EVEN_PLAC = WT_Filter::post('EVEN_PLAC');
     if ($EVEN_PLAC) {
         $newgedrec .= "\n3 EVEN_PLAC " . $EVEN_PLAC;
     }
     $AGNC = WT_Filter::post('AGNC');
     if ($AGNC) {
         $newgedrec .= "\n2 AGNC " . $AGNC;
     }
コード例 #3
0
ファイル: module.php プロジェクト: elRadix/webtrees-facebook
 private function fetchFriendList()
 {
     global $WT_SESSION, $controller;
     $controller = new WT_Controller_Page();
     $controller->addInlineJavaScript("\n            \$('head').append('<link rel=\"stylesheet\" href=\"" . WT_MODULES_DIR . $this->getName() . "/facebook.css?v=" . WT_FACEBOOK_VERSION . "\" />');", WT_Controller_Page::JS_PRIORITY_LOW);
     $preApproved = unserialize($this->getSetting('preapproved'));
     if (WT_Filter::postArray('preApproved') && WT_Filter::checkCsrf()) {
         $roleRows = WT_Filter::postArray('preApproved');
         $fbUsernames = WT_Filter::postArray('facebook_username', WT_REGEX_USERNAME);
         foreach ($fbUsernames as $facebook_username) {
             $facebook_username = $this->cleanseFacebookUsername($facebook_username);
             $this->appendPreapproved($preApproved, $facebook_username, $roleRows);
         }
         $this->setSetting('preapproved', serialize($preApproved));
         WT_FlashMessages::addMessage(WT_I18N::translate('Users successfully imported from Facebook'));
         header("Location: module.php?mod=" . $this->getName() . "&mod_action=admin");
         exit;
     }
     if (empty($WT_SESSION->facebook_access_token)) {
         $this->error_page(WT_I18N::translate("You must <a href='%s'>login to the site via Facebook</a> in order to import friends from Facebook", "index.php?logout=1"));
     }
     $graph_url = "https://graph.facebook.com/" . self::api_dir . "me/friends?fields=first_name,last_name,name,username&access_token=" . $WT_SESSION->facebook_access_token;
     $friendsResponse = $this->fetch_url($graph_url);
     if ($friendsResponse === FALSE) {
         $this->error_page(WT_I18N::translate("Could not fetch your friends from Facebook. Note that this feature won't work for Facebook Apps created after 2014-04-30 due to a Facebook policy change."));
     }
     $controller->restrictAccess(\WT\Auth::isAdmin())->setPageTitle($this->getTitle())->pageHeader();
     $friends = json_decode($friendsResponse);
     if (empty($friends->data)) {
         $this->error_page(WT_I18N::translate("No friend data"));
         return;
     }
     function nameSort($a, $b)
     {
         return strcmp($a->last_name . " " . $a->first_name, $b->last_name . " " . $b->first_name);
     }
     usort($friends->data, "nameSort");
     echo "<form id='facebook_friend_list' method='post' action=''>";
     require_once WT_ROOT . 'includes/functions/functions_edit.php';
     // for select_edit_control
     $index = 0;
     foreach (WT_Tree::getAll() as $tree) {
         $class = $index++ % 2 ? 'odd' : 'even';
         echo "<label>" . $tree->tree_name_html . " - " . WT_I18N::translate('Role') . help_link('role') . ": " . select_edit_control('preApproved[' . $tree->tree_id . '][canedit]', $this->get_edit_options(), NULL, NULL) . "</label>";
     }
     foreach ($friends->data as $friend) {
         $facebook_username = $this->cleanseFacebookUsername(isset($friend->username) ? $friend->username : $friend->id);
         // Exclude friends who are already pre-approved or are current users
         if (isset($preApproved[$facebook_username]) || $this->get_user_id_from_facebook_username($facebook_username)) {
             continue;
         }
         echo "<label><input name='facebook_username[]' type='checkbox' value='" . $facebook_username . "'/>" . $friend->name . "</label>";
     }
     echo WT_Filter::getCsrf();
     echo "<button>Select Friends</button></form>";
 }
コード例 #4
0
ファイル: addmedia.php プロジェクト: brambravo/webtrees
use WT\Auth;
use WT\Log;
define('WT_SCRIPT_NAME', 'addmedia.php');
require './includes/session.php';
require_once WT_ROOT . 'includes/functions/functions_print_lists.php';
require WT_ROOT . 'includes/functions/functions_edit.php';
$pid = WT_Filter::get('pid', WT_REGEX_XREF, WT_Filter::post('pid', WT_REGEX_XREF));
// edit this media object
$linktoid = WT_Filter::get('linktoid', WT_REGEX_XREF, WT_Filter::post('linktoid', WT_REGEX_XREF));
// create a new media object, linked to this record
$action = WT_Filter::get('action', null, WT_Filter::post('action'));
$filename = WT_Filter::get('filename', null, WT_Filter::post('filename'));
$text = WT_Filter::postArray('text');
$tag = WT_Filter::postArray('tag', WT_REGEX_TAG);
$islink = WT_Filter::postArray('islink');
$glevels = WT_Filter::postArray('glevels', '[0-9]');
$folder = WT_Filter::post('folder');
$update_CHAN = !WT_Filter::postBool('preserve_last_changed');
$controller = new WT_Controller_Simple();
$controller->addExternalJavascript(WT_STATIC_URL . 'js/autocomplete.js')->addInlineJavascript('autocomplete();')->restrictAccess(Auth::isMember());
$disp = true;
$media = WT_Media::getInstance($pid);
if ($media) {
    $disp = $media->canShow();
}
if ($action == 'update' || $action == 'create') {
    if ($linktoid) {
        $disp = WT_GedcomRecord::getInstance($linktoid)->canShow();
    }
}
if (!WT_USER_CAN_EDIT || !$disp) {