Exemplo n.º 1
0
 /**
  * Constructor for Sosa Provider.
  * A provider is defined in relation to a specific tree and reference user.
  * 
  * @param Tree $tree
  * @param User $user
  */
 public function __construct(Tree $tree, User $user = null)
 {
     if (self::$default_user === null) {
         self::$default_user = User::find(-1);
     }
     $this->tree = $tree;
     $this->user = $user;
     $this->is_setup = true;
     if ($this->user === null) {
         $this->user = Auth::user();
     }
     if (strlen($this->user->getUserId()) == 0) {
         $this->user = self::$default_user;
     }
     // Check if the user, or the default user, has a root already setup;
     if (empty($this->getRootIndiId())) {
         if ($this->user == self::$default_user) {
             // If the default user is not setup
             $this->is_setup = false;
         } else {
             $this->user = self::$default_user;
             $this->is_setup = $this->getRootIndiId() === null;
         }
     }
 }
Exemplo n.º 2
0
    public function pageBody()
    {
        $tmp_dir = WT_DATA_DIR . 'ftv_pdf_tmp/';
        define('_JPGRAPH_PATH', $tmp_dir);
        define('_MPDF_TEMP_PATH', $tmp_dir);
        define('_MPDF_TTFONTDATAPATH', $tmp_dir);
        require_once WT_MODULES_DIR . $this->getName() . '/mpdf/mpdf.php';
        $stylesheet = file_get_contents($this->directory . '/css/style.css');
        $stylesheet_rtl = file_get_contents($this->directory . '/css/style-rtl.css');
        $html = Filter::post('pdfContent');
        $header = '<header>=== ' . $this->tree()->getTitleHtml() . ' ===</header>';
        $footer = '<footer>' . '<table><tr>' . '<td class="left">' . WT_BASE_URL . '</td>' . '<td class="center">{DATE d-m-Y}</td>' . '<td class="right">{PAGENO}</td>' . '</tr></table>' . '</footer>';
        $mpdf = new mPDF();
        $mpdf->simpleTables = true;
        $mpdf->shrink_tables_to_fit = 1;
        $mpdf->autoScriptToLang = true;
        $mpdf->baseScript = 1;
        $mpdf->autoVietnamese = true;
        $mpdf->autoArabic = true;
        $mpdf->autoLangToFont = true;
        if (I18N::direction() === 'rtl') {
            $mpdf->SetDirectionality('rtl');
            $mpdf->WriteHTML($stylesheet_rtl, 1);
        } else {
            $mpdf->WriteHTML($stylesheet, 1);
        }
        $mpdf->setAutoTopMargin = 'stretch';
        $mpdf->setAutoBottomMargin = 'stretch';
        $mpdf->autoMarginPadding = 5;
        $admin = User::find($this->tree()->getPreference('WEBMASTER_USER_ID'))->getRealName();
        $mpdf->setCreator($this->getTitle() . ' - a webtrees module by justcarmen.nl');
        $mpdf->SetTitle(Filter::get('title'));
        $mpdf->setAuthor($admin);
        $mpdf->SetHTMLHeader($header);
        $mpdf->setHTMLFooter($footer);
        $html_chunks = explode("\n", $html);
        $chunks = count($html_chunks);
        $i = 1;
        foreach ($html_chunks as $html_chunk) {
            // write html body parts only (option 2);
            if ($i === 1) {
                // first chunk (initialize all buffers - init=true)
                $mpdf->WriteHTML($html_chunk, 2, true, false);
            } elseif ($i === $chunks) {
                // last chunck (close all buffers - close=true)
                $mpdf->WriteHTML($html_chunk, 2, false, true);
            } else {
                // all other parts (keep the buffer open)
                $mpdf->WriteHTML($html_chunk, 2, false, false);
            }
            $i++;
        }
        $index = '
				<pagebreak type="next-odd" />
				<h2>' . I18N::translate('Index') . '</h2>
				<columns column-count="2" column-gap="5" />
				<indexinsert usedivletters="on" links="on" collation="' . WT_LOCALE . '.utf8" collationgroup="' . I18N::collation() . '" />';
        $mpdf->writeHTML($index);
        $mpdf->Output($tmp_dir . Filter::get('title') . '.pdf', 'F');
    }
