query() public method

SELECT queries should use getOne, getRow or getRows.
public query ( $sql ) : resource | false
return resource | false
Example #1
0
 /**
  * Migrate form legacy column set editor.
  *
  * @return void
  */
 private function migrateFromLegacy()
 {
     if (!$this->database->fieldExists('bootstrap_grid', 'tl_content') && $this->database->fieldExists('columnset_id', 'tl_content')) {
         $this->database->query('ALTER TABLE tl_content ADD bootstrap_grid int(10) unsigned NOT NULL default \'0\';');
         $this->database->query('UPDATE tl_content SET bootstrap_grid=columnset_id WHERE bootstrap_grid = 0');
     }
 }
Example #2
0
 /**
  * 重载lists
  * 加百分比统计功能
  */
 public function lists($query_struct = array())
 {
     $list = parent::lists($query_struct);
     $agent_detail_num = array();
     $version_num = array();
     $type_num = array();
     $total_num = $this->count(array());
     $db = new Database();
     //统计agent_detail数目
     $sql = "SELECT agent_detail, count(id) as agent_num FROM kc_browser_stats WHERE 1=1 GROUP BY agent_detail";
     $query = $db->query($sql);
     foreach ($query as $key => $_query) {
         $agent_detail_num[$_query->agent_detail] = $_query->agent_num;
     }
     //统计version数目
     $sql = "SELECT version, count(id) as version_num FROM kc_browser_stats WHERE 1=1 GROUP BY version";
     $query = $db->query($sql);
     foreach ($query as $key => $_query) {
         $version_num[$_query->version] = $_query->version_num;
     }
     //统计type数目
     $sql = "SELECT type, count(id) as type_num FROM kc_browser_stats WHERE 1=1 GROUP BY type";
     $query = $db->query($sql);
     foreach ($query as $key => $_query) {
         $type_num[$_query->type] = $_query->type_num;
     }
     //计算百分比
     foreach ($list as $key_list => $_list) {
         $list[$key_list]['agent_detail_percentage'] = round($agent_detail_num[$_list['agent_detail']] / $total_num * 100);
         $list[$key_list]['version_percentage'] = round($version_num[$_list['version']] / $total_num * 100);
         $list[$key_list]['type_percentage'] = round($type_num[$_list['type']] / $total_num * 100);
     }
     return $list;
 }
Example #3
0
 function save(Entity $entity)
 {
     $vars = get_object_vars($entity);
     //print_r($vars);
     if ($vars['id'] == 0) {
         $vars['id'] == 'NULL';
     }
     $cols = array();
     $values = array();
     $updates = array();
     foreach ($vars as $key => $value) {
         $cols[] = "`{$key}`";
         $values[] = ' :' . $key . ' ';
         $updates[] = " `{$key}` = VALUES(`{$key}`) ";
     }
     $col = implode(",", $cols);
     $value = implode(",", $values);
     $update = implode(",", $updates);
     $sql = "INSERT INTO {$this->tableName()} ({$col}) VALUES ({$value}) ON DUPLICATE KEY UPDATE {$update}";
     $res = $this->db->query($sql, $vars);
     if ($res === FALSE) {
         return FALSE;
     }
     if ($entity->id == 0) {
         $entity->id = $this->db->lastInsertId();
     }
     return $entity;
 }
Example #4
0
function checkLogin($login, $pass)
{
    $db = new Database();
    //Traigo el usuario
    $q = "select salt from jugador where login='{$login}' limit 1";
    $r = $db->query($q);
    //Controlo que exista el usuario con el login $login
    if ($db->num_rows($r) > 0) {
        //Traigo el registro
        $data = $db->fetch_array($r);
        $salt_db = $data['salt'];
        //Genero el mismo hash que se creo al registrar jugador
        $hashedpass = hash('sha512', $pass . $salt_db);
        $q2 = "select * from jugador where login='{$login}' and pass=PASSWORD('{$hashedpass}')";
        $r2 = $db->query($q2);
        if ($db->num_rows($r2) > 0) {
            return 1;
        } else {
            return 0;
        }
    } else {
        alertMessage('El usuario no existe');
        exit;
    }
    $db->close();
}
Example #5
0
 /**
  * Save layer relations.
  *
  * @param mixed          $layerId       The layer id values.
  * @param \DataContainer $dataContainer The dataContainer driver.
  *
  * @return null
  */
 public function saveLayerRelations($layerId, $dataContainer)
 {
     $new = deserialize($layerId, true);
     $values = array();
     $result = $this->database->prepare('SELECT * FROM tl_leaflet_map_layer WHERE mid=? order BY sorting')->execute($dataContainer->id);
     while ($result->next()) {
         $values[$result->lid] = $result->row();
     }
     $sorting = 0;
     foreach ($new as $layerId) {
         if (!isset($values[$layerId])) {
             $this->database->prepare('INSERT INTO tl_leaflet_map_layer %s')->set(array('tstamp' => time(), 'lid' => $layerId, 'mid' => $dataContainer->id, 'sorting' => $sorting))->execute();
             $sorting += 128;
         } else {
             if ($values[$layerId]['sorting'] <= $sorting - 128 || $values[$layerId]['sorting'] >= $sorting + 128) {
                 $this->database->prepare('UPDATE tl_leaflet_map_layer %s WHERE id=?')->set(array('tstamp' => time(), 'sorting' => $sorting))->execute($values[$layerId]['id']);
             }
             $sorting += 128;
             unset($values[$layerId]);
         }
     }
     $ids = array_map(function ($item) {
         return $item['id'];
     }, $values);
     if ($ids) {
         $this->database->query('DELETE FROM tl_leaflet_map_layer WHERE id IN(' . implode(',', $ids) . ')');
     }
     return null;
 }
