Exemple #1
0
 function view()
 {
     $database = mamboDatabase::getInstance();
     $query = "SELECT a.*, a.id AS value, CONCAT_WS( ' - ', a.name, a.con_position ) AS text" . "\n FROM #__contact_details AS a" . "\n LEFT JOIN #__categories AS cc ON cc.id = a.catid" . "\n WHERE a.published = '1'" . "\n AND cc.published = '1'" . "\n AND a.access <=" . $this->user->gid . "\n AND cc.access <=" . $this->user->gid . "\n ORDER BY a.default_con DESC, a.ordering ASC";
     $database->setQuery($query);
     $list = $database->loadObjectList();
     $count = count($list);
     if ($count == 0) {
         $params =& new mosParameters('');
         $params->def('back_button', mamboCore::get('mosConfig_back_button'));
         HTML_contact::nocontact($params);
         return;
     }
     if ($this->contact_id == 0) {
         $this->contact_id = $list[0]->id;
     }
     foreach ($list as $cont) {
         if ($cont->id == $this->contact_id) {
             $contact =& $cont;
             break;
         }
     }
     if (!isset($contact)) {
         echo T_('You are not authorized to view this resource.');
         return;
     }
     // creates dropdown select list
     $contact->select = mosHTML::selectList($list, 'contact_id', 'class="inputbox" onchange="ViewCrossReference(this);"', 'value', 'text', $this->contact_id);
     // Adds parameter handling
     $params =& $this->makeParams($contact->params);
     // load mambot params info
     $query = "SELECT id FROM #__mambots WHERE element = 'mosemailcloak' AND folder = 'content'";
     $database->setQuery($query);
     $id = $database->loadResult();
     $mambot = new mosMambot($database);
     $mambot->load($id);
     $params2 =& $this->makeParams($mambot->params);
     if ($contact->email_to and $params->get('email')) {
         // email cloacking
         $contact->email = mosHTML::emailCloaking($contact->email_to, $params2->get('mode'));
     }
     // loads current template for the pop-up window
     $pop = mosGetParam($_REQUEST, 'pop', 0);
     if ($pop) {
         $params->set('popup', 1);
         $params->set('back_button', 0);
     }
     if ($params->get('email_description')) {
         $params->set('email_description', $params->get('email_description_text'));
     } else {
         $params->set('email_description', '');
     }
     // needed to control the display of the Address marker
     $temp = $params->get('street_address') . $params->get('suburb') . $params->get('state') . $params->get('country') . $params->get('postcode');
     $params->set('address_check', $temp);
     // determines whether to use Text, Images or nothing to highlight the different info groups
     $this->groupMarking($params);
     // params from menu item
     $menuhandler = mosMenuHandler::getInstance();
     $menu =& $menuhandler->getMenuByID($this->Itemid);
     $menu_params =& new mosParameters($menu->params);
     $menu_params->def('page_title', 1);
     $menu_params->def('header', $menu->name);
     $menu_params->def('pageclass_sfx', '');
     HTML_contact::viewcontact($contact, $params, $count, $list, $menu_params);
 }
