function FetchNth($N) { # # call Fetch first. # then call this function N times, where N is the number # returned by Fetch # # echo "fetching row $N<br>"; $WatchList = new WatchList($this->dbh); $myrow = pg_fetch_array($this->LocalResult, $N); $WatchList->PopulateValues($myrow); return $WatchList; }
public static function newInstance() { if (!self::$instance instanceof self) { self::$instance = new self(); } return self::$instance; }
function nc_osc_remove_watchlist($user_id, $item_id) { return WatchList::newInstance()->deleteFromWatchList($item_id, $user_id); }
if ($Debug) { echo "\$key='{$key}' \$WatchListIDToEmpty='{$WatchListIDToEmpty}'<br>"; } $EmptydWatchListID = $WatchList->EmptyTheList($User->id, pg_escape_string($WatchListIDToEmpty)); if ($EmptydWatchListID != $WatchListIDToEmpty) { die("Failed to Empty '{$WatchListIDToEmpty}' (return value '{$EmptydWatchListID}')" . pg_last_error()); } if ($Debug) { echo 'I have emptied watch list id = ' . $WatchListIDToEmpty . '<br>'; } } pg_query($db, 'COMMIT'); break; case 'empty_all': pg_query($db, 'BEGIN'); $WatchList = new WatchList($db); $NumRows = $WatchList->EmptyAllLists($User->id, pg_escape_string($WatchListIDToEmpty)); if (!isset($NumRows)) { die("Failed to Empty '{$WatchListIDToEmpty}' (return value '{$EmptydWatchListID}')" . pg_last_error()); } if ($Debug) { echo 'I have emptied all the watch lists.<br>'; } pg_query($db, 'COMMIT'); break; case 'set_default': if ($Debug) { echo 'I have set your default lists.<br>'; } pg_query($db, 'BEGIN'); $WatchLists = new WatchLists($db);
<?php $obj = new WatchList(); $objDb = new PDODatabase(); $tables = $objDb->Query('SHOW TABLES FROM ' . DB_NAME); $data['module_Title'] = 'List of tables'; foreach ($tables as $table) { $tableData = $obj->getByTableName($table['Tables_in_db_hacker']); //var_dump('<pre>', $tableData, $table); if (empty($tableData)) { $result = $obj->insert(array('table' => $table['Tables_in_db_hacker'])); //var_dump($result); } } /* * *************** these fields are required *********************************** */ //die(); //var_dump($MyModules); $id = 0; $message = ''; $data['module_Title'] = 'List of table'; $data['message'] = ''; if (isset($_GET['_Id'])) { $id = $_GET['_Id']; $data['_data'] = $obj->getByID($id); } else { $data['_data'] = $obj->get(); $data['list_fields'] = $obj->getListField(); } //var_dump($data); //$data['_extraModule'] = array(array('Commitments', 'Commit&action = Commitlist')); $data['prefix'] = $obj->getPrefix();
function nc_osc_has_watchlist_item() { $user_id = osc_logged_user_id(); $res = WatchList::newInstance()->userList($user_id); $Item = array(); $Resource = array(); foreach ($res as $key) { $aItem = Item::newInstance()->findByPrimaryKey($key['pk_i_item_id']); $iResource = ItemResource::newInstance()->getAllResourcesFromItem($key['pk_i_item_id']); $Item[$key['pk_i_item_id']] = $aItem; $Item[$key['pk_i_item_id']]['resources'] = $iResource; } if (!View::newInstance()->_exists('items')) { View::newInstance()->_exportVariableToView('items', $Item); } // set itemLoop to latest if it's the first time we enter here if (View::newInstance()->_get('itemLoop') !== 'latest') { View::newInstance()->_exportVariableToView('oldItem', View::newInstance()->_get('item')); View::newInstance()->_exportVariableToView('itemLoop', 'latest'); } // get next item $item = View::newInstance()->_next('items'); if (!$item) { View::newInstance()->_exportVariableToView('item', View::newInstance()->_get('oldItem')); View::newInstance()->_exportVariableToView('itemLoop', ''); } else { View::newInstance()->_exportVariableToView('item', View::newInstance()->_current('items')); } // reset the loop once we finish just in case we want to use it again if (!$item && View::newInstance()->_count('items') > 0) { View::newInstance()->_reset('items'); } return $item; }
if (isset($_REQUEST['category'])) { $category = pg_escape_string($_REQUEST['category']); $CategoryID = $Category->FetchByName($category); if (!$CategoryID) { $msg = "category '{$category}' not found"; syslog(LOG_ERR, $msg . " User = '******' in " . __FILE__ . ':' . __LINE__); die($msg); } } else { $msg = "category not supplied"; syslog(LOG_ERR, $msg . " User = '******' in " . __FILE__ . ':' . __LINE__); die($msg); } if ($submit) { pg_exec($db, "BEGIN"); $WatchList = new WatchList($db); $WatchList->EmptyTheListCategory($User->id, $wlid, $Category->id); $ports = $_POST["ports"]; if ($ports) { $WatchListElement = new WatchListElement($db); // make sure we are pointing at the start of the array. reset($ports); while (list($key, $value) = each($ports)) { $WatchListElement->Add($User->id, $wlid, $value); $result = pg_exec($db, $sql); ${"port_" . $value} = 1; if (!$result) { syslog(LOG_ERR, $_SERVER["PHP_SELF"] . ": could not clear watch list '{$wlid}' owned by '{$User->id}' of element '{$value}' in " . __FILE__ . ':' . __LINE__); die("error clear list before saving"); } }