Exemplo n.º 3
0
    public function pageBody()
    {
        $cache_dir = WT_DATA_DIR . 'ftv_cache/';
        define("_JPGRAPH_PATH", $cache_dir);
        define("_MPDF_TEMP_PATH", $cache_dir);
        define('_MPDF_TTFONTDATAPATH', $cache_dir);
        require_once WT_MODULES_DIR . $this->getName() . '/packages/mpdf60/mpdf.php';
        $tmpfile = $cache_dir . 'fancy-treeview-tmp.txt';
        if (file_exists($cache_dir) && is_readable($tmpfile)) {
            $stylesheet = file_get_contents($this->directory . '/css/pdf/style.css');
            $stylesheet_rtl = file_get_contents($this->directory . '/css/pdf/style-rtl.css');
            $html = file_get_contents($tmpfile);
            $header = '<header>=== ' . $this->tree->getTitleHtml() . ' ===</header>';
            $footer = '<footer>' . '<table><tr>' . '<td class="left">' . WT_BASE_URL . '</td>' . '<td class="center">{DATE d-m-Y}</td>' . '<td class="right">{PAGENO}</td>' . '</tr></table>' . '</footer>';
            $mpdf = new mPDF();
            $mpdf->simpleTables = true;
            $mpdf->shrink_tables_to_fit = 1;
            $mpdf->autoScriptToLang = true;
            if (I18N::direction() === 'rtl') {
                $mpdf->SetDirectionality('rtl');
            }
            if (I18N::direction() === 'rtl') {
                $mpdf->WriteHTML($stylesheet_rtl, 1);
            } else {
                $mpdf->WriteHTML($stylesheet, 1);
            }
            $mpdf->setAutoTopMargin = 'stretch';
            $mpdf->setAutoBottomMargin = 'stretch';
            $mpdf->autoMarginPadding = 5;
            $admin = User::find($this->tree->getPreference('WEBMASTER_USER_ID'))->getRealName();
            $mpdf->setCreator($this->getTitle() . ' - a webtrees module by justcarmen.nl');
            $mpdf->SetTitle(Filter::get('title'));
            $mpdf->setAuthor($admin);
            $mpdf->SetHTMLHeader($header);
            $mpdf->setHTMLFooter($footer);
            $html_chunks = explode("\n", $html);
            $chunks = count($html_chunks);
            $i = 1;
            foreach ($html_chunks as $html_chunk) {
                if ($i === 1) {
                    $mpdf->WriteHTML($html_chunk, 2, true, false);
                } elseif ($i === $chunks) {
                    $mpdf->WriteHTML($html_chunk, 2, false, false);
                } else {
                    $mpdf->WriteHTML($html_chunk, 2, false, true);
                }
                $i++;
            }
            $index = '
				<pagebreak type="next-odd" />
				<h2>' . I18N::translate('Index') . '</h2>
				<columns column-count="2" column-gap="5" />
				<indexinsert usedivletters="on" links="on" collation="' . WT_LOCALE . '.utf8" collationgroup="' . I18N::collation() . '" />';
            $mpdf->writeHTML($index);
            $mpdf->Output(Filter::get('title') . '.pdf', 'D');
        } else {
            echo $this->addMessage('alert', 'danger', false, I18N::translate('Error: the pdf file could not be generated.'));
        }
    }
