/**
  * Delete an account
  *
  * @param integer $account_id the account to delete
  * @return boolean was the account deleted?
  */
 public function delete($accountid)
 {
     if (parent::delete($accountid)) {
         return $this->ldap->delete($accountid);
     }
     return false;
 }
Example #2
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $c = strtolower($this->argument('controller'));
     $files = [];
     $files[] = mkny_models_path($c) . '.php';
     $files[] = mkny_model_config_path($c) . '.php';
     $files[] = mkny_presenters_path($c) . 'Presenter.php';
     $files[] = mkny_controllers_path($c) . 'Controller.php';
     $files[] = mkny_requests_path($c) . 'Request.php';
     $files[] = mkny_lang_path(\App::getLocale() . '/' . $c) . '.php';
     $errors = [];
     foreach ($files as $file) {
         if (!$this->files->exists($file)) {
             $errors[] = $file;
         }
     }
     if (!$this->option('force') && count($errors)) {
         $this->error("Nao foi possivel executar o delete-automatico!\nAlguns arquivos estao ausentes!");
     } else {
         if ($this->option('force') || $this->confirm("Deseja realmente remover os arquivos: \n'" . implode("',\n'", $files))) {
             foreach ($files as $file) {
                 $this->files->delete($file);
             }
             $this->info('Deleted!');
         }
     }
 }
Example #3
0
 /**
  * Test role synchronisation
  */
 public function testRoleSynchronisation()
 {
     // create a first test ACL role
     $query = $this->model->insert()->into('acl_role')->values(['name' => 'test role 1']);
     $statement = $this->model->prepareStatementForSqlObject($query);
     $statement->execute();
     $this->aclRolesIds[] = $this->model->getAdapter()->getDriver()->getLastGeneratedValue();
     // create a test user
     $query = $this->model->insert()->into('user_list')->values(['nick_name' => Rand::getString(32), 'email' => Rand::getString(32), 'role' => $this->aclRolesIds[0]]);
     $statement = $this->model->prepareStatementForSqlObject($query);
     $statement->execute();
     $this->usersIds[] = $this->model->getAdapter()->getDriver()->getLastGeneratedValue();
     // delete the created ACL role
     $query = $this->model->delete()->from('acl_role')->where(['id' => $this->aclRolesIds[0]]);
     $statement = $this->model->prepareStatementForSqlObject($query);
     $statement->execute();
     // fire the delete ACL role event
     AclEvent::fireDeleteAclRoleEvent($this->aclRolesIds[0]);
     // check the created test user's role
     $select = $this->model->select();
     $select->from('user_list')->columns(['role'])->where(['user_id' => $this->usersIds[0]]);
     $statement = $this->model->prepareStatementForSqlObject($select);
     $resultSet = new ResultSet();
     $result = $resultSet->initialize($statement->execute());
     // user must be a default member
     $this->assertEquals($result->current()['role'], AclBaseModel::DEFAULT_ROLE_MEMBER);
 }
