/** Creates a new session entry in database and return its ID. * * @param $uid the id of the logged user * @param $suid the id of the administrator who has just su'd to the user * @return session the session id */ private function writeSession($uid, $suid = null) { $ip = $_SERVER['REMOTE_ADDR']; $host = strtolower(gethostbyaddr($_SERVER['REMOTE_ADDR'])); $browser = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; @(list($forward_ip, ) = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR'])); $forward_host = $forward_ip; if ($forward_host) { $forward_host = strtolower(gethostbyaddr($forward_host)); } $proxy = ''; if ($forward_ip || @$_SERVER['HTTP_VIA']) { $proxy = 'proxy'; } $uid = $uid == 0 ? null : $uid; $suid = $suid == 0 ? null : $suid; XDB::execute("INSERT INTO log_sessions\n SET uid={?}, host={?}, ip={?}, forward_ip={?}, forward_host={?}, browser={?}, suid={?}, flags={?}", $uid, $host, ip_to_uint($ip), ip_to_uint($forward_ip), $forward_host, $browser, $suid, $proxy); if ($forward_ip) { $this->proxy_ip = $ip; $this->proxy_host = $host; $this->ip = $forward_ip; $this->host = $forward_host; } else { $this->ip = $ip; $this->host = $host; } return XDB::insertId(); }
public function insert() { XDB::execute('INSERT qdj SET question = {?}, answer1 = {?}, answer2 = {?}, count1 = 0, count2 = 0, writer = {?}', $this->question, $this->answer1, $this->answer2, $this->writer->id()); $this->id = XDB::insertId(); }
function handler_ajax_todo_add($page) { S::assert_xsrf_token(); if (Json::has('tobedone')) { XDB::execute('INSERT INTO todo SET uid = {?}, sent = NOW(), checked = 0, tobedone = {?}', S::user()->id(), Json::s('tobedone')); if (XDB::affectedRows() > 0) { $page->jsonAssign('todo_id', XDB::insertId()); } else { $page->jsonAssign('error', "Impossible d'ajouter une nouvelle tâche"); } } else { $page->jsonAssign('error', "Requête invalide"); } return PL_JSON; }
public static function getComponentId(array $component) { $where = ''; foreach ($component['types'] as $type) { $where .= XDB::format(' AND FIND_IN_SET({?}, types)', $type); } $id = XDB::fetchOneCell('SELECT id FROM profile_addresses_components_enum WHERE short_name = {?} AND long_name = {?}' . $where, $component['short_name'], $component['long_name']); if (is_null($id)) { XDB::execute('INSERT INTO profile_addresses_components_enum (short_name, long_name, types) VALUES ({?}, {?}, {?})', $component['short_name'], $component['long_name'], implode(',', $component['types'])); $id = XDB::insertId(); } return $id; }
$parser = xml_parser_create(); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); xml_parse_into_struct($parser, $data, $values, $tags); xml_parser_free($parser); XDB::execute('INSERT INTO `profile_job_term_enum` (`name`, `full_name`) VALUES ("Emplois", "Emplois")'); $opened_nodes = array(); $broader_ids = array(XDB::insertId()); XDB::execute('INSERT INTO profile_job_term_relation VALUES (0, {?}, "narrower", "original"), ({?}, {?}, "narrower", "computed")', $broader_ids[0], $broader_ids[0], $broader_ids[0]); // loop through the structures foreach ($values as $val) { if (($val['type'] == 'open' || $val['type'] == 'complete') && !empty($val['attributes']['intitule'])) { $intitule = $val['attributes']['intitule']; if (mb_strtoupper($intitule) == $intitule) { $intitule = ucfirst(mb_strtolower($intitule)); } $res = XDB::execute('INSERT INTO profile_job_term_enum (name, full_name) VALUES ({?}, {?})', $intitule, $intitule . ' (emploi' . ($val['type'] == 'open' ? 's' : '') . ')'); $newid = XDB::insertId(); array_unshift($broader_ids, $newid); array_unshift($opened_nodes, $val['tag']); foreach ($broader_ids as $i => $bid) { XDB::execute('INSERT INTO profile_job_term_relation VALUES ({?}, {?}, "narrower", {?})', $bid, $newid, $i == 1 ? 'original' : 'computed'); } } if (count($opened_nodes) > 0 && $val['tag'] == $opened_nodes[0] && ($val['type'] == 'close' || $val['type'] == 'complete')) { array_shift($broader_ids); array_shift($opened_nodes); } } /* vim:set et sw=4 sts=4 ts=4: */
public function insert() { XDB::execute('INSERT activities SET target = {?}, origin = {?}, title = {?}, description = {?}, days = {?}, default_begin = {?}, default_end = {?}', $this->target->id(), !$this->origin ? null : $this->origin->id(), $this->title, $this->description, $this->days, $this->default_begin, $this->default_end); $this->id = XDB::insertId(); }
/** Import de l'annuaire de l'AX depuis l'export situé dans le home de jacou */ function handler_import($page, $action = 'index', $file = '') { global $globals; if ($action == 'index') { $page->changeTpl('fusionax/import.tpl'); return; } // toutes les actions sont faites en ajax en utilisant jquery header('Content-type: text/javascript; charset=utf-8'); // log des actions $report = array(); $modulepath = realpath(dirname(__FILE__) . '/fusionax/') . '/'; $spoolpath = realpath(dirname(__FILE__) . '/../spool/fusionax/') . '/'; if ($action == 'launch') { if ($file == '') { $report[] = 'Nom de fichier non renseigné.'; } elseif (!file_exists(dirname(__FILE__) . '/../spool/fusionax/' . $file)) { $report[] = 'Le fichier ne se situe pas au bon endroit.'; } else { // séparation de l'archive en fichiers par tables $file = $spoolpath . $file; // Split export into specialised files exec('grep "^AD" ' . $file . ' > ' . $spoolpath . 'Adresses.txt'); exec('grep "^AN" ' . $file . ' > ' . $spoolpath . 'Anciens.txt'); exec('grep "^FO.[0-9]\\{4\\}[MD][0-9]\\{3\\}.Etudiant" ' . $file . ' > ' . $spoolpath . 'Formations_MD.txt'); exec('grep "^FO.[0-9]\\{4\\}[MD][0-9]\\{3\\}.Doct. de" ' . $file . ' >> ' . $spoolpath . 'Formations_MD.txt'); exec('grep "^FO" ' . $file . ' > ' . $spoolpath . 'Formations.txt'); exec('grep "^AC" ' . $file . ' > ' . $spoolpath . 'Activites.txt'); exec('grep "^EN" ' . $file . ' > ' . $spoolpath . 'Entreprises.txt'); exec($modulepath . 'formation.pl'); exec('mv -f ' . $spoolpath . 'Formations_out.txt ' . $spoolpath . 'Formations.txt'); exec('mv -f ' . $spoolpath . 'Formations_MD_out.txt ' . $spoolpath . 'Formations_MD.txt'); $report[] = 'Fichier parsé.'; $report[] = 'Import dans la base en cours...'; XDB::execute("UPDATE profiles\n SET ax_id = NULL\n WHERE ax_id = ''"); $next = 'integrateSQL'; } } elseif ($action == 'integrateSQL') { // intégration des données dans la base MySQL // liste des fichiers sql à exécuter $filesSQL = array(0 => 'Activites.sql', 1 => 'Adresses.sql', 2 => 'Anciens.sql', 3 => 'Formations.sql', 4 => 'Entreprises.sql', 5 => 'Formations_MD.sql'); if ($file != '') { // récupère le contenu du fichier sql $queries = explode(';', file_get_contents($modulepath . $filesSQL[$file])); $db = mysqli_init(); $db->options(MYSQLI_OPT_LOCAL_INFILE, true); $db->real_connect($globals->dbhost, $globals->dbuser, $globals->dbpwd, $globals->dbdb); $db->autocommit(true); $db->set_charset($globals->dbcharset); foreach ($queries as $q) { if (trim($q)) { // coupe le fichier en requêtes individuelles if (substr($q, 0, 2) == '--') { // affiche les commentaires dans le report $lines = explode("\n", $q); $l = $lines[0]; $report[] = addslashes($l); } // exécute la requête $res = $db->query(str_replace('{?}', $spoolpath, $q)); if ($res === false) { throw new XDBException($q, $db->error); } } } $db->close(); // trouve le prochain fichier à exécuter $nextfile = $file + 1; } else { $nextfile = 0; } if ($nextfile > 5) { // tous les fichiers ont été exécutés, on passe à l'étape suivante $next = 'adds1920'; } else { // on passe au fichier suivant $next = 'integrateSQL/' . $nextfile; } } elseif ($action == 'adds1920') { // Adds promotion 1920 from AX db. $report[] = 'Ajout de la promotion 1920'; $res = XDB::iterator('SELECT prenom, Nom_complet, ax_id FROM fusionax_anciens WHERE promotion_etude = 1920;'); $eduSchools = DirEnum::getOptions(DirEnum::EDUSCHOOLS); $eduSchools = array_flip($eduSchools); $eduDegrees = DirEnum::getOptions(DirEnum::EDUDEGREES); $eduDegrees = array_flip($eduDegrees); $degreeid = $eduDegrees[Profile::DEGREE_X]; $entry_year = 1920; $grad_year = 1923; $promo = 'X1920'; $hrpromo = '1920'; $sex = 'male'; $xorgId = 19200000; $type = 'x'; while ($new = $res->next()) { $firstname = $new['prenom']; $lastname = $new['Nom_complet']; $ax_id = $new['ax_id']; $hrid = User::makeHrid($firstname, $lastname, $hrpromo); $res1 = XDB::query('SELECT COUNT(*) FROM accounts WHERE hruid = {?}', $hrid); $res2 = XDB::query('SELECT COUNT(*) FROM profiles WHERE hrpid = {?}', $hrid); if (is_null($hrid) || $res1->fetchOneCell() > 0 || $res2->fetchOneCell() > 0) { $report[] = $ax_id . ' non ajouté'; } $fullName = $firstname . ' ' . $lastname; $directoryName = $lastname . ' ' . $firstname; ++$xorgId; XDB::execute('INSERT INTO profiles (hrpid, xorg_id, ax_id, sex) VALUES ({?}, {?}, {?}, {?})', $hrid, $xorgId, $ax_id, $sex); $pid = XDB::insertId(); XDB::execute('INSERT INTO profile_public_names (pid, lastname_initial, firstname_initial, lastname_main, firstname_main) VALUES ({?}, {?}, {?}, {?}, {?})', $pid, $lastname, $firstname, $lastname, $firstname); XDB::execute('INSERT INTO profile_display (pid, yourself, public_name, private_name, directory_name, short_name, sort_name, promo) VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})', $pid, $firstname, $fullName, $fullName, $directoryName, $fullName, $directoryName, $promo); XDB::execute('INSERT INTO profile_education (pid, eduid, degreeid, entry_year, grad_year, flags) VALUES ({?}, {?}, {?}, {?}, {?}, {?})', $pid, $eduSchools[Profile::EDU_X], $degreeid, $entry_year, $grad_year, 'primary'); XDB::execute('INSERT INTO accounts (hruid, type, is_admin, state, full_name, directory_name, display_name, lastname, firstname, sex) VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})', $hrid, $type, 0, 'pending', $fullName, $directoryName, $firstname, $lastname, $firstname, $sex); $uid = XDB::insertId(); XDB::execute('INSERT INTO account_profiles (uid, pid, perms) VALUES ({?}, {?}, {?})', $uid, $pid, 'owner'); } $report[] = 'Promo 1920 ajoutée.'; $next = 'view'; } elseif ($action == 'view') { XDB::execute('CREATE OR REPLACE ALGORITHM=MERGE VIEW fusionax_xorg_anciens AS SELECT p.pid, p.ax_id, pd.promo, pd.private_name, pd.public_name, pd.sort_name, pd.short_name, pd.directory_name FROM profiles AS p INNER JOIN profile_display AS pd ON (pd.pid = p.pid)'); $next = 'clean'; } elseif ($action == 'clean') { // nettoyage du fichier temporaire //exec('rm -Rf ' . $spoolpath); $report[] = 'Import finit.'; } foreach ($report as $t) { // affiche les lignes de report echo "\$('#fusionax').append('" . $t . "<br/>');\n"; } if (isset($next)) { // lance le prochain script s'il y en a un echo "\$.getScript('fusionax/import/" . $next . "');"; } // exit pour ne pas afficher la page template par défaut exit; }
function handler_add_accounts($page, $action = null, $promo = null) { require_once 'name.func.inc.php'; $page->changeTpl('admin/add_accounts.tpl'); if (Env::has('add_type') && Env::has('people')) { static $titles = array('male' => 'M', 'female' => 'MLLE'); $lines = explode("\n", Env::t('people')); $separator = Env::t('separator'); $promotion = Env::i('promotion'); if (Env::t('add_type') == 'promo') { $eduSchools = DirEnum::getOptions(DirEnum::EDUSCHOOLS); $eduSchools = array_flip($eduSchools); $eduDegrees = DirEnum::getOptions(DirEnum::EDUDEGREES); $eduDegrees = array_flip($eduDegrees); switch (Env::t('edu_type')) { case 'X': $degreeid = $eduDegrees[Profile::DEGREE_X]; $entry_year = $promotion; $grad_year = $promotion + 3; $promo = 'X' . $promotion; $hrpromo = $promotion; $type = 'x'; break; case 'M': $degreeid = $eduDegrees[Profile::DEGREE_M]; $grad_year = $promotion; $entry_year = $promotion - 2; $promo = 'M' . $promotion; $hrpromo = $promo; $type = 'master'; break; case 'D': $degreeid = $eduDegrees[Profile::DEGREE_D]; $grad_year = $promotion; $entry_year = $promotion - 3; $promo = 'D (en cours)'; $hrpromo = 'D' . $promotion; $type = 'phd'; break; default: $page->killError("La formation n'est pas reconnue : " . Env::t('edu_type') . '.'); } $best_domain = XDB::fetchOneCell('SELECT id FROM email_virtual_domains WHERE name = {?}', User::$sub_mail_domains[$type] . Platal::globals()->mail->domain); XDB::startTransaction(); foreach ($lines as $line) { if ($infos = self::formatNewUser($page, $line, $separator, $hrpromo, 6)) { $sex = self::formatSex($page, $infos[3], $line); $lastname = capitalize_name($infos[0]); $firstname = capitalize_name($infos[1]); if (!is_null($sex)) { $fullName = build_full_name($firstname, $lastname); $directoryName = build_directory_name($firstname, $lastname); $sortName = build_sort_name($firstname, $lastname); $birthDate = self::formatBirthDate($infos[2]); if ($type == 'x') { if ($promotion < 1996 && preg_match('/^[0-9]{8}$/', $infos[4])) { /* Allow using Xorg ID for old promotions, to allow fixing typos in names */ $xorgId = $infos[4]; $year = intval(substr($xorgId, 0, 4)); if ($year != $promotion) { $page->trigError("La ligne {$line} n'a pas été ajoutée car le matricule Xorg n'a pas la date correspondant à la promotion."); continue; } } else { $xorgId = Profile::getXorgId($infos[4]); } } elseif (isset($infos[4])) { $xorgId = trim($infos[4]); } else { $xorgId = 0; } if (is_null($xorgId)) { $page->trigError("La ligne {$line} n'a pas été ajoutée car le matricule École est mal renseigné."); continue; } XDB::execute('INSERT INTO profiles (hrpid, xorg_id, ax_id, birthdate_ref, sex, title) VALUES ({?}, {?}, {?}, {?}, {?}, {?})', $infos['hrid'], $xorgId, isset($infos[5]) ? $infos[5] : null, $birthDate, $sex, $titles[$sex]); $pid = XDB::insertId(); XDB::execute('INSERT INTO profile_public_names (pid, lastname_initial, lastname_main, firstname_initial, firstname_main) VALUES ({?}, {?}, {?}, {?}, {?})', $pid, $lastname, $lastname, $firstname, $firstname); XDB::execute('INSERT INTO profile_display (pid, yourself, public_name, private_name, directory_name, short_name, sort_name, promo) VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})', $pid, $firstname, $fullName, $fullName, $directoryName, $fullName, $sortName, $promo); XDB::execute('INSERT INTO profile_education (id, pid, eduid, degreeid, entry_year, grad_year, promo_year, flags) VALUES (100, {?}, {?}, {?}, {?}, {?}, {?}, \'primary\')', $pid, $eduSchools[Profile::EDU_X], $degreeid, $entry_year, $grad_year, $promotion); XDB::execute('INSERT INTO accounts (hruid, type, is_admin, state, full_name, directory_name, sort_name, display_name, lastname, firstname, sex, best_domain) VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})', $infos['hrid'], $type, 0, 'pending', $fullName, $directoryName, $sortName, $firstname, $lastname, $firstname, $sex, $best_domain); $uid = XDB::insertId(); XDB::execute('INSERT INTO account_profiles (uid, pid, perms) VALUES ({?}, {?}, {?})', $uid, $pid, 'owner'); Profile::rebuildSearchTokens($pid, false); } } } XDB::commit(); } else { if (Env::t('add_type') == 'account') { $type = Env::t('type'); $newAccounts = array(); foreach ($lines as $line) { if ($infos = self::formatNewUser($page, $line, $separator, $type, 4)) { $sex = self::formatSex($page, $infos[3], $line); if (!is_null($sex)) { $lastname = capitalize_name($infos[0]); $firstname = capitalize_name($infos[1]); $fullName = build_full_name($firstname, $lastname); $directoryName = build_directory_name($firstname, $lastname); $sortName = build_sort_name($firstname, $lastname); XDB::execute('INSERT INTO accounts (hruid, type, is_admin, state, email, full_name, directory_name, sort_name, display_name, lastname, firstname, sex) VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})', $infos['hrid'], $type, 0, 'pending', $infos[2], $fullName, $directoryName, $sortName, $firstname, $lastname, $firstname, $sex); $newAccounts[$infos['hrid']] = $fullName; } } } if (!empty($newAccounts)) { $page->assign('newAccounts', $newAccounts); } } else { if (Env::t('add_type') == 'ax_id') { $type = 'x'; foreach ($lines as $line) { $infos = explode($separator, $line); if (sizeof($infos) > 3 || sizeof($infos) < 2) { $page->trigError("La ligne {$line} n'a pas été ajoutée : mauvais nombre de champs."); continue; } $infos = array_map('trim', $infos); if (sizeof($infos) == 3) { // Get human readable ID with first name and last name $hrid = User::makeHrid($infos[1], $infos[0], $promotion); $user = User::getSilent($hrid); $axid = $infos[2]; } else { // The first column is the hrid, possibly without the promotion $user = User::getSilent($infos[0] . '.' . $promotion); if (is_null($user)) { $user = User::getSilent($infos[0]); } $axid = $infos[1]; } if (!$axid) { $page->trigError("La ligne {$line} n'a pas été ajoutée : matricule AX vide."); continue; } if (is_null($user)) { $page->trigError("La ligne {$line} n'a pas été ajoutée : aucun compte trouvé."); continue; } $profile = $user->profile(); if ($profile->ax_id) { $page->trigError("Le profil " . $profile->hrpid . " a déjà l'ID AX " . $profile->ax_id); continue; } XDB::execute('UPDATE profiles SET ax_id = {?} WHERE pid = {?}', $axid, $profile->id()); } } } } $errors = $page->nb_errs(); if ($errors == 0) { $page->trigSuccess("L'opération a été effectuée avec succès."); } else { $page->trigSuccess('L\'opération a été effectuée avec succès, sauf pour ' . ($errors == 1 ? 'l\'erreur signalée' : "les {$errors} erreurs signalées") . ' ci-dessus.'); } } else { if (Env::has('add_type')) { $res = XDB::query('SELECT type FROM account_types'); $page->assign('account_types', $res->fetchColumn()); $page->assign('add_type', Env::s('add_type')); } } }
public function commit() { /* TODO: refines this filter on promotions by using userfilter. */ if (XDB::execute("INSERT INTO announces\n SET uid = {?}, creation_date=NOW(), titre={?}, texte={?},\n expiration={?}, promo_min={?}, promo_max={?}, flags=CONCAT(flags,',valide,wiki')", $this->user->id(), $this->titre, $this->texte, $this->expiration, $this->pmin, $this->pmax)) { $eid = XDB::insertId(); if ($this->img) { XDB::execute("INSERT INTO announce_photos\n SET eid = {?}, attachmime = {?}, x = {?}, y = {?}, attach = {?}", XDB::insertId(), $this->imgtype, $this->imgx, $this->imgy, $this->img); } global $globals; if ($globals->banana->event_forum) { require_once 'banana/forum.inc.php'; $banana = new ForumsBanana($this->user); $post = $banana->post($globals->banana->event_forum, $globals->banana->event_reply, $this->titre, MiniWiki::wikiToText($this->texte, false, 0, 80)); if ($post != -1) { XDB::execute("UPDATE announces\n SET creation_date = creation_date, post_id = {?}\n WHERE id = {?}", $post, $eid); } } return true; } return false; }
public function commit() { $res = XDB::query('SELECT id FROM profile_job_enum WHERE name = {?}', $this->name); if ($res->numRows() != 1) { XDB::execute('INSERT INTO profile_job_enum (name, acronym, url, email, holdingid, SIREN_code, NAF_code, AX_code) VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})', $this->name, $this->acronym, $this->url, $this->email, $this->holdingid, $this->SIREN, $this->NAF_code, $this->AX_code); $jobid = XDB::insertId(); $phone = new Phone(array('link_type' => 'hq', 'link_id' => $jobid, 'id' => 0, 'type' => 'fixed', 'display' => $this->tel, 'pub' => 'public')); $fax = new Phone(array('link_type' => 'hq', 'link_id' => $jobid, 'id' => 1, 'type' => 'fax', 'display' => $this->fax, 'pub' => 'public')); $address = new Address(array('jobid' => $jobid, 'type' => Address::LINK_COMPANY, 'text' => $this->address)); $phone->save(); $fax->save(); $address->save(); } else { $jobid = $res->fetchOneCell(); } XDB::execute('UPDATE profile_job SET jobid = {?} WHERE pid = {?} AND id = {?}', $jobid, $this->profile->id(), $this->id); if (XDB::affectedRows() == 0) { return XDB::execute('INSERT INTO profile_job (jobid, pid, id) VALUES ({?}, {?}, {?})', $jobid, $this->profile->id(), $this->id); } return true; }
public function insert() { $schema = Schema::get(get_class($this)); $table = $schema->table(); $id = $schema->id(); XDB::execute("INSERT INTO {$table} SET `{$id}` = NULL"); $this->id = XDB::insertId(); }
function handler_adm_importlogs($page, $step, $param = null) { $page->setTitle('Administration - Paiements - Réconciliations'); $page->changeTpl('payment/reconcile.tpl'); $page->assign('step', $step); if (isset($_SESSION['paymentrecon_data'])) { // create temporary table with imported data XDB::execute('CREATE TEMPORARY TABLE payment_tmp ( reference VARCHAR(255) PRIMARY KEY, date DATE, amount DECIMAL(9,2), commission DECIMAL(9,2) )'); foreach ($_SESSION['paymentrecon_data'] as $i) { XDB::execute('INSERT INTO payment_tmp VALUES ({?}, {?}, {?}, {?})', $i['reference'], $i['date'], $i['amount'], $i['commission']); } } if ($step == 'step1') { $page->assign('title', 'Étape 1'); unset($_SESSION['paymentrecon_method']); unset($_SESSION['paymentrecon_data']); unset($_SESSION['paymentrecon_id']); // was a payment method choosen ? if ($param != null) { $_SESSION['paymentrecon_method'] = (int) $param; pl_redirect('admin/reconcile/importlogs/step2'); } else { // ask to choose a payment method $res = XDB::query('SELECT id, text FROM payment_methods'); $page->assign('methods', $res->fetchAllAssoc()); } } elseif ($step == 'step2') { $page->assign('title', 'Étape 2'); // import logs formated in CVS $fields = array('date', 'reference', 'amount', 'commission'); $importer = new PaymentLogsImporter(); $importer->apply($page, 'admin/reconcile/importlogs/step2', $fields); // if import is finished $result = $importer->get_result(); if ($result != null) { $_SESSION['paymentrecon_data'] = $result; pl_redirect('admin/reconcile/importlogs/step3'); } } elseif ($step == 'step3') { $page->assign('title', 'Étape 3'); // compute reconcilation summary data $res = XDB::query('SELECT MIN(date) AS period_start, MAX(date) AS period_end, count(*) AS payment_count, SUM(amount) AS sum_amounts, SUM(commission) AS sum_commissions FROM payment_tmp'); $recon = $res->fetchOneAssoc(); $recon['method_id'] = $_SESSION['paymentrecon_method']; // create reconciliation item in database if (Post::has('next')) { S::assert_xsrf_token(); // get parameters $recon['period_start'] = preg_replace('/([0-9]{1,2})\\/([0-9]{1,2})\\/([0-9]{4})/', '\\3-\\2-\\1', Post::v('period_start')); $recon['period_end'] = preg_replace('/([0-9]{1,2})\\/([0-9]{1,2})\\/([0-9]{4})/', '\\3-\\2-\\1', Post::v('period_end')); // FIXME: save checks to be done at next step // Create reconcilation item in database // FIXME: check if period doesn't overlap with others for the same method_id XDB::execute('INSERT INTO payment_reconcilations (method_id, period_start, period_end, payment_count, sum_amounts, sum_commissions) VALUES ({?}, {?}, {?}, {?}, {?}, {?})', $recon['method_id'], $recon['period_start'], $recon['period_end'], $recon['payment_count'], $recon['sum_amounts'], $recon['sum_commissions']); $_SESSION['paymentrecon_id'] = XDB::insertId(); // reconcile simple cases (trans.commission n'est modifié que s'il vaut NULL) XDB::execute("UPDATE payment_transactions AS trans, payment_tmp AS tmp\n SET trans.recon_id = {?}, trans.commission=tmp.commission\n WHERE trans.fullref = tmp.reference\n AND trans.amount = tmp.amount AND DATE(trans.ts_confirmed) = tmp.date\n AND (trans.commission IS NULL OR trans.commission = tmp.commission)\n AND method_id = {?} AND recon_id IS NULL AND status = 'confirmed'", $_SESSION['paymentrecon_id'], $recon['method_id']); pl_redirect("admin/reconcile/importlogs/step4"); // show summary of the imported data + ask form start/end of reconcilation period } else { $recon['period_start'] = preg_replace('/([0-9]{4})-([0-9]{2})-([0-9]{2})/', '\\3/\\2/\\1', $recon['period_start']); $recon['period_end'] = preg_replace('/([0-9]{4})-([0-9]{2})-([0-9]{2})/', '\\3/\\2/\\1', $recon['period_end']); $page->assign('recon', $recon); } } elseif ($step == 'step4') { $page->assign('title', 'Étape 4'); // get reconcilation summary informations $res = XDB::query('SELECT * FROM payment_reconcilations WHERE id = {?}', $_SESSION['paymentrecon_id']); $recon = $res->fetchOneAssoc(); $page->assign('recon', $recon); if (Post::has('force')) { S::assert_xsrf_token(); foreach (Post::v('force') as $id => $value) { XDB::execute('UPDATE payment_transactions AS trans, payment_tmp AS tmp SET trans.recon_id = {?}, trans.commission = tmp.commission WHERE trans.id = {?} AND trans.fullref = tmp.reference', $_SESSION['paymentrecon_id'], $id); } $page->trigSuccess('La réconciliation a été forcée pour ' . count(Post::v('force')) . ' transaction(s).'); } elseif (Post::has('next')) { if (strlen($recon['comments']) < 3) { $page->trigError('Le commentaire doit contenir au moins 3 caractères.'); } else { XDB::execute("UPDATE payment_reconcilations SET status = 'transfering' WHERE id = {?}", $_SESSION['paymentrecon_id']); pl_redirect('admin/reconcile/step5'); } } elseif (Post::has('savecomments')) { S::assert_xsrf_token(); $recon['comments'] = Post::v('comments'); $page->assign('recon', $recon); XDB::execute('UPDATE payment_reconcilations SET comments = {?} WHERE id = {?}', $recon['comments'], $_SESSION['paymentrecon_id']); $page->trigSuccess('Les commentaires ont été enregistrés.'); } // reconcilation results - ok $res = XDB::query('SELECT count(*), SUM(amount), SUM(commission) FROM payment_transactions WHERE recon_id = {?}', $recon['id']); list($ok_count, $ok_sum_amounts, $ok_sum_coms) = $res->fetchOneRow(); $page->assign('ok_count', $ok_count); // reconcilation results - ref exists, but some data differs $res = XDB::query('SELECT id, fullref, method_id, ts_confirmed, trans.amount, trans.commission, status, recon_id, reference, date, tmp.amount as amount2, tmp.commission as commission2 FROM payment_transactions AS trans INNER JOIN payment_tmp AS tmp ON (trans.fullref = tmp.reference) WHERE trans.recon_id IS NULL OR trans.recon_id != {?}', $recon['id']); $differs = $res->fetchAllAssoc(); $page->assign_by_ref('differs', $differs); $page->assign('differ_count', count($differs)); // reconcilation results - ref doesn't exists in database $res = XDB::query('SELECT tmp.* FROM payment_tmp AS tmp LEFT JOIN payment_transactions AS trans ON (trans.fullref = tmp.reference) WHERE trans.fullref IS NULL'); $only_import = $res->fetchAllAssoc(); $page->assign_by_ref('only_import', $only_import); $page->assign('onlyim_count', count($only_import)); // reconcilation results - exists in database but not in import $res = XDB::query('SELECT trans.* FROM payment_transactions AS trans LEFT JOIN payment_tmp AS tmp ON (trans.fullref = tmp.reference) WHERE {?} <= DATE(trans.ts_confirmed) AND DATE(trans.ts_confirmed) <= {?} AND tmp.reference IS NULL AND method_id = {?}', $recon['period_start'], $recon['period_end'], $recon['method_id']); $only_database = $res->fetchAllAssoc(); $page->assign_by_ref('only_database', $only_database); $page->assign('onlydb_count', count($only_database)); } }
/** * Insert a new Wiki in the DB */ public function insert() { XDB::execute('INSERT INTO wiki SET name = {?}', $this->name); $this->id = XDB::insertId(); }
function handler_edit($page, $eid = null) { global $globals; // get eid if the the given one is a short name if (!is_null($eid) && !is_numeric($eid)) { $res = XDB::query("SELECT eid\n FROM group_events\n WHERE asso_id = {?} AND short_name = {?}", $globals->asso('id'), $eid); if ($res->numRows()) { $eid = (int) $res->fetchOneCell(); } } // check the event is in our group if (!is_null($eid)) { $res = XDB::query("SELECT short_name\n FROM group_events\n WHERE eid = {?} AND asso_id = {?}", $eid, $globals->asso('id')); if ($res->numRows()) { $infos = $res->fetchOneAssoc(); } else { return PL_FORBIDDEN; } } $page->changeTpl('xnetevents/edit.tpl'); $moments = range(1, 4); $error = false; $page->assign('moments', $moments); if (Post::v('intitule')) { S::assert_xsrf_token(); $this->load('xnetevents.inc.php'); $short_name = event_change_shortname($page, $eid, $infos['short_name'], Env::v('short_name', '')); if ($short_name != Env::v('short_name')) { $error = true; } $evt = array('eid' => $eid, 'asso_id' => $globals->asso('id'), 'paiement_id' => Post::v('paiement_id') > 0 ? Post::v('paiement_id') : null, 'debut' => Post::v('deb_Year') . '-' . Post::v('deb_Month') . '-' . Post::v('deb_Day') . ' ' . Post::v('deb_Hour') . ':' . Post::v('deb_Minute') . ':00', 'fin' => Post::v('fin_Year') . '-' . Post::v('fin_Month') . '-' . Post::v('fin_Day') . ' ' . Post::v('fin_Hour') . ':' . Post::v('fin_Minute') . ':00', 'short_name' => $short_name); $trivial = array('intitule', 'descriptif', 'noinvite', 'subscription_notification', 'show_participants', 'accept_nonmembre', 'uid'); foreach ($trivial as $k) { $evt[$k] = Post::v($k); } if (!$eid) { $evt['uid'] = S::v('uid'); } if (Post::v('deadline')) { $evt['deadline_inscription'] = Post::v('inscr_Year') . '-' . Post::v('inscr_Month') . '-' . Post::v('inscr_Day'); } else { $evt['deadline_inscription'] = null; } // Store the modifications in the database XDB::execute('INSERT INTO group_events (eid, asso_id, uid, intitule, paiement_id, descriptif, debut, fin, show_participants, short_name, deadline_inscription, noinvite, accept_nonmembre, subscription_notification) VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}) ON DUPLICATE KEY UPDATE asso_id = VALUES(asso_id), uid = VALUES(uid), intitule = VALUES(intitule), paiement_id = VALUES(paiement_id), descriptif = VALUES(descriptif), debut = VALUES(debut), fin = VALUES(fin), show_participants = VALUES(show_participants), short_name = VALUES(short_name), deadline_inscription = VALUES(deadline_inscription), noinvite = VALUES(noinvite), accept_nonmembre = VALUES(accept_nonmembre), subscription_notification = VALUES(subscription_notification)', $evt['eid'], $evt['asso_id'], $evt['uid'], $evt['intitule'], $evt['paiement_id'], $evt['descriptif'], $evt['debut'], $evt['fin'], $evt['show_participants'], $evt['short_name'], $evt['deadline_inscription'], $evt['noinvite'], $evt['accept_nonmembre'], $evt['subscription_notification']); // if new event, get its id if (!$eid) { $eid = XDB::insertId(); } foreach ($moments as $i) { if (Post::v('titre' . $i)) { $nb_moments++; $montant = strtr(Post::v('montant' . $i), ',', '.'); $money_defaut += (double) $montant; XDB::execute('INSERT INTO group_event_items (eid, item_id, titre, details, montant) VALUES ({?}, {?}, {?}, {?}, {?}) ON DUPLICATE KEY UPDATE titre = VALUES(titre), details = VALUES(details), montant = VALUES(montant)', $eid, $i, Post::v('titre' . $i), Post::v('details' . $i), $montant); } else { XDB::execute('DELETE FROM group_event_items WHERE eid = {?} AND item_id = {?}', $eid, $i); } } // request for a new payment if (Post::v('paiement_id') == -1 && $money_defaut >= 0) { $p = new PayReq(S::user(), $globals->asso('nom') . " - " . Post::v('intitule'), Post::v('site'), $money_defaut, Post::v('confirmation'), 0, 999, $globals->asso('id'), $eid, Post::v('payment_public') == 'yes'); if ($p->accept()) { $p->submit(); } else { $page->assign('payment_message', Post::v('confirmation')); $page->assign('payment_site', Post::v('site')); $page->assign('payment_public', Post::v('payment_public') == 'yes'); $page->assign('error', true); $error = true; } } // events with no sub-event: add a sub-event with default name if ($nb_moments == 0) { XDB::execute("INSERT INTO group_event_items\n VALUES ({?}, {?}, 'Événement', '', 0)", $eid, 1); } if (!$error) { pl_redirect('events'); } } // get a list of all the payment for this asso $res = XDB::iterator("SELECT id, text\n FROM payments\n WHERE asso_id = {?} AND NOT FIND_IN_SET('old', flags)", $globals->asso('id')); $paiements = array(); while ($a = $res->next()) { $paiements[$a['id']] = $a['text']; } $page->assign('paiements', $paiements); // when modifying an old event retreive the old datas if ($eid) { $res = XDB::query("SELECT eid, intitule, descriptif, debut, fin, uid,\n show_participants, paiement_id, short_name,\n deadline_inscription, noinvite, accept_nonmembre, subscription_notification\n FROM group_events\n WHERE eid = {?}", $eid); $evt = $res->fetchOneAssoc(); // find out if there is already a request for a payment for this event $res = XDB::query("SELECT stamp\n FROM requests\n WHERE type = 'paiements' AND data LIKE {?}", PayReq::same_event($eid, $globals->asso('id'))); $stamp = $res->fetchOneCell(); if ($stamp) { $evt['paiement_id'] = -2; $evt['paiement_req'] = $stamp; } $page->assign('evt', $evt); // get all the different moments infos $res = XDB::iterator("SELECT item_id, titre, details, montant\n FROM group_event_items AS ei\n INNER JOIN group_events AS e ON(e.eid = ei.eid)\n WHERE e.eid = {?}\n ORDER BY item_id", $eid); $items = array(); while ($item = $res->next()) { $items[$item['item_id']] = $item; } $page->assign('items', $items); } $page->assign('url_ref', $eid); }
/** Create a new, empty, pending newsletter issue * @p $nlid The id of the NL for which a new pending issue should be created. * @return Id of the newly created issue. */ public function createPending() { XDB::execute('INSERT INTO newsletter_issues SET nlid = {?}, state=\'new\', date=NOW(), title=\'to be continued\', mail_title=\'to be continued\'', $this->id); return XDB::insertId(); }
$subsectors = XDB::iterator('SELECT `id`, `name` FROM `profile_job_subsector_enum` WHERE sectorid = {?}', $oldsector['id']); while ($oldsubsector = $subsectors->next()) { if ($oldsubsector['name'] == $oldsector['name']) { // adds sector term to jobs and mentorships linked to subsector with same name as sector XDB::execute('INSERT INTO `profile_job_term` SELECT `pid`, `id`, {?}, "original" FROM `profile_job` WHERE `sectorid` = {?} AND `subsectorid` = {?}', $sector_id, $oldsector['id'], $oldsubsector['id']); XDB::execute('INSERT INTO `profile_mentor_term` SELECT `pid`, {?} FROM `profile_mentor_sector` WHERE `sectorid` = {?} AND `subsectorid` = {?}', $sector_id, $oldsector['id'], $oldsubsector['id']); continue; } // adds subsector as term XDB::execute('INSERT INTO `profile_job_term_enum` (`name`, `full_name`) VALUES ( {?}, {?} )', $oldsubsector['name'], $oldsubsector['name'] . ' (secteur)'); $subsector_id = XDB::insertId(); // links to root for sectors and to sector XDB::execute('INSERT INTO `profile_job_term_relation` VALUES ({?}, {?}, "narrower", "computed"), ({?}, {?}, "narrower", "original"), ({?}, {?}, "narrower", "computed")', $root_sector_id, $subsector_id, $sector_id, $subsector_id, $subsector_id, $subsector_id); // adds subsector term to linked jobs and mentorships XDB::execute('INSERT INTO `profile_job_term` SELECT `pid`, `id`, {?}, "original" FROM `profile_job` WHERE `sectorid` = {?} AND `subsectorid` = {?}', $subsector_id, $oldsector['id'], $oldsubsector['id']); XDB::execute('INSERT INTO `profile_mentor_term` SELECT `pid`, {?} FROM `profile_mentor_sector` WHERE `sectorid` = {?} AND `subsectorid` = {?}', $subsector_id, $oldsector['id'], $oldsubsector['id']); } } /* vim:set et sw=4 sts=4 ts=4: */
function handler_edit_announce($page, $aid = null) { global $globals, $platal; $page->changeTpl('xnetgrp/announce-edit.tpl'); $page->assign('new', is_null($aid)); $art = array(); if (Post::v('valid') == 'Visualiser' || Post::v('valid') == 'Enregistrer' || Post::v('valid') == 'Supprimer l\'image' || Post::v('valid') == 'Pas d\'image') { S::assert_xsrf_token(); if (!is_null($aid)) { $art['id'] = $aid; } $art['titre'] = Post::v('titre'); $art['texte'] = Post::v('texte'); $art['contacts'] = Post::v('contacts'); $art['promo_min'] = Post::i('promo_min'); $art['promo_max'] = Post::i('promo_max'); $art['nom'] = S::v('nom'); $art['prenom'] = S::v('prenom'); $art['promo'] = S::v('promo'); $art['hruid'] = S::user()->login(); $art['uid'] = S::user()->id(); $art['expiration'] = Post::v('expiration'); $art['public'] = Post::has('public'); $art['xorg'] = Post::has('xorg'); $art['nl'] = Post::has('nl'); $art['event'] = Post::v('event'); $upload = new PlUpload(S::user()->login(), 'xnetannounce'); $this->upload_image($page, $upload); $art['contact_html'] = $art['contacts']; if ($art['event']) { $art['contact_html'] .= "\n{$globals->baseurl}/{$platal->ns}events/sub/{$art['event']}"; } if (!$art['public'] && ($art['promo_min'] > $art['promo_max'] && $art['promo_max'] != 0 || $art['promo_min'] != 0 && ($art['promo_min'] <= 1900 || $art['promo_min'] >= 2020) || $art['promo_max'] != 0 && ($art['promo_max'] <= 1900 || $art['promo_max'] >= 2020))) { $page->trigError("L'intervalle de promotions est invalide."); Post::kill('valid'); } if (!trim($art['titre']) || !trim($art['texte'])) { $page->trigError("L'article doit avoir un titre et un contenu."); Post::kill('valid'); } if (Post::v('valid') == 'Supprimer l\'image') { $upload->rm(); Post::kill('valid'); } $art['photo'] = $upload->exists() || Post::i('photo'); if (Post::v('valid') == 'Pas d\'image' && !is_null($aid)) { XDB::query('DELETE FROM group_announces_photo WHERE eid = {?}', $aid); $upload->rm(); Post::kill('valid'); $art['photo'] = false; } } if (Post::v('valid') == 'Enregistrer') { $promo_min = $art['public'] ? 0 : $art['promo_min']; $promo_max = $art['public'] ? 0 : $art['promo_max']; $flags = new PlFlagSet(); if ($art['public']) { $flags->addFlag('public'); } if ($art['photo']) { $flags->addFlag('photo'); } if (is_null($aid)) { $fulltext = $art['texte']; if (!empty($art['contact_html'])) { $fulltext .= "\n\n'''Contacts :'''\\\\\n" . $art['contact_html']; } $post = null; if ($globals->asso('forum')) { require_once 'banana/forum.inc.php'; $banana = new ForumsBanana(S::user()); $post = $banana->post($globals->asso('forum'), null, $art['titre'], MiniWiki::wikiToText($fulltext, false, 0, 80)); } XDB::query('INSERT INTO group_announces (uid, asso_id, create_date, titre, texte, contacts, expiration, promo_min, promo_max, flags, post_id) VALUES ({?}, {?}, NOW(), {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})', S::i('uid'), $globals->asso('id'), $art['titre'], $art['texte'], $art['contact_html'], $art['expiration'], $promo_min, $promo_max, $flags, $post); $aid = XDB::insertId(); if ($art['photo']) { list($imgx, $imgy, $imgtype) = $upload->imageInfo(); XDB::execute('INSERT INTO group_announces_photo SET eid = {?}, attachmime = {?}, x = {?}, y = {?}, attach = {?}', $aid, $imgtype, $imgx, $imgy, $upload->getContents()); } if ($art['xorg']) { $article = new EvtReq("[{$globals->asso('nom')}] " . $art['titre'], $fulltext, $art['promo_min'], $art['promo_max'], $art['expiration'], "", S::user(), $upload); $article->submit(); $page->trigWarning("L'affichage sur la page d'accueil de Polytechnique.org est en attente de validation."); } else { if ($upload && $upload->exists()) { $upload->rm(); } } if ($art['nl']) { $article = new NLReq(S::user(), $globals->asso('nom') . " : " . $art['titre'], $art['texte'], $art['contact_html']); $article->submit(); $page->trigWarning("La parution dans la Lettre Mensuelle est en attente de validation."); } } else { XDB::query('UPDATE group_announces SET titre = {?}, texte = {?}, contacts = {?}, expiration = {?}, promo_min = {?}, promo_max = {?}, flags = {?} WHERE id = {?} AND asso_id = {?}', $art['titre'], $art['texte'], $art['contacts'], $art['expiration'], $promo_min, $promo_max, $flags, $art['id'], $globals->asso('id')); if ($art['photo'] && $upload->exists()) { list($imgx, $imgy, $imgtype) = $upload->imageInfo(); XDB::execute('INSERT INTO group_announces_photo (eid, attachmime, attach, x, y) VALUES ({?}, {?}, {?}, {?}, {?}) ON DUPLICATE KEY UPDATE attachmime = VALUES(attachmime), attach = VALUES(attach), x = VALUES(x), y = VALUES(y)', $aid, $imgtype, $upload->getContents(), $imgx, $imgy); $upload->rm(); } } } if (Post::v('valid') == 'Enregistrer' || Post::v('valid') == 'Annuler') { pl_redirect(""); } if (empty($art) && !is_null($aid)) { $res = XDB::query("SELECT *, FIND_IN_SET('public', flags) AS public,\n FIND_IN_SET('photo', flags) AS photo\n FROM group_announces\n WHERE asso_id = {?} AND id = {?}", $globals->asso('id'), $aid); if ($res->numRows()) { $art = $res->fetchOneAssoc(); $art['contact_html'] = $art['contacts']; } else { $page->kill("Aucun article correspond à l'identifiant indiqué."); } } if (is_null($aid)) { $events = XDB::iterator("SELECT *\n FROM group_events\n WHERE asso_id = {?} AND archive = 0", $globals->asso('id')); if ($events->total()) { $page->assign('events', $events); } } $art['contact_html'] = @MiniWiki::WikiToHTML($art['contact_html']); $page->assign('art', $art); $page->assign_by_ref('upload', $upload); }
public function insert() { XDB::execute('INSERT INTO castes SET `group` = {?}, rights = {?}', $this->group->id(), (string) $this->rights); $this->id = XDB::insertId(); }
public function insert() { XDB::execute('INSERT INTO images SET seen = 0, lastseen = NOW()'); $this->id = XDB::insertId(); }
public function insert() { XDB::startTransaction(); XDB::execute('INSERT INTO surveys SET writer = {?}', S::user()->id()); $this->id = XDB::insertId(); foreach ($this->questions as $question) { $question->insert($ssid); } XDB::commit(); }
public function insert($id = null, $type = 'all') { if ($id == null) { $this->name = uniqid(); XDB::execute('INSERT INTO groups SET name = {?}', $this->name); $this->id = XDB::insertId(); } else { $this->name = 'g_' . $id; XDB::execute('INSERT INTO groups SET gid = {?}, name= {?}', $id, $this->name); $this->id = $id; } /* * Create the castes */ if ($type == 'user') { // A user group only needs an admin caste & a restricted caste. $this->addCaste(Rights::admin()); $this->addCaste(Rights::restricted()); } else { $admins = $this->addCaste(Rights::admin()); $members = $this->addCaste(Rights::member()); $logics = $this->addCaste(Rights::logic()); $friends = $this->addCaste(Rights::friend()); /* * Create the 'restricted' caste */ $restricted = new UserFilter(new UFC_Caste(array($admins, $members, $logics))); $this->addCaste(Rights::restricted())->userfilter($restricted); /* * Create the 'everybody' caste * It's better not to refer to the restricted caste, as we don't know in what * order the bubbling is going to happen */ $everybody = new UserFilter(new UFC_Caste(array($admins, $members, $logics, $friends))); $this->addCaste(Rights::everybody())->userfilter($everybody); } }
public function vote($uid, $args) { XDB::execute('INSERT INTO survey_votes SET survey_id = {?}, uid = {?}', $this->id, $uid == 0 ? null : $uid); // notes the user as having voted $vid = XDB::insertId(); for ($i = 0; $i < count($this->questions); $i++) { $ans = $this->questions[$i]->checkAnswer($args[$i]); if (!is_null($ans) && is_array($ans)) { foreach ($ans as $a) { XDB::execute('INSERT INTO survey_answers SET vote_id = {?}, question_id = {?}, answer = {?}', $vid, $i, $a); } } } }
public function insert($type = '') { XDB::execute('INSERT INTO links SET id = NULL'); $r = XDB::query('SELECT MAX(rank) FROM links WHERE ns = {?}', $type)->fetchOneCell(); $this->id = XDB::insertId(); $this->ns($type); $this->rank($r + 1); }
protected function action_saveSubs($groups) { global $globals; $uid = $this->user->id(); Banana::$profile['subscribe'] = array(); XDB::execute('DELETE FROM forum_subs WHERE uid = {?}', $this->user->id()); if (!count($groups)) { return true; } $fids = XDB::fetchAllAssoc('name', 'SELECT fid, name FROM forums'); $diff = array_diff($groups, array_keys($fids)); foreach ($diff as $g) { XDB::execute('INSERT INTO forums (name) VALUES ({?})', $g); $fids[$g] = XDB::insertId(); } foreach ($groups as $g) { XDB::execute('INSERT INTO forum_subs (fid, uid) VALUES ({?}, {?})', $fids[$g], $uid); Banana::$profile['subscribe'][] = $g; } }
public function insert($id = null) { if ($id == null) { XDB::execute('INSERT INTO account SET perms = "user"'); $this->id = XDB::insertId(); } else { XDB::execute('INSERT INTO account SET uid = {?}, perms= "user"', $id); $this->id = $id; } $group = new Group(); $group->insert(null, 'user'); $group->ns(Group::NS_USER); $group->name('user_' . $this->id()); $group->leavable(false); $group->visible(false); $group->label('Groupe personnel de ' . $this->fullName()); XDB::execute('UPDATE account SET `group` = {?} WHERE uid = {?}', $group->id(), $this->id()); $group->caste(Rights::admin())->addUser($this); $group->caste(Rights::restricted())->addUser($this); $this->group = $group; }
/** * to use to send the data for moderation * if $this->item->unique is true, then the database will be cleaned before */ public function insert() { if (is_null($this->item)) { return; } if ($this->item->unique()) { XDB::execute('DELETE FROM validate WHERE writer = {?} AND `group` = {?} AND type = {?}', $this->writer->id(), $this->group->id(), $this->type); } XDB::execute('INSERT INTO validate SET writer = {?}, `group` = {?}, type = {?}, item = {?}, created = NOW()', $this->writer->id(), $this->group->id(), $this->type, $this->itemToDb()); $this->id = XDB::insertId(); $this->item->sendmailadmin(); }
public function insert() { XDB::execute('INSERT INTO activities_instances SET activity = {?}, writer = {?}, comment = {?}, begin = {?}, end = {?}', $this->activity->id(), $this->writer->id(), $this->comment, $this->begin->toDb(), $this->end->toDb()); $this->id = XDB::insertId(); }