Example #6
0
    public function RenderPage()
    {
        require_once "/Classes/databaseHandler.class.php";
        $Database = new Database();
        print '
        <title>Run2Day - Bannerbeheer</title>
        <h1>Bannerbeheer</h1>
        <table class="table">
                            <tr>
                                <th>Toegevoegd aan</th>
                                <th>Bestandsnaam</th>
                                <th>Banner tekst</th>
                                <th>Verwijderen</th>
                            </tr> ';
        $Database->query('SELECT ID, fileName, fk_wedstrijdID, text  FROM afbeeldingen');
        $result = $Database->resultset();
        foreach ($result as $key) {
            $Database->query('SELECT name  FROM wedstrijden WHERE wedstrijdID=?');
            $Database->bind(1, $key['fk_wedstrijdID']);
            $wedstrijd = $Database->single();
            print '<tr><td>' . $wedstrijd['name'] . ' </td>';
            print '<td>' . $key['fileName'] . ' </td>';
            print '<td>' . $key['text'] . ' </td>';
            print ' <td><a class="fa fa-trash-o"  href="?dashboard&deletebanner=' . $key['ID'] . '"</td></tr>';
        }
        print '
            </table>


   <div class="col-md-4">
   <h3>Banner afbeelding toevoegen</h3>
   <form action="../Classes/submitWedstrijd.php" method="POST"  enctype="multipart/form-data">

      <label for="usr">Banner toevoegen aan:</label>
      <select class="form-control" name="wedstrijd" id="wedstrijd">';
        $Database->query('SELECT name, wedstrijdID FROM wedstrijden');
        $result = $Database->resultset();
        foreach ($result as $key) {
            print '  <option> ' . $key['name'] . '</option>';
        }
        print '
</select>

    <div class="form-group">
      <label for="usr">Banner tekst:</label>
      <input type="text" class="form-control" id="name" name="name" required>
    </div>

      <div class="form-group">
      <label for="usr">Afbeelding:</label>
        <input type="file" name="file" id="file">
            </div>
           <input type="submit" value="Opslaan">
    <br><br>
  </form>
   </div>
</div>
</div> ';
    }
Example #7
0
 /**
  * Selects the user information for $userId
  * @param int $userId
  * @return Resultset $q
  */
 function _selectUser($userId)
 {
     $sql = "SELECT USER_ID, USER_NAME, USER_PASSWORD, \r\n\t\t\tUSER_ACCESSLEVEL, USER_COLOR, USER_IMG\r\n\t\t\tFROM TBL_USER \r\n\t\t\tWHERE USER_ID = ??";
     $q = $this->db->query($sql);
     $q->bind_values(array($userId));
     $q->execute();
     return $q;
 }
Example #8
0
function getChoicesByQuestion($question_id)
{
    $db = new Database();
    $db->query('SELECT * FROM choices WHERE question_id = :question_id');
    $db->query(':question_id', $question_id);
    // Assign Rows
    $rows = $db->resultset();
    return $rows;
}
 function checkSystem($memberid)
 {
     $database = new Database();
     $othernotes = $database->query('SELECT notification, label, timestamp, color, fk_from_id, isRead FROM s_notifications_log LEFT JOIN s_notifications_labels ON s_notifications_log.fk_label_id = s_notifications_labels.id WHERE fk_member_id=' . $memberid . ' ORDER BY timestamp DESC LIMIT 3');
     $systemnotes = $database->query('SELECT notification, label, timestamp, color FROM s_notifications LEFT JOIN s_notifications_labels ON s_notifications.fk_label_id = s_notifications_labels.id WHERE isVisible=1 ORDER BY timestamp DESC');
     //.' AND isRead=0'
     $notes = array("others" => $othernotes, "system" => $systemnotes);
     return $notes;
 }
