Esempio n. 1
0
 public function __construct($photos = true, $freetext = null)
 {
     PlVCard::$folding = false;
     $this->visibility = Visibility::defaultForRead(Visibility::VIEW_PRIVATE);
     $this->freetext = $freetext;
     $this->photos = $photos;
 }
Esempio n. 2
0
 public function __construct(array $pids, array $types, array $jobids, $visibility, $_where)
 {
     $where = array();
     if (!is_null($_where)) {
         $where[] = $_where;
     }
     if (count($pids) != 0) {
         $where[] = XDB::format('(pa.pid IN {?})', $pids);
     }
     if (count($types) != 0) {
         $where[] = XDB::format('(pa.type IN {?})', $types);
     }
     if (count($jobids) != 0) {
         $where[] = XDB::format('(pa.jobid IN {?})', $jobids);
     }
     if ($visibility == null || !$visibility instanceof Visibility) {
         $visibility = Visibility::defaultForRead();
     }
     $where[] = 'pve.best_display_level+0 <= pa.pub+0';
     $sql = 'SELECT  pa.pid, pa.jobid, pa.groupid, pa.type, pa.id, pa.flags, pa.text, pa.postalText, pa.pub, pa.comment,
                     pa.types, pa.formatted_address, pa.location_type, pa.partial_match, pa.latitude, pa.longitude,
                     pa.southwest_latitude, pa.southwest_longitude, pa.northeast_latitude, pa.northeast_longitude,
                     pa.geocoding_date, pa.geocoding_calls,
                     GROUP_CONCAT(DISTINCT pc.component_id SEPARATOR \',\') AS componentsIds,
                     GROUP_CONCAT(pace1.long_name) AS postalCode, GROUP_CONCAT(pace2.long_name) AS locality,
                     GROUP_CONCAT(pace3.long_name) AS administrativeArea, GROUP_CONCAT(pace4.long_name) AS country
               FROM  profile_addresses                 AS pa
          LEFT JOIN  profile_addresses_components      AS pc    ON (pa.pid = pc.pid AND pa.jobid = pc.jobid AND pa.groupid = pc.groupid
                                                                    AND pa.type = pc.type AND pa.id = pc.id)
          LEFT JOIN  profile_addresses_components_enum AS pace1 ON (FIND_IN_SET(\'postal_code\', pace1.types) AND pace1.id = pc.component_id)
          LEFT JOIN  profile_addresses_components_enum AS pace2 ON (FIND_IN_SET(\'locality\', pace2.types) AND pace2.id = pc.component_id)
          LEFT JOIN  profile_addresses_components_enum AS pace3 ON (FIND_IN_SET(\'administrative_area_level_1\', pace3.types) AND pace3.id = pc.component_id)
          LEFT JOIN  profile_addresses_components_enum AS pace4 ON (FIND_IN_SET(\'country\', pace4.types) AND pace4.id = pc.component_id)
          LEFT JOIN  profile_visibility_enum AS pve ON (pve.access_level = {?})
              WHERE  ' . implode(' AND ', $where) . '
           GROUP BY  pa.pid, pa.jobid, pa.groupid, pa.type, pa.id
           ORDER BY  pa.pid, pa.jobid, pa.id';
     $this->dbiter = XDB::iterator($sql, $visibility->level());
     $this->visibility = $visibility;
 }
Esempio n. 3
0
 public function __construct($cond = null, $sort = null)
 {
     if (empty($this->joinMethods)) {
         $class = new ReflectionClass('UserFilter');
         foreach ($class->getMethods() as $method) {
             $name = $method->getName();
             if (substr($name, -5) == 'Joins' && $name != 'buildJoins') {
                 $this->joinMethods[] = $name;
             }
         }
     }
     if (!is_null($cond)) {
         if ($cond instanceof PlFilterCondition) {
             $this->setCondition($cond);
         }
     }
     if (!is_null($sort)) {
         if ($sort instanceof PlFilterOrder) {
             $this->addSort($sort);
         } else {
             if (is_array($sort)) {
                 foreach ($sort as $s) {
                     $this->addSort($s);
                 }
             }
         }
     }
     // This will set the visibility to the default correct level.
     $this->visibility = Visibility::defaultForRead();
 }
Esempio n. 4
0
 public function __construct(PlIterator $it, array $pids, $fields = 0x0, $visibility = null)
 {
     require_once 'profilefields.inc.php';
     if ($visibility === null) {
         $visibility = Visibility::defaultForRead();
     }
     $this->fields = $fields;
     $this->visibility = $visibility;
     $subits = array();
     $callbacks = array();
     $subits[0] = $it;
     $callbacks[0] = PlIteratorUtils::arrayValueCallback('pid');
     $cb = PlIteratorUtils::objectPropertyCallback('pid');
     $fields = $fields & self::FETCH_ALL;
     for ($field = 1; $field < $fields; $field *= 2) {
         if ($fields & $field) {
             $callbacks[$field] = $cb;
             $subits[$field] = new ProfileFieldIterator($field, $pids, $visibility);
         }
     }
     $this->iterator = PlIteratorUtils::parallelIterator($subits, $callbacks, 0);
 }
Esempio n. 5
0
 public function apply(PlPage $page)
 {
     if ($this->set instanceof UserSet) {
         $uids = $this->set->getIds(new PlLimit());
         $pids = Profile::getPIDsFromUIDs($uids);
     } else {
         $pids = $this->set->getIds(new PlLimit());
     }
     $visibility = Visibility::defaultForRead(Visibility::VIEW_AX);
     pl_cached_content_headers('text/x-csv', 'iso-8859-1', 1, 'adresses.csv');
     $csv = fopen('php://output', 'w');
     fputcsv($csv, array('AX_ID', 'PROMOTION', 'CIVILITE', 'NOM', 'PRENOM', 'SOCIETE', 'ADRESSE', 'ADRESSE1', 'ADRESSE2', 'ADRESSE3', 'CP', 'EMAIL', 'NHABITE_PLUS_A_LADRESSE'), ';');
     if (!empty($pids)) {
         $res = XDB::query("SELECT  p.ax_id, pd.promo, p.title,\n                                       IF (pn.firstname_ordinary = '', UPPER(pn.firstname_main), UPPER(pn.firstname_ordinary)) AS firstname,\n                                       IF (pn.lastname_ordinary = '', UPPER(pn.lastname_main), UPPER(pn.lastname_ordinary)) AS lastname,\n                                       UPPER(pje.name), pa.postalText, pa.postal_code_fr AS postal_code, p.email_directory,\n                                       IF (FIND_IN_SET('deliveryIssue', pa.flags), 'oui', '') AS delivery_issue\n                                 FROM  profile_addresses    AS pa\n                           INNER JOIN  profiles             AS p    ON (pa.pid = p.pid)\n                           INNER JOIN  profile_display      AS pd   ON (pd.pid = pa.pid)\n                           INNER JOIN  profile_public_names AS pn   ON (pn.pid = pa.pid)\n                            LEFT JOIN  profile_job          AS pj   ON (pj.pid = pa.pid\n                                                                        AND pj.id = IF(pa.type = 'job', pa.id, NULL))\n                            LEFT JOIN  profile_job_enum     AS pje  ON (pj.jobid = pje.id)\n                                WHERE  pa.pid IN {?} AND FIND_IN_SET('dn_best_mail', pa.flags)", $pids);
         foreach ($res->fetchAllRow() as $item) {
             list($axid, $promo, $title, $lastname, $firstname, $company, $full_address, $zipcode, $email, $delivery_issue) = array_map('utf8_decode', $item);
             $lines = self::split_address($full_address);
             fputcsv($csv, array($axid, $promo, $title, $lastname, $firstname, $company, $full_address, $lines[0], $lines[1], $lines[2], $zipcode, $email, $delivery_issue), ';');
         }
     }
     fclose($csv);
     exit;
 }
Esempio n. 6
0
 public function __construct(array $pids, array $link_types, array $link_ids, $visibility)
 {
     $where = array();
     if (count($pids) != 0) {
         $where[] = XDB::format('(pid IN {?})', $pids);
     }
     if (count($link_types) != 0) {
         $where[] = XDB::format('(link_type IN {?})', $link_types);
     }
     if (count($link_ids) != 0) {
         $where[] = XDB::format('(link_id IN {?})', $link_ids);
     }
     if ($visibility == null || !$visibility instanceof Visibility) {
         $visibility = Visibility::defaultForRead();
     }
     $where[] = 'pve.best_display_level+0 <= pub+0';
     $sql = 'SELECT  search_tel AS search, display_tel AS display, comment, link_id,
                     tel_type AS type, link_type, tel_id AS id, pid, pub
               FROM  profile_phones
          LEFT JOIN  profile_visibility_enum AS pve ON (pve.access_level = {?})
              WHERE  ' . implode(' AND ', $where) . '
           ORDER BY  pid, link_id, tel_id';
     $this->dbiter = XDB::iterator($sql, $visibility->level());
 }
Esempio n. 7
0
 public static function preload($pids = array())
 {
     if (self::$fullload) {
         return;
     }
     // Load raw data
     if (count($pids)) {
         $join = 'LEFT JOIN profile_job ON (profile_job.jobid = pje.id)';
         $where = 'WHERE profile_job.pid IN ' . XDB::formatArray($pids);
     } else {
         $join = '';
         $where = '';
     }
     $it = XDB::iterator('SELECT  pje.id, pje.name, pje.acronym, pje.url,
                                  pa.flags, pa.text, pa.type, pa.pub
                            FROM  profile_job_enum AS pje
                       LEFT JOIN  profile_addresses AS pa ON (pje.id = pa.jobid AND pa.type = \'hq\')
                               ' . $join . '
                               ' . $where);
     $newcompanies = array();
     while ($row = $it->next()) {
         $cp = new Company($row);
         $addr = new Address($row);
         $cp->setAddress($addr);
         if (!array_key_exists($row['id'], self::$companies)) {
             $newcompanies[] = $row['id'];
         }
         self::$companies[$row['id']] = $cp;
     }
     // Add phones to hq
     if (count($newcompanies)) {
         $it = Phone::iterate(array(), array(Phone::LINK_COMPANY), $newcompanies, Visibility::defaultForRead());
         while ($phone = $it->next()) {
             self::$companies[$phone->link_id]->setPhone($phone);
         }
     }
     if (count($pids) == 0) {
         self::$fullload = true;
     }
 }
Esempio n. 8
0
 function handler_profile($page, $id = null)
 {
     // Checks if the identifier corresponds to an actual profile. Numeric
     // identifiers canonly be user by logged users.
     if (is_null($id)) {
         return PL_NOT_FOUND;
     }
     // Determines the access level at which the profile will be displayed.
     // Note: VIEW_HIDDEN can NOT be selected. The admins who want to read
     // information need to use the "edit profile" pages instead.
     if (Env::v('view') == 'public') {
         $view = Visibility::VIEW_PUBLIC;
     } else {
         if (Env::v('view') == 'ax') {
             $view = Visibility::VIEW_AX;
         } else {
             $view = Visibility::VIEW_PRIVATE;
         }
     }
     $visibility = Visibility::defaultForRead($view);
     // Display pending picture
     if (S::logged() && Env::v('modif') == 'new') {
         $page->assign('with_pending_pic', true);
     }
     $pid = !is_numeric($id) || S::admin() ? Profile::getPID($id) : null;
     if (is_null($pid)) {
         $owner = User::getSilent($id);
         if ($owner) {
             $profile = $owner->profile(true, Profile::FETCH_ALL, $visibility);
             if ($profile) {
                 $pid = $profile->id();
             }
         }
     } else {
         // Fetches profile's and profile's owner information and redirects to
         // marketing if the owner has not subscribed and the requirer has logged in.
         $profile = Profile::get($pid, Profile::FETCH_ALL, $visibility);
         $owner = $profile->owner();
     }
     if (is_null($pid)) {
         if (S::logged()) {
             $page->kill($id . " inconnu dans l'annuaire.");
         }
         return PL_NOT_FOUND;
     }
     // Now that we know this is an existing profile, we can switch to the
     // appropriate template.
     $page->changeTpl('profile/profile.tpl', SIMPLE);
     // Profile view are logged.
     if (S::logged()) {
         S::logger()->log('view_profile', $profile->hrid());
     }
     // Sets the title of the html page.
     $page->setTitle($profile->fullName());
     // Determines and displays the virtual alias.
     if (!is_null($owner) && $profile->isVisible($profile->alias_pub)) {
         $page->assign('virtualalias', $owner->emailAlias());
     }
     $page->assign_by_ref('profile', $profile);
     $page->assign_by_ref('owner', $owner);
     $page->assign('view', $visibility);
     $page->assign('logged', S::logged());
     header('Last-Modified: ' . date('r', strtotime($profile->last_change)));
 }