Exemplo n.º 4
0
        // See http://www.datatables.net/usage/server-side
        echo json_encode(array('draw' => Filter::getInteger('draw'), 'recordsTotal' => $recordsTotal, 'recordsFiltered' => $recordsFiltered, 'data' => $data));
        return;
    case 'edit':
        $user_id = Filter::getInteger('user_id');
        if ($user_id === 0) {
            $controller->setPageTitle(I18N::translate('Add a user'));
            $tmp = new \stdClass();
            $tmp->user_id = '';
            $tmp->user_name = '';
            $tmp->real_name = '';
            $tmp->email = '';
            $user = new User($tmp);
        } else {
            $controller->setPageTitle(I18N::translate('Edit the user'));
            $user = User::find($user_id);
        }
        $controller->pageHeader()->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL)->addInlineJavascript('autocomplete();')->addInlineJavascript('
			jQuery(".relpath").change(function() {
				var fieldIDx = jQuery(this).attr("id");
				var idNum = fieldIDx.replace("RELATIONSHIP_PATH_LENGTH","");
				var newIDx = "gedcomid"+idNum;
				if (jQuery("#"+newIDx).val() === "" && jQuery("#".fieldIDx).val() !== "0") {
					alert("' . I18N::translate('You must specify an individual record before you can restrict the user to their immediate family.') . '");
					jQuery(this).val("0");
				}
			});
			function regex_quote(str) {
				return str.replace(/[\\\\.?+*()[\\](){}|]/g, "\\\\$&");
			}
		');
Exemplo n.º 5
0
 /**
  * Create a link to contact the genealogy contact.
  *
  * @return string
  */
 public function contactGedcom()
 {
     $user_id = $this->tree->getPreference('CONTACT_USER_ID');
     $user = User::find($user_id);
     if ($user) {
         return Theme::theme()->contactLink($user);
     } else {
         return $user_id;
     }
 }
Exemplo n.º 6
0
     break;
 case 'language':
     // Change the current language
     $language = Filter::post('language');
     try {
         I18N::init($language);
         Session::put('locale', $language);
         // Remember our selection
         Auth::user()->setPreference('language', $language);
     } catch (\Exception $ex) {
         // Request for a non-existant language.
         http_response_code(406);
     }
     break;
 case 'masquerade':
     $user = User::find(Filter::postInteger('user_id'));
     if ($user && Auth::isAdmin() && Auth::user() !== $user) {
         Log::addAuthenticationLog('Masquerade as user: '******'unlink-media':
     // Remove links from an individual and their spouse-family records to a media object.
     // Used by the "unlink" option on the album (lightbox) tab.
     $source = Individual::getInstance(Filter::post('source', WT_REGEX_XREF), $WT_TREE);
     $target = Filter::post('target', WT_REGEX_XREF);
     if ($source && $source->canShow() && $source->canEdit() && $target) {
         // Consider the individual and their spouse-family records
         $sources = $source->getSpouseFamilies();
Exemplo n.º 7
0
			<label for="user_hashcode">', I18N::translate('Verification code'), '</label>
			<input type="text" id="user_hashcode" name="user_hashcode" value="', $user_hashcode, '">
			</div>
			<div>
				<input type="submit" value="', I18N::translate('Send'), '">
			</div>
		</form>
	</div>';
        break;
    case 'verify_hash':
        if (!Site::getPreference('USE_REGISTRATION_MODULE')) {
            header('Location: ' . WT_BASE_URL);
            return;
        }
        // switch language to webmaster settings
        $webmaster = User::find($WT_TREE->getPreference('WEBMASTER_USER_ID'));
        I18N::init($webmaster->getPreference('language'));
        $user = User::findByUserName($user_name);
        $edit_user_url = WT_BASE_URL . "admin_users.php?action=edit&amp;user_id=" . $user->getUserId();
        $mail1_body = I18N::translate('Hello administrator…') . Mail::EOL . Mail::EOL . I18N::translate('A new user (%1$s) has requested an account (%2$s) and verified an email address (%3$s).', $user->getRealNameHtml(), Filter::escapeHtml($user->getUserName()), Filter::escapeHtml($user->getEmail())) . Mail::EOL . Mail::EOL . I18N::translate('You need to review the account details.') . Mail::EOL . Mail::EOL . '<a href="' . $edit_user_url . '">' . $edit_user_url . '</a>' . Mail::EOL . Mail::EOL . I18N::translate('Set the status to “approved”.') . Mail::EOL . I18N::translate('Set the access level for each tree.') . Mail::EOL . I18N::translate('Link the user account to an individual.');
        $mail1_subject = I18N::translate('New user at %s', WT_BASE_URL . ' ' . $WT_TREE->getTitle());
        // Change to the new user’s language
        I18N::init($user->getPreference('language'));
        $controller->setPageTitle(I18N::translate('User verification'));
        $controller->pageHeader();
        echo '<div id="login-register-page">';
        echo '<h2>' . I18N::translate('User verification') . '</h2>';
        echo '<div id="user-verify">';
        if ($user && $user->checkPassword($user_password) && $user->getPreference('reg_hashcode') === $user_hashcode) {
            Mail::send($WT_TREE, $webmaster->getEmail(), $webmaster->getRealName(), $WT_TREE->getPreference('WEBTREES_EMAIL'), $WT_TREE->getPreference('WEBTREES_EMAIL'), $mail1_subject, $mail1_body);
            $mail1_method = $webmaster->getPreference('CONTACT_METHOD');
Exemplo n.º 8
0
 /**
  * Create contact links for the page footer.
  *
  * @return string
  */
 protected function contactLinks()
 {
     $contact_user = User::find($this->tree->getPreference('CONTACT_USER_ID'));
     $webmaster_user = User::find($this->tree->getPreference('WEBMASTER_USER_ID'));
     if ($contact_user && $contact_user === $webmaster_user) {
         return $this->contactLinkEverything($contact_user);
     } elseif ($contact_user && $webmaster_user) {
         return $this->contactLinkGenealogy($contact_user) . '<br>' . $this->contactLinkTechnical($webmaster_user);
     } elseif ($contact_user) {
         return $this->contactLinkGenealogy($contact_user);
     } elseif ($webmaster_user) {
         return $this->contactLinkTechnical($webmaster_user);
     } else {
         return '';
     }
 }
Exemplo n.º 9
0
 /**
  * {@inheritDoc}
  * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\AbstractTask::executeSteps()
  */
 protected function executeSteps()
 {
     $res = false;
     // Get the number of days to take into account, either last 7 days or since last check
     $interval_sincelast = 0;
     if ($this->last_updated) {
         $tmpInt = $this->last_updated->diff(new \DateTime('now'), true);
         $interval_sincelast = ($tmpInt->days * 24 + $tmpInt->h) * 60 + $tmpInt->i;
     }
     $interval = max($this->frequency, $interval_sincelast);
     $nbdays = ceil($interval / (24 * 60));
     // Check for updates
     $latest_version_txt = Functions::fetchLatestVersion();
     if (preg_match('/^[0-9.]+\\|[0-9.]+\\|/', $latest_version_txt)) {
         list($latest_version, , $download_url) = explode('|', $latest_version_txt);
     } else {
         // Cannot determine the latest version
         list($latest_version, , $download_url) = explode('|', '||');
     }
     // Users statistics
     $warnusers = 0;
     $nverusers = 0;
     $applusers = 0;
     foreach (User::all() as $user) {
         if (date("U") - (int) $user->getPreference('reg_timestamp') > 604800 && !$user->getPreference('verified')) {
             $warnusers++;
         }
         if (!$user->getPreference('verified_by_admin') && $user->getPreference('verified')) {
             $nverusers++;
         }
         if (!$user->getPreference('verified')) {
             $applusers++;
         }
     }
     // Tree specifics checks
     $one_tree_done = false;
     foreach (Tree::getAll() as $tree) {
         $isTreeEnabled = $tree->getPreference('MAJ_AT_' . $this->getName() . '_ENABLED');
         if ((is_null($isTreeEnabled) || $isTreeEnabled) && ($webmaster = User::find($tree->getPreference('WEBMASTER_USER_ID')))) {
             I18N::init($webmaster->getPreference('language'));
             $subject = I18N::translate('Health Check Report') . ' - ' . I18N::translate('Tree %s', $tree->getTitle());
             $message = I18N::translate('Health Check Report for the last %d days', $nbdays) . Mail::EOL . Mail::EOL . I18N::translate('Tree %s', $tree->getTitle()) . Mail::EOL . '==========================================' . Mail::EOL . Mail::EOL;
             // News
             $message_version = '';
             if ($latest_version && version_compare(WT_VERSION, $latest_version) < 0) {
                 $message_version = I18N::translate('News') . Mail::EOL . '-------------' . Mail::EOL . I18N::translate('A new version of *webtrees* is available: %s. Upgrade as soon as possible.', $latest_version) . Mail::EOL . I18N::translate('Download it here: %s.', $download_url) . Mail::EOL . Mail::EOL;
             }
             $message .= $message_version;
             // Statistics users
             $message_users = I18N::translate('Users') . Mail::EOL . '-------------' . Mail::EOL . WT_BASE_URL . 'admin_users.php' . Mail::EOL . I18N::translate('Total number of users') . "\t\t" . User::count() . Mail::EOL . I18N::translate('Not verified by the user') . "\t\t" . $applusers . Mail::EOL . I18N::translate('Not approved by an administrator') . "\t" . $nverusers . Mail::EOL . Mail::EOL;
             $message .= $message_users;
             // Statistics tree:
             $stats = new Stats($tree);
             $sql = 'SELECT ged_type AS type, COUNT(change_id) AS chgcount FROM wt_change' . ' JOIN (' . ' SELECT "indi" AS ged_type, i_id AS ged_id, i_file AS ged_file FROM wt_individuals' . ' UNION SELECT "fam" AS ged_type, f_id AS ged_id, f_file AS ged_file FROM wt_families' . ' UNION SELECT "sour" AS ged_type, s_id AS ged_id, s_file AS ged_file FROM wt_sources' . ' UNION SELECT "media" AS ged_type, m_id AS ged_id, m_file AS ged_file FROM wt_media' . ' UNION SELECT LOWER(o_type) AS ged_type, o_id AS ged_id, o_file AS ged_file FROM wt_other' . ') AS gedrecords ON (xref = ged_id AND gedcom_id = ged_file)' . ' WHERE change_time >= DATE_ADD( NOW(), INTERVAL - :nb_days DAY)' . ' AND status = :status AND gedcom_id = :gedcom_id' . ' GROUP BY ged_type';
             $changes = Database::prepare($sql)->execute(array('status' => 'accepted', 'gedcom_id' => $tree->getTreeId(), 'nb_days' => $nbdays))->fetchAssoc();
             $message_gedcom = I18N::translate('Tree statistics') . Mail::EOL . '-------------' . Mail::EOL . sprintf('%-25s', I18N::translate('Records')) . "\t" . sprintf('%15s', I18N::translate('Count')) . "\t" . sprintf('%15s', I18N::translate('Changes')) . Mail::EOL . sprintf('%-25s', I18N::translate('Individuals')) . "\t" . sprintf('%15s', $stats->totalIndividuals()) . "\t" . sprintf('%15s', isset($changes['indi']) ? $changes['indi'] : 0) . Mail::EOL . sprintf('%-25s', I18N::translate('Families')) . "\t" . sprintf('%15s', $stats->totalFamilies()) . "\t" . sprintf('%15s', isset($changes['fam']) ? $changes['fam'] : 0) . Mail::EOL . sprintf('%-25s', I18N::translate('Sources')) . "\t" . sprintf('%15s', $stats->totalSources()) . "\t" . sprintf('%15s', isset($changes['sour']) ? $changes['sour'] : 0) . Mail::EOL . sprintf('%-25s', I18N::translate('Repositories')) . "\t" . sprintf('%15s', $stats->totalRepositories()) . "\t" . sprintf('%15s', isset($changes['repo']) ? $changes['repo'] : 0) . Mail::EOL . sprintf('%-25s', I18N::translate('Media objects')) . "\t" . sprintf('%15s', $stats->totalMedia()) . "\t" . sprintf('%15s', isset($changes['media']) ? $changes['media'] : 0) . Mail::EOL . sprintf('%-25s', I18N::translate('Notes')) . "\t" . sprintf('%15s', $stats->totalNotes()) . "\t" . sprintf('%15s', isset($changes['note']) ? $changes['note'] : 0) . Mail::EOL . Mail::EOL;
             $message .= $message_gedcom;
             //Errors
             $sql = 'SELECT SQL_CACHE log_message, gedcom_id, COUNT(log_id) as nblogs, MAX(log_time) as lastoccurred' . ' FROM `##log`' . ' WHERE log_type = :log_type AND (gedcom_id = :gedcom_id OR ISNULL(gedcom_id))' . ' AND log_time >= DATE_ADD( NOW(), INTERVAL - :nb_days DAY)' . ' GROUP BY log_message, gedcom_id' . ' ORDER BY lastoccurred DESC';
             $errors = Database::prepare($sql)->execute(array('log_type' => Log::TYPE_ERROR, 'gedcom_id' => $tree->getTreeId(), 'nb_days' => $nbdays))->fetchAll();
             $nb_errors = 0;
             $tmp_message = '';
             $nb_char_count_title = strlen(I18N::translate('Count'));
             $nb_char_type = max(strlen(I18N::translate('Type')), strlen(I18N::translate('Site')), strlen(I18N::translate('Tree')));
             foreach ($errors as $error) {
                 $tmp_message .= sprintf('%' . $nb_char_count_title . 'd', $error->nblogs) . "\t";
                 $tmp_message .= sprintf('%' . $nb_char_type . 's', is_null($error->gedcom_id) ? I18N::translate('Site') : I18N::translate('Tree'));
                 $tmp_message .= "\t" . sprintf('%20s', $error->lastoccurred) . "\t";
                 $tmp_message .= str_replace("\n", "\n\t\t\t\t\t\t", $error->log_message) . Mail::EOL;
                 $nb_errors += $error->nblogs;
             }
             if ($nb_errors > 0) {
                 $message .= I18N::translate('Errors [%d]', $nb_errors) . Mail::EOL . '-------------' . Mail::EOL . WT_BASE_URL . 'admin_site_logs.php' . Mail::EOL . I18N::translate('Count') . "\t" . sprintf('%-' . $nb_char_type . 's', I18N::translate('Type')) . "\t" . sprintf('%-20s', I18N::translate('Last occurrence')) . "\t" . I18N::translate('Error') . Mail::EOL . str_repeat('-', $nb_char_count_title) . "\t" . str_repeat('-', $nb_char_type) . "\t" . str_repeat('-', 20) . "\t" . str_repeat('-', strlen(I18N::translate('Error'))) . Mail::EOL . $tmp_message . Mail::EOL;
             } else {
                 $message .= I18N::translate('No errors', $nb_errors) . Mail::EOL . Mail::EOL;
             }
             $tmpres = true;
             if ($webmaster->getPreference('contactmethod') !== 'messaging' && $webmaster->getPreference('contactmethod') !== 'none') {
                 $tmpres = Mail::systemMessage($tree, $webmaster, $subject, $message);
             }
             $res = $tmpres && (!$one_tree_done || $one_tree_done && $res);
             $one_tree_done = true;
         }
     }
     return $res;
 }
Exemplo n.º 10
0
 /**
  * SosaConfig@computePartial
  */
 public function computePartial()
 {
     global $WT_TREE;
     $controller = new AjaxController();
     $controller->restrictAccess($this->canUpdate());
     $view_bag = new ViewBag();
     $view_bag->set('is_success', false);
     $user = User::find(Filter::getInteger('userid', -1));
     $indi = Individual::getInstance(Filter::get('pid', WT_REGEX_XREF), $WT_TREE);
     if ($user && $indi) {
         $calculator = new SosaCalculator($WT_TREE, $user);
         if ($calculator->computeFromIndividual($indi)) {
             $view_bag->set('is_success', true);
         }
     } else {
         $view_bag->set('error', I18N::translate('Non existing individual'));
     }
     ViewFactory::make('SosaComputeResult', $this, $controller, $view_bag)->render();
 }
Exemplo n.º 11
0
 /**
  * Create the clippings controller
  */
 public function __construct()
 {
     global $WT_TREE;
     // Our cart is an array of items in the session
     $this->cart = Session::get('cart', array());
     if (!array_key_exists($WT_TREE->getTreeId(), $this->cart)) {
         $this->cart[$WT_TREE->getTreeId()] = array();
     }
     $this->action = Filter::get('action');
     $this->id = Filter::get('id');
     $convert = Filter::get('convert', 'yes|no', 'no');
     $this->Zip = Filter::get('Zip');
     $this->IncludeMedia = Filter::get('IncludeMedia');
     $this->conv_path = Filter::get('conv_path');
     $this->privatize_export = Filter::get('privatize_export', 'none|visitor|user|gedadmin', 'visitor');
     $this->level1 = Filter::getInteger('level1');
     $this->level2 = Filter::getInteger('level2');
     $this->level3 = Filter::getInteger('level3');
     $others = Filter::get('others');
     $this->type = Filter::get('type');
     if (($this->privatize_export === 'none' || $this->privatize_export === 'none') && !Auth::isManager($WT_TREE)) {
         $this->privatize_export = 'visitor';
     }
     if ($this->privatize_export === 'user' && !Auth::isMember($WT_TREE)) {
         $this->privatize_export = 'visitor';
     }
     if ($this->action === 'add') {
         if (empty($this->type) && !empty($this->id)) {
             $obj = GedcomRecord::getInstance($this->id, $WT_TREE);
             if ($obj) {
                 $this->type = $obj::RECORD_TYPE;
             } else {
                 $this->type = '';
                 $this->id = '';
                 $this->action = '';
             }
         } elseif (empty($this->id)) {
             $this->action = '';
         }
         if (!empty($this->id) && $this->type !== 'FAM' && $this->type !== 'INDI' && $this->type !== 'SOUR') {
             $this->action = 'add1';
         }
     }
     if ($this->action === 'add1') {
         $obj = GedcomRecord::getInstance($this->id, $WT_TREE);
         $this->addClipping($obj);
         if ($this->type === 'SOUR') {
             if ($others === 'linked') {
                 foreach ($obj->linkedIndividuals('SOUR') as $indi) {
                     $this->addClipping($indi);
                 }
                 foreach ($obj->linkedFamilies('SOUR') as $fam) {
                     $this->addClipping($fam);
                 }
             }
         }
         if ($this->type === 'FAM') {
             if ($others === 'parents') {
                 $this->addClipping($obj->getHusband());
                 $this->addClipping($obj->getWife());
             } elseif ($others === "members") {
                 $this->addFamilyMembers(Family::getInstance($this->id, $WT_TREE));
             } elseif ($others === "descendants") {
                 $this->addFamilyDescendancy(Family::getInstance($this->id, $WT_TREE));
             }
         } elseif ($this->type === 'INDI') {
             if ($others === 'parents') {
                 foreach (Individual::getInstance($this->id, $WT_TREE)->getChildFamilies() as $family) {
                     $this->addFamilyMembers($family);
                 }
             } elseif ($others === 'ancestors') {
                 $this->addAncestorsToCart(Individual::getInstance($this->id, $WT_TREE), $this->level1);
             } elseif ($others === 'ancestorsfamilies') {
                 $this->addAncestorsToCartFamilies(Individual::getInstance($this->id, $WT_TREE), $this->level2);
             } elseif ($others === 'members') {
                 foreach (Individual::getInstance($this->id, $WT_TREE)->getSpouseFamilies() as $family) {
                     $this->addFamilyMembers($family);
                 }
             } elseif ($others === 'descendants') {
                 foreach (Individual::getInstance($this->id, $WT_TREE)->getSpouseFamilies() as $family) {
                     $this->addClipping($family);
                     $this->addFamilyDescendancy($family, $this->level3);
                 }
             }
             uksort($this->cart[$WT_TREE->getTreeId()], array($this, 'compareClippings'));
         }
     } elseif ($this->action === 'remove') {
         unset($this->cart[$WT_TREE->getTreeId()][$this->id]);
     } elseif ($this->action === 'empty') {
         $this->cart[$WT_TREE->getTreeId()] = array();
     } elseif ($this->action === 'download') {
         $media = array();
         $mediacount = 0;
         $filetext = FunctionsExport::gedcomHeader($WT_TREE);
         // Include SUBM/SUBN records, if they exist
         $subn = Database::prepare("SELECT o_gedcom FROM `##other` WHERE o_type=? AND o_file=?")->execute(array('SUBN', $WT_TREE->getTreeId()))->fetchOne();
         if ($subn) {
             $filetext .= $subn . "\n";
         }
         $subm = Database::prepare("SELECT o_gedcom FROM `##other` WHERE o_type=? AND o_file=?")->execute(array('SUBM', $WT_TREE->getTreeId()))->fetchOne();
         if ($subm) {
             $filetext .= $subm . "\n";
         }
         if ($convert === "yes") {
             $filetext = str_replace("UTF-8", "ANSI", $filetext);
             $filetext = utf8_decode($filetext);
         }
         switch ($this->privatize_export) {
             case 'gedadmin':
                 $access_level = Auth::PRIV_NONE;
                 break;
             case 'user':
                 $access_level = Auth::PRIV_USER;
                 break;
             case 'visitor':
                 $access_level = Auth::PRIV_PRIVATE;
                 break;
             case 'none':
                 $access_level = Auth::PRIV_HIDE;
                 break;
         }
         foreach (array_keys($this->cart[$WT_TREE->getTreeId()]) as $xref) {
             $object = GedcomRecord::getInstance($xref, $WT_TREE);
             // The object may have been deleted since we added it to the cart....
             if ($object) {
                 $record = $object->privatizeGedcom($access_level);
                 // Remove links to objects that aren't in the cart
                 preg_match_all('/\\n1 ' . WT_REGEX_TAG . ' @(' . WT_REGEX_XREF . ')@(\\n[2-9].*)*/', $record, $matches, PREG_SET_ORDER);
                 foreach ($matches as $match) {
                     if (!array_key_exists($match[1], $this->cart[$WT_TREE->getTreeId()])) {
                         $record = str_replace($match[0], '', $record);
                     }
                 }
                 preg_match_all('/\\n2 ' . WT_REGEX_TAG . ' @(' . WT_REGEX_XREF . ')@(\\n[3-9].*)*/', $record, $matches, PREG_SET_ORDER);
                 foreach ($matches as $match) {
                     if (!array_key_exists($match[1], $this->cart[$WT_TREE->getTreeId()])) {
                         $record = str_replace($match[0], '', $record);
                     }
                 }
                 preg_match_all('/\\n3 ' . WT_REGEX_TAG . ' @(' . WT_REGEX_XREF . ')@(\\n[4-9].*)*/', $record, $matches, PREG_SET_ORDER);
                 foreach ($matches as $match) {
                     if (!array_key_exists($match[1], $this->cart[$WT_TREE->getTreeId()])) {
                         $record = str_replace($match[0], '', $record);
                     }
                 }
                 $record = FunctionsExport::convertMediaPath($record, $this->conv_path);
                 $savedRecord = $record;
                 // Save this for the "does this file exist" check
                 if ($convert === 'yes') {
                     $record = utf8_decode($record);
                 }
                 switch ($object::RECORD_TYPE) {
                     case 'INDI':
                         $filetext .= $record . "\n";
                         $filetext .= "1 SOUR @WEBTREES@\n";
                         $filetext .= "2 PAGE " . WT_BASE_URL . $object->getRawUrl() . "\n";
                         break;
                     case 'FAM':
                         $filetext .= $record . "\n";
                         $filetext .= "1 SOUR @WEBTREES@\n";
                         $filetext .= "2 PAGE " . WT_BASE_URL . $object->getRawUrl() . "\n";
                         break;
                     case 'SOUR':
                         $filetext .= $record . "\n";
                         $filetext .= "1 NOTE " . WT_BASE_URL . $object->getRawUrl() . "\n";
                         break;
                     default:
                         // This autoloads the PclZip library, so we can use its constants.
                         new PclZip('');
                         $ft = preg_match_all("/\n\\d FILE (.+)/", $savedRecord, $match, PREG_SET_ORDER);
                         $MEDIA_DIRECTORY = $WT_TREE->getPreference('MEDIA_DIRECTORY');
                         for ($k = 0; $k < $ft; $k++) {
                             // Skip external files and non-existant files
                             if (file_exists(WT_DATA_DIR . $MEDIA_DIRECTORY . $match[$k][1])) {
                                 $media[$mediacount] = array(\PCLZIP_ATT_FILE_NAME => WT_DATA_DIR . $MEDIA_DIRECTORY . $match[$k][1], \PCLZIP_ATT_FILE_NEW_FULL_NAME => $match[$k][1]);
                                 $mediacount++;
                             }
                         }
                         $filetext .= trim($record) . "\n";
                         break;
                 }
             }
         }
         if ($this->IncludeMedia === "yes") {
             $this->media_list = $media;
         } else {
             $this->media_list = array();
         }
         $filetext .= "0 @WEBTREES@ SOUR\n1 TITL " . WT_BASE_URL . "\n";
         if ($user_id = $WT_TREE->getPreference('CONTACT_EMAIL')) {
             $user = User::find($user_id);
             $filetext .= "1 AUTH " . $user->getRealName() . "\n";
         }
         $filetext .= "0 TRLR\n";
         //-- make sure the preferred line endings are used
         $filetext = preg_replace("/[\r\n]+/", WT_EOL, $filetext);
         $this->download_data = $filetext;
         $this->downloadClipping();
     }
     Session::put('cart', $this->cart);
 }
Exemplo n.º 12
0
 /**
  * {@inheritDoc}
  * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\PageFooterExtenderInterface::hPrintFooter()
  */
 public function hPrintFooter()
 {
     global $WT_TREE;
     $html = '';
     if ($this->getSetting('MAJ_DISPLAY_CNIL', 0) == 1) {
         $html .= '<br/>';
         $html .= '<div class="center">';
         $cnil_ref = $this->getSetting('MAJ_CNIL_REFERENCE', '');
         if ($cnil_ref != '') {
             $html .= I18N::translate('This site has been notified to the French National Commission for Data protection (CNIL) and registered under number %s. ', $cnil_ref);
         }
         $html .= I18N::translate('In accordance with the French Data protection Act (<em>Loi Informatique et Libertés</em>) of January 6th, 1978, you have the right to access, modify, rectify and delete personal information that pertains to you. To exercice this right, please contact %s, and provide your name, address and a proof of your identity.', Theme::theme()->contactLink(User::find($WT_TREE->getPreference('WEBMASTER_USER_ID'))));
         $html .= '</div>';
     }
     if ($this->getSetting('MAJ_ADD_HTML_FOOTER', 0) == 1) {
         if (Auth::accessLevel($WT_TREE) >= $this->getSetting('MAJ_SHOW_HTML_FOOTER', Auth::PRIV_HIDE) && !Filter::getBool('nofooter')) {
             $html .= $this->getSetting('MAJ_HTML_FOOTER', '');
         }
     }
     return $html;
 }