Example #4
0
 /**
  * testDelete function
  *
  * @return void
  * @access public
  */
 function testDelete()
 {
     // Without params
     $this->Shell->delete();
     $this->Shell->expectAt(0, 'out', array(new PatternExpectation('/Usage/')));
     // Invalid config
     $this->Shell->args = array('cache_test');
     $this->Shell->delete();
     $this->Shell->expectAt(0, 'err', array(new PatternExpectation('/not found/')));
     $this->Shell->expectCallCount('_stop', 2);
     Cache::config('cache_test', Cache::config('default'));
     // With config
     Cache::write('anything', array('a'), 'cache_test');
     Cache::write('anything2', array('b'), 'cache_test');
     $this->assertTrue(Cache::read('anything', 'cache_test') !== false);
     $this->Shell->args = array('cache_test');
     $this->Shell->delete();
     $this->assertFalse(Cache::read('anything', 'cache_test'));
     // With config
     Cache::write('anything', array('a'), 'cache_test');
     Cache::write('anything2', array('b'), 'cache_test');
     $this->assertTrue(Cache::read('anything', 'cache_test') !== false);
     $this->Shell->args = array('cache_test', 'anything');
     $this->Shell->delete();
     $this->assertFalse(Cache::read('anything', 'cache_test'));
     $this->assertTrue(Cache::read('anything2', 'cache_test') !== false);
 }
 /**
  * Tear down
  */
 protected function tearDown()
 {
     // delete a test user
     if ($this->userIds) {
         $query = $this->model->delete()->from('user_list')->where([new InPredicate('user_id', $this->userIds)]);
         $statement = $this->model->prepareStatementForSqlObject($query);
         $statement->execute();
         $this->userIds = [];
     }
 }
 /**
  * Tear down
  */
 protected function tearDown()
 {
     // clear test settings
     if ($this->settingsNames) {
         $query = $this->settingModel->delete()->from('application_setting')->where(['name' => $this->settingsNames]);
         $statement = $this->settingModel->prepareStatementForSqlObject($query);
         $statement->execute();
         $this->settingsNames = [];
     }
 }
Example #7
0
 /**
  * Open haystack, find and replace needles, save haystack
  * @param  string $oldFile The haystack
  * @param  mixed  $search  String or array to look for (the needles)
  * @param  mixed  $replace What to replace the needles for?
  * @param  string $newFile Where to save, defaults to $oldFile
  * @param  boolean $deleteOldFile Whether to delete $oldFile or not
  * @return void
  */
 public function replaceAndSave($oldFile, $search, $replace, $newFile = null, $deleteOldFile = false)
 {
     $newFile = $newFile === null ? $oldFile : $newFile;
     $file = $this->files->get($oldFile);
     $replacing = str_replace($search, $replace, $file);
     $this->files->put($newFile, $replacing);
     if ($deleteOldFile) {
         $this->files->delete($oldFile);
     }
 }
Example #8
0
 /**
  * Deletes an item out of the cache, or multiple items
  *
  * @param string|array $key
  * @return int
  */
 public function delete($key)
 {
     $delCount = 0;
     foreach (array_filter((array) $key) as $cacheKey) {
         if ($this->memcached->delete($key)) {
             ++$delCount;
         }
     }
     return $delCount;
 }
 /**
  * 删除文章评论
  *
  * @access public
  */
 public function delete()
 {
     if (!($id = Request::input('id'))) {
         return responseJson(Lang::get('common.action_error'));
     }
     $id = array_map('intval', (array) $id);
     $comment = $this->commentModel->getCommentInIds($id);
     if ($this->commentProcess->delete($id)) {
         $this->setActionLog(['comment' => $comment]);
         return responseJson(Lang::get('common.action_success'), true);
     }
     return responseJson($this->commentProcess->getErrorMessage());
 }
 /**
  * 删除文章分类
  *
  * @access public
  */
 public function delete()
 {
     if (!($id = Request::input('id'))) {
         return responseJson(Lang::get('common.action_error'));
     }
     if (!is_array($id)) {
         $id = array($id);
     }
     $id = array_map('intval', $id);
     if ($this->tagProcess->delete($id)) {
         $this->setActionLog(['id' => $id]);
         return responseJson(Lang::get('common.action_success'), true);
     }
     return responseJson($this->tagProcess->getErrorMessage());
 }