Example #10
0
 public function mainP()
 {
     $sen = 0;
     $db = new Database();
     foreach ($this->sentences as $sentence) {
         $highest = 0;
         $words = array();
         $words = explode(" ", $sentence);
         foreach ($words as $word) {
             if (!in_array(strtolower($word), $this->stopwords)) {
                 //Fetching the meaning definition of the senses From the WordNet
                 $db->query("SELECT * from words where lemma like :word");
                 $db->bind("word", $word);
                 $wordid = $db->single()->wordid;
                 $db->query("SELECT * from senses where wordid like :wordid");
                 $db->bind("wordid", $wordid);
                 $resulta2 = $db->resultset();
                 foreach ($resulta2 as $row) {
                     $synsetid = $row->synsetid;
                     $sample2[] = $synsetid;
                     $title = $row->wordid . " " . $row->senseid;
                 }
                 $db->query("select * from synsets where synsetid like :sample");
                 $db->bind("sample", $sample2[0]);
                 $resulta3 = $db->resultset();
                 unset($sample2[0]);
                 for ($i = 0; $i < count($sample2) + 1; $i++) {
                     ${result_A . $i} = $sample2[$i];
                     ${lexdomains_var . $i} = $lexdomains[$i];
                     $db->query("select * from synsets where synsetid like :sample");
                     $db->bind("sample", ${result_A . $i});
                     ${result . $i} = $db->resultset();
                     foreach (${result . $i} as $row) {
                         ${pos . $i} = $row->pos;
                         if (${pos . $i} == "s") {
                             ${pos . $i} = "satellite adj";
                         }
                         $def = $row->definition;
                         $def = preg_replace('/[^a-zA-Z0-9_ -]/s', '', $def);
                         $definition = array();
                         $definition = explode(" ", $def);
                         $frequency = $this->frequency($definition);
                         if ($frequency > $highest) {
                             $highest = $frequency;
                         }
                     }
                 }
                 $sample2 = array();
             }
         }
         $this->frequencies[] = $highest;
         $this->sentence_count[] = $sen;
         $sen++;
     }
 }
Example #11
0
	/**
	 * Displays a list of reports
	 * @param boolean $category_id If category_id is supplied filter by
	 * that category
	 */
	public function index($category_id = false)
	{
		$this->template->content = new View('mobile/reports');
		$get_params = "?";
		if(isset($_GET['c']) AND !empty($_GET['c']) AND $_GET['c']!=0)$get_params .= "c=".$_GET['c']."&";
		if(isset($_GET['sw']))$get_params .= "sw=".$_GET['sw']."&";
		if(isset($_GET['ne']))$get_params .= "ne=".$_GET['ne']."&";
		if(isset($_GET['l']) AND !empty($_GET['l']) AND $_GET['l']!=0)$get_params .= "l=".$_GET['l'];
		$get_params = rtrim(rtrim($get_params,'&'),'?');
		$this->template->content->get_params = $get_params;
		$db = new Database;
		
		$filter = ( $category_id )
			? " AND ( c.id='".$category_id."' OR 
				c.parent_id='".$category_id."' )  "
			: " AND 1 = 1";
		// 検索キーワード取得
		if(isset($_GET["keyword"]) && trim($_GET["keyword"]) !==""){
			$keywords = array();
			$keyword = str_replace(" "," ",$_GET["keyword"]);
			$keywords = explode(" ",$keyword);
		}
		$keyword_like = "1=1";
		if(isset($keywords) && count($keywords)){
			$keyword_like = "";
			foreach($keywords as $val){
				$keyword_like .= "(incident_title like '%".addslashes($val)."%' OR incident_description like '%".addslashes($val)."%') AND ";
			}
			$keyword_like = rtrim($keyword_like," AND ");
		}
		// Pagination
		$pagination = new Pagination(array(
				'style' => 'mobile',
				'query_string' => 'page',
				'items_per_page' => (int) Kohana::config('mobile.items_per_page'),
				'total_items' => $db->query("SELECT DISTINCT i.* FROM `".$this->table_prefix."incident` AS i JOIN `".$this->table_prefix."incident_category` AS ic ON (i.`id` = ic.`incident_id`) JOIN `".$this->table_prefix."category` AS c ON (c.`id` = ic.`category_id`) WHERE `incident_active` = '1' AND $keyword_like $filter")->count()
				));
		$this->template->content->pagination = $pagination;

		$incidents = $db->query("SELECT DISTINCT i.*, l.location_name FROM `".$this->table_prefix."incident` AS i JOIN `".$this->table_prefix."incident_category` AS ic ON (i.`id` = ic.`incident_id`) JOIN `".$this->table_prefix."category` AS c ON (c.`id` = ic.`category_id`) JOIN `".$this->table_prefix."location` AS l ON (i.`location_id` = l.`id`) WHERE `incident_active` = '1' AND $keyword_like $filter ORDER BY incident_date DESC LIMIT ". (int) Kohana::config('mobile.items_per_page') . " OFFSET ".$pagination->sql_offset);
		
		// If Category Exists
		if ($category_id)
		{
			$category = ORM::factory("category", $category_id);
		}
		else
		{
			$category = FALSE;
		}
			
		$this->template->content->incidents = $incidents;
		$this->template->content->category = $category;
	}
