/** * delete a reference * * @param $args['pid'] ID of the item * @return bool true on success, false on failure */ public function delete($args) { // Argument check if (!isset($args['pid']) || !is_numeric($args['pid'])) { return LogUtil::registerError($this->__('Error! Could not do what you wanted. Please check your input.')); } // Get the current faq $item = ModUtil::apiFunc('IWwebbox', 'user', 'get', array('pid' => $args['pid'])); if (!$item) { return LogUtil::registerError($this->__('No such item found.')); } // Security check if (!SecurityUtil::checkPermission('IWwebbox::', "$args[pid]::", ACCESS_DELETE)) { return LogUtil::registerPermissionError(); } if (!DBUtil::deleteObjectByID('IWwebbox', $args['pid'], 'pid')) { return LogUtil::registerError($this->__('Error! Sorry! Deletion attempt failed.')); } // Let any hooks know that we have deleted an item ModUtil::callHooks('item', 'delete', $args['pid'], array('module' => 'IWwebbox')); // The item has been deleted, so we clear all cached pages of this item. $view = Zikula_View::getInstance('IWwebbox'); $view->clear_cache(null, $args['pid']); return true; }
/** * initialise module */ public function install() { if (!DBUtil::createTable('categories_category')) { return false; } // Create the index if (!DBUtil::createIndex('idx_categories_parent', 'categories_category', 'parent_id') || !DBUtil::createIndex('idx_categories_is_leaf', 'categories_category', 'is_leaf') || !DBUtil::createIndex('idx_categories_name', 'categories_category', 'name') || !DBUtil::createIndex('idx_categories_ipath', 'categories_category', array('ipath', 'is_leaf', 'status')) || !DBUtil::createIndex('idx_categories_status', 'categories_category', 'status') || !DBUtil::createIndex('idx_categories_ipath_status', 'categories_category', array('ipath', 'status'))) { return false; } $this->insertData_10(); // Set autonumber to 10000 (for DB's that support autonumber fields) $cat = array('id' => 9999, 'parent_id' => 1, 'is_locked' => 0, 'is_leaf' => 0, 'name' => '', 'value' => '', 'sort_value' => 0, 'display_name' => '', 'display_desc' => '', 'path' => '', 'ipath' => '', 'status' => ''); DBUtil::insertObject($cat, 'categories_category', 'id', true); // for postgres, we need to explicitly set the sequence value to reflect the inserted data $dbDriverName = strtolower(Doctrine_Manager::getInstance()->getCurrentConnection()->getDriverName()); if ($dbDriverName == 'pgsql') { $dbtables = DBUtil::getTables(); $tab = $dbtables['categories_category']; $col = $dbtables['categories_category_column']; $seq = $tab . '_cat_id_seq'; $sql = "SELECT setval('{$seq}', (SELECT MAX({$col['id']}) + 1 FROM {$tab}))"; DBUtil::executeSQL($sql); } DBUtil::deleteObjectByID('categories_category', 9999, 'id'); $this->createTables_101(); $this->setVar('userrootcat', '/__SYSTEM__/Users'); $this->setVar('allowusercatedit', 0); $this->setVar('autocreateusercat', 0); $this->setVar('autocreateuserdefaultcat', 0); $this->setVar('userdefaultcatname', 'Default'); // Initialisation successful return true; }
/** * delete a News item * * @author Mark West * @param $args['sid'] ID of the item * @return bool true on success, false on failure */ public function delete($args) { // Argument check if (!isset($args['sid']) || !is_numeric($args['sid'])) { return LogUtil::registerArgsError(); } // Get the news story $item = ModUtil::apiFunc('News', 'user', 'get', array('sid' => $args['sid'])); if ($item == false) { return LogUtil::registerError($this->__('Error! No such article found.')); } $this->throwForbiddenUnless(SecurityUtil::checkPermission('News::', $item['cr_uid'] . '::' . $item['sid'], ACCESS_DELETE), LogUtil::getErrorMsgPermission()); if (!DBUtil::deleteObjectByID('news', $args['sid'], 'sid')) { return LogUtil::registerError($this->__('Error! Could not delete article.')); } // delete News images $modvars = $this->getVars(); if ($modvars['picupload_enabled'] && $item['pictures'] > 0) { News_ImageUtil::deleteImagesBySID($modvars['picupload_uploaddir'], $item['sid'], $item['pictures']); } // Let the calling process know that we have finished successfully return true; }
/** * Delete a topic from the database * @author: Albert Pï¿œrez Monfort (aperezm@xtec.cat) * @param: args The id of the topic * @return: true if success and false if fails */ public function esborra($args) { $tid = FormUtil::getPassedValue('tid', isset($args['tid']) ? $args['tid'] : null, 'POST'); // Security check if (!SecurityUtil::checkPermission('IWnoteboard::', '::', ACCESS_ADMIN)) { return LogUtil::registerPermissionError(); } // Argument check if (!isset($tid) || !is_numeric($tid)) { return LogUtil::registerError($this->__('Error! Could not do what you wanted. Please check your input.')); } // Get the item $item = ModUtil::apiFunc('IWnoteboard', 'user', 'gettema', array('tid' => $tid)); if (!$item) { return LogUtil::registerError($this->__('No such item found.')); } if (!DBUtil::deleteObjectByID('IWnoteboard_topics', $tid, 'tid')) { return LogUtil::registerError($this->__('Error! Sorry! Deletion attempt failed.')); } // The item has been deleted, so we clear all cached pages of this item. $view = Zikula_View::getInstance('IWnoteboard'); $view->clear_cache(null, $tid); return true; }
/** * delete an Admin_Messages item * @author Mark West * @param int $args['mid'] ID of the admin message to delete * @return bool true on success, false on failure */ function Admin_Messages_adminapi_delete($args) { $dom = ZLanguage::getModuleDomain('Admin_Messages'); // Argument check if (!isset($args['mid'])) { return LogUtil::registerArgsError(); } // Get the existing admin message $item = ModUtil::apiFunc('Admin_Messages', 'user', 'get', array('mid' => $args['mid'])); if ($item == false) { return LogUtil::registerError(__('Sorry! No such item found.', $dom)); } // Security check if (!SecurityUtil::checkPermission('Admin_Messages::', "{$item['title']}::{$args['mid']}", ACCESS_DELETE)) { return LogUtil::registerPermissionError(); } if (!DBUtil::deleteObjectByID('message', $args['mid'], 'mid')) { return LogUtil::registerError(__('Error! Could not perform the deletion.', $dom)); } // Let any hooks know that we have deleted an item. ModUtil::callHooks('item', 'delete', $args['mid'], array('module' => 'Admin_Messages')); // The item has been modified, so we clear all cached pages of this item. $view = Zikula_View::getInstance('Admin_Messages'); $view->clear_cache(null, UserUtil::getVar('uid')); // Let the calling process know that we have finished successfully return true; }
/** * delete a RSS item * @param $args['fid'] ID of the item * @return bool true on success, false on failure */ public function delete($args) { // Argument check if (!isset($args['fid']) || !is_numeric($args['fid'])) { return LogUtil::registerArgsError(); } // Get the 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_DELETE)) { return LogUtil::registerPermissionError(); } if (!DBUtil::deleteObjectByID('feeds', $args['fid'], 'fid')) { return LogUtil::registerError($this->__('Error! Deletion attempt failed.')); } // Let the calling process know that we have finished successfully return true; }
/** * Delete an item * * @param $args['id'] ID of the item * @return bool true on success, false on failure */ public function delete($args) { // Argument check if (!isset($args['id']) || !is_numeric($args['id'])) { return LogUtil::registerArgsError(); } // The user API function is called. $item = ModUtil::apiFunc('EZComments', 'user', 'get', array('id' => $args['id'])); if (!$item) { return LogUtil::registerError($this->__('No such item found.')); } // Security check $securityCheck = ModUtil::apiFunc('EZComments', 'user', 'checkPermission', array('module' => '', 'objectid' => '', 'commentid' => $args['id'], 'level' => ACCESS_DELETE)); if (!$securityCheck) { return LogUtil::registerPermissionError(ModUtil::url('EZComments', 'admin', 'main')); } // Check for an error with the database code if (!DBUtil::deleteObjectByID('EZComments', (int) $args['id'])) { return LogUtil::registerError($this->__('Error! Deletion attempt failed.')); } // clear respective cache ModUtil::apiFunc('EZComments', 'user', 'clearItemCache', $item); // Let the calling process know that we have finished successfully return true; }
public function deleteCategory($args) { // Security check if (!SecurityUtil::checkPermission('IWdocmanager::', "::", ACCESS_ADMIN)) { throw new Zikula_Exception_Forbidden(); } if (!DBUtil::deleteObjectByID('IWdocmanager_categories', $args['categoryId'], 'categoryId')) { return LogUtil::registerError($this->__('Error! Delete attempt failed.')); } return true; }
/** * Delete Ephemeride * @author The Zikula Development Team * @param 'eid' the id of the ephemerid * @return true if success, false otherwise */ public function delete($args) { // argument check if (!isset($args['eid']) || !is_numeric($args['eid'])) { return LogUtil::registerArgsError(); } // get the existing item $item = ModUtil::apiFunc('Ephemerides', 'user', 'get', array('eid' => $args['eid'])); if (!$item) { return LogUtil::registerError($this->__('No such Ephemeride found.')); } // delete the item and check the return value for error $res = DBUtil::deleteObjectByID('ephem', $args['eid'], 'eid'); if (!$res) { return LogUtil::registerError($this->__('Error! Ephemeride deletion failed.')); } // delete any object category mappings for this item ObjectUtil::deleteObjectCategories($item, 'ephem', 'eid'); return true; }
/** * Changeblockorder. * * @param blockorder array of sorted blocks (value = block id) * @param position int zone id * * @return mixed true or Ajax error */ public function changeblockorder() { $this->checkAjaxToken(); $this->throwForbiddenUnless(SecurityUtil::checkPermission('Blocks::', '::', ACCESS_ADMIN)); $blockorder = $this->request->getPost()->get('blockorder'); $position = $this->request->getPost()->get('position'); // empty block positions for this block zone $res = DBUtil::deleteObjectByID('block_placements', $position, 'pid'); if (!$res) { throw new Zikula_Exception_Fatal($this->__('Error! Could not save your changes.')); } // add new block positions $blockplacements = array(); foreach ((array) $blockorder as $order => $bid) { $blockplacements[] = array('bid' => $bid, 'pid' => $position, 'order' => $order); } if (!empty($blockplacements)) { $res = DBUtil::insertObjectArray($blockplacements, 'block_placements'); if (!$res) { throw new Zikula_Exception_Fatal($this->__('Error! Could not save your changes.')); } } return new Zikula_Response_Ajax(array('result' => true)); }
public function delete_hour($args) { if (!SecurityUtil::checkPermission('IWtimeframes::', "::", ACCESS_ADMIN)) { return LogUtil::registerError($this->__('Not authorized to manage timeFrames.'), 403); } $hid = FormUtil::getPassedValue('hid', isset($args['hid']) ? $args['hid'] : null, 'GET'); //Comprovem que el parï¿œmetre id hagi arribat correctament if (!isset($hid)) { return LogUtil::registerError($this->__('Error! Could not do what you wanted. Please check your input.')); } //Carreguem l'API de l'usuari per carregar les dades del registre if (!ModUtil::loadApi('IWtimeframes', 'user')) { return LogUtil::registerError($this->__('Error! Could not load module.')); } DBUtil::deleteObjectByID('IWtimeframes', $hid, 'hid'); //Retornem true ja que el procï¿œs ha finalitzat amb ï¿œxit return true; }
public function deleteBlock($bid) { // Ensure that $bid is 1 or higher. if (!is_numeric($bid) || $bid < 1) { $this->setError(__('Block ID Invalid')); return false; } // Ensure block exists. if (!BlockUtil::getBlockInfo($bid)) { $this->setError(__('No Such Block Exists')); return false; } // Delete block placements for this block. if (!DBUtil::deleteObjectByID('block_placements', $bid, 'bid')) { $this->setError(__('Block Placements Not Removed')); return false; } // Delete the block itself. if (!DBUtil::deleteObjectByID('blocks', $bid, 'bid')) { $this->setError(__('Block Not Deleted')); return false; } // Let other modules know we have deleted an item. ModUtil::callHooks('item', 'delete', $bid, array('module' => 'Blocks')); // Success. return true; }
public function remove($id) { $this->throwForbiddenUnless(SecurityUtil::checkPermission('Llicencies::', '::', ACCESS_ADMIN)); return DBUtil::deleteObjectByID('llicencies', $id, 'codi_treball'); }
/** * delete a note * @author: Albert Pérez Monfort (aperezm@xtec.cat) * @param: id of the note * @return: An array with the note information */ public function deleteNote($args) { $fmid = (isset($args['fmid'])) ? $args['fmid'] : null; //get the note information $note = ModUtil::apiFunc('IWforms', 'user', 'getNote', array('fmid' => $fmid)); //check user access to this form $access = ModUtil::func('IWforms', 'user', 'access', array('fid' => $note['fid'])); if ($access['level'] < 7) { return LogUtil::registerError($this->__('You do not have access to manage form')); } //Delete the note content if (!DBUtil::deleteObjectByID('IWforms_note', $fmid, 'fmid')) { return LogUtil::registerError($this->__('Error! Sorry! Deletion attempt failed.')); } //Delete the note if (!DBUtil::deleteObjectByID('IWforms', $fmid, 'fmid')) { return LogUtil::registerError($this->__('Error! Sorry! Deletion attempt failed.')); } return true; }
/** * Pre-Process the data prior a delete operation. * The event happens before the entity managers remove operation is executed for this entity. * * Restrictions: * - no access to entity manager or unit of work apis * - will not be called for a DQL DELETE statement * * @see MUVideo_Entity_Movie::preRemoveCallback() * @return boolean true if completed successfully else false. */ protected function performPreRemoveCallback() { // delete workflow for this entity $workflow = $this['__WORKFLOW__']; if ($workflow['id'] > 0) { $result = (bool) DBUtil::deleteObjectByID('workflows', $workflow['id']); if ($result === false) { $dom = ZLanguage::getModuleDomain('MUVideo'); return LogUtil::registerError(__('Error! Could not remove stored workflow. Deletion has been aborted.', $dom)); } } return true; }
/** * {@inheritdoc} */ public function destroy($sessionId) { if (isset($GLOBALS['_ZSession'])) { unset($GLOBALS['_ZSession']); } // expire the cookie setcookie(session_name(), '', 0, ini_get('session.cookie_path')); // ensure we delete the stored session (not a regenerated one) if (isset($GLOBALS['_ZSession']['regenerated']) && $GLOBALS['_ZSession']['regenerated'] == true) { $sessionId = $GLOBALS['_ZSession']['sessid_old']; } else { $sessionId = session_id(); } if (System::getVar('sessionstoretofile')) { $path = DataUtil::formatForOS(session_save_path(), true); return unlink("{$path}/{$sessionId}"); } else { $res = DBUtil::deleteObjectByID('session_info', $sessionId, 'sessid'); return (bool) $res; } }
/** * Regenerate modules list. * * @param array $args All parameters passed to this function. * array $args['filemodules'] An array of modules in the filesystem, as would be returned by * {@link getfilemodules()}; optional, defaults to the results of * $this->getfilemodules(). * * @return boolean True on success, false on failure. */ public function regenerate($args) { // Security check if (!System::isInstalling()) { if (!SecurityUtil::checkPermission('Extensions::', '::', ACCESS_ADMIN)) { return LogUtil::registerPermissionError(); } } // Argument check if (!isset($args['filemodules']) || !is_array($args['filemodules'])) { return LogUtil::registerArgsError(); } // default action $filemodules = $args['filemodules']; $defaults = isset($args['defaults']) ? $args['defaults'] : false; // Get all modules in DB $dbmodules = DBUtil::selectObjectArray('modules', '', '', -1, -1, 'name'); if (!$dbmodules) { return LogUtil::registerError($this->__('Error! Could not load data.')); } // build a list of found modules and dependencies $module_names = array(); $moddependencies = array(); foreach ($filemodules as $modinfo) { $module_names[] = $modinfo['name']; if (isset($modinfo['dependencies']) && !empty($modinfo['dependencies'])) { $moddependencies[$modinfo['name']] = unserialize($modinfo['dependencies']); } } // see if any modules have changed name since last generation foreach ($filemodules as $name => $modinfo) { if (isset($modinfo['oldnames']) || !empty($modinfo['oldnames'])) { $tables = DBUtil::getTables(); foreach ($dbmodules as $dbname => $dbmodinfo) { if (in_array($dbmodinfo['name'], (array) $modinfo['oldnames'])) { // migrate its modvars $cols = $tables['module_vars_column']; $save = array('modname' => $modinfo['name']); DBUtil::updateObject($save, 'module_vars', "{$cols['modname']} = '{$dbname}'"); // rename the module register $save = $dbmodules[$dbname]; $save['name'] = $modinfo['name']; unset($dbmodules[$dbname]); $dbname = $modinfo['name']; $dbmodules[$dbname] = $save; DBUtil::updateObject($dbmodules[$dbname], 'modules'); // rename hooks in the hooks table. $hooksColumns = $tables['hooks_column']; $hooks = DBUtil::selectObjectArray('hooks', "{$hooksColumns['smodule']} = '{$save['name']}'"); if ($hooks) { foreach ($hooks as $hook) { $hook['smodule'] = $dbmodinfo['name']; DBUtil::updateObject($hook, 'hooks'); } } $hooks = DBUtil::selectObjectArray('hooks', "{$hooksColumns['tmodule']} = '{$save['name']}'"); if ($hooks) { foreach ($hooks as $hook) { $hook['tmodule'] = $dbmodinfo['name']; DBUtil::updateObject($hook, 'hooks'); } } DBUtil::deleteObjectByID('hooks', $modinfo['name'], 'tmodule'); } } unset($tables); } if (isset($dbmodules[$name]) && $dbmodules[$name]['state'] > 10) { $dbmodules[$name]['state'] = $dbmodules[$name]['state'] - 20; $this->setState(array('id' => $dbmodules[$name]['id'], 'state' => $dbmodules[$name]['state'])); } if (isset($dbmodules[$name]['id'])) { $modinfo['id'] = $dbmodules[$name]['id']; if ($dbmodules[$name]['state'] != ModUtil::STATE_UNINITIALISED && $dbmodules[$name]['state'] != ModUtil::STATE_INVALID) { unset($modinfo['version']); } if (!$defaults) { unset($modinfo['displayname']); unset($modinfo['description']); unset($modinfo['url']); } DBUtil::updateObject($modinfo, 'modules'); } // check core version is compatible with current $minok = 0; $maxok = 0; // strip any -dev, -rcN etc from version number $coreVersion = preg_replace('#(\\d+\\.\\d+\\.\\d+).*#', '$1', Zikula_Core::VERSION_NUM); if (!empty($filemodules[$name]['core_min'])) { $minok = version_compare($coreVersion, $filemodules[$name]['core_min']); } if (!empty($filemodules[$name]['core_max'])) { $maxok = version_compare($filemodules[$name]['core_max'], $coreVersion); } if ($minok == -1 || $maxok == -1) { $dbmodules[$name]['state'] = $dbmodules[$name]['state'] + 20; $this->setState(array('id' => $dbmodules[$name]['id'], 'state' => $dbmodules[$name]['state'])); } if (isset($dbmodules[$name]['state'])) { $filemodules[$name]['state'] = $dbmodules[$name]['state']; } } // See if we have lost any modules since last generation foreach ($dbmodules as $name => $modinfo) { if (!in_array($name, $module_names)) { $result = DBUtil::selectObjectByID('modules', $name, 'name'); if ($result === false) { return LogUtil::registerError($this->__('Error! Could not load data.')); } if (empty($result)) { die($this->__('Error! Could not retrieve module ID.')); } if ($dbmodules[$name]['state'] == ModUtil::STATE_INVALID) { // module was invalid and now it was removed, delete it $this->remove(array('id' => $dbmodules[$name]['id'])); } elseif ($dbmodules[$name]['state'] == ModUtil::STATE_UNINITIALISED) { // module was uninitialised and subsequently removed, delete it $this->remove(array('id' => $dbmodules[$name]['id'])); } else { // Set state of module to 'missing' $this->setState(array('id' => $result['id'], 'state' => ModUtil::STATE_MISSING)); } unset($dbmodules[$name]); } } // See if we have gained any modules since last generation, // or if any current modules have been upgraded foreach ($filemodules as $name => $modinfo) { if (empty($dbmodules[$name])) { // New module // RNG: set state to invalid if we can't determine an ID $modinfo['state'] = ModUtil::STATE_UNINITIALISED; if (!$modinfo['version']) { $modinfo['state'] = ModUtil::STATE_INVALID; } if ($this->serviceManager['multisites.enabled'] == 1) { // only the main site can regenerate the modules list if ($this->serviceManager['multisites.mainsiteurl'] == FormUtil::getPassedValue('sitedns', null, 'GET') && $this->serviceManager['multisites.based_on_domains'] == 0 || $this->serviceManager['multisites.mainsiteurl'] == $_SERVER['HTTP_HOST'] && $this->serviceManager['multisites.based_on_domains'] == 1) { DBUtil::insertObject($modinfo, 'modules'); } } else { DBUtil::insertObject($modinfo, 'modules'); } } else { // module is in the db already if ($dbmodules[$name]['state'] == ModUtil::STATE_MISSING) { // module was lost, now it is here again $this->setState(array('id' => $dbmodules[$name]['id'], 'state' => ModUtil::STATE_INACTIVE)); } elseif ($dbmodules[$name]['state'] == ModUtil::STATE_INVALID && $modinfo['version']) { // module was invalid, now it is valid $modinfo = array_merge($modinfo, array('id' => $dbmodules[$name]['id'], 'state' => ModUtil::STATE_UNINITIALISED)); DBUtil::updateObject($modinfo, 'modules'); } if ($dbmodules[$name]['version'] != $modinfo['version']) { if ($dbmodules[$name]['state'] != ModUtil::STATE_UNINITIALISED && $dbmodules[$name]['state'] != ModUtil::STATE_INVALID) { $this->setState(array('id' => $dbmodules[$name]['id'], 'state' => ModUtil::STATE_UPGRADED)); } } } } // now clear re-load the dependencies table with all current dependencies DBUtil::truncateTable('module_deps'); // loop round dependences adding the module id - we do this now rather than // earlier since we won't have the id's for new modules at that stage $dependencies = array(); ModUtil::flushCache(); foreach ($moddependencies as $modname => $moddependency) { $modid = ModUtil::getIdFromName($modname); // each module may have multiple dependencies foreach ($moddependency as $dependency) { $dependency['modid'] = $modid; $dependencies[] = $dependency; } } DBUtil::insertObjectArray($dependencies, 'module_deps'); return true; }
/** * Removes expired registrations from the users table. * * @return void */ protected function purgeExpired() { $dbinfo = DBUtil::getTables(); $verifyChgColumn = $dbinfo['users_verifychg_column']; $regExpireDays = $this->getVar('reg_expiredays', 0); if ($regExpireDays > 0) { // Expiration date/times, as with all date/times in the Users module, are stored as UTC. $staleRecordUTC = new DateTime(null, new DateTimeZone('UTC')); $staleRecordUTC->modify("-{$regExpireDays} days"); $staleRecordUTCStr = $staleRecordUTC->format(Users_Constant::DATETIME_FORMAT); // The zero date is there to guard against odd DB errors $where = "WHERE ({$verifyChgColumn['changetype']} = " . Users_Constant::VERIFYCHGTYPE_REGEMAIL .") " . "AND ({$verifyChgColumn['created_dt']} IS NOT NULL) " . "AND ({$verifyChgColumn['created_dt']} != '0000-00-00 00:00:00') " . "AND ({$verifyChgColumn['created_dt']} < '{$staleRecordUTCStr}')"; $staleVerifyChgRecs = DBUtil::selectObjectArray('users_verifychg', $where); if (is_array($staleVerifyChgRecs) && !empty($staleVerifyChgRecs)) { foreach ($staleVerifyChgRecs as $verifyChg) { $registration = UserUtil::getVars($verifyChg['uid'], true, 'uid', true); DBUtil::deleteObjectByID('users', $verifyChg['uid'], 'uid'); ModUtil::apiFunc($this->name, 'user', 'resetVerifyChgFor', array( 'uid' => $verifyChg['uid'], 'changetype'=> Users_Constant::VERIFYCHGTYPE_REGEMAIL, )); $deleteEvent = new Zikula_Event('user.registration.delete', $registration); $this->eventManager->notify($deleteEvent); } } } }
/** * Delete one or more user account records, or mark one or more account records for deletion. * * If records are marked for deletion, they remain in the system and accessible by the system, but are given an * 'activated' status that prevents the user from logging in. Records marked for deletion will not appear on the * regular users list. The delete hook and delete events are not triggered if the records are only marked for * deletion. * * Parameters passed in the $args array: * ------------------------------------- * numeric|array $args['uid'] A single (numeric integer) user id, or an array of user ids to delete. * boolean $args['mark'] If true, then mark for deletion, but do not actually delete. * defaults to false. * * @param array $args All parameters passed to this function. * * @return bool True if successful, false otherwise. */ public function deleteUser($args) { if (!SecurityUtil::checkPermission("{$this->name}::", 'ANY', ACCESS_DELETE)) { return false; } if (!isset($args['uid']) || (!is_numeric($args['uid']) && !is_array($args['uid']))) { $this->registerError("Error! Illegal argument were passed to 'deleteuser'"); return false; } if (isset($args['mark']) && is_bool($args['mark'])) { $markOnly = $args['mark']; } else { $markOnly = false; } // ensure we always have an array if (!is_array($args['uid'])) { $args['uid'] = array($args['uid']); } $curUserUid = UserUtil::getVar('uid'); $userList = array(); foreach ($args['uid'] as $uid) { if (!is_numeric($uid) || ((int)$uid != $uid) || ($uid == $curUserUid)) { return false; } $userObj = UserUtil::getVars($uid); if (!$userObj) { return false; } elseif (!SecurityUtil::checkPermission("{$this->name}::", "{$userObj['uname']}::{$userObj['uid']}", ACCESS_DELETE)) { return false; } $userList[] = $userObj; } foreach ($userList as $userObj) { if ($markOnly) { UserUtil::setVar('activated', Users_Constant::ACTIVATED_PENDING_DELETE, $userObj['uid']); } else { // TODO - This should be in the Groups module, and happen as a result of an event. if (!DBUtil::deleteObjectByID('group_membership', $userObj['uid'], 'uid')) { return false; } ModUtil::apiFunc($this->name, 'admin', 'resetVerifyChgFor', array('uid' => $userObj['uid'])); DBUtil::deleteObjectByID('session_info', $userObj['uid'], 'uid'); if (!DBUtil::deleteObject($userObj, 'users', '', 'uid')) { return false; } // Let other modules know we have deleted an item $deleteEvent = new Zikula_Event('user.account.delete', $userObj); $this->eventManager->notify($deleteEvent); } } return $args['uid']; }
public function deletePageAndSubPageContent($args) { $pageId = (int) $args['pageId']; // Get all content items on this page and all it's sub pages $contentItems = $this->getPageAndSubPageContent(array('pageId' => $pageId)); if ($contentItems === false) { return false; } for ($i = 0, $cou = count($contentItems); $i < $cou; ++$i) { // Make sure content items get a chance to delete themselves $contentItems[$i]['plugin']->delete(); // Delete from DB DBUtil::deleteObjectByID('content_content', $contentItems[$i]['id']); } Content_Util::clearCache(); return true; }
public function del_msg($args) { $fmid = FormUtil::getPassedValue('fmid', isset($args['fmid']) ? $args['fmid'] : null, 'POST'); //$fmid = isset($args['fmid']) ? $args['fmid'] : null; // Security check if (!SecurityUtil::checkPermission('IWforums::', '::', ACCESS_READ)) { return LogUtil::registerPermissionError(); } //check needed values if (!isset($fmid)) { return LogUtil::registerError("Function del_msg: ".$this->__('Error! Could not do what you wanted. Please check your input.')); } //get message //$item = ModUtil::apiFunc('IWforums', 'user', 'get_msg', array('fmid' => $fmid)); $item = ModUtil::apiFunc('IWforums', 'user', 'getMessageInfo', array('fmid' => $fmid)); if ($item == false) { return LogUtil::registerError($this->__('No messages have been found')); } //get forum information $registre = ModUtil::apiFunc('IWforums', 'user', 'get', array('fid' => $item['fid'])); if ($registre == false) { LogUtil::registerError($this->__('The forum upon which the action had to be carried out hasn\'t been found')); return System::redirect(ModUtil::url('IWforums', 'user', 'main')); } //check if user can access the forum $access = ModUtil::func('IWforums', 'user', 'access', array('fid' => $item['fid'])); if ($access < 2) { return LogUtil::registerError($this->__('You can\'t access the forum')); } $moderator = ($access == 4) ? true : false; //Check if user can delete the message if (!$moderator && (time() > $item['data'] + 60 * $registre['msgDelTime'] || $item['usuari'] != UserUtil::getVar('uid'))) { return LogUtil::registerError($this->__('You can\'t access the forum')); } //Delete the note content if (!DBUtil::deleteObjectByID('IWforums_msg', $fmid, 'fmid')) { return LogUtil::registerError($this->__('Error! Sorry! Deletion attempt failed.')); } //Update de last time and user in forum topic $updated = ModUtil::apiFunc('IWforums', 'user', 'updateLast', array('ftids' => array($item['ftid']))); $tema = ModUtil::apiFunc('IWforums', 'user', 'get_tema', array('ftid' => $item['ftid'], 'fid' => $fid)); // If topic has no messages and topic was created by de current user then delete topic if (($tema['last_time']=="") && ($tema['usuari'] == UserUtil::getVar('uid'))) { if (ModUtil::apiFunc('IWforums', 'user', 'deltema', array('ftid' => $ftid, 'fid' => $fid, 'force' => true))){ DBUtil::flushCache('IWforums_temes'); LogUtil::registerStatus($this->__('The empty topic has been deleted.')); } } //success return true; }
/** * Delete the assignament * @author: Albert Pérez Monfort (aperezm@xtec.cat) * @param: args Id of the assignament * @return: true if user exists and false otherwise */ public function delAssignament($args) { $jid = FormUtil::getPassedValue('jid', isset($args['jid']) ? $args['jid'] : null, 'POST'); // Security check if (!SecurityUtil::checkPermission('IWjclic::', "::", ACCESS_ADD)) { throw new Zikula_Exception_Forbidden(); } //get jclic activity $jclic = ModUtil::apiFunc('IWjclic', 'user', 'get', array('jid' => $jid)); if ($jclic == false) { return LogUtil::registerError($this->__('Could not find the allocation requested')); } //Check if user can edit the activity because he/she is the owner or only change the expanded/collapsed status if ($jclic['user'] != UserUtil::getVar('uid')) { return LogUtil::registerError($this->__('You do not have access to edit the activity')); } if (!DBUtil::deleteObjectByID('IWjclic', $jid, 'jid')) { return LogUtil::registerError($this->__('Error! Sorry! Deletion attempt failed.')); } return true; }
function mediashare_editapi_updateAccessSettings($args) { $dom = ZLanguage::getModuleDomain('mediashare'); // First remove existing access entries $result = DBUtil::deleteObjectByID('mediashare_access', (int) $args['albumId'], 'albumId'); if ($result === false) { return LogUtil::registerError(__f('Error in %1$s: %2$s.', array('editapi.updateAccessSettings', 'Could not delete the access registries.'), $dom)); } foreach ((array) $args['access'] as $accessRow) { $access = ($accessRow['accessView'] ? mediashareAccessRequirementView : 0) | ($accessRow['accessEditAlbum'] ? mediashareAccessRequirementEditAlbum : 0) | ($accessRow['accessEditMedia'] ? mediashareAccessRequirementEditMedia : 0) | ($accessRow['accessAddAlbum'] ? mediashareAccessRequirementAddAlbum : 0) | ($accessRow['accessAddMedia'] ? mediashareAccessRequirementAddMedia : 0); $record = array('groupId' => (int) $accessRow['groupId'], 'albumId' => (int) $args['albumId'], 'access' => $access); $result = DBUtil::insertObject($record, 'mediashare_access', 'id'); if ($result === false) { return LogUtil::registerError(__f('Error in %1$s: %2$s.', array('editapi.updateAccessSettings', 'Could not insert the access registry.'), $dom)); } } return true; }
/** * Delete a perm. * * @param string $args ['type'] the type of the permission to update (user or group). * @param int $args ['pid'] the ID of the permission to delete. * * @return boolean true on success, false on failure. */ public function delete($args) { // Security check if (!SecurityUtil::checkPermission('Permissions::', "group::{$args['pid']}", ACCESS_ADMIN)) { return LogUtil::registerPermissionError(); } // Argument check if (!isset($args['pid'])) { return LogUtil::registerArgsError(); } // Work out which tables to operate against $dbtable = DBUtil::getTables(); $permcolumn = $dbtable['group_perms_column']; $where = "WHERE {$permcolumn['pid']} = '" . (int) DataUtil::formatForStore($args['pid']) . "'"; if (!DBUtil::deleteObjectByID('group_perms', $args['pid'], 'pid')) { return LogUtil::registerError($this->__f('Error! Could not delete group permission rule %s.', $args[pid])); } $this->resequence(); return true; }
/** * Delete a meta data object. * * @param array &$obj The object we wish to delete metadata for. * @param string $tablename The object's tablename. * @param string $idcolumn The object's idcolumn (optional) (default='id'). * * @return The result from the metadata insert operation */ public static function deleteObjectMetaData(&$obj, $tablename, $idcolumn = 'id') { self::fixObjectMetaData($obj, $tablename, $idcolumn); if (isset($obj['__META__']['id']) && $obj['__META__']['id']) { $rc = DBUtil::deleteObjectByID($obj['__META__'], 'objectdata_meta'); } elseif (isset($obj['__META__']['idcolumn']) && $obj['__META__']['obj_id']) { $dbtables = DBUtil::getTables(); $meta_column = $dbtables['objectdata_meta_column']; $meta = $obj['__META__']; $where = "WHERE {$meta_column['module']}='" . DataUtil::formatForStore($meta['module']) . "'\n AND {$meta_column['table']}='" . DataUtil::formatForStore($meta['table']) . "'\n AND {$meta_column['idcolumn']}='" . DataUtil::formatForStore($meta['idcolumn']) . "'\n AND {$meta_column['obj_id']}='" . DataUtil::formatForStore($meta['obj_id']) . "'"; $rc = DBUtil::deleteObject(array(), 'objectdata_meta', $where); } $dbtables = DBUtil::getTables(); if (isset($dbtables[$tablename])) { DBUtil::flushCache($tablename); } return (bool) $rc; }
/** * Delete a menu item and all the submenus items associated with it * @author: Albert Pérez Monfort (aperezm@xtec.cat) * @param: args id of the item to delete * @return: True if success */ public function delete($args) { $submenusId = FormUtil::getPassedValue('submenusId', isset($args['submenusId']) ? $args['submenusId'] : null, 'POST'); // Security check if (!SecurityUtil::checkPermission('IWmenu::', '::', ACCESS_ADMIN)) { return LogUtil::registerPermissionError(); } // Needed arguments. if (!isset($submenusId)) { return LogUtil::registerError($this->__('Error! Could not do what you wanted. Please check your input.')); } $submenusId_array = explode(',', $submenusId); foreach ($submenusId_array as $mid) { //Cridem la funció get que retorna les dades $item = ModUtil::apiFunc('IWmenu', 'admin', 'get', array('mid' => $mid)); if (!$item) { return LogUtil::registerError($this->__('No such item found.')); } // Delete the item and check the return value for error if (!DBUtil::deleteObjectByID('IWmenu', $mid, 'mid')) { return LogUtil::registerError($this->__('Error! Sorry! Deletion attempt failed.')); } // Let any hooks know that we have deleted an item. ModUtil::callHooks('item', 'delete', $mid, array('module' => 'IWmenu')); } // Let the calling process know that we have finished successfully return true; }
/** * Delete a block position. * * @param int $args['pid'] ID of the position. * * @return bool true on success, false on failure. */ public function deleteposition($args) { if (!isset($args['pid']) || !is_numeric($args['pid'])) { return LogUtil::registerArgsError(); } $item = ModUtil::apiFunc('Blocks', 'user', 'getposition', array('pid' => $args['pid'])); if ($item == false) { return LogUtil::registerError($this->__('Sorry! No such item found.')); } if (!SecurityUtil::checkPermission('Blocks::position', "{$item['name']}::{$item['pid']}", ACCESS_DELETE)) { return LogUtil::registerPermissionError(); } // Now actually delete the category if (!DBUtil::deleteObjectByID('block_positions', $args['pid'], 'pid')) { return LogUtil::registerError($this->__('Error! Could not perform the deletion.')); } // Let the calling process know that we have finished successfully return true; }
/** * Delete a group item. * * @param int $args['gid'] ID of the item. * * @todo call permissions API to remove group permissions associated with the group * * @return boolean true on success, false on failure. */ public function delete($args) { // Argument check if (!isset($args['gid'])) { return LogUtil::registerArgsError(); } // The user API function is called. $item = ModUtil::apiFunc('Groups', 'user', 'get', array('gid' => $args['gid'])); if ($item == false) { return LogUtil::registerError($this->__('Sorry! No such item found.')); } // Security check if (!SecurityUtil::checkPermission('Groups::', $args['gid'] . '::', ACCESS_DELETE)) { return LogUtil::registerPermissionError(); } // Special groups check $defaultgroupid = $this->getVar('defaultgroup', 0); if ($item['gid'] == $defaultgroupid) { return LogUtil::registerError($this->__('Sorry! You cannot delete the default users group.')); } $primaryadmingroupid = $this->getVar('primaryadmingroup', 0); if ($item['gid'] == $primaryadmingroupid) { return LogUtil::registerError($this->__('Sorry! You cannot delete the primary administrators group.')); } // Delete the item $group_result = DBUtil::deleteObjectByID('groups', $args['gid'], 'gid'); // remove all memberships of this group $groupmembership_result = DBUtil::deleteObjectByID('group_membership', $args['gid'], 'gid'); // Remove any group permissions for this group // TODO: Call the permissions API to do this job $groupperm_result = DBUtil::deleteObjectByID('group_perms', $args['gid'], 'gid'); // Check for an error with the database code if (!$group_result || !$groupmembership_result || !$groupperm_result) { return LogUtil::registerError($this->__('Error! Could not perform the deletion.')); } // Let other modules know that we have deleted a group. $deleteEvent = new Zikula_Event('group.delete', $item); $this->eventManager->notify($deleteEvent); // Let the calling process know that we have finished successfully return true; }
/** * Delete a dynamic user data item. * * Parameters passed in the $args array: * ------------------------------------- * int dudid ID of the item to delete. * * @param array $args All parameters passed to this function. * * @return bool true on success, false on failure */ public function delete($args) { // Argument check if (!isset($args['dudid']) || !is_numeric($args['dudid'])) { return LogUtil::registerArgsError(); } $dudid = $args['dudid']; unset($args); // The user API function is called. $item = ModUtil::apiFunc('Profile', 'user', 'get', array('propid' => $dudid)); if ($item == false) { return LogUtil::registerError($this->__('Error! No such personal info item found.')); } // normal type validation if ((int)$item['prop_dtype'] != 1) { return LogUtil::registerError($this->__('Error! You cannot delete this personal info item.'), 404); } // Security check if (!SecurityUtil::checkPermission('Profile::Item', "$item[prop_label]::$dudid", ACCESS_DELETE)) { return LogUtil::registerPermissionError(); } // delete the property data aka attributes $dbtables = DBUtil::getTables(); $objattr_column = $dbtables['objectdata_attributes_column']; $delwhere = "WHERE $objattr_column[attribute_name] = '" . DataUtil::formatForStore($item['prop_attribute_name']) . "' AND $objattr_column[object_type] = 'users'"; $res = DBUtil::deleteWhere('objectdata_attributes', $delwhere); if (!$res) { return LogUtil::registerError($this->__('Error! Could not delete the personal info item.')); } // delete the property $res = DBUtil::deleteObjectByID('user_property', $dudid, 'prop_id'); if (!$res) { return LogUtil::registerError($this->__('Error! Could not delete the personal info item.')); } // Let the calling process know that we have finished successfully return true; }
public function anulla($args) { $bid = FormUtil::getPassedValue('bid', isset($args['bid']) ? $args['bid'] : null, 'GET'); //Comprovem que el par�metre id efectivament hagi arribat if (!isset($bid)) { LogUtil::registerError($this->__('Error! Could not do what you wanted. Please check your input.')); return false; } //Comprovaci� de seguretat if (!SecurityUtil::checkPermission('IWbookings::', '::', ACCESS_ADMIN)) { LogUtil::registerError($this->__('You are not allowed to administrate the bookings')); return false; } if (!DBUtil::deleteObjectByID('IWbookings', DataUtil::formatForStore($bid), 'bid')) { return false; } else { //Retornem true ja que el proc�s ha finalitzat amb �xit return true; } }