}
// }}}
+// {{{ class UFC_SchoolId
+/** Filters users based on their shoold identifier
+ * @param type Parameter type (Xorg, AX, School)
+ * @param value School id value
+ */
+class UFC_SchooldId implements UserFilterCondition
+{
+ const AX = 'ax';
+ const Xorg = 'xorg';
+ const School = 'school';
+
+ private $type;
+ private $id;
+
+ static public function assertType($type)
+ {
+ if ($type != self::AX && $type != self::Xorg && $type != self::School) {
+ Platal::page()->killError("Type de matricule invalide: $type");
+ }
+ }
+
+ public function __construct($type, $id)
+ {
+ $this->type = $type;
+ $this->id = $id;
+ self::assertType($type);
+ }
+
+ public function buildCondition(PlFilter &$uf)
+ {
+ $uf->requireProfiles();
+ $id = $this->id;
+ $type = $this->type;
+ if ($type == self::School) {
+ $type = self::Xorg;
+ $id = Profile::getXorgId($id);
+ }
+ return XDB::format('p.' . $type . '_id = {?}', $id);
+ }
+}
+// }}}
+
// {{{ class UFC_EducationSchool
/** Filters users by formation
* @param $val The formation to search (either ID or array of IDs)
{
public function buildCondition(PlFilter &$uf)
{
- if (!$this->user->watch('registration')) {
+ if (!$this->user->watchType('registration')) {
return PlFilterCondition::COND_FALSE;
}
$uids = $this->user->watchUsers();
}
// }}}
+// {{{ class UFC_MarketingHash
+/** Filters users using the hash generated
+ * to send marketing emails to him.
+ */
+class UFC_MarketingHash implements UserFilterCondition
+{
+ private $hash;
+
+ public function __construct($hash)
+ {
+ $this->hash = $hash;
+ }
+
+ public function buildCondition(PlFilter &$uf)
+ {
+ $table = $uf->addMarketingHash();
+ return XDB::format('rm.hash = {?}', $this->hash);
+ }
+}
/******************
* ORDERS
return $this->getUIDList(null, $limit);
}
+ public function getUID($pos = 0)
+ {
+ $uids =$this->getUIDList(null, new PlFilter(1, $pos));
+ if (count($uids) == 0) {
+ return null;
+ } else {
+ return $uids[0];
+ }
+ }
+
public function getPIDs($limit = null)
{
$limit = self::defaultLimit($limit);
return $this->getPIDList(null, $limit);
}
+ public function getPID($pos = 0)
+ {
+ $pids =$this->getPIDList(null, new PlFilter(1, $pos));
+ if (count($pids) == 0) {
+ return null;
+ } else {
+ return $pids[0];
+ }
+ }
+
public function getUsers($limit = null)
{
return User::getBulkUsersWithUIDs($this->getUIDs($limit));
}
+ public function getUser($pos = 0)
+ {
+ $uid = $this->getUID($pos);
+ if ($uid == null) {
+ return null;
+ } else {
+ return User::getWithUID($uid);
+ }
+ }
+
public function iterUsers($limit = null)
{
return User::iterOverUIDs($this->getUIDs($limit));
return Profile::getBulkProfilesWithPIDs($this->getPIDs($limit));
}
+ public function getProfile($pos = 0)
+ {
+ $pid = $this->getPID($pos);
+ if ($pid == null) {
+ return null;
+ } else {
+ return Profile::get($pid);
+ }
+ }
+
public function iterProfiles($limit = null)
{
return Profile::iterOverPIDs($this->getPIDs($limit));
if ($promo_min != 0) {
$min = new UFC_Promo('>=', self::GRADE_ING, intval($promo_min));
} else {
- $min = new UFC_True();
+ $min = new PFC_True();
}
if ($promo_max != 0) {
$max = new UFC_Promo('<=', self::GRADE_ING, intval($promo_max));
} else {
- $max = new UFC_True();
+ $max = new PFC_True();
}
return new UserFilter(new PFC_And($min, $max));
}
static public function assertGrade($grade)
{
if (!self::isGrade($grade)) {
- Platal::page()->killError("Diplôme non valide");
+ Platal::page()->killError("Diplôme non valide: $grade");
}
}
}
foreach ($this->pepe as $grade => $sub) {
if ($this->isGrade($grade)) {
- $joins['pe' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_education', '$ME.eduid = pee.id AND $ME.uid = $PID');
+ $joins['pe' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_education', '$ME.eduid = pee.id AND $ME.pid = $PID');
$joins['pede' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_INNER, 'profile_education_degree_enum', '$ME.id = pe' . $sub . '.degreeid AND $ME.abbreviation LIKE ' .
XDB::format('{?}', $grade));
} else {
- $joins['pe' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_education', '$ME.uid = $PID');
+ $joins['pe' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_education', '$ME.pid = $PID');
$joins['pee' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_INNER, 'profile_education_enum', '$ME.id = pe' . $sub . '.eduid');
$joins['pede' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_INNER, 'profile_education_degree_enum', '$ME.id = pe' . $sub . '.degreeid');
}
{
$joins = array();
if ($this->with_bi) {
- $joins['bi'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'binets_ins', '$ME.user_id = $PID');
+ $joins['bi'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_binets', '$ME.pid = $PID');
}
if ($this->with_bd) {
- $joins['bd'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'binets_def', '$ME.id = bi.binet_id');
+ $joins['bd'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_binet_enum', '$ME.id = bi.binet_id');
}
return $joins;
}
}
foreach ($this->al as $sub=>$key) {
if (is_null($key)) {
- $joins['al' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'aliases', '$ME.id = $UID AND $ME.type IN (\'alias\', \'a_vie\')');
+ $joins['al' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'aliases', '$ME.uid = $UID AND $ME.type IN (\'alias\', \'a_vie\')');
} else if ($key == self::ALIAS_BEST) {
- $joins['al' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'aliases', '$ME.id = $UID AND $ME.type IN (\'alias\', \'a_vie\') AND FIND_IN_SET(\'bestalias\', $ME.flags)');
+ $joins['al' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'aliases', '$ME.uid = $UID AND $ME.type IN (\'alias\', \'a_vie\') AND FIND_IN_SET(\'bestalias\', $ME.flags)');
} else if ($key == self::ALIAS_FORLIFE) {
- $joins['al' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'aliases', '$ME.id = $UID AND $ME.type = \'a_vie\'');
+ $joins['al' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'aliases', '$ME.uid = $UID AND $ME.type = \'a_vie\'');
} else {
- $joins['al' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'aliases', XDB::format('$ME.id = $UID AND $ME.type IN (\'alias\', \'a_vie\') AND $ME.alias = {?}', $key));
+ $joins['al' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'aliases', XDB::format('$ME.uid = $UID AND $ME.type IN (\'alias\', \'a_vie\') AND $ME.alias = {?}', $key));
}
}
foreach ($this->ve as $sub=>$key) {
{
$joins = array();
if ($this->pc) {
- $joins['pc'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_corps', '$ME.uid = $UID');
+ $joins['pc'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_corps', '$ME.pid = $PID');
}
if ($this->pcr) {
$joins['pcr'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_corps_rank_enum', '$ME.id = pc.rankid');
{
$joins = array();
if ($this->with_pj) {
- $joins['pj'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_job', '$ME.uid = $UID');
+ $joins['pj'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_job', '$ME.pid = $PID');
}
if ($this->with_pje) {
$joins['pje'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_job_enum', '$ME.id = pj.jobid');
{
$joins = array();
if ($this->with_pnw) {
- $joins['pnw'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_networking', '$ME.uid = $UID');
+ $joins['pnw'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_networking', '$ME.pid = $PID');
}
return $joins;
}
{
$joins = array();
if ($this->with_ptel) {
- $joins['ptel'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_phones', '$ME.uid = $UID');
+ $joins['ptel'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_phones', '$ME.pid = $PID');
}
return $joins;
}
{
$joins = array();
if ($this->with_pmed) {
- $joins['pmed'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_medals_sub', '$ME.uid = $UID');
+ $joins['pmed'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_medals', '$ME.pid = $PID');
}
return $joins;
}
{
$joins = array();
foreach ($this->pms as $sub => $tab) {
- $joins[$sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, $tab, '$ME.uid = $UID');
+ $joins[$sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, $tab, '$ME.pid = $PID');
}
return $joins;
}
}
return $joins;
}
+
+
+ /** MARKETING
+ */
+ private $with_rm;
+ public function addMarketingHash()
+ {
+ $this->requireAccounts();
+ $this->with_rm = true;
+ }
+
+ protected function marketingJoins()
+ {
+ if ($this->with_rm) {
+ return array('rm' => new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'register_marketing', '$ME.uid = $UID'));
+ } else {
+ return array();
+ }
+ }
}
// }}}