Example #11
0
 /**
  * Delete a config from the database
  *
  * @param   object  &$config    reference to a {@link XoopsConfigItem}
  */
 function deleteConfig(&$config)
 {
     if (!$this->_cHandler->delete($config)) {
         return false;
     }
     $options =& $config->getConfOptions();
     $count = count($options);
     if ($count == 0) {
         $options = $this->getConfigOptions(new Criteria('conf_id', $config->getVar('conf_id')));
         $count = count($options);
     }
     if (is_array($options) && $count > 0) {
         for ($i = 0; $i < $count; $i++) {
             $this->_oHandler->delete($options[$i]);
         }
     }
     if (!empty($this->_cachedConfigs[$config->getVar('conf_modid')][$config->getVar('conf_catid')])) {
         unset($this->_cachedConfigs[$config->getVar('conf_modid')][$config->getVar('conf_catid')]);
     }
     xoops_load("cache");
     $key = "config_" . intval($config->getVar('conf_modid')) . "_" . intval($config->getVar('conf_catid'));
     if (XoopsCache::read($key)) {
         XoopsCache::delete($key);
     }
     return true;
 }
 /**
  * Remove payment system object by GUID
  * 
  * @param string $gid system GUID
  * @return void
  */
 public function delete_system_by_gid($gid)
 {
     $this->DB->where("gid", $gid);
     $this->DB->delete(PAYMENTS_SYSTEMS_TABLE);
     unset($this->systems_cache[$gid]);
     return;
 }
Example #13
0
 /**
  * 删除数据
  *
  * @author          liu21st <*****@*****.**>
  * @lastmodify      2013-01-21 15:03:16 by mrmsl
  *
  * @param array $options 参数表达式
  *
  * @return bool true删除成功,否则false
  */
 public function delete($options = array())
 {
     if (empty($options) && empty($this->_options['where'])) {
         if (!empty($this->_data) && isset($this->_data[$v = $this->getPk()])) {
             //如果删除条件为空 则删除当前数据对象所对应的记录
             return $this->delete($this->_data[$v]);
         }
         return false;
     }
     if (is_numeric($options) || is_string($options)) {
         $pk = $this->getPk();
         //根据主键删除记录
         $where[$pk] = strpos($options, ',') ? array('IN', $options) : $options;
         $pk_value = $where[$pk];
         $options = array('where' => $where);
     }
     $options = $this->_parseOptions($options);
     //分析表达式
     $result = $this->_db->delete($options);
     if (false !== $result) {
         $data = array();
         isset($pk_value) && ($data[$pk] = $pk_value);
         $this->_afterDelete($data, $options);
     }
     return $result;
 }
 /**
  * Deletes a cache file based on unique key.
  *
  * @since 6.2.0
  * @param int|string $key
  *            Unique key of cache file.
  * @param string $namespace
  *            Optional. Where the cache contents are namespaced.
  */
 public function delete($key, $namespace = 'default')
 {
     if (empty($namespace)) {
         $namespace = 'default';
     }
     return $this->_cache->delete($key, $namespace);
 }
Example #15
0
 public function delete($table, $cond, array $bind = array())
 {
     if (empty($this->_database)) {
         return false;
     }
     return $this->_database->delete($table, $cond, $bind);
 }
 function testDeleteCommand()
 {
     $id = 123123;
     $pattern = static::$pattern . "\\/" . $id;
     $this->mock->shouldReceive('delete')->once()->with("/" . $pattern . "/");
     $this->resource->delete($id);
 }
Example #17
0
 /**
  * Delete
  * 删除
  *
  * @return void
  */
 public function delete()
 {
     if ($this->pk_id) {
         $this->model->delete($this->pk_id);
         Redirect::success('删除成功');
     }
 }
Example #18
0
 /**
  * Remove data of available method for moderators from data source by identifier
  * 
  * @param integer $method_id method identifier
  * @return void
  */
 public function delete_method($id)
 {
     $this->DB->where("id", $id);
     $this->DB->delete(AUSERS_MODERATE_METHODS_TABLE);
     $this->CI->pg_language->pages->delete_string('ausers_moderation', "method_name_" . $id);
     return;
 }
