PHP Method User::ID, codiad Code Examples

This page contains top rated real world PHP examples of method User::ID from package codiad extracted from open source projects. You can rate examples to help us improve the quality of examples
Example #1
Show file File: boite.class.php Project: leqg/leqg
0
 /**
  * Effectue le reporting d'un boîtage
  *
  * @param string  $mission  ID de la mission concernée par le reporting (MD5)
  * @param string  $immeuble ID de l'immeuble concerné par le reporting (MD5)
  * @param integer $statut   Statut du reporting :
  *                          2 pour fait,
  *                          1 pour inaccessible
  *
  * @return void
  * @static
  */
 public static function reporting(string $mission, string $immeuble, int $statut)
 {
     // On met en place le lien vers la base de données
     $link = Configuration::read('db.link');
     // On récupère les informations sur la mission
     $informations = self::informations($mission);
     // On prépare et exécute la requête
     $query = 'UPDATE `boitage`
               SET `boitage_statut` = :statut,
                   `boitage_date` = NOW(),
                   `boitage_militant` = :cookie
               WHERE MD5(`mission_id`) = :mission
               AND MD5(`immeuble_id`) = :immeuble';
     $query = $link->prepare($query);
     $query->bindParam(':statut', $statut);
     $query->bindParam(':cookie', User::ID(), PDO::PARAM_INT);
     $query->bindParam(':mission', $mission);
     $query->bindParam(':immeuble', $immeuble);
     $query->execute();
     // Si l'immeuble a été fait,
     // on reporte le boitage pour tous les les contacts
     if ($statut == 2) {
         // On cherche tous les contacts qui habitent ou sont déclarés
         // électoralement dans l'immeuble en question pour
         // créer un élément d'historique
         $query = 'SELECT `contact_id`
                   FROM `contacts`
                   WHERE MD5(`immeuble_id`) = :immeuble
                   OR MD5(`adresse_id`) = :immeuble';
         $query = $link->prepare($query);
         $query->bindParam(':immeuble', $immeuble);
         $query->execute();
         $contacts = $query->fetchAll(PDO::FETCH_NUM);
         // On fait la boucle de tous ces contacts
         // pour leur ajouter l'élément d'historique
         foreach ($contacts as $contact) {
             $query = 'INSERT INTO `historique` (`contact_id`,
                                                 `compte_id`,
                                                 `historique_type`,
                                                 `historique_date`,
                                                 `historique_objet`)
                       VALUES (:contact,
                               :compte,
                               "boite",
                               NOW(),
                               :mission)';
             $query = $link->prepare($query);
             $query->bindParam(':contact', $contact[0], PDO::PARAM_INT);
             $query->bindParam(':compte', User::ID(), PDO::PARAM_INT);
             $query->bindParam(':mission', $informations['mission_nom']);
             $query->execute();
         }
     }
 }
Example #2
Show file File: admin-creation.tpl.php Project: leqg/leqg
0
 $link = Configuration::read('db.core');
 $client = Configuration::read('ini')['LEQG']['compte'];
 $query = $link->prepare('INSERT INTO `user` (`client`, `email`, `password`, `firstname`, `lastname`, `auth_level`) VALUES (:client, :email, :pass, :first, :last, :auth)');
 $query->bindParam(':client', $client);
 $query->bindParam(':email', $form['email']);
 $query->bindParam(':pass', $form['pass_sec']);
 $query->bindParam(':first', $form['prenom']);
 $query->bindParam(':last', $form['nom']);
 $query->bindParam(':auth', $form['selectAuth']);
 $query->execute();
 // On lance l'envoi du mail avec les informations de connexion
 $email = file_get_contents('tpl/mail/user-creation.tpl.html');
 $objet = 'LeQG – Votre compte a été créé par ' . User::getLoginByID(User::ID()) . '.';
 // On insère dans le mail l'URL du fichier pour qu'il puisse être téléchargé
 $email = strtr($email, array('{COMPTE}' => $form['prenom'] . ' ' . $form['nom']));
 $email = strtr($email, array('{USER}' => User::getLoginByID(User::ID())));
 $email = strtr($email, array('{EMAIL}' => $form['email']));
 $email = strtr($email, array('{PASS}' => $form['pass']));
 // On démarre l'instance
 $mail = new PHPMailer();
 // On récupère les informations sur l'API
 $api = Configuration::read('api');
 // On contacte le serveur d'envoi SMTP
 $mail->IsSMTP();
 $mail->SMTPAuth = true;
 $mail->Host = $api['mail']['smtp']['host'];
 $mail->Port = $api['mail']['smtp']['port'];
 $mail->Username = $api['mail']['smtp']['user'];
 $mail->Password = $api['mail']['smtp']['pass'];
 // On configure le mail à envoyer
 $mail->CharSet = $api['mail']['charset'];
