public static function update($listID, $post = array(), $whereQuery = '', $addWhere = '') { if (isset($post['groupdata']) && !is_array($post['groupdata'])) { $post['groupdata'] = self::lineToArray($post['groupdata']); } if (is_numeric($listID)) { $catid = $listID; unset($listID); $listID = array($catid); } $listIDs = "'" . implode("','", $listID) . "'"; $keyNames = array_keys($post); $total = count($post); $setUpdates = ''; for ($i = 0; $i < $total; $i++) { $keyName = $keyNames[$i]; $setUpdates .= "{$keyName}='{$post[$keyName]}', "; } $setUpdates = substr($setUpdates, 0, strlen($setUpdates) - 2); $whereQuery = isset($whereQuery[5]) ? $whereQuery : "groupid in ({$listIDs})"; $addWhere = isset($addWhere[5]) ? $addWhere : ""; $prefix = ''; $prefixall = Database::isPrefixAll(); if ($prefixall != false || $prefixall == 'no') { $prefix = Database::getPrefix(); } Database::query("update " . $prefix . "usergroups set {$setUpdates} where {$whereQuery} {$addWhere}"); // DBCache::removeDir('system/usergroup'); // DBCache::removeCache($listIDs,'system/usergroup'); if (!($error = Database::hasError())) { $loadData = self::get(array('where' => "where groupid IN ({$listIDs})")); $total = count($loadData); for ($i = 0; $i < $total; $i++) { $loadData[$i]['groupdata'] = self::lineToArray($loadData[$i]['groupdata']); Cache::saveKey($prefix . 'userGroup_' . $loadData[$i]['groupid'], serialize($loadData[$i])); } return true; } return false; }
public static function update($listID, $post = array(), $whereQuery = '', $addWhere = '') { if (is_numeric($listID)) { $catid = $listID; unset($listID); $listID = array($catid); } $listIDs = "'" . implode("','", $listID) . "'"; $keyNames = array_keys($post); $total = count($post); $setUpdates = ''; for ($i = 0; $i < $total; $i++) { $keyName = $keyNames[$i]; $setUpdates .= "{$keyName}='{$post[$keyName]}', "; } $setUpdates = substr($setUpdates, 0, strlen($setUpdates) - 2); $whereQuery = isset($whereQuery[5]) ? $whereQuery : "userid in ({$listIDs})"; $addWhere = isset($addWhere[5]) ? $addWhere : ""; $prefix = ''; $prefixall = Database::isPrefixAll(); if ($prefixall != false || $prefixall == 'no') { $prefix = Database::getPrefix(); } Database::query("update " . $prefix . "users set {$setUpdates} where {$whereQuery} {$addWhere}"); // DBCache::removeDir('system/user'); DBCache::removeCache($listIDs, 'system/user'); if (!($error = Database::hasError())) { return true; } return false; }
public function profile() { $post = array('alert' => ''); $match = Uri::match('\\/profile$'); $userid = Users::getCookieUserId(); if (Request::has('btnSave')) { try { updateProcess($userid); $post['alert'] = '<div class="alert alert-success">Save changes success.</div>'; } catch (Exception $e) { $post['alert'] = '<div class="alert alert-warning">' . $e->getMessage() . '</div>'; } } if (Request::has('btnChangePassword')) { Users::changePassword($userid, Request::get('password', '')); } $prefix = ''; $prefixall = Database::isPrefixAll(); if ($prefixall != false || $prefixall == 'no') { $prefix = Database::getPrefix(); } $loadData = Users::get(array('query' => "select u.*,ug.*,a.* from " . $prefix . "users u," . $prefix . "usergroups ug," . $prefix . "address a where u.groupid=ug.groupid AND u.userid=a.userid AND u.userid='{$userid}' order by u.userid desc")); $post['edit'] = $loadData[0]; $post['listGroups'] = UserGroups::get(); System::setTitle('Profile - ' . ADMINCP_TITLE); View::make('admincp/head'); self::makeContents('userEdit', $post); View::make('admincp/footer'); }