const JOBS_FINISHED = 0x004000;
const JOBS_CURRENT = 0x008000;
+ const NETWORKING_ALL = 0x000000;
+ const NETWORKING_WEB = 0x010000;
+ const NETWORKING_IM = 0x020000;
+ const NETWORKING_SOCIAL = 0x040000;
+
private $pid;
private $hrpid;
private $data = array();
$this->data = $data;
$this->pid = $this->data['pid'];
$this->hrpid = $this->data['hrpid'];
+ if (!S::logged()) {
+ $this->setVisibilityLevel(self::VISIBILITY_PUBLIC);
+ }
}
public function id()
}
+ /** Networking
+ */
+
+ public function getNetworking($flags, $limit = null)
+ {
+ $where = XDB::format('pn.uid = {?}', $this->id());
+ if ($flags & self::NETWORKING_WEB) {
+ $where .= ' AND pn.network_type = 0'; // XXX hardcoded reference to web site index
+ }
+ if ($this->visibility) {
+ $where .= ' AND pn.pub IN ' . XDB::formatArray($this->visibility);
+ }
+ $limit = is_null($limit) ? '' : XDB::format('LIMIT {?}', (int)$limit);
+ return XDB::iterator('SELECT pne.name, pne.icon,
+ IF (LENGTH(pne.link) > 0, REPLACE(pne.link, \'%s\', pn.address),
+ pn.address) AS address
+ FROM profile_networking AS pn
+ INNER JOIN profile_networking_enum AS pne ON (pn.network_type = pne.network_type)
+ WHERE ' . $where . '
+ ORDER BY pn.network_type, pn.nwid
+ ' . $limit);
+ }
+
+ public function getWebSite()
+ {
+ $site = $this->getNetworking(self::NETWORKING_WEB, 1);
+ if ($site->total() != 1) {
+ return null;
+ }
+ $site = $site->next();
+ return $site['address'];
+ }
+
+
+ /** Jobs
+ */
+
+ public function getJobs($flags, $limit = null)
+ {
+ $where = XDB::format('pj.uid = {?}', $this->id());
+ $cond = 'TRUE';
+ if ($this->visibility) {
+ $where .= ' AND pj.pub IN ' . XDB::formatArray($this->visibility);
+ $cond = 'pj.email_pub IN ' . XDB::formatArray($this->visibility);
+ }
+ $limit = is_null($limit) ? '' : XDB::format('LIMIT {?}', (int)$limit);
+ return XDB::iterator('SELECT pje.name, pje.acronym, pje.url, pje.email, pje.NAF_code,
+ pj.description, pj.url AS user_site,
+ IF (' . $cond . ', pj.email, NULL) AS user_email,
+ pjse.name AS sector, pjsse.name AS subsector,
+ pjssse.name AS subsubsector
+ FROM profile_job AS pj
+ INNER JOIN profile_job_enum AS pje ON (pje.id = pj.jobid)
+ LEFT JOIN profile_job_sector_enum AS pjse ON (pjse.id = pj.sectorid)
+ LEFT JOIN profile_job_subsector_enum AS pjsse ON (pjsse.id = pj.subsectorid)
+ LEFT JOIN profile_job_subsubsector_enum AS pjssse ON (pjssse.id = pj.subsubsectorid)
+ WHERE ' . $where . '
+ ORDER BY pj.id
+ ' . $limit);
+ }
+
+ public function getMailJob()
+ {
+ $job = $this->getJobs(self::JOBS_MAIN, 1);
+ if ($job->total() != 1) {
+ return null;
+ }
+ return $job->next();
+ }
+
+
public function owner()
{
return User::getSilent($this);