Example #12
0
 public function renderSearch()
 {
     require_once "/Classes/databaseHandler.class.php";
     $Database = new Database();
     $Database->query('SELECT fileName, name, date  FROM wedstrijden');
     $resultSet = $Database->single();
     print '
     </div >
         <div id = "clickTable" class="container" >
         <table id = "myTable" class="table" >
          <thead>
         <tr>
         <th> Startnr <i class="fa fa-sort" ></i></th>
         <th> Wedstrijd <i class="fa fa-sort" ></i></th>
         <th> Naam <i class="fa fa-sort" ></i></th>
         <th> Woonplaats <i class="fa fa-sort" ></i></th>
         <th> Geboortedatum <i class="fa fa-sort" ></i></th>
         <th> Geslacht</th >
         <th> Netto tijd <i class="fa fa-sort" ></i></th>
         <th> Onderdeel <i class="fa fa-sort" ></i> </th>
         <th> Beeld</th>
         </tr></thead ><tbody> ';
     $Database->query('SELECT * FROM tijden WHERE Naam LIKE ?');
     if (!isset($_GET['show'])) {
         $Database->bind(1, "%" . $_POST['naam'] . "%");
         $result = $Database->resultset();
         if (empty($result)) {
             echo "Deelnemer niet gevonden.";
         }
         foreach ($result as $data) {
             $Database->query('SELECT fileName, name, date  FROM wedstrijden WHERE wedstrijdID=?');
             $Database->bind(1, $data['fk_wedstrijdID']);
             $resultSet = $Database->single();
             print ' <tr><td> ' . $data['Startnummer'] . ' </td> ';
             print '<td> ' . $resultSet['name'] . ' </td> ';
             print '<td> ' . $data['Naam'] . ' </td> ';
             print '<td> ' . $data['Woonplaats'] . ' </td> ';
             print '<td> ' . $data['Geboortedatum'] . ' </td> ';
             echo "<td>";
             if ($data['Geslacht'] == "V") {
                 echo ' <i class="fa fa-female" ></i> ';
             } else {
                 echo '<i class="fa fa-male" ></i> ';
             }
             echo "</td>";
             print '<td> ' . $data['NettoTijd'] . ' </td> ';
             print '<td> ' . $data['Onderdeel'] . ' </td> ';
             print "<td><a class='fa fa-line-chart' href='?statistieken&startnummer=" . $data['Startnummer'] . "&eventid=" . $data['fk_wedstrijdID'] . "'></a>";
             print " <a class='fa fa-video-camera' href='?newplayer&wedstrijd=" . $resultSet['name'] . "&naam=& startnummer=" . $data['Startnummer'] . "'></a>";
             print " <a class='fa fa-camera' </a> ";
             print " <a class='fa fa-certificate' target='_blank' href='https://uitslagensoftware.nl/certificaat_3.php?event_id=2015083000294&S= " . $data['Startnummer'] . "'></a></td></tr>";
         }
     }
 }
 public function page($pagenum)
 {
     css::add(array('media/css/rating.css'));
     $this->template->content = new View('content/rating');
     $db = new Database();
     $query = $db->query("SELECT Company FROM ambestf");
     $this->pagination = new Pagination(array('directory' => 'pagination', 'style' => 'trinhall', 'uri_segment' => 3, 'query_string' => '', 'items_per_page' => 23, 'auto_hide' => FALSE, 'total_items' => $query->count()));
     $this->pagination->extras = array('hide_count' => TRUE);
     $b = $this->pagination->items_per_page;
     $offset = ($pagenum - 1) * $b;
     $result = $db->query("SELECT Company, Rating1, Rating2, Rating3, Rating4 FROM ambestf ORDER BY Company ASC LIMIT {$b} OFFSET {$offset}");
     $this->template->content->result = $result;
 }