Example #19
0
 public function actionDel()
 {
     if (Ibos::app()->request->isAjaxRequest) {
         $catid = EnvUtil::getRequest("catid");
         $category = OfficialdocCategory::model()->fetchByPk($catid);
         $supCategoryNum = OfficialdocCategory::model()->countByAttributes(array("pid" => 0));
         if (!empty($category) && $category["pid"] == 0 && $supCategoryNum == 1) {
             $this->ajaxReturn(array("IsSuccess" => false, "msg" => Ibos::lang("Leave at least a Category")), "json");
         }
         $ret = $this->_category->delete($catid);
         if ($ret == -1) {
             $this->ajaxReturn(array("IsSuccess" => false, "msg" => Ibos::lang("Contents under this classification only be deleted when no content")), "json");
         }
         $this->ajaxReturn(array("IsSuccess" => !!$ret), "json");
     }
 }
Example #20
0
 /**
  * Table delete method
  *
  * @param  object   	A KDatabaseRow object
  * @return bool|integer Returns the number of rows updated, or FALSE if insert query was not executed.
  */
 public function delete(KDatabaseRowInterface $row)
 {
     //Create commandchain context
     $context = $this->getCommandContext();
     $context->operation = KDatabase::OPERATION_DELETE;
     $context->table = $this->getBase();
     $context->data = $row;
     $context->query = null;
     if ($this->getCommandChain()->run('before.delete', $context) !== false) {
         $query = $this->_database->getQuery();
         //Create where statement
         foreach ($this->getPrimaryKey() as $key => $column) {
             $query->where($column->name, '=', $context->data->{$key});
         }
         //Execute the delete query
         $context->affected = $this->_database->delete($context->table, $query);
         if ($context->affected !== false) {
             //The delete succeeded
             if ($context->affected > 0) {
                 $context->data->setStatus(KDatabase::STATUS_DELETED);
             }
             //The delete failed
             if ($context->affected <= 0) {
                 $context->data->setStatus(KDatabase::STATUS_FAILED);
             }
             //Set the query in the context
             $context->query = $query;
         }
         $this->getCommandChain()->run('after.delete', $context);
     }
     return $context->affected;
 }
 /**
  * Delete a comment
  *
  * @access	public
  * @param	int			Member ID of user who is attempting to access
  * @param	int			Comment ID to remove
  * @return	mixed		Error string or nothing on success
  */
 public function deleteComment($member_id, $comment_id)
 {
     //-----------------------------------------
     // Load member
     //-----------------------------------------
     $member = IPSMember::load(intval($member_id));
     $comment_id = intval($comment_id);
     //-----------------------------------------
     // Check
     //-----------------------------------------
     if (!$member['member_id']) {
         return 'nopermission';
     }
     //-----------------------------------------
     // Get comment
     //-----------------------------------------
     $comment = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'profile_comments', 'where' => 'comment_id=' . $comment_id));
     //-----------------------------------------
     // Can remove?
     //-----------------------------------------
     if ($member['member_id'] == $this->memberData['member_id'] and $member['member_id'] == $comment['comment_for_member_id'] or $this->memberData['g_is_supmod']) {
         $this->DB->delete('profile_comments', 'comment_id=' . $comment_id);
     } else {
         return 'nopermission';
     }
     return '';
 }
Example #22
0
 /**
  * Will attempt to remove specified keys from the user space cache.
  *
  * @param array $keys Keys to uniquely identify the cached items.
  * @return boolean `true` on successful delete, `false` otherwise.
  */
 public function delete(array $keys)
 {
     if (count($keys) > 1) {
         return $this->connection->deleteMulti($keys);
     }
     return $this->connection->delete(current($keys));
 }
