本文整理汇总了PHP中DBUtil::updateObject方法的典型用法代码示例。如果您正苦于以下问题:PHP DBUtil::updateObject方法的具体用法?PHP DBUtil::updateObject怎么用?PHP DBUtil::updateObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBUtil
的用法示例。
在下文中一共展示了DBUtil::updateObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setstatus
/**
* 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));
}
示例2: mediashare_adminapi_setTemplateGlobally
/**
* Set plugins
*/
function mediashare_adminapi_setTemplateGlobally($args)
{
$dom = ZLanguage::getModuleDomain('mediashare');
$new = array('template' => DataUtil::formatForStore($args['template']));
if (!DBUtil::updateObject($new, 'mediashare_albums', '1=1', 'id')) {
return LogUtil::registerError(__f('Error in %1$s: %2$s.', array('adminapi.setTemplateGlobally', 'Could not set the template.'), $dom));
}
return true;
}
示例3: resetagreement
/**
* Reset the agreement to the terms of use for a specific group of users, or all users.
*
* Parameters passed in the $args array:
* -------------------------------------
* int $args['gid'] The group id; -1 = none, 0 = all groups.
*
* @param array $args All arguments passed to the function.
*
* @return bool True if successfully reset, otherwise false.
*
* @throws Zikula_Exception_Forbidden Thrown if the user does not have the appropriate access level for the function.
*
* @throws Zikula_Exception_Fatal Thrown in cases where expected data is not present or not in an expected form.
*/
public function resetagreement($args)
{
// Security check
if (!SecurityUtil::checkPermission('legal::', '::', ACCESS_ADMIN)) {
throw new Zikula_Exception_Forbidden();
}
if (!isset($args['gid']) || $args['gid'] == -1) {
throw new Zikula_Exception_Fatal();
}
// Get database setup
$pntable = DBUtil::getTables();
$userscolumn = $pntable['users_column'];
if ($args['gid']==0) {
//all users
// creative usage of DBUtil
$object = array('activated' => 2);
$where = "WHERE $userscolumn[uid] NOT IN (1,2)";
DBUtil::updateObject($object, 'users', $where, 'uid');
} else {
// single group
// get the group incl members
$grp = ModUtil::apiFunc('Groups', 'user', 'get', array('gid' => $args['gid']));
if ($grp==false) {
return false;
}
// remove anonymous from members array
if (array_key_exists(1, $grp['members'])) {
unset($grp['members'][1]);
}
// remove admin from members array
if (array_key_exists(2, $grp['members'])) {
unset($grp['members'][2]);
}
// return if group is empty
if (count($grp['members'])==0) {
return false;
}
$members = '(' . implode(array_keys($grp['members']), ',') . ')';
// creative usage of DBUtil
$object = array('activated' => 2);
$where = "WHERE $userscolumn[uid] IN $members";
DBUtil::updateObject($object, 'users', $where, 'uid');
}
return true;
}
示例4: updateCategory
public function updateCategory($args) {
// Security check
if (!SecurityUtil::checkPermission('IWdocmanager::', "::", ACCESS_ADMIN)) {
throw new Zikula_Exception_Forbidden();
}
$table = DBUtil::getTables();
$c = $table['IWdocmanager_categories_column'];
$where = "$c[categoryId]=$args[categoryId]";
if (!DBUtil::updateObject($args['items'], 'IWdocmanager_categories', $where)) {
return LogUtil::registerError($this->__('Error! Update attempt failed.'));
}
return true;
}
示例5: updatesettings
/**
* update theme settings
*
* @return bool true on success, false otherwise
*/
public function updatesettings($args)
{
// Security check
if (!SecurityUtil::checkPermission('Theme::', '::', ACCESS_ADMIN)) {
return LogUtil::registerPermissionError();
}
// Check our input arguments
if (!isset($args['themeinfo'])) {
return LogUtil::registerArgsError();
}
if (!DBUtil::updateObject($args['themeinfo'], 'themes')) {
return LogUtil::registerError(__('Error! Could not save your changes.'));
}
return true;
}
示例6: EZComments_migrateapi_pnProfile
/**
* Do the migration
*
* With this function, the actual migration is done.
*
* @return boolean true on sucessful migration, false else
*/
function EZComments_migrateapi_pnProfile()
{
if (!SecurityUtil::checkPermission('EZComments::', '::', ACCESS_ADMIN)) {
return LogUtil::registerError('pnProfile comments migration: Not Admin');
}
$columnArray = array('id', 'modname', 'objectid');
$comments = DBUtil::selectObjectArray('EZComments', '', '', -1, -1, '', null, null, $columnArray);
$counter = 0;
foreach ($comments as $comment) {
if ($comment['modname'] == 'pnProfile') {
$comment['modname'] = 'MyProfile';
$comment['url'] = ModUtil::url('MyProfile', 'user', 'display', array('uid' => $comment['objectid']));
$comment['owneruid'] = $comment['objectid'];
if (DBUtil::updateObject($comment, 'EZComments')) {
$counter++;
}
}
}
return LogUtil::registerStatus("Updated / migrated: {$counter} comments from pnProfile to MyProfile, the successor of pnProfile");
}
示例7: uninstall
/**
* Delete the IWTimeFrames module & update existing bookings references
* @author Albert Pérez Monfort (aperezm@xtec.cat)
* @author Josep Ferràndiz Farré (jferran6@xtec.cat)
* @return bool true if successful, false otherwise
*/
public function uninstall() {
// Delete module table
DBUtil::dropTable('IWtimeframes');
DBUtil::dropTable('IWtimeframes_definition');
// Totes les referències als marcs s'han d'esborrar a IWbookings_spaces
// 1r. mirar si existeix el mòdul i després actualitzar els registres
$modid = ModUtil::getIdFromName('IWbookings');
$modinfo = ModUtil::getInfo($modid);
if ($modinfo['state'] > 1) {
$obj = array('mdid' => 0);
DBUtil::updateObject($obj, 'IWbookings_spaces', 'mdid != 0');
}
//Delete module vars
$this->delVar('frames');
//Deletion successfull
return true;
}
示例8: updateUsedSpace
/**
* update the used disk for the user
* @author: Albert Pérez Monfort
* @return: True if success and false otherwise
*/
public function updateUsedSpace()
{
// security check
if (!SecurityUtil::checkPermission('Files::', '::', ACCESS_ADD)) {
return LogUtil::registerPermissionError();
}
// get user used space
$usedSpace = ModUtil::apiFunc('Files', 'user', 'get');
if (!$usedSpace) {
// user row doesn't exists and it is created
ModUtil::apiFunc('Files', 'user', 'createUserFilesInfo');
}
$initFolderPath = ModUtil::func('Files', 'user', 'getInitFolderPath');
$spaceUsed = ModUtil::apiFunc('Files', 'user', 'calcUsedSpace', array('folderToCalc' => $initFolderPath));
$item = array('diskUse' => DataUtil::formatForStore($spaceUsed));
$pntable =& DBUtil::getTables();
$c = $pntable['Files_column'];
$where = "{$c['userId']}=" . UserUtil::getVar('uid');
if (!DBUtil::updateObject($item, 'Files', $where, 'fileId')) {
return LogUtil::registerError($this->__('Error! Could not update the used disk.'));
}
// Let the calling process know that we have finished successfully
return true;
}
示例9: setVar
/**
* The setVar method sets a module variable.
*
* @param string $modname The name of the module.
* @param string $name The name of the variable.
* @param string $value The value of the variable.
*
* @return boolean True if successful, false otherwise.
*/
public static function setVar($modname, $name, $value = '')
{
// define input, all numbers and booleans to strings
$modname = isset($modname) ? (string) $modname : '';
// validate
if (!System::varValidate($modname, 'mod') || !isset($name)) {
return false;
}
$obj = array();
$obj['value'] = serialize($value);
if (self::hasVar($modname, $name)) {
$tables = DBUtil::getTables();
$cols = $tables['module_vars_column'];
$where = "WHERE {$cols['modname']} = '" . DataUtil::formatForStore($modname) . "'\n AND {$cols['name']} = '" . DataUtil::formatForStore($name) . "'";
$res = DBUtil::updateObject($obj, 'module_vars', $where);
} else {
$obj['name'] = $name;
$obj['modname'] = $modname;
$res = DBUtil::insertObject($obj, 'module_vars');
}
if ($res) {
self::$modvars[$modname][$name] = $value;
}
return (bool) $res;
}
示例10: update_company
function update_company()
{
// Confirm the forms authorisation key
$this->checkCsrfToken();
$ot = FormUtil::getPassedValue('ot', 'address', 'GETPOST');
$id = (int) FormUtil::getPassedValue('id', 0, 'GETPOST');
$oldvalue = (int) FormUtil::getPassedValue('oldvalue', 0, 'GETPOST');
$startnum = FormUtil::getPassedValue('startnum', 1, 'GET');
$letter = FormUtil::getPassedValue('letter', 0);
$sort = FormUtil::getPassedValue('sort', ModUtil::getVar('AddressBook', 'addressbooktype') == 1 ? 'sortname ASC' : 'sortcompany ASC');
$search = FormUtil::getPassedValue('search', 0);
$category = FormUtil::getPassedValue('category', 0);
$private = FormUtil::getPassedValue('private', 0);
$url = ModUtil::url('AddressBook', 'user', 'view', array('ot' => $ot, 'startnum' => $startnum, 'letter' => $letter, 'sort' => $sort, 'search' => $search, 'category' => $category, 'private' => $private));
$object = new AddressBook_DBObject_Address();
$data = $object->get($id);
// security check
// Get user id
if (UserUtil::isLoggedIn()) {
$user_id = UserUtil::getVar('uid');
} else {
$user_id = 0;
}
if (!(SecurityUtil::checkPermission('AddressBook::', '::', ACCESS_EDIT) || $user_id == $data['user_id'])) {
return LogUtil::registerPermissionError();
}
$obj = array('company' => $data['company'], 'address1' => $data['address1'], 'address2' => $data['address2'], 'zip' => $data['zip'], 'city' => $data['city'], 'state' => $data['state'], 'country' => $data['country']);
$res = DBUtil::updateObject($obj, 'addressbook_address', '', 'company');
if (!$res) {
LogUtil::registerError($this->__('Error! Company update failed.'));
return System::redirect($url);
}
// clear respective cache
ModUtil::apiFunc('AddressBook', 'user', 'clearItemCache', $data);
LogUtil::registerStatus($this->__('Done! Company update successful.'));
return System::redirect($url);
}
示例11: changePermissions
public function changePermissions($args) {
$gid = FormUtil::getPassedValue('gid', isset($args['gid']) ? $args['gid'] : null, 'GET');
// Security check
if (!SecurityUtil::checkPermission('IWmyrole::', "::", ACCESS_ADMIN)) {
throw new Zikula_Exception_Forbidden();
}
$pntables = DBUtil::getTables();
$column = $pntables['group_perms_column'];
$object = array('gid' => $gid);
$where = "WHERE $column[component] LIKE 'IWmyrole%' AND $column[gid] = " . ModUtil::getVar('IWmyrole', 'rolegroup');
$result = DBUtil::updateObject($object, 'group_perms', $where);
return!(empty($result));
}
示例12: update
/**
* Generic upate handler for an object.
*
* @return array|boolean The Object Data.
*/
public function update()
{
if (!$this->updatePreProcess()) {
return false;
}
$res = DBUtil::updateObject($this->_objData, $this->_objType, '', $this->_objField, $this->_objInsertPreserve);
if ($res) {
$this->updatePostProcess();
return $this->_objData;
}
return false;
}
示例13: update
/**
* Update Ephemeride
* @author The Zikula Development Team
* @param 'args['eid']' item ID
* @return true if success, false otherwise
*/
public function update($args)
{
// Argument check
if (!isset($args['eid']) || !isset($args['did']) || !isset($args['mid']) || !isset($args['yid']) || !isset($args['content']) || !isset($args['language'])) {
return LogUtil::registerArgsError();
}
if (!isset($args['status'])) {
$args['status'] = 1;
}
if (!isset($args['type'])) {
$args['type'] = 1;
}
// get the existing args
$item = ModUtil::apiFunc('Ephemerides', 'user', 'get', array('eid' => $args['eid']));
if (!$item) {
return LogUtil::registerError($this->__('No such Ephemeride found.'));
}
// security check(s)
// check permissions for both the original and modified ephemerides
if (!SecurityUtil::checkPermission('Ephemerides::', "::{$args['eid']}", ACCESS_EDIT)) {
return LogUtil::registerPermissionError();
}
// update the args and check return value for error
$res = DBUtil::updateObject($args, 'ephem', '', 'eid');
if (!$res) {
return LogUtil::registerError($this->__('Error! Ephemeride update failed.'));
}
return true;
}
示例14: update
/**
* update a RSS item
* @param $args['fid'] the ID of the item
* @param $args['feedname'] the new name of the item
* @param $args['number'] the new number of the item
*/
public function update($args)
{
// Argument check
if (!isset($args['fid']) ||
!isset($args['name']) ||
!isset($args['url'])) {
return LogUtil::registerArgsError();
}
// Get the existing feed
$item = ModUtil::apiFunc('Feeds', 'user', 'get', array('fid' => $args['fid']));
if (!$item) {
return LogUtil::registerError($this->__('No such Feed found.'));
}
// Security check
if (!SecurityUtil::checkPermission('Feeds::Item', "$item[name]::$args[fid]", ACCESS_EDIT)) {
return LogUtil::registerPermissionError();
}
if (!SecurityUtil::checkPermission('Feeds::Item', "$args[name]::$args[fid]", ACCESS_EDIT)) {
return LogUtil::registerPermissionError();
}
// check for maximum length to avoid cutting off URLs
if (strlen($args['url'] > 200)) {
return LogUtil::registerError($this->__('The provided URL is too long (200 chars max.).'));
}
// Check for a protocol Magpie RSS (more exactly Snoopy) can handle.
$url_parts = parse_url($args['url']);
if ($url_parts['scheme'] != 'http' && $url_parts['scheme'] != 'https') {
return LogUtil::registerError($this->__('Invalid protocol selected. Only http and https are allowed.'));
}
// define the permalink title if not present
if (!isset($args['urltitle']) || empty($args['urltitle'])) {
$args['urltitle'] = DataUtil::formatPermalink($args['name']);
}
if (!DBUtil::updateObject($args, 'feeds', '', 'fid')) {
return LogUtil::registerError($this->__('Error! Update attempt failed.'));
}
// Let the calling process know that we have finished successfully
return true;
}
示例15: log
/**
* Log search query for search statistics.
*/
public function log($args)
{
$searchterms = DataUtil::formatForStore($args['q']);
$obj = DBUtil::selectObjectByID('search_stat', $searchterms, 'search');
$newobj['count'] = isset($obj['count']) ? $obj['count'] + 1 : 1;
$newobj['date'] = date('Y-m-d H:i:s');
$newobj['search'] = $searchterms;
if (!isset($obj) || empty($obj)) {
$res = DBUtil::insertObject($newobj, 'search_stat');
} else {
$res = DBUtil::updateObject($newobj, 'search_stat', '', 'search');
}
if (!$res) {
return false;
}
return true;
}