Example #14
0
function userPostCount($user_id)
{
    $db = new Database();
    $db->query("SELECT * FROM topics \n\t\t\t\t\t  WHERE user_id=:user_id");
    $db->bind('user_id', $user_id);
    $db->resultSet();
    $topic_count = $db->rowCount();
    $db->query("SELECT * FROM replies\n\t\t\t\t      WHERE user_id=:user_id");
    $db->bind('user_id', $user_id);
    $db->resultSet();
    $reply_count = $db->rowCount();
    return $topic_count + $reply_count;
}
Example #15
0
 public function page($pagenum)
 {
     css::add(array('media/css/fee.css'));
     javascript::add(array('media/js/ext-base.js', 'media/js/ext-all.js', 'media/js/app.js'));
     $this->template->content = new View('content/fees');
     $db = new Database('fees');
     $query = $db->query("SELECT co_name FROM feesNew");
     $this->pagination = new Pagination(array('uri_segment' => 'page', 'total_items' => $query->count(), 'items_per_page' => 28, 'style' => 'punbb'));
     $b = $this->pagination->items_per_page;
     $offset = ($pagenum - 1) * $b;
     $result = $db->query("SELECT co_name FROM feesNew ORDER BY co_name ASC LIMIT {$b} OFFSET {$offset}");
     $this->template->content->result = $result;
 }
Example #16
0
 public function register($username, $passowrd)
 {
     if ($this->userExists($username)) {
         throw new \Exception("User already registered");
     }
     $result = $this->db->prepare("INSERT INTO users(username, password, gold, food) VALUES(?, ?, ?, ?)");
     $result->execute([$username, password_hash($passowrd, PASSWORD_DEFAULT), User::GOLD_DEFAULT, User::FOOD_DEFAULT]);
     if ($result->rowCount() > 0) {
         $userId = $this->db->lastId();
         $this->db->query("INSERT INTO players_buildings(user_id, building_id, level_id) SELECT {$userId}, id, 0 FROM buildings");
         return true;
     }
     throw new \Exception('Cannot register user');
 }
Example #17
0
 public function register($username, $password)
 {
     if ($this->userExists($username)) {
         throw new \Exception('Username already taken');
     }
     $registerUserQuery = "INSERT INTO users(username, password, gold, food) VALUES(?, ?, ?, ?)";
     $result = $this->database->prepare($registerUserQuery);
     $result->execute([$username, password_hash($password, PASSWORD_DEFAULT), User::GOLD_DEFAULT, User::FOOD_DEFAULT]);
     if ($result->rowCount() > 0) {
         $userId = $this->database->lastId();
         $this->database->query("\n                INSERT INTO users_buildings_levels (user_id, building_id, level_id)\n                SELECT {$userId}, id, 0\n                FROM buildings\n            ");
         $this->login($username, $password);
     }
     throw new \Exception('Unsuccessful registration');
 }
Example #18
0
function userPostCount($user_id)
{
    $db = new Database();
    //topic count
    $db->query("SELECT * FROM topics\n\t\t\t\tWHERE user_id = :user_id\n\t\t\t\t");
    $db->bind(":user_id", $user_id);
    $rows = $db->resultset();
    $topic_count = $db->rowCount();
    //reply count
    $db->query("SELECT * FROM replies\n\t\t\t\tWHERE user_id = :user_id\n\t\t\t\t");
    $db->bind(":user_id", $user_id);
    $rows = $db->resultset();
    $reply_count = $db->rowCount();
    return $topic_count + $reply_count;
}
Example #19
0
 public static function isCurrentPanelMembersArchived()
 {
     $DB = new Database();
     $sql = "SELECT UID FROM userids WHERE Responsibility != 'Member'";
     $result = $DB->query($sql);
     while ($row = $DB->fetch($result)) {
         $sql = "SELECT UID FROM panelmembers WHERE UID = '" . $row['UID'] . "'";
         $res = $DB->query($sql);
         $ret = $DB->fetch($res);
         if (!$ret['UID']) {
             return false;
         }
     }
     return true;
 }
Example #20
0
 /**
  * User Login
  *
  * @param $username
  * @param $password
  * @return bool
  */
 public function login($username, $password)
 {
     $this->db->query("SELECT * FROM users\n\t\t\t\tWHERE username = :username\n\t\t\t\tAND password = :password");
     //Bind Values
     $this->db->bind(':username', $username);
     $this->db->bind(':password', $password);
     $row = $this->db->single();
     //Check Rows
     if ($this->db->rowCount() > 0) {
         $this->setUserData($row);
         return true;
     } else {
         return false;
     }
 }