Example #23
0
 /**
  * Remove alert by ID
  * @param integer $id alert ID
  * @param boolean $remove_object
  */
 public function delete_alert($id, $remove_object = false)
 {
     $alert = $this->get_alert_by_id($id, true);
     if (!$alert) {
         return "";
     }
     if ($remove_object && $alert["type"]["module"] && $alert["type"]["model"] && $alert["type"]["callback"]) {
         try {
             $this->CI->load->model($alert["type"]["module"] . "/models/" . $alert["type"]["model"], $alert["type"]["model"], true);
             $error = $this->CI->{$alert["type"]["model"]}->{$alert["type"]["callback"]}("delete", $alert["id_object"]);
         } catch (\Exception $e) {
             $error = $e->getMessage();
         }
         if ($error && $error != "removed") {
             return $error;
         }
     }
     $type = $alert["type"];
     if ($alert["spam_status"] == "none") {
         $save_data["obj_need_approve"] = $type["obj_need_approve"] - 1;
     }
     $save_data["obj_count"] = $type["obj_count"] - 1;
     $this->CI->Spam_type_model->save_type($type['id'], $save_data);
     $this->DB->where("id", $id);
     $this->DB->delete(SPAM_ALERTS_TABLE);
     return "";
 }
Example #24
0
 /**
  * Delete a cookie
  * 
  * @access public
  */
 public function delete()
 {
     setcookie($this->name, '', time() - 60000, $this->domain);
     if ($this->exists()) {
         $this->cookie->delete($_COOKIE[$this->name]);
     }
 }
 function delete($cat_id = '', $entity_id = '', $attrib_id = '', $acl_location = '', $custom_function_id = '', $group_id = '')
 {
     if (!$attrib_id && !$cat_id && $entity_id && !$custom_function_id && !$group_id) {
         $this->so->delete_entity($entity_id);
         execMethod('phpgwapi.menu.clear');
     } else {
         if (!$attrib_id && $cat_id && $entity_id && !$custom_function_id && !$group_id) {
             $this->so->delete_category($entity_id, $cat_id);
             execMethod('phpgwapi.menu.clear');
         } else {
             if ($group_id && $cat_id && $entity_id && !$custom_function_id && !$attrib_id) {
                 $this->custom->delete_group($this->type_app[$this->type], ".{$this->type}.{$entity_id}.{$cat_id}", $group_id);
             } else {
                 if ($attrib_id && $cat_id && $entity_id && !$custom_function_id && !$group_id) {
                     $this->custom->delete($this->type_app[$this->type], ".{$this->type}.{$entity_id}.{$cat_id}", $attrib_id);
                     $this->so->delete_history($entity_id, $cat_id, $attrib_id);
                 } else {
                     if ($custom_function_id && $acl_location) {
                         $GLOBALS['phpgw']->custom_functions->delete($this->type_app[$this->type], $acl_location, $custom_function_id);
                     }
                 }
             }
         }
     }
 }