Example #3
Show file File: template.class.php Project: leqg/leqg
0
 /**
  * Create a new template
  *
  * @return integer
  * @static
  */
 public static function create()
 {
     $user = User::ID();
     $query = Core::query('template-create');
     $query->bindParam(':user', $user);
     $query->execute();
     return Configuration::read('db.link')->lastInsertId();
 }
Example #4
Show file File: campaign.class.php Project: leqg/leqg
0
 /**
  * Create a new campaign
  *
  * @param string $method Campaign method (email, sms, publi)
  *
  * @return int
  * @static
  **/
 public static function create(string $method)
 {
     $user = User::ID();
     $query = Core::query('campaign-create');
     $query->bindParam(':type', $method);
     $query->bindParam(':user', $user, PDO::PARAM_INT);
     $query->execute();
     return Configuration::read('db.link')->lastInsertId();
 }
Example #5
Show file File: people.class.php Project: leqg/leqg
0
 /**
  * File upload for an asked person
  *
  * @param  mixed $file       Uploaded file
  * @param  array $data       Linked data
  * @param  array $extensions Auth extensions
  * @param  int   $maxsize    File max allowed size
  * @result bool
  * */
 public function file_upload($file, array $data, $extensions = false, $maxsize = false)
 {
     $extension = substr(strrchr($file['name'], '.'), 1);
     $nom = preg_replace("#[^a-zA-Z0-9]#", "-", strtolower($data['titre'])) . '-' . uniqid() . '.' . $extension;
     if (!isset($file) || $file['error'] > 0) {
         return false;
     }
     if ($maxsize !== false && $file['size'] > $maxsize) {
         return false;
     }
     if ($extensions !== false && !in_array($extension, $extensions)) {
         return false;
     }
     $destination = 'uploads/' . $nom;
     if (move_uploaded_file($file['tmp_name'], $destination)) {
         $utilisateur = User::ID();
         $query = Core::query('file-upload');
         $query->bindValue(':people', $this->_people['id'], PDO::PARAM_INT);
         $query->bindValue(':user', $utilisateur, PDO::PARAM_INT);
         $query->bindValue(':event', $data['evenement'], PDO::PARAM_INT);
         $query->bindValue(':name', $data['titre']);
         $query->bindValue(':desc', $data['description']);
         $query->bindValue(':url', $nom);
         $query->execute();
         return true;
     } else {
         return false;
     }
 }
Example #6
Show file File: admin-user.tpl.php Project: leqg/leqg
0
if (User::ID() != $_GET['compte']) {
    ?>
    	<section class="contenu demi">
        	<a href="ajax.php?script=admin-suppression&compte=<?php 
    echo $_GET['compte'];
    ?>
" class="nostyle"><button class="deleting long" style="margin: 0 auto">Supprimer ce compte</button></a>
    	</section>
        <?php 
}
?>
	</div>
    
    <div class="colonne demi droite">
        <?php 