Example #21
0
 public function getOrganizacion()
 {
     $coneccion = new Database();
     $id = $_SESSION['usuario']['id'];
     $obj = $coneccion->query("SELECT usu.*,IFNULL(nombre, '') AS nombre, IFNULL(calle, '') AS calle, IFNULL(numero, 0) AS numero, IFNULL(colonia, 0) AS colonia,\n                    IFNULL(codigo_postal, 0) AS codigo_postal, IFNULL(ciudad, '') AS ciudad, IFNULL(pais,'') AS pais, IFNULL(telefono, '') AS telefono,\n                    IFNULL(descripcion, '') AS descripcion, IFNULL(estado, '') AS estado\n                    FROM usuario usu\n                    LEFT JOIN organizacion org ON org.id_usuario = usu.id\n                    WHERE usu.id={$id}");
     $result = $obj->fetch_object();
     if (is_object($result)) {
         return $result;
     } else {
         $temp = new stdClass();
         $temp->nombre = "";
         $temp->descripcion = "";
         $temp->calle = "";
         $temp->numero = "";
         $temp->colonia = "";
         $temp->codigo_postal = "";
         $temp->ciudad = "";
         $temp->pais = "";
         $temp->telefono = "";
         $temp->estado = "";
         $temp->correo_electronico = "";
         $temp->contrasena = "";
         return $temp;
     }
 }
 public function uninstall()
 {
     $t_settings = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
     $t_options = Database::get_main_table(TABLE_MAIN_SETTINGS_OPTIONS);
     $t_tool = Database::get_course_table(TABLE_TOOL_LIST);
     //New settings
     $sql = "DELETE FROM {$t_settings} WHERE variable = 'openmeetings_tool_enable'";
     Database::query($sql);
     $sql = "DELETE FROM {$t_settings} WHERE variable = 'openmeetings_pass'";
     Database::query($sql);
     $sql = "DELETE FROM {$t_settings} WHERE variable = 'openmeetings_user'";
     Database::query($sql);
     $sql = "DELETE FROM {$t_settings} WHERE variable = 'openmeetings_host'";
     Database::query($sql);
     //Old settings deleting just in case
     $sql = "DELETE FROM {$t_settings} WHERE variable = 'openmeetings_plugin'";
     Database::query($sql);
     $sql = "DELETE FROM {$t_options} WHERE variable  = 'openmeetings_plugin'";
     Database::query($sql);
     //        $sql = "DELETE FROM $t_settings WHERE variable = 'openmeetings_plugin_host'";
     //        Database::query($sql);
     //        $sql = "DELETE FROM $t_settings WHERE variable = 'openmeetings_plugin_salt'";
     //        Database::query($sql);
     //hack to get rid of Database::query warning (please add c_id...)
     $sql = "DELETE FROM {$t_tool} WHERE name = 'openmeetings' AND c_id = c_id";
     Database::query($sql);
     $sql = "DROP TABLE IF EXISTS plugin_openmeetings";
     Database::query($sql);
     //Deleting course settings
     $this->uninstall_course_fields_in_all_courses();
 }
Example #23
0
 /**
  * Check to see if a table exists in the database
  *
  * @param string $table
  * The table name to check
  *
  * @return bool
  * True if the table exists, false otherwise
  */
 public static function tableExists($table)
 {
     // the query to run
     $query = "SELECT name FROM sqlite_master WHERE type='table' AND name=:name;";
     // run the query
     return count(Database::query($query, array(':name' => $table))) > 0 ? true : false;
 }
