/** * Generate a new slug for the post. * * @return string The slug */ protected function setslug() { $value = ''; // determine the base value from: // - the new slug if (isset($this->newfields['term']) && $this->newfields['term'] != '') { $value = $this->newfields['term']; } elseif ($this->fields['term'] != '') { $value = $this->fields['term']; } elseif (isset($this->newfields['term_display']) && $this->newfields['term_display'] != '') { $value = $this->newfields['term_display']; } elseif ($this->fields['term_display'] != '') { $value = $this->fields['term_display']; } // make sure our slug is unique $slug = Plugins::filter('term_setslug', $value); $slug = Utils::slugify($slug); $postfix = ''; $postfixcount = 0; do { if (!($slugcount = DB::get_row('SELECT COUNT(term) AS ct FROM {terms} WHERE term = ? AND vocabulary_id = ?;', array($slug . $postfix, $this->fields['vocabulary_id'])))) { Utils::debug(DB::get_errors()); exit; } if ($slugcount->ct != 0) { $postfix = "-" . ++$postfixcount; } } while ($slugcount->ct != 0); return $this->newfields['term'] = $slug . $postfix; }
public function action_plugin_activation($file) { DB::register_table('abbrev'); /* * Create the database table, or upgrade it */ $dbms = DB::get_driver_name(); $sql = 'CREATE TABLE ' . DB::table('abbrev') . ' ' . '('; if ($dbms == 'sqlite') { $sql .= 'xid INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,'; } else { if ($dbms == 'mysql') { $sql .= 'xid INT(9) NOT NULL AUTO_INCREMENT,' . 'UNIQUE KEY xid (xid),'; } else { $sql .= 'xid INT(9) NOT NULL AUTO_INCREMENT,' . 'UNIQUE KEY xid (xid),'; } } $sql .= 'abbrev VARCHAR(255),' . 'caseful INTEGER DEFAULT 0,' . "prefix VARCHAR(16) DEFAULT '\\b'," . "postfix VARCHAR(16) DEFAULT '\\b'," . 'priority INTEGER DEFAULT 100,' . 'definition VARCHAR(255)' . ')'; if (!DB::dbdelta($sql)) { Utils::debug(DB::get_errors()); } if ($file == str_replace('\\', '/', $this->get_file())) { ACL::create_token(self::PLUGIN_TOKEN, _t('Allow use of Abbrev plugin'), 'Category', false); $group = UserGroup::get_by_name('admin'); $group->grant(self::PLUGIN_TOKEN); } }
public function cuantosRepuestos() { $bd = new DB(); $query = $bd->query("SELECT COUNT(*) as cuantos FROM repuestos"); if ($query) { $res = $bd->fetchObj(); return $res->cuantos; } else { return $bd->get_errors(); } }
public function cuantosUsuarios() { $bd = new DB(); if ($_SESSION['tipoUser'] == 1) { $where = " WHERE\tid_tipo_usuario != 1"; } else { $where = ""; } $query = $bd->query("SELECT COUNT(*) as cuantos FROM usuarios " . $where); if ($query) { $res = $bd->fetchObj(); return $res->cuantos; } else { return $bd->get_errors(); } }
/** * Generate a new slug for the post. * * @return string The slug */ private function setslug() { // determine the base value from: // - the new slug // If the slug is new and has a length if ( isset( $this->newfields['slug'] ) && $this->newfields['slug'] != '' ) { $value = $this->newfields['slug']; } // - the new empty slug whilst in draft or progressing directly to published or scheduled from draft. // - Also allow changing of slug whilst in scheduled state // // This happens when a draft is being updated, or a post is being directly published or scheduled, // or an existing scheduled or published post is being updated, but not made into a draft // // If a new slug is set, and it doesn't have a length elseif ( isset( $this->newfields['slug'] ) && $this->newfields['slug'] == '' ) { // If the existing status of the post is draft, no matter what status it is being changed to if ( $this->fields['status'] == Post::status( 'draft' ) || ( // or the existing status is not draft and the new status is not draft $this->fields['status'] != Post::status( 'draft' ) && $this->newfields['status'] != Post::status( 'draft' ) ) ) { // And a new title is set, use the new title if ( isset( $this->newfields['title'] ) && $this->newfields['title'] != '' ) { $value = $this->newfields['title']; } // Otherwise, use the existing title else { $value = $this->fields['title']; } } } // - the existing slug // If there is an existing slug, and it has a length elseif ( $this->fields['slug'] != '' ) { $value = $this->fields['slug']; } // - the new post title // If there is a new title, and it has a length elseif ( isset( $this->newfields['title'] ) && $this->newfields['title'] != '' ) { $value = $this->newfields['title']; } // - the existing post title // If there is an existing title, and it has a length elseif ( $this->fields['title'] != '' ) { $value = $this->fields['title']; } // - default //Nothing else worked. Default to 'Post' else { $value = 'Post'; } // make sure our slug is unique $slug = Plugins::filter( 'post_setslug', $value ); $slug = Utils::slugify( $slug ); $postfix = ''; $postfixcount = 0; do { if ( ! $slugcount = DB::get_row( 'SELECT COUNT(slug) AS ct FROM {posts} WHERE slug = ?;', array( $slug . $postfix ) ) ) { Utils::debug( DB::get_errors() ); exit; } if ( $slugcount->ct != 0 ) { $postfix = "-" . ( ++$postfixcount ); } } while ( $slugcount->ct != 0 ); return $this->newfields['slug'] = $slug . $postfix; }
/** * Generate a new slug for the post. * * @return string The slug */ private function setslug() { // determine the base value from: // - the new slug if (isset($this->newfields['slug']) && $this->newfields['slug'] != '') { $value = $this->newfields['slug']; } elseif (isset($this->newfields['slug']) && $this->newfields['slug'] == '') { if ($this->fields['status'] == Post::status('draft') || $this->fields['status'] != Post::status('draft') && $this->newfields['status'] != Post::status('draft')) { if (isset($this->newfields['title']) && $this->newfields['title'] != '') { $value = $this->newfields['title']; } else { $value = $this->fields['title']; } } } elseif ($this->fields['slug'] != '') { $value = $this->fields['slug']; } elseif (isset($this->newfields['title']) && $this->newfields['title'] != '') { $value = $this->newfields['title']; } elseif ($this->fields['title'] != '') { $value = $this->fields['title']; } else { $value = 'Post'; } // make sure our slug is unique $slug = Plugins::filter('post_setslug', $value); $slug = Utils::slugify($slug); $postfix = ''; $postfixcount = 0; do { if (!($slugcount = DB::get_row('SELECT COUNT(slug) AS ct FROM {posts} WHERE slug = ?;', array($slug . $postfix)))) { Utils::debug(DB::get_errors()); exit; } if ($slugcount->ct != 0) { $postfix = "-" . ++$postfixcount; } } while ($slugcount->ct != 0); return $this->newfields['slug'] = $slug . $postfix; }
public function listarEstadoPresupuesto($seleccionado) { $bd = new DB(); $sql = "\tSELECT\tid_estado_ppto, descripcion\n\t\t\t\t\t\tFROM \testados_ppto\n\t\t\t\t\t\tWHERE\tactivo = 1 \n\t\t\t\t\t"; if ($bd->query($sql)) { $array_res = array(); $cuantos = $bd->resultCount(); #$options = '<option value="">[Selecciona un Tipo]</option>'; $options = ''; for ($i = 0; $i < $cuantos; $i++) { $res = $bd->fetchObj(); if ($seleccionado != 0 and $res->id_estado_ppto == $seleccionado) { $sel = "selected='selected'"; } else { $sel = ""; } $options .= '<option value="' . $res->id_estado_ppto . '" ' . $sel . '>' . utf8_encode($res->descripcion) . '</option>'; } return $options; } else { return $bd->get_errors(); } }
extract($_POST); $sql = 'SELECT u.id_usuario, u.id_tipo_usuario, u.nombre, u.correo, u.telefono, u.activo FROM usuarios u WHERE u.usuario="' . $login_username . '" AND u.pass="******" LIMIT 1'; #echo $sql; $bd->query($sql); if ($bd->resultExist()) { $user = @$bd->fetchObj(); if ($user->activo == 0) { echo 2; } else { $_SESSION['userid'] = $user->id_usuario; $_SESSION['nombreUser'] = $user->nombre; $_SESSION['correoUser'] = $user->correo; $_SESSION['tipoUser'] = $user->id_tipo_usuario; $_SESSION['time_login'] = time(); echo 1; } } else { echo 0; } $bd->disconnect(); } else { echo "error: " . $bd->get_errors(); } } else { echo "error2: " . $bd->get_errors(); }
public function cargaComunas($id_region, $seleccionado) { $bd = new DB(); $sql = $bd->query("SELECT id_comuna, nombre FROM comunas WHERE id_region = " . $id_region); if ($sql) { $cuantos = $bd->resultCount(); #$options = '<option value="">[Selecciona una Comuna]</option>'; $options = ''; for ($i = 0; $i < $cuantos; $i++) { $res = $bd->fetchObj(); if ($seleccionado != 0 and $res->id_comuna == $seleccionado) { $sel = "selected='selected'"; } else { $sel = ""; } $options .= '<option value="' . $res->id_comuna . '" ' . $sel . '>' . utf8_encode($res->nombre) . '</option>'; } return $options; } else { return $bd->get_errors(); } }