Example #26
0
    /**
     * Disapprove the post/topic
     */
    public function disapprove($reason_id, $explanation)
    {
        if (!$this->load_source_object() || !$this->is_open() || $this->is_report()) {
            return false;
        }
        $sql = 'SELECT reason_title, reason_description
			FROM ' . REPORTS_REASONS_TABLE . '
			WHERE reason_id = ' . (int) $reason_id;
        $result = phpbb::$db->sql_query($sql);
        $reason = phpbb::$db->sql_fetchrow($result);
        phpbb::$db->sql_freeresult($result);
        if (!$reason || $reason['reason_title'] == 'other' && utf8_clean_string($explanation) == '') {
            return 'reason_empty';
        }
        if ($reason['reason_title'] != 'other') {
            if (isset(phpbb::$user->lang['report_reasons']['DESCRIPTION'][strtoupper($reason['reason_title'])])) {
                $reason['reason_description'] = phpbb::$user->lang['report_reasons']['DESCRIPTION'][strtoupper($reason['reason_title'])];
            }
            // @todo Get description string in poster's language
            $explanation = $reason['reason_description'];
        }
        // Notify poster about disapproval
        $message_vars = array('REASON' => $explanation);
        $this->notify_poster('disapproved', $message_vars);
        // Delete the post
        $this->post->delete();
        return true;
    }
 /**
  * get() method instantiate matched connector object
  *
  * @param string $sConnectorType
  * @param array $aParams
  * @return obj connector abstract type
  */
 public static function get($sConnectorType, array $aParams = null)
 {
     // if valid connector
     if (in_array($sConnectorType, array_keys($GLOBALS[_FPC_MODULE_NAME . '_CONNECTORS']))) {
         // set module URI
         if (!empty($aParams['sURI'])) {
             self::$sModuleURI = $aParams['sURI'];
         }
         // include
         require_once $sConnectorType . '-connect_class.php';
         require_once _FPC_PATH_LIB_COMMON . 'session.class.php';
         // get session object
         self::$oSession = BT_FpcSession::create(array('sPrefix' => _FPC_MODULE_NAME . '_'));
         // check if back URI is set
         if (!empty($aParams['back'])) {
             // delete first
             self::$oSession->delete('back');
             self::$oSession->set('back', $aParams['back']);
         }
         // set class name
         $sClassName = 'BT_' . ucfirst($sConnectorType) . 'Connect';
         // get connector name
         self::$sName = $sConnectorType;
         return new $sClassName($aParams);
     } else {
         throw new BT_ConnectorException(FacebookPsConnect::$oModule->l('Internal server error => invalid connector', 'base-connector_class'), 520);
     }
 }
Example #28
0
 /**
  * Log out a user by removing the related session variables.
  *
  * @param   boolean  $destroy     Completely destroy the session [Optional]
  * @param   boolean  $logout_all  Remove all tokens for user [Optional]
  * @return  boolean
  */
 public function logout($destroy = FALSE, $logout_all = FALSE)
 {
     // Set by force_login()
     $this->_session->delete('auth_forced');
     if ($token = Cookie::get('authautologin')) {
         // Delete the autologin cookie to prevent re-login
         Cookie::delete('authautologin');
         // Clear the autologin token from the database
         $token = ORM::factory('user_token', array('token' => $token));
         if ($token->loaded() and $logout_all) {
             ORM::factory('user_token')->where('user_id', '=', $token->user_id)->delete_all();
         } elseif ($token->loaded()) {
             $token->delete();
         }
     }
     if ($destroy === TRUE) {
         // Destroy the session completely
         $this->_session->destroy();
     } else {
         // Remove the user from the session
         $this->_session->delete($this->_config['session_key']);
         // Regenerate session_id
         $this->_session->regenerate();
     }
     // Double check
     return !$this->logged_in();
 }
Example #29
0
 /**
  * Delete all values from the cache
  *
  * @param boolean $check Optional - only delete expired cache items
  * @return boolean True if the cache was succesfully cleared, false otherwise
  * @access public
  */
 function clear($check)
 {
     if (!$this->__init) {
         return false;
     }
     $dir = dir($this->settings['path']);
     if ($check) {
         $now = time();
         $threshold = $now - $this->settings['duration'];
     }
     while (($entry = $dir->read()) !== false) {
         if ($this->__setKey($entry) === false) {
             continue;
         }
         if ($check) {
             $mtime = $this->__File->lastChange();
             if ($mtime === false || $mtime > $threshold) {
                 continue;
             }
             $expires = $this->__File->read(11);
             $this->__File->close();
             if ($expires > $now) {
                 continue;
             }
         }
         $this->__File->delete();
     }
     $dir->close();
     return true;
 }
Example #30
0
 /**
  * Deletes the users session by expiring the cookie and removing the
  * entry from the session table.
  */
 function delete_session()
 {
     setcookie($this->cookie_prefix . 'sessionhash', '', time() - 3600);
     setcookie($this->cookie_prefix . 'userid', '', time() - 3600);
     setcookie($this->cookie_prefix . 'password', '', time() - 3600);
     $this->db->delete('session', array('sessionhash' => $this->info['sessionhash']));
 }