function search_sessions($needle, $type)
{
    global $_configuration, $tbl_session_rel_access_url, $tbl_session, $user_id;
    $xajax_response = new XajaxResponse();
    $return = '';
    if (!empty($needle) && !empty($type)) {
        // xajax send utf8 datas... datas in db can be non-utf8 datas
        $charset = api_get_system_encoding();
        $needle = api_convert_encoding($needle, $charset, 'utf-8');
        $assigned_sessions_to_hrm = SessionManager::get_sessions_followed_by_drh($user_id);
        $assigned_sessions_id = array_keys($assigned_sessions_to_hrm);
        $without_assigned_sessions = '';
        if (count($assigned_sessions_id) > 0) {
            $without_assigned_sessions = " AND s.id NOT IN(" . implode(',', $assigned_sessions_id) . ")";
        }
        if ($_configuration['multiple_access_urls']) {
            $sql = " SELECT s.id, s.name FROM {$tbl_session} s LEFT JOIN {$tbl_session_rel_access_url} a ON (s.id = a.session_id)\n\t\t\t\t\t\tWHERE  s.name LIKE '{$needle}%' {$without_assigned_sessions} AND access_url_id = " . api_get_current_access_url_id() . "";
        } else {
            $sql = "SELECT s.id, s.name FROM {$tbl_session} s\n\t\t\t\tWHERE  s.name LIKE '{$needle}%' {$without_assigned_sessions} ";
        }
        $rs = Database::query($sql);
        $return .= '<select id="origin" name="NoAssignedSessionsList[]" multiple="multiple" size="20" style="width:340px;">';
        while ($session = Database::fetch_array($rs)) {
            $return .= '<option value="' . $session['id'] . '" title="' . htmlspecialchars($session['name'], ENT_QUOTES) . '">' . $session['name'] . '</option>';
        }
        $return .= '</select>';
        $xajax_response->addAssign('ajax_list_sessions_multiple', 'innerHTML', api_utf8_encode($return));
    }
    return $xajax_response;
}
 /**
  * Search for a list of available courses by title or code, based on
  * a given string
  * @param string String to search for
  * @param int Deprecated param
  * @return string A formatted, xajax answer block
  * @assert () === false
  */
 function search_courses($needle, $id)
 {
     global $tbl_course;
     $xajax_response = new XajaxResponse();
     $return = '';
     if (!empty($needle)) {
         // xajax send utf8 datas... datas in db can be non-utf8 datas
         $charset = api_get_system_encoding();
         $needle = api_convert_encoding($needle, $charset, 'utf-8');
         $needle = Database::escape_string($needle);
         // search courses where username or firstname or lastname begins likes $needle
         $sql = 'SELECT code, title FROM ' . $tbl_course . ' u ' . ' WHERE (title LIKE "' . $needle . '%" ' . ' OR code LIKE "' . $needle . '%" ' . ' ) ' . ' ORDER BY title, code ' . ' LIMIT 11';
         $rs = Database::query($sql);
         $i = 0;
         while ($course = Database::fetch_array($rs)) {
             $i++;
             if ($i <= 10) {
                 $return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_url(\'' . addslashes($course['code']) . '\',\'' . addslashes($course['title']) . ' (' . addslashes($course['code']) . ')' . '\')">' . $course['title'] . ' (' . $course['code'] . ')</a><br />';
             } else {
                 $return .= '...<br />';
             }
         }
     }
     $xajax_response->addAssign('ajax_list_courses', 'innerHTML', api_utf8_encode($return));
     return $xajax_response;
 }
 public function uninstall()
 {
     $t_settings = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
     $t_options = Database::get_main_table(TABLE_MAIN_SETTINGS_OPTIONS);
     $t_tool = Database::get_course_table(TABLE_TOOL_LIST);
     //New settings
     $sql = "DELETE FROM {$t_settings} WHERE variable = 'bbb_tool_enable'";
     Database::query($sql);
     $sql = "DELETE FROM {$t_settings} WHERE variable = 'bbb_salt'";
     Database::query($sql);
     $sql = "DELETE FROM {$t_settings} WHERE variable = 'bbb_host'";
     Database::query($sql);
     //Old settings deleting just in case
     $sql = "DELETE FROM {$t_settings} WHERE variable = 'bbb_plugin'";
     Database::query($sql);
     $sql = "DELETE FROM {$t_options} WHERE variable  = 'bbb_plugin'";
     Database::query($sql);
     $sql = "DELETE FROM {$t_settings} WHERE variable = 'bbb_plugin_host'";
     Database::query($sql);
     $sql = "DELETE FROM {$t_settings} WHERE variable = 'bbb_plugin_salt'";
     Database::query($sql);
     //hack to get rid of Database::query warning (please add c_id...)
     $sql = "DELETE FROM {$t_tool} WHERE name = 'bbb' AND c_id != 0";
     Database::query($sql);
     $t = Database::get_main_table('plugin_bbb_meeting');
     $sql = "DROP TABLE IF EXISTS {$t}";
     Database::query($sql);
     //Deleting course settings
     $this->uninstall_course_fields_in_all_courses($this->course_settings);
 }
/**
 *
 */
function get_course_usage($course_code, $session_id = 0)
{
    $table = Database::get_main_table(TABLE_MAIN_COURSE);
    $course_code = Database::escape_string($course_code);
    $sql = "SELECT * FROM {$table} WHERE code='" . $course_code . "'";
    $res = Database::query($sql);
    $course = Database::fetch_object($res);
    // Learnpaths
    $table = Database::get_course_table(TABLE_LP_MAIN);
    $usage[] = array(get_lang(ucfirst(TOOL_LEARNPATH)), CourseManager::count_rows_course_table($table, $session_id, $course->id));
    // Forums
    $table = Database::get_course_table(TABLE_FORUM);
    $usage[] = array(get_lang('Forums'), CourseManager::count_rows_course_table($table, $session_id, $course->id));
    // Quizzes
    $table = Database::get_course_table(TABLE_QUIZ_TEST);
    $usage[] = array(get_lang(ucfirst(TOOL_QUIZ)), CourseManager::count_rows_course_table($table, $session_id, $course->id));
    // Documents
    $table = Database::get_course_table(TABLE_DOCUMENT);
    $usage[] = array(get_lang(ucfirst(TOOL_DOCUMENT)), CourseManager::count_rows_course_table($table, $session_id, $course->id));
    // Groups
    $table = Database::get_course_table(TABLE_GROUP);
    $usage[] = array(get_lang(ucfirst(TOOL_GROUP)), CourseManager::count_rows_course_table($table, $session_id, $course->id));
    // Calendar
    $table = Database::get_course_table(TABLE_AGENDA);
    $usage[] = array(get_lang(ucfirst(TOOL_CALENDAR_EVENT)), CourseManager::count_rows_course_table($table, $session_id, $course->id));
    // Link
    $table = Database::get_course_table(TABLE_LINK);
    $usage[] = array(get_lang(ucfirst(TOOL_LINK)), CourseManager::count_rows_course_table($table, $session_id, $course->id));
    // Announcements
    $table = Database::get_course_table(TABLE_ANNOUNCEMENT);
    $usage[] = array(get_lang(ucfirst(TOOL_ANNOUNCEMENT)), CourseManager::count_rows_course_table($table, $session_id, $course->id));
    return $usage;
}
Example #28
0
 /**
  * function that load packages and register them in storage
  * @param integer
  * @return void
  **/
 public static function load(int $group) : bool
 {
     $packages = Database::query(TABLE_PACKAGE_TO_GROUP, ['packageid'], '`groupid` = ' . $group);
     $list = [];
     $store = [];
     foreach ($packages as $package) {
         $list[] = $package['packageid'];
     }
     if (!empty($list)) {
         $packages = Database::query(TABLE_PACKAGE, ['*'], '`packageid` IN ( ' . implode(', ', $list) . ' )');
         foreach ($packages as $package) {
             if (file_exists(DIR_PACKAGES . '/' . $package['repertory'] . '/confs.php')) {
                 require DIR_PACKAGES . '/' . $package['repertory'] . '/confs.php';
             }
             if (file_exists(DIR_PACKAGES . '/' . $package['repertory'] . '/models')) {
                 Document::get(DIR_PACKAGES . '/' . $package['repertory'] . '/models');
             }
             if (file_exists(DIR_PACKAGES . '/' . $package['repertory'] . '/controllers')) {
                 Document::get(DIR_PACKAGES . '/' . $package['repertory'] . '/controllers');
             }
             $store[] = $package;
         }
     }
     Storage::store(['packages' => $store]);
     return true;
 }
Example #29
0
 public function RemoveMatchingProcess($param)
 {
     parent::query('DELETE FROM dy_place_to_tag WHERE (pt_place_id = :place_id AND pt_tag_id = :tag_id)');
     parent::bind(':place_id', $param['place_id']);
     parent::bind(':tag_id', $param['tag_id']);
     parent::execute();
 }
function search_sessions($needle, $type)
{
    global $tbl_session_rel_access_url, $tbl_session, $user_id;
    $xajax_response = new xajaxResponse();
    $return = '';
    if (!empty($needle) && !empty($type)) {
        $needle = Database::escape_string($needle);
        $assigned_sessions_to_hrm = SessionManager::get_sessions_followed_by_drh($user_id);
        $assigned_sessions_id = array_keys($assigned_sessions_to_hrm);
        $without_assigned_sessions = '';
        if (count($assigned_sessions_id) > 0) {
            $without_assigned_sessions = " AND s.id NOT IN(" . implode(',', $assigned_sessions_id) . ")";
        }
        if (api_is_multiple_url_enabled()) {
            $sql = " SELECT s.id, s.name FROM {$tbl_session} s\n                        LEFT JOIN {$tbl_session_rel_access_url} a ON (s.id = a.session_id)\n                        WHERE  s.name LIKE '{$needle}%' {$without_assigned_sessions} AND access_url_id = " . api_get_current_access_url_id() . "";
        } else {
            $sql = "SELECT s.id, s.name FROM {$tbl_session} s\n                    WHERE  s.name LIKE '{$needle}%' {$without_assigned_sessions} ";
        }
        $rs = Database::query($sql);
        $return .= '<select class="form-control" id="origin" name="NoAssignedSessionsList[]" multiple="multiple" size="20">';
        while ($session = Database::fetch_array($rs)) {
            $return .= '<option value="' . $session['id'] . '" title="' . htmlspecialchars($session['name'], ENT_QUOTES) . '">' . $session['name'] . '</option>';
        }
        $return .= '</select>';
        $xajax_response->addAssign('ajax_list_sessions_multiple', 'innerHTML', api_utf8_encode($return));
    }
    return $xajax_response;
}