function handler_rooms($page) { $rf = new RoomFilter(new RFC_Prefix('BATACL')); $rooms = $rf->get(); $rooms->select(RoomSelect::see(array('groups' => GroupSelect::base()))); $page->assign('rooms', $rooms); $page->changeTpl('rooms/rooms.tpl'); }
public function run() { $binets = S::user()->castes()->groups()->filter('ns', Group::NS_BINET); $frees = S::user()->castes()->groups()->filter('ns', Group::NS_FREE); $binets->select(GroupSelect::premises()); $binets->select(GroupSelect::nb_news()); $this->assign('binets', $binets); $this->assign('frees', $frees); $this->assign('user', S::user()); }
function handler_upload($page) { $page->assign('exception', false); $page->assign('image', false); if (FrankizUpload::has('file')) { $g = Group::from('temp')->select(GroupSelect::castes()); $temp = $g->caste(Rights::everybody()); try { $upload = FrankizUpload::v('file'); $secret = uniqid(); $i = new FrankizImage(); $i->insert(); $i->caste($temp); $i->label($secret); $i->image($upload); $page->assign('image', $i); $page->assign('secret', $secret); } catch (Exception $e) { try { if ($i) { $i->delete(); } } catch (Exception $eb) { $page->assign('exception', $eb); } $page->assign('exception', $e); if ($e instanceof ImageSizeException) { $page->assign('pixels', true); } else { if ($e instanceof UploadSizeException) { $page->assign('bytes', true); } else { if ($e instanceof ImageFormatException) { $page->assign('format', true); } } } } } if (Env::has('delete')) { $image = new FrankizImage(Env::i('iid')); $image->select(FrankizImageSelect::base()); if ($image->label() == Env::s('secret')) { $image->delete(); } } $page->addCssLink('upload.css'); $page->changeTpl('images/upload.tpl', SIMPLE); }
public function sendmailadmin() { if (is_null($this->user->bestEmail())) { $this->user->select(UserSelect::base()); } $mail = new FrankizMailer('validate/mail.admin.tol.tpl'); $mail->assign('user', $this->user->displayName()); $group = Group::from('tol'); $group->select(GroupSelect::base()); $mail->assign('targetGroup', $group); $mail->subject("[Frankiz] Validation d'une photo tol"); $mail->SetFrom($this->user->bestEmail(), $this->user->displayName()); $mail->AddAddress($this->_mail_from_addr(), $this->_mail_from_disp()); $mail->Send(false); }
function smarty_function_origin_picker($params, &$smarty) { $gf = new GroupFilter(new PFC_And(new PFC_Not(new GFC_Namespace(Group::NS_USER)), new GFC_User(S::user(), Rights::admin())), new GFO_Score()); $gs = $gf->get(); if ($params['not_only_admin']) { $gfo = new GroupFilter(new PFC_And(new GFC_Namespace(array(Group::NS_BINET, Group::NS_FREE)), new GFC_User(S::user(), Rights::restricted())), new GFO_Score()); $gso = $gfo->get()->diff($gs); $temp = new Collection(); $temp->merge($gs)->merge($gso); $temp->select(GroupSelect::base()); $smarty->assign('not_admin', $gso); } else { $gs = $gf->get()->select(GroupSelect::base()); } $smarty->assign($params['out'], $gs); }
/** * Create an image for a promotion, for a group, if needed */ function create_promo_image(Group $g, $promo) { $g->select(GroupSelect::base()); if ($g->image()) { return; } if ($promo % 2 == 0) { $upload = FrankizUpload::fromFile(dirname(__FILE__) . '/../images/rouje.png'); $label = 'Chic à la rouje'; } else { $upload = FrankizUpload::fromFile(dirname(__FILE__) . '/../images/jone.png'); $label = 'Chic à la jone'; } $i = new FrankizImage(); $i->insert(); $i->caste($g->caste(Rights::everybody())); $i->label($label); $i->image($upload, false); $g->image($i); }
function handler_links_new($page) { if (!S::user()->perms()->hasFlag('admin')) { return PL_FORBIDDEN; } $label = Env::t('label', ''); $link = Env::t('link', ''); $description = Env::t('description', ''); $comment = Env::t('comment', ''); $type = Env::t('type', ''); trace($type); if (Env::has('create') && $label != '' && $link != '' && ($type == 'partners' || $type == 'usefuls')) { $l = new Link(); $l->insert($type); if (FrankizUpload::has('image') && $type == 'partners') { try { $group = Group::from('partnership'); $group->select(GroupSelect::castes()); $image = new FrankizImage(); $image->insert(); $image->label($label); $image->caste($group->caste(new Rights('everybody'))); $image->image(FrankizUpload::v('image')); $l->image($image); } catch (Exception $e) { $page->assign('err', $e->getMessage()); } } $l->label($label); $l->link($link); $l->description($description); $l->comment($comment); pl_redirect('links/' . $type); } $page->assign('title', 'Nouveau lien'); $page->addCssLink('links.css'); $page->changeTpl('links/new_link.tpl'); }
function smarty_function_target_picker($params, &$smarty) { // Get user groups $everybody_groups = S::user()->castes(Rights::everybody())->groups(); // Get Frankiz special groups $fkz = new Collection('Group'); $fkz->add(array('everybody', 'public')); $fkz->select(new GroupSelect(array('description'))); // BDE, study and promo groups $study_groups = $everybody_groups->filter('ns', Group::NS_BDE); $study_groups->merge($everybody_groups->filter('ns', Group::NS_PROMO)); $study_groups->merge($everybody_groups->filter('ns', Group::NS_STUDY)); // Get all groups user is admin, without the user one $gs = S::user()->castes(Rights::admin())->groups(); $gs->diff($fkz); $gs->filter(function ($g) { return $g->ns() != Group::NS_USER; }); if ($params['even_only_friend']) { $gfo = new GroupFilter(new PFC_And(new GFC_Namespace(array(Group::NS_BINET, Group::NS_FREE)), new GFC_User(S::user(), Rights::everybody())), new GFO_Score()); $gso = $gfo->get()->diff($gs)->diff($fkz); $temp = new Collection(); $temp->merge($gs)->merge($gso); $temp->select(GroupSelect::base()); $smarty->assign('only_friend', $gso); $temp = new Collection(); $temp->merge($gs)->merge($fkz)->merge($gso); $temp->select(GroupSelect::base()); } else { $temp = new Collection(); $temp->merge($gs)->merge($fkz); $temp->select(GroupSelect::base()); } $smarty->assign($params['user_groups'], $gs); $smarty->assign($params['fkz_groups'], $fkz); $smarty->assign($params['study_groups'], $study_groups); $smarty->assign($params['own_group'], S::user()->group()); }
function handler_mail($page) { $subject = Env::t('subject', ''); $body = Env::t('mail_body', ''); $no_wiki = Env::has('no_wiki'); // Retrieve the years on_platal of each formation $formations = Formation::selectAll(FormationSelect::on_platal()); if (Env::has('send')) { try { $required_fields = array('subject' => 'Il faut donner un sujet à ton mail', 'mail_body' => 'Tu ne veux pas envoyer de mail vide à tous. Si ?'); foreach ($required_fields as $field => $msg) { if (Env::v($field, '') == '') { throw new Exception($msg); } } if (Env::t('origin_mail_proposal') == 'false') { $origin = false; } else { $origin = new Group(Env::i('origin_mail_proposal')); } if ($origin !== false && !S::user()->hasRights($origin, Rights::admin())) { throw new Exception("Invalid credentials for origin Group"); } if (Env::t('type_mail_proposal') == 'group') { // Mail to a group list($temp, $target_group) = self::target_picker_to_caste_group('mail'); $target = new Collection('Caste'); $target->add($temp); $target_group->select(GroupSelect::validate()); $nv = new MailValidate(array('writer' => S::user(), 'type_mail' => Env::t('type_mail_proposal'), 'origin' => $origin, 'targets' => $target, 'subject' => $subject, 'body' => $body, 'nowiki' => $no_wiki, 'formation' => $target_group)); $el = new Validate(array('item' => $nv, 'group' => $target_group, 'writer' => S::user(), 'type' => 'mail')); $el->insert(); } elseif (Env::t('type_mail_proposal') == 'promo') { // Target group is a Collection of formation groups, which validate requests $target_group = new Collection('Group'); // Group promos by formation $promos = unflatten(Env::v('promos')); $promosByFormation = array(); foreach ($promos as $formation_promo) { $formation_promo = trim($formation_promo); if (!$formation_promo) { continue; } if (!preg_match('/^([0-9]+)_([0-9]+)$/', $formation_promo, $matches)) { throw new Exception("Oops, mauvais format de destinataire."); } $formid = (int) $matches[1]; $promo = (int) $matches[2]; if (isset($promosByFormation[$formid])) { $promosByFormation[$formid][] = $promo; } else { $promosByFormation[$formid] = array($promo); } } if (empty($promosByFormation)) { throw new Exception("Il faut indiquer au moins un destinataire."); } foreach ($promosByFormation as $formid => $promos) { // Now, $promos are the list of promos of formation $formid $form = $formations->get($formid); // Study group are the people the mail is sent to, array of CasteFilterCondition $cfc_study_groups = array(); foreach ($promos as $promo) { if (!$form->hasPlatalYear($promo)) { throw new Exception("Mauvaise promo " . $promo . " pour " . $form->label() . "."); } $cfc_study_groups[] = new CFC_Group($form->getGroupForPromo($promo), Rights::restricted()); } $target = new CasteFilter(new PFC_Or($cfc_study_groups)); $target = $target->get(); $target->select(CasteSelect::validate()); // $target_group is the group which validates this email $target_group = $form->getGroup(); $target_group->select(GroupSelect::validate()); $nv = new MailValidate(array('writer' => S::user(), 'type_mail' => Env::t('type_mail_proposal'), 'origin' => $origin, 'targets' => $target, 'subject' => $subject, 'body' => $body, 'nowiki' => $no_wiki, 'formation' => $target_group)); $el = new Validate(array('item' => $nv, 'group' => $target_group, 'writer' => S::user(), 'type' => 'mail')); $el->insert(); } } $page->assign('envoye', true); } catch (Exception $e) { $page->trigError($e->getMessage()); } } $page->assign('subject', $subject); $page->assign('body', $body); $page->assign('nowiki', $no_wiki); $page->assign('formations', $formations); $page->assign('title', 'Envoi des mails'); $page->addCssLink('validate.css'); $page->changeTpl('validate/prop.mail.tpl'); }
public function handler_defaultfilters($page) { S::user()->select(UserSelect::login()); if (Env::has('options')) { $groups = new Collection('Group'); $gids = explode(';', Env::s('promo')); if (Env::t('promo', '') != '') { $groups->add($gids); } $groups->select(GroupSelect::base()); S::user()->defaultFilters($groups); } $page->assign('user', S::user()); $page->addCssLink('profile.css'); $page->assign('title', "Filtre par défaut"); $page->changeTpl('profile/defaultfilters.tpl'); }
function handler_admin($page, $id = null, $action = null) { $page->assign('title', "Administration de l'authentification externe"); $page->assign('remoterights_available', implode(',', Remote::availableRights())); // Find remote $remote = null; if ($id == 'new') { $remote = new Remote(); $remote->insert(); } elseif (Remote::isId($id)) { $remote = new Remote($id); // Delete a remote if ($action == 'delete') { $remote->delete(); $remote = null; } } if (!empty($remote)) { $remote->select(RemoteSelect::groups()); if (Env::has('change_remote')) { $remote->site(Env::t('site')); $remote->label(Env::t('label')); $remote->privkey(Env::t('privkey')); $rights = explode(',', Env::t('rights')); foreach ($rights as $k => $v) { $rights[$k] = strtolower(trim($v)); } $rights = array_intersect($rights, Remote::availableRights()); $remote->rights(new PlFlagSet(implode(',', $rights))); $groups = new Collection('Group'); $groups_fields = array('binets', 'frees'); foreach ($groups_fields as $field) { foreach (explode(';', Env::t($field)) as $gid) { $gid = trim($gid); if ($gid) { $groups->add(new Group($gid)); } } } $groups->select(GroupSelect::base()); $remote->groups($groups); } $page->assign('remote', $remote); $page->changeTpl('remote/admin.tpl'); } else { $remotes = Remote::selectAll(RemoteSelect::groups()); $page->assign('remotes', $remotes); $page->changeTpl('remote/list.tpl'); } }
public static function news() { return new NewsSelect(array_merge(self::$natives, array('read', 'star')), array('writer' => UserSelect::base(), 'target' => CasteSelect::group(), 'origin' => GroupSelect::base())); }
public static function base() { return new ActivitySelect(self::$natives, array('target' => CasteSelect::validate(), 'origin' => GroupSelect::base())); }
function handler_validate($page, $gid = null, $vid = null) { $page->assign('msg', ''); $gf = new GroupFilter(new PFC_Or(new GFC_Id($gid), new GFC_Name($gid))); $group = $gf->get(true); if (!$group) { throw new Exception("This Group (' . {$gid} . ') doesn't exist"); } $group->select(GroupSelect::base()); if (!S::user()->hasRights($group, Rights::admin())) { throw new Exception("You don't have the credential to validate request in this group"); } $filter = new ValidateFilter(new VFC_Group($group)); $collec = $filter->get()->select(ValidateSelect::validate()); if (Env::has('val_id')) { $el = $collec->get(Env::v('val_id')); if (!$el) { $page->assign('msg', 'La validation a déjà été effectuée.'); } else { if (Env::has('accept') || Env::has('delete')) { S::logger()->log('admin/validate', array('type' => $el->type(), 'writer' => $el->writer()->id(), 'group' => $el->group()->id(), 'created' => $el->created()->toDb(), 'valid' => Env::has('accept'), 'item' => $el->itemToDb())); } if ($el->handle_form() && (Env::has('accept') || Env::has('delete'))) { $collec->remove(Env::v('val_id')); } } } $page->assign('validation', is_null($vid) ? 0 : $vid); $page->assign('isEdition', false); $page->assign('gid', $gid); $page->assign('group', $group); $page->assign('val', $collec); $page->addCssLink('validate.css'); $page->addCssLink('surveys.css'); $page->assign('title', "Validations des requêtes"); $page->changeTpl('validate/validate.tpl'); }
public function objects() { return array('writer' => UserSelect::base(), 'target' => CasteSelect::validate(), 'origin' => GroupSelect::base()); }
public static function login() { $cb = function ($users) { $web = Group::from('webmasters'); foreach ($users as $u) { if ($u->hasRights($web, Rights::member())) { $u->perms()->addFlag('web'); } } }; return new UserSelect(array_merge(self::$natives, array('rooms', 'minimodules', 'castes', 'poly', 'comments', 'defaultfilters', 'studies', 'cuvisibility')), array('castes' => CasteSelect::group(), 'defaultfilters' => GroupSelect::base()), $cb); }
public static function see() { return self::all(array('ips' => IpSelect::base(), 'users' => UserSelect::base(), 'groups' => GroupSelect::base())); }
function handler_tol_ajax_visibility($page, $usergroupid) { $matches = array(); // Retrieve UID and GID from path if (!preg_match('/[a-zA-Z-_.]*([0-9]+)-([0-9]+)/', $usergroupid, $matches)) { $page->jsonAssign('reason', 'Invalid ids'); return PL_JSON; } $uid = $matches[1]; $gid = $matches[2]; // Sanity checks if (!S::user()->isMe($uid)) { $page->jsonAssign('reason', 'Invalid user'); return PL_JSON; } $usergroups = S::user()->castes()->groups(); $group = $usergroups->get($gid); if (!$group) { $page->jsonAssign('reason', "Invalid group"); return PL_JSON; } $group->select(GroupSelect::visibility()); // Get new visibility from json data $json_data = json_decode(Env::v('json')); $visibid = $json_data->visibility; if (!$visibid) { $page->jsonAssign('reason', "Invalid visibility group id"); return PL_JSON; } $visigroup = $usergroups->get($visibid); if (!$visigroup) { $page->jsonAssign('reason', "Invalid visibility group"); return PL_JSON; } // Check avaibility if (!S::user()->groupVisibilityIsPossible($group, $visigroup)) { $page->jsonAssign('reason', "Not available visibility"); return PL_JSON; } // Now make the read call $colVisiGroup = S::user()->groupVisibility($group, $visigroup); //$page->jsonAssign('usergroupid', json_encode(array($uid, $gid, $visigroup->label(), $group->label()))); $page->jsonAssign('usergroupid', $uid . '-' . $gid); list($color, $title) = User::visibilitiesColInfo($colVisiGroup); $page->jsonAssign('color', $color); $page->jsonAssign('title', $title); $page->jsonAssign('success', true); return PL_JSON; }
public function buildCondition(PlFilter $f) { $g = Group::from('temp')->select(GroupSelect::castes()); $temp = $g->caste(Rights::everybody()); return XDB::format('i.caste = {?}', $temp->id()); }
$groups_friend = new Collection('Group'); while ($g_datas = $g_iter->next()) { $g = new Group($g_datas['binet_id']); if (preg_match('/ympath?isant/', $g_datas['remarque'])) { $groups_friend->add($g); } else { $groups_member->add($g); } $u->comments($g, conv($g_datas['remarque'])); if ($g->id() == 1 && strlen(conv_name($u->nickname())) > 1) { $u->addStudy(0, $datas['promo'], (int) $datas['promo'] + 4, $datas['promo'], conv_name($u->nickname())); } } $temp = new Collection('Group'); $temp->safeMerge(array($groups_member, $groups_friend)); $temp->select(GroupSelect::castes()); foreach ($groups_member as $g) { $g->caste(Rights::member())->addUser($u); } foreach ($groups_friend as $g) { $g->caste(Rights::friend())->addUser($u); } $k++; echo 'User ' . str_pad($k, 4, '0', STR_PAD_LEFT) . '/' . $users . ' : ' . str_pad($u->id(), 5, '0', STR_PAD_LEFT) . ' - ' . $datas['promo'] . ' - ' . str_pad($groups_member->count(), 2, '0', STR_PAD_LEFT) . " members - " . str_pad($groups_friend->count(), 2, '0', STR_PAD_LEFT) . " friends - " . substr(microtime(true) - $t, 0, 5) . ' ' . $u->login() . "\n"; } echo "-----------------------------------------------\n"; XDB::execute('UPDATE account SET skin = "default"'); echo "default skin set \n"; XDB::execute('INSERT INTO users_minimodules (SELECT uid, "birthday", "COL_LEFT", 0 FROM account WHERE uid > 0)'); XDB::execute('INSERT INTO users_minimodules
public static function groups() { return new RemoteSelect(array_merge(self::$natives, array('groups')), array('groups' => GroupSelect::base())); }
* - Folder to search the pictures in * - Method of the User to use to find the correct picture * - Load the original picture or the current photo ? * * Example : * ./import.tol.php '{"type":"user","condition":{"type":"uid","uids":[2]}}' . poly original * * Or : * * ./import.tol.php '{"type":"user","condition":{"type":"promo","comparison":"=","promo":2008}}' /home/2008/riton/dev/tol/2008 poly original * */ require_once dirname(__FILE__) . '/connect.db.inc.php'; $globals->debug = 0; $gf = new GroupFilter(new GFC_Name('tol')); $group = $gf->get(true)->select(GroupSelect::castes()); $tol_caste = $group->caste(Rights::everybody()); // Concerned users $uf = UserFilter::fromExport(json_decode($argv[1], true)); // Folder to look in $folder = $argv[2]; // Field to use for the "join" $field = $argv[3]; // Update original or current picture ? $original = $argv[4] == 'photo' ? false : true; $total = $uf->getTotalCount(); $chunk = empty($argv[5]) ? 100 : $argv[5]; $from = 0; while (true) { echo "Chunk from {$from} to " . ($from + $chunk) . "\n"; $users = $uf->get(new PlLimit($chunk, $from));
public function objects() { return array('user' => userSelect::base(), 'group' => GroupSelect::validate()); }
function handler_group_unsubscribe($page, $group) { S::assert_xsrf_token(); $group = Group::fromId($group); if (!$group) { $page->assign('title', "Ce groupe n'existe pas"); $page->changeTpl('groups/no_group.tpl'); return; } $group->select(GroupSelect::subscribe()); if ($group->leavable()) { $group->removeUser(S::user()); S::user()->select(UserSelect::castes()); } pl_redirect('groups/see/' . $group->name()); exit; }
public static function validate($subs = null) { return new self(array('writer', 'type', 'group', 'created', 'item'), array('writer' => UserSelect::base(), 'group' => GroupSelect::base())); }
} } elseif ($g->ns() == 'sport') { if (!preg_match('/^sport_[a-z]+$/', $g->name())) { echo "Warning: sport group " . $gtext . " has an invalid name\n"; } } elseif ($g->ns() == 'bde') { if ($g->name() != 'adherents-kes') { echo "Warning: unknown BDE " . $gtext . "\n"; } } elseif (!in_array($g->ns(), array('study', 'promo', 'binet', 'free'))) { echo "Error: Unknown NS " . $g->ns() . " for group " . $gtext . "\n"; } } } // Fetch groups $groups = Group::selectAll(GroupSelect::base())->select(GroupSelect::castes()); $groups = $groups->toArray(); krsort($groups); // Remember used castes $used_castes = array(); echo "Checking " . count($groups) . " groups\n"; while (!empty($groups)) { $g = array_pop($groups); check_group($g); foreach ($g->castes() as $c) { array_push($used_castes, $c->id()); } // Frees memory unset($g); } // Fetch castes
public function objects() { return array('writer' => UserSelect::base(), 'formation' => GroupSelect::base(), 'origin' => GroupSelect::base()); }
function handler_new_regular($page) { $title = Env::t('title', ''); $description = Env::t('activity_description', ''); $default_begin = Env::t('begin', '00:00'); $default_end = Env::t('end', '00:00'); $days = Env::v('days'); $target = Env::i('target_group_activity', ''); $caste = Env::has('target_everybody_activity') ? 'everybody' : 'restricted'; if (Env::has('send')) { S::assert_xsrf_token(); if ($title == '' || is_null($days) || $default_begin == '00:00' || $default_end == '00:00' || $target == '' || !(preg_match('`^\\d{2}:\\d{2}$`', $default_begin) && strtotime($default_begin) !== false && preg_match('`^\\d{2}:\\d{2}$`', $default_end) && strtotime($default_end) !== false)) { $page->assign('msg', 'Il manque des informations pour créer l\'activité. Attention les heures ne peuvent pas rester de la forme 00:00.'); } else { $days = implode(',', $days); $target = new Group($target); $target->select(GroupSelect::validate()); if (!S::user()->hasRights($target, Rights::admin())) { throw new Exception("Invalid credentials"); } if ($target->ns() == Group::NS_USER) { $caste = 'restricted'; } $a = new Activity(array('target' => $target->caste(new Rights($caste)), 'origin' => $target, 'title' => $title, 'description' => $description, 'days' => $days, 'default_begin' => $default_begin, 'default_end' => $default_end)); $a->insert(); $page->assign('envoye', true); } } $page->assign('title_activity', $title); $page->assign('description', $description); $page->assign('begin', $default_begin); $page->assign('end', $default_end); $page->assign('title', 'Créer une activité régulière'); $page->changeTpl('activity/create_regular_activity.tpl'); }
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the Free Software * * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ /* * This script creates and updates the groups corresponding to the promos */ require_once dirname(__FILE__) . '/../connect.db.inc.php'; $gf = new GroupFilter(new GFC_Name('everybody')); $g = $gf->get(true); $g->select(GroupSelect::castes()); $c = $g->caste(Rights::member()); $c->select(CasteSelect::base())->compute(); echo 'Groupe everybody mis à jour' . "\n"; $gf = new GroupFilter(new GFC_Name('public')); $g = $gf->get(true); $g->select(GroupSelect::castes()); $c = $g->caste(Rights::member()); $c->select(CasteSelect::base())->compute(); echo 'Groupe visibilité extérieure mis à jour' . "\n"; $gf = new GroupFilter(new GFC_Name('licenses')); $g = $gf->get(true); $g->select(GroupSelect::castes()); $c = $g->caste(Rights::member()); $c->select(CasteSelect::base())->compute(); echo 'Groupe licenses mis à jour' . "\n";
public static function validate() { return new CasteSelect(array('group', 'rights'), array('group' => GroupSelect::validate())); }