Example #1
0
 function __construct($datas = array())
 {
     $this->tableName = 'possibilities';
     $this->databaseFields = array('idea', 'name', 'code');
     parent::__construct($datas);
     $this->votes = Database::getAll('votes', array('possibility' => $this->id));
 }
Example #2
0
 public static function loadAllPermissions($pid = null)
 {
     if ($pid != null) {
         return Database::getAll("select * from " . CONFIG_DB_PREFIX . "permission_group where pid={$pid}");
     } else {
         return Database::getAll("select * from " . CONFIG_DB_PREFIX . "permission_group");
     }
 }
Example #3
0
 public function load_members()
 {
     $list = Database::getAll("SELECT uid from " . CONFIG_DB_PREFIX . "user_group" . " where gid=" . $this->gid);
     foreach ($list as $l) {
         $d = new UserObject();
         $d->load($l->uid);
         $this->_members[$l->uid] = $d;
     }
 }
Example #4
0
 public static function isFriend($id_demandeur, $id_receveur)
 {
     $d = new FriendshipObject();
     $request = "SELECT * FROM " . CONFIG_DB_PREFIX . $d->tableName();
     $request .= " WHERE (sid = {$id_demandeur} OR sid = {$id_receveur})";
     $request .= " AND (rid = {$id_demandeur} OR rid = {$id_receveur})";
     $request .= "AND accepted = 1";
     $results = Database::getAll($request);
     return $results == null ? false : true;
 }
Example #5
0
 public static function loadByPositionAndPriority($position, $priority)
 {
     $d = new WidgetObject();
     $request = "SELECT widget_name FROM " . CONFIG_DB_PREFIX . $d->tableName() . " WHERE position = " . $position . " AND priority = " . $priority . " AND activate = 1 ORDER BY priority ASC";
     $results = Database::getAll($request);
     $return = array();
     if (is_array($results)) {
         foreach ($results as $v) {
             $n = new WidgetObject();
             $n->load($v->widget_name);
             $return[] = $n;
         }
     }
     return $return;
 }
Example #6
0
 private function updatePossibilities()
 {
     $this->possibilities = Database::getAll('possibilities', array('idea' => $this->id));
     $this->votesNumber = 0;
     foreach ($this->possibilities as $possibility) {
         if (is_object($possibility)) {
             $this->votesNumber += $possibility->getVotesNumber();
         }
     }
     foreach ($this->possibilities as $possibility) {
         if (is_object($possibility)) {
             if ($this->votesNumber > 0) {
                 $possibility->votesPourcentage = round($possibility->getVotesNumber() / $this->votesNumber * 100, 2);
             } else {
                 $possibility->votesPourcentage = 0;
             }
         }
     }
 }
Example #7
0
 public static function loadAllUsersWithout($array_id_users = array())
 {
     $d = new UserObject();
     $request = "SELECT * FROM " . CONFIG_DB_PREFIX . $d->tableName();
     if (sizeof($array_id_users) > 0) {
         $request .= " WHERE uid NOT IN(" . implode(",", $array_id_users) . ")";
     }
     $request .= " ORDER BY lastname ASC, firstname ASC";
     $results = Database::getAll($request);
     $list_of_users = array();
     if (is_array($results)) {
         foreach ($results as $r) {
             if ($r->uid != User::get_user_logged_id()) {
                 $list_of_users[] = $r->uid;
             }
         }
     }
     return $list_of_users;
 }
Example #8
0
 * User: DiD
 * Date: 02/10/2015
 * Time: 14:15
 */