if (User::ID() != $_GET['compte']) {
    ?>
        <section class="contenu demi">
            <h4>Attribuer de nouveaux droits</h4>
            
            <a href="ajax.php?script=admin-auth&compte=<?php 
    echo $user['id'];
    ?>
&lvl=8" class="nostyle"><button class="jaune long">Administrateur</button></a>
            <a href="ajax.php?script=admin-auth&compte=<?php 
    echo $user['id'];
    ?>
&lvl=3" class="nostyle"><button class="vert long">Militant</button></a>
        </section>
        <?php 
}
Example #7
Show file File: mission.class.php Project: leqg/leqg
0
 /**
  * Create a new mission
  *
  * @param string $type  mission type
  * @param array  $infos mission informations
  *
  * @return integer
  * @static
  */
 public static function creation(string $type, array $infos)
 {
     // On récupère la connexion à la base de données
     $link = Configuration::read('db.link');
     $userId = User::ID();
     // On retraite la date entrée
     if (!empty($infos['date'])) {
         $date = explode('/', $infos['date']);
         krsort($date);
         $date = implode('-', $date);
     } else {
         $date = null;
     }
     // On exécute la requête d'insertion dans la base de données
     $sql = 'INSERT INTO `mission` (`createur_id`,
                                    `responsable_id`,
                                    `mission_deadline`,
                                    `mission_nom`,
                                    `mission_type`)
             VALUES (:cookie,
                     :responsable,
                     :deadline,
                     :nom,
                     :type)';
     $query = $link->prepare($sql);
     $query->bindParam(':cookie', $userId, PDO::PARAM_INT);
     $query->bindParam(':responsable', $infos['responsable'], PDO::PARAM_INT);
     $query->bindParam(':deadline', $date);
     $query->bindParam(':nom', $infos['nom']);
     $query->bindParam(':type', $type);
     $query->execute();
     // On affiche l'identifiant de la nouvelle mission
     return $link->lastInsertId();
 }
Example #8
Show file File: class_user.php Project: beerdude26/NewNova
0
 public function Equals(self $other)
 {
     if ($this->ID() === $other->ID()) {
         return true;
     }
     return false;
 }
Example #9
Show file File: index.php Project: leqg/leqg
0
        }
    } elseif ($_GET['page'] == 'services') {
        // Si l'utilisateur a une forte accréditation,
        // il s'agit de l'écran d'accueil du module contacts qui est demandé
        if (User::authLevel() >= 5) {
            Core::goPage('contacts', true);
        } else {
            Core::loadTemplate('services');
        }
    } else {
        if (User::authLevel() >= 5) {
            Core::goPage('contacts', true);
        } else {
            Core::goPage('services', true);
        }
    }
}
// Une fois les templates chargés, on met en place la purge et on calcule le
// temps nécessaire au chargement de la page à des fins de statistique
$loading['end'] = microtime();
$loading['time'] = $loading['end'] - $loading['begin'];
$loading['time-sql'] = number_format($loading['time'], 6, '.', '');
// On prépare la requête d'analyse du temps de chargement
$page = isset($_GET['page']) ? $_GET['page'] : '';
// On enregistre le temps de chargement de la page à des fins statistiques
$query = $core->prepare('INSERT INTO `stats` (`user`, `page`, `time`) VALUES (:compte, :page, :temps)');
$utilisateur = User::ID();
$query->bindParam(':compte', $utilisateur);
$query->bindParam(':page', $page);
$query->bindParam(':temps', $loading['time-sql']);
$query->execute();
Example #10
Show file File: rappel.class.php Project: leqg/leqg
0
 /**
  * Create a new phonecall mission
  *
  * @return integer
  * @static
  */
 public static function creer()
 {
     // On commence par paramétrer les données PDO
     $link = Configuration::read('db.link');
     $userId = User::ID();
     // On prépare la requête
     $sql = 'INSERT INTO `argumentaires` (`createur_id`)
             VALUES (:id)';
     $query = $link->prepare($sql);
     $query->bindParam(':id', $userId);
     // On exécute la requête
     $query->execute();
     // On récupère l'identifiant des données insérées
     $identifiant = $link->lastInsertId();
     // On retourne cet identifiant
     return $identifiant;
 }
Example #11
Show file File: boitage.tpl.php Project: leqg/leqg
0
<?php

/**
 * Open a mission
 *
 * PHP version 5
 *
 * @category Mobile
 * @package  LeQG
 * @author   Damien Senger <hi@hiwelo.co>
 * @license  https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License 3.0
 * @link     http://leqg.info
 */
// On charge la liste des missions ouvertes où la personne est inscrite
$missions_ouvertes = Mission::openMissions('boitage', User::ID());
// On charge le header
Core::loadHeader();
?>
<h2>Missions de boîtage</h2>