Exemple #2
0
function contactpage($contact_id)
{
    global $mainframe, $database, $my, $Itemid;
    $query = "SELECT a.id AS value, CONCAT_WS( ' - ', a.name, a.con_position ) AS text, a.catid, cc.access AS cat_access" . "\n FROM #__contact_details AS a" . "\n LEFT JOIN #__categories AS cc ON cc.id = a.catid" . "\n WHERE a.published = 1" . "\n AND cc.published = 1" . "\n AND a.access <= " . (int) $my->gid . "\n ORDER BY a.default_con DESC, a.ordering ASC";
    $database->setQuery($query);
    $checks = $database->loadObjectList();
    $count = count($checks);
    if ($count) {
        if ($contact_id < 1) {
            $contact_id = $checks[0]->value;
        }
        $query = "SELECT a.*, cc.access AS cat_access" . "\n FROM #__contact_details AS a" . "\n LEFT JOIN #__categories AS cc ON cc.id = a.catid" . "\n WHERE a.published = 1" . "\n AND a.id = " . (int) $contact_id . "\n AND a.access <= " . (int) $my->gid;
        $database->SetQuery($query);
        $contacts = $database->LoadObjectList();
        if (!$contacts) {
            echo _NOT_AUTH;
            return;
        }
        $contact = $contacts[0];
        /*
         * check whether category access level allows access
         */
        if ($contact->cat_access > $my->gid) {
            mosNotAuth();
            return;
        }
        $list = array();
        foreach ($checks as $check) {
            if ($check->catid == $contact->catid) {
                $list[] = $check;
            }
        }
        // creates dropdown select list
        $contact->select = mosHTML::selectList($list, 'contact_id', 'class="inputbox" onchange="ViewCrossReference(this);"', 'value', 'text', $contact_id);
        // Adds parameter handling
        $params = new mosParameters($contact->params);
        $params->set('page_title', 0);
        $params->def('pageclass_sfx', '');
        $params->def('back_button', $mainframe->getCfg('back_button'));
        $params->def('print', !$mainframe->getCfg('hidePrint'));
        $params->def('name', 1);
        $params->def('email', 0);
        $params->def('street_address', 1);
        $params->def('suburb', 1);
        $params->def('state', 1);
        $params->def('country', 1);
        $params->def('postcode', 1);
        $params->def('telephone', 1);
        $params->def('fax', 1);
        $params->def('misc', 1);
        $params->def('image', 1);
        $params->def('email_description', 1);
        $params->def('email_description_text', _EMAIL_DESCRIPTION);
        $params->def('email_form', 1);
        $params->def('email_copy', 0);
        // global pront|pdf|email
        $params->def('icons', $mainframe->getCfg('icons'));
        // contact only icons
        $params->def('contact_icons', 0);
        $params->def('icon_address', '');
        $params->def('icon_email', '');
        $params->def('icon_telephone', '');
        $params->def('icon_fax', '');
        $params->def('icon_misc', '');
        $params->def('drop_down', 0);
        $params->def('vcard', 0);
        if ($contact->email_to && $params->get('email')) {
            // email cloacking
            $contact->email = mosHTML::emailCloaking($contact->email_to);
        }
        // loads current template for the pop-up window
        $pop = intval(mosGetParam($_REQUEST, 'pop', 0));
        if ($pop) {
            $params->set('popup', 1);
            $params->set('back_button', 0);
        }
        if ($params->get('email_description')) {
            $params->set('email_description', $params->get('email_description_text'));
        } else {
            $params->set('email_description', '');
        }
        // needed to control the display of the Address marker
        $temp = $params->get('street_address') . $params->get('suburb') . $params->get('state') . $params->get('country') . $params->get('postcode');
        $params->set('address_check', $temp);
        // determines whether to use Text, Images or nothing to highlight the different info groups
        switch ($params->get('contact_icons')) {
            case 1:
                // text
                $params->set('marker_address', _CONTACT_ADDRESS);
                $params->set('marker_email', _CONTACT_EMAIL);
                $params->set('marker_telephone', _CONTACT_TELEPHONE);
                $params->set('marker_fax', _CONTACT_FAX);
                $params->set('marker_misc', _CONTACT_MISC);
                $params->set('column_width', '100');
                break;
            case 2:
                // none
                $params->set('marker_address', '');
                $params->set('marker_email', '');
                $params->set('marker_telephone', '');
                $params->set('marker_fax', '');
                $params->set('marker_misc', '');
                $params->set('column_width', '0');
                break;
            default:
                // icons
                $image1 = mosAdminMenus::ImageCheck('con_address.png', '/images/M_images/', $params->get('icon_address'), '/images/M_images/', _CONTACT_ADDRESS, _CONTACT_ADDRESS);
                $image2 = mosAdminMenus::ImageCheck('emailButton.png', '/images/M_images/', $params->get('icon_email'), '/images/M_images/', _CONTACT_EMAIL, _CONTACT_EMAIL);
                $image3 = mosAdminMenus::ImageCheck('con_tel.png', '/images/M_images/', $params->get('icon_telephone'), '/images/M_images/', _CONTACT_TELEPHONE, _CONTACT_TELEPHONE);
                $image4 = mosAdminMenus::ImageCheck('con_fax.png', '/images/M_images/', $params->get('icon_fax'), '/images/M_images/', _CONTACT_FAX, _CONTACT_FAX);
                $image5 = mosAdminMenus::ImageCheck('con_info.png', '/images/M_images/', $params->get('icon_misc'), '/images/M_images/', _CONTACT_MISC, _CONTACT_MISC);
                $params->set('marker_address', $image1);
                $params->set('marker_email', $image2);
                $params->set('marker_telephone', $image3);
                $params->set('marker_fax', $image4);
                $params->set('marker_misc', $image5);
                $params->set('column_width', '40');
                break;
        }
        // params from menu item
        $menu = $mainframe->get('menu');
        $menu_params = new mosParameters($menu->params);
        $menu_params->def('page_title', 1);
        $menu_params->def('header', $menu->name);
        $menu_params->def('pageclass_sfx', '');
        HTML_contact::viewcontact($contact, $params, $count, $list, $menu_params);
    } else {
        $params = new mosParameters('');
        $params->def('back_button', $mainframe->getCfg('back_button'));
        HTML_contact::nocontact($params);
    }
}