include 'common.php';
if (isset($_POST['idea-id'], $_POST['name'], $_POST['description'])) {
    if (is_numeric($_POST['idea-id'])) {
        $idea = Database::getOne('ideas', array('id' => $_POST['idea-id']));
    } else {
        $idea = new Idea();
    }
    if ($idea) {
        $idea->name = $_POST['name'];
        $idea->description = $_POST['description'];
        $idea->save();
        $possibilities = Database::getAll('possibilities', array('idea' => $_POST['idea-id']));
        foreach ($possibilities as $possibility) {
            if (isset($_POST['possibility_' . $possibility->id]) && isset($_POST['possibility_code_' . $possibility->id]) && !empty($_POST['possibility_' . $possibility->id])) {
                $possibility->name = htmlspecialchars($_POST['possibility_' . $possibility->id]);
                $possibility->code = htmlspecialchars($_POST['possibility_code_' . $possibility->id]);
                $possibility->save();
            } else {
                $possibility->delete();
            }
        }
        foreach ($_POST['possibility_new'] as $index => $possibilityName) {
            if (!empty($possibilityName)) {
                $possibility = new Possibility();
                $possibility->idea = $idea->id;
                $possibility->name = htmlspecialchars($possibilityName);
                $possibility->code = htmlspecialchars($_POST['possibility_code_new'][$index]);
Example #9
0
 public static function getOne($table = null, $conditions = array())
 {
     if (!$table) {
         return null;
     }
     $results = Database::getAll($table, $conditions);
     if (count($results)) {
         return array_shift($results);
     } else {
         return null;
     }
 }
Example #10
0
<?php

require_once '../../../util/pdo/Database.php';
$db = new Database('ci_demo', 'root', '');
// Just for testing
$users = $db->getAll('membership');
<?php

/**
 * Created by PhpStorm.
 * User: DiD
 * Date: 30/09/2015
 * Time: 14:10
 */
function __autoload($className)
{
    include '../../classes/' . $className . '.php';
}
$test = array();
$return = array();
$test['count'] = 0;
if (isset($_POST['idea-id']) && is_numeric($_POST['idea-id'])) {
    $return['possibilities'] = Database::getAll('possibilities', array('idea' => $_POST['idea-id']), array(), 'json_serialize');
}
echo json_encode($return);
Example #12
0
<?php

require_once 'Database.php';
$username = $_GET['username'];
$password = $_GET['password'];
$score = $_GET['score'];
$data = new Database($username, $password, $score);
echo $data->getAll();
Example #13
0
        $sql = "SELECT * FROM `config` WHERE `index` = 'mode'";
        $result = mysql_query($sql) or die(mysql_error());
        $mode = mysql_fetch_array($result) or die(mysql_error());
        if ($_POST["val"] == "contest" or $_POST["val"] == "blind_contest") {
            // Database::deleteAllThat("backup","`task_id` > 0");
            $re_task = Database::getAllThat("task", "`see` = 1");
            while ($task = mysql_fetch_array($re_task)) {
                $input["task_id"] = $task["task_id"];
                Database::putInTo("backup", $input);
                $inputx["see"] = 0;
                Database::updateById("task", $task["task_id"], $inputx);
            }
        } else {
            if ($_POST["val"] == "online") {
                mysql_query("TRUNCATE TABLE `ask`");
                $re_backup = Database::getAll("backup");
                while ($task = mysql_fetch_array($re_backup)) {
                    $input["see"] = 1;
                    Database::updateById("task", $task["task_id"], $input);
                }
                Database::deleteAllThat("backup", "`task_id` > 0");
            }
        }
    }
    $sql = "UPDATE `config` SET `val` = '" . $_POST["val"] . "' WHERE `index` = '" . $_POST["index"] . "'";
    mysql_query($sql) or die("<div style='background-color:#FFBFD3'><br><div style='height:1px'></div><h4>UNSUCCESS</h4><div style='height:1px'></div><br></div>");
} else {
    if ($_POST["type"] == "main_time") {
        $date = strtotime($_POST["val"]);
        $sql = "UPDATE `config` SET `val` = '" . $date . "' WHERE `index` = '" . $_POST["index"] . "'";
        mysql_query($sql) or die("<div style='background-color:#FFBFD3'><br><div style='height:1px'></div><h4>UNSUCCESS</h4><div style='height:1px'></div><br></div>");
Example #14
0
    <td id="status_done"><?php 
echo $stats['status_done'];
?>
</td>
  </tr>
</table>

<h2>Units</h2>
<p>
  <div class="error"></div>Red lines had errors while parsing. Data may not be reliable.
</p>
<p>
  <div class="warn"></div>Yellow lines had warnings while parsing (Duplicates). Frequency column may not be reliable.
</p>
<?php 
$units = Database::getAll();
?>
<div id="statusboard">
  <img src="images/done.png" onclick="set_status('done')">
  <img src="images/not_done.png" onclick="set_status('not_done')">
  <img src="images/waiting.png" onclick="set_status('waiting')">
</div>
<form action="index.php" method="post">
  <table class="units">
    <tr>
      <th></th>
      <th>Unit name</th>
      <th>File</th>
      <th>Row</th>
      <th>Frequency</th>
      <th>Complexity</th>
Example #15
0
        <div class="col s12">
            <?php 
    if ($loggedUser->access > 0) {
        ?>
                <a class="btn waves-effect waves-light right" href="./?page=ideas-gestion&new-idea">
                    Ajouter une idée
                    <i class="material-icons right">note_add</i>
                </a>
                <?php 
    }
    ?>
        </div>
    </div>
    <?php 
}
$ideas = Database::getAll('ideas');
if (count($ideas)) {
    foreach ($ideas as $idea) {
        ?>
        <div class="card blue lighten-2">
            <ul class="card-content">
                <div class="card-title">
                    <?php 
        echo $idea->name;
        ?>

                    <form class="right" onsubmit="return confirm('Sûr de toi?');" action="./operations/idea.php" method="post">
                        <input type="hidden" name="idea-id" value="<?php 
        echo $idea->id;
        ?>
"/>
Example #16
0
 public static function getDiscussions($uid)
 {
     $messages = array();
     $messagers = array();
     $tbl = CONFIG_DB_PREFIX . "messages";
     $request = "SELECT m1.*\r\nFROM {$tbl} m1 LEFT JOIN {$tbl} m2\r\n ON (m1.sid = m2.sid AND m1.rid=m2.rid AND m1.sent_on < m2.sent_on)\r\nWHERE m2.mid IS NULL and m1.sid={$uid} OR m1.rid={$uid} ORDER BY m1.sent_on DESC;";
     $results = Database::getAll($request);
     foreach ($results as $r) {
         if ($r->sid != $uid) {
             if (!in_array($r->sid, $messagers)) {
                 $r->conversation = $r->sid;
                 $messagers[] = $r->sid;
                 $messages[] = $r;
             }
         } elseif ($r->rid != $uid) {
             if (!in_array($r->rid, $messagers)) {
                 $r->conversation = $r->rid;
                 $messagers[] = $r->rid;
                 $messages[] = $r;
             }
         } else {
             if (!in_array($r->rid, $messagers)) {
                 $r->conversation = $r->rid;
                 $messagers[] = $r->rid;
                 $messages[] = $r;
             }
         }
     }
     return $messages;
 }
Example #17
0
 public static function loadAll()
 {
     $cname = get_called_class();
     $o = new $cname();
     return Database::getAll("SELECT * FROM " . CONFIG_DB_PREFIX . $o->tableName() . " WHERE 1");
 }
Example #18
0
    .visit>div {
        float: left;
        margin: 3px;
        padding: 3px;
        width: 200px;
    }
</style>

<?php 
/**
 * Created by PhpStorm.
 * User: DiD
 * Date: 12/10/2015
 * Time: 11:02
 */
$visits = Database::getAll('visits', array(), array('date' => 'DESC'));
if (count($visits)) {
    foreach ($visits as $visit) {
        ?>
        <div class="visit">
            <div>
                <?php 
        if ($visit->user) {
            echo $visit->user;
        } else {
            echo 'Visiteur';
        }
        ?>
            </div>
            <div>
                <?php