<ul class="listeMissions">
<?php 
if ($missions_ouvertes) {
    foreach ($missions_ouvertes as $mission_ouverte) {
        $mission = new Mission(md5($mission_ouverte));
        $deadline = DateTime::createFromFormat('Y-m-d', $mission->get('mission_deadline'));
        ?>
    <li>
        <a href="<?php 
        Core::goPage('mission', array('code' => $mission->get('mission_hash')));
        ?>
Example #12
Show file File: porte.tpl.php Project: leqg/leqg
0
<?php

// On charge la liste des missions ouvertes où la personne est inscrite
$missions_ouvertes = Mission::openMissions('porte', User::ID());
// On charge le header
Core::loadHeader();
?>
	<h2>Missions de porte-à-porte</h2>

	<ul class="listeMissions">
    <?php 
if ($missions_ouvertes) {
    foreach ($missions_ouvertes as $mission_ouverte) {
        $mission = new Mission(md5($mission_ouverte));
        $deadline = DateTime::createFromFormat('Y-m-d', $mission->get('mission_deadline'));
        ?>
		<li>
		    <a href="<?php 
        Core::goPage('mission', array('code' => $mission->get('mission_hash')));
        ?>
" class="nostyle">
        <h4><?php 
        echo $mission->get('mission_nom');
        ?>
</h4>
				<?php 
        if ($mission->get('mission_deadline')) {
            ?>
<p><span>Deadline :</span> <strong><?php 
            echo $deadline->format('d/m/Y');
            ?>
Example #13
Show file File: login.php Project: jhogan/nplay
0
function main()
{
    try {
        global $sid;
        global $session;
        global $returnURI;
        global $DOMAIN;
        global $FROM_ADDR;
        global $X_MAILER;
        $PHP_SELF = $_SERVER['PHP_SELF'];
        $message = $_REQUEST['message'];
        $captchaCode = $_REQUEST['txtCaptchaCode'];
        $random = $_REQUEST['txtRandom'];
        $post = $_POST['blnPost'];
        $username = $_POST['txtUsername'];
        $password = $_POST['txtPassword'];
        $repassword = $_POST['txtRePassword'];
        $email = $_POST['txtEmail'];
        $emailPassword = $_POST['btnEmailPassword'] != "";
        $create = $_POST['btnCreateAccount'] != "";
        if (!$create) {
            $create = $_GET['create'] != "";
        }
        if (!$emailPassword) {
            $emailPassword = $_GET['emailPassword'] != "";
        }
        if ($post) {
            if ($emailPassword) {
                $user = new User("username='{$username}'");
                if ($user->Email() != '') {
                    $capLogin = GetCap('capLogin');
                    $sub = GetCap('capPassword');
                    $path = dirname($_SERVER['SCRIPT_NAME']);
                    $msg = GetCap('capBelowAreYourCredentials') . "\r\n";
                    $msg .= "Username: " . $user->Username() . "\r\n";
                    $msg .= 'Password: ' . $user->Password() . "\r\n";
                    $msg .= "{$capLogin}: http://{$DOMAIN}{$path}/" . "movies.php?username=" . urlencode($user->Username());
                    $user->EmailPassword($msg, $sub, $FROM_ADDR, $X_MAILER);
                    $session->EmailedPassword("User", $user->ID());
                    print "<b><center>" . GetCap('capEmailHasBeenSent') . '</center></b>';
                } else {
                    print "<b><center>" . GetCap('capUserAccountDoesn\'tHaveEmailAddress</center></b>');
                }
                $username = $user->UserName();
                $email = $user->Email();
            } elseif ($create) {
                $captcha = new CaptchasDotNet('demo', 'secret');
                if (!$captcha->validate($random)) {
                    $password = $_POST['txtPassword'];
                    $rePassword = $_POST['txtRePassword'];
                    print "<center>" . GetCap('capCaptchaWasReused') . "</center>";
                    $session->ReusedCaptcha("session", $session->ID(), $random);
                } elseif (!$captcha->verify($captchaCode)) {
                    $password = $_POST['txtPassword'];
                    $rePassword = $_POST['txtRePassword'];
                    print "<center>" . GetCap('capInvalidConfirmationCode') . "</center>";
                    $session->InvalidConfirmationCode($captchCode);
                } elseif ($password == $repassword) {
                    $user = new User();
                    $user->UserName($username);
                    $user->Password($password);
                    $user->Email($email);
                    if (UpdateObject($user)) {
                        $session->UserID($user->ID());
                        $session->LoggedIn(true);
                        UpdateObject($session);
                        $username = $user->UserName();
                        $email = $user->Email();
                        ReturnURI();
                        print '<center>' . GetCap("capUpdateSucceded") . '</center>';
                    }
                } else {
                    $password = $_POST['txtPassword'];
                    $rePassword = $_POST['txtRePassword'];
                    print "<center>" . GetCap('capPasswordsDoNotMatch') . "</center>";
                }
            }
        }
        /* TODO:PREROLL Go to captcha.net and register an actual account (not demo) before rolling
           to production */
        if ($create) {
            $captcha = new CaptchasDotNet('demo', 'secret');
        }
        ?>
        <form name="frm" method="post" action="<?php 
        echo "login.php?returnURI={$returnURI}";
        ?>
">
            <table>
                <tr> 
                    <td>
                        <b><?php 
        echo GetCap('capUsername');
        ?>
: </b>
                    </td>
                    <td>
                        <input type="text" name="txtUsername" value="<?php 
        echo $username;
        ?>
"/>
                    </td>
                </tr> 
                <?php 
        if ($create) {
            ?>
                    <tr> 
                        <td>
                            <b><?php 
            echo GetCap('capPassword');
            ?>
: </b>
                        </td>
                        <td>
                            <input type="password" name="txtPassword" value="<?php 
            echo $password;
            ?>
"/>
                        </td>
                    </tr> 
                    <tr> 
                        <td>
                            <b><?php 
            echo GetCap('capRe-typePassword');
            ?>
: </b>
                        </td>
                        <td>
                            <input type="password" name="txtRePassword" value="<?php 
            echo $_POST['txtRePassword'];
            ?>
"/>
                        </td>
                    </tr> 
                    <tr> 
                        <td>
                            <b><?php 
            echo GetCap('capEmail (optional)');
            ?>
: </b>
                        </td>
                        <td>
                            <input type="text" name="txtEmail" value="<?php 
            echo $email;
            ?>
"/>
                        </td>
                        <td>
                            <i><?php 
            echo GetCap('capIn case you forget your password we can email you a new one.');
            ?>
</i>
                        </td>
                    </tr> 
                    <tr valign="top">
                        <td>
                            <b><?php 
            echo GetCap('capEnterConfirmationCodeFromPicture');
            ?>
: </b>
                        </td>
                        <td>
                            <input type="text" name="txtCaptchaCode"/>
                            <input type="hidden" name="txtRandom" value="<?php 
            echo $captcha->random();
            ?>
" />
                            <br /><br/><br/> 
                            <a href="<?php 
            echo $captcha->audio_url();
            ?>
"><?php 
            echo GetCap('capPhoenieticSpelling(mp3)');
            ?>
</a>
                        </td>
                        <td>
                            <?php 
            echo $captcha->Image(false, 'captchas.net', GetCap('capLoadingCaptcha...'));
            ?>
                        </td>
                    </tr> 
                    <tr> 
                        <td>
                            <input type="submit" name="btnCreateAccount" value="<?php 
            echo GetCap('capCreateAccount');
            ?>
"/>
                        </td>
                    </tr> 
                <?php 
        }
        if ($emailPassword) {
            ?>
                    <tr>
                        <td>&nbsp;</td>
                        <td>
                            <input type="submit" name="btnEmailPassword" value="<?php 
            echo GetCap('capEmailMePassword');
            ?>
"/>
                        </td>
                    </tr>
                <?php 
        }
        ?>
                <tr>
                    <td>
                        <input type="hidden" name="blnPost" value="1"/>
                    </td>
                </tr> 
            </table>
         </form>
        <?php 
    } catch (Exception $ex) {
        ProcessException($ex);
    }
}
Example #14
Show file File: event.class.php Project: leqg/leqg
0
 /**
  * Create a new event
  *
  * @param integer $person Person ID for this event
  *
  * @return integer
  */
 public static function create(int $person)
 {
     $user = User::ID();
     $query = Core::query('event-new');
     $query->bindValue(':person', $person, PDO::PARAM_INT);
     $query->bindValue(':user', $user, PDO::PARAM_INT);
     $query->execute();
     return Configuration::read('db.link')->lastInsertId();
 }
Example #15
Show file File: user.php Project: jhogan/nplay
0
function main()
{
    try {
        global $pageTitle;
        global $editable;
        global $session;
        global $user;
        $post = $_POST['blnPost'];
        $username = $_GET['username'];
        $selUser = new User("username = '{$username}'");
        $logout = $_GET['logout'];
        if ($selUser->IsEmpty()) {
            print GetCap('capUserNotFound');
            $session->ViewedNotFound("Movie", $username);
            UpdateObject($session, false);
            Dump();
        }
        if ($logout) {
            $selUser->Logout();
            $session->ForcedLogout($selUser->ID());
        }
        if (isset($user)) {
            if ($user->ID() == $selUser->ID()) {
                $sameUser = true;
            }
        }
        if (!$editable && !$selUser->Enabled()) {
            echo GetCap('capThisAccountHasBeenDisabled');
            Dump();
        }
        if ($post) {
            if (!$editable && !$sameUser) {
                BlockIfViolation('update');
            }
            ThrowExceptionOnMaliciousInput($_POST['txtInfo'], 'USER_INFO');
            if ($editable) {
                $selUser->Enabled($_POST['chkEnabled'] == '1' ? 1 : 0);
            }
            $selUser->PlayTimesLocation($_POST['txtPlayTimesLocation']);
            $selUser->Email($_POST['txtEmail']);
            $selUser->Info(strip_tags($_POST['txtInfo']));
            UpdateObject($selUser);
        } else {
            $session->Viewed("User", $selUser->ID());
        }
        $username = $selUser->UserName();
        $pageTitle = $username;
        $email = $selUser->Email();
        $playTimesLocation = $selUser->PlayTimesLocation();
        $enabled = $selUser->Enabled();
        $info = $selUser->Info();
        ?>
        <br />
        <form name="frm" method="post" action="<?php 
        echo $PHP_SELF . "?username=" . urlencode($username);
        ?>
">
            <table>
                <tr> 
                    <td>
                        <font size=6><b><?php 
        echo $username;
        ?>
</b></font>
                        <?php 
        if (!$sameUser) {
            echo PublicizedInfo($info);
        }
        ?>
                    </td>
                </tr> 
                    <?php 
        if ($editable || $sameUser) {
            ?>
                        <tr> 
                            <td>
                                <b><?php 
            echo GetCap('capEmailAddress');
            ?>
: </b>
                            </td>
                            <td>
                                <input type="text" size=50 name="txtEmail" value="<?php 
            echo $email;
            ?>
"/>
                                <?php 
            echo "<i>(" . GetCap('capPrivate') . ")</i>";
            ?>
                            </td>
                        </tr> 
                     <?php 
        }
        if ($editable || $sameUser) {
            ?>
                    <tr> 
                        <td>
                            <b><?php 
            echo GetCap('capPlayTimesLocation');
            ?>
: </b>
                        </td>
                        <td>
                            <input type="text" size=50 name="txtPlayTimesLocation" value="<?php 
            echo $playTimesLocation;
            ?>
"/>
                            <?php 
            echo "<i>(" . GetCap('capPrivate') . ")</i>";
            ?>
                        </td>
                    </tr> 
                <?php 
        }
        if ($editable || $sameUser) {
            ?>
                <tr> 
                        <td valign=top>
                            <b><?php 
            echo GetCap('capTellUsAboutYourself');
            ?>
: </b>
                            <br/>
                            <i>(<?php 
            echo GetCap('capEditAnywayYouWish');
            ?>
)</i>
                        </td>
                        <td valign=top>
                            <textarea rows="10" cols="57" name="txtInfo"><?php 
            echo $info;
            ?>
</textarea>
                            <?php 
            echo "<i>(" . GetCap('capPublic') . ")</i>";
            ?>
                        </td>
                </tr> 
                <tr valign=top> 
                        <td>
                            <b><?php 
            echo GetCap('capPublicView');
            ?>
: </b>
                        </td>
                        <td>
                            <?php 
            echo PublicizedInfo($info);
            ?>
                        </td>
                </tr> 
                <?php 
        }
        if ($editable) {
            ?>
                    <tr> 
                        <td>
                            <b><?php 
            echo GetCap('capLoggedIn');
            ?>
: </b>
                            <?php 
            if ($selUser->LoggedIn()) {
                print GetCap("capYes");
                if ($admin) {
                    print "<a href=\"user.php?username={$username}&logout=1\">[" . GetCap('capLogout') . "]</a>";
                }
            } else {
                print GetCap("capNo");
            }
            ?>
                    </tr> 
                    <tr> 
                        <td>
                            <b><?php 
            echo GetCap('capEnabled');
            ?>
: </b>
                            <?php 
            print "<input type=\"checkbox\" name=\"chkEnabled\" value=\"1\" " . ($enabled ? 'checked="checked"' : '') . "/>";
            ?>
                    </tr> 
                <?php 
        }
        if ($editable || $sameUser) {
            ?>
                    <tr> 
                        <td>
                            <input type="submit" name="btnLogin" value="<?php 
            echo GetCap('capSave');
            ?>
"/>
                        </td>
                        <td>
                            <input type="hidden" name="blnPost" value="1"/>
                        </td>
                    </tr> 
                <?php 
        }
        ?>
        </table>
    </form>
    <?php 
    } catch (Exception $ex) {
        ProcessException($ex);
    }
}
Example #16
Show file File: campagne-nouveau-email.ajax.php Project: leqg/leqg
0
/**
 * Création d'une nouvelle campagne Email
 *
 * PHP version 5
 *
 * @category Ajax
 * @package  LeQG
 * @author   Damien Senger <hi@hiwelo.co>
 * @license  https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License 3.0
 * @link     http://leqg.info
 */
// On lance la création de la campagne
if (isset($_GET)) {
    // On récupère les données
    $user = User::ID();
    // On crée la nouvelle mission en récupérant l'identifiant créé
    $campagne = Campaign::create("email");
    // On tâche de récupérer la liste des contacts concernés par l'envoi
    $var = $_GET;
    // On retraite les critères complexes
    $var['criteres'] = trim($var['criteres'], ';');
    // On charge les identifiants des fiches correspondantes
    $contacts = People::listing($var, 0, false);
    // On prépare la requête d'ajout des destinataires
    $query = Core::query('campagne-destinataires');
    // On enregistre les contacts concernés
    foreach ($contacts as $contact) {
        $query->bindParam(':campagne', $campagne, PDO::PARAM_INT);
        $query->bindParam(':contact', $contact, PDO::PARAM_INT);
        $query->execute();
Example #17
Show file File: export.ajax.php Project: leqg/leqg
0
$nomFichier = 'export-' . User::ID() . '-' . uniqid() . '.csv';
$file = fopen('exports/' . $nomFichier, 'w+');
$entete = ['nom', 'nom_usage', 'prenoms', 'sexe', 'date_naissance', 'age', 'adresse declaree', 'adresse electorale', 'bureau', 'ville', 'electeur', 'electeur_europeen', 'electeur_municipales', 'organisme', 'fonction', 'tags'];
fputcsv($file, $entete, ';', '"');
foreach ($contacts as $_contact) {
    $contact = new People($_contact);
    $address = $contact->postal_address();
    $poll = Maps::pollData($contact->get('bureau'));
    $birthdate = new DateTime($contact->get('date_naissance'));
    $_fichier = array($contact->get('nom'), $contact->get('nom_usage'), $contact->get('prenoms'), $contact->get('sexe'), $birthdate->format('d/m/Y'), $contact->age(), $address['reel'], $address['officiel'], $poll['number'], $poll['city'], $contact->get('electeur'), $contact->get('electeur_europeen'), $contact->get('electeur_municipales'), $contact->get('organisme'), $contact->get('fonction'), implode(',', $contact->get('tags')));
    fputcsv($file, $_fichier, ';', '"');
}
// On retraite le nom du fichier
$f = 'exports/' . $nomFichier;
if ($f) {
    $email = file_get_contents('tpl/mail/export-reussi.tpl.html');
    $objet = '[LeQG] Votre export est prêt à être téléchargé';
    $email = strtr($email, array('{URL}' => 'http://' . Configuration::read('url') . $f));
} else {
    $email = file_get_contents('tpl/mail/export-echec.tpl.html');
    $objet = '[LeQG] Votre export a provoqué un erreur';
}
$query = Core::query('user-data', 'core');
$query->bindValue(':user', User::ID());
$query->execute();
$data = $query->fetch(PDO::FETCH_ASSOC);
$service = Configuration::read('mail');
$to = array(array('email' => $data['email'], 'name' => $data['firstname'] . ' ' . $data['lastname'], 'type' => 'to'));
$mail = array('html' => $email, 'subject' => $objet, 'from_email' => 'serveur@leqg.info', 'from_name' => 'LeQG.info', 'to' => $to, 'headers' => array('Reply-To' => 'tech@leqg.info'), 'track_opens' => true, 'auto_text' => true);
$async = true;
$service->messages->send($mail, $async);
Example #18
Show file File: porte-missions.tpl.php Project: leqg/leqg
0
    foreach ($invitations as $invitation) {
        $mission = new Mission(md5($invitation));
        ?>
    		<li>
    		    <a href="ajax.php?script=mission-refuser&code=<?php 
        echo $mission->get('mission_hash');
        ?>
&user=<?php 
        echo md5(User::ID());
        ?>
" class="nostyle"><button class="deleting" style="float: right; margin-top: 1.33em;">Refuser</button></a>
    		    <a href="ajax.php?script=mission-accepter&code=<?php 
        echo $mission->get('mission_hash');
        ?>
&user=<?php 
        echo md5(User::ID());
        ?>
" class="nostyle"><button class="vert" style="float: right; margin-top: 1.33em; margin-right: 1em;">Accepter</button></a>
    		    <h4><?php 
        echo $mission->get('mission_nom');
        ?>
</h4>
    		    <p>Vous êtes invité à participer à cette mission par <em><?php 
        echo User::getLoginByID($mission->get('responsable_id'));
        ?>
</em>.</p>
    		</li>
        <?php 
    }
    ?>
		</ul>
Example #19
Show file File: campagne.class.php Project: leqg/leqg
0
 /**
  * Créé un nouvel envoi
  *
  * @param string $objet   Objet de l'envoi
  * @param string $message Message de l'envoi
  * @param string $type    Type de l'envoi
  *
  * @return integer
  * @static
  */
 public static function envoi(string $objet, string $message, string $type)
 {
     // On récupère les données
     $user = User::ID();
     // On lance la création de l'envoi
     $link = Configuration::read('db.link');
     $query = 'INSERT INTO `envois` (`compte_id`,
                                     `envoi_type`,
                                     `envoi_time`,
                                     `envoi_titre`,
                                     `envoi_texte`)
               VALUES (:compte,
                       :type,
                       NOW(),
                       :titre,
                       :texte)';
     $query = $link->prepare($query);
     $query->bindValue(':compte', $user, PDO::PARAM_INT);
     $query->bindValue(':type', $type);
     $query->bindValue(':titre', $objet);
     $query->bindValue(':texte', $message);
     $query->execute();
     return $link->lastInsertId();
 }
Example #20
Show file File: porte-inscription.ajax.php Project: leqg/leqg
0
<?php

/**
 * Inscription à une mission de porte à porte
 *
 * PHP version 5
 *
 * @category Ajax
 * @package  LeQG
 * @author   Damien Senger <hi@hiwelo.co>
 * @license  https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License 3.0
 * @link     http://leqg.info
 */
// On lance la connexion
$link = Configuration::read('db.link');
// On réalise l'inscription
if (isset($_POST['mission'])) {
    $userId = User::ID();
    $query = 'INSERT INTO `inscriptions` (`mission_id`, `user_id`)
              VALUES (:mission, :user)';
    $query = $link->prepare($query);
    $query->bindParam(':mission', $_POST['mission'], PDO::PARAM_INT);
    $query->bindParam('user', $userId, PDO::PARAM_INT);
    $query->execute();
}
Example #21
Show file File: user.class.php Project: leqg/leqg
0
 /**
  * List all client's user except each user asked
  *
  * @param array\string $sauf User to exclude
  *
  * @return array
  * @static
  */
 public static function sauf($sauf = '')
 {
     $user = User::data(User::ID());
     if (empty($sauf)) {
         return User::all(0);
     } else {
         $query = Core::query('user-list-except', 'core');
         $query->bindValue(':client', $user['client'], PDO::PARAM_INT);
         $query->bindValue(':exclude', implode(',', $sauf));
         $query->execute();
         return $query->fetchAll(PDO::FETCH_ASSOC);
     }
 }