public function checkForDuplicateReg($params) { $db = new DBUtil(); $sql = "select count(*) as count from person p \n" . "join user u on p.person_id = u.person_id \n" . "join contact c on p.person_id = c.person_id \n" . "where email = :email or login = :username \n" . "or (first_name = :first_name and last_name = :last_name and postal_code = :postal_code) \n"; $stmt = $db->query($sql, $params); if ($stmt && ($row = $stmt->fetch(PDO::FETCH_OBJ))) { echo print_r($row, true); if (empty($row->count)) { // we haven't created this example or a similar user doesn't already exist return false; } } return true; }
/** * Creates a new logging instance. * * @param Doctrine_Event $event Event. * @param int $opType I/U/D for Insert/Update/Delete. * * @return void */ private function _createOperationLog(Doctrine_Event $event, $opType = 'I') { $data = $event->getInvoker(); $tableName = $this->getTableNameFromEvent($event); $idColumn = $this->getIdColumnFromEvent($event); $log = array(); $log['object_type'] = $tableName; $log['object_id'] = $data[$idColumn]; $log['op'] = $opType; if ($opType == 'U') { $oldValues = $data->getLastModified(true); $diff = array(); foreach ($oldValues as $column => $oldValue) { if (empty($oldValue) && isset($data[$column]) && !empty($data[$column])) { $diff[$column] = 'I: ' . $data[$column]; } elseif (!empty($oldValue) && isset($data[$column]) && !empty($data[$column])) { $diff[$column] = 'U: ' . $data[$column]; } elseif (!empty($oldValue) && empty($data[$column])) { $diff[$column] = 'D: ' . $oldValue; } } $log['diff'] = serialize($diff); } else { // Convert object to array (otherwise we serialize the record object) $log['diff'] = serialize($data->toArray()); } DBUtil::insertObject($log, 'objectdata_log'); }
public static function Authenticate($username, $pass) { $o = new DBUtil(); $username = mysql_real_escape_string($username); $pass = md5(mysql_real_escape_string($pass)); $query = "CALL " . SP_LOGIN . "('" . $username . "','" . $pass . "')"; $res = $o->fetch($query); $row = mysql_fetch_array($res); $loginInfo = new LoginInfo(); $loginInfo->msg = $row['res_msg']; $loginInfo->id = $row['id1']; return $loginInfo; }
function display() { $prevpage = null; $nextpage = null; $page = ModUtil::apiFunc('Content', 'Page', 'getPage', array('id' => $this->pageId)); $tables = DBUtil::getTables(); $pageTable = $tables['content_page']; $pageColumn = $tables['content_page_column']; $options = array('makeTree' => true); $options['orderBy'] = 'position'; $options['orderDir'] = 'desc'; $options['pageSize'] = 1; $options['filter']['superParentId'] = $page['parentPageId']; if ($page['position'] > 0) { $options['filter']['where'] = "{$pageColumn['level']} = {$page['level']} and {$pageColumn['position']} < {$page['position']}"; $pages = ModUtil::apiFunc('Content', 'Page', 'getPages', $options); if (count($pages) > 0) { $prevpage = $pages[0]; } } if (isset($page['position']) && $page['position'] >= 0) { $options['orderDir'] = 'asc'; $options['filter']['where'] = "{$pageColumn['level']} = {$page['level']} and {$pageColumn['position']} > {$page['position']}"; $pages = ModUtil::apiFunc('Content', 'Page', 'getPages', $options); if (count($pages) > 0) { $nextpage = $pages[0]; } } $this->view->assign('loggedin', UserUtil::isLoggedIn()); $this->view->assign('prevpage', $prevpage); $this->view->assign('nextpage', $nextpage); return $this->view->fetch($this->getTemplate()); }
function do_main() { $this->oPage->setBreadcrumbDetails(_kt("transactions")); $this->oPage->setTitle(_kt('Folder transactions')); $folder_data = array(); $folder_data["folder_id"] = $this->oFolder->getId(); $this->oPage->setSecondaryTitle($this->oFolder->getName()); $aTransactions = array(); // FIXME do we really need to use a raw db-access here? probably... $sQuery = "SELECT DTT.name AS transaction_name, FT.transaction_namespace, U.name AS user_name, FT.comment AS comment, FT.datetime AS datetime " . "FROM " . KTUtil::getTableName("folder_transactions") . " AS FT LEFT JOIN " . KTUtil::getTableName("users") . " AS U ON FT.user_id = U.id " . "LEFT JOIN " . KTUtil::getTableName("transaction_types") . " AS DTT ON DTT.namespace = FT.transaction_namespace " . "WHERE FT.folder_id = ? ORDER BY FT.datetime DESC"; $aParams = array($this->oFolder->getId()); $res = DBUtil::getResultArray(array($sQuery, $aParams)); if (PEAR::isError($res)) { var_dump($res); // FIXME be graceful on failure. exit(0); } // FIXME roll up view transactions $aTransactions = $res; // Set the namespaces where not in the transactions lookup foreach ($aTransactions as $key => $transaction) { if (empty($transaction['transaction_name'])) { $aTransactions[$key]['transaction_name'] = $this->_getActionNameForNamespace($transaction['transaction_namespace']); } } // render pass. $this->oPage->title = _kt("Folder History"); $oTemplating =& KTTemplating::getSingleton(); $oTemplate = $oTemplating->loadTemplate("kt3/view_folder_history"); $aTemplateData = array("context" => $this, "folder_id" => $folder_id, "folder" => $this->oFolder, "transactions" => $aTransactions); return $oTemplate->render($aTemplateData); }
function transform() { global $default; $iMimeTypeId = $this->oDocument->getMimeTypeId(); $sMimeType = KTMime::getMimeTypeName($iMimeTypeId); $sFileName = $this->oDocument->getFileName(); $aTestTypes = array('application/octet-stream', 'application/zip', 'application/x-zip'); if (in_array($sMimeType, $aTestTypes)) { $sExtension = KTMime::stripAllButExtension($sFileName); $sTable = KTUtil::getTableName('mimetypes'); $sQuery = "SELECT id, mimetypes FROM {$sTable} WHERE LOWER(filetypes) = ?"; $aParams = array($sExtension); $aRow = DBUtil::getOneResult(array($sQuery, $aParams)); if (PEAR::isError($aRow)) { $default->log->debug("ODI: error in query: " . print_r($aRow, true)); return; } if (empty($aRow)) { $default->log->debug("ODI: query returned entry"); return; } $id = $aRow['id']; $mimetype = $aRow['mimetypes']; $default->log->debug("ODI: query returned: " . print_r($aRow, true)); if (in_array($mimetype, $aTestTypes)) { // Haven't changed, really not an OpenDocument file... return; } if ($id) { $this->oDocument->setMimeTypeId($id); $this->oDocument->update(); } } parent::transform(); }
/** * upgrade the module from an old version * * This function must consider all the released versions of the module! * If the upgrade fails at some point, it returns the last upgraded version. * * @param string $oldVersion version number string to upgrade from * @return mixed true on success, last valid version string or false if fails */ public function upgrade($oldversion) { // Upgrade dependent on old version number switch ($oldversion) { case '3.6': // Rename 'thelang' block. $table = 'blocks'; $sql = "UPDATE {$table} SET bkey = 'lang' WHERE bkey = 'thelang'"; \DBUtil::executeSQL($sql); // Optional upgrade if (in_array(\DBUtil::getLimitedTablename('message'), \DBUtil::metaTables())) { $this->migrateMessages(); } $this->migrateBlockNames(); $this->migrateExtMenu(); case '3.7': case '3.7.0': if (!\DBUtil::changeTable('blocks')) { return false; } case '3.7.1': $this->newBlockPositions(); case '3.8.0': // update empty filter fields to an empty array $entity = $this->name . '\\Entity\\Block'; $dql = "UPDATE {$entity} p SET p.filter = 'a:0:{}' WHERE p.filter = '' OR p.filter = 's:0:\"\";'"; $query = $this->entityManager->createQuery($dql); $query->getResult(); case '3.8.1': // future upgrade routines } // Update successful return true; }
/** * Define module tables * @author Albert Perez Monfort (aperezm@xtec.cat) * @return module tables information */ function IWmenu_tables() { // Initialise table array $tables = array(); // IWmain table definition $tables['IWmenu'] = DBUtil::getLimitedTablename('IWmenu'); //Noms dels camps $tables['IWmenu_column'] = array('mid' => 'iw_mid', 'text' => 'iw_text', 'url' => 'iw_url', 'id_parent' => 'iw_id_parent', 'groups' => 'iw_groups', 'active' => 'iw_active', 'target' => 'iw_target', 'descriu' => 'iw_descriu', 'iorder' => 'iw_iorder', 'icon' => 'iw_icon',); $tables['IWmenu_column_def'] = array('mid' => "I NOTNULL AUTO PRIMARY", 'text' => "C(255) NOTNULL DEFAULT ''", 'url' => "X NOTNULL", 'id_parent' => "I NOTNULL DEFAULT '0'", 'groups' => "X NOTNULL", 'active' => "I(1) NOTNULL DEFAULT '0'", 'target' => "I(1) NOTNULL DEFAULT '0'", 'descriu' => "X NOTNULL", 'iorder' => "I NOTNULL DEFAULT '0'", 'icon' => "C(40) NOTNULL DEFAULT ''"); // Return the table information return $tables; }
/** * Update the IWwebbox module * @author Albert Pérez Monfort (aperezm@xtec.cat) * @author Jaume Fernàndez Valiente (jfern343@xtec.cat) * @return bool true if successful, false otherwise */ public function upgrade($oldversion) { // Update z_blocs table $c = "UPDATE blocks SET bkey = 'Webbox' WHERE bkey = 'webbox'"; if (!DBUtil::executeSQL($c)) { return false; } //Array de noms $oldVarsNames = DBUtil::selectFieldArray("module_vars", 'name', "`modname` = 'IWwebbox'", '', false, ''); $newVarsNames = Array('url', 'width', 'height', 'scrolls', 'widthunit'); $newVars = Array('url' => 'http://phobos.xtec.cat/intraweb', 'width' => '100', 'height' => '600', 'scrolls' => '1', 'widthunit' => '%'); // Delete unneeded vars $del = array_diff($oldVarsNames, $newVarsNames); foreach ($del as $i) { $this->delVar($i); } // Add new vars $add = array_diff($newVarsNames, $oldVarsNames); foreach ($add as $i) { $this->setVar($i, $newVars[$i]); } return true; }
public function down() { $tables = array('bans', 'user_metadata', 'user_security', 'user_groups', 'users', 'group_permissions', 'groups_users'); foreach ($tables as $table) { \DBUtil::drop_table($table); } }
public function getModuleConfig($args) { if (!isset($args['modulename'])) { $args['modulename'] = ModUtil::getName(); } $modconfig = array(); if ($args['modulename'] == 'list') { $modconfig = DBUtil::selectObjectArray('scribite', '', 'modname'); } else { $dbtables = DBUtil::getTables(); $scribitecolumn = $dbtables['scribite_column']; $where = "{$scribitecolumn['modname']} = '" . $args['modulename'] . "'"; $item = DBUtil::selectObjectArray('scribite', $where); if ($item == false) { return; } $modconfig['mid'] = $item[0]['mid']; $modconfig['modulename'] = $item[0]['modname']; if (!is_int($item[0]['modfuncs'])) { $modconfig['modfuncs'] = unserialize($item[0]['modfuncs']); } if (!is_int($item[0]['modareas'])) { $modconfig['modareas'] = unserialize($item[0]['modareas']); } $modconfig['modeditor'] = $item[0]['modeditor']; } return $modconfig; }
function down() { // get the driver used \Config::load('auth', true); $drivers = \Config::get('auth.driver', array()); is_array($drivers) or $drivers = array($drivers); if (in_array('Simpleauth', $drivers)) { // get the tablename \Config::load('simpleauth', true); $table = \Config::get('simpleauth.table_name', 'users') . '_providers'; // make sure the configured DB is used \DBUtil::set_connection(\Config::get('simpleauth.db_connection', null)); } elseif (in_array('Ormauth', $drivers)) { // get the tablename \Config::load('ormauth', true); $table = \Config::get('ormauth.table_name', 'users') . '_providers'; // make sure the configured DB is used \DBUtil::set_connection(\Config::get('ormauth.db_connection', null)); } if (isset($table)) { // drop the users remote table \DBUtil::drop_table($table); } // reset any DBUtil connection set \DBUtil::set_connection(null); }
/** * Return a reference depending on this reference name * * @param int $args['ref'] Id of the reference that have to be returned * @return array array of items, or false on failure */ public function getref($args) { if (!isset($args['ref'])) { return LogUtil::registerError(__('Error! Could not do what you wanted. Please check your input.')); } return DBUtil::selectObjectByID('IWwebbox', $args['ref'], 'ref', '', ''); }
/** * Check whether the object cache should be used for a specific query/operation. * * @param string $tablename The Zikula tablename. * * @return true/false */ public static function hasObjectCache($tablename) { if (!self::$cache_enabled) { self::$cache_enabled = ServiceUtil::getManager()->getParameter('dbcache.enable'); } return $tablename != 'session_info' && !System::isInstalling() && self::$cache_enabled; }
public function ruleDeleted($rid) { $form = DBUtil::findUnique(DBUtil::$TABLE_ORDER_FORM, array(":rid" => $rid)); pdo_delete(DBUtil::$TABLE_ORDER_ITEM, array("fid" => $form['id'])); pdo_delete(DBUtil::$TABLE_ORDER_ORDER, array("fid" => $form['id'])); pdo_delete(DBUtil::$TABLE_ORDER_FORM, array('id' => $form['id'])); }
public function down() { $tables = array('bans', 'groups_users', 'group_permissions', 'log_in_attempt', 'users', 'user_groups', 'user_metadata', 'user_oauth', 'user_security'); foreach ($tables as $table) { \DBUtil::rename_table('ethanol_' . $table, $table); } }
/** * Zikula Application Framework * * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html * @author Joan Guillén i Pelegay (jguille2@xtec.cat) * * @category Sirius Modules */ function SiriusXtecAuth_tables() { // Inclusió de la definició de la taula IWusers $tables['IWusers'] = DBUtil::getLimitedTablename('IWusers'); $tables['IWusers_column'] = array( 'suid' => 'iw_suid', 'uid' => 'iw_uid', 'id' => 'iw_id', 'nom' => 'iw_nom', 'cognom1' => 'iw_cognom1', 'cognom2' => 'iw_cognom2', 'naixement' => 'iw_naixement', 'accio' => 'iw_accio', 'sex' => 'iw_sex', 'description' => 'iw_description', 'avatar' => 'iw_avatar', 'newavatar' => 'iw_newavatar', ); $tables['IWusers_column_def'] = array('suid' => "I NOTNULL AUTO PRIMARY", 'uid' => "I NOTNULL DEFAULT '0'", 'id' => "C(50) NOTNULL DEFAULT ''", 'nom' => "C(25) NOTNULL DEFAULT ''", 'cognom1' => "C(25) NOTNULL DEFAULT ''", 'cognom2' => "C(25) NOTNULL DEFAULT ''", 'naixement' => "C(8) NOTNULL DEFAULT ''", 'accio' => "I(1) NOTNULL DEFAULT '0'", 'sex' => "C(1) NOTNULL DEFAULT ''", 'description' => "X NOTNULL", 'avatar' => "C(50) NOTNULL DEFAULT ''", 'newavatar' => "C(50) NOTNULL DEFAULT ''", ); //Returns informació de les taules return $tables; }
/** * This method gets ran when a valid method name is not used in the command. * * Usage (from command line): * * php oil r setuptables:index "arguments" * * @return string */ public function index($args = NULL) { echo "\n==========================================="; echo "\nRunning task [Setuptables:Index]"; echo "\n-------------------------------------------\n\n"; /*************************** Put in TASK DETAILS HERE **************************/ // 初期ユーザー定義 $init_users = array(array('name' => 'codex', 'password' => '1234', 'group' => 6)); // データベース接続 \DBUtil::set_connection(null); // {{{ トランケート $truncates = array('', '_permissions', '_metadata', '_user_permissions', '_group_permissions', '_role_permissions'); foreach ($truncates as $truncate) { \DBUtil::truncate_table('users' . $truncate); } // }}} // {{{ 初期ユーザー追加 foreach ($init_users as $init_user) { // ユーザー名 $key = $init_user['name']; // パスワード $password = $init_user['password']; // メールアドレス $email = $key . '@xenophy.com'; // グループ $group = $init_user['group']; // 追加 $user = \Auth\Model\Auth_User::forge()->find(\Auth::create_user($key, $password, $email, $group)); // 保存 $user->save(); } // }}} }
function delete() { // security check if (!SecurityUtil::checkPermission('AddressBook::', '::', ACCESS_ADMIN)) { return LogUtil::registerPermissionError(); } $ot = FormUtil::getPassedValue('ot', 'categories', 'GETPOST'); $id = (int) FormUtil::getPassedValue('id', 0, 'GETPOST'); $url = ModUtil::url('AddressBook', 'admin', 'view', array('ot' => $ot)); $class = 'AddressBook_DBObject_' . ucfirst($ot); if (!class_exists($class)) { return z_exit(__f('Error! Unable to load class [%s]', $ot)); } $object = new $class(); $data = $object->get($id); if (!$data) { LogUtil::registerError(__f('%1$s with ID of %2$s doesn\'\\t seem to exist', array($ot, $id))); return System::redirect($url); } $object->delete(); if ($ot == "customfield") { $sql = "ALTER TABLE addressbook_address DROP adr_custom_" . $id; try { DBUtil::executeSQL($sql, -1, -1, true, true); } catch (Exception $e) { } } LogUtil::registerStatus($this->__('Done! Item deleted.')); return System::redirect($url); }
/** * This function sets active/inactive status. * * @param eid * * @return mixed true or Ajax error */ public function setstatus() { $this->checkAjaxToken(); $this->throwForbiddenUnless(SecurityUtil::checkPermission('Ephemerides::', '::', ACCESS_ADMIN)); $eid = $this->request->request->get('eid', 0); $status = $this->request->request->get('status', 0); $alert = ''; if ($eid == 0) { $alert .= $this->__('No ID passed.'); } else { $item = array('eid' => $eid, 'status' => $status); $res = DBUtil::updateObject($item, 'ephem', '', 'eid'); if (!$res) { $alert .= $item['eid'] . ', ' . $this->__f('Could not change item, ID %s.', DataUtil::formatForDisplay($eid)); if ($item['status']) { $item['status'] = 0; } else { $item['status'] = 1; } } } // get current status to return $item = ModUtil::apiFunc($this->name, 'user', 'get', array('eid' => $eid)); if (!$item) { $alert .= $this->__f('Could not get data, ID %s.', DataUtil::formatForDisplay($eid)); } return new Zikula_Response_Ajax(array('eid' => $eid, 'status' => $item['status'], 'alert' => $alert)); }
function down() { // get the drivers defined $drivers = normalize_driver_types(); if (in_array('Simpleauth', $drivers)) { // get the tablename \Config::load('simpleauth', true); $basetable = \Config::get('simpleauth.table_name', 'users'); // make sure the configured DB is used \DBUtil::set_connection(\Config::get('simpleauth.db_connection', null)); } elseif (in_array('Ormauth', $drivers)) { // get the tablename \Config::load('ormauth', true); $basetable = \Config::get('ormauth.table_name', 'users'); // make sure the configured DB is used \DBUtil::set_connection(\Config::get('ormauth.db_connection', null)); } else { $basetable = 'users'; } \DBUtil::drop_table($basetable . '_sessionscopes'); \DBUtil::drop_table($basetable . '_sessions'); \DBUtil::drop_table($basetable . '_scopes'); \DBUtil::drop_table($basetable . '_clients'); // reset any DBUtil connection set \DBUtil::set_connection(null); }
public function down() { \DBUtil::drop_table('scripts_forms_products'); \DBUtil::drop_table('scripts_forms_questions_products'); \DBUtil::drop_table('scripts_forms_responses_products'); \DB::query("ALTER TABLE `scripts_forms` DROP `rebuttal_script`")->execute(); }
public static function updateStatusAndPayChannel($reservationId, $status, $channel = NULL) { $connection = DBUtil::connectDB(); $ret = mysql_query("update reservation set status='{$status}',pay_channel='{$channel}' where id={$reservationId}", $connection); mysql_close(); return $ret; }
function down() { // get the configured table name $table = \Config::get('simpleauth.table_name', 'users'); // drop the users table \DBUtil::drop_table($table); }
public function action_index() { if (!\DBUtil::table_exists('blog') && !\DBUtil::table_exists('blog_comment')) { \Response::redirect('blog/installrequired'); } // list posts ----------------------------------------------------------------------------------------------------- $option['limit'] = \Model_Config::getval('content_items_perpage'); $option['offset'] = trim(\Input::get('page')) != null ? ((int) \Input::get('page') - 1) * $option['limit'] : 0; $list_items = \Blog\Model_Blog::listItems($option); // pagination config $config['pagination_url'] = \Uri::main() . \Uri::getCurrentQuerystrings(true, true, false); $config['total_items'] = $list_items['total']; $config['per_page'] = $option['limit']; $config['uri_segment'] = 'page'; $config['num_links'] = 3; $config['show_first'] = true; $config['show_last'] = true; $config['first-inactive'] = "\n\t\t<li class=\"disabled\">{link}</li>"; $config['first-inactive-link'] = '<a href="#">{page}</a>'; $config['first-marker'] = '«'; $config['last-inactive'] = "\n\t\t<li class=\"disabled\">{link}</li>"; $config['last-inactive-link'] = '<a href="#">{page}</a>'; $config['last-marker'] = '»'; $config['previous-marker'] = '‹'; $config['next-marker'] = '›'; $pagination = \Pagination::forge('viewlogins_pagination', $config); $output['list_items'] = $list_items; $output['pagination'] = $pagination; unset($config, $list_accounts, $option, $pagination); // <head> output ---------------------------------------------------------------------------------------------- $output['page_title'] = $this->generateTitle(\Lang::get('blog')); // <head> output ---------------------------------------------------------------------------------------------- return $this->generatePage('blog_v', $output, false); }
function do_main() { $this->oPage->setSecondaryTitle($this->oDocument->getName()); $this->oPage->setBreadcrumbDetails(_kt('history')); $aTransactions = array(); // FIXME create a sane "view user information" page somewhere. // FIXME do we really need to use a raw db-access here? probably... $sQuery = 'SELECT DTT.name AS transaction_name, DT.transaction_namespace, U.name AS user_name, DT.version AS version, DT.comment AS comment, DT.datetime AS datetime ' . 'FROM ' . KTUtil::getTableName('document_transactions') . ' AS DT INNER JOIN ' . KTUtil::getTableName('users') . ' AS U ON DT.user_id = U.id ' . 'LEFT JOIN ' . KTUtil::getTableName('transaction_types') . ' AS DTT ON DTT.namespace = DT.transaction_namespace ' . 'WHERE DT.document_id = ? ORDER BY DT.datetime DESC'; $aParams = array($this->oDocument->getId()); $res = DBUtil::getResultArray(array($sQuery, $aParams)); if (PEAR::isError($res)) { var_dump($res); // FIXME be graceful on failure. exit(0); } $aTransactions = $res; // Set the namespaces where not in the transactions lookup foreach ($aTransactions as $key => $transaction) { if (empty($transaction['transaction_name'])) { $aTransactions[$key]['transaction_name'] = $this->_getActionNameForNamespace($transaction['transaction_namespace']); } } // render pass. $this->oPage->setTitle(_kt('Document History')); $oTemplate = $this->oValidator->validateTemplate('ktcore/document/transaction_history'); $aTemplateData = array('context' => $this, 'document_id' => $this->oDocument->getId(), 'document' => $this->oDocument, 'transactions' => $aTransactions); return $oTemplate->render($aTemplateData); }
public static function updateUser($username, $nick, $avatar, $gender) { $sentence = ''; if ($nick != NULL) { $sentence = "nick='{$nick}'"; } if ($avatar != NULL) { if (!empty($sentence)) { $sentence .= ','; } $sentence .= "avatar='{$avatar}'"; } if ($gender != NULL) { if (!empty($sentence)) { $sentence .= ','; } $sentence .= "gender='{$gender}'"; } if (empty($sentence)) { return TRUE; } $conn = DBUtil::connectDB(); $result = mysql_query("update user set {$sentence} where username='******'", $conn); mysql_close(); return $result; }
function showArticles() { $db = new DBUtil(); $result = $db->getArticles("39"); echo "<table border=1>"; echo "<tr><td>ID</td><td>标题</td><td>文章</td></tr>"; while ($info = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>姚明</td>"; echo "<td>" . $info['title'] . "</td>"; echo "<td>" . $info['content'] . "</td>"; echo "</tr>"; } echo "</table>"; }
/** * Gets from the database all the items in the submenus * @author: Albert Pᅵrez Monfort (aperezm@xtec.cat) * @param: id parent of the menu which want the submenus * @return: And array with the items information */ public function getAllSubMenuItems($args) { $values = array(); // Security check if (!SecurityUtil::checkPermission('IWvhmenu::', '::', ACCESS_READ)) { return LogUtil::registerPermissionError(); } $table = DBUtil::getTables(); $c = $table['IWvhmenu_column']; $where = "$c[id_parent]=$args[id_parent] AND $c[active]=1"; $orderby = "$c[iorder]"; // get the objects from the db $items = DBUtil::selectObjectArray('IWvhmenu', $where, $orderby); // Check for an error with the database code, and if so set an appropriate // error message and return if ($items === false) { return LogUtil::registerError($this->__('Error! Could not load items.')); } // Return the items return $items; }
function do_main() { $this->oPage->setBreadcrumbDetails(_kt('select a group')); $this->oPage->setTitle(_kt("Group Management")); $KTConfig =& KTConfig::getSingleton(); $alwaysAll = $KTConfig->get("alwaysShowAll"); $name = KTUtil::arrayGet($_REQUEST, 'search_name', KTUtil::arrayGet($_REQUEST, 'old_search')); $show_all = KTUtil::arrayGet($_REQUEST, 'show_all', $alwaysAll); $group_id = KTUtil::arrayGet($_REQUEST, 'group_id'); $no_search = true; if (KTUtil::arrayGet($_REQUEST, 'do_search', false) != false) { $no_search = false; } if ($name == '*') { $show_all = true; $name = ''; } $search_fields = array(); $search_fields[] = new KTStringWidget(_kt('Group Name'), _kt("Enter part of the group's name. e.g. <strong>ad</strong> will match <strong>administrators</strong>."), 'search_name', $name, $this->oPage, true); if (!empty($name)) { $search_results =& Group::getList('WHERE name LIKE \'%' . DBUtil::escapeSimple($name) . '%\' AND id > 0'); } else { if ($show_all !== false) { $search_results =& Group::getList('id > 0'); $no_search = false; $name = '*'; } } $oTemplating =& KTTemplating::getSingleton(); $oTemplate = $oTemplating->loadTemplate("ktcore/principals/groupadmin"); $aTemplateData = array("context" => $this, "search_fields" => $search_fields, "search_results" => $search_results, 'no_search' => $no_search, 'old_search' => $name); return $oTemplate